diff options
author | Richard Trieu <rtrieu@google.com> | 2012-05-03 01:09:59 +0000 |
---|---|---|
committer | Richard Trieu <rtrieu@google.com> | 2012-05-03 01:09:59 +0000 |
commit | 2cdcf82396b5e745f153d1503491007a988291df (patch) | |
tree | be342814e75dfa5e6bfe72836e147776431039c3 /clang/lib/Sema/AnalysisBasedWarnings.cpp | |
parent | 78453eed1219b83dff87d34a4bbbe48cc65eda70 (diff) | |
download | bcm5719-llvm-2cdcf82396b5e745f153d1503491007a988291df.tar.gz bcm5719-llvm-2cdcf82396b5e745f153d1503491007a988291df.zip |
Fix a note without a SourceLocation.
#define TEST int y; int x = y;
void foo() {
TEST
}
-Wuninitialized gives this warning:
invalid-loc.cc:4:3: warning: variable 'y' is uninitialized when used here
[-Wuninitialized]
TEST
^~~~
invalid-loc.cc:2:29: note: expanded from macro 'TEST'
#define TEST int y; int x = y;
^
note: initialize the variable 'y' to silence this warning
1 warning generated.
The second note lacks filename, line number, and code snippet. This change
will remove the fixit and only point to variable declaration.
invalid-loc.cc:4:3: warning: variable 'y' is uninitialized when used here
[-Wuninitialized]
TEST
^~~~
invalid-loc.cc:2:29: note: expanded from macro 'TEST'
#define TEST int y; int x = y;
^
invalid-loc.cc:4:3: note: variable 'y' is declared here
TEST
^
invalid-loc.cc:2:14: note: expanded from macro 'TEST'
#define TEST int y; int x = y;
^
1 warning generated.
llvm-svn: 156045
Diffstat (limited to 'clang/lib/Sema/AnalysisBasedWarnings.cpp')
-rw-r--r-- | clang/lib/Sema/AnalysisBasedWarnings.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp b/clang/lib/Sema/AnalysisBasedWarnings.cpp index 02886219285..c3b802e4db4 100644 --- a/clang/lib/Sema/AnalysisBasedWarnings.cpp +++ b/clang/lib/Sema/AnalysisBasedWarnings.cpp @@ -441,6 +441,11 @@ static bool SuggestInitializationFixit(Sema &S, const VarDecl *VD) { std::string Init = S.getFixItZeroInitializerForType(VariableTy); if (Init.empty()) return false; + + // Don't suggest a fixit inside macros. + if (VD->getLocEnd().isMacroID()) + return false; + SourceLocation Loc = S.PP.getLocForEndOfToken(VD->getLocEnd()); S.Diag(Loc, diag::note_var_fixit_add_initialization) << VD->getDeclName() |