diff options
author | Lubos Lunak <l.lunak@centrum.cz> | 2019-09-16 19:18:37 +0000 |
---|---|---|
committer | Lubos Lunak <l.lunak@centrum.cz> | 2019-09-16 19:18:37 +0000 |
commit | a507a5ec8f1d7ded4a808a8813be1ade08580a7b (patch) | |
tree | 4ff6bac5ea7af28068c8b56947ebf20ee49ec599 | |
parent | 413647d730972eac9675f695c2ea63fb393a5531 (diff) | |
download | bcm5719-llvm-a507a5ec8f1d7ded4a808a8813be1ade08580a7b.tar.gz bcm5719-llvm-a507a5ec8f1d7ded4a808a8813be1ade08580a7b.zip |
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.
Differential Revision: https://reviews.llvm.org/D65371
llvm-svn: 372026
-rw-r--r-- | clang/lib/Lex/PPDirectives.cpp | 3 | ||||
-rw-r--r-- | clang/test/Frontend/rewrite-includes-warnings.c | 5 |
2 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index c4f660f88c7..fe57f37f09a 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -2782,7 +2782,8 @@ void Preprocessor::HandleDefineDirective( // 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()); } diff --git a/clang/test/Frontend/rewrite-includes-warnings.c b/clang/test/Frontend/rewrite-includes-warnings.c index 1fb98db3014..d955f86f826 100644 --- a/clang/test/Frontend/rewrite-includes-warnings.c +++ b/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; } |