]> granicus.if.org Git - clang/commitdiff
[analyzer] Fix a crash when analyzing C++ code.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 18 Feb 2011 20:55:19 +0000 (20:55 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 18 Feb 2011 20:55:19 +0000 (20:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125958 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
test/Analysis/cxx-crashes.cpp [new file with mode: 0644]

index 02517e38b477ff459552d53b80ef91a4e2b52bce..a4327e127f5fed2cf6506da0ca37d9ebc8f29752 100644 (file)
@@ -164,7 +164,7 @@ public:
   }
 
   inline const llvm::APSInt& getTruthValue(bool b) {
-    return getTruthValue(b, Ctx.IntTy);
+    return getTruthValue(b, Ctx.getLogicalOperationType());
   }
 
   const CompoundValData *getCompoundValData(QualType T,
diff --git a/test/Analysis/cxx-crashes.cpp b/test/Analysis/cxx-crashes.cpp
new file mode 100644 (file)
index 0000000..720850c
--- /dev/null
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -verify %s
+
+int f1(char *dst) {
+  char *p = dst + 4;
+  char *q = dst + 3;
+  return !(q >= p);
+}