forked from OSchip/llvm-project
[-Wunreachable-code] include some enum constants in "configuration value" heuristic
llvm-svn: 203026
This commit is contained in:
parent
da3f4fd3fe
commit
01a39b601f
|
@ -376,6 +376,11 @@ static bool isConfigurationValue(const Stmt *S) {
|
|||
S = Ex->IgnoreParenCasts();
|
||||
|
||||
switch (S->getStmtClass()) {
|
||||
case Stmt::DeclRefExprClass: {
|
||||
const DeclRefExpr *DR = cast<DeclRefExpr>(S);
|
||||
const EnumConstantDecl *ED = dyn_cast<EnumConstantDecl>(DR->getDecl());
|
||||
return ED ? isConfigurationValue(ED->getInitExpr()) : false;
|
||||
}
|
||||
case Stmt::IntegerLiteralClass:
|
||||
return isExpandedFromConfigurationMacro(S);
|
||||
case Stmt::UnaryExprOrTypeTraitExprClass:
|
||||
|
|
|
@ -234,3 +234,21 @@ int sizeof_int() {
|
|||
return 2; // no-warning
|
||||
}
|
||||
|
||||
enum MyEnum {
|
||||
ME_A = CONFIG_CONSTANT,
|
||||
ME_B = 1
|
||||
};
|
||||
|
||||
int test_MyEnum() {
|
||||
if (!ME_A)
|
||||
return 1; // no-warning
|
||||
if (ME_A)
|
||||
return 2; // no-warning
|
||||
if (ME_B)
|
||||
return 3;
|
||||
// FIXME: we should only need one diagnostic here.
|
||||
if (!ME_B) // expected-warning {{will never be executed}}
|
||||
return 4;// expected-warning {{will never be executed}}
|
||||
return 5;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue