llvm-project/clang/test/Driver/cxx20-fdirectives-only.cpp
Iain Sandoe 9dc9b21488 [C++20][Modules][Driver][HU 4/N] Add fdirectives-only mode for preprocessing output.
When the -fdirectives-only option is used together with -E, the preprocessor
output reflects evaluation of if/then/else directives.

Thus it preserves macros that are still live after such processing.
This output can be consumed by a second compilation to produce a header unit.

We automatically invoke this (with -E) when we know that the job produces a
header unit so that the preprocessed output reflects the macros that will be
defined when the binary HU is emitted.

Differential Revision: https://reviews.llvm.org/D121591
2022-04-23 14:43:07 +01:00

21 lines
717 B
C++

// Test -fdirectives-only cases.
// We can manullay specify fdirectives-only, for any pre-processor job.
// RUN: %clang -### -std=c++20 -E -fdirectives-only foo.hh 2>&1 | \
// RUN: FileCheck -check-prefix=CHECK-NON-HU %s
// Check that we automatically append -fdirectives-only for header-unit
// preprocessor jobs.
// RUN: %clang -### -std=c++20 -E -fmodule-header=user foo.hh 2>&1 | \
// RUN: FileCheck -check-prefix=CHECK-HU %s
// CHECK-NON-HU: "-E"
// CHECK-NON-HU-SAME: "-fdirectives-only"
// CHECK-NON-HU-SAME: "-o" "-"
// CHECK-NON-HU-SAME: "-x" "c++-header" "foo.hh"
// CHECK-HU: "-E"
// CHECK-HU-SAME: "-fdirectives-only"
// CHECK-HU-SAME: "-o" "-"
// CHECK-HU-SAME: "-x" "c++-user-header" "foo.hh"