[clang] [analyzer] Implement binary operations on LazyCompoundVals (PR #106982)

DonĂ¡t Nagy via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 2 08:18:06 PDT 2024


================
@@ -315,6 +315,62 @@ static bool isFunctionMacroExpansion(SourceLocation Loc,
   return EInfo.isFunctionMacroExpansion();
 }
 
+static const LocationContext *getFirstNonCtorCall(const LocationContext *LCtx) {
+  while (llvm::isa_and_nonnull<CXXConstructorDecl>(LCtx->getDecl()))
+    LCtx = LCtx->getParent();
+  return LCtx;
+}
+
+static const MemRegion *getInitializerRegion(const PostInitializer &PI) {
+  return reinterpret_cast<const MemRegion *>(PI.getLocationValue());
----------------
NagyDonat wrote:

This reinterpret cast is really scary, but I see that this is apparently the intended way of using `PostInitializer` objects (which is a bit crazy). Perhaps add an explanation comment.

It would be good to have a templated `PostInitializer::getLocationValue<T>() const` which returns `const T *` instead of `const void *`. However, that class is defined outside of CSA so I'm not sure that this is worth the effort.

https://github.com/llvm/llvm-project/pull/106982


More information about the cfe-commits mailing list