[llvm] r271168 - [pdb] Make an abstract base class for PDBFile.

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Sat May 28 22:38:27 PDT 2016


Author: zturner
Date: Sun May 29 00:36:01 2016
New Revision: 271168

URL: http://llvm.org/viewvc/llvm-project?rev=271168&view=rev
Log:
[pdb] Make an abstract base class for PDBFile.

This will allow us to mock it out in a unit test to begin
writing unit tests for the various PDB and codeview classes.

Added:
    llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IPDBFile.h
Modified:
    llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PDBFile.h

Added: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IPDBFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IPDBFile.h?rev=271168&view=auto
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IPDBFile.h (added)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IPDBFile.h Sun May 29 00:36:01 2016
@@ -0,0 +1,45 @@
+//===- IPDBFile.h - Abstract base class for a PDB file ----------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DEBUGINFO_PDB_RAW_IPDBFILE_H
+#define LLVM_DEBUGINFO_PDB_RAW_IPDBFILE_H
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Endian.h"
+
+#include <stdint.h>
+
+namespace llvm {
+namespace pdb {
+
+struct IPDBFile {
+public:
+  virtual ~IPDBFile() {}
+
+  virtual uint32_t getBlockSize() const = 0;
+  virtual uint32_t getBlockCount() const = 0;
+  virtual uint32_t getNumDirectoryBytes() const = 0;
+  virtual uint32_t getBlockMapIndex() const = 0;
+  virtual uint32_t getNumDirectoryBlocks() const = 0;
+  virtual uint64_t getBlockMapOffset() const = 0;
+
+  virtual uint32_t getNumStreams() const = 0;
+  virtual uint32_t getStreamByteSize(uint32_t StreamIndex) const = 0;
+  virtual ArrayRef<uint32_t> getStreamBlockList(uint32_t StreamIndex) const = 0;
+
+  virtual StringRef getBlockData(uint32_t BlockIndex,
+                                 uint32_t NumBytes) const = 0;
+
+  virtual ArrayRef<support::ulittle32_t> getDirectoryBlockArray() = 0;
+};
+}
+}
+
+#endif // LLVM_DEBUGINFO_PDB_RAW_IPDBFILE_H

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PDBFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PDBFile.h?rev=271168&r1=271167&r2=271168&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PDBFile.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PDBFile.h Sun May 29 00:36:01 2016
@@ -11,6 +11,7 @@
 #define LLVM_DEBUGINFO_PDB_RAW_PDBFILE_H
 
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/DebugInfo/PDB/Raw/IPDBFile.h"
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/MathExtras.h"
@@ -28,27 +29,28 @@ class PublicsStream;
 class SymbolStream;
 class TpiStream;
 
-class PDBFile {
+class PDBFile : public IPDBFile {
 public:
   explicit PDBFile(std::unique_ptr<MemoryBuffer> MemBuffer);
-  ~PDBFile();
+  ~PDBFile() override;
 
-  uint32_t getBlockSize() const;
   uint32_t getUnknown0() const;
-  uint32_t getBlockCount() const;
-  uint32_t getNumDirectoryBytes() const;
-  uint32_t getBlockMapIndex() const;
   uint32_t getUnknown1() const;
-  uint32_t getNumDirectoryBlocks() const;
-  uint64_t getBlockMapOffset() const;
 
-  uint32_t getNumStreams() const;
-  uint32_t getStreamByteSize(uint32_t StreamIndex) const;
-  ArrayRef<uint32_t> getStreamBlockList(uint32_t StreamIndex) const;
+  uint32_t getBlockSize() const override;
+  uint32_t getBlockCount() const override;
+  uint32_t getNumDirectoryBytes() const override;
+  uint32_t getBlockMapIndex() const override;
+  uint32_t getNumDirectoryBlocks() const override;
+  uint64_t getBlockMapOffset() const override;
+
+  uint32_t getNumStreams() const override;
+  uint32_t getStreamByteSize(uint32_t StreamIndex) const override;
+  ArrayRef<uint32_t> getStreamBlockList(uint32_t StreamIndex) const override;
 
-  StringRef getBlockData(uint32_t BlockIndex, uint32_t NumBytes) const;
+  StringRef getBlockData(uint32_t BlockIndex, uint32_t NumBytes) const override;
 
-  ArrayRef<support::ulittle32_t> getDirectoryBlockArray();
+  ArrayRef<support::ulittle32_t> getDirectoryBlockArray() override;
 
   Error parseFileHeaders();
   Error parseStreamData();




More information about the llvm-commits mailing list