Skip to content

Commit 6c0d9a6

Browse files
committed
[ClangModuleLoader] Provide a function to allow access to the clang::CompilerInstance, NFC.
1 parent 661a503 commit 6c0d9a6

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

include/swift/AST/ClangModuleLoader.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
namespace clang {
1919
class ASTContext;
20+
class CompilerInstance;
2021
class Preprocessor;
2122
class Sema;
2223
} // namespace clang
@@ -32,6 +33,7 @@ class ClangModuleLoader : public ModuleLoader {
3233
virtual clang::ASTContext &getClangASTContext() const = 0;
3334
virtual clang::Preprocessor &getClangPreprocessor() const = 0;
3435
virtual clang::Sema &getClangSema() const = 0;
36+
virtual const clang::CompilerInstance &getClangInstance() const = 0;
3537
virtual void printStatistics() const = 0;
3638

3739
/// Returns the module that contains imports and declarations from all loaded

include/swift/ClangImporter/ClangImporter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ class ClangImporter final : public ClangModuleLoader {
241241
clang::ASTContext &getClangASTContext() const override;
242242
clang::Preprocessor &getClangPreprocessor() const override;
243243
clang::Sema &getClangSema() const override;
244+
const clang::CompilerInstance &getClangInstance() const override;
244245
clang::CodeGenOptions &getClangCodeGenOpts() const;
245246

246247
std::string getClangModuleHash() const;

lib/ClangImporter/ClangImporter.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2373,6 +2373,11 @@ clang::ASTContext &ClangImporter::getClangASTContext() const {
23732373
clang::Preprocessor &ClangImporter::getClangPreprocessor() const {
23742374
return Impl.getClangPreprocessor();
23752375
}
2376+
2377+
const clang::CompilerInstance &ClangImporter::getClangInstance() const {
2378+
return *Impl.Instance;
2379+
}
2380+
23762381
const clang::Module *ClangImporter::getClangOwningModule(ClangNode Node) const {
23772382
return ::getClangOwningModule(Node, getClangASTContext());
23782383
}

0 commit comments

Comments
 (0)