Index: clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp =================================================================== --- clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp +++ clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp @@ -100,6 +100,11 @@ SVal Result = evalBinOp(state, Op, LeftV, RightV, B->getType()); if (!Result.isUnknown()) { state = state->BindExpr(B, LCtx, Result); + + // If we cannot evaluate the operation escape the operands. + } else { + state = escapeValue(state, LeftV, PSK_EscapeOther); + state = escapeValue(state, RightV, PSK_EscapeOther); } Bldr.generateNode(B, *it, state); Index: clang/test/Analysis/symbol-escape.cpp =================================================================== --- clang/test/Analysis/symbol-escape.cpp +++ clang/test/Analysis/symbol-escape.cpp @@ -2,6 +2,9 @@ // RUN: -analyzer-checker=core,cplusplus.NewDeleteLeaks \ // RUN: -verify %s +// expected-no-diagnostics: Whenever we cannot evaluate an operation we escape +// the operands. + #include class C {}; @@ -12,7 +15,7 @@ ~static_cast(0x1)) | (reinterpret_cast(Bar) & 0x1)); (void)Bar; - // expected-warning@-1 {{Potential leak of memory pointed to by 'Bar'}} + // no-warning: "Potential leak of memory pointed to by 'Bar'" was here. return Bar; } @@ -23,7 +26,7 @@ Baz = reinterpret_cast(reinterpret_cast(Baz) | 0x1); Baz = reinterpret_cast(reinterpret_cast(Baz) & ~static_cast(0x1)); - // expected-warning@-2 {{Potential leak of memory pointed to by 'Qux'}} + // no-warning: "Potential leak of memory pointed to by 'Qux'" was here. delete *Baz; return Baz;