[PATCH] D70936: [clang-scan-deps] do not skip empty #if/#elif in the minimize to avoid missing `__has_include` dependencies

Alex Lorenz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 2 18:12:45 PST 2019


arphaman created this revision.
arphaman added reviewers: Bigcheese, dexonsmith, kousikk.
Herald added subscribers: ributzka, tschuett, jkorous.
Herald added a project: clang.

This patch makes the minimizer more conservative to avoid missing dependency files that are brought in by `__has_include` PP expressions that occur in a condition of an `#if`/`#elif` that was previously skipped. The `__has_include` PP expressions can be used in an `#if`/`#elif` either directly, or through macro expansion, so we can't detect them at the time of minimization.

It'll be possible to skip certain `#if`/`#elif` in the future by doing more minimizer optimizations (e.g. skip `#if 0`). Furthermore, @Bigcheese is working on clarifying the allowed usage of  `__has_include` in the standard, as it seems that this kind of usage should actually be disallowed. This will hopefully allow us skip these `#if`/`#elif` again in the future.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70936

Files:
  clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
  clang/test/ClangScanDeps/Inputs/has_include_if_elif.json
  clang/test/ClangScanDeps/has_include_if_elif.cpp
  clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70936.231804.patch
Type: text/x-patch
Size: 4595 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191203/a7f85b30/attachment-0001.bin>


More information about the cfe-commits mailing list