[PATCH] D100713: [clang] NFC: refactor usage of getDecltypeForParenthesizedExpr and getValueKind
Matheus Izvekov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Apr 17 19:35:15 PDT 2021
mizvekov added inline comments.
================
Comment at: clang/lib/Sema/SemaExprCXX.cpp:5845
+ if (!To->isRValue()) {
+ QualType T = Self.Context.getDecltypeForParenthesizedExpr(To);
InitializedEntity Entity = InitializedEntity::InitializeTemporary(T);
----------------
aaronpuchert wrote:
> The quote doesn't reference parenthesized expressions, isn't this just coincidentally the same thing?
It's fundamentally the same thing. The `getDecltypeForParenthesizedExpr` name is what I tried to keep, I don't have better ideas there.
================
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;
}
----------------
aaronpuchert wrote:
> 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.)
Yes, not a coincidence, still fundamentally the same thing.
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