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 
19 PDBSymbolCompiland::PDBSymbolCompiland(const IPDBSession &PDBSession,
20                                        std::unique_ptr<IPDBRawSymbol> Symbol)
21     : PDBSymbol(PDBSession, std::move(Symbol)) {}
22 
23 void PDBSymbolCompiland::dump(PDBSymDumper &Dumper) const {
24   Dumper.dump(*this);
25 }
26 
27 std::string PDBSymbolCompiland::getSourceFileName() const
28 {
29     std::string Result = RawSymbol->getSourceFileName();
30     if (!Result.empty())
31         return Result;
32     auto Envs = findAllChildren<PDBSymbolCompilandEnv>();
33     if (!Envs)
34         return std::string();
35     while (auto Env = Envs->getNext()) {
36         std::string Var = Env->getName();
37         if (Var != "src")
38             continue;
39         std::string Value = Env->getValue();
40         return Value;
41     }
42     return std::string();
43 }
44