[clang] 4a8120c - Fix ConstantAggregateBuilderBase::getRelativeOffset

Arnold Schwaighofer via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 15 12:26:33 PDT 2020


Author: Arnold Schwaighofer
Date: 2020-06-15T12:23:20-07:00
New Revision: 4a8120ca9fb904b50e6940457e0f891ca1fdb605

URL: https://github.com/llvm/llvm-project/commit/4a8120ca9fb904b50e6940457e0f891ca1fdb605
DIFF: https://github.com/llvm/llvm-project/commit/4a8120ca9fb904b50e6940457e0f891ca1fdb605.diff

LOG: Fix ConstantAggregateBuilderBase::getRelativeOffset

Summary:
If a record has a mix of relative pointers and other fields they
wouldn't necessarily be the same.

Fallout from D77592.

rdar://64309883

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D81857

Added: 
    

Modified: 
    clang/lib/CodeGen/ConstantInitBuilder.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/ConstantInitBuilder.cpp b/clang/lib/CodeGen/ConstantInitBuilder.cpp
index 326f079e82fa..24e3ca19709c 100644
--- a/clang/lib/CodeGen/ConstantInitBuilder.cpp
+++ b/clang/lib/CodeGen/ConstantInitBuilder.cpp
@@ -129,7 +129,7 @@ llvm::Constant *
 ConstantAggregateBuilderBase::getRelativeOffset(llvm::IntegerType *offsetType,
                                                 llvm::Constant *target) {
   return getRelativeOffsetToPosition(offsetType, target,
-                                     Builder.SelfReferences.size());
+                                     Builder.Buffer.size() - Begin);
 }
 
 llvm::Constant *ConstantAggregateBuilderBase::getRelativeOffsetToPosition(


        


More information about the cfe-commits mailing list