summaryrefslogtreecommitdiffstats
path: root/tests/cxx/range_for.cc
blob: 0eb1191242741fd056c85d11d9f5cffa605c3143 (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
//===--- range_for.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.
//
//===----------------------------------------------------------------------===//

// Verify correct handling of the C++11 range-for statement.
// The range-init expression always needs the complete type.
// The loop variable should behave like any variable use.

#include "tests/cxx/range_for-iterable.h"
#include "tests/cxx/direct.h"

int ref_item(const Iterable& items) {
  int total = 0;
  // IWYU: IndirectClass needs a declaration
  for (const IndirectClass& i : items)
    ;
  return 0;
}

int value_item(const Iterable& items) {
  // IWYU: IndirectClass is...*indirect.h
  for (IndirectClass i : items)
    ;
  return 0;
}


/**** IWYU_SUMMARY

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

tests/cxx/range_for.cc should remove these lines:
- #include "tests/cxx/direct.h"  // lines XX-XX

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

***** IWYU_SUMMARY */