[NFC] Remove string parameter of annotation attribute from AST childs.
this simplifies using annotation attributes when using clang as library
This commit is contained in:
parent
d631e5240c
commit
d093401a26
|
@ -740,6 +740,16 @@ def Annotate : InheritableParamAttr {
|
|||
let Args = [StringArgument<"Annotation">, VariadicExprArgument<"Args">];
|
||||
// Ensure that the annotate attribute can be used with
|
||||
// '#pragma clang attribute' even though it has no subject list.
|
||||
let AdditionalMembers = [{
|
||||
static AnnotateAttr *Create(ASTContext &Ctx, llvm::StringRef Annotation, \
|
||||
const AttributeCommonInfo &CommonInfo = {SourceRange{}}) {
|
||||
return AnnotateAttr::Create(Ctx, Annotation, nullptr, 0, CommonInfo);
|
||||
}
|
||||
static AnnotateAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Annotation, \
|
||||
const AttributeCommonInfo &CommonInfo = {SourceRange{}}) {
|
||||
return AnnotateAttr::CreateImplicit(Ctx, Annotation, nullptr, 0, CommonInfo);
|
||||
}
|
||||
}];
|
||||
let PragmaAttributeSupport = 1;
|
||||
let Documentation = [Undocumented];
|
||||
}
|
||||
|
|
|
@ -2391,7 +2391,6 @@ llvm::Constant *CodeGenModule::EmitAnnotationLineNo(SourceLocation L) {
|
|||
|
||||
llvm::Constant *CodeGenModule::EmitAnnotationArgs(const AnnotateAttr *Attr) {
|
||||
ArrayRef<Expr *> Exprs = {Attr->args_begin(), Attr->args_size()};
|
||||
Exprs = Exprs.drop_front();
|
||||
if (Exprs.empty())
|
||||
return llvm::ConstantPointerNull::get(Int8PtrTy);
|
||||
|
||||
|
|
|
@ -3686,7 +3686,7 @@ void Sema::AddAnnotationAttr(Decl *D, const AttributeCommonInfo &CI,
|
|||
StringRef Str, MutableArrayRef<Expr *> Args) {
|
||||
auto *Attr = AnnotateAttr::Create(Context, Str, Args.data(), Args.size(), CI);
|
||||
llvm::SmallVector<PartialDiagnosticAt, 8> Notes;
|
||||
for (unsigned Idx = 1; Idx < Attr->args_size(); Idx++) {
|
||||
for (unsigned Idx = 0; Idx < Attr->args_size(); Idx++) {
|
||||
Expr *&E = Attr->args_begin()[Idx];
|
||||
assert(E && "error are handled before");
|
||||
if (E->isValueDependent() || E->isTypeDependent())
|
||||
|
@ -3718,7 +3718,7 @@ void Sema::AddAnnotationAttr(Decl *D, const AttributeCommonInfo &CI,
|
|||
/// current language mode.
|
||||
if (!Result || !Notes.empty()) {
|
||||
Diag(E->getBeginLoc(), diag::err_attribute_argument_n_type)
|
||||
<< CI << Idx << AANT_ArgumentConstantExpr;
|
||||
<< CI << (Idx + 1) << AANT_ArgumentConstantExpr;
|
||||
for (auto &Note : Notes)
|
||||
Diag(Note.first, Note.second);
|
||||
return;
|
||||
|
@ -3737,8 +3737,8 @@ static void handleAnnotateAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
|
|||
return;
|
||||
|
||||
llvm::SmallVector<Expr *, 4> Args;
|
||||
Args.reserve(AL.getNumArgs());
|
||||
for (unsigned Idx = 0; Idx < AL.getNumArgs(); Idx++) {
|
||||
Args.reserve(AL.getNumArgs() - 1);
|
||||
for (unsigned Idx = 1; Idx < AL.getNumArgs(); Idx++) {
|
||||
assert(!AL.isArgIdent(Idx));
|
||||
Args.push_back(AL.getArgAsExpr(Idx));
|
||||
}
|
||||
|
|
|
@ -252,12 +252,10 @@ int mergeAttrTest() __attribute__((unused,no_thread_safety_analysis));
|
|||
// CHECK-NEXT: DeprecatedAttr{{.*}} Inherited
|
||||
// CHECK-NEXT: WarnUnusedResultAttr{{.*}} Inherited
|
||||
// CHECK-NEXT: AnnotateAttr{{.*}}
|
||||
// CHECK-NEXT: StringLiteral
|
||||
|
||||
// CHECK: FunctionDecl{{.*}} mergeAttrTest
|
||||
// CHECK-NEXT: DeprecatedAttr{{.*}} Inherited
|
||||
// CHECK-NEXT: WarnUnusedResultAttr{{.*}} Inherited
|
||||
// CHECK-NEXT: AnnotateAttr{{.*}} Inherited
|
||||
// CHECK-NEXT: StringLiteral
|
||||
// CHECK-NEXT: UnusedAttr
|
||||
// CHECK-NEXT: NoThreadSafetyAnalysisAttr
|
||||
|
|
|
@ -21,15 +21,11 @@ class testClass2 {
|
|||
// CHECK: CXXMethodDecl{{.*}} testMethod1
|
||||
// CHECK-NEXT: ParmVarDecl{{.*}} param
|
||||
// CHECK-NEXT: AnnotateAttr{{.*}} "test"
|
||||
// CHECK-NEXT: StringLiteral
|
||||
// CHECK-NEXT: AnnotateAttr{{.*}} "test"
|
||||
// CHECK-NEXT: StringLiteral
|
||||
// CHECK-NEXT: CXXConstructorDecl
|
||||
// CHECK-NEXT: AnnotateAttr{{.*}} "test"
|
||||
// CHECK-NEXT: StringLiteral
|
||||
// CHECK-NEXT: CXXMethodDecl{{.*}} operator->
|
||||
// CHECK-NEXT: AnnotateAttr{{.*}} "test"
|
||||
// CHECK-NEXT: StringLiteral
|
||||
|
||||
#pragma clang attribute push (__attribute__((annotate("method"))), apply_to=any(record, field, variable, function, namespace, type_alias))
|
||||
|
||||
|
@ -40,25 +36,19 @@ void testClass2::testMethod1(int param) {
|
|||
// CHECK-LABEL: CXXMethodDecl{{.*}}prev{{.*}} testMethod1
|
||||
// CHECK-NEXT: ParmVarDecl{{.*}} param
|
||||
// CHECK-NEXT: AnnotateAttr{{.*}} "test"
|
||||
// CHECK-NEXT: StringLiteral
|
||||
// CHECK-NEXT: AnnotateAttr{{.*}} "method"
|
||||
// CHECK-NEXT: StringLiteral
|
||||
// CHECK-NEXT: CompoundStmt
|
||||
// CHECK-NEXT: AnnotateAttr{{.*}} "test"
|
||||
// CHECK-NEXT: StringLiteral
|
||||
// CHECK-NEXT: AnnotateAttr{{.*}} "method"
|
||||
// CHECK-NEXT: StringLiteral
|
||||
|
||||
namespace testNamespace {
|
||||
}
|
||||
// CHECK-LABEL: NamespaceDecl{{.*}} testNamespace
|
||||
// CHECK-NEXT: AnnotateAttr{{.*}} "test"
|
||||
// CHECK-NEXT: StringLiteral
|
||||
|
||||
class testClassForward;
|
||||
// CHECK-LABEL: CXXRecordDecl{{.*}} testClassForward
|
||||
// CHECK-NEXT: AnnotateAttr{{.*}} "test"
|
||||
// CHECK-NEXT: StringLiteral
|
||||
|
||||
namespace testNamespaceAlias = testNamespace;
|
||||
// CHECK-LABEL: NamespaceAliasDecl{{.*}} testNamespaceAlias
|
||||
|
@ -78,7 +68,6 @@ void testCatchVariable() {
|
|||
// CHECK: CXXCatchStmt
|
||||
// CHECK-NEXT: VarDecl{{.*}} testCatch
|
||||
// CHECK-NEXT: AnnotateAttr{{.*}} "test"
|
||||
// CHECK-NEXT: StringLiteral
|
||||
|
||||
void testLambdaMethod() {
|
||||
auto l = [] () { };
|
||||
|
@ -90,7 +79,6 @@ void testLambdaMethod() {
|
|||
// CHECK: CXXMethodDecl{{.*}} operator()
|
||||
// CHECK-NEXT: CompoundStmt
|
||||
// CHECK-NEXT: AnnotateAttr{{.*}} "test"
|
||||
// CHECK-NEXT: StringLiteral
|
||||
|
||||
#pragma clang attribute pop
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
// CHECK-LABEL: ObjCInterfaceDecl{{.*}}testInterface1
|
||||
// CHECK-NEXT: ObjCImplementation
|
||||
// CHECK-NEXT: AnnotateAttr{{.*}} "test"
|
||||
// CHECK-NEXT: StringLiteral
|
||||
// CHECK-NEXT: ObjCSubclassingRestrictedAttr{{.*}}
|
||||
|
||||
// CHECK-NOT: AnnotateAttr
|
||||
|
@ -18,29 +17,24 @@
|
|||
int testIvar1;
|
||||
// CHECK-LABEL: ObjCIvarDecl{{.*}} testIvar1
|
||||
// CHECK-NEXT: AnnotateAttr{{.*}} "test"
|
||||
// CHECK-NEXT: StringLiteral
|
||||
// CHECK-NOT: ObjCSubclassingRestrictedAttr
|
||||
}
|
||||
|
||||
@property int testProp1;
|
||||
// CHECK-LABEL: ObjCPropertyDecl{{.*}} testProp1
|
||||
// CHECK-NEXT: AnnotateAttr{{.*}} "test"
|
||||
// CHECK-NEXT: StringLiteral
|
||||
// CHECK-NOT: ObjCSubclassingRestrictedAttr
|
||||
|
||||
- (void)testIm:(int) x;
|
||||
// CHECK-LABEL: ObjCMethodDecl{{.*}}testIm
|
||||
// CHECK-NEXT: ParmVarDecl{{.*}} x
|
||||
// CHECK-NEXT: AnnotateAttr{{.*}} "test"
|
||||
// CHECK-NEXT: StringLiteral
|
||||
// CHECK-NEXT: AnnotateAttr{{.*}} "test"
|
||||
// CHECK-NEXT: StringLiteral
|
||||
// CHECK-NOT: ObjCSubclassingRestrictedAttr
|
||||
|
||||
+ (void)testCm;
|
||||
// CHECK-LABEL: ObjCMethodDecl{{.*}}testCm
|
||||
// CHECK-NEXT: AnnotateAttr{{.*}} "test"
|
||||
// CHECK-NEXT: StringLiteral
|
||||
// CHECK-NOT: ObjCSubclassingRestrictedAttr
|
||||
|
||||
// Implicit getters/setters shouldn't receive the attributes.
|
||||
|
@ -62,7 +56,6 @@
|
|||
int testIvar2;
|
||||
// CHECK-LABEL: ObjCIvarDecl{{.*}} testIvar2
|
||||
// CHECK-NEXT: AnnotateAttr{{.*}} "test"
|
||||
// CHECK-NEXT: StringLiteral
|
||||
// CHECK-NOT: ObjCSubclassingRestrictedAttr
|
||||
}
|
||||
|
||||
|
@ -73,10 +66,8 @@
|
|||
// CHECK-NEXT: ImplicitParamDecl
|
||||
// CHECK-NEXT: ParmVarDecl{{.*}} x
|
||||
// CHECK-NEXT: AnnotateAttr{{.*}} "test"
|
||||
// CHECK-NEXT: StringLiteral
|
||||
// CHECK-NEXT: CompoundStmt
|
||||
// CHECK-NEXT: AnnotateAttr{{.*}} "test"
|
||||
// CHECK-NEXT: StringLiteral
|
||||
// CHECK-NOT: ObjCSubclassingRestrictedAttr
|
||||
}
|
||||
|
||||
|
@ -98,10 +89,8 @@
|
|||
// CHECK-LABEL: ObjCInterfaceDecl{{.*}}testImplWithoutInterface
|
||||
// CHECK-NEXT: ObjCImplementation
|
||||
// CHECK-NEXT: AnnotateAttr{{.*}} "test"
|
||||
// CHECK-NEXT: StringLiteral
|
||||
// CHECK-NEXT: ObjCSubclassingRestrictedAttr
|
||||
// CHECK-NEXT: AnnotateAttr{{.*}} "applied at container start"
|
||||
// CHECK-NEXT: StringLiteral
|
||||
|
||||
// CHECK-LABEL: ObjCImplementationDecl{{.*}}testImplWithoutInterface
|
||||
// CHECK-NOT: AnnotateAttr
|
||||
|
@ -114,14 +103,12 @@
|
|||
@protocol testProtocol
|
||||
// CHECK-LABEL: ObjCProtocolDecl{{.*}}testProtocol
|
||||
// CHECK-NEXT: AnnotateAttr{{.*}} "test"
|
||||
// CHECK-NEXT: StringLiteral
|
||||
// CHECK-NOT: ObjCSubclassingRestrictedAttr
|
||||
// CHECK-NOT: AnnotateAttr
|
||||
|
||||
- (void)testProtIm;
|
||||
// CHECK-LABEL: ObjCMethodDecl{{.*}}testProtIm
|
||||
// CHECK-NEXT: AnnotateAttr{{.*}} "test"
|
||||
// CHECK-NEXT: StringLiteral
|
||||
// CHECK-NOT: ObjCSubclassingRestrictedAttr
|
||||
|
||||
@end
|
||||
|
@ -129,7 +116,6 @@
|
|||
@protocol testForwardProtocol;
|
||||
// CHECK-LABEL: ObjCProtocolDecl{{.*}}testForwardProtocol
|
||||
// CHECK-NEXT: AnnotateAttr{{.*}} "test"
|
||||
// CHECK-NEXT: StringLiteral
|
||||
// CHECK-NOT: ObjCSubclassingRestrictedAttr
|
||||
|
||||
|
||||
|
@ -166,7 +152,6 @@
|
|||
@interface testInterface3
|
||||
// CHECK-LABEL: ObjCInterfaceDecl{{.*}}testInterface3
|
||||
// CHECK-NEXT: AnnotateAttr{{.*}} "test"
|
||||
// CHECK-NEXT: StringLiteral
|
||||
// CHECK-NOT: ObjCSubclassingRestrictedAttr
|
||||
@end
|
||||
|
||||
|
|
Loading…
Reference in New Issue