Fix CPP backend for method attributes by creating a block where a new AttrBuilder...
authorNicolas Geoffray <nicolas.geoffray@lip6.fr>
Fri, 26 Oct 2012 09:14:38 +0000 (09:14 +0000)
committerNicolas Geoffray <nicolas.geoffray@lip6.fr>
Fri, 26 Oct 2012 09:14:38 +0000 (09:14 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166762 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/CppBackend/CPPBackend.cpp

index 61fb4e98ecd804628dd324cc7d732da56817f68e..dd00b7d48bd16171e3cfdf68edc0e4eee16a4670 100644 (file)
@@ -476,11 +476,11 @@ void CppWriter::printAttributes(const AttrListPtr &PAL,
       unsigned index = PAL.getSlot(i).Index;
       AttrBuilder attrs(PAL.getSlot(i).Attrs);
       Out << "PAWI.Index = " << index << "U;\n";
-      Out << "   AttrBuilder B;\n";
+      Out << " {\n    AttrBuilder B;\n";
 
 #define HANDLE_ATTR(X)                                     \
       if (attrs.hasAttribute(Attributes::X))               \
-        Out << "   B.addAttribute(Attributes::" #X ");\n"; \
+        Out << "    B.addAttribute(Attributes::" #X ");\n"; \
       attrs.removeAttribute(Attributes::X);
 
       HANDLE_ATTR(SExt);
@@ -509,11 +509,10 @@ void CppWriter::printAttributes(const AttrListPtr &PAL,
       HANDLE_ATTR(NonLazyBind);
 #undef HANDLE_ATTR
       if (attrs.hasAttribute(Attributes::StackAlignment))
-        Out << "B.addStackAlignmentAttr(" << attrs.getStackAlignment() << ")";
-      nl(Out);
+        Out << "    B.addStackAlignmentAttr(" << attrs.getStackAlignment() << ")\n";
       attrs.removeAttribute(Attributes::StackAlignment);
       assert(!attrs.hasAttributes() && "Unhandled attribute!");
-      Out << "PAWI.Attrs = Attributes::get(mod->getContext(), B);";
+      Out << "    PAWI.Attrs = Attributes::get(mod->getContext(), B);\n }";
       nl(Out);
       Out << "Attrs.push_back(PAWI);";
       nl(Out);