[analyzer] Fixing SVal::getType returns Null Type for NonLoc::ConcreteInt in boolean...
authorElla Ma <alansnape3058@gmail.com>
Thu, 14 Jul 2022 07:54:40 +0000 (15:54 +0800)
committerElla Ma <alansnape3058@gmail.com>
Thu, 14 Jul 2022 14:00:38 +0000 (22:00 +0800)
commit32fe1a4be95c90da9a24d63a097429ec7c3bbfba
tree06155b21fa3540cc124cf2d99bbb3ca52206bd81
parent74902cc96faa04b8606f4eba59c51dac48cb924d
[analyzer] Fixing SVal::getType returns Null Type for NonLoc::ConcreteInt in boolean type

In method `TypeRetrievingVisitor::VisitConcreteInt`, `ASTContext::getIntTypeForBitwidth` is used to get the type for `ConcreteInt`s.
However, the getter in ASTContext cannot handle the boolean type with the bit width of 1, which will make method `SVal::getType` return a Null `Type`.
In this patch, a check for this case is added to fix this problem by returning the bool type directly when the bit width is 1.

Differential Revision: https://reviews.llvm.org/D129737
clang/lib/StaticAnalyzer/Core/SVals.cpp
clang/unittests/StaticAnalyzer/SValTest.cpp