Author: probinson Date: Fri Apr 29 12:03:34 2016 New Revision: 268065 URL: http://llvm.org/viewvc/llvm-project?rev=268065&view=rev Log: Add a Subjects line to NoDebugAttr [NFC].
The 'nodebug' attribute had hand-coded constraints; replace those with a Subjects line in Attr.td. Also add a missing test to verify the attribute is okay on an Objective-C method. Differential Revision: http://reviews.llvm.org/D19689 Added: cfe/trunk/test/SemaObjC/attr-nodebug.m Modified: cfe/trunk/include/clang/Basic/Attr.td cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaDeclAttr.cpp cfe/trunk/test/Sema/attr-nodebug.c Modified: cfe/trunk/include/clang/Basic/Attr.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=268065&r1=268064&r2=268065&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/Attr.td (original) +++ cfe/trunk/include/clang/Basic/Attr.td Fri Apr 29 12:03:34 2016 @@ -973,6 +973,8 @@ def NoCommon : InheritableAttr { def NoDebug : InheritableAttr { let Spellings = [GCC<"nodebug">]; + let Subjects = SubjectList<[FunctionLike, ObjCMethod, GlobalVar], WarnDiag, + "ExpectedFunctionGlobalVarMethodOrProperty">; let Documentation = [NoDebugDocs]; } Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=268065&r1=268064&r2=268065&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Apr 29 12:03:34 2016 @@ -2512,9 +2512,6 @@ def warn_type_attribute_wrong_type : War def warn_incomplete_encoded_type : Warning< "encoding of %0 type is incomplete because %1 component has unknown encoding">, InGroup<DiagGroup<"encode-type">>; -def warn_attribute_requires_functions_or_static_globals : Warning< - "%0 only applies to variables with static storage duration and functions">, - InGroup<IgnoredAttributes>; def warn_gnu_inline_attribute_requires_inline : Warning< "'gnu_inline' attribute requires function to be marked 'inline'," " attribute ignored">, Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=268065&r1=268064&r2=268065&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri Apr 29 12:03:34 2016 @@ -3572,18 +3572,6 @@ void Sema::AddModeAttr(SourceRange AttrR } static void handleNoDebugAttr(Sema &S, Decl *D, const AttributeList &Attr) { - if (const VarDecl *VD = dyn_cast<VarDecl>(D)) { - if (!VD->hasGlobalStorage()) - S.Diag(Attr.getLoc(), - diag::warn_attribute_requires_functions_or_static_globals) - << Attr.getName(); - } else if (!isFunctionOrMethod(D)) { - S.Diag(Attr.getLoc(), - diag::warn_attribute_requires_functions_or_static_globals) - << Attr.getName(); - return; - } - D->addAttr(::new (S.Context) NoDebugAttr(Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex())); Modified: cfe/trunk/test/Sema/attr-nodebug.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-nodebug.c?rev=268065&r1=268064&r2=268065&view=diff ============================================================================== --- cfe/trunk/test/Sema/attr-nodebug.c (original) +++ cfe/trunk/test/Sema/attr-nodebug.c Fri Apr 29 12:03:34 2016 @@ -3,7 +3,7 @@ int a __attribute__((nodebug)); void b() { - int b __attribute__((nodebug)); // expected-warning {{'nodebug' only applies to variables with static storage duration and functions}} + int b __attribute__((nodebug)); // expected-warning {{'nodebug' attribute only applies to functions and global variables}} } void t1() __attribute__((nodebug)); Added: cfe/trunk/test/SemaObjC/attr-nodebug.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/attr-nodebug.m?rev=268065&view=auto ============================================================================== --- cfe/trunk/test/SemaObjC/attr-nodebug.m (added) +++ cfe/trunk/test/SemaObjC/attr-nodebug.m Fri Apr 29 12:03:34 2016 @@ -0,0 +1,5 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// expected-no-diagnostics +@interface NSObject +- (void)doSomething __attribute__((nodebug)); +@end _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits