[clang] [ObjC][Preprocessor] Handle @import directive as a pp-directive (PR #157726)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 24 08:53:45 PDT 2026


AaronBallman wrote:

> This is needed for the same reason that `import` and `module` are (potentially) preprocessor directives in C++. It allows detecting dependencies without doing full preprocessing. https://wg21.link/P1857R3 covers this more. DependencyDirectivesScanner.cpp has the corresponding code that only works with the restrictions added in this PR.

Ah, I kind of wondered if that was the reason for this, thank you! I'm not happy to see C++ modules being used as precedent for other preprocessor shenanigans in other languages, but it probably doesn't matter much in this case either and is maybe fine. ObjC is a superset of C and C allows for the preprocessor to be a separate process that only operates on directives which are identified by the leading `#`. I have no idea if Apple wants to support other implementations of Objective-C which may use that strategy (such tools do exist, but are rare), which is why I raised the question.

https://github.com/llvm/llvm-project/pull/157726


More information about the cfe-commits mailing list