blob: 8393b5cdfd1acd1a9fef1b28e30b891df5d7a222 [file] [log] [blame]
Zachary Turner21473f72015-02-08 00:29:29 +00001//===- 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 Turner52c9f882015-02-14 03:53:56 +000010#include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
Zachary Turner43ec3af2016-02-18 18:47:29 +000011#include "llvm/DebugInfo/PDB/PDBSymbolCompilandEnv.h"
Zachary Turner52c9f882015-02-14 03:53:56 +000012
Zachary Turner9a818ad2015-02-22 22:03:38 +000013#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
Zachary Turner52c9f882015-02-14 03:53:56 +000014
Chandler Carruth71f308a2015-02-13 09:09:03 +000015#include <utility>
Zachary Turner21473f72015-02-08 00:29:29 +000016
17using namespace llvm;
18
Zachary Turner98571ed2015-02-08 22:53:53 +000019PDBSymbolCompiland::PDBSymbolCompiland(const IPDBSession &PDBSession,
Zachary Turnerbae16b32015-02-08 20:58:09 +000020 std::unique_ptr<IPDBRawSymbol> Symbol)
21 : PDBSymbol(PDBSession, std::move(Symbol)) {}
Zachary Turner21473f72015-02-08 00:29:29 +000022
Zachary Turnerb52d08d2015-03-01 06:51:29 +000023void PDBSymbolCompiland::dump(PDBSymDumper &Dumper) const {
24 Dumper.dump(*this);
Zachary Turner21473f72015-02-08 00:29:29 +000025}
Zachary Turner43ec3af2016-02-18 18:47:29 +000026
27std::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}