clang  14.0.0git
TestModuleFileExtension.h
Go to the documentation of this file.
1 //===-- TestModuleFileExtension.h - Module Extension Tester -----*- 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 #ifndef LLVM_CLANG_FRONTEND_TESTMODULEFILEEXTENSION_H
9 #define LLVM_CLANG_FRONTEND_TESTMODULEFILEEXTENSION_H
10 
12 #include "clang/Basic/LLVM.h"
13 #include "llvm/ADT/StringRef.h"
14 #include "llvm/Bitstream/BitstreamReader.h"
15 #include <string>
16 
17 namespace clang {
18 
19 /// A module file extension used for testing purposes.
21  : public llvm::RTTIExtends<TestModuleFileExtension, ModuleFileExtension> {
22  std::string BlockName;
23  unsigned MajorVersion;
24  unsigned MinorVersion;
25  bool Hashed;
26  std::string UserInfo;
27 
28  class Writer : public ModuleFileExtensionWriter {
29  public:
30  Writer(ModuleFileExtension *Ext) : ModuleFileExtensionWriter(Ext) { }
31  ~Writer() override;
32 
33  void writeExtensionContents(Sema &SemaRef,
34  llvm::BitstreamWriter &Stream) override;
35  };
36 
37  class Reader : public ModuleFileExtensionReader {
38  llvm::BitstreamCursor Stream;
39 
40  public:
41  ~Reader() override;
42 
43  Reader(ModuleFileExtension *Ext, const llvm::BitstreamCursor &InStream);
44  };
45 
46 public:
47  static char ID;
48 
49  TestModuleFileExtension(StringRef BlockName, unsigned MajorVersion,
50  unsigned MinorVersion, bool Hashed,
51  StringRef UserInfo)
52  : BlockName(BlockName), MajorVersion(MajorVersion),
53  MinorVersion(MinorVersion), Hashed(Hashed), UserInfo(UserInfo) {}
54  ~TestModuleFileExtension() override;
55 
57 
58  void hashExtension(ExtensionHashBuilder &HBuilder) const override;
59 
60  std::unique_ptr<ModuleFileExtensionWriter>
61  createExtensionWriter(ASTWriter &Writer) override;
62 
63  std::unique_ptr<ModuleFileExtensionReader>
66  const llvm::BitstreamCursor &Stream) override;
67 
68  std::string str() const;
69 };
70 
71 } // end namespace clang
72 
73 #endif // LLVM_CLANG_FRONTEND_TESTMODULEFILEEXTENSION_H
clang::TestModuleFileExtension::~TestModuleFileExtension
~TestModuleFileExtension() override
Definition: TestModuleFileExtension.cpp:89
clang::TestModuleFileExtension::createExtensionReader
std::unique_ptr< ModuleFileExtensionReader > createExtensionReader(const ModuleFileExtensionMetadata &Metadata, ASTReader &Reader, serialization::ModuleFile &Mod, const llvm::BitstreamCursor &Stream) override
Definition: TestModuleFileExtension.cpp:112
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::TestModuleFileExtension::str
std::string str() const
Definition: TestModuleFileExtension.cpp:131
clang::TestModuleFileExtension::hashExtension
void hashExtension(ExtensionHashBuilder &HBuilder) const override
Definition: TestModuleFileExtension.cpp:96
clang::ModuleFileExtension
An abstract superclass that describes a custom extension to the module/precompiled header file format...
Definition: ModuleFileExtension.h:66
clang::TestModuleFileExtension::ID
static char ID
Definition: TestModuleFileExtension.h:47
clang::ASTWriter
Writes an AST file containing the contents of a translation unit.
Definition: ASTWriter.h:99
clang::TestModuleFileExtension
A module file extension used for testing purposes.
Definition: TestModuleFileExtension.h:20
clang::Sema
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:354
LLVM.h
ModuleFileExtension.h
clang::ASTReader
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:342
clang
Definition: CalledOnceCheck.h:17
clang::ModuleFileExtensionWriter
Abstract base class that writes a module file extension block into a module file.
Definition: ModuleFileExtension.h:113
clang::ModuleFileExtensionMetadata
Metadata for a module file extension.
Definition: ModuleFileExtension.h:36
clang::TestModuleFileExtension::createExtensionWriter
std::unique_ptr< ModuleFileExtensionWriter > createExtensionWriter(ASTWriter &Writer) override
Definition: TestModuleFileExtension.cpp:107
clang::ModuleFileExtensionReader
Abstract base class that reads a module file extension block from a module file.
Definition: ModuleFileExtension.h:140
clang::TestModuleFileExtension::getExtensionMetadata
ModuleFileExtensionMetadata getExtensionMetadata() const override
Definition: TestModuleFileExtension.cpp:92
clang::serialization::ModuleFile
Information about a module that has been loaded by the ASTReader.
Definition: ModuleFile.h:111
clang::TestModuleFileExtension::TestModuleFileExtension
TestModuleFileExtension(StringRef BlockName, unsigned MajorVersion, unsigned MinorVersion, bool Hashed, StringRef UserInfo)
Definition: TestModuleFileExtension.h:49