From f4699d14b03d805ad9ccaa6288836ac2a8612925 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Fri, 18 Feb 2011 20:55:19 +0000 Subject: [PATCH] [analyzer] Fix a crash when analyzing C++ code. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125958 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h | 2 +- test/Analysis/cxx-crashes.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 test/Analysis/cxx-crashes.cpp diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h b/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h index 02517e38b4..a4327e127f 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h @@ -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 index 0000000000..720850cc5c --- /dev/null +++ b/test/Analysis/cxx-crashes.cpp @@ -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); +} -- 2.50.1