]> granicus.if.org Git - clang/commitdiff
Add a Subjects line to NoDebugAttr [NFC].
authorPaul Robinson <paul.robinson@sony.com>
Fri, 29 Apr 2016 17:03:34 +0000 (17:03 +0000)
committerPaul Robinson <paul.robinson@sony.com>
Fri, 29 Apr 2016 17:03:34 +0000 (17:03 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@268065 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/Attr.td
include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaDeclAttr.cpp
test/Sema/attr-nodebug.c
test/SemaObjC/attr-nodebug.m [new file with mode: 0644]

index d5dcdc063543045e98f72fabdd39fe1d9652a3dc..df41aebf457b90932c000764515fafd4274c64f1 100644 (file)
@@ -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];
 }
 
index cd7a7557d073bae61b4f6ca02548591f8fdd5bbf..28612e6c70623e967249720418639daa649579dc 100644 (file)
@@ -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">,
index 9bf5fc9e36d5c350cead8467535d16da75d3039a..cbc95dc643dd3ca94f1e84535fd753538c0a3b22 100644 (file)
@@ -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()));
index 03ec49b850d6f00e55ddf7dcb6fa7b55d0d89b5b..39643bfb70d95049a9906931709d48dc22ad9e26 100644 (file)
@@ -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/test/SemaObjC/attr-nodebug.m b/test/SemaObjC/attr-nodebug.m
new file mode 100644 (file)
index 0000000..7cf8e6c
--- /dev/null
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+@interface NSObject
+- (void)doSomething __attribute__((nodebug));
+@end