r199834 - If an attribute has a semantically meaningful spelling (such as ArgumentWithTypeTagAttr or MSInheritanceAttr), display the spelling used for the attribute as part of the AST dump. This should ease debugging the AST for these attributes. Attributes without semantically meaningful spelling variations are not affected.

Aaron Ballman aaron at aaronballman.com
Wed Jan 22 13:51:21 PST 2014


Author: aaronballman
Date: Wed Jan 22 15:51:20 2014
New Revision: 199834

URL: http://llvm.org/viewvc/llvm-project?rev=199834&view=rev
Log:
If an attribute has a semantically meaningful spelling (such as ArgumentWithTypeTagAttr or MSInheritanceAttr), display the spelling used for the attribute as part of the AST dump. This should ease debugging the AST for these attributes. Attributes without semantically meaningful spelling variations are not affected.

Modified:
    cfe/trunk/test/Misc/ast-dump-attr.cpp
    cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/test/Misc/ast-dump-attr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-dump-attr.cpp?rev=199834&r1=199833&r2=199834&view=diff
==============================================================================
--- cfe/trunk/test/Misc/ast-dump-attr.cpp (original)
+++ cfe/trunk/test/Misc/ast-dump-attr.cpp Wed Jan 22 15:51:20 2014
@@ -29,12 +29,12 @@ void TestAttributedStmt() {
 
 int TestAlignedNull __attribute__((aligned));
 // CHECK:      VarDecl{{.*}}TestAlignedNull
-// CHECK-NEXT:   AlignedAttr
+// CHECK-NEXT:   AlignedAttr {{.*}} aligned
 // CHECK-NEXT:     <<<NULL>>>
 
 int TestAlignedExpr __attribute__((aligned(4)));
 // CHECK:      VarDecl{{.*}}TestAlignedExpr
-// CHECK-NEXT:   AlignedAttr
+// CHECK-NEXT:   AlignedAttr {{.*}} aligned
 // CHECK-NEXT:     IntegerLiteral
 
 int TestEnum __attribute__((visibility("default")));
@@ -63,17 +63,17 @@ void function1(void *) {
 void TestIdentifier(void *, int)
 __attribute__((pointer_with_type_tag(ident1,1,2)));
 // CHECK: FunctionDecl{{.*}}TestIdentifier
-// CHECK:   ArgumentWithTypeTagAttr{{.*}} ident1
+// CHECK:   ArgumentWithTypeTagAttr{{.*}} pointer_with_type_tag ident1
 
 void TestBool(void *, int)
 __attribute__((pointer_with_type_tag(bool1,1,2)));
 // CHECK: FunctionDecl{{.*}}TestBool
-// CHECK:   ArgumentWithTypeTagAttr{{.*}} IsPointer
+// CHECK:   ArgumentWithTypeTagAttr{{.*}}pointer_with_type_tag bool1 0 1 IsPointer
 
 void TestUnsigned(void *, int)
 __attribute__((pointer_with_type_tag(unsigned1,1,2)));
 // CHECK: FunctionDecl{{.*}}TestUnsigned
-// CHECK:   ArgumentWithTypeTagAttr{{.*}} 0 1
+// CHECK:   ArgumentWithTypeTagAttr{{.*}} pointer_with_type_tag unsigned1 0 1
 
 void TestInt(void) __attribute__((constructor(123)));
 // CHECK:      FunctionDecl{{.*}}TestInt

Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=199834&r1=199833&r2=199834&view=diff
==============================================================================
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Wed Jan 22 15:51:20 2014
@@ -2482,6 +2482,14 @@ void EmitClangAttrDump(RecordKeeper &Rec
     if (!R.getValueAsBit("ASTNode"))
       continue;
     OS << "  case attr::" << R.getName() << ": {\n";
+
+    // If the attribute has a semantically-meaningful name (which is determined
+    // by whether there is a Spelling enumeration for it), then write out the
+    // spelling used for the attribute.
+    std::vector<Record *> Spellings = R.getValueAsListOfDefs("Spellings");
+    if (Spellings.size() > 1 && !SpellingNamesAreCommon(Spellings))
+      OS << "    OS << \" \" << A->getSpelling();\n";
+
     Args = R.getValueAsListOfDefs("Args");
     if (!Args.empty()) {
       OS << "    const " << R.getName() << "Attr *SA = cast<" << R.getName()





More information about the cfe-commits mailing list