From fa6228d61499e4f6c490afeb636e36d8ae00b5ee Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Wed, 11 Mar 2009 02:52:39 +0000 Subject: [PATCH] Fix PR 3780: In one code path in BasicValueFactory::getValue() we would not return an unsigned integer for a null pointer value. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66630 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/BasicValueFactory.cpp | 2 +- test/Analysis/misc-ps.m | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/Analysis/BasicValueFactory.cpp b/lib/Analysis/BasicValueFactory.cpp index 2c7d6a37c1..6ceab93b08 100644 --- a/lib/Analysis/BasicValueFactory.cpp +++ b/lib/Analysis/BasicValueFactory.cpp @@ -92,7 +92,7 @@ const llvm::APSInt& BasicValueFactory::getValue(uint64_t X, unsigned BitWidth, const llvm::APSInt& BasicValueFactory::getValue(uint64_t X, QualType T) { unsigned bits = Ctx.getTypeSize(T); - llvm::APSInt V(bits, T->isUnsignedIntegerType()); + llvm::APSInt V(bits, T->isUnsignedIntegerType() || Loc::IsLocType(T)); V = X; return getValue(V); } diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m index 04e6555dd1..50dda78cdb 100644 --- a/test/Analysis/misc-ps.m +++ b/test/Analysis/misc-ps.m @@ -178,3 +178,18 @@ char pr3770(int x) { return 'a'; } +// PR 3780 +// - We just want to test that this doesn't crash the analyzer. +typedef struct st ST; +struct st { char *name; }; +extern ST *Cur_Pu; + +void pr3780(void) +{ + static ST *last_Cur_Pu; + if (last_Cur_Pu == Cur_Pu) { + return; + } +} + + -- 2.40.0