summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [clang-scan-deps] do not skip empty #if/#elif in the minimizer to avoid ↵Alex Lorenz2019-12-021-6/+7
| | | | | | | | | | missing `__has_include` dependencies 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. Differential Revision: https://reviews.llvm.org/D70936
* [clang-scan-deps] Improve string/character literal skippingAlex Lorenz2019-10-081-11/+29
| | | | | | | | | | | | | | | | The existing string/character literal skipping code in the dependency directives source minimizer has two issues: - It doesn't stop the scanning when a newline is reached before the terminating character, unlike the lexer which considers the token to be done (even if it's invalid) at the end of the line. - It doesn't support whitespace between '\' and the newline when looking if the '\' is used as a line continuation character. This commit fixes both issues. Differential Revision: https://reviews.llvm.org/D68436 llvm-svn: 374127
* [clang-scan-deps] Allow continuation line backslashes followed by whitespaceAlex Lorenz2019-09-261-11/+22
| | | | | | | | | | | | in the dependency source minimizer Clang allows continuations that have whitespace between the backslash and the newline. This patch ensures that the dependency source minimizer can handle the whitespace between the backslash and the newline when looking for a line continuation. Differential Revision: https://reviews.llvm.org/D68052 llvm-svn: 373007
* Fix for stringized function-macro args continued across linesAlex Lorenz2019-09-191-2/+5
| | | | | | | | | | | In case of certain #define'd macros, there's a space just before line continuation that the minimized-source lexer was missing to include, resulting in invalid stringize. Patch by: kousikk (Kousik Kumar) Differential Revision: https://reviews.llvm.org/D67635 llvm-svn: 372360
* [clang-scan-deps] add skip excluded conditional preprocessor block ↵Alex Lorenz2019-09-111-0/+48
| | | | | | | | | | | | | | | preprocessing optimization This commit adds an optimization to clang-scan-deps and clang's preprocessor that skips excluded preprocessor blocks by bumping the lexer pointer, and not lexing the tokens until reaching appropriate #else/#endif directive. The skip positions and lexer offsets are computed when the file is minimized, directly from the minimized tokens. On an 18-core iMacPro with macOS Catalina Beta I got 10-15% speed-up from this optimization when running clang-scan-deps on the compilation database for a recent LLVM and Clang (3511 files). Differential Revision: https://reviews.llvm.org/D67127 llvm-svn: 371656
* Re-land [clang-scan-deps] Minimizer: Correctly handle multi-line content ↵Alexandre Ganea2019-08-281-14/+35
| | | | | | | | | | with CR+LF line endings Previously, an #error directive with quoted, multi-line content, along with CR+LF line endings wasn't handled correctly. Differential Revision: https://reviews.llvm.org/D66556 llvm-svn: 370129
* Revert "[clang-scan-deps] Minimizer: Correctly handle multi-line content ↵Richard Smith2019-08-271-35/+14
| | | | | | | | | | | | with CR+LF line endings" This reverts commit r369986. This change added a dependency on the 'dos2unix' tool, which is not one of our accepted test dependencies and may not exist on all machines that build Clang. llvm-svn: 370000
* [clang-scan-deps] Skip UTF-8 BOM in source minimizerAlexandre Ganea2019-08-271-0/+7
| | | | | | Differential Revision: https://reviews.llvm.org/D66511 llvm-svn: 369993
* [clang-scan-deps] Minimizer: Correctly skip over double slashes in angle ↵Alexandre Ganea2019-08-261-3/+4
| | | | | | | | | | bracket #include Previously, double slashes (//) occurring in angle brackets #include were incorrectly interpreted as comments. eg. #include <dir//file.h> Differential Revision: https://reviews.llvm.org/D66550 llvm-svn: 369988
* [clang-scan-deps] Minimizer: Correctly handle multi-line content with CR+LF ↵Alexandre Ganea2019-08-261-14/+35
| | | | | | | | | | line endings Previously, an #error directive with quoted, multi-line content, along with CR+LF line endings wasn't handled correctly. Differential Revision: https://reviews.llvm.org/D66556 llvm-svn: 369986
* [clang-scan-deps] Add minimizer support for C++20 modules.Michael J. Spencer2019-08-091-1/+70
| | | | | | This only adds support to the minimizer, it doesn't actually capture the dependencies yet. llvm-svn: 368381
* [clang-scan-deps] Dependency directives source minimizer: handle #pragma onceAlex Lorenz2019-07-181-1/+15
| | | | | | | | | We should re-emit `#pragma once` to ensure the preprocessor will still honor it when running on minimized sources. Differential Revision: https://reviews.llvm.org/D64945 llvm-svn: 366509
* [clang-scan-deps] Dependency directives source minimizer:Alex Lorenz2019-07-101-1/+8
| | | | | | | | | | | | single quotes are not digit separators after a valid character literal prefix The single quote character can act as a c++ digit separator. However, the minimizer shouldn't treat it as such when it's actually following a valid character literal prefix, like L, U, u, or u8. Differential Revision: https://reviews.llvm.org/D64525 llvm-svn: 365700
* Fix windows build for commit r362459Alex Lorenz2019-06-031-6/+6
| | | | llvm-svn: 362463
* Add clang source minimizer that reduces source to directivesAlex Lorenz2019-06-031-0/+756
that might affect the dependency list for a compilation This commit introduces a dependency directives source minimizer to clang that minimizes header and source files to the minimum necessary preprocessor directives for evaluating includes. It reduces the source down to #define, #include, The source minimizer works by lexing the input with a custom fast lexer that recognizes the preprocessor directives it cares about, and emitting those directives in the minimized source. It ignores source code, comments, and normalizes whitespace. It gives up and fails if seems any directives that it doesn't recognize as valid (e.g. #define 0). In addition to the source minimizer this patch adds a -print-dependency-directives-minimized-source CC1 option that allows you to invoke the minimizer from clang directly. Differential Revision: https://reviews.llvm.org/D55463 llvm-svn: 362459
OpenPOWER on IntegriCloud