aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/StaticAnalyzer/ExprEngineVisitTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/unittests/StaticAnalyzer/ExprEngineVisitTest.cpp')
-rw-r--r--clang/unittests/StaticAnalyzer/ExprEngineVisitTest.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/clang/unittests/StaticAnalyzer/ExprEngineVisitTest.cpp b/clang/unittests/StaticAnalyzer/ExprEngineVisitTest.cpp
index 12be228..ab4b8c7 100644
--- a/clang/unittests/StaticAnalyzer/ExprEngineVisitTest.cpp
+++ b/clang/unittests/StaticAnalyzer/ExprEngineVisitTest.cpp
@@ -55,11 +55,13 @@ public:
", Stmt = " + S->getStmtClassName());
}
- void checkBind(SVal Loc, SVal Val, const Stmt *S, CheckerContext &C) const {
+ void checkBind(SVal Loc, SVal Val, const Stmt *S, bool AtDeclInit,
+ CheckerContext &C) const {
emitErrorReport(C, Bug,
"checkBind: Loc = " + dumpToString(Loc) +
", Val = " + dumpToString(Val) +
- ", Stmt = " + S->getStmtClassName());
+ ", Stmt = " + S->getStmtClassName() +
+ ", AtDeclInit = " + (AtDeclInit ? "true" : "false"));
}
private:
@@ -140,7 +142,7 @@ TEST(ExprEngineVisitTest, checkLocationAndBind) {
"Stmt = ImplicitCastExpr";
std::string BindMsg =
"checkBind: Loc = &MyClassWrite, Val = lazyCompoundVal{0x0,MyClassRead}, "
- "Stmt = CXXOperatorCallExpr";
+ "Stmt = CXXOperatorCallExpr, AtDeclInit = false";
std::size_t LocPos = Diags.find(LocMsg);
std::size_t BindPos = Diags.find(BindMsg);
EXPECT_NE(LocPos, std::string::npos);
@@ -150,4 +152,20 @@ TEST(ExprEngineVisitTest, checkLocationAndBind) {
EXPECT_TRUE(LocPos > BindPos);
}
+TEST(ExprEngineVisitTest, checkLocationAndBindInitialization) {
+ std::string Diags;
+ EXPECT_TRUE(runCheckerOnCode<addMemAccessChecker>(R"(
+ class MyClass{
+ public:
+ int Value;
+ };
+ void top(MyClass param) {
+ MyClass MyClassWrite = param;
+ }
+ )",
+ Diags));
+
+ EXPECT_TRUE(StringRef(Diags).contains("AtDeclInit = true"));
+}
+
} // namespace