[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cfe-commits
Subject:    Re: [PATCH] PR15614 : -frewrite-includes causes -Wunused-macros false positives
From:       Lubos Lunak <l.lunak () suse ! cz>
Date:       2013-07-28 9:50:25
Message-ID: 201307281150.25916.l.lunak () suse ! cz
[Download RAW message or body]

On Monday 01 of July 2013, Eli Friedman wrote:
> On Sun, Jun 30, 2013 at 12:01 AM, Lubos Lunak <l.lunak@suse.cz> wrote:
> >   Hello,
> >
> >  could somebody please review and commit the atached patch for pr15610
> > (it needs the patch for pr15610 applied first in order to apply cleanly).
> > Thank you.
> >
> > Testcase?

 Updated.

-- 
 Lubos Lunak
 l.lunak@suse.cz

["pr15614.patch" (text/x-diff)]

From c6c972b397f14b261c5350cb45bd94cea6609e7d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= <l.lunak@suse.cz>
Date: Sun, 28 Jul 2013 11:32:55 +0200
Subject: [PATCH] do not emit -Wunused-macros warnings in -frewrite-includes
 mode (PR15614)

-frewrite-includes calls PP.SetMacroExpansionOnlyInDirectives() to avoid
macro expansions that are useless in that mode, but this can lead
to -Wunused-macros false positives. As -frewrite-includes does not emit
normal warnings, block -Wunused-macros too.
---
 lib/Lex/PPDirectives.cpp                  | 3 ++-
 test/Frontend/rewrite-includes-warnings.c | 7 ++++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp
index c70019f..06f7283 100644
--- a/lib/Lex/PPDirectives.cpp
+++ b/lib/Lex/PPDirectives.cpp
@@ -2039,7 +2039,8 @@ void Preprocessor::HandleDefineDirective(Token &DefineTok,
   // warn-because-unused-macro set. If it gets used it will be removed from set.
   if (isInPrimaryFile() && // don't warn for include'd macros.
       Diags->getDiagnosticLevel(diag::pp_macro_not_used,
-          MI->getDefinitionLoc()) != DiagnosticsEngine::Ignored) {
+          MI->getDefinitionLoc()) != DiagnosticsEngine::Ignored &&
+      !MacroExpansionInDirectivesOverride) {
     MI->setIsWarnIfUnused(true);
     WarnUnusedMacroLocs.insert(MI->getDefinitionLoc());
   }
diff --git a/test/Frontend/rewrite-includes-warnings.c b/test/Frontend/rewrite-includes-warnings.c
index 1fb98db..c4f38ed 100644
--- a/test/Frontend/rewrite-includes-warnings.c
+++ b/test/Frontend/rewrite-includes-warnings.c
@@ -1,4 +1,9 @@
-// RUN: %clang_cc1 -verify -Wall -Wextra -E -frewrite-includes %s
+// RUN: %clang_cc1 -verify -Wall -Wextra -Wunused-macros -E -frewrite-includes %s
 // expected-no-diagnostics
 
+// PR14831
 #pragma GCC visibility push (default)
+
+// PR15614
+#define FOO 1
+int foo = FOO;
-- 
1.8.1.4



_______________________________________________
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic