================
@@ -178,36 +184,35 @@ class EntityPointerLevelTranslator
 
   // Translate((T*)base) -> Translate(base) if base has pointer type
   //                     -> {} otherwise
-  Expected<EntityPointerLevelSet> VisitCastExpr(const CastExpr *E) {
+  Expected<DeclPointerLevels> VisitCastExpr(const CastExpr *E) {
     if (hasPtrOrArrType(E->getSubExpr()))
       return Visit(E->getSubExpr());
-    return EntityPointerLevelSet{};
+    return DeclPointerLevels{};
   }
 
   // Translate(f(...)) -> {} if it is an indirect call
   //                   -> {(f_return, 1)}, otherwise
-  Expected<EntityPointerLevelSet> VisitCallExpr(const CallExpr *E) {
-    if (auto *FD = E->getDirectCallee()) {
-      if (auto ReturnId = Extractor.addEntityForReturn(FD))
-        return EntityPointerLevelSet{buildEntityPointerLevel(*ReturnId, 1)};
-    }
-    return EntityPointerLevelSet{};
+  Expected<DeclPointerLevels> VisitCallExpr(const CallExpr *E) {
+    if (auto *FD = E->getDirectCallee())
+      if (Extractor.addEntityForReturn(FD))
+        return DeclPointerLevels{{FD, /*PointerLevel=*/1, /*IsReturn=*/true}};
+    return DeclPointerLevels{};
----------------
steakhal wrote:

Right, so we drop the EntityId on the floor because we only keep the decl and 
we expect that we would get a cached EntityId when we transform the DPL to EPL 
for the same FD. Reasonable.

The alternative is to let the transform take care of calling 
`addEntityForReturn` (which it anyway must call) for getting an EntityId for 
FD. I think would be cleaner.

```suggestion
  Expected<DeclPointerLevels> VisitCallExpr(const CallExpr *E) {
    if (auto *FD = E->getDirectCallee())
      return DeclPointerLevels{{FD, /*PointerLevel=*/1, /*IsReturn=*/true}};
    return DeclPointerLevels{};
```

https://github.com/llvm/llvm-project/pull/218196
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to