Skip to content

Commit

Permalink
[ASTImporter] Copy Argument Passing Restrictions setting when importi…
Browse files Browse the repository at this point in the history
…ng a CXXRecordDecl definition

Summary:
For a CXXRecordDecl the RecordDeclBits are stored in the DeclContext. Currently when we import the definition of a CXXRecordDecl via the ASTImporter we do not copy over this data.
This change will add support for copying the ArgPassingRestrictions from RecordDeclBits to fix an LLDB expression parsing bug where we would set it to not pass in registers.
Note, we did not copy over any other of the RecordDeclBits since we don't have tests for those. We know that copying over LoadedFieldsFromExternalStorage would be a error and that may be the case for others as well.

The companion LLDB review: https://reviews.llvm.org/D61146

Differential Review: https://reviews.llvm.org/D61140

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@359338 91177308-0d34-0410-b5e6-96231b3b80d8
(cherry picked from commit f894ac0)
  • Loading branch information
shafik committed May 7, 2019
1 parent dbdb83f commit dd3ef95
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/AST/ASTImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1798,6 +1798,9 @@ Error ASTNodeImporter::ImportDefinition(
ToData.HasDeclaredCopyAssignmentWithConstParam
= FromData.HasDeclaredCopyAssignmentWithConstParam;

// Copy over the data stored in RecordDeclBits
ToCXX->setArgPassingRestrictions(FromCXX->getArgPassingRestrictions());

SmallVector<CXXBaseSpecifier *, 4> Bases;
for (const auto &Base1 : FromCXX->bases()) {
ExpectedType TyOrErr = import(Base1.getType());
Expand Down
9 changes: 9 additions & 0 deletions test/Import/cxx-record-flags/Inputs/F.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class FTrivial {
int i;
};

struct FNonTrivial {
virtual ~FNonTrivial() = default;
int i;
};

14 changes: 14 additions & 0 deletions test/Import/cxx-record-flags/test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s

// CHECK: FTrivial
// CHECK: DefinitionData
// CHECK-SAME: pass_in_registers

// CHECK: FNonTrivial
// CHECK-NOT: pass_in_registers
// CHECK: DefaultConstructor

void expr() {
FTrivial f1;
FNonTrivial f2;
}

0 comments on commit dd3ef95

Please sign in to comment.