[clang] [clang-tools-extra] [libcxx] [lldb] [llvm] Add clang basic module directory (PR #93388)
via llvm-commits
llvm-commits at lists.llvm.org
Sat May 25 17:18:16 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff faef8b4aa245a671e2013319e8073a9fc52ae12e 9be7409d8d246a24432faf7d5c238d6c0e1763d9 -- clang/include/clang/Basic/ASTSourceDescriptor.h clang/include/clang/Basic/Module/ASTSourceDescriptor.h clang/lib/Basic/Module/ASTSourceDescriptor.cpp clang/lib/Basic/Module/Module.cpp clang-tools-extra/clangd/unittests/ReplayPeambleTests.cpp clang/include/clang/APINotes/APINotesManager.h clang/include/clang/ExtractAPI/ExtractAPIVisitor.h clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h clang/include/clang/Lex/ModuleLoader.h clang/include/clang/Lex/ModuleMap.h clang/include/clang/Lex/Preprocessor.h clang/include/clang/Sema/Sema.h clang/include/clang/Serialization/ASTWriter.h clang/include/clang/Serialization/ModuleFile.h clang/include/clang/Serialization/ModuleManager.h clang/include/clang/Serialization/PCHContainerOperations.h clang/lib/AST/ASTContext.cpp clang/lib/AST/ASTDumper.cpp clang/lib/AST/Decl.cpp clang/lib/AST/DeclBase.cpp clang/lib/AST/DeclPrinter.cpp clang/lib/AST/ExternalASTSource.cpp clang/lib/AST/ItaniumMangle.cpp clang/lib/AST/ODRDiagsEmitter.cpp clang/lib/AST/TextNodeDumper.cpp clang/lib/Basic/Module.cpp clang/lib/CodeGen/CGDebugInfo.h clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/CodeGenModule.h clang/lib/ExtractAPI/API.cpp clang/lib/ExtractAPI/TypedefUnderlyingTypeResolver.cpp clang/lib/Frontend/ASTUnit.cpp clang/lib/Frontend/FrontendActions.cpp clang/lib/Lex/HeaderSearch.cpp clang/lib/Lex/ModuleMap.cpp clang/lib/Lex/PPDirectives.cpp clang/lib/Lex/Pragma.cpp clang/lib/Lex/Preprocessor.cpp clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTReaderDecl.cpp clang/lib/Serialization/ASTWriter.cpp libcxx/test/tools/clang_tidy_checks/header_exportable_declarations.cpp lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h clang/include/clang/Basic/Module/Module.h
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/include/clang/Basic/Module/Module.h b/clang/include/clang/Basic/Module/Module.h
index e86f4303d7..f71595c23b 100644
--- a/clang/include/clang/Basic/Module/Module.h
+++ b/clang/include/clang/Basic/Module/Module.h
@@ -230,7 +230,7 @@ private:
std::vector<std::string> TopHeaderNames;
/// Cache of modules visible to lookup in this module.
- mutable llvm::DenseSet<const Module*> VisibleModulesCache;
+ mutable llvm::DenseSet<const Module *> VisibleModulesCache;
/// The ID used when referencing this module within a VisibleModuleSet.
unsigned VisibilityID;
@@ -545,10 +545,8 @@ public:
///
/// \param ShadowingModule If this module is unavailable because it is
/// shadowed, this parameter will be set to the shadowing module.
- bool isAvailable(const LangOptions &LangOpts,
- const TargetInfo &Target,
- Requirement &Req,
- UnresolvedHeaderDirective &MissingHeader,
+ bool isAvailable(const LangOptions &LangOpts, const TargetInfo &Target,
+ Requirement &Req, UnresolvedHeaderDirective &MissingHeader,
Module *&ShadowingModule) const;
/// Determine whether this module is a submodule.
@@ -665,7 +663,7 @@ public:
/// be this module.
Module *getTopLevelModule() {
return const_cast<Module *>(
- const_cast<const Module *>(this)->getTopLevelModule());
+ const_cast<const Module *>(this)->getTopLevelModule());
}
/// Retrieve the top-level module for this (sub)module, which may
@@ -673,9 +671,7 @@ public:
const Module *getTopLevelModule() const;
/// Retrieve the name of the top-level module.
- StringRef getTopLevelModuleName() const {
- return getTopLevelModule()->Name;
- }
+ StringRef getTopLevelModuleName() const { return getTopLevelModule()->Name; }
/// The serialized AST file for this module, if one was created.
OptionalFileEntryRef getASTFile() const {
@@ -739,8 +735,7 @@ public:
/// \param Target The target options that will be used to evaluate the
/// availability of this feature.
void addRequirement(StringRef Feature, bool RequiredState,
- const LangOptions &LangOpts,
- const TargetInfo &Target);
+ const LangOptions &LangOpts, const TargetInfo &Target);
/// Mark this module and all of its submodules as unavailable.
void markUnavailable(bool Unimportable);
@@ -793,9 +788,7 @@ public:
/// directly exported), not the complete set of exported modules.
void getExportedModules(SmallVectorImpl<Module *> &Exported) const;
- static StringRef getModuleInputBufferName() {
- return "<module-includes>";
- }
+ static StringRef getModuleInputBufferName() { return "<module-includes>"; }
/// Print the module map for this module to the given stream.
void print(raw_ostream &OS, unsigned Indent = 0, bool Dump = false) const;
@@ -832,9 +825,7 @@ public:
unsigned getGeneration() const { return Generation; }
/// Determine whether a module is visible.
- bool isVisible(const Module *M) const {
- return getImportLoc(M).isValid();
- }
+ bool isVisible(const Module *M) const { return getImportLoc(M).isValid(); }
/// Get the location at which the import of a module was triggered.
SourceLocation getImportLoc(const Module *M) const {
@@ -850,15 +841,14 @@ public:
/// A callback to call when a module conflict is found. \p Path
/// consists of a sequence of modules from the conflicting module to the one
/// made visible, where each was exported by the next.
- using ConflictCallback =
- llvm::function_ref<void(ArrayRef<Module *> Path, Module *Conflict,
- StringRef Message)>;
+ using ConflictCallback = llvm::function_ref<void(
+ ArrayRef<Module *> Path, Module *Conflict, StringRef Message)>;
/// Make a specific module visible.
- void setVisible(Module *M, SourceLocation Loc,
- VisibleCallback Vis = [](Module *) {},
- ConflictCallback Cb = [](ArrayRef<Module *>, Module *,
- StringRef) {});
+ void setVisible(
+ Module *M, SourceLocation Loc, VisibleCallback Vis = [](Module *) {},
+ ConflictCallback Cb = [](ArrayRef<Module *>, Module *, StringRef) {});
+
private:
/// Import locations for each visible module. Indexed by the module's
/// VisibilityID.
diff --git a/clang/lib/AST/ExternalASTSource.cpp b/clang/lib/AST/ExternalASTSource.cpp
index fb16f41ced..61c650d463 100644
--- a/clang/lib/AST/ExternalASTSource.cpp
+++ b/clang/lib/AST/ExternalASTSource.cpp
@@ -15,10 +15,10 @@
#include "clang/AST/ExternalASTSource.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclarationName.h"
-#include "clang/Basic/Module/ASTSourceDescriptor.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/LLVM.h"
+#include "clang/Basic/Module/ASTSourceDescriptor.h"
#include "clang/Basic/SourceManager.h"
#include "llvm/Support/ErrorHandling.h"
#include <cstdint>
diff --git a/clang/lib/Basic/Module/Module.cpp b/clang/lib/Basic/Module/Module.cpp
index 581509b888..4bc8e63e3e 100644
--- a/clang/lib/Basic/Module/Module.cpp
+++ b/clang/lib/Basic/Module/Module.cpp
@@ -78,7 +78,7 @@ static bool isPlatformEnvironment(const TargetInfo &Target, StringRef Feature) {
if (Pos == StringRef::npos)
return false;
SmallString<128> NewLHS = LHS.slice(0, Pos);
- NewLHS += LHS.slice(Pos+1, LHS.size());
+ NewLHS += LHS.slice(Pos + 1, LHS.size());
return NewLHS == RHS;
};
@@ -218,7 +218,7 @@ static StringRef getModuleNameFromComponent(
static StringRef getModuleNameFromComponent(StringRef R) { return R; }
-template<typename InputIter>
+template <typename InputIter>
static void printModuleId(raw_ostream &OS, InputIter Begin, InputIter End,
bool AllowStringLiterals = true) {
for (InputIter It = Begin; It != End; ++It) {
@@ -236,7 +236,7 @@ static void printModuleId(raw_ostream &OS, InputIter Begin, InputIter End,
}
}
-template<typename Container>
+template <typename Container>
static void printModuleId(raw_ostream &OS, const Container &C) {
return printModuleId(OS, C.begin(), C.end());
}
@@ -325,7 +325,7 @@ void Module::addRequirement(StringRef Feature, bool RequiredState,
if (hasFeature(Feature, LangOpts, Target) == RequiredState)
return;
- markUnavailable(/*Unimportable*/true);
+ markUnavailable(/*Unimportable*/ true);
}
void Module::markUnavailable(bool Unimportable) {
@@ -368,7 +368,8 @@ Module *Module::findOrInferSubmodule(StringRef Name) {
return SubModules[Pos->getValue()];
if (!InferSubmodules)
return nullptr;
- Module *Result = new Module(Name, SourceLocation(), this, false, InferExplicitSubmodules, 0);
+ Module *Result = new Module(Name, SourceLocation(), this, false,
+ InferExplicitSubmodules, 0);
Result->InferExplicitSubmodules = InferExplicitSubmodules;
Result->InferSubmodules = InferSubmodules;
Result->InferExportWildcard = InferExportWildcard;
@@ -551,8 +552,8 @@ void Module::print(raw_ostream &OS, unsigned Indent, bool Dump) const {
OS.indent(Indent + 2);
OS << K.Prefix << "header \"";
OS.write_escaped(H.NameAsWritten);
- OS << "\" { size " << H.Entry.getSize()
- << " mtime " << H.Entry.getModificationTime() << " }\n";
+ OS << "\" { size " << H.Entry.getSize() << " mtime "
+ << H.Entry.getModificationTime() << " }\n";
}
}
for (auto *Unresolved : {&UnresolvedHeaders, &MissingHeaders}) {
@@ -674,9 +675,7 @@ void Module::print(raw_ostream &OS, unsigned Indent, bool Dump) const {
OS << "}\n";
}
-LLVM_DUMP_METHOD void Module::dump() const {
- print(llvm::errs(), 0, true);
-}
+LLVM_DUMP_METHOD void Module::dump() const { print(llvm::errs(), 0, true); }
void VisibleModuleSet::setVisible(Module *M, SourceLocation Loc,
VisibleCallback Vis, ConflictCallback Cb) {
@@ -715,7 +714,7 @@ void VisibleModuleSet::setVisible(Module *M, SourceLocation Loc,
for (auto &C : V.M->Conflicts) {
if (isVisible(C.Other)) {
- llvm::SmallVector<Module*, 8> Path;
+ llvm::SmallVector<Module *, 8> Path;
for (Visiting *I = &V; I; I = I->ExportedBy)
Path.push_back(I->M);
Cb(Path, C.Other, C.Message);
diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h
index 530c5eeedb..7a767508b0 100644
--- a/clang/lib/CodeGen/CGDebugInfo.h
+++ b/clang/lib/CodeGen/CGDebugInfo.h
@@ -20,8 +20,8 @@
#include "clang/AST/PrettyPrinter.h"
#include "clang/AST/Type.h"
#include "clang/AST/TypeOrdering.h"
-#include "clang/Basic/Module/ASTSourceDescriptor.h"
#include "clang/Basic/CodeGenOptions.h"
+#include "clang/Basic/Module/ASTSourceDescriptor.h"
#include "clang/Basic/SourceLocation.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index de930f8dab..ad49de7cde 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -25,11 +25,11 @@
#include "clang/Lex/Preprocessor.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/Hashing.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringRef.h"
-#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/Capacity.h"
#include "llvm/Support/Errc.h"
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index d596082d21..95a62095d4 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -40,7 +40,6 @@
#include "clang/AST/TypeLoc.h"
#include "clang/AST/TypeLocVisitor.h"
#include "clang/AST/UnresolvedSet.h"
-#include "clang/Basic/Module/ASTSourceDescriptor.h"
#include "clang/Basic/CommentOptions.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticError.h"
@@ -52,6 +51,7 @@
#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/Module/ASTSourceDescriptor.h"
#include "clang/Basic/Module/Module.h"
#include "clang/Basic/ObjCRuntime.h"
#include "clang/Basic/OpenACCKinds.h"
``````````
</details>
https://github.com/llvm/llvm-project/pull/93388
More information about the llvm-commits
mailing list