aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/ExprConstant.cpp
diff options
context:
space:
mode:
authorcor3ntin <corentinjabot@gmail.com>2025-05-02 18:45:24 +0200
committerGitHub <noreply@github.com>2025-05-02 18:45:24 +0200
commitcb068dcec1b30528f0d06916911f55b4bd61b0bb (patch)
treeb0adaaa8f4e43f3e6df1889f4eab45e4578b632f /clang/lib/AST/ExprConstant.cpp
parentb752822c445b9fba1f59a2822c7b675561749dd4 (diff)
downloadllvm-cb068dcec1b30528f0d06916911f55b4bd61b0bb.zip
llvm-cb068dcec1b30528f0d06916911f55b4bd61b0bb.tar.gz
llvm-cb068dcec1b30528f0d06916911f55b4bd61b0bb.tar.bz2
[Clang] Fix handling of reference types in tryEvaluateBuiltinObjectSize (#138247)
The order of operation was slightly incorrect, as we were checking for incomplete types *before* handling reference types. Fixes #129397 --------- Co-authored-by: Erich Keane <ekeane@nvidia.com>
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r--clang/lib/AST/ExprConstant.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index f2e49b9..b79d8c1 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -12772,11 +12772,13 @@ static bool determineEndOffset(EvalInfo &Info, SourceLocation ExprLoc,
bool DetermineForCompleteObject = refersToCompleteObject(LVal);
auto CheckedHandleSizeof = [&](QualType Ty, CharUnits &Result) {
- if (Ty.isNull() || Ty->isIncompleteType() || Ty->isFunctionType())
+ if (Ty.isNull())
return false;
- if (Ty->isReferenceType())
- Ty = Ty.getNonReferenceType();
+ Ty = Ty.getNonReferenceType();
+
+ if (Ty->isIncompleteType() || Ty->isFunctionType())
+ return false;
return HandleSizeof(Info, ExprLoc, Ty, Result);
};