diff options
| author | Paul Robinson <paul.robinson@sony.com> | 2016-04-29 17:03:34 +0000 |
|---|---|---|
| committer | Paul Robinson <paul.robinson@sony.com> | 2016-04-29 17:03:34 +0000 |
| commit | e801f6a7f4448be91f7598818af92b3f0ec9f36a (patch) | |
| tree | 9d9e3c5453676fa20db93aa38accf645860cb090 /clang | |
| parent | fa3e04298b65abf1ef34187ab45db8b16329d4bf (diff) | |
| download | bcm5719-llvm-e801f6a7f4448be91f7598818af92b3f0ec9f36a.tar.gz bcm5719-llvm-e801f6a7f4448be91f7598818af92b3f0ec9f36a.zip | |
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
llvm-svn: 268065
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/include/clang/Basic/Attr.td | 2 | ||||
| -rw-r--r-- | clang/include/clang/Basic/DiagnosticSemaKinds.td | 3 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 12 | ||||
| -rw-r--r-- | clang/test/Sema/attr-nodebug.c | 2 | ||||
| -rw-r--r-- | clang/test/SemaObjC/attr-nodebug.m | 5 |
5 files changed, 8 insertions, 16 deletions
diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index d5dcdc06354..df41aebf457 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -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]; } diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index cd7a7557d07..28612e6c706 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -2512,9 +2512,6 @@ def warn_type_attribute_wrong_type : Warning< 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">, diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 9bf5fc9e36d..cbc95dc643d 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -3572,18 +3572,6 @@ void Sema::AddModeAttr(SourceRange AttrRange, Decl *D, IdentifierInfo *Name, } 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())); diff --git a/clang/test/Sema/attr-nodebug.c b/clang/test/Sema/attr-nodebug.c index 03ec49b850d..39643bfb70d 100644 --- a/clang/test/Sema/attr-nodebug.c +++ b/clang/test/Sema/attr-nodebug.c @@ -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)); diff --git a/clang/test/SemaObjC/attr-nodebug.m b/clang/test/SemaObjC/attr-nodebug.m new file mode 100644 index 00000000000..7cf8e6cfbc8 --- /dev/null +++ b/clang/test/SemaObjC/attr-nodebug.m @@ -0,0 +1,5 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// expected-no-diagnostics +@interface NSObject +- (void)doSomething __attribute__((nodebug)); +@end |

