Summary:
- Fix a bug in PrettyBuiltinDumper that returns "void" as the name for
an unspecified builtin type. Since the unspecified param of a variadic
function is considered a builtin of unspecified type in PDBs, we set
"..." for its name.
- Provide a method to determine if a PDBSymbolFunc is variadic in
PrettyFunctionDumper since PDBSymbolFunc::getArgument() doesn't return the
last unspecified-type param.
- Add a pretty-func-dumper.test to test pretty dumping of variadic
functions.
Reviewers: zturner, llvm-commits
Reviewed By: zturner
Differential Revision: https://reviews.llvm.org/D41801
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@322608
91177308-0d34-0410-b5e6-
96231b3b80d8
void dumpRight(PDBSymDumper &Dumper) const override;
void dumpArgList(raw_ostream &OS) const;
+ bool isCVarArgs() const;
+
FORWARD_SYMBOL_METHOD(getCallingConvention)
FORWARD_SYMBOL_ID_METHOD(getClassParent)
FORWARD_SYMBOL_ID_METHOD(getUnmodifiedType)
#include "llvm/DebugInfo/PDB/IPDBSession.h"
#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
#include "llvm/DebugInfo/PDB/PDBSymbol.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h"
#include <utility>
void PDBSymbolTypeFunctionSig::dumpRight(PDBSymDumper &Dumper) const {
Dumper.dumpRight(*this);
}
+
+bool PDBSymbolTypeFunctionSig::isCVarArgs() const {
+ auto SigArguments = getArguments();
+ if (!SigArguments)
+ return false;
+ uint32_t NumArgs = SigArguments->getChildCount();
+ if (NumArgs == 0)
+ return false;
+ auto Last = SigArguments->getChildAtIndex(NumArgs - 1);
+ if (auto Builtin = llvm::dyn_cast_or_null<PDBSymbolTypeBuiltin>(Last.get())) {
+ if (Builtin->getBuiltinType() == PDB_BuiltinType::None)
+ return true;
+ }
+
+ // Note that for a variadic template signature, this method always returns
+ // false since the parameters of the template are specialized.
+ return false;
+}
--- /dev/null
+// Compile for x86 (FPO disabled)
+// Compile with "cl /c /Zi /GR- PrettyFuncDumperTest.cpp"
+// Link with "link PrettyFuncDumperTest.obj /debug /nodefaultlib /entry:main"
+
+typedef void (*FuncPtrA)();
+FuncPtrA FuncVarA;
+
+typedef float (*FuncPtrB)(void);
+FuncPtrB FuncVarB;
+
+typedef int(*VariadicFuncPtrTypedef)(char, double, ...);
+VariadicFuncPtrTypedef VariadicFuncVar;
+
+void Func(int array[]) { return; }
+
+template <int N=1, class ...T>
+void TemplateFunc(T ...Arg) {
+ return;
+}
+
+namespace {
+ void Func(int& a, const double b, volatile bool c) { return; }
+}
+
+namespace NS {
+ void Func(char a, int b, ...) {
+ return;
+ }
+}
+
+namespace MemberFuncsTest {
+ class A {
+ public:
+ int FuncA() { return 1; }
+ void FuncB(int a, ...) {}
+ };
+}
+
+int main() {
+ MemberFuncsTest::A v1;
+ v1.FuncA();
+ v1.FuncB(9, 10, 20);
+
+ NS::Func('c', 2, 10, 100);
+
+ TemplateFunc(10);
+ TemplateFunc(10, 11, 88);
+ return 0;
+}
--- /dev/null
+; RUN: llvm-pdbutil pretty -all -class-recurse-depth=1 \
+; RUN: %p/Inputs/PrettyFuncDumperTest.pdb > %t
+; RUN: FileCheck -input-file=%t %s -check-prefix=GLOBALS_FUNC
+; RUN: FileCheck -input-file=%t %s -check-prefix=GLOBALS_DATA
+; RUN: FileCheck -input-file=%t %s -check-prefix=TYPEDEF
+
+; GLOBALS_FUNC: ---GLOBALS---
+; GLOBALS_FUNC-DAG: void __cdecl NS::Func(char a, int b, ...)
+; GLOBALS_FUNC-DAG: void __cdecl TemplateFunc<1,int>(int <Arg_0>)
+; GLOBALS_FUNC-DAG: void __cdecl TemplateFunc<1,int,int,int>(int <Arg_0>, int <Arg_1>, int <Arg_2>)
+; GLOBALS_FUNC-DAG: void __cdecl `anonymous namespace'::Func(int& a, const double b, volatile bool c)
+; GLOBALS_FUNC-DAG: void __cdecl Func(int* array)
+; GLOBALS_FUNC-DAG: int MemberFuncsTest::A::FuncA()
+; GLOBALS_FUNC-DAG: void __cdecl MemberFuncsTest::A::FuncB(int a, ...)
+
+; GLOBALS_DATA: ---GLOBALS---
+; GLOBALS_DATA-DAG: void (__cdecl * FuncVarA)()
+; GLOBALS_DATA-DAG: float (__cdecl * FuncVarB)()
+; GLOBALS_DATA-DAG: int (__cdecl * VariadicFuncVar)(char, double, ...)
+
+; TYPEDEF: ---TYPES---
+; TYPEDEF: Typedefs:
+; TYPEDEF-DAG: typedef void (__cdecl *)() FuncPtrA
+; TYPEDEF-DAG: typedef int (__cdecl *)(char, double, ...) VariadicFuncPtrTypedef
+; TYPEDEF-DAG: typedef float (__cdecl *)() FuncPtrB
return "HRESULT";
case PDB_BuiltinType::BCD:
return "HRESULT";
+ case PDB_BuiltinType::None:
+ return "...";
default:
return "void";
}
if (++Index < Arguments->getChildCount())
Printer << ", ";
}
+ if (Signature->isCVarArgs())
+ Printer << ", ...";
}
Printer << ")";
if (Symbol.isConstType())