mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-23 05:40:09 +00:00
Fix analyzer crash on 'StructuralValue' (#79764)
`OpaqueValueExpr` doesn't necessarily contain a source expression. Particularly, after #78041, it is used to carry the type and the value kind of a non-type template argument of floating-point type or referring to a subobject (those are so called `StructuralValue` arguments). This fixes #79575. (cherry picked from commit ef67f63fa5f950f4056b5783e92e137342805d74)
This commit is contained in:
parent
692f465456
commit
0eb163cc27
@ -12752,7 +12752,8 @@ namespace {
|
||||
}
|
||||
|
||||
if (OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(E)) {
|
||||
HandleValue(OVE->getSourceExpr());
|
||||
if (Expr *SE = OVE->getSourceExpr())
|
||||
HandleValue(SE);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -40,8 +40,11 @@ static const Expr *ignoreTransparentExprs(const Expr *E) {
|
||||
|
||||
switch (E->getStmtClass()) {
|
||||
case Stmt::OpaqueValueExprClass:
|
||||
E = cast<OpaqueValueExpr>(E)->getSourceExpr();
|
||||
break;
|
||||
if (const Expr *SE = cast<OpaqueValueExpr>(E)->getSourceExpr()) {
|
||||
E = SE;
|
||||
break;
|
||||
}
|
||||
return E;
|
||||
case Stmt::ExprWithCleanupsClass:
|
||||
E = cast<ExprWithCleanups>(E)->getSubExpr();
|
||||
break;
|
||||
@ -98,7 +101,6 @@ SVal Environment::getSVal(const EnvironmentEntry &Entry,
|
||||
case Stmt::CXXBindTemporaryExprClass:
|
||||
case Stmt::ExprWithCleanupsClass:
|
||||
case Stmt::GenericSelectionExprClass:
|
||||
case Stmt::OpaqueValueExprClass:
|
||||
case Stmt::ConstantExprClass:
|
||||
case Stmt::ParenExprClass:
|
||||
case Stmt::SubstNonTypeTemplateParmExprClass:
|
||||
|
@ -68,3 +68,16 @@ namespace rdar13954714 {
|
||||
// force instantiation
|
||||
template void blockWithStatic<true>();
|
||||
}
|
||||
|
||||
namespace structural_value_crash {
|
||||
constexpr char abc[] = "abc";
|
||||
|
||||
template <const char* in>
|
||||
void use_template_param() {
|
||||
const char *p = in;
|
||||
}
|
||||
|
||||
void force_instantiate() {
|
||||
use_template_param<abc>();
|
||||
}
|
||||
}
|
||||
|
@ -354,3 +354,20 @@ namespace ReportedRegression1 {
|
||||
return dummy.exit_code();
|
||||
}
|
||||
}
|
||||
|
||||
namespace ReportedRegression2 {
|
||||
const char str[] = "dummy";
|
||||
|
||||
struct S {
|
||||
S operator+(const char*) const;
|
||||
};
|
||||
|
||||
template <const char* in>
|
||||
void fn() {
|
||||
auto s = S{} + in;
|
||||
}
|
||||
|
||||
void use() {
|
||||
fn<str>();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user