diff options
author | Timm Baeder <tbaeder@redhat.com> | 2025-04-19 16:48:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-19 16:48:49 +0200 |
commit | 6196b4ee8c47dc4a2267b7c704d1811e68c7f1c1 (patch) | |
tree | ac7079e079ba964b09f45ad60891485bc8b9823a /clang/lib/AST/ByteCode/Pointer.cpp | |
parent | 8fdebff69d92fd3c6023bf2d0646ca909bb4ec05 (diff) | |
download | llvm-6196b4ee8c47dc4a2267b7c704d1811e68c7f1c1.zip llvm-6196b4ee8c47dc4a2267b7c704d1811e68c7f1c1.tar.gz llvm-6196b4ee8c47dc4a2267b7c704d1811e68c7f1c1.tar.bz2 |
[clang][bytecode] Don't set OnePastEnd bit for array elements (#136422)
If we refer to arr[N], don't set the OnePastEnd bit of the APValue,
since that is already encoded in the array index.
Diffstat (limited to 'clang/lib/AST/ByteCode/Pointer.cpp')
-rw-r--r-- | clang/lib/AST/ByteCode/Pointer.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/clang/lib/AST/ByteCode/Pointer.cpp b/clang/lib/AST/ByteCode/Pointer.cpp index 686ec381..059503c 100644 --- a/clang/lib/AST/ByteCode/Pointer.cpp +++ b/clang/lib/AST/ByteCode/Pointer.cpp @@ -223,6 +223,7 @@ APValue Pointer::toAPValue(const ASTContext &ASTCtx) const { UsePath = false; // Build the path into the object. + bool OnePastEnd = isOnePastEnd(); Pointer Ptr = *this; while (Ptr.isField() || Ptr.isArrayElement()) { @@ -251,9 +252,10 @@ APValue Pointer::toAPValue(const ASTContext &ASTCtx) const { Ptr = Ptr.expand(); const Descriptor *Desc = Ptr.getFieldDesc(); unsigned Index; - if (Ptr.isOnePastEnd()) + if (Ptr.isOnePastEnd()) { Index = Ptr.getArray().getNumElems(); - else + OnePastEnd = false; + } else Index = Ptr.getIndex(); QualType ElemType = Desc->getElemQualType(); @@ -304,8 +306,7 @@ APValue Pointer::toAPValue(const ASTContext &ASTCtx) const { std::reverse(Path.begin(), Path.end()); if (UsePath) - return APValue(Base, Offset, Path, - /*IsOnePastEnd=*/!isElementPastEnd() && isOnePastEnd()); + return APValue(Base, Offset, Path, OnePastEnd); return APValue(Base, Offset, APValue::NoLValuePath()); } |