summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-pdbdump/VariableDumper.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2015-02-26 23:49:23 +0000
committerZachary Turner <zturner@google.com>2015-02-26 23:49:23 +0000
commitd270d22f3547aa4e7bf4f3c41c9828c6b981de70 (patch)
tree08909bf70a59d5e3dfc1d84cc1d01572a319a2e6 /llvm/tools/llvm-pdbdump/VariableDumper.cpp
parent53a93c6c399b7e514f9500283be59022e20034a7 (diff)
downloadbcm5719-llvm-d270d22f3547aa4e7bf4f3c41c9828c6b981de70.tar.gz
bcm5719-llvm-d270d22f3547aa4e7bf4f3c41c9828c6b981de70.zip
[llvm-pdbdump] Fix dumping of function pointers and basic types.
Function pointers were not correctly handled by the dumper, and they would print as "* name". They now print as "int (__cdecl *name)(int arg1, int arg2)" as they should. Also, doubles were being printed as floats. This fixes that bug as well, and adds tests for all builtin types. as well as a test for function pointers. llvm-svn: 230703
Diffstat (limited to 'llvm/tools/llvm-pdbdump/VariableDumper.cpp')
-rw-r--r--llvm/tools/llvm-pdbdump/VariableDumper.cpp32
1 files changed, 28 insertions, 4 deletions
diff --git a/llvm/tools/llvm-pdbdump/VariableDumper.cpp b/llvm/tools/llvm-pdbdump/VariableDumper.cpp
index 913cfee6622..371c270443a 100644
--- a/llvm/tools/llvm-pdbdump/VariableDumper.cpp
+++ b/llvm/tools/llvm-pdbdump/VariableDumper.cpp
@@ -9,13 +9,14 @@
#include "VariableDumper.h"
+#include "BuiltinDumper.h"
#include "llvm-pdbdump.h"
#include "FunctionDumper.h"
#include "llvm/DebugInfo/PDB/PDBSymbolData.h"
#include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypeArray.h"
-#include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypePointer.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
@@ -57,7 +58,8 @@ void VariableDumper::start(const PDBSymbolData &Var, raw_ostream &OS,
void VariableDumper::dump(const PDBSymbolTypeBuiltin &Symbol, raw_ostream &OS,
int Indent) {
- OS << Symbol.getBuiltinType();
+ BuiltinDumper Dumper;
+ Dumper.start(Symbol, OS);
}
void VariableDumper::dump(const PDBSymbolTypeEnum &Symbol, raw_ostream &OS,
@@ -114,7 +116,29 @@ void VariableDumper::dumpSymbolTypeAndName(const PDBSymbol &Type,
ElementType->dump(OS, 0, *this);
OS << " " << Name << IndexStream.str();
} else {
- Type.dump(OS, 0, *this);
- OS << " " << Name;
+ if (!tryDumpFunctionPointer(Type, Name, OS)) {
+ Type.dump(OS, 0, *this);
+ OS << " " << Name;
+ }
+ }
+}
+
+bool VariableDumper::tryDumpFunctionPointer(const PDBSymbol &Type,
+ StringRef Name, raw_ostream &OS) {
+ // Function pointers come across as pointers to function signatures. But the
+ // signature carries no name, so we have to handle this case separately.
+ if (auto *PointerType = dyn_cast<PDBSymbolTypePointer>(&Type)) {
+ auto PointeeType = PointerType->getPointeeType();
+ if (auto *FunctionSig =
+ dyn_cast<PDBSymbolTypeFunctionSig>(PointeeType.get())) {
+ FunctionDumper Dumper;
+ FunctionDumper::PointerType PT = FunctionDumper::PointerType::Pointer;
+ if (PointerType->isReference())
+ PT = FunctionDumper::PointerType::Reference;
+ std::string NameStr(Name.begin(), Name.end());
+ Dumper.start(*FunctionSig, NameStr.c_str(), PT, OS);
+ return true;
+ }
}
+ return false;
}
OpenPOWER on IntegriCloud