aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/AnalysisBasedWarnings.cpp
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2012-05-03 01:09:59 +0000
committerRichard Trieu <rtrieu@google.com>2012-05-03 01:09:59 +0000
commit7b0a3e378c441cec60f929d13bd48846c267a008 (patch)
tree2a3fd8b403a62464aaad4548aeea74592e4493f9 /lib/Sema/AnalysisBasedWarnings.cpp
parent07a075870110a8376ddc1cd09412a0ec00987153 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156045 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/AnalysisBasedWarnings.cpp')
-rw-r--r--lib/Sema/AnalysisBasedWarnings.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/Sema/AnalysisBasedWarnings.cpp b/lib/Sema/AnalysisBasedWarnings.cpp
index 0288621928..c3b802e4db 100644
--- a/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/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()