Zachary Turner | 21473f7 | 2015-02-08 00:29:29 +0000 | [diff] [blame] | 1 | //===- PDBSymbolCompiland.cpp - compiland details --------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
Zachary Turner | 52c9f88 | 2015-02-14 03:53:56 +0000 | [diff] [blame] | 10 | #include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h" |
Zachary Turner | 43ec3af | 2016-02-18 18:47:29 +0000 | [diff] [blame] | 11 | #include "llvm/DebugInfo/PDB/PDBSymbolCompilandEnv.h" |
Zachary Turner | 52c9f88 | 2015-02-14 03:53:56 +0000 | [diff] [blame] | 12 | |
Zachary Turner | 9a818ad | 2015-02-22 22:03:38 +0000 | [diff] [blame] | 13 | #include "llvm/DebugInfo/PDB/PDBSymDumper.h" |
Zachary Turner | 52c9f88 | 2015-02-14 03:53:56 +0000 | [diff] [blame] | 14 | |
Chandler Carruth | 71f308a | 2015-02-13 09:09:03 +0000 | [diff] [blame] | 15 | #include <utility> |
Zachary Turner | 21473f7 | 2015-02-08 00:29:29 +0000 | [diff] [blame] | 16 | |
| 17 | using namespace llvm; |
Zachary Turner | ec28fc3 | 2016-05-04 20:32:13 +0000 | [diff] [blame] | 18 | using namespace llvm::pdb; |
Zachary Turner | 21473f7 | 2015-02-08 00:29:29 +0000 | [diff] [blame] | 19 | |
Zachary Turner | 98571ed | 2015-02-08 22:53:53 +0000 | [diff] [blame] | 20 | PDBSymbolCompiland::PDBSymbolCompiland(const IPDBSession &PDBSession, |
Zachary Turner | bae16b3 | 2015-02-08 20:58:09 +0000 | [diff] [blame] | 21 | std::unique_ptr<IPDBRawSymbol> Symbol) |
Zachary Turner | 1b1a70f | 2017-04-10 06:14:09 +0000 | [diff] [blame^] | 22 | : PDBSymbol(PDBSession, std::move(Symbol)) { |
| 23 | assert(RawSymbol->getSymTag() == PDB_SymType::Compiland); |
| 24 | } |
Zachary Turner | 21473f7 | 2015-02-08 00:29:29 +0000 | [diff] [blame] | 25 | |
Zachary Turner | b52d08d | 2015-03-01 06:51:29 +0000 | [diff] [blame] | 26 | void PDBSymbolCompiland::dump(PDBSymDumper &Dumper) const { |
| 27 | Dumper.dump(*this); |
Zachary Turner | 21473f7 | 2015-02-08 00:29:29 +0000 | [diff] [blame] | 28 | } |
Zachary Turner | 43ec3af | 2016-02-18 18:47:29 +0000 | [diff] [blame] | 29 | |
| 30 | std::string PDBSymbolCompiland::getSourceFileName() const |
| 31 | { |
| 32 | std::string Result = RawSymbol->getSourceFileName(); |
| 33 | if (!Result.empty()) |
| 34 | return Result; |
| 35 | auto Envs = findAllChildren<PDBSymbolCompilandEnv>(); |
| 36 | if (!Envs) |
| 37 | return std::string(); |
| 38 | while (auto Env = Envs->getNext()) { |
| 39 | std::string Var = Env->getName(); |
| 40 | if (Var != "src") |
| 41 | continue; |
| 42 | std::string Value = Env->getValue(); |
| 43 | return Value; |
| 44 | } |
| 45 | return std::string(); |
| 46 | } |