LLVM  9.0.0svn
DIAInjectedSource.cpp
Go to the documentation of this file.
1 //===- DIAInjectedSource.cpp - DIA impl for IPDBInjectedSource --*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
10 #include "llvm/ADT/ArrayRef.h"
14 
15 using namespace llvm;
16 using namespace llvm::pdb;
17 
18 DIAInjectedSource::DIAInjectedSource(CComPtr<IDiaInjectedSource> DiaSourceFile)
19  : SourceFile(DiaSourceFile) {}
20 
22  DWORD Crc;
23  return (S_OK == SourceFile->get_crc(&Crc)) ? Crc : 0;
24 }
25 
27  ULONGLONG Size;
28  return (S_OK == SourceFile->get_length(&Size)) ? Size : 0;
29 }
30 
31 std::string DIAInjectedSource::getFileName() const {
32  return invokeBstrMethod(*SourceFile, &IDiaInjectedSource::get_filename);
33 }
34 
36  return invokeBstrMethod(*SourceFile, &IDiaInjectedSource::get_objectFilename);
37 }
38 
40  return invokeBstrMethod(*SourceFile,
41  &IDiaInjectedSource::get_virtualFilename);
42 }
43 
45  DWORD Compression = 0;
46  if (S_OK != SourceFile->get_sourceCompression(&Compression))
48  return static_cast<PDB_SourceCompression>(Compression);
49 }
50 
51 std::string DIAInjectedSource::getCode() const {
52  DWORD DataSize;
53  if (S_OK != SourceFile->get_source(0, &DataSize, nullptr))
54  return "";
55 
56  std::vector<uint8_t> Buffer(DataSize);
57  if (S_OK != SourceFile->get_source(DataSize, &DataSize, Buffer.data()))
58  return "";
59  assert(Buffer.size() == DataSize);
60  return std::string(reinterpret_cast<const char *>(Buffer.data()),
61  Buffer.size());
62 }
This class represents lattice values for constants.
Definition: AllocatorList.h:23
std::string getObjectFileName() const override
std::string getFileName() const override
std::string getCode() const override
uint64_t getCodeByteSize() const override
uint32_t getCrc32() const override
PDB_SourceCompression
Definition: PDBTypes.h:148
DIAInjectedSource(CComPtr< IDiaInjectedSource > DiaSourceFile)
std::string invokeBstrMethod(Obj &Object, HRESULT(__stdcall Obj::*Func)(BSTR *))
Definition: DIAUtils.h:16
PDB_SourceCompression getCompression() const override
std::string getVirtualFileName() const override
uint32_t Size
Definition: Profile.cpp:46
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())