107 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -fcxx-exceptions %s2// RUN: %clang_cc1 -ast-dump -ast-dump-filter test -std=c++11 -fcxx-exceptions %s | FileCheck %s3// expected-no-diagnostics4 5class testClass1 {6};7// CHECK-LABEL: CXXRecordDecl{{.*}} testClass18// CHECK-NOT: AnnotateAttr9 10#pragma clang attribute push (__attribute__((annotate("test"))), apply_to=any(record, field, variable, function, namespace, type_alias))11 12class testClass2 {13 void testMethod1(int param);14 15 testClass2();16 17 testClass2 *operator -> ();18};19// CHECK-LABEL: CXXRecordDecl{{.*}} testClass220// CHECK: AnnotateAttr{{.*}} "test"21// CHECK: CXXMethodDecl{{.*}} testMethod122// CHECK-NEXT: ParmVarDecl{{.*}} param23// CHECK-NEXT: AnnotateAttr{{.*}} "test"24// CHECK-NEXT: AnnotateAttr{{.*}} "test"25// CHECK-NEXT: CXXConstructorDecl26// CHECK-NEXT: AnnotateAttr{{.*}} "test"27// CHECK-NEXT: CXXMethodDecl{{.*}} operator->28// CHECK-NEXT: AnnotateAttr{{.*}} "test"29 30#pragma clang attribute push (__attribute__((annotate("method"))), apply_to=any(record, field, variable, function, namespace, type_alias))31 32void testClass2::testMethod1(int param) {33 34#pragma clang attribute pop35}36// CHECK-LABEL: CXXMethodDecl{{.*}}prev{{.*}} testMethod137// CHECK-NEXT: ParmVarDecl{{.*}} param38// CHECK-NEXT: AnnotateAttr{{.*}} "test"39// CHECK-NEXT: AnnotateAttr{{.*}} "method"40// CHECK-NEXT: CompoundStmt41// CHECK-NEXT: AnnotateAttr{{.*}} "test"42// CHECK-NEXT: AnnotateAttr{{.*}} "method"43 44namespace testNamespace {45}46// CHECK-LABEL: NamespaceDecl{{.*}} testNamespace47// CHECK-NEXT: AnnotateAttr{{.*}} "test"48 49class testClassForward;50// CHECK-LABEL: CXXRecordDecl{{.*}} testClassForward51// CHECK-NEXT: AnnotateAttr{{.*}} "test"52 53namespace testNamespaceAlias = testNamespace;54// CHECK-LABEL: NamespaceAliasDecl{{.*}} testNamespaceAlias55// CHECK-NOT: AnnotateAttr56 57using testTypeAlias = testClass2;58// CHECK-LABEL: TypeAliasDecl{{.*}} testTypeAlias59// CHECK: AnnotateAttr{{.*}} "test"60 61void testCatchVariable() {62 try {63 } catch (int testCatch) {64 }65 testCatchVariable();66}67// CHECK-LABEL: FunctionDecl{{.*}} testCatchVariable68// CHECK: CXXCatchStmt69// CHECK-NEXT: VarDecl{{.*}} testCatch70// CHECK-NEXT: AnnotateAttr{{.*}} "test"71 72void testLambdaMethod() {73 auto l = [] () { };74 testLambdaMethod();75}76// CHECK-LABEL: FunctionDecl{{.*}} testLambdaMethod77// CHECK: LambdaExpr78// CHECK-NEXT: CXXRecordDecl79// CHECK: CXXMethodDecl{{.*}} operator()80// CHECK-NEXT: CompoundStmt81// CHECK-NEXT: AnnotateAttr{{.*}} "test"82 83#pragma clang attribute pop84 85#pragma clang attribute push (__attribute__((require_constant_initialization)), apply_to=variable(is_global))86 87int testCI1 = 1;88// CHECK-LABEL: VarDecl{{.*}} testCI189// CHECK-NEXT: IntegerLiteral90// CHECK-NEXT: ConstInitAttr91 92#pragma clang attribute pop93 94int testNoCI = 0;95// CHECK-LABEL: VarDecl{{.*}} testNoCI96// CHECK-NEXT: IntegerLiteral97// CHECK-NOT: ConstInitAttr98 99// Check support for CXX11 style attributes100#pragma clang attribute push ([[noreturn]], apply_to = function)101 102void testNoReturn();103// CHECK-LABEL: FunctionDecl{{.*}} testNoReturn104// CHECK-NEXT: CXX11NoReturnAttr105 106#pragma clang attribute pop107