[cfe-commits] r128899 - /cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
Chandler Carruth
chandlerc at gmail.com
Tue Apr 5 11:18:08 PDT 2011
Author: chandlerc
Date: Tue Apr 5 13:18:08 2011
New Revision: 128899
URL: http://llvm.org/viewvc/llvm-project?rev=128899&view=rev
Log:
Separate the logic for issuing the initialization fixit hint from the
diagnostic emission. The fixit hint, when suggested, typically has
nothing to do with the nature or form of the reference.
Modified:
cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=128899&r1=128898&r2=128899&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Tue Apr 5 13:18:08 2011
@@ -411,8 +411,7 @@
}
static void DiagnoseUninitializedUse(Sema &S, const VarDecl *VD,
- const Expr *E, bool &fixitIssued,
- bool isAlwaysUninit) {
+ const Expr *E, bool isAlwaysUninit) {
bool isSelfInit = false;
if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
@@ -465,6 +464,10 @@
S.Diag(VD->getLocStart(), diag::note_uninit_var_def)
<< VD->getDeclName();
+}
+
+static void SuggestInitializationFixit(Sema &S, const VarDecl *VD,
+ bool &fixitIssued) {
// Only report the fixit once.
if (fixitIssued)
return;
@@ -552,9 +555,12 @@
// a stable ordering.
std::sort(vec->begin(), vec->end(), SLocSort());
- for (UsesVec::iterator vi = vec->begin(), ve = vec->end(); vi != ve; ++vi)
- DiagnoseUninitializedUse(S, vd, vi->first, fixitIssued,
+ for (UsesVec::iterator vi = vec->begin(), ve = vec->end(); vi != ve;
+ ++vi) {
+ DiagnoseUninitializedUse(S, vd, vi->first,
/*isAlwaysUninit=*/vi->second);
+ SuggestInitializationFixit(S, vd, fixitIssued);
+ }
delete vec;
}
More information about the cfe-commits
mailing list