clang 10.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
11 #include "clang/Serialization/ModuleFileExtension.h"
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.
20 class TestModuleFileExtension : public ModuleFileExtension {
21 std::string BlockName;
22 unsigned MajorVersion;
23 unsigned MinorVersion;
24 bool Hashed;
25 std::string UserInfo;
26
27 class Writer : public ModuleFileExtensionWriter {
28 public:
29 Writer(ModuleFileExtension *Ext) : ModuleFileExtensionWriter(Ext) { }
30 ~Writer() override;
31
32 void writeExtensionContents(Sema &SemaRef,
33 llvm::BitstreamWriter &Stream) override;
34 };
35
36 class Reader : public ModuleFileExtensionReader {
37 llvm::BitstreamCursor Stream;
38
39 public:
40 ~Reader() override;
41
42 Reader(ModuleFileExtension *Ext, const llvm::BitstreamCursor &InStream);
43 };
44
45 public:
46 TestModuleFileExtension(StringRef BlockName,
47 unsigned MajorVersion,
48 unsigned MinorVersion,
49 bool Hashed,
50 StringRef UserInfo)
51 : BlockName(BlockName),
52 MajorVersion(MajorVersion), MinorVersion(MinorVersion),
53 Hashed(Hashed), UserInfo(UserInfo) { }
54 ~TestModuleFileExtension() override;
55
56 ModuleFileExtensionMetadata getExtensionMetadata() const override;
57
58 llvm::hash_code hashExtension(llvm::hash_code Code) const override;
59
60 std::unique_ptr<ModuleFileExtensionWriter>
61 createExtensionWriter(ASTWriter &Writer) override;
62
63 std::unique_ptr<ModuleFileExtensionReader>
64 createExtensionReader(const ModuleFileExtensionMetadata &Metadata,
65 ASTReader &Reader, serialization::ModuleFile &Mod,
66 const llvm::BitstreamCursor &Stream) override;
67 };
68
69 } // end namespace clang
70
71 #endif // LLVM_CLANG_FRONTEND_TESTMODULEFILEEXTENSION_H
ModuleFileExtension.h
clang::TestModuleFileExtension::createExtensionWriter
std::unique_ptr< ModuleFileExtensionWriter > createExtensionWriter(ASTWriter &Writer) override
Create a new module file extension writer, which will be responsible for writing the extension conten...
Definition: TestModuleFileExtension.cpp:107
clang::TestModuleFileExtension
A module file extension used for testing purposes.
Definition: TestModuleFileExtension.h:20
LLVM.h
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
clang::TestModuleFileExtension::TestModuleFileExtension
TestModuleFileExtension(StringRef BlockName, unsigned MajorVersion, unsigned MinorVersion, bool Hashed, StringRef UserInfo)
Definition: TestModuleFileExtension.h:46
clang::Sema
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:336
clang::TestModuleFileExtension::~TestModuleFileExtension
~TestModuleFileExtension() override
Definition: TestModuleFileExtension.cpp:87
clang::ModuleFileExtensionReader
Abstract base class that reads a module file extension block from a module file.
Definition: ModuleFileExtension.h:131
clang::TestModuleFileExtension::createExtensionReader
std::unique_ptr< ModuleFileExtensionReader > createExtensionReader(const ModuleFileExtensionMetadata &Metadata, ASTReader &Reader, serialization::ModuleFile &Mod, const llvm::BitstreamCursor &Stream) override
Create a new module file extension reader, given the metadata read from the block and the cursor into...
Definition: TestModuleFileExtension.cpp:112
clang::TestModuleFileExtension::hashExtension
llvm::hash_code hashExtension(llvm::hash_code Code) const override
Hash information about the presence of this extension into the module hash code.
Definition: TestModuleFileExtension.cpp:94
clang::TestModuleFileExtension::getExtensionMetadata
ModuleFileExtensionMetadata getExtensionMetadata() const override
Retrieves the metadata for this module file extension.
Definition: TestModuleFileExtension.cpp:90
clang::serialization::ModuleFile
Information about a module that has been loaded by the ASTReader.
Definition: ModuleFile.h:107
clang::ModuleFileExtensionWriter
Abstract base class that writes a module file extension block into a module file. ...
Definition: ModuleFileExtension.h:104
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:21
clang::ASTReader
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:340
clang::ModuleFileExtensionMetadata
Metadata for a module file extension.
Definition: ModuleFileExtension.h:34
clang::ASTWriter
Writes an AST file containing the contents of a translation unit.
Definition: ASTWriter.h:96
clang::ModuleFileExtension
An abstract superclass that describes a custom extension to the module/precompiled header file format...
Definition: ModuleFileExtension.h:62