blob: ebff08846cacea616fbdcbf8151d1e2c0776a9a8 [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;
Zachary Turnerec28fc32016-05-04 20:32:13 +000018using namespace llvm::pdb;
Zachary Turner21473f72015-02-08 00:29:29 +000019
Zachary Turner98571ed2015-02-08 22:53:53 +000020PDBSymbolCompiland::PDBSymbolCompiland(const IPDBSession &PDBSession,
Zachary Turnerbae16b32015-02-08 20:58:09 +000021 std::unique_ptr<IPDBRawSymbol> Symbol)
22 : PDBSymbol(PDBSession, std::move(Symbol)) {}
Zachary Turner21473f72015-02-08 00:29:29 +000023
Zachary Turnerb52d08d2015-03-01 06:51:29 +000024void PDBSymbolCompiland::dump(PDBSymDumper &Dumper) const {
25 Dumper.dump(*this);
Zachary Turner21473f72015-02-08 00:29:29 +000026}
Zachary Turner43ec3af2016-02-18 18:47:29 +000027
28std::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}