This is an archive of the discontinued LLVM Phabricator instance.

[C++20] [Modules] [NFC] Add Preprocessor methods for named modules - for ClangScanDeps (1/4)
ClosedPublic

Authored by ChuanqiXu on Nov 6 2022, 10:06 PM.

Details

Summary

This patch prepares the necessary interfaces in the preprocessor part for D137527 since we need to recognize if we're in a module unit, the module kinds and the module declaration and the module we're importing in the preprocessor.

Diff Detail

Event Timeline

ChuanqiXu created this revision.Nov 6 2022, 10:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 6 2022, 10:06 PM
ChuanqiXu requested review of this revision.Nov 6 2022, 10:06 PM
ChuanqiXu edited the summary of this revision. (Show Details)Nov 6 2022, 10:43 PM
ChuanqiXu updated this revision to Diff 473567.Nov 6 2022, 10:46 PM

Format codes.

ChuanqiXu added inline comments.Nov 6 2022, 10:47 PM
clang/include/clang/Lex/Preprocessor.h
321–322

This is needed since in fact we use @import in objective-c++ mode. See the test for example.

ChuanqiXu retitled this revision from [C++20] [Modules] [NFC] Add Preprocessor methods for named modules - for ClangScanDeps (1/2) to [C++20] [Modules] [NFC] Add Preprocessor methods for named modules - for ClangScanDeps (1/3).Nov 6 2022, 11:54 PM
ChuanqiXu retitled this revision from [C++20] [Modules] [NFC] Add Preprocessor methods for named modules - for ClangScanDeps (1/3) to [C++20] [Modules] [NFC] Add Preprocessor methods for named modules - for ClangScanDeps (1/4).Dec 4 2022, 7:19 PM
chfast added a subscriber: chfast.Dec 11 2022, 5:55 AM
jansvoboda11 resigned from this revision.Jan 9 2023, 9:46 AM

I'm not familiar with standard C++ modules. @Bigcheese any thoughts?

clang/include/clang/Lex/Preprocessor.h
2372

Preprocessor::isNamedModule() is bit misleading. How about Preprocessor::isInNamedModule()? Similar for other Preprocessor::is*() functions this patch introduces.

ChuanqiXu updated this revision to Diff 487690.Jan 9 2023, 10:57 PM

Address comments.

ChuanqiXu updated this revision to Diff 493474.Jan 30 2023, 7:34 PM

Replace llvm::Optional with std::optional

ChuanqiXu accepted this revision.Feb 9 2023, 6:00 PM
This revision is now accepted and ready to land.Feb 9 2023, 6:00 PM
This revision was landed with ongoing or failed builds.Feb 9 2023, 6:12 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 9 2023, 6:12 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
thakis added a subscriber: thakis.Feb 10 2023, 5:56 AM
thakis added inline comments.
clang/unittests/Lex/CMakeLists.txt
21

It seems strange layering-wise that the Lex unit tests would depend on Frontend. Is there any way to prevent that dep?

nikic added a subscriber: nikic.Feb 14 2023, 2:57 AM

It looks like this causes a minor compile-time regression (about 0.2% on O0 builds): http://llvm-compile-time-tracker.com/compare.php?from=ad81d019a62d33e5d1f232844b83d3e164e4b160&to=6470706bc0ed2425704bc8c9e121a72e2d272616&stat=instructions:u

I wanted to check whether this is expected (as I don't think CTMark even compiles anything in C++20 mode).

It looks like this causes a minor compile-time regression (about 0.2% on O0 builds): http://llvm-compile-time-tracker.com/compare.php?from=ad81d019a62d33e5d1f232844b83d3e164e4b160&to=6470706bc0ed2425704bc8c9e121a72e2d272616&stat=instructions:u

I wanted to check whether this is expected (as I don't think CTMark even compiles anything in C++20 mode).

This is strange since all the codes would only work if there is an import. And I didn't introduce any loops so it shouldn't cause compile-time regression.

clang/unittests/Lex/CMakeLists.txt
21

I see. I'll try to look at it.

ChuanqiXu added inline comments.Feb 14 2023, 7:31 PM
clang/unittests/Lex/CMakeLists.txt
21