Author: dergachev Date: Thu Jan 12 03:46:16 2017 New Revision: 291754 URL: http://llvm.org/viewvc/llvm-project?rev=291754&view=rev Log: [analyzer] Avoid a crash in DereferenceChecker on string literal initializers.
A hotfix for pr31592 that fixes the crash but not the root cause of the problem. We need to update the analyzer engine further to account for AST changes introduced in r289618. At the moment we're erroneously performing a redundant lvalue-to-rvalue cast in this scenario, and squashing the rvalue of the object bound to the reference into the reference itself. rdar://problem/28832541 Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp cfe/trunk/test/Analysis/initializer.cpp Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp?rev=291754&r1=291753&r2=291754&view=diff ============================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp Thu Jan 12 03:46:16 2017 @@ -253,6 +253,12 @@ void DereferenceChecker::checkBind(SVal if (!TVR->getValueType()->isReferenceType()) return; + // FIXME: This is a hotfix for https://llvm.org/bugs/show_bug.cgi?id=31592 + // A proper fix is very much necessary. Otherwise we would never normally bind + // a NonLoc to a reference. + if (V.getAs<NonLoc>()) + return; + ProgramStateRef State = C.getState(); ProgramStateRef StNonNull, StNull; Modified: cfe/trunk/test/Analysis/initializer.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/initializer.cpp?rev=291754&r1=291753&r2=291754&view=diff ============================================================================== --- cfe/trunk/test/Analysis/initializer.cpp (original) +++ cfe/trunk/test/Analysis/initializer.cpp Thu Jan 12 03:46:16 2017 @@ -197,3 +197,10 @@ namespace ReferenceInitialization { } }; + +namespace PR31592 { +struct C { + C() : f("}") { } // no-crash + const char(&f)[2]; +}; +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits