[cfe-commits] r163262 - in /cfe/trunk: lib/StaticAnalyzer/Core/ExprEngineC.cpp test/Analysis/complex-init-list.cpp

Anna Zaks ganna at apple.com
Wed Sep 5 15:31:58 PDT 2012


Author: zaks
Date: Wed Sep  5 17:31:58 2012
New Revision: 163262

URL: http://llvm.org/viewvc/llvm-project?rev=163262&view=rev
Log:
[analyzer] Fix a crash PR13762.

Added:
    cfe/trunk/test/Analysis/complex-init-list.cpp
Modified:
    cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp?rev=163262&r1=163261&r2=163262&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp Wed Sep  5 17:31:58 2012
@@ -567,7 +567,8 @@
   QualType T = getContext().getCanonicalType(IE->getType());
   unsigned NumInitElements = IE->getNumInits();
   
-  if (T->isArrayType() || T->isRecordType() || T->isVectorType()) {
+  if (T->isArrayType() || T->isRecordType() || T->isVectorType() ||
+      T->isAnyComplexType()) {
     llvm::ImmutableList<SVal> vals = getBasicVals().getEmptySValList();
     
     // Handle base case where the initializer has no elements.

Added: cfe/trunk/test/Analysis/complex-init-list.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/complex-init-list.cpp?rev=163262&view=auto
==============================================================================
--- cfe/trunk/test/Analysis/complex-init-list.cpp (added)
+++ cfe/trunk/test/Analysis/complex-init-list.cpp Wed Sep  5 17:31:58 2012
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=text -verify %s
+
+// Do not crash on initialization to complex numbers.
+void init_complex() {
+  _Complex float valid1 = { 0.0f, 0.0f };
+}





More information about the cfe-commits mailing list