r173768 - Propagate the spelling list index for an attribute across template instantiation.

Richard Smith richard-llvm at metafoo.co.uk
Mon Jan 28 20:21:28 PST 2013


Author: rsmith
Date: Mon Jan 28 22:21:28 2013
New Revision: 173768

URL: http://llvm.org/viewvc/llvm-project?rev=173768&view=rev
Log:
Propagate the spelling list index for an attribute across template instantiation.

Modified:
    cfe/trunk/include/clang/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaDeclAttr.cpp
    cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
    cfe/trunk/test/SemaCXX/cxx11-attr-print.cpp
    cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=173768&r1=173767&r2=173768&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Jan 28 22:21:28 2013
@@ -6527,9 +6527,9 @@ public:
 
   /// AddAlignedAttr - Adds an aligned attribute to a particular declaration.
   void AddAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E,
-                      bool isDeclSpec, unsigned SpellingListIndex = 0);
+                      bool isDeclSpec, unsigned SpellingListIndex);
   void AddAlignedAttr(SourceRange AttrRange, Decl *D, TypeSourceInfo *T,
-                      bool isDeclSpec);
+                      bool isDeclSpec, unsigned SpellingListIndex);
 
   /// \brief The kind of conversion being performed.
   enum CheckedConversionKind {

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=173768&r1=173767&r2=173768&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Mon Jan 28 22:21:28 2013
@@ -3330,11 +3330,11 @@ void Sema::AddAlignedAttr(SourceRange At
 }
 
 void Sema::AddAlignedAttr(SourceRange AttrRange, Decl *D, TypeSourceInfo *TS, 
-                          bool isDeclSpec) {
+                          bool isDeclSpec, unsigned SpellingListIndex) {
   // FIXME: Cache the number on the Attr object if non-dependent?
   // FIXME: Perform checking of type validity
   D->addAttr(::new (Context) AlignedAttr(AttrRange, Context, false, TS, 
-                                         isDeclSpec));
+                                         isDeclSpec, SpellingListIndex));
   return;
 }
 

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=173768&r1=173767&r2=173768&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Mon Jan 28 22:21:28 2013
@@ -80,15 +80,17 @@ void Sema::InstantiateAttrs(const MultiL
                                         TemplateArgs);
           if (!Result.isInvalid())
             AddAlignedAttr(Aligned->getLocation(), New, Result.takeAs<Expr>(), 
-                           Aligned->getIsMSDeclSpec());
+                           Aligned->getIsMSDeclSpec(),
+                           Aligned->getSpellingListIndex());
         } else {
           TypeSourceInfo *Result = SubstType(Aligned->getAlignmentType(),
                                              TemplateArgs,
                                              Aligned->getLocation(),
                                              DeclarationName());
           if (Result)
-            AddAlignedAttr(Aligned->getLocation(), New, Result, 
-                           Aligned->getIsMSDeclSpec());
+            AddAlignedAttr(Aligned->getLocation(), New, Result,
+                           Aligned->getIsMSDeclSpec(),
+                           Aligned->getSpellingListIndex());
         }
         continue;
       }

Modified: cfe/trunk/test/SemaCXX/cxx11-attr-print.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx11-attr-print.cpp?rev=173768&r1=173767&r2=173768&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx11-attr-print.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx11-attr-print.cpp Mon Jan 28 22:21:28 2013
@@ -55,3 +55,24 @@ inline void f7 [[gnu::gnu_inline]] ();
 // arguments printing
 // CHECK: __attribute__((format("printf", 2, 3)));
 void f8 (void *, const char *, ...) __attribute__ ((format (printf, 2, 3)));
+
+// CHECK: int m __attribute__((aligned(4
+// CHECK: int n alignas(4
+// CHECK: static int f() __attribute__((pure))
+// CHECK: static int g() {{\[}}[gnu::pure]]
+template <typename T> struct S {
+  __attribute__((aligned(4))) int m;
+  alignas(4) int n;
+  __attribute__((pure)) static int f() {
+    return 0;
+  }
+  [[gnu::pure]] static int g() {
+    return 1;
+  }
+};
+
+// CHECK: int m __attribute__((aligned(4
+// CHECK: int n alignas(4
+// CHECK: static int f() __attribute__((pure))
+// CHECK: static int g() {{\[}}[gnu::pure]]
+template struct S<int>;

Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=173768&r1=173767&r2=173768&view=diff
==============================================================================
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Mon Jan 28 22:21:28 2013
@@ -937,7 +937,7 @@ void EmitClangAttrImpl(RecordKeeper &Rec
       OS << ", ";
       (*ai)->writeCloneArgs(OS);
     }
-    OS << ");\n}\n\n";
+    OS << ", getSpellingListIndex());\n}\n\n";
 
     writePrettyPrintFunction(R, Args, OS);
   }





More information about the cfe-commits mailing list