diff options
author | cor3ntin <corentinjabot@gmail.com> | 2025-05-02 18:45:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-02 18:45:24 +0200 |
commit | cb068dcec1b30528f0d06916911f55b4bd61b0bb (patch) | |
tree | b0adaaa8f4e43f3e6df1889f4eab45e4578b632f /clang/lib/AST/ExprConstant.cpp | |
parent | b752822c445b9fba1f59a2822c7b675561749dd4 (diff) | |
download | llvm-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.cpp | 8 |
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); }; |