Index: clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h =================================================================== --- clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h +++ clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h @@ -103,7 +103,10 @@ } std::string VisitSymbolDerived(const SymbolDerived *S) { - return "value derived from (" + Visit(S->getParentSymbol()) + + std::string Prefix = ""; + if (const auto *SRV = dyn_cast(S->getParentSymbol())) + Prefix = "initial "; + return Prefix + "value derived from (" + Visit(S->getParentSymbol()) + ") for " + Visit(S->getRegion()); } Index: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp =================================================================== --- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -304,6 +304,16 @@ } } + if (const auto *FD = dyn_cast(D)) { + // Fill the Store with initial value of parameters. + for (const ParmVarDecl *PVD : FD->parameters()) { + const auto *TVR = + state->getRegion(PVD, InitLoc)->castAs(); + state = state->bindLoc(loc::MemRegionVal(TVR), + svalBuilder.getRegionValueSymbolVal(TVR), InitLoc); + } + } + return state; } Index: clang/test/Analysis/explain-svals.c =================================================================== --- clang/test/Analysis/explain-svals.c +++ clang/test/Analysis/explain-svals.c @@ -25,5 +25,5 @@ void test_2(struct S s) { clang_analyzer_explain_S(s); //expected-warning-re{{{{^lazily frozen compound value of parameter 's'$}}}} clang_analyzer_explain_voidp(&s); // expected-warning-re{{{{^pointer to parameter 's'$}}}} - clang_analyzer_explain_int(s.z); // expected-warning-re{{{{^initial value of field 'z' of parameter 's'$}}}} + clang_analyzer_explain_int(s.z); // expected-warning-re{{{{^initial value derived from \(argument 's'\) for field 'z' of parameter 's'$}}}} } Index: clang/test/Analysis/explain-svals.cpp =================================================================== --- clang/test/Analysis/explain-svals.cpp +++ clang/test/Analysis/explain-svals.cpp @@ -59,7 +59,7 @@ void test_3(S s) { clang_analyzer_explain(&s); // expected-warning-re{{{{^pointer to parameter 's'$}}}} - clang_analyzer_explain(s.z); // expected-warning-re{{{{^initial value of field 'z' of parameter 's'$}}}} + clang_analyzer_explain(s.z); // expected-warning-re{{{{^initial value derived from \(argument 's'\) for field 'z' of parameter 's'$}}}} clang_analyzer_explain(&s.s2[5].y[3]); // expected-warning-re{{{{^pointer to element of type 'int' with index 3 of field 'y' of base object 'S::S3' inside element of type 'struct S::S2' with index 5 of field 's2' of parameter 's'$}}}} if (!s.s2[7].x) { clang_analyzer_explain(s.s2[7].x); // expected-warning-re{{{{^concrete memory address '0'$}}}} Index: clang/test/Analysis/expr-inspection.c =================================================================== --- clang/test/Analysis/expr-inspection.c +++ clang/test/Analysis/expr-inspection.c @@ -28,6 +28,9 @@ // CHECK-NEXT: "store": { "pointer": "{{0x[0-9a-f]+}}", "items": [ // CHECK-NEXT: { "cluster": "y", "pointer": "{{0x[0-9a-f]+}}", "items": [ // CHECK-NEXT: { "kind": "Direct", "offset": 0, "value": "2 S32b" } +// CHECK-NEXT: ]}, +// CHECK-NEXT: { "cluster": "x", "pointer": "{{0x[0-9a-f]+}}", "items": [ +// CHECK-NEXT: { "kind": "Direct", "offset": 0, "value": "reg_$0" } // CHECK-NEXT: ]} // CHECK-NEXT: ]}, // CHECK-NEXT: "environment": { "pointer": "{{0x[0-9a-f]+}}", "items": [ Index: clang/test/Analysis/osobject-retain-release.cpp =================================================================== --- clang/test/Analysis/osobject-retain-release.cpp +++ clang/test/Analysis/osobject-retain-release.cpp @@ -35,7 +35,7 @@ static OSArray* consumeArrayHasCode(OS_CONSUME OSArray * array) { // expected-note{{Parameter 'array' starts at +1, as it is marked as consuming}} return nullptr; // expected-warning{{Potential leak of an object of type 'OSArray'}} -// expected-note@-1{{Object leaked: allocated object of type 'OSArray' is not referenced later in this execution path and has a retain count of +1}} +// expected-note@-1{{Object leaked: object allocated and stored into 'array' is not referenced later in this execution path and has a retain count of +1}} } @@ -70,7 +70,7 @@ a->release(); b->retain(); // expected-note{{Reference count incremented. The object now has a +1 retain count}} } // expected-warning{{Potential leak of an object of type 'OSObject'}} -// expected-note@-1{{Object leaked: allocated object of type 'OSObject' is not referenced later in this execution path and has a retain count of +1}} +// expected-note@-1{{Object leaked: object allocated and stored into 'b' is not referenced later in this execution path and has a retain count of +1}} void escape(void *); void escape_with_source(void *p) {}