From d91bf3998fb45f5a959b77d5d0e2d86c040b8bed Mon Sep 17 00:00:00 2001 From: Adrian McCarthy Date: Wed, 13 Sep 2017 20:53:55 +0000 Subject: Mark static member functions as static in CodeViewDebug Summary: To improve CodeView quality for static member functions, we need to make the static explicit. In addition to a small change in LLVM's CodeViewDebug to return the appropriate MethodKind, this requires a small change in Clang to note the staticness in the debug info metadata. Subscribers: aprantl, hiraditya Differential Revision: https://reviews.llvm.org/D37715 llvm-svn: 313192 --- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp') diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp index 42a0d7991d2..ed2dfa6906f 100644 --- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -325,8 +325,9 @@ TypeIndex CodeViewDebug::getMemberFunctionType(const DISubprogram *SP, // function type, as the complete class type is likely to reference this // member function type. TypeLoweringScope S(*this); - TypeIndex TI = - lowerTypeMemberFunction(SP->getType(), Class, SP->getThisAdjustment()); + const bool IsStaticMethod = (SP->getFlags() & DINode::FlagStaticMember) != 0; + TypeIndex TI = lowerTypeMemberFunction( + SP->getType(), Class, SP->getThisAdjustment(), IsStaticMethod); return recordTypeIndexForDINode(SP, TI, Class); } @@ -1221,7 +1222,8 @@ TypeIndex CodeViewDebug::lowerType(const DIType *Ty, const DIType *ClassTy) { // The member function type of a member function pointer has no // ThisAdjustment. return lowerTypeMemberFunction(cast(Ty), ClassTy, - /*ThisAdjustment=*/0); + /*ThisAdjustment=*/0, + /*IsStaticMethod=*/false); } return lowerTypeFunction(cast(Ty)); case dwarf::DW_TAG_enumeration_type: @@ -1542,7 +1544,8 @@ TypeIndex CodeViewDebug::lowerTypeFunction(const DISubroutineType *Ty) { TypeIndex CodeViewDebug::lowerTypeMemberFunction(const DISubroutineType *Ty, const DIType *ClassTy, - int ThisAdjustment) { + int ThisAdjustment, + bool IsStaticMethod) { // Lower the containing class type. TypeIndex ClassType = getTypeIndex(ClassTy); @@ -1558,7 +1561,7 @@ TypeIndex CodeViewDebug::lowerTypeMemberFunction(const DISubroutineType *Ty, ArgTypeIndices = ReturnAndArgTypesRef.drop_front(); } TypeIndex ThisTypeIndex = TypeIndex::Void(); - if (!ArgTypeIndices.empty()) { + if (!IsStaticMethod && !ArgTypeIndices.empty()) { ThisTypeIndex = ArgTypeIndices.front(); ArgTypeIndices = ArgTypeIndices.drop_front(); } @@ -1568,9 +1571,7 @@ TypeIndex CodeViewDebug::lowerTypeMemberFunction(const DISubroutineType *Ty, CallingConvention CC = dwarfCCToCodeView(Ty->getCC()); - // TODO: Need to use the correct values for: - // FunctionOptions - // ThisPointerAdjustment. + // TODO: Need to use the correct values for FunctionOptions. MemberFunctionRecord MFR(ReturnTypeIndex, ClassType, ThisTypeIndex, CC, FunctionOptions::None, ArgTypeIndices.size(), ArgListIndex, ThisAdjustment); @@ -1612,6 +1613,9 @@ static MethodOptions translateMethodOptionFlags(const DISubprogram *SP) { static MethodKind translateMethodKindFlags(const DISubprogram *SP, bool Introduced) { + if (SP->getFlags() & DINode::FlagStaticMember) + return MethodKind::Static; + switch (SP->getVirtuality()) { case dwarf::DW_VIRTUALITY_none: break; @@ -1624,8 +1628,6 @@ static MethodKind translateMethodKindFlags(const DISubprogram *SP, llvm_unreachable("unhandled virtuality case"); } - // FIXME: Get Clang to mark DISubprogram as static and do something with it. - return MethodKind::Vanilla; } -- cgit v1.2.3