summaryrefslogtreecommitdiffstats
path: root/clang/test/Misc/ast-dump-attr.cpp
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2013-01-07 17:53:08 +0000
committerAlexander Kornienko <alexfh@google.com>2013-01-07 17:53:08 +0000
commit5bc364eb0587de079a54dc570d20ada46b195b81 (patch)
treeea4a74c9813a2bf8b3ef9e9090765076882ece83 /clang/test/Misc/ast-dump-attr.cpp
parent8a9b6a3681c698dfb64c49f0e44eec19fa94de90 (diff)
downloadbcm5719-llvm-5bc364eb0587de079a54dc570d20ada46b195b81.tar.gz
bcm5719-llvm-5bc364eb0587de079a54dc570d20ada46b195b81.zip
Implement Attr dumping for -ast-dump.
http://llvm-reviews.chandlerc.com/D234 Patch by Philip Craig! llvm-svn: 171760
Diffstat (limited to 'clang/test/Misc/ast-dump-attr.cpp')
-rw-r--r--clang/test/Misc/ast-dump-attr.cpp97
1 files changed, 97 insertions, 0 deletions
diff --git a/clang/test/Misc/ast-dump-attr.cpp b/clang/test/Misc/ast-dump-attr.cpp
new file mode 100644
index 00000000000..57d52b1ce51
--- /dev/null
+++ b/clang/test/Misc/ast-dump-attr.cpp
@@ -0,0 +1,97 @@
+// RUN: %clang_cc1 -std=c++11 -ast-dump -ast-dump-filter Test %s | FileCheck --strict-whitespace %s
+
+int TestLocation
+__attribute__((unused));
+// CHECK: VarDecl{{.*}}TestLocation
+// CHECK-NEXT: UnusedAttr 0x{{[^ ]*}} <line:[[@LINE-2]]:16>
+
+int TestIndent
+__attribute__((unused));
+// CHECK: {{^\(VarDecl.*TestIndent[^()]*$}}
+// CHECK-NEXT: {{^ \(UnusedAttr[^()]*\)\)$}}
+
+void TestAttributedStmt() {
+ switch (1) {
+ case 1:
+ [[clang::fallthrough]];
+ case 2:
+ ;
+ }
+}
+// CHECK: FunctionDecl{{.*}}TestAttributedStmt
+// CHECK: AttributedStmt
+// CHECK-NEXT: FallThroughAttr
+// CHECK-NEXT: NullStmt
+
+[[clang::warn_unused_result]] int TestCXX11DeclAttr();
+// CHECK: FunctionDecl{{.*}}TestCXX11DeclAttr
+// CHECK-NEXT: WarnUnusedResultAttr
+
+int TestAlignedNull __attribute__((aligned));
+// CHECK: VarDecl{{.*}}TestAlignedNull
+// CHECK-NEXT: AlignedAttr
+// CHECK-NEXT: <<<NULL>>>
+
+int TestAlignedExpr __attribute__((aligned(4)));
+// CHECK: VarDecl{{.*}}TestAlignedExpr
+// CHECK-NEXT: AlignedAttr
+// CHECK-NEXT: IntegerLiteral
+
+int TestEnum __attribute__((visibility("default")));
+// CHECK: VarDecl{{.*}}TestEnum
+// CHECK-NEXT: VisibilityAttr{{.*}} Default
+
+class __attribute__((lockable)) Mutex {
+} mu1, mu2;
+int TestExpr __attribute__((guarded_by(mu1)));
+// CHECK: VarDecl{{.*}}TestExpr
+// CHECK-NEXT: GuardedByAttr
+// CHECK-NEXT: DeclRefExpr{{.*}}mu1
+
+class Mutex TestVariadicExpr __attribute__((acquired_after(mu1, mu2)));
+// CHECK: VarDecl{{.*}}TestVariadicExpr
+// CHECK: AcquiredAfterAttr
+// CHECK-NEXT: DeclRefExpr{{.*}}mu1
+// CHECK-NEXT: DeclRefExpr{{.*}}mu2
+
+void function1(void *) {
+ int TestFunction __attribute__((cleanup(function1)));
+}
+// CHECK: VarDecl{{.*}}TestFunction
+// CHECK-NEXT: CleanupAttr{{.*}} Function{{.*}}function1
+
+void TestIdentifier(void *, int)
+__attribute__((pointer_with_type_tag(ident1,1,2)));
+// CHECK: FunctionDecl{{.*}}TestIdentifier
+// CHECK: ArgumentWithTypeTagAttr{{.*}} ident1
+
+void TestBool(void *, int)
+__attribute__((pointer_with_type_tag(bool1,1,2)));
+// CHECK: FunctionDecl{{.*}}TestBool
+// CHECK: ArgumentWithTypeTagAttr{{.*}} IsPointer
+
+void TestUnsigned(void *, int)
+__attribute__((pointer_with_type_tag(unsigned1,1,2)));
+// CHECK: FunctionDecl{{.*}}TestUnsigned
+// CHECK: ArgumentWithTypeTagAttr{{.*}} 0 1
+
+void TestInt(void) __attribute__((constructor(123)));
+// CHECK: FunctionDecl{{.*}}TestInt
+// CHECK-NEXT: ConstructorAttr{{.*}} 123
+
+int TestString __attribute__((alias("alias1")));
+// CHECK: VarDecl{{.*}}TestString
+// CHECK-NEXT: AliasAttr{{.*}} "alias1"
+
+extern struct s1 TestType
+__attribute__((type_tag_for_datatype(ident1,int)));
+// CHECK: VarDecl{{.*}}TestType
+// CHECK-NEXT: TypeTagForDatatypeAttr{{.*}} int
+
+void *TestVariadicUnsigned1(int) __attribute__((alloc_size(1)));
+// CHECK: FunctionDecl{{.*}}TestVariadicUnsigned1
+// CHECK: AllocSizeAttr{{.*}} 0
+
+void *TestVariadicUnsigned2(int, int) __attribute__((alloc_size(1,2)));
+// CHECK: FunctionDecl{{.*}}TestVariadicUnsigned2
+// CHECK: AllocSizeAttr{{.*}} 0 1
OpenPOWER on IntegriCloud