[PATCH] D65371: do not emit -Wunused-macros warnings in -frewrite-includes mode (PR15614)

Luboš Luňák via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 16 12:20:43 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rGa507a5ec8f1d: do not emit -Wunused-macros warnings in -frewrite-includes mode (PR15614) (authored by llunak).

Changed prior to commit:
  https://reviews.llvm.org/D65371?vs=219370&id=220370#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65371/new/

https://reviews.llvm.org/D65371

Files:
  clang/lib/Lex/PPDirectives.cpp
  clang/test/Frontend/rewrite-includes-warnings.c


Index: clang/test/Frontend/rewrite-includes-warnings.c
===================================================================
--- clang/test/Frontend/rewrite-includes-warnings.c
+++ clang/test/Frontend/rewrite-includes-warnings.c
@@ -1,4 +1,7 @@
-// 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
 
 #pragma GCC visibility push (default)
+
+#define USED_MACRO 1
+int test() { return USED_MACRO; }
Index: clang/lib/Lex/PPDirectives.cpp
===================================================================
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -2782,7 +2782,8 @@
   // If we need warning for not using the macro, add its location in the
   // warn-because-unused-macro set. If it gets used it will be removed from set.
   if (getSourceManager().isInMainFile(MI->getDefinitionLoc()) &&
-      !Diags->isIgnored(diag::pp_macro_not_used, MI->getDefinitionLoc())) {
+      !Diags->isIgnored(diag::pp_macro_not_used, MI->getDefinitionLoc()) &&
+      !MacroExpansionInDirectivesOverride) {
     MI->setIsWarnIfUnused(true);
     WarnUnusedMacroLocs.insert(MI->getDefinitionLoc());
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65371.220370.patch
Type: text/x-patch
Size: 1237 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190916/27d9c0bf/attachment-0001.bin>


More information about the cfe-commits mailing list