From f894ac01dc3f4a29fa6fbaf44518c5de98c848b4 Mon Sep 17 00:00:00 2001 From: Shafik Yaghmour Date: Fri, 26 Apr 2019 18:51:28 +0000 Subject: [PATCH] [ASTImporter] Copy Argument Passing Restrictions setting when importing 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 --- lib/AST/ASTImporter.cpp | 3 +++ test/Import/cxx-record-flags/Inputs/F.cpp | 9 +++++++++ test/Import/cxx-record-flags/test.cpp | 14 ++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 test/Import/cxx-record-flags/Inputs/F.cpp create mode 100644 test/Import/cxx-record-flags/test.cpp diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp index db956561e9..b4c0428405 100644 --- a/lib/AST/ASTImporter.cpp +++ b/lib/AST/ASTImporter.cpp @@ -1767,6 +1767,9 @@ Error ASTNodeImporter::ImportDefinition( ToData.HasDeclaredCopyAssignmentWithConstParam = FromData.HasDeclaredCopyAssignmentWithConstParam; + // Copy over the data stored in RecordDeclBits + ToCXX->setArgPassingRestrictions(FromCXX->getArgPassingRestrictions()); + SmallVector Bases; for (const auto &Base1 : FromCXX->bases()) { ExpectedType TyOrErr = import(Base1.getType()); diff --git a/test/Import/cxx-record-flags/Inputs/F.cpp b/test/Import/cxx-record-flags/Inputs/F.cpp new file mode 100644 index 0000000000..1294c67f68 --- /dev/null +++ b/test/Import/cxx-record-flags/Inputs/F.cpp @@ -0,0 +1,9 @@ +class FTrivial { + int i; +}; + +struct FNonTrivial { + virtual ~FNonTrivial() = default; + int i; +}; + diff --git a/test/Import/cxx-record-flags/test.cpp b/test/Import/cxx-record-flags/test.cpp new file mode 100644 index 0000000000..bff76274fb --- /dev/null +++ b/test/Import/cxx-record-flags/test.cpp @@ -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; +} -- 2.50.1