summaryrefslogtreecommitdiffstats
path: root/tests/cxx/remove_fwd_decl_when_including.cc
blob: e2f4b2124d8d3ced6ced8f61d994c5b5f69eafdb (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
//===--- remove_fwd_decl_when_including.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: -I .

// This tests the following behavior: when we need to #include a
// file to get the full type of Foo (here, Foo == IndirectClass),
// but a forward-declare will also suffice for another use of Foo,
// *and* we forward-declare foo, make sure we get rid of the
// forward-declare, which is superseded by the #include.
//
// In other words, we should never have the case where we both
// #include a class, and forward-declare the same class, in a file.

#include "tests/cxx/direct.h"

class IndirectClass;

int main() {
  IndirectClass* p;
  // IWYU: IndirectClass is...*indirect.h
  IndirectClass i;
}

/**** IWYU_SUMMARY

tests/cxx/remove_fwd_decl_when_including.cc should add these lines:
#include "tests/cxx/indirect.h"

tests/cxx/remove_fwd_decl_when_including.cc should remove these lines:
- #include "tests/cxx/direct.h"  // lines XX-XX
- class IndirectClass;  // lines XX-XX

The full include-list for tests/cxx/remove_fwd_decl_when_including.cc:
#include "tests/cxx/indirect.h"  // for IndirectClass

***** IWYU_SUMMARY */