From 1d13545e10c5574a40821115d10c54c16f7c47be Mon Sep 17 00:00:00 2001 From: Aaron Smith Date: Sat, 21 Jul 2018 05:42:13 +0000 Subject: [PATCH] [DebugInfo] Add a new DI flag to record if a C++ record is a trivial type Summary: This flag is used when emitting debug info and is needed to initialize subprogram and member function attributes (function options) for Codeview. These function options are used to create an accurate compiler type for UDT symbols (class/struct/union) from PDBs. It is not easy to determine if a C++ record is trivial or not based on the current DICompositeType flags and other accessible debug information from Codeview. For example, without this flag the metadata for a non-trivial C++ record with user-defined ctor and a trivial one with a defaulted ctor are the same. struct S { S(); } struct S { S() = default; } This change introduces a new DI flag and corresponding clang::CXXRecordDecl::isTrivial method to set the flag in the frontend. Reviewers: rnk, zturner, llvm-commits, dblaikie, aleksandr.urakov, deadalnix Reviewed By: rnk Subscribers: asmith, probinson, aprantl, JDevlieghere Differential Revision: https://reviews.llvm.org/D45122 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337641 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/DebugInfo.h | 3 +++ include/llvm/IR/DebugInfoFlags.def | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/llvm-c/DebugInfo.h b/include/llvm-c/DebugInfo.h index dc1578f4862..cee6755f187 100644 --- a/include/llvm-c/DebugInfo.h +++ b/include/llvm-c/DebugInfo.h @@ -54,6 +54,9 @@ typedef enum { LLVMDIFlagMainSubprogram = 1 << 21, LLVMDIFlagTypePassByValue = 1 << 22, LLVMDIFlagTypePassByReference = 1 << 23, + LLVMDIFlagFixedEnum = 1 << 24, + LLVMDIFlagThunk = 1 << 25, + LLVMDIFlagTrivial = 1 << 26, LLVMDIFlagIndirectVirtualBase = (1 << 2) | (1 << 5), LLVMDIFlagAccessibility = LLVMDIFlagPrivate | LLVMDIFlagProtected | LLVMDIFlagPublic, diff --git a/include/llvm/IR/DebugInfoFlags.def b/include/llvm/IR/DebugInfoFlags.def index e3707d48754..b1f5fac6423 100644 --- a/include/llvm/IR/DebugInfoFlags.def +++ b/include/llvm/IR/DebugInfoFlags.def @@ -47,6 +47,7 @@ HANDLE_DI_FLAG((1 << 22), TypePassByValue) HANDLE_DI_FLAG((1 << 23), TypePassByReference) HANDLE_DI_FLAG((1 << 24), FixedEnum) HANDLE_DI_FLAG((1 << 25), Thunk) +HANDLE_DI_FLAG((1 << 26), Trivial) // To avoid needing a dedicated value for IndirectVirtualBase, we use // the bitwise or of Virtual and FwdDecl, which does not otherwise @@ -56,7 +57,7 @@ HANDLE_DI_FLAG((1 << 2) | (1 << 5), IndirectVirtualBase) #ifdef DI_FLAG_LARGEST_NEEDED // intended to be used with ADT/BitmaskEnum.h // NOTE: always must be equal to largest flag, check this when adding new flag -HANDLE_DI_FLAG((1 << 25), Largest) +HANDLE_DI_FLAG((1 << 26), Largest) #undef DI_FLAG_LARGEST_NEEDED #endif -- 2.50.1