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 10 #include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h" 11 #include "llvm/DebugInfo/PDB/PDBSymbolCompilandEnv.h" 12 13 #include "llvm/DebugInfo/PDB/PDBSymDumper.h" 14 15 #include <utility> 16 17 using namespace llvm; 18 using namespace llvm::pdb; 19 20 PDBSymbolCompiland::PDBSymbolCompiland(const IPDBSession &PDBSession, 21 std::unique_ptr<IPDBRawSymbol> Symbol) 22 : PDBSymbol(PDBSession, std::move(Symbol)) { 23 assert(RawSymbol->getSymTag() == PDB_SymType::Compiland); 24 } 25 26 void PDBSymbolCompiland::dump(PDBSymDumper &Dumper) const { 27 Dumper.dump(*this); 28 } 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 } 47