[PATCH] D68199: [analyzer] DynamicTypeInfo: Simplify the API

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 30 13:00:47 PDT 2019


NoQ added a comment.

I actually like the idea, it makes it consistent with other maps. But you'll need to clean up memory management here. Given that you can't modify the state in `getDynamicTypeInfo()`, i guess you'll have to resort to smart pointers.



================
Comment at: clang/lib/StaticAnalyzer/Core/DynamicType.cpp:53-57
   if (const auto *TR = dyn_cast<TypedRegion>(MR))
-    return DynamicTypeInfo(TR->getLocationType(), /*CanBeSub=*/false);
+    return new DynamicTypeInfo(TR->getLocationType(), /*CanBeSub=*/false);
 
-  if (const auto *SR = dyn_cast<SymbolicRegion>(MR)) {
-    SymbolRef Sym = SR->getSymbol();
-    return DynamicTypeInfo(Sym->getType());
-  }
+  if (const auto *SR = dyn_cast<SymbolicRegion>(MR))
+    return new DynamicTypeInfo(SR->getSymbol()->getType());
----------------
Do i have to do a `delete` manually every time i call this function?


================
Comment at: clang/lib/StaticAnalyzer/Core/DynamicType.cpp:96
+  return setDynamicTypeInfo(State, MR,
+                            new DynamicTypeInfo(NewTy, CanBeSubClassed));
 }
----------------
Who is responsible for deallocating this memory?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68199/new/

https://reviews.llvm.org/D68199





More information about the cfe-commits mailing list