summaryrefslogtreecommitdiffstats
path: root/tests/cxx/pch_in_code.cc
blob: 1362948749f0962f5e85ea0ee3443328209309de (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//===--- pch_in_code.cc - test input file for iwyu ------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// IWYU_ARGS: -Xiwyu --pch_in_code -Xiwyu --prefix_header_includes=remove -I .

// Test IWYU's handling of precompiled headers explicitly included in code.
// This is a pattern popularized by MSVC and allowed by GCC, where an include
// directive is used as a marker to signal that a precompiled header should be
// pulled into the translation unit.
//
// Under these compilers' rules, the precompiled header must be included first.
//
// A PCH lives under special rules:
// - should never be removed
// - all headers included in it are considered prefix headers
// - always stays the first include, no matter what changes IWYU makes
//
// This test assumes being run with --prefix_header_includes=remove and
// --pch_in_code.

#include "tests/cxx/pch.h"  // this is the precompiled header
// Associated header needs to be in a subdirectory to provoke
// first-include-with-same-basename heuristic, which is sensitive to the
// presence of a PCH.
#include "tests/cxx/public/pch_in_code.h"
#include <stdlib.h>  // unused
#include <stdint.h>  // for int8_t
#include "tests/cxx/indirect.h"

IndirectClass ic;
int8_t global_byte;

/**** IWYU_SUMMARY

tests/cxx/pch_in_code.cc should add these lines:

tests/cxx/pch_in_code.cc should remove these lines:
- #include <stdlib.h>  // lines XX-XX
- #include "tests/cxx/indirect.h"  // lines XX-XX

The full include-list for tests/cxx/pch_in_code.cc:
#include "tests/cxx/pch.h"
#include "tests/cxx/public/pch_in_code.h"
#include <stdint.h>  // for int8_t

***** IWYU_SUMMARY */