[PATCH] D100713: [clang] NFC: refactor usage of getDecltypeForParenthesizedExpr and getValueKind

Aaron Puchert via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Apr 17 19:19:48 PDT 2021


aaronpuchert added a comment.

It seems that using `is*Value` and the introduction of `getDecltypeForParenthesizedExpr` could be two separate changes.



================
Comment at: clang/lib/Sema/SemaExprCXX.cpp:5845
+  if (!To->isRValue()) {
+    QualType T = Self.Context.getDecltypeForParenthesizedExpr(To);
     InitializedEntity Entity = InitializedEntity::InitializeTemporary(T);
----------------
The quote doesn't reference parenthesized expressions, isn't this just coincidentally the same thing?


================
Comment at: clang/lib/StaticAnalyzer/Core/CallEvent.cpp:73
   const Expr *E = getOriginExpr();
-  if (!E)
-    return Ctx.VoidTy;
-  assert(E);
-
-  QualType ResultTy = E->getType();
-
-  // A function that returns a reference to 'int' will have a result type
-  // of simply 'int'. Check the origin expr's value kind to recover the
-  // proper type.
-  switch (E->getValueKind()) {
-  case VK_LValue:
-    ResultTy = Ctx.getLValueReferenceType(ResultTy);
-    break;
-  case VK_XValue:
-    ResultTy = Ctx.getRValueReferenceType(ResultTy);
-    break;
-  case VK_RValue:
-    // No adjustment is necessary.
-    break;
-  }
-
-  return ResultTy;
+  return E ? Ctx.getDecltypeForParenthesizedExpr(E) : Ctx.VoidTy;
 }
----------------
This seems also more of a coincidence. There is no parenthesized expression, we're just trying to figure out a function return type.

(Ok, it's not a pure coincidence, the decltype is probably chosen to match that type.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100713



More information about the cfe-commits mailing list