[clang] [C++20][Modules] Implement P1857R3 Modules Dependency Discovery (PR #107168)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 3 17:04:22 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 448d8fa880be5cae0f63c3b248f07f647013a5a4 b7b4e2549a5fb723b455768f2bcf75bfab6cab04 --extensions h,cpp -- clang/include/clang/Basic/IdentifierTable.h clang/include/clang/Lex/Lexer.h clang/include/clang/Lex/Preprocessor.h clang/include/clang/Lex/Token.h clang/include/clang/Lex/TokenLexer.h clang/include/clang/Parse/Parser.h clang/lib/Basic/IdentifierTable.cpp clang/lib/Lex/DependencyDirectivesScanner.cpp clang/lib/Lex/Lexer.cpp clang/lib/Lex/PPDirectives.cpp clang/lib/Lex/PPMacroExpansion.cpp clang/lib/Lex/Preprocessor.cpp clang/lib/Lex/TokenLexer.cpp clang/lib/Parse/Parser.cpp clang/unittests/Lex/DependencyDirectivesScannerTest.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h
index a9acde7ac5..d8b0d4a540 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -400,7 +400,7 @@ private:
/// Whether the last token we lexed was an '@'.
bool LastTokenWasAt = false;
-
+
struct ExportContextualKeywordInfo {
Token ExportTok;
bool TokAtPhysicalStartOfLine;
@@ -1847,7 +1847,8 @@ public:
/// This consumes the import, module directive, modifies the
/// lexer/preprocessor state, and advances the lexer(s) so that the next token
/// read is the correct one.
- bool HandleModuleContextualKeyword(Token &Result, bool TokAtPhysicalStartOfLine);
+ bool HandleModuleContextualKeyword(Token &Result,
+ bool TokAtPhysicalStartOfLine);
void HandleModuleDirective(Token &ModuleOrImportKeyword);
void LexAfterModuleImport(SmallVectorImpl<Token> &Suffix, bool IsImport);
diff --git a/clang/lib/Basic/IdentifierTable.cpp b/clang/lib/Basic/IdentifierTable.cpp
index 10ed86d5d5..d44f553e59 100644
--- a/clang/lib/Basic/IdentifierTable.cpp
+++ b/clang/lib/Basic/IdentifierTable.cpp
@@ -457,7 +457,7 @@ tok::PPKeywordKind IdentifierInfo::getPPKeywordID() const {
CASE( 6, 'd', 'f', define);
CASE( 6, 'i', 'n', ifndef);
CASE( 6, 'i', 'p', import);
- CASE( 6, 'm', 'd', module);
+ CASE(6, 'm', 'd', module);
CASE( 6, 'p', 'a', pragma);
CASE( 7, 'd', 'f', defined);
diff --git a/clang/lib/Lex/DependencyDirectivesScanner.cpp b/clang/lib/Lex/DependencyDirectivesScanner.cpp
index 58e92977f9..245ce25b82 100644
--- a/clang/lib/Lex/DependencyDirectivesScanner.cpp
+++ b/clang/lib/Lex/DependencyDirectivesScanner.cpp
@@ -857,7 +857,8 @@ bool Scanner::lexPPLine(const char *&First, const char *const End) {
if (*First == '@')
return lexAt(First, End);
- // if (!LangOpts.CPlusPlusModules && (*First == 'i' || *First == 'e' || *First == 'm'))
+ // if (!LangOpts.CPlusPlusModules && (*First == 'i' || *First == 'e' || *First
+ // == 'm'))
// return lexModule(First, End);
if (*First == '_') {
@@ -871,7 +872,7 @@ bool Scanner::lexPPLine(const char *&First, const char *const End) {
TheLexer.setParsingPreprocessorDirective(true);
auto ScEx2 = make_scope_exit(
[&]() { TheLexer.setParsingPreprocessorDirective(false); });
- if (*First == 'i' || *First == 'e' || *First == 'm')
+ if (*First == 'i' || *First == 'e' || *First == 'm')
return lexModule(First, End);
// Lex '#'.
const dependency_directives_scan::Token &HashTok = lexToken(First, End);
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index b40de9d918..7cce869662 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -4023,12 +4023,13 @@ void Preprocessor::HandleEmbedDirective(SourceLocation HashLoc, Token &EmbedTok,
HandleEmbedDirectiveImpl(HashLoc, *Params, BinaryContents);
}
-void Preprocessor::LexAfterModuleImport(SmallVectorImpl<Token> &Suffix, bool IsImport) {
+void Preprocessor::LexAfterModuleImport(SmallVectorImpl<Token> &Suffix,
+ bool IsImport) {
Token Result;
Suffix.clear();
Retry:
if (IsImport && getLangOpts().CPlusPlusModules) {
- (void) LexHeaderName(Result);
+ (void)LexHeaderName(Result);
if (Result.is(tok::colon) && ModuleDeclState.isNamedModule()) {
std::string Name = ModuleDeclState.getPrimaryName().str();
Name += ":";
@@ -4172,8 +4173,7 @@ Retry:
// We don't/shouldn't load the standard c++20 modules when preprocessing.
if (getLangOpts().Modules && !isInImportingCXXNamedModules()) {
Imported = TheModuleLoader.loadModule(ModuleImportLoc,
- NamedModuleImportPath,
- Module::Hidden,
+ NamedModuleImportPath, Module::Hidden,
/*IsInclusionDirective=*/false);
if (Imported)
makeModuleVisible(Imported, SemiLoc);
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp
index eb694ce415..a4ac1505be 100644
--- a/clang/lib/Lex/Preprocessor.cpp
+++ b/clang/lib/Lex/Preprocessor.cpp
@@ -1154,7 +1154,8 @@ bool Preprocessor::HandleModuleContextualKeyword(
} else if (!TokAtPhysicalStartOfLine)
return false;
- bool SavedParsingPreprocessorDirective = CurPPLexer->ParsingPreprocessorDirective;
+ bool SavedParsingPreprocessorDirective =
+ CurPPLexer->ParsingPreprocessorDirective;
CurPPLexer->ParsingPreprocessorDirective = true;
// Peek next token.
auto NextTok = peekNextPPToken().value_or(Token{});
``````````
</details>
https://github.com/llvm/llvm-project/pull/107168
More information about the cfe-commits
mailing list