StmtNodeBuilder Bldr2(PreVisit, Tmp, *currBldrCtx);
const LocationContext *LCtx = Pred->getLocationContext();
- const Expr *ArgE = cast<CXXDefaultArgExpr>(S)->getExpr();
+ const CXXDefaultArgExpr *DefaultE = cast<CXXDefaultArgExpr>(S);
+ const Expr *ArgE = DefaultE->getExpr();
// Avoid creating and destroying a lot of APSInts.
SVal V;
else
V = State->getSVal(ArgE, LCtx);
- State = State->BindExpr(S, LCtx, V);
+ State = State->BindExpr(DefaultE, LCtx, V);
+ if (DefaultE->isGLValue())
+ State = createTemporaryRegionIfNeeded(State, LCtx, DefaultE);
Bldr2.generateNode(S, *I, State);
}
return None;
llvm::APSInt Result;
- if (Init->EvaluateAsInt(Result, Ctx))
+ if (!Init->isGLValue() && Init->EvaluateAsInt(Result, Ctx))
return SVB.makeIntVal(Result);
if (Init->isNullPointerConstant(Ctx, Expr::NPC_ValueDependentIsNotNull))
static id p = foo(1);
clang_analyzer_eval(p == 0); // expected-warning{{TRUE}}
return p;
-}
\ No newline at end of file
+}
+
+const int &globalInt = 42;
+
+void testGlobal() {
+ // FIXME: Should be TRUE, but should at least not crash.
+ clang_analyzer_eval(globalInt == 42); // expected-warning{{UNKNOWN}}
+}
clang_analyzer_eval(complicatedExprUser(1) == 1); // expected-warning{{TRUE}}
clang_analyzer_eval(complicatedExprUser() == 84); // expected-warning{{TRUE}}
}
+
+ int defaultReference(const int &input = 42) {
+ return input;
+ }
+
+ void testReference() {
+ clang_analyzer_eval(defaultReference(1) == 1); // expected-warning{{TRUE}}
+ clang_analyzer_eval(defaultReference() == 42); // expected-warning{{TRUE}}
+ }
}
namespace OperatorNew {