[cfe-commits] r134919 - in /cfe/trunk: lib/Lex/PPDirectives.cpp test/Preprocessor/warn-macro-unused.c

Argyrios Kyrtzidis akyrtzi at gmail.com
Mon Jul 11 13:39:47 PDT 2011


Author: akirtzidis
Date: Mon Jul 11 15:39:47 2011
New Revision: 134919

URL: http://llvm.org/viewvc/llvm-project?rev=134919&view=rev
Log:
Don't warn for unused macro when undef'ing it, if it comes from an included file. rdar://9745065

Modified:
    cfe/trunk/lib/Lex/PPDirectives.cpp
    cfe/trunk/test/Preprocessor/warn-macro-unused.c

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=134919&r1=134918&r2=134919&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Mon Jul 11 15:39:47 2011
@@ -1594,7 +1594,7 @@
   // If the macro is not defined, this is a noop undef, just return.
   if (MI == 0) return;
 
-  if (!MI->isUsed())
+  if (!MI->isUsed() && MI->isWarnIfUnused())
     Diag(MI->getDefinitionLoc(), diag::pp_macro_not_used);
 
   // If the callbacks want to know, tell them about the macro #undef.

Modified: cfe/trunk/test/Preprocessor/warn-macro-unused.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/warn-macro-unused.c?rev=134919&r1=134918&r2=134919&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/warn-macro-unused.c (original)
+++ cfe/trunk/test/Preprocessor/warn-macro-unused.c Mon Jul 11 15:39:47 2011
@@ -1,5 +1,10 @@
 // RUN: %clang_cc1 %s -Wunused-macros -Dfoo -Dfoo -verify
 
+#include "warn-macro-unused.h"
+
 #define unused // expected-warning {{macro is not used}}
 #define unused
 unused
+
+// rdar://9745065
+#undef unused_from_header // no warning





More information about the cfe-commits mailing list