blob: 854cf42d1baeeb2bb1a251eec00907077f433040 [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)
Zachary Turner1b1a70f2017-04-10 06:14:09 +000022 : PDBSymbol(PDBSession, std::move(Symbol)) {
23 assert(RawSymbol->getSymTag() == PDB_SymType::Compiland);
24}
Zachary Turner21473f72015-02-08 00:29:29 +000025
Zachary Turnerb52d08d2015-03-01 06:51:29 +000026void PDBSymbolCompiland::dump(PDBSymDumper &Dumper) const {
27 Dumper.dump(*this);
Zachary Turner21473f72015-02-08 00:29:29 +000028}
Zachary Turner43ec3af2016-02-18 18:47:29 +000029
30std::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}