diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp --- a/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp @@ -380,7 +380,6 @@ case CK_Dependent: case CK_ArrayToPointerDecay: case CK_BitCast: - case CK_LValueToRValueBitCast: case CK_AddressSpaceConversion: case CK_BooleanToSignedIntegral: case CK_IntegralToPointer: @@ -538,6 +537,7 @@ continue; } // Various C++ casts that are not handled yet. + case CK_LValueToRValueBitCast: case CK_ToUnion: case CK_VectorSplat: { state = handleLVectorSplat(state, LCtx, CastE, Bldr, Pred); diff --git a/clang/test/Analysis/builtin_bitcast.cpp b/clang/test/Analysis/builtin_bitcast.cpp new file mode 100644 --- /dev/null +++ b/clang/test/Analysis/builtin_bitcast.cpp @@ -0,0 +1,17 @@ +// RUN: %clang_analyze_cc1 -verify %s \ +// RUN: -analyzer-checker=core,debug.ExprInspection + +template void clang_analyzer_dump(T); + +__attribute__((always_inline)) static inline constexpr unsigned int _castf32_u32(float __A) { + return __builtin_bit_cast(unsigned int, __A); // no-warning +} + +void test() { + _castf32_u32(42); + + float f = 42; + unsigned int g = __builtin_bit_cast(unsigned int, f); + clang_analyzer_dump(g); + // expected-warning-re@-1{{{{^conj_\$[0-9]+{unsigned int, LC[0-9]+, S[0-9]+, #[0-9]+}}}}} +}