mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-08 09:03:18 +00:00
6e2d36b60b
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
15 lines
283 B
C
15 lines
283 B
C
// RUN: %clang_cc1 -print-dependency-directives-minimized-source %s > %t
|
|
// RUN: echo END. >> %t
|
|
// RUN: FileCheck < %t %s
|
|
|
|
#ifdef FOO
|
|
#include "a.h"
|
|
#else
|
|
void skipThisCode();
|
|
#endif
|
|
|
|
// CHECK: #ifdef FOO
|
|
// CHECK-NEXT: #include "a.h"
|
|
// CHECK-NEXT: #endif
|
|
// CHECK-NEXT: END.
|