]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/DebugInfo/PDB/PDBSymbolCompiland.cpp
MFV r319740: 8168 NULL pointer dereference in zfs_create()
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / DebugInfo / PDB / PDBSymbolCompiland.cpp
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
24 void PDBSymbolCompiland::dump(PDBSymDumper &Dumper) const {
25   Dumper.dump(*this);
26 }
27
28 std::string PDBSymbolCompiland::getSourceFileName() const
29 {
30     std::string Result = RawSymbol->getSourceFileName();
31     if (!Result.empty())
32         return Result;
33     auto Envs = findAllChildren<PDBSymbolCompilandEnv>();
34     if (!Envs)
35         return std::string();
36     while (auto Env = Envs->getNext()) {
37         std::string Var = Env->getName();
38         if (Var != "src")
39             continue;
40         std::string Value = Env->getValue();
41         return Value;
42     }
43     return std::string();
44 }