[PATCH] D149777: [clang][deps] Teach dep directive scanner about #pragma clang system_header
Ben Langmuir via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 3 13:58:39 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7b492d1be0ea: [clang][deps] Teach dep directive scanner about #pragma clang system_header (authored by benlangmuir).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D149777/new/
https://reviews.llvm.org/D149777
Files:
clang/include/clang/Lex/DependencyDirectivesScanner.h
clang/lib/Lex/DependencyDirectivesScanner.cpp
clang/lib/Lex/Lexer.cpp
clang/unittests/Lex/DependencyDirectivesScannerTest.cpp
Index: clang/unittests/Lex/DependencyDirectivesScannerTest.cpp
===================================================================
--- clang/unittests/Lex/DependencyDirectivesScannerTest.cpp
+++ clang/unittests/Lex/DependencyDirectivesScannerTest.cpp
@@ -90,7 +90,8 @@
"#pragma pop_macro(A)\n"
"#pragma include_alias(<A>, <B>)\n"
"export module m;\n"
- "import m;\n",
+ "import m;\n"
+ "#pragma clang system_header\n",
Out, Tokens, Directives));
EXPECT_EQ(pp_define, Directives[0].Kind);
EXPECT_EQ(pp_undef, Directives[1].Kind);
@@ -113,7 +114,8 @@
EXPECT_EQ(pp_pragma_include_alias, Directives[18].Kind);
EXPECT_EQ(cxx_export_module_decl, Directives[19].Kind);
EXPECT_EQ(cxx_import_decl, Directives[20].Kind);
- EXPECT_EQ(pp_eof, Directives[21].Kind);
+ EXPECT_EQ(pp_pragma_system_header, Directives[21].Kind);
+ EXPECT_EQ(pp_eof, Directives[22].Kind);
}
TEST(MinimizeSourceToDependencyDirectivesTest, EmptyHash) {
Index: clang/lib/Lex/Lexer.cpp
===================================================================
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -4480,6 +4480,7 @@
case pp_pragma_push_macro:
case pp_pragma_pop_macro:
case pp_pragma_include_alias:
+ case pp_pragma_system_header:
case pp_include_next:
case decl_at_import:
case cxx_module_decl:
Index: clang/lib/Lex/DependencyDirectivesScanner.cpp
===================================================================
--- clang/lib/Lex/DependencyDirectivesScanner.cpp
+++ clang/lib/Lex/DependencyDirectivesScanner.cpp
@@ -652,9 +652,22 @@
return false;
}
- // #pragma clang.
- if (!isNextIdentifierOrSkipLine("module", First, End))
+ FoundId = tryLexIdentifierOrSkipLine(First, End);
+ if (!FoundId)
return false;
+ Id = *FoundId;
+
+ // #pragma clang system_header
+ if (Id == "system_header") {
+ lexPPDirectiveBody(First, End);
+ pushDirective(pp_pragma_system_header);
+ return false;
+ }
+
+ if (Id != "module") {
+ skipLine(First, End);
+ return false;
+ }
// #pragma clang module.
if (!isNextIdentifierOrSkipLine("import", First, End))
Index: clang/include/clang/Lex/DependencyDirectivesScanner.h
===================================================================
--- clang/include/clang/Lex/DependencyDirectivesScanner.h
+++ clang/include/clang/Lex/DependencyDirectivesScanner.h
@@ -68,6 +68,7 @@
pp_pragma_push_macro,
pp_pragma_pop_macro,
pp_pragma_include_alias,
+ pp_pragma_system_header,
pp_include_next,
pp_if,
pp_ifdef,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149777.519244.patch
Type: text/x-patch
Size: 2835 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230503/9536fb6a/attachment-0001.bin>
More information about the cfe-commits
mailing list