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.

llvm-svn: 128899
This commit is contained in:
Chandler Carruth 2011-04-05 18:18:08 +00:00
parent 895904da51
commit 7a0372023a
1 changed files with 10 additions and 4 deletions

View File

@ -411,8 +411,7 @@ public:
}
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 @@ static void DiagnoseUninitializedUse(Sema &S, const VarDecl *VD,
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 @@ public:
// 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;
}