forked from OSchip/llvm-project
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:
parent
895904da51
commit
7a0372023a
|
@ -411,8 +411,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DiagnoseUninitializedUse(Sema &S, const VarDecl *VD,
|
static void DiagnoseUninitializedUse(Sema &S, const VarDecl *VD,
|
||||||
const Expr *E, bool &fixitIssued,
|
const Expr *E, bool isAlwaysUninit) {
|
||||||
bool isAlwaysUninit) {
|
|
||||||
bool isSelfInit = false;
|
bool isSelfInit = false;
|
||||||
|
|
||||||
if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
|
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)
|
S.Diag(VD->getLocStart(), diag::note_uninit_var_def)
|
||||||
<< VD->getDeclName();
|
<< VD->getDeclName();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SuggestInitializationFixit(Sema &S, const VarDecl *VD,
|
||||||
|
bool &fixitIssued) {
|
||||||
// Only report the fixit once.
|
// Only report the fixit once.
|
||||||
if (fixitIssued)
|
if (fixitIssued)
|
||||||
return;
|
return;
|
||||||
|
@ -552,9 +555,12 @@ public:
|
||||||
// a stable ordering.
|
// a stable ordering.
|
||||||
std::sort(vec->begin(), vec->end(), SLocSort());
|
std::sort(vec->begin(), vec->end(), SLocSort());
|
||||||
|
|
||||||
for (UsesVec::iterator vi = vec->begin(), ve = vec->end(); vi != ve; ++vi)
|
for (UsesVec::iterator vi = vec->begin(), ve = vec->end(); vi != ve;
|
||||||
DiagnoseUninitializedUse(S, vd, vi->first, fixitIssued,
|
++vi) {
|
||||||
|
DiagnoseUninitializedUse(S, vd, vi->first,
|
||||||
/*isAlwaysUninit=*/vi->second);
|
/*isAlwaysUninit=*/vi->second);
|
||||||
|
SuggestInitializationFixit(S, vd, fixitIssued);
|
||||||
|
}
|
||||||
|
|
||||||
delete vec;
|
delete vec;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue