[clang][Modules] Move ASTSourceDescriptor into its own file (#67930)
This commit is contained in:
52
clang/include/clang/Basic/ASTSourceDescriptor.h
Normal file
52
clang/include/clang/Basic/ASTSourceDescriptor.h
Normal file
@@ -0,0 +1,52 @@
|
||||
//===- ASTSourceDescriptor.h -----------------------------*- C++ -*-===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
/// \file
|
||||
/// Defines the clang::ASTSourceDescriptor class, which abstracts clang modules
|
||||
/// and precompiled header files
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
|
||||
#define LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
|
||||
|
||||
#include "clang/Basic/Module.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace clang {
|
||||
|
||||
/// Abstracts clang modules and precompiled header files and holds
|
||||
/// everything needed to generate debug info for an imported module
|
||||
/// or PCH.
|
||||
class ASTSourceDescriptor {
|
||||
StringRef PCHModuleName;
|
||||
StringRef Path;
|
||||
StringRef ASTFile;
|
||||
ASTFileSignature Signature;
|
||||
Module *ClangModule = nullptr;
|
||||
|
||||
public:
|
||||
ASTSourceDescriptor() = default;
|
||||
ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile,
|
||||
ASTFileSignature Signature)
|
||||
: PCHModuleName(std::move(Name)), Path(std::move(Path)),
|
||||
ASTFile(std::move(ASTFile)), Signature(Signature) {}
|
||||
ASTSourceDescriptor(Module &M);
|
||||
|
||||
std::string getModuleName() const;
|
||||
StringRef getPath() const { return Path; }
|
||||
StringRef getASTFile() const { return ASTFile; }
|
||||
ASTFileSignature getSignature() const { return Signature; }
|
||||
Module *getModuleOrNull() const { return ClangModule; }
|
||||
};
|
||||
|
||||
} // namespace clang
|
||||
|
||||
#endif // LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
|
||||
@@ -868,32 +868,6 @@ private:
|
||||
unsigned Generation = 0;
|
||||
};
|
||||
|
||||
/// Abstracts clang modules and precompiled header files and holds
|
||||
/// everything needed to generate debug info for an imported module
|
||||
/// or PCH.
|
||||
class ASTSourceDescriptor {
|
||||
StringRef PCHModuleName;
|
||||
StringRef Path;
|
||||
StringRef ASTFile;
|
||||
ASTFileSignature Signature;
|
||||
Module *ClangModule = nullptr;
|
||||
|
||||
public:
|
||||
ASTSourceDescriptor() = default;
|
||||
ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile,
|
||||
ASTFileSignature Signature)
|
||||
: PCHModuleName(std::move(Name)), Path(std::move(Path)),
|
||||
ASTFile(std::move(ASTFile)), Signature(Signature) {}
|
||||
ASTSourceDescriptor(Module &M);
|
||||
|
||||
std::string getModuleName() const;
|
||||
StringRef getPath() const { return Path; }
|
||||
StringRef getASTFile() const { return ASTFile; }
|
||||
ASTFileSignature getSignature() const { return Signature; }
|
||||
Module *getModuleOrNull() const { return ClangModule; }
|
||||
};
|
||||
|
||||
|
||||
} // namespace clang
|
||||
|
||||
#endif // LLVM_CLANG_BASIC_MODULE_H
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
#include "clang/AST/ExternalASTSource.h"
|
||||
#include "clang/AST/ASTContext.h"
|
||||
#include "clang/AST/DeclarationName.h"
|
||||
#include "clang/Basic/ASTSourceDescriptor.h"
|
||||
#include "clang/Basic/FileManager.h"
|
||||
#include "clang/Basic/IdentifierTable.h"
|
||||
#include "clang/Basic/LLVM.h"
|
||||
#include "clang/Basic/Module.h"
|
||||
#include "clang/Basic/SourceManager.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include <cstdint>
|
||||
|
||||
33
clang/lib/Basic/ASTSourceDescriptor.cpp
Normal file
33
clang/lib/Basic/ASTSourceDescriptor.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
//===- ASTSourceDescriptor.cpp -------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
/// Defines the clang::ASTSourceDescriptor class, which abstracts clang modules
|
||||
/// and precompiled header files
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "clang/Basic/ASTSourceDescriptor.h"
|
||||
|
||||
namespace clang {
|
||||
|
||||
ASTSourceDescriptor::ASTSourceDescriptor(Module &M)
|
||||
: Signature(M.Signature), ClangModule(&M) {
|
||||
if (M.Directory)
|
||||
Path = M.Directory->getName();
|
||||
if (auto File = M.getASTFile())
|
||||
ASTFile = File->getName();
|
||||
}
|
||||
|
||||
std::string ASTSourceDescriptor::getModuleName() const {
|
||||
if (ClangModule)
|
||||
return ClangModule->Name;
|
||||
else
|
||||
return std::string(PCHModuleName);
|
||||
}
|
||||
|
||||
} // namespace clang
|
||||
@@ -55,6 +55,7 @@ if(CLANG_VENDOR)
|
||||
endif()
|
||||
|
||||
add_clang_library(clangBasic
|
||||
ASTSourceDescriptor.cpp
|
||||
Attributes.cpp
|
||||
Builtins.cpp
|
||||
CLWarnings.cpp
|
||||
|
||||
@@ -724,18 +724,3 @@ void VisibleModuleSet::setVisible(Module *M, SourceLocation Loc,
|
||||
};
|
||||
VisitModule({M, nullptr});
|
||||
}
|
||||
|
||||
ASTSourceDescriptor::ASTSourceDescriptor(Module &M)
|
||||
: Signature(M.Signature), ClangModule(&M) {
|
||||
if (M.Directory)
|
||||
Path = M.Directory->getName();
|
||||
if (auto File = M.getASTFile())
|
||||
ASTFile = File->getName();
|
||||
}
|
||||
|
||||
std::string ASTSourceDescriptor::getModuleName() const {
|
||||
if (ClangModule)
|
||||
return ClangModule->Name;
|
||||
else
|
||||
return std::string(PCHModuleName);
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
#include "clang/AST/PrettyPrinter.h"
|
||||
#include "clang/AST/Type.h"
|
||||
#include "clang/AST/TypeOrdering.h"
|
||||
#include "clang/Basic/ASTSourceDescriptor.h"
|
||||
#include "clang/Basic/CodeGenOptions.h"
|
||||
#include "clang/Basic/Module.h"
|
||||
#include "clang/Basic/SourceLocation.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/DenseSet.h"
|
||||
@@ -38,6 +38,7 @@ class MDNode;
|
||||
namespace clang {
|
||||
class ClassTemplateSpecializationDecl;
|
||||
class GlobalDecl;
|
||||
class Module;
|
||||
class ModuleMap;
|
||||
class ObjCInterfaceDecl;
|
||||
class UsingDecl;
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "clang/AST/TypeLoc.h"
|
||||
#include "clang/AST/TypeLocVisitor.h"
|
||||
#include "clang/AST/UnresolvedSet.h"
|
||||
#include "clang/Basic/ASTSourceDescriptor.h"
|
||||
#include "clang/Basic/CommentOptions.h"
|
||||
#include "clang/Basic/Diagnostic.h"
|
||||
#include "clang/Basic/DiagnosticError.h"
|
||||
|
||||
@@ -9,13 +9,19 @@
|
||||
#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_ASTUTILS_H
|
||||
#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_ASTUTILS_H
|
||||
|
||||
#include "clang/Basic/Module.h"
|
||||
#include "clang/Basic/ASTSourceDescriptor.h"
|
||||
#include "clang/Sema/Lookup.h"
|
||||
#include "clang/Sema/MultiplexExternalSemaSource.h"
|
||||
#include "clang/Sema/Sema.h"
|
||||
#include "clang/Sema/SemaConsumer.h"
|
||||
#include <optional>
|
||||
|
||||
namespace clang {
|
||||
|
||||
class Module;
|
||||
|
||||
} // namespace clang
|
||||
|
||||
namespace lldb_private {
|
||||
|
||||
/// Wraps an ExternalASTSource into an ExternalSemaSource. Doesn't take
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "clang/AST/Decl.h"
|
||||
#include "clang/AST/DeclObjC.h"
|
||||
#include "clang/Basic/Module.h"
|
||||
#include <optional>
|
||||
|
||||
using namespace lldb_private;
|
||||
|
||||
@@ -10,9 +10,15 @@
|
||||
#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGEXTERNALASTSOURCECALLBACKS_H
|
||||
|
||||
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
|
||||
#include "clang/Basic/Module.h"
|
||||
#include "clang/Basic/ASTSourceDescriptor.h"
|
||||
#include <optional>
|
||||
|
||||
namespace clang {
|
||||
|
||||
class Module;
|
||||
|
||||
} // namespace clang
|
||||
|
||||
namespace lldb_private {
|
||||
|
||||
class ClangExternalASTSourceCallbacks : public clang::ExternalASTSource {
|
||||
|
||||
Reference in New Issue
Block a user