Clean up line endings after r523

This commit is contained in:
Kim Gräsman 2014-02-16 07:52:34 +00:00
parent c54ab54c26
commit f8c43d28c6
82 changed files with 2801 additions and 2801 deletions

View File

@ -1,51 +1,51 @@
//===--- iterator.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.
//
//===----------------------------------------------------------------------===//
// We have special-case code to deal with foo::iterator, for various
// STL classes foo. They are complicated because they often map to
// __normal_iterator<foo>, and we have to map back. There are also
// issues with reverse_iterator.
//
// Basically, we don't want any of the code below to result in an
// #include of <iterator>
#include <algorithm>
#include <vector>
#include <list>
std::vector<int> vi;
std::vector<int>::iterator vi_begin = vi.begin();
std::vector<int>::const_iterator vi_cbegin = vi.begin();
std::vector<int>::reverse_iterator vi_rbegin = vi.rbegin();
std::vector<int>::const_reverse_iterator vi_crbegin = vi.rbegin();
void VectorFns() {
// Tricky issue with deduced template args.
std::find(vi_begin, vi_begin, 5);
// Issues with operator!=, operator bool, etc.
for (std::vector<int>::iterator it = vi_begin; it != vi_begin; ++it) ;
for (std::vector<int>::reverse_iterator it = vi_rbegin; it != vi_rbegin; ++it)
;
}
std::list<int> li;
std::list<int>::iterator li_begin = li.begin();
std::list<int>::const_iterator li_cbegin = li.begin();
std::list<int>::reverse_iterator li_rbegin = li.rbegin();
std::list<int>::const_reverse_iterator li_crbegin = li.rbegin();
void ListFns() {
std::find(li_begin, li_begin, 5);
for (std::list<int>::iterator it = li_begin; it != li_begin; ++it) ;
for (std::list<int>::reverse_iterator it = li_rbegin; it != li_rbegin; ++it) ;
}
/**** IWYU_SUMMARY
(tests/cxx/iterator.cc has correct #includes/fwd-decls)
***** IWYU_SUMMARY */
//===--- iterator.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.
//
//===----------------------------------------------------------------------===//
// We have special-case code to deal with foo::iterator, for various
// STL classes foo. They are complicated because they often map to
// __normal_iterator<foo>, and we have to map back. There are also
// issues with reverse_iterator.
//
// Basically, we don't want any of the code below to result in an
// #include of <iterator>
#include <algorithm>
#include <vector>
#include <list>
std::vector<int> vi;
std::vector<int>::iterator vi_begin = vi.begin();
std::vector<int>::const_iterator vi_cbegin = vi.begin();
std::vector<int>::reverse_iterator vi_rbegin = vi.rbegin();
std::vector<int>::const_reverse_iterator vi_crbegin = vi.rbegin();
void VectorFns() {
// Tricky issue with deduced template args.
std::find(vi_begin, vi_begin, 5);
// Issues with operator!=, operator bool, etc.
for (std::vector<int>::iterator it = vi_begin; it != vi_begin; ++it) ;
for (std::vector<int>::reverse_iterator it = vi_rbegin; it != vi_rbegin; ++it)
;
}
std::list<int> li;
std::list<int>::iterator li_begin = li.begin();
std::list<int>::const_iterator li_cbegin = li.begin();
std::list<int>::reverse_iterator li_rbegin = li.rbegin();
std::list<int>::const_reverse_iterator li_crbegin = li.rbegin();
void ListFns() {
std::find(li_begin, li_begin, 5);
for (std::list<int>::iterator it = li_begin; it != li_begin; ++it) ;
for (std::list<int>::reverse_iterator it = li_rbegin; it != li_rbegin; ++it) ;
}
/**** IWYU_SUMMARY
(tests/cxx/iterator.cc has correct #includes/fwd-decls)
***** IWYU_SUMMARY */

View File

@ -1,90 +1,90 @@
//===--- iwyu_stricter_than_cpp-autocast.h - 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.
//
//===----------------------------------------------------------------------===//
#ifndef IWYU_STRICTER_THAN_CPP_AUTOCAST_H_
#define IWYU_STRICTER_THAN_CPP_AUTOCAST_H_
// The two rules the author has to follow to disable iwyu's
// stricter-than-C++ rule and force it to fall back on the c++
// requirement (forward-declare ok):
// (1) forward-declare the relevant type
// (2) do not directly #include the definition of the relevant type.
#include "tests/cxx/iwyu_stricter_than_cpp-d1.h"
// --- Autocast types.
struct DirectStruct1;
struct IndirectStruct2;
void Fn(
// Requires the full type because it does not obey rule (1)
// IWYU: IndirectStruct1 needs a declaration
// IWYU: IndirectStruct1 is...*iwyu_stricter_than_cpp-i1.h.*for autocast
const IndirectStruct1& ic1,
// This also does not obey rule (1): it's -d1 that does the fwd-declaring.
// IWYU: IndirectStructForwardDeclaredInD1 is...*iwyu_stricter_than_cpp-i1.h.*for autocast
const struct IndirectStructForwardDeclaredInD1& icfdid1,
// Requires the full type because it does not obey rule (2)
DirectStruct1 dc1,
// Requires the full type because it does not obey rules (1) *or* (2)
struct DirectStruct2 dc2,
// Does not require full type because it obeys all the rules.
IndirectStruct2 ic2);
// --- Now do it all again, with templates!
template <typename T> struct TplDirectStruct1;
template <typename T> struct TplIndirectStruct2;
void TplFn(
// IWYU: TplIndirectStruct1 needs a declaration
// IWYU: TplIndirectStruct1 is...*iwyu_stricter_than_cpp-i1.h.*for autocast
const TplIndirectStruct1<char>& ic1,
// A bit of an asymmetry with the non-tpl case: 'struct
// IndirectStructForwardDeclaredInD1' does not need to be
// forward-declared because it's elaborated, but template types
// need to be forward-declared even when they're elaborated. (Of
// course, the fwd-decl requirement will be superceded by the
// full-type requirement due to autocast, but we report both.)
// IWYU: TplIndirectStructForwardDeclaredInD1 needs a declaration
// IWYU: TplIndirectStructForwardDeclaredInD1 is...*iwyu_stricter_than_cpp-i1.h.*for autocast
const struct TplIndirectStructForwardDeclaredInD1<char>& icfdid1,
TplDirectStruct1<char> dc1,
struct TplDirectStruct2<char> dc2,
TplIndirectStruct2<char> ic2);
// --- The rules do not apply for friend functions declarations.
struct AutocastStruct {
// IWYU: IndirectStruct1 needs a declaration
friend void ClassFn1(const IndirectStruct1&);
// IWYU: TplIndirectStruct1 needs a declaration
friend void ClassFn2(TplIndirectStruct1<char>);
};
#endif // IWYU_STRICTER_THAN_CPP_AUTOCAST_H_
/**** IWYU_SUMMARY
tests/cxx/iwyu_stricter_than_cpp-autocast.h should add these lines:
#include "tests/cxx/iwyu_stricter_than_cpp-i1.h"
tests/cxx/iwyu_stricter_than_cpp-autocast.h should remove these lines:
- struct DirectStruct1; // lines XX-XX
- template <typename T> struct TplDirectStruct1; // lines XX-XX
The full include-list for tests/cxx/iwyu_stricter_than_cpp-autocast.h:
#include "tests/cxx/iwyu_stricter_than_cpp-d1.h" // for DirectStruct1, DirectStruct2, TplDirectStruct1, TplDirectStruct2
#include "tests/cxx/iwyu_stricter_than_cpp-i1.h" // for IndirectStruct1, IndirectStructForwardDeclaredInD1, TplIndirectStruct1, TplIndirectStructForwardDeclaredInD1
struct IndirectStruct2; // lines XX-XX
template <typename T> struct TplIndirectStruct2; // lines XX-XX
***** IWYU_SUMMARY */
//===--- iwyu_stricter_than_cpp-autocast.h - 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.
//
//===----------------------------------------------------------------------===//
#ifndef IWYU_STRICTER_THAN_CPP_AUTOCAST_H_
#define IWYU_STRICTER_THAN_CPP_AUTOCAST_H_
// The two rules the author has to follow to disable iwyu's
// stricter-than-C++ rule and force it to fall back on the c++
// requirement (forward-declare ok):
// (1) forward-declare the relevant type
// (2) do not directly #include the definition of the relevant type.
#include "tests/cxx/iwyu_stricter_than_cpp-d1.h"
// --- Autocast types.
struct DirectStruct1;
struct IndirectStruct2;
void Fn(
// Requires the full type because it does not obey rule (1)
// IWYU: IndirectStruct1 needs a declaration
// IWYU: IndirectStruct1 is...*iwyu_stricter_than_cpp-i1.h.*for autocast
const IndirectStruct1& ic1,
// This also does not obey rule (1): it's -d1 that does the fwd-declaring.
// IWYU: IndirectStructForwardDeclaredInD1 is...*iwyu_stricter_than_cpp-i1.h.*for autocast
const struct IndirectStructForwardDeclaredInD1& icfdid1,
// Requires the full type because it does not obey rule (2)
DirectStruct1 dc1,
// Requires the full type because it does not obey rules (1) *or* (2)
struct DirectStruct2 dc2,
// Does not require full type because it obeys all the rules.
IndirectStruct2 ic2);
// --- Now do it all again, with templates!
template <typename T> struct TplDirectStruct1;
template <typename T> struct TplIndirectStruct2;
void TplFn(
// IWYU: TplIndirectStruct1 needs a declaration
// IWYU: TplIndirectStruct1 is...*iwyu_stricter_than_cpp-i1.h.*for autocast
const TplIndirectStruct1<char>& ic1,
// A bit of an asymmetry with the non-tpl case: 'struct
// IndirectStructForwardDeclaredInD1' does not need to be
// forward-declared because it's elaborated, but template types
// need to be forward-declared even when they're elaborated. (Of
// course, the fwd-decl requirement will be superceded by the
// full-type requirement due to autocast, but we report both.)
// IWYU: TplIndirectStructForwardDeclaredInD1 needs a declaration
// IWYU: TplIndirectStructForwardDeclaredInD1 is...*iwyu_stricter_than_cpp-i1.h.*for autocast
const struct TplIndirectStructForwardDeclaredInD1<char>& icfdid1,
TplDirectStruct1<char> dc1,
struct TplDirectStruct2<char> dc2,
TplIndirectStruct2<char> ic2);
// --- The rules do not apply for friend functions declarations.
struct AutocastStruct {
// IWYU: IndirectStruct1 needs a declaration
friend void ClassFn1(const IndirectStruct1&);
// IWYU: TplIndirectStruct1 needs a declaration
friend void ClassFn2(TplIndirectStruct1<char>);
};
#endif // IWYU_STRICTER_THAN_CPP_AUTOCAST_H_
/**** IWYU_SUMMARY
tests/cxx/iwyu_stricter_than_cpp-autocast.h should add these lines:
#include "tests/cxx/iwyu_stricter_than_cpp-i1.h"
tests/cxx/iwyu_stricter_than_cpp-autocast.h should remove these lines:
- struct DirectStruct1; // lines XX-XX
- template <typename T> struct TplDirectStruct1; // lines XX-XX
The full include-list for tests/cxx/iwyu_stricter_than_cpp-autocast.h:
#include "tests/cxx/iwyu_stricter_than_cpp-d1.h" // for DirectStruct1, DirectStruct2, TplDirectStruct1, TplDirectStruct2
#include "tests/cxx/iwyu_stricter_than_cpp-i1.h" // for IndirectStruct1, IndirectStructForwardDeclaredInD1, TplIndirectStruct1, TplIndirectStructForwardDeclaredInD1
struct IndirectStruct2; // lines XX-XX
template <typename T> struct TplIndirectStruct2; // lines XX-XX
***** IWYU_SUMMARY */

View File

@ -1,16 +1,16 @@
//===--- iwyu_stricter_than_cpp-autocast2.h - 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.
//
//===----------------------------------------------------------------------===//
#include "tests/cxx/iwyu_stricter_than_cpp-d1.h"
// Because we do not forward-declare IndirectStruct2, we need the full
// definition here. But that fact doesn't matter because the caller
// of TwiceDeclaredFunction (-d2.h), cannot see this definition.
void TwiceDeclaredFunction(IndirectStruct2 ic2);
void TwiceDeclaredRefFunction(const IndirectStruct2& ic2);
//===--- iwyu_stricter_than_cpp-autocast2.h - 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.
//
//===----------------------------------------------------------------------===//
#include "tests/cxx/iwyu_stricter_than_cpp-d1.h"
// Because we do not forward-declare IndirectStruct2, we need the full
// definition here. But that fact doesn't matter because the caller
// of TwiceDeclaredFunction (-d2.h), cannot see this definition.
void TwiceDeclaredFunction(IndirectStruct2 ic2);
void TwiceDeclaredRefFunction(const IndirectStruct2& ic2);

View File

@ -1,26 +1,26 @@
//===--- iwyu_stricter_than_cpp-d1.h - 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.
//
//===----------------------------------------------------------------------===//
#ifndef IWYU_STRICTER_THAN_CPP_D1_H_
#define IWYU_STRICTER_THAN_CPP_D1_H_
#include "tests/cxx/iwyu_stricter_than_cpp-i1.h"
#include "tests/cxx/iwyu_stricter_than_cpp-i2.h"
// Note all these structs have an 'autocast' constructor.
struct DirectStruct1 { DirectStruct1(int) {} };
struct DirectStruct2 { DirectStruct2(int) {} };
struct IndirectStructForwardDeclaredInD1;
template <typename T> struct TplDirectStruct1 { TplDirectStruct1(int) {} };
template <typename T> struct TplDirectStruct2 { TplDirectStruct2(int) {} };
template <typename T> struct TplIndirectStructForwardDeclaredInD1;
#endif
//===--- iwyu_stricter_than_cpp-d1.h - 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.
//
//===----------------------------------------------------------------------===//
#ifndef IWYU_STRICTER_THAN_CPP_D1_H_
#define IWYU_STRICTER_THAN_CPP_D1_H_
#include "tests/cxx/iwyu_stricter_than_cpp-i1.h"
#include "tests/cxx/iwyu_stricter_than_cpp-i2.h"
// Note all these structs have an 'autocast' constructor.
struct DirectStruct1 { DirectStruct1(int) {} };
struct DirectStruct2 { DirectStruct2(int) {} };
struct IndirectStructForwardDeclaredInD1;
template <typename T> struct TplDirectStruct1 { TplDirectStruct1(int) {} };
template <typename T> struct TplDirectStruct2 { TplDirectStruct2(int) {} };
template <typename T> struct TplIndirectStructForwardDeclaredInD1;
#endif

View File

@ -1,41 +1,41 @@
//===--- iwyu_stricter_than_cpp-d2.h - 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.
//
//===----------------------------------------------------------------------===//
class IndirectStruct2;
// These functions are also declared in -autocast2.h, but that
// declaration isn't visible from here.
void TwiceDeclaredFunction(IndirectStruct2 ic2);
void TwiceDeclaredRefFunction(const IndirectStruct2& ic2);
void CallTwiceDeclaredFunction() {
// We need the full type for IndirectStruct2 because the only
// declaration that we can see, does not provide the full type for
// us.
// IWYU: IndirectStruct2 is...*iwyu_stricter_than_cpp-i2.h
TwiceDeclaredFunction(1);
// This *should* be exactly the same, but doesn't seem to be:
// clang leaves out the constructor-conversion AST node.
// TODO(csilvers): IWYU: IndirectStruct2 is...*iwyu_stricter_than_cpp-i2.h
TwiceDeclaredRefFunction(1);
}
/**** IWYU_SUMMARY
tests/cxx/iwyu_stricter_than_cpp-d2.h should add these lines:
#include "tests/cxx/iwyu_stricter_than_cpp-i2.h"
tests/cxx/iwyu_stricter_than_cpp-d2.h should remove these lines:
- class IndirectStruct2; // lines XX-XX
The full include-list for tests/cxx/iwyu_stricter_than_cpp-d2.h:
#include "tests/cxx/iwyu_stricter_than_cpp-i2.h" // for IndirectStruct2
***** IWYU_SUMMARY */
//===--- iwyu_stricter_than_cpp-d2.h - 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.
//
//===----------------------------------------------------------------------===//
class IndirectStruct2;
// These functions are also declared in -autocast2.h, but that
// declaration isn't visible from here.
void TwiceDeclaredFunction(IndirectStruct2 ic2);
void TwiceDeclaredRefFunction(const IndirectStruct2& ic2);
void CallTwiceDeclaredFunction() {
// We need the full type for IndirectStruct2 because the only
// declaration that we can see, does not provide the full type for
// us.
// IWYU: IndirectStruct2 is...*iwyu_stricter_than_cpp-i2.h
TwiceDeclaredFunction(1);
// This *should* be exactly the same, but doesn't seem to be:
// clang leaves out the constructor-conversion AST node.
// TODO(csilvers): IWYU: IndirectStruct2 is...*iwyu_stricter_than_cpp-i2.h
TwiceDeclaredRefFunction(1);
}
/**** IWYU_SUMMARY
tests/cxx/iwyu_stricter_than_cpp-d2.h should add these lines:
#include "tests/cxx/iwyu_stricter_than_cpp-i2.h"
tests/cxx/iwyu_stricter_than_cpp-d2.h should remove these lines:
- class IndirectStruct2; // lines XX-XX
The full include-list for tests/cxx/iwyu_stricter_than_cpp-d2.h:
#include "tests/cxx/iwyu_stricter_than_cpp-i2.h" // for IndirectStruct2
***** IWYU_SUMMARY */

View File

@ -1,93 +1,93 @@
//===--- iwyu_stricter_than_cpp-fnreturn.h - 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.
//
//===----------------------------------------------------------------------===//
// The two rules the author has to follow to disable iwyu's
// stricter-than-C++ rule and force it to fall back on the c++
// requirement (forward-declare ok):
// (1) forward-declare the relevant type
// (2) do not directly #include the definition of the relevant type.
#include "tests/cxx/iwyu_stricter_than_cpp-d1.h"
// --- Return values of functions.
// Requires the full type because it does not obey rule (1)
// IWYU: IndirectStruct1 needs a declaration
// IWYU: IndirectStruct1 is...*iwyu_stricter_than_cpp-i1.h.*for fn return type
IndirectStruct1 DoesNotForwardDeclareFn();
// This also does not obey rule (1): it's -d1 that does the fwd-declaring.
// IWYU: IndirectStructForwardDeclaredInD1 is...*iwyu_stricter_than_cpp-i1.h.*for fn return type
struct IndirectStructForwardDeclaredInD1 DoesNotForwardDeclareProperlyFn();
// Requires the full type because it does not obey rule (2)
struct DirectStruct1;
DirectStruct1 IncludesFn();
// Requires the full type because it does not obey rules (1) *or* (2)
DirectStruct2 DoesNotForwardDeclareAndIncludesFn();
// Does not require full type because it obeys all the rules.
struct IndirectStruct2;
IndirectStruct2 DoesEverythingRightFn();
// --- Now do it all again, with templates!
// IWYU: TplIndirectStruct1 needs a declaration
// IWYU: TplIndirectStruct1 is...*iwyu_stricter_than_cpp-i1.h.*for fn return type
TplIndirectStruct1<int> TplDoesNotForwardDeclareFn();
// A bit of an asymmetry with the non-tpl case: 'struct
// IndirectStructForwardDeclaredInD1' does not need to be
// forward-declared because it's elaborated, but template types need
// to be forward-declared even when they're elaborated.
// IWYU: TplIndirectStructForwardDeclaredInD1 needs a declaration
struct TplIndirectStructForwardDeclaredInD1<int>
// IWYU: TplIndirectStructForwardDeclaredInD1 is...*iwyu_stricter_than_cpp-i1.h.*for fn return type
TplDoesNotForwardDeclareProperlyFn();
template <typename T> struct TplDirectStruct1;
TplDirectStruct1<int> TplIncludesFn();
TplDirectStruct2<int> TplDoesNotForwardDeclareAndIncludesFn();
template <typename T> struct TplIndirectStruct2;
TplIndirectStruct2<int> TplDoesEverythingRightFn();
// Another way to forward-declare a class template.
template <> struct TplIndirectStruct2<float>;
TplIndirectStruct2<float> TplDoesEverythingRightAgainFn();
// --- The rules do not apply for friend functions.
struct FnreturnStruct {
// IWYU: IndirectStruct1 needs a declaration
friend const IndirectStruct1& ClassFn1();
// IWYU: TplIndirectStruct1 needs a declaration
friend TplIndirectStruct1<char> ClassFn2();
};
/**** IWYU_SUMMARY
tests/cxx/iwyu_stricter_than_cpp-fnreturn.h should add these lines:
#include "tests/cxx/iwyu_stricter_than_cpp-i1.h"
tests/cxx/iwyu_stricter_than_cpp-fnreturn.h should remove these lines:
- struct DirectStruct1; // lines XX-XX
- template <typename T> struct TplDirectStruct1; // lines XX-XX
The full include-list for tests/cxx/iwyu_stricter_than_cpp-fnreturn.h:
#include "tests/cxx/iwyu_stricter_than_cpp-d1.h" // for DirectStruct1, DirectStruct2, TplDirectStruct1, TplDirectStruct2
#include "tests/cxx/iwyu_stricter_than_cpp-i1.h" // for IndirectStruct1, IndirectStructForwardDeclaredInD1, TplIndirectStruct1, TplIndirectStructForwardDeclaredInD1
struct IndirectStruct2; // lines XX-XX
template <typename T> struct TplIndirectStruct2; // lines XX-XX
***** IWYU_SUMMARY */
//===--- iwyu_stricter_than_cpp-fnreturn.h - 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.
//
//===----------------------------------------------------------------------===//
// The two rules the author has to follow to disable iwyu's
// stricter-than-C++ rule and force it to fall back on the c++
// requirement (forward-declare ok):
// (1) forward-declare the relevant type
// (2) do not directly #include the definition of the relevant type.
#include "tests/cxx/iwyu_stricter_than_cpp-d1.h"
// --- Return values of functions.
// Requires the full type because it does not obey rule (1)
// IWYU: IndirectStruct1 needs a declaration
// IWYU: IndirectStruct1 is...*iwyu_stricter_than_cpp-i1.h.*for fn return type
IndirectStruct1 DoesNotForwardDeclareFn();
// This also does not obey rule (1): it's -d1 that does the fwd-declaring.
// IWYU: IndirectStructForwardDeclaredInD1 is...*iwyu_stricter_than_cpp-i1.h.*for fn return type
struct IndirectStructForwardDeclaredInD1 DoesNotForwardDeclareProperlyFn();
// Requires the full type because it does not obey rule (2)
struct DirectStruct1;
DirectStruct1 IncludesFn();
// Requires the full type because it does not obey rules (1) *or* (2)
DirectStruct2 DoesNotForwardDeclareAndIncludesFn();
// Does not require full type because it obeys all the rules.
struct IndirectStruct2;
IndirectStruct2 DoesEverythingRightFn();
// --- Now do it all again, with templates!
// IWYU: TplIndirectStruct1 needs a declaration
// IWYU: TplIndirectStruct1 is...*iwyu_stricter_than_cpp-i1.h.*for fn return type
TplIndirectStruct1<int> TplDoesNotForwardDeclareFn();
// A bit of an asymmetry with the non-tpl case: 'struct
// IndirectStructForwardDeclaredInD1' does not need to be
// forward-declared because it's elaborated, but template types need
// to be forward-declared even when they're elaborated.
// IWYU: TplIndirectStructForwardDeclaredInD1 needs a declaration
struct TplIndirectStructForwardDeclaredInD1<int>
// IWYU: TplIndirectStructForwardDeclaredInD1 is...*iwyu_stricter_than_cpp-i1.h.*for fn return type
TplDoesNotForwardDeclareProperlyFn();
template <typename T> struct TplDirectStruct1;
TplDirectStruct1<int> TplIncludesFn();
TplDirectStruct2<int> TplDoesNotForwardDeclareAndIncludesFn();
template <typename T> struct TplIndirectStruct2;
TplIndirectStruct2<int> TplDoesEverythingRightFn();
// Another way to forward-declare a class template.
template <> struct TplIndirectStruct2<float>;
TplIndirectStruct2<float> TplDoesEverythingRightAgainFn();
// --- The rules do not apply for friend functions.
struct FnreturnStruct {
// IWYU: IndirectStruct1 needs a declaration
friend const IndirectStruct1& ClassFn1();
// IWYU: TplIndirectStruct1 needs a declaration
friend TplIndirectStruct1<char> ClassFn2();
};
/**** IWYU_SUMMARY
tests/cxx/iwyu_stricter_than_cpp-fnreturn.h should add these lines:
#include "tests/cxx/iwyu_stricter_than_cpp-i1.h"
tests/cxx/iwyu_stricter_than_cpp-fnreturn.h should remove these lines:
- struct DirectStruct1; // lines XX-XX
- template <typename T> struct TplDirectStruct1; // lines XX-XX
The full include-list for tests/cxx/iwyu_stricter_than_cpp-fnreturn.h:
#include "tests/cxx/iwyu_stricter_than_cpp-d1.h" // for DirectStruct1, DirectStruct2, TplDirectStruct1, TplDirectStruct2
#include "tests/cxx/iwyu_stricter_than_cpp-i1.h" // for IndirectStruct1, IndirectStructForwardDeclaredInD1, TplIndirectStruct1, TplIndirectStructForwardDeclaredInD1
struct IndirectStruct2; // lines XX-XX
template <typename T> struct TplIndirectStruct2; // lines XX-XX
***** IWYU_SUMMARY */

View File

@ -1,18 +1,18 @@
//===--- iwyu_stricter_than_cpp-i1.h - 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.
//
//===----------------------------------------------------------------------===//
struct IndirectStruct1 { IndirectStruct1(int) {} };
struct IndirectStructForwardDeclaredInD1 {
IndirectStructForwardDeclaredInD1(int) {}
};
template <typename T> struct TplIndirectStruct1 { TplIndirectStruct1(int) {} };
template <typename T> struct TplIndirectStructForwardDeclaredInD1 {
TplIndirectStructForwardDeclaredInD1(int) {}
};
//===--- iwyu_stricter_than_cpp-i1.h - 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.
//
//===----------------------------------------------------------------------===//
struct IndirectStruct1 { IndirectStruct1(int) {} };
struct IndirectStructForwardDeclaredInD1 {
IndirectStructForwardDeclaredInD1(int) {}
};
template <typename T> struct TplIndirectStruct1 { TplIndirectStruct1(int) {} };
template <typename T> struct TplIndirectStructForwardDeclaredInD1 {
TplIndirectStructForwardDeclaredInD1(int) {}
};

View File

@ -1,18 +1,18 @@
//===--- iwyu_stricter_than_cpp-i2.h - 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.
//
//===----------------------------------------------------------------------===//
struct IndirectStruct2 {
IndirectStruct2(int) {}
int a;
};
template <typename T> struct TplIndirectStruct2 { TplIndirectStruct2(int) {} };
// We also use a specialization for float.
template <> struct TplIndirectStruct2<float> { TplIndirectStruct2(float) {} };
//===--- iwyu_stricter_than_cpp-i2.h - 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.
//
//===----------------------------------------------------------------------===//
struct IndirectStruct2 {
IndirectStruct2(int) {}
int a;
};
template <typename T> struct TplIndirectStruct2 { TplIndirectStruct2(int) {} };
// We also use a specialization for float.
template <> struct TplIndirectStruct2<float> { TplIndirectStruct2(float) {} };

View File

@ -1,76 +1,76 @@
//===--- iwyu_stricter_than_cpp-typedefs.h - 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.
//
//===----------------------------------------------------------------------===//
// The two rules the author has to follow to disable iwyu's
// stricter-than-C++ rule and force it to fall back on the c++
// requirement (forward-declare ok):
// (1) forward-declare the relevant type
// (2) do not directly #include the definition of the relevant type.
#include "tests/cxx/iwyu_stricter_than_cpp-d1.h"
// --- Typedefs.
// Requires the full type because it does not obey rule (1)
// IWYU: IndirectStruct1 is...*iwyu_stricter_than_cpp-i1.h
typedef IndirectStruct1 DoesNotForwardDeclare;
// This also does not obey rule (1): it's -d1 that does the fwd-declaring.
// IWYU: IndirectStructForwardDeclaredInD1 is...*iwyu_stricter_than_cpp-i1.h
typedef IndirectStructForwardDeclaredInD1 DoesNotForwardDeclareProperly;
// Requires the full type because it does not obey rule (2)
struct DirectStruct1;
typedef DirectStruct1 Includes;
// Requires the full type because it does not obey rules (1) *or* (2)
typedef DirectStruct2 DoesNotForwardDeclareAndIncludes;
// Does not require full type because it obeys all the rules.
struct IndirectStruct2;
typedef IndirectStruct2 DoesEverythingRight;
// --- Now do it all again, with templates!
// IWYU: IndirectStruct1 is...*iwyu_stricter_than_cpp-i1.h
typedef TplIndirectStruct1<int> TplDoesNotForwardDeclare;
// IWYU: IndirectStructForwardDeclaredInD1 is...*iwyu_stricter_than_cpp-i1.h
typedef TplIndirectStructForwardDeclaredInD1<int>
TplDoesNotForwardDeclareProperly;
template <typename T> struct TplDirectStruct1;
typedef TplDirectStruct1<int> TplIncludes;
typedef TplDirectStruct2<int> TplDoesNotForwardDeclareAndIncludes;
template <typename T> struct TplIndirectStruct2;
typedef TplIndirectStruct2<int> TplDoesEverythingRight;
// Another way to forward-declare a class template.
template <> struct TplIndirectStruct2<float>;
typedef TplIndirectStruct2<float> TplDoesEverythingRightAgain;
/**** IWYU_SUMMARY
tests/cxx/iwyu_stricter_than_cpp-typedefs.h should add these lines:
#include "tests/cxx/iwyu_stricter_than_cpp-i1.h"
tests/cxx/iwyu_stricter_than_cpp-typedefs.h should remove these lines:
- struct DirectStruct1; // lines XX-XX
- template <typename T> struct TplDirectStruct1; // lines XX-XX
The full include-list for tests/cxx/iwyu_stricter_than_cpp-typedefs.h:
#include "tests/cxx/iwyu_stricter_than_cpp-d1.h" // for DirectStruct1, DirectStruct2, TplDirectStruct1, TplDirectStruct2
#include "tests/cxx/iwyu_stricter_than_cpp-i1.h" // for IndirectStruct1, IndirectStructForwardDeclaredInD1, TplIndirectStruct1, TplIndirectStructForwardDeclaredInD1
struct IndirectStruct2; // lines XX-XX
template <typename T> struct TplIndirectStruct2; // lines XX-XX
***** IWYU_SUMMARY */
//===--- iwyu_stricter_than_cpp-typedefs.h - 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.
//
//===----------------------------------------------------------------------===//
// The two rules the author has to follow to disable iwyu's
// stricter-than-C++ rule and force it to fall back on the c++
// requirement (forward-declare ok):
// (1) forward-declare the relevant type
// (2) do not directly #include the definition of the relevant type.
#include "tests/cxx/iwyu_stricter_than_cpp-d1.h"
// --- Typedefs.
// Requires the full type because it does not obey rule (1)
// IWYU: IndirectStruct1 is...*iwyu_stricter_than_cpp-i1.h
typedef IndirectStruct1 DoesNotForwardDeclare;
// This also does not obey rule (1): it's -d1 that does the fwd-declaring.
// IWYU: IndirectStructForwardDeclaredInD1 is...*iwyu_stricter_than_cpp-i1.h
typedef IndirectStructForwardDeclaredInD1 DoesNotForwardDeclareProperly;
// Requires the full type because it does not obey rule (2)
struct DirectStruct1;
typedef DirectStruct1 Includes;
// Requires the full type because it does not obey rules (1) *or* (2)
typedef DirectStruct2 DoesNotForwardDeclareAndIncludes;
// Does not require full type because it obeys all the rules.
struct IndirectStruct2;
typedef IndirectStruct2 DoesEverythingRight;
// --- Now do it all again, with templates!
// IWYU: IndirectStruct1 is...*iwyu_stricter_than_cpp-i1.h
typedef TplIndirectStruct1<int> TplDoesNotForwardDeclare;
// IWYU: IndirectStructForwardDeclaredInD1 is...*iwyu_stricter_than_cpp-i1.h
typedef TplIndirectStructForwardDeclaredInD1<int>
TplDoesNotForwardDeclareProperly;
template <typename T> struct TplDirectStruct1;
typedef TplDirectStruct1<int> TplIncludes;
typedef TplDirectStruct2<int> TplDoesNotForwardDeclareAndIncludes;
template <typename T> struct TplIndirectStruct2;
typedef TplIndirectStruct2<int> TplDoesEverythingRight;
// Another way to forward-declare a class template.
template <> struct TplIndirectStruct2<float>;
typedef TplIndirectStruct2<float> TplDoesEverythingRightAgain;
/**** IWYU_SUMMARY
tests/cxx/iwyu_stricter_than_cpp-typedefs.h should add these lines:
#include "tests/cxx/iwyu_stricter_than_cpp-i1.h"
tests/cxx/iwyu_stricter_than_cpp-typedefs.h should remove these lines:
- struct DirectStruct1; // lines XX-XX
- template <typename T> struct TplDirectStruct1; // lines XX-XX
The full include-list for tests/cxx/iwyu_stricter_than_cpp-typedefs.h:
#include "tests/cxx/iwyu_stricter_than_cpp-d1.h" // for DirectStruct1, DirectStruct2, TplDirectStruct1, TplDirectStruct2
#include "tests/cxx/iwyu_stricter_than_cpp-i1.h" // for IndirectStruct1, IndirectStructForwardDeclaredInD1, TplIndirectStruct1, TplIndirectStructForwardDeclaredInD1
struct IndirectStruct2; // lines XX-XX
template <typename T> struct TplIndirectStruct2; // lines XX-XX
***** IWYU_SUMMARY */

View File

@ -1,166 +1,166 @@
//===--- iwyu_stricter_than_cpp.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.
//
//===----------------------------------------------------------------------===//
// There are a few scenarios where iwyu requires a full type but c++
// doesn't.
//
// One is in a typedef: if you write 'typedef Foo MyTypedef', iwyu
// says that you are responsible for #including "foo.h", but the
// language allows a forward-declare.
//
// Another is for 'autocast': if your function has a parameter with a
// conversion (one-arg, not-explicit) constructor, iwyu require the
// function-author to provide the full type of that parameter, but the
// language doesn't. (It's ok with all callers providing the full
// type instead.)
//
// In each case, we can disable iwyu's rule, and force it to fall back
// on the c++ requirement (forward-declare ok), by writing the code in
// the following way:
// (1) forward-declare the relevant type
// (2) do not directly #include the definition of the relevant type.
//
// This test tests that the iwyu requirement is correctly suppressed
// when these two conditions are met, and not otherwise.
#include "tests/cxx/iwyu_stricter_than_cpp-typedefs.h"
#include "tests/cxx/iwyu_stricter_than_cpp-autocast.h"
#include "tests/cxx/iwyu_stricter_than_cpp-fnreturn.h"
// We include this so the second declaration of TwiceDeclaredFunction
// is visible in the translation unit (but not by -d2.h)
#include "tests/cxx/iwyu_stricter_than_cpp-autocast2.h"
#include "tests/cxx/iwyu_stricter_than_cpp-d2.h"
typedef DoesEverythingRight DoubleTypedef;
// If the typedef in -typedefs.h requires the full type, then users of
// that typedef (here) do not. Otherwise, they do.
void TestTypedefs() {
DoesNotForwardDeclare dnfd(1);
DoesNotForwardDeclareProperly dnfdp(2);
Includes i(3);
DoesNotForwardDeclareAndIncludes dnfdai(4);
// IWYU: IndirectStruct2 is...*iwyu_stricter_than_cpp-i2.h
DoesEverythingRight dor(5);
// Because DoubleTypedef resolves to DoesEverythingRight, we need the
// same things DoesEverythingRight does.
// IWYU: IndirectStruct2 is...*iwyu_stricter_than_cpp-i2.h
DoubleTypedef dt(6);
// ...and with templates.
TplDoesNotForwardDeclare tdnfd(7);
TplDoesNotForwardDeclareProperly tdnfdp(8);
TplIncludes ti(9);
TplDoesNotForwardDeclareAndIncludes tdnfdai(10);
// IWYU: TplIndirectStruct2 is...*iwyu_stricter_than_cpp-i2.h
TplDoesEverythingRight tdor(11);
// IWYU: TplIndirectStruct2 is...*iwyu_stricter_than_cpp-i2.h
TplDoesEverythingRightAgain tdora(12);
// But if we're in a forward-declare context, we don't require the
// underlying type!
DoesEverythingRight* dor_ptr = 0;
TplDoesEverythingRightAgain* tdora_ptr = 0;
// ...at least until we dereference the pointer
// IWYU: IndirectStruct2 is...*iwyu_stricter_than_cpp-i2.h
(void) dor_ptr->a;
// TODO(csilvers): test template types where we need some (but not
// all) of the template args as well.
}
void TestAutocast() {
// We need full type of is2 because the declarer of Fn didn't
// IWYU: IndirectStruct2 is...*iwyu_stricter_than_cpp-i2.h
Fn(1, 2, 3, 4, 5);
// We need full type of is2 because the declarer of Fn didn't
// IWYU: IndirectStruct2 is...*iwyu_stricter_than_cpp-i2.h
TplFn(6, 7, 8, 9, 10);
}
void TestFunctionReturn() {
// In each of these cases, we bind the return value to a reference,
// so we only need a forward-declare unless the function-author has
// not taken responsibility for the return type.
// IWYU: IndirectStruct1 needs a declaration
const IndirectStruct1& is1 = DoesNotForwardDeclareFn();
// IWYU: IndirectStructForwardDeclaredInD1 needs a declaration
const IndirectStructForwardDeclaredInD1& isfdid1 =
DoesNotForwardDeclareProperlyFn();
// IWYU: DirectStruct1 needs a declaration
const DirectStruct1& ds1 = IncludesFn();
// IWYU: DirectStruct2 needs a declaration
const DirectStruct2& ds2 = DoesNotForwardDeclareAndIncludesFn();
// IWYU: IndirectStruct2 needs a declaration
// IWYU: IndirectStruct2 is...*iwyu_stricter_than_cpp-i2.h
const IndirectStruct2& is2 = DoesEverythingRightFn();
// -- And with templates.
// IWYU: TplIndirectStruct1 needs a declaration
const TplIndirectStruct1<int>& tis1 = TplDoesNotForwardDeclareFn();
// IWYU: TplIndirectStructForwardDeclaredInD1 needs a declaration
const TplIndirectStructForwardDeclaredInD1<int>& tisfdid1 =
TplDoesNotForwardDeclareProperlyFn();
// IWYU: TplDirectStruct1 needs a declaration
const TplDirectStruct1<int>& tds1 = TplIncludesFn();
// IWYU: TplDirectStruct2 needs a declaration
const TplDirectStruct2<int>& tds2 = TplDoesNotForwardDeclareAndIncludesFn();
// IWYU: TplIndirectStruct2 needs a declaration
// IWYU: TplIndirectStruct2 is...*iwyu_stricter_than_cpp-i2.h
const TplIndirectStruct2<int>& tis2 = TplDoesEverythingRightFn();
// IWYU: TplIndirectStruct2 needs a declaration
// IWYU: TplIndirectStruct2 is...*iwyu_stricter_than_cpp-i2.h
const TplIndirectStruct2<float>& tis2b = TplDoesEverythingRightAgainFn();
}
/**** IWYU_SUMMARY
tests/cxx/iwyu_stricter_than_cpp.cc should add these lines:
#include "tests/cxx/iwyu_stricter_than_cpp-i2.h"
struct DirectStruct1;
struct DirectStruct2;
struct IndirectStruct1;
struct IndirectStructForwardDeclaredInD1;
template <typename T> struct TplDirectStruct1;
template <typename T> struct TplDirectStruct2;
template <typename T> struct TplIndirectStruct1;
template <typename T> struct TplIndirectStructForwardDeclaredInD1;
tests/cxx/iwyu_stricter_than_cpp.cc should remove these lines:
- #include "tests/cxx/iwyu_stricter_than_cpp-autocast2.h" // lines XX-XX
- #include "tests/cxx/iwyu_stricter_than_cpp-d2.h" // lines XX-XX
The full include-list for tests/cxx/iwyu_stricter_than_cpp.cc:
#include "tests/cxx/iwyu_stricter_than_cpp-autocast.h" // for Fn, TplFn
#include "tests/cxx/iwyu_stricter_than_cpp-fnreturn.h" // for DoesEverythingRightFn, DoesNotForwardDeclareAndIncludesFn, DoesNotForwardDeclareFn, DoesNotForwardDeclareProperlyFn, IncludesFn, TplDoesEverythingRightAgainFn, TplDoesEverythingRightFn, TplDoesNotForwardDeclareAndIncludesFn, TplDoesNotForwardDeclareFn, TplDoesNotForwardDeclareProperlyFn, TplIncludesFn
#include "tests/cxx/iwyu_stricter_than_cpp-i2.h" // for IndirectStruct2, TplIndirectStruct2
#include "tests/cxx/iwyu_stricter_than_cpp-typedefs.h" // for DoesEverythingRight, DoesNotForwardDeclare, DoesNotForwardDeclareAndIncludes, DoesNotForwardDeclareProperly, Includes, TplDoesEverythingRight, TplDoesEverythingRightAgain, TplDoesNotForwardDeclare, TplDoesNotForwardDeclareAndIncludes, TplDoesNotForwardDeclareProperly, TplIncludes
struct DirectStruct1;
struct DirectStruct2;
struct IndirectStruct1;
struct IndirectStructForwardDeclaredInD1;
template <typename T> struct TplDirectStruct1;
template <typename T> struct TplDirectStruct2;
template <typename T> struct TplIndirectStruct1;
template <typename T> struct TplIndirectStructForwardDeclaredInD1;
***** IWYU_SUMMARY */
//===--- iwyu_stricter_than_cpp.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.
//
//===----------------------------------------------------------------------===//
// There are a few scenarios where iwyu requires a full type but c++
// doesn't.
//
// One is in a typedef: if you write 'typedef Foo MyTypedef', iwyu
// says that you are responsible for #including "foo.h", but the
// language allows a forward-declare.
//
// Another is for 'autocast': if your function has a parameter with a
// conversion (one-arg, not-explicit) constructor, iwyu require the
// function-author to provide the full type of that parameter, but the
// language doesn't. (It's ok with all callers providing the full
// type instead.)
//
// In each case, we can disable iwyu's rule, and force it to fall back
// on the c++ requirement (forward-declare ok), by writing the code in
// the following way:
// (1) forward-declare the relevant type
// (2) do not directly #include the definition of the relevant type.
//
// This test tests that the iwyu requirement is correctly suppressed
// when these two conditions are met, and not otherwise.
#include "tests/cxx/iwyu_stricter_than_cpp-typedefs.h"
#include "tests/cxx/iwyu_stricter_than_cpp-autocast.h"
#include "tests/cxx/iwyu_stricter_than_cpp-fnreturn.h"
// We include this so the second declaration of TwiceDeclaredFunction
// is visible in the translation unit (but not by -d2.h)
#include "tests/cxx/iwyu_stricter_than_cpp-autocast2.h"
#include "tests/cxx/iwyu_stricter_than_cpp-d2.h"
typedef DoesEverythingRight DoubleTypedef;
// If the typedef in -typedefs.h requires the full type, then users of
// that typedef (here) do not. Otherwise, they do.
void TestTypedefs() {
DoesNotForwardDeclare dnfd(1);
DoesNotForwardDeclareProperly dnfdp(2);
Includes i(3);
DoesNotForwardDeclareAndIncludes dnfdai(4);
// IWYU: IndirectStruct2 is...*iwyu_stricter_than_cpp-i2.h
DoesEverythingRight dor(5);
// Because DoubleTypedef resolves to DoesEverythingRight, we need the
// same things DoesEverythingRight does.
// IWYU: IndirectStruct2 is...*iwyu_stricter_than_cpp-i2.h
DoubleTypedef dt(6);
// ...and with templates.
TplDoesNotForwardDeclare tdnfd(7);
TplDoesNotForwardDeclareProperly tdnfdp(8);
TplIncludes ti(9);
TplDoesNotForwardDeclareAndIncludes tdnfdai(10);
// IWYU: TplIndirectStruct2 is...*iwyu_stricter_than_cpp-i2.h
TplDoesEverythingRight tdor(11);
// IWYU: TplIndirectStruct2 is...*iwyu_stricter_than_cpp-i2.h
TplDoesEverythingRightAgain tdora(12);
// But if we're in a forward-declare context, we don't require the
// underlying type!
DoesEverythingRight* dor_ptr = 0;
TplDoesEverythingRightAgain* tdora_ptr = 0;
// ...at least until we dereference the pointer
// IWYU: IndirectStruct2 is...*iwyu_stricter_than_cpp-i2.h
(void) dor_ptr->a;
// TODO(csilvers): test template types where we need some (but not
// all) of the template args as well.
}
void TestAutocast() {
// We need full type of is2 because the declarer of Fn didn't
// IWYU: IndirectStruct2 is...*iwyu_stricter_than_cpp-i2.h
Fn(1, 2, 3, 4, 5);
// We need full type of is2 because the declarer of Fn didn't
// IWYU: IndirectStruct2 is...*iwyu_stricter_than_cpp-i2.h
TplFn(6, 7, 8, 9, 10);
}
void TestFunctionReturn() {
// In each of these cases, we bind the return value to a reference,
// so we only need a forward-declare unless the function-author has
// not taken responsibility for the return type.
// IWYU: IndirectStruct1 needs a declaration
const IndirectStruct1& is1 = DoesNotForwardDeclareFn();
// IWYU: IndirectStructForwardDeclaredInD1 needs a declaration
const IndirectStructForwardDeclaredInD1& isfdid1 =
DoesNotForwardDeclareProperlyFn();
// IWYU: DirectStruct1 needs a declaration
const DirectStruct1& ds1 = IncludesFn();
// IWYU: DirectStruct2 needs a declaration
const DirectStruct2& ds2 = DoesNotForwardDeclareAndIncludesFn();
// IWYU: IndirectStruct2 needs a declaration
// IWYU: IndirectStruct2 is...*iwyu_stricter_than_cpp-i2.h
const IndirectStruct2& is2 = DoesEverythingRightFn();
// -- And with templates.
// IWYU: TplIndirectStruct1 needs a declaration
const TplIndirectStruct1<int>& tis1 = TplDoesNotForwardDeclareFn();
// IWYU: TplIndirectStructForwardDeclaredInD1 needs a declaration
const TplIndirectStructForwardDeclaredInD1<int>& tisfdid1 =
TplDoesNotForwardDeclareProperlyFn();
// IWYU: TplDirectStruct1 needs a declaration
const TplDirectStruct1<int>& tds1 = TplIncludesFn();
// IWYU: TplDirectStruct2 needs a declaration
const TplDirectStruct2<int>& tds2 = TplDoesNotForwardDeclareAndIncludesFn();
// IWYU: TplIndirectStruct2 needs a declaration
// IWYU: TplIndirectStruct2 is...*iwyu_stricter_than_cpp-i2.h
const TplIndirectStruct2<int>& tis2 = TplDoesEverythingRightFn();
// IWYU: TplIndirectStruct2 needs a declaration
// IWYU: TplIndirectStruct2 is...*iwyu_stricter_than_cpp-i2.h
const TplIndirectStruct2<float>& tis2b = TplDoesEverythingRightAgainFn();
}
/**** IWYU_SUMMARY
tests/cxx/iwyu_stricter_than_cpp.cc should add these lines:
#include "tests/cxx/iwyu_stricter_than_cpp-i2.h"
struct DirectStruct1;
struct DirectStruct2;
struct IndirectStruct1;
struct IndirectStructForwardDeclaredInD1;
template <typename T> struct TplDirectStruct1;
template <typename T> struct TplDirectStruct2;
template <typename T> struct TplIndirectStruct1;
template <typename T> struct TplIndirectStructForwardDeclaredInD1;
tests/cxx/iwyu_stricter_than_cpp.cc should remove these lines:
- #include "tests/cxx/iwyu_stricter_than_cpp-autocast2.h" // lines XX-XX
- #include "tests/cxx/iwyu_stricter_than_cpp-d2.h" // lines XX-XX
The full include-list for tests/cxx/iwyu_stricter_than_cpp.cc:
#include "tests/cxx/iwyu_stricter_than_cpp-autocast.h" // for Fn, TplFn
#include "tests/cxx/iwyu_stricter_than_cpp-fnreturn.h" // for DoesEverythingRightFn, DoesNotForwardDeclareAndIncludesFn, DoesNotForwardDeclareFn, DoesNotForwardDeclareProperlyFn, IncludesFn, TplDoesEverythingRightAgainFn, TplDoesEverythingRightFn, TplDoesNotForwardDeclareAndIncludesFn, TplDoesNotForwardDeclareFn, TplDoesNotForwardDeclareProperlyFn, TplIncludesFn
#include "tests/cxx/iwyu_stricter_than_cpp-i2.h" // for IndirectStruct2, TplIndirectStruct2
#include "tests/cxx/iwyu_stricter_than_cpp-typedefs.h" // for DoesEverythingRight, DoesNotForwardDeclare, DoesNotForwardDeclareAndIncludes, DoesNotForwardDeclareProperly, Includes, TplDoesEverythingRight, TplDoesEverythingRightAgain, TplDoesNotForwardDeclare, TplDoesNotForwardDeclareAndIncludes, TplDoesNotForwardDeclareProperly, TplIncludes
struct DirectStruct1;
struct DirectStruct2;
struct IndirectStruct1;
struct IndirectStructForwardDeclaredInD1;
template <typename T> struct TplDirectStruct1;
template <typename T> struct TplDirectStruct2;
template <typename T> struct TplIndirectStruct1;
template <typename T> struct TplIndirectStructForwardDeclaredInD1;
***** IWYU_SUMMARY */

View File

@ -1,10 +1,10 @@
//===--- keep_mapping-pragma1.h - 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.
//
//===----------------------------------------------------------------------===//
// This space intentionally left blank.
//===--- keep_mapping-pragma1.h - 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.
//
//===----------------------------------------------------------------------===//
// This space intentionally left blank.

View File

@ -1,10 +1,10 @@
//===--- keep_mapping-pragma2.h - 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.
//
//===----------------------------------------------------------------------===//
// This space intentionally left blank.
//===--- keep_mapping-pragma2.h - 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.
//
//===----------------------------------------------------------------------===//
// This space intentionally left blank.

View File

@ -1,10 +1,10 @@
//===--- keep_mapping-priv.h - 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.
//
//===----------------------------------------------------------------------===//
// This space intentionally left blank.
//===--- keep_mapping-priv.h - 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.
//
//===----------------------------------------------------------------------===//
// This space intentionally left blank.

View File

@ -1,10 +1,10 @@
//===--- keep_mapping-private.h - 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.
//
//===----------------------------------------------------------------------===//
// This space intentionally left blank.
//===--- keep_mapping-private.h - 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.
//
//===----------------------------------------------------------------------===//
// This space intentionally left blank.

View File

@ -1,31 +1,31 @@
//===--- keep_mapping-public.h - 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.
//
//===----------------------------------------------------------------------===//
// Makes sure that when we #include a file that is part of an explicit
// mapping in iwyu_include_picker.cc, that iwyu doesn't say to remove
// that include.
// This is part of a mapping in iwyu_include_picker.cc.
#include "tests/cxx/keep_mapping-priv.h"
// This is part of a glob-mapping in iwyu_include_picker.cc
#include "tests/cxx/keep_mapping-private.h"
// This has an explicit pragma
#include "tests/cxx/keep_mapping-pragma1.h" // IWYU pragma: export
// This is also an explicit pragma
// IWYU pragma: begin_exports
#include "tests/cxx/keep_mapping-pragma2.h"
// IWYU pragma: end_exports
const int kInt = 5;
/**** IWYU_SUMMARY
(tests/cxx/keep_mapping-public.h has correct #includes/fwd-decls)
***** IWYU_SUMMARY */
//===--- keep_mapping-public.h - 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.
//
//===----------------------------------------------------------------------===//
// Makes sure that when we #include a file that is part of an explicit
// mapping in iwyu_include_picker.cc, that iwyu doesn't say to remove
// that include.
// This is part of a mapping in iwyu_include_picker.cc.
#include "tests/cxx/keep_mapping-priv.h"
// This is part of a glob-mapping in iwyu_include_picker.cc
#include "tests/cxx/keep_mapping-private.h"
// This has an explicit pragma
#include "tests/cxx/keep_mapping-pragma1.h" // IWYU pragma: export
// This is also an explicit pragma
// IWYU pragma: begin_exports
#include "tests/cxx/keep_mapping-pragma2.h"
// IWYU pragma: end_exports
const int kInt = 5;
/**** IWYU_SUMMARY
(tests/cxx/keep_mapping-public.h has correct #includes/fwd-decls)
***** IWYU_SUMMARY */

View File

@ -1,20 +1,20 @@
//===--- keep_mapping.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.
//
//===----------------------------------------------------------------------===//
// The real test here is in keep_mapping-public.h.
#include "tests/cxx/keep_mapping-public.h"
const int kCcInt = kInt;
/**** IWYU_SUMMARY
(tests/cxx/keep_mapping.cc has correct #includes/fwd-decls)
***** IWYU_SUMMARY */
//===--- keep_mapping.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.
//
//===----------------------------------------------------------------------===//
// The real test here is in keep_mapping-public.h.
#include "tests/cxx/keep_mapping-public.h"
const int kCcInt = kInt;
/**** IWYU_SUMMARY
(tests/cxx/keep_mapping.cc has correct #includes/fwd-decls)
***** IWYU_SUMMARY */

View File

@ -1,5 +1,5 @@
# Header mappings for IWYU tests.
[
{ include: ["@\"tests/cxx/keep_mapping-private.*\"", "private", "\"tests/cxx/keep_mapping-public.h\"", "public"] },
{ include: ["\"tests/cxx/keep_mapping-priv.h\"", "private", "\"tests/cxx/keep_mapping-public.h\"", "public"] }
]
# Header mappings for IWYU tests.
[
{ include: ["@\"tests/cxx/keep_mapping-private.*\"", "private", "\"tests/cxx/keep_mapping-public.h\"", "public"] },
{ include: ["\"tests/cxx/keep_mapping-priv.h\"", "private", "\"tests/cxx/keep_mapping-public.h\"", "public"] }
]

View File

@ -1,11 +1,11 @@
//===--- macro_location-d1.h - 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.
//
//===----------------------------------------------------------------------===//
class NewClass {};
class OtherClass {};
//===--- macro_location-d1.h - 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.
//
//===----------------------------------------------------------------------===//
class NewClass {};
class OtherClass {};

View File

@ -1,38 +1,38 @@
//===--- macro_location-d2.h - 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.
//
//===----------------------------------------------------------------------===//
#include "tests/cxx/macro_location-d1.h"
#define ARRAYSIZE(x) ( sizeof(x) / sizeof(*(x)) )
#define NEW_CLASS(name) \
class NewClass_##name : public NewClass { \
public: \
OtherClass o; \
};
// This macro is tricky because myclass_##classname involves a type
// that's defined in scratch space. Make sure this doesn't result in
// an IWYU violation. Nor should classname used *not* in a macro
// concatenation (as the return value of Init).
#define USE_CLASS(classname) \
struct Use_##classname { \
Use_##classname() { Init(); } \
classname* Init() { return 0; } \
}; \
static Use_##classname myclass_##classname
#define CREATE_VAR(typ) typ create_var
/**** IWYU_SUMMARY
(tests/cxx/macro_location-d2.h has correct #includes/fwd-decls)
***** IWYU_SUMMARY */
//===--- macro_location-d2.h - 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.
//
//===----------------------------------------------------------------------===//
#include "tests/cxx/macro_location-d1.h"
#define ARRAYSIZE(x) ( sizeof(x) / sizeof(*(x)) )
#define NEW_CLASS(name) \
class NewClass_##name : public NewClass { \
public: \
OtherClass o; \
};
// This macro is tricky because myclass_##classname involves a type
// that's defined in scratch space. Make sure this doesn't result in
// an IWYU violation. Nor should classname used *not* in a macro
// concatenation (as the return value of Init).
#define USE_CLASS(classname) \
struct Use_##classname { \
Use_##classname() { Init(); } \
classname* Init() { return 0; } \
}; \
static Use_##classname myclass_##classname
#define CREATE_VAR(typ) typ create_var
/**** IWYU_SUMMARY
(tests/cxx/macro_location-d2.h has correct #includes/fwd-decls)
***** IWYU_SUMMARY */

View File

@ -1,10 +1,10 @@
//===--- macro_location-d3.h - 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.
//
//===----------------------------------------------------------------------===//
#include "tests/cxx/macro_location-i3.h"
//===--- macro_location-d3.h - 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.
//
//===----------------------------------------------------------------------===//
#include "tests/cxx/macro_location-i3.h"

View File

@ -1,12 +1,12 @@
//===--- macro_location-i3.h - 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.
//
//===----------------------------------------------------------------------===//
#define DECLARE_FRIEND(cls) friend class cls
class Foo {};
//===--- macro_location-i3.h - 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.
//
//===----------------------------------------------------------------------===//
#define DECLARE_FRIEND(cls) friend class cls
class Foo {};

View File

@ -1,34 +1,34 @@
//===--- macro_location.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.
//
//===----------------------------------------------------------------------===//
// Tests a few common types of macro uses to make sure we correctly
// identify what symbols belong to the macro author, and what symbols
// belong to the macro user. Also make sure we don't ignore macro
// expansions when the macro is written in a to-ignore file.
#include "tests/cxx/macro_location.h"
struct A {
// This doesn't require us to forward-declare ToBeDeclared because it's
// part of a friendship declaration.
friend class ToBeDeclaredLater1;
// iwyu should treat this exactly the same, even though DECLARE_FRIEND
// is in a far-away file.
// IWYU: DECLARE_FRIEND is...*macro_location-i3.h
DECLARE_FRIEND(ToBeDeclaredLater2);
};
class ToBeDeclaredLater1 { };
class ToBeDeclaredLater2 { };
/**** IWYU_SUMMARY
(tests/cxx/macro_location.cc has correct #includes/fwd-decls)
***** IWYU_SUMMARY */
//===--- macro_location.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.
//
//===----------------------------------------------------------------------===//
// Tests a few common types of macro uses to make sure we correctly
// identify what symbols belong to the macro author, and what symbols
// belong to the macro user. Also make sure we don't ignore macro
// expansions when the macro is written in a to-ignore file.
#include "tests/cxx/macro_location.h"
struct A {
// This doesn't require us to forward-declare ToBeDeclared because it's
// part of a friendship declaration.
friend class ToBeDeclaredLater1;
// iwyu should treat this exactly the same, even though DECLARE_FRIEND
// is in a far-away file.
// IWYU: DECLARE_FRIEND is...*macro_location-i3.h
DECLARE_FRIEND(ToBeDeclaredLater2);
};
class ToBeDeclaredLater1 { };
class ToBeDeclaredLater2 { };
/**** IWYU_SUMMARY
(tests/cxx/macro_location.cc has correct #includes/fwd-decls)
***** IWYU_SUMMARY */

View File

@ -1,42 +1,42 @@
//===--- macro_location.h - 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.
//
//===----------------------------------------------------------------------===//
#include "tests/cxx/macro_location-d2.h"
#include "tests/cxx/macro_location-d3.h"
class Foo;
static Foo *foo = 0;
class HClass { };
// IWYU: Foo is...*macro_location-i3.h
const int s = ARRAYSIZE(foo);
// Should not need a declaration of NewClass_Bar, or NewClass.
NEW_CLASS(Bar);
// This shouldn't cause weird iwyu issues between us and macro_location-d2.h.
USE_CLASS(HClass);
// This shouldn't cause macro_location-d1.h to need to include us for HClass.
CREATE_VAR(HClass);
/**** IWYU_SUMMARY
tests/cxx/macro_location.h should add these lines:
#include "tests/cxx/macro_location-i3.h"
tests/cxx/macro_location.h should remove these lines:
- #include "tests/cxx/macro_location-d3.h" // lines XX-XX
- class Foo; // lines XX-XX
The full include-list for tests/cxx/macro_location.h:
#include "tests/cxx/macro_location-d2.h" // for ARRAYSIZE, CREATE_VAR, NEW_CLASS, USE_CLASS
#include "tests/cxx/macro_location-i3.h" // for Foo
***** IWYU_SUMMARY */
//===--- macro_location.h - 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.
//
//===----------------------------------------------------------------------===//
#include "tests/cxx/macro_location-d2.h"
#include "tests/cxx/macro_location-d3.h"
class Foo;
static Foo *foo = 0;
class HClass { };
// IWYU: Foo is...*macro_location-i3.h
const int s = ARRAYSIZE(foo);
// Should not need a declaration of NewClass_Bar, or NewClass.
NEW_CLASS(Bar);
// This shouldn't cause weird iwyu issues between us and macro_location-d2.h.
USE_CLASS(HClass);
// This shouldn't cause macro_location-d1.h to need to include us for HClass.
CREATE_VAR(HClass);
/**** IWYU_SUMMARY
tests/cxx/macro_location.h should add these lines:
#include "tests/cxx/macro_location-i3.h"
tests/cxx/macro_location.h should remove these lines:
- #include "tests/cxx/macro_location-d3.h" // lines XX-XX
- class Foo; // lines XX-XX
The full include-list for tests/cxx/macro_location.h:
#include "tests/cxx/macro_location-d2.h" // for ARRAYSIZE, CREATE_VAR, NEW_CLASS, USE_CLASS
#include "tests/cxx/macro_location-i3.h" // for Foo
***** IWYU_SUMMARY */

View File

@ -1,12 +1,12 @@
//===--- member_expr-d1.h - 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.
//
//===----------------------------------------------------------------------===//
#define CALL_METHOD Method()
#define IC ic
#define IC_CALL_METHOD (ic).Method()
//===--- member_expr-d1.h - 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.
//
//===----------------------------------------------------------------------===//
#define CALL_METHOD Method()
#define IC ic
#define IC_CALL_METHOD (ic).Method()

View File

@ -1,71 +1,71 @@
//===--- member_expr.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.
//
//===----------------------------------------------------------------------===//
// Tests that we correctly detect iwyu use with member accesses.
#include "tests/cxx/member_expr-d1.h"
#include "tests/cxx/direct.h"
// IWYU: IndirectClass needs a declaration
int RefFn(const IndirectClass& ic) {
// IWYU: IndirectClass is...*indirect.h
ic.Method();
// IWYU: IndirectClass is...*indirect.h
return ic.a;
}
// IWYU: IndirectClass needs a declaration
int PtrFn(const IndirectClass* ic) {
// IWYU: IndirectClass is...*indirect.h
ic->Method();
// IWYU: IndirectClass is...*indirect.h
return ic->a;
}
void StaticFn() {
// IWYU: IndirectClass is...*indirect.h
IndirectClass::StaticMethod();
}
// IWYU: IndirectClass needs a declaration
void ViaMacro(const IndirectClass& ic) {
// We should figure out we need IndirectClass because of the 'ic.',
// even if the member-expr itself is in another file due to the macro.
// IWYU: IndirectClass is...*indirect.h
ic.CALL_METHOD;
// Likewise, we 'own' this member expr because we own the dot.
// IWYU: IndirectClass is...*indirect.h
IC.Method();
// IWYU: IndirectClass is...*indirect.h
IC.CALL_METHOD;
IC
.
// IWYU: IndirectClass is...*indirect.h
CALL_METHOD;
// But this member-expr is entirely in the macro, so we don't own it.
IC_CALL_METHOD;
}
/**** IWYU_SUMMARY
tests/cxx/member_expr.cc should add these lines:
#include "tests/cxx/indirect.h"
tests/cxx/member_expr.cc should remove these lines:
- #include "tests/cxx/direct.h" // lines XX-XX
The full include-list for tests/cxx/member_expr.cc:
#include "tests/cxx/indirect.h" // for IndirectClass
#include "tests/cxx/member_expr-d1.h" // for CALL_METHOD, IC, IC_CALL_METHOD
***** IWYU_SUMMARY */
//===--- member_expr.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.
//
//===----------------------------------------------------------------------===//
// Tests that we correctly detect iwyu use with member accesses.
#include "tests/cxx/member_expr-d1.h"
#include "tests/cxx/direct.h"
// IWYU: IndirectClass needs a declaration
int RefFn(const IndirectClass& ic) {
// IWYU: IndirectClass is...*indirect.h
ic.Method();
// IWYU: IndirectClass is...*indirect.h
return ic.a;
}
// IWYU: IndirectClass needs a declaration
int PtrFn(const IndirectClass* ic) {
// IWYU: IndirectClass is...*indirect.h
ic->Method();
// IWYU: IndirectClass is...*indirect.h
return ic->a;
}
void StaticFn() {
// IWYU: IndirectClass is...*indirect.h
IndirectClass::StaticMethod();
}
// IWYU: IndirectClass needs a declaration
void ViaMacro(const IndirectClass& ic) {
// We should figure out we need IndirectClass because of the 'ic.',
// even if the member-expr itself is in another file due to the macro.
// IWYU: IndirectClass is...*indirect.h
ic.CALL_METHOD;
// Likewise, we 'own' this member expr because we own the dot.
// IWYU: IndirectClass is...*indirect.h
IC.Method();
// IWYU: IndirectClass is...*indirect.h
IC.CALL_METHOD;
IC
.
// IWYU: IndirectClass is...*indirect.h
CALL_METHOD;
// But this member-expr is entirely in the macro, so we don't own it.
IC_CALL_METHOD;
}
/**** IWYU_SUMMARY
tests/cxx/member_expr.cc should add these lines:
#include "tests/cxx/indirect.h"
tests/cxx/member_expr.cc should remove these lines:
- #include "tests/cxx/direct.h" // lines XX-XX
The full include-list for tests/cxx/member_expr.cc:
#include "tests/cxx/indirect.h" // for IndirectClass
#include "tests/cxx/member_expr-d1.h" // for CALL_METHOD, IC, IC_CALL_METHOD
***** IWYU_SUMMARY */

View File

@ -1,30 +1,30 @@
//===--- ms_inline_asm.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.
//
//===----------------------------------------------------------------------===//
// This file is not strictly an IWYU test, it just checks that the parser
// doesn't choke on Microsoft inline assembly on any of our target platforms.
// Requires -fms-extensions.
int main() {
int r;
__asm {
// TODO: Add a use here, e.g. by using IndirectClass::statica
// when/if we ever support IWYU analysis inside inline assembly.
mov ecx, 0
mov r, ecx
};
return r;
}
/**** IWYU_SUMMARY
(tests/cxx/ms_inline_asm.cc has correct #includes/fwd-decls)
***** IWYU_SUMMARY */
//===--- ms_inline_asm.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.
//
//===----------------------------------------------------------------------===//
// This file is not strictly an IWYU test, it just checks that the parser
// doesn't choke on Microsoft inline assembly on any of our target platforms.
// Requires -fms-extensions.
int main() {
int r;
__asm {
// TODO: Add a use here, e.g. by using IndirectClass::statica
// when/if we ever support IWYU analysis inside inline assembly.
mov ecx, 0
mov r, ecx
};
return r;
}
/**** IWYU_SUMMARY
(tests/cxx/ms_inline_asm.cc has correct #includes/fwd-decls)
***** IWYU_SUMMARY */

View File

@ -1,44 +1,44 @@
//===--- multiple_include_paths.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.
//
//===----------------------------------------------------------------------===//
// Tests that when a file is referred to in a non-canonical way, iwyu
// respects that rather than trying to rewrite it. This matters most
// when a file can be referred to in two ways because of
// include-paths: if we #include "a/b/c.h" and compile with "-I. -Ia
// -Ia/b", then we could say #include "a/b/c.h", #include "b/c.h", or
// #include "c.h"). clang will, as I understand it, pick one of these
// three forms arbitrarily for FileEntry::getName. We want to use the
// name that was actually written in the source. It also matters when
// there are symlinks in the source-tree.
//
// However, those are both pretty tricky to test, so instead we
// just throw in some ..'s that clang would otherwise normalize.
// For a given file, clang stores the first includename-as-written as
// its canonical name. The include of direct.h will make sure it's
// the one without the ..
#include "tests/cxx/direct.h"
#include "tests/cxx/internal/../indirect.h"
IndirectClass ic;
/**** IWYU_SUMMARY
tests/cxx/multiple_include_paths.cc should add these lines:
tests/cxx/multiple_include_paths.cc should remove these lines:
- #include "tests/cxx/direct.h" // lines XX-XX
The full include-list for tests/cxx/multiple_include_paths.cc:
#include "tests/cxx/internal/../indirect.h" // for IndirectClass
***** IWYU_SUMMARY */
//===--- multiple_include_paths.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.
//
//===----------------------------------------------------------------------===//
// Tests that when a file is referred to in a non-canonical way, iwyu
// respects that rather than trying to rewrite it. This matters most
// when a file can be referred to in two ways because of
// include-paths: if we #include "a/b/c.h" and compile with "-I. -Ia
// -Ia/b", then we could say #include "a/b/c.h", #include "b/c.h", or
// #include "c.h"). clang will, as I understand it, pick one of these
// three forms arbitrarily for FileEntry::getName. We want to use the
// name that was actually written in the source. It also matters when
// there are symlinks in the source-tree.
//
// However, those are both pretty tricky to test, so instead we
// just throw in some ..'s that clang would otherwise normalize.
// For a given file, clang stores the first includename-as-written as
// its canonical name. The include of direct.h will make sure it's
// the one without the ..
#include "tests/cxx/direct.h"
#include "tests/cxx/internal/../indirect.h"
IndirectClass ic;
/**** IWYU_SUMMARY
tests/cxx/multiple_include_paths.cc should add these lines:
tests/cxx/multiple_include_paths.cc should remove these lines:
- #include "tests/cxx/direct.h" // lines XX-XX
The full include-list for tests/cxx/multiple_include_paths.cc:
#include "tests/cxx/internal/../indirect.h" // for IndirectClass
***** IWYU_SUMMARY */

View File

@ -1,38 +1,38 @@
//===--- no_char_traits.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.
//
//===----------------------------------------------------------------------===//
// A very small test that makes sure we don't suggest char_traits
// when using ostreams with a char*. That triggers this code in
// <ostream>:
// inline basic_ostream<char, _Traits>&
// operator<<(basic_ostream<char, _Traits>& __out, const char* __s)
// {
// if (!__s)
// __out.setstate(ios_base::badbit);
// else
// __ostream_insert(__out, __s,
// static_cast<streamsize>(_Traits::length(__s)));
// return __out;
// }
// But for char*'s <ostream> should intend-to-provide traits, even
// though it's a template arg, so the user doesn't have to.
#include <iostream>
int main() {
std::cout << "Hello, world.\n";
// This is more difficult because the first << returns a basic_ostream.
std::cout << "Hello, world." << "\n";
}
/**** IWYU_SUMMARY
(tests/cxx/no_char_traits.cc has correct #includes/fwd-decls)
***** IWYU_SUMMARY */
//===--- no_char_traits.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.
//
//===----------------------------------------------------------------------===//
// A very small test that makes sure we don't suggest char_traits
// when using ostreams with a char*. That triggers this code in
// <ostream>:
// inline basic_ostream<char, _Traits>&
// operator<<(basic_ostream<char, _Traits>& __out, const char* __s)
// {
// if (!__s)
// __out.setstate(ios_base::badbit);
// else
// __ostream_insert(__out, __s,
// static_cast<streamsize>(_Traits::length(__s)));
// return __out;
// }
// But for char*'s <ostream> should intend-to-provide traits, even
// though it's a template arg, so the user doesn't have to.
#include <iostream>
int main() {
std::cout << "Hello, world.\n";
// This is more difficult because the first << returns a basic_ostream.
std::cout << "Hello, world." << "\n";
}
/**** IWYU_SUMMARY
(tests/cxx/no_char_traits.cc has correct #includes/fwd-decls)
***** IWYU_SUMMARY */

View File

@ -1,29 +1,29 @@
//===--- no_definition.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.
//
//===----------------------------------------------------------------------===//
// Tests we keep at least one forward-decl even when there's no definition.
class Foo;
Foo* foo;
template <typename T> class Bar;
Bar<int>* bar;
// The tricky case -- because of the default parameter, we want to
// replace the fwd-decl with a full use, but there *is* no full use.
template <typename T, typename U = int> class Baz;
Baz<int>* baz;
/**** IWYU_SUMMARY
(tests/cxx/no_definition.cc has correct #includes/fwd-decls)
***** IWYU_SUMMARY */
//===--- no_definition.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.
//
//===----------------------------------------------------------------------===//
// Tests we keep at least one forward-decl even when there's no definition.
class Foo;
Foo* foo;
template <typename T> class Bar;
Bar<int>* bar;
// The tricky case -- because of the default parameter, we want to
// replace the fwd-decl with a full use, but there *is* no full use.
template <typename T, typename U = int> class Baz;
Baz<int>* baz;
/**** IWYU_SUMMARY
(tests/cxx/no_definition.cc has correct #includes/fwd-decls)
***** IWYU_SUMMARY */

View File

@ -1,24 +1,24 @@
//===--- no_deque.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.
//
//===----------------------------------------------------------------------===//
// A very small test that makes sure we don't suggest deque when using
// a queue.
#include <queue>
int main() {
std::queue<int> q;
(void)q;
}
/**** IWYU_SUMMARY
(tests/cxx/no_deque.cc has correct #includes/fwd-decls)
***** IWYU_SUMMARY */
//===--- no_deque.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.
//
//===----------------------------------------------------------------------===//
// A very small test that makes sure we don't suggest deque when using
// a queue.
#include <queue>
int main() {
std::queue<int> q;
(void)q;
}
/**** IWYU_SUMMARY
(tests/cxx/no_deque.cc has correct #includes/fwd-decls)
***** IWYU_SUMMARY */

View File

@ -1,12 +1,12 @@
//===--- no_fwd_decl_nested_class-d1.h - 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.
//
//===----------------------------------------------------------------------===//
struct DirectOuterClass {
class NestedClass;
};
//===--- no_fwd_decl_nested_class-d1.h - 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.
//
//===----------------------------------------------------------------------===//
struct DirectOuterClass {
class NestedClass;
};

View File

@ -1,24 +1,24 @@
//===--- no_fwd_decl_nested_class.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.
//
//===----------------------------------------------------------------------===//
// Tests that when we use a nested class, and we already have an
// #include for the outer class, we don't try to forward-declare the
// nested class anyway. Usually we got this right, but sometimes
// wouldn't when then nested class had no definition.
#include "tests/cxx/no_fwd_decl_nested_class-d1.h"
DirectOuterClass doc;
void CallDOC(DirectOuterClass::NestedClass*) { }
/**** IWYU_SUMMARY
(tests/cxx/no_fwd_decl_nested_class.cc has correct #includes/fwd-decls)
***** IWYU_SUMMARY */
//===--- no_fwd_decl_nested_class.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.
//
//===----------------------------------------------------------------------===//
// Tests that when we use a nested class, and we already have an
// #include for the outer class, we don't try to forward-declare the
// nested class anyway. Usually we got this right, but sometimes
// wouldn't when then nested class had no definition.
#include "tests/cxx/no_fwd_decl_nested_class-d1.h"
DirectOuterClass doc;
void CallDOC(DirectOuterClass::NestedClass*) { }
/**** IWYU_SUMMARY
(tests/cxx/no_fwd_decl_nested_class.cc has correct #includes/fwd-decls)
***** IWYU_SUMMARY */

View File

@ -1,43 +1,43 @@
//===--- no_fwd_decl_std.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.
//
//===----------------------------------------------------------------------===//
// Do not forward-declare anything from the std namespace. (This is a
// matter of policy, not language correctness.) When testing, we have
// to make sure to pick something that wouldn't be caught under
// another rule (such as the 'never forward-declare anything with
// default template arguments rule).
#include <utility>
std::pair<int, int>* p1 = 0;
// Make sure it the rule works even with a using declaration
using std::pair;
pair<float, float>* p2 = 0;
// We should remove this fwd-decl, since we're keeping utility
namespace std {
template<typename T, typename U> struct pair;
}
pair<char, char>* p3 = 0;
/**** IWYU_SUMMARY
tests/cxx/no_fwd_decl_std.cc should add these lines:
tests/cxx/no_fwd_decl_std.cc should remove these lines:
- namespace std { template <typename T, typename U> struct pair; } // lines XX-XX
The full include-list for tests/cxx/no_fwd_decl_std.cc:
#include <utility> // for pair
***** IWYU_SUMMARY */
//===--- no_fwd_decl_std.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.
//
//===----------------------------------------------------------------------===//
// Do not forward-declare anything from the std namespace. (This is a
// matter of policy, not language correctness.) When testing, we have
// to make sure to pick something that wouldn't be caught under
// another rule (such as the 'never forward-declare anything with
// default template arguments rule).
#include <utility>
std::pair<int, int>* p1 = 0;
// Make sure it the rule works even with a using declaration
using std::pair;
pair<float, float>* p2 = 0;
// We should remove this fwd-decl, since we're keeping utility
namespace std {
template<typename T, typename U> struct pair;
}
pair<char, char>* p3 = 0;
/**** IWYU_SUMMARY
tests/cxx/no_fwd_decl_std.cc should add these lines:
tests/cxx/no_fwd_decl_std.cc should remove these lines:
- namespace std { template <typename T, typename U> struct pair; } // lines XX-XX
The full include-list for tests/cxx/no_fwd_decl_std.cc:
#include <utility> // for pair
***** IWYU_SUMMARY */

View File

@ -1,20 +1,20 @@
//===--- no_h_includes_cc-inc.c - 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.
//
//===----------------------------------------------------------------------===//
// A .cc file that's included by another .cc file.
#define CC_INC_HAS_INT 1
const int kCcIncInt = 100;
/**** IWYU_SUMMARY
(tests/cxx/no_h_includes_cc-inc.c has correct #includes/fwd-decls)
***** IWYU_SUMMARY */
//===--- no_h_includes_cc-inc.c - 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.
//
//===----------------------------------------------------------------------===//
// A .cc file that's included by another .cc file.
#define CC_INC_HAS_INT 1
const int kCcIncInt = 100;
/**** IWYU_SUMMARY
(tests/cxx/no_h_includes_cc-inc.c has correct #includes/fwd-decls)
***** IWYU_SUMMARY */

View File

@ -1,22 +1,22 @@
//===--- no_h_includes_cc-inc2.c - 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.
//
//===----------------------------------------------------------------------===//
// A .cc file that's included by another .cc file, and uses symbols
// defined in that other .cc file. We should not suggest adding any
// #includes.
#if INCLUDED_FROM_MAIN
const int inc2 = 2;
#endif
/**** IWYU_SUMMARY
(tests/cxx/no_h_includes_cc-inc2.c has correct #includes/fwd-decls)
***** IWYU_SUMMARY */
//===--- no_h_includes_cc-inc2.c - 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.
//
//===----------------------------------------------------------------------===//
// A .cc file that's included by another .cc file, and uses symbols
// defined in that other .cc file. We should not suggest adding any
// #includes.
#if INCLUDED_FROM_MAIN
const int inc2 = 2;
#endif
/**** IWYU_SUMMARY
(tests/cxx/no_h_includes_cc-inc2.c has correct #includes/fwd-decls)
***** IWYU_SUMMARY */

View File

@ -1,28 +1,28 @@
//===--- no_h_includes_cc.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.
//
//===----------------------------------------------------------------------===//
// Tests that we never suggest that a .h file #include a .cc file,
// even in cases where one .cc file #includes another one.
#include "tests/cxx/no_h_includes_cc-inc.c"
#include "tests/cxx/no_h_includes_cc.h"
#ifndef CC_INC_HAS_INT
const int x = kCcIncInt + 2;
#endif
#define INCLUDED_FROM_MAIN 1
#include "tests/cxx/no_h_includes_cc-inc2.c"
/**** IWYU_SUMMARY
(tests/cxx/no_h_includes_cc.cc has correct #includes/fwd-decls)
***** IWYU_SUMMARY */
//===--- no_h_includes_cc.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.
//
//===----------------------------------------------------------------------===//
// Tests that we never suggest that a .h file #include a .cc file,
// even in cases where one .cc file #includes another one.
#include "tests/cxx/no_h_includes_cc-inc.c"
#include "tests/cxx/no_h_includes_cc.h"
#ifndef CC_INC_HAS_INT
const int x = kCcIncInt + 2;
#endif
#define INCLUDED_FROM_MAIN 1
#include "tests/cxx/no_h_includes_cc-inc2.c"
/**** IWYU_SUMMARY
(tests/cxx/no_h_includes_cc.cc has correct #includes/fwd-decls)
***** IWYU_SUMMARY */

View File

@ -1,21 +1,21 @@
//===--- no_h_includes_cc.h - 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.
//
//===----------------------------------------------------------------------===//
// Uses a macro symbol and a non-macro symbol that are defined in the
// -inc.cc file.
#ifndef CC_INC_HAS_INT
const int x = kCcIncInt + 2;
#endif
/**** IWYU_SUMMARY
(tests/cxx/no_h_includes_cc.h has correct #includes/fwd-decls)
***** IWYU_SUMMARY */
//===--- no_h_includes_cc.h - 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.
//
//===----------------------------------------------------------------------===//
// Uses a macro symbol and a non-macro symbol that are defined in the
// -inc.cc file.
#ifndef CC_INC_HAS_INT
const int x = kCcIncInt + 2;
#endif
/**** IWYU_SUMMARY
(tests/cxx/no_h_includes_cc.h has correct #includes/fwd-decls)
***** IWYU_SUMMARY */

View File

@ -1,17 +1,17 @@
//===--- non_transitive_include-d1.h - 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.
//
//===----------------------------------------------------------------------===//
class NonTransitiveIncludeD1 {};
/**** IWYU_SUMMARY
(tests/cxx/non_transitive_include-d1.h has correct #includes/fwd-decls)
***** IWYU_SUMMARY */
//===--- non_transitive_include-d1.h - 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.
//
//===----------------------------------------------------------------------===//
class NonTransitiveIncludeD1 {};
/**** IWYU_SUMMARY
(tests/cxx/non_transitive_include-d1.h has correct #includes/fwd-decls)
***** IWYU_SUMMARY */

View File

@ -1,21 +1,21 @@
//===--- non_transitive_include-d2.h - 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.
//
//===----------------------------------------------------------------------===//
// NOTE: this uses NonTransitiveIncludeD1, from d1.h, but does not
// #include d1.h. But iwyu will not complain because we are in
// --transitive_includes_only mode.
NonTransitiveIncludeD1 nti_d2;
/**** IWYU_SUMMARY
(tests/cxx/non_transitive_include-d2.h has correct #includes/fwd-decls)
***** IWYU_SUMMARY */
//===--- non_transitive_include-d2.h - 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.
//
//===----------------------------------------------------------------------===//
// NOTE: this uses NonTransitiveIncludeD1, from d1.h, but does not
// #include d1.h. But iwyu will not complain because we are in
// --transitive_includes_only mode.
NonTransitiveIncludeD1 nti_d2;
/**** IWYU_SUMMARY
(tests/cxx/non_transitive_include-d2.h has correct #includes/fwd-decls)
***** IWYU_SUMMARY */

View File

@ -1,25 +1,25 @@
//===--- non_transitive_include.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.
//
//===----------------------------------------------------------------------===//
// Tests that when we run in --transitive_includes_only mode, we
// do not suggest that d2.h #include d1.h, even though it needs
// a symbol from there, because d1.h is not a file that d2.h can
// see transitively.
#include "tests/cxx/non_transitive_include-d1.h"
#include "tests/cxx/non_transitive_include-d2.h"
NonTransitiveIncludeD1 nti = nti_d2;
/**** IWYU_SUMMARY
(tests/cxx/non_transitive_include.cc has correct #includes/fwd-decls)
***** IWYU_SUMMARY */
//===--- non_transitive_include.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.
//
//===----------------------------------------------------------------------===//
// Tests that when we run in --transitive_includes_only mode, we
// do not suggest that d2.h #include d1.h, even though it needs
// a symbol from there, because d1.h is not a file that d2.h can
// see transitively.
#include "tests/cxx/non_transitive_include-d1.h"
#include "tests/cxx/non_transitive_include-d2.h"
NonTransitiveIncludeD1 nti = nti_d2;
/**** IWYU_SUMMARY
(tests/cxx/non_transitive_include.cc has correct #includes/fwd-decls)
***** IWYU_SUMMARY */

View File

@ -1,15 +1,15 @@
//===--- overloaded_class-d1.h - 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.
//
//===----------------------------------------------------------------------===//
#ifndef DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_OVERLOADED_CLASS_D1_H_
#define DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_OVERLOADED_CLASS_D1_H_
#include "tests/cxx/overloaded_class-i1.h"
#endif // DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_OVERLOADED_CLASS_D1_H_
//===--- overloaded_class-d1.h - 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.
//
//===----------------------------------------------------------------------===//
#ifndef DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_OVERLOADED_CLASS_D1_H_
#define DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_OVERLOADED_CLASS_D1_H_
#include "tests/cxx/overloaded_class-i1.h"
#endif // DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_OVERLOADED_CLASS_D1_H_

View File

@ -1,30 +1,30 @@
//===--- overloaded_class-i1.h - 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.
//
//===----------------------------------------------------------------------===//
#ifndef DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_OVERLOADED_CLASS_I1_H_
#define DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_OVERLOADED_CLASS_I1_H_
#include <vector>
// This is a template function that instantiates a template type. It
// should be responsible for the type because all possible
// instantiations come from the same file.
template<class T> void MyFunc() {
std::vector<T> v;
v.resize(10);
}
#endif // DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_OVERLOADED_CLASS_I1_H_
/**** IWYU_SUMMARY
(tests/cxx/overloaded_class-i1.h has correct #includes/fwd-decls)
***** IWYU_SUMMARY */
//===--- overloaded_class-i1.h - 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.
//
//===----------------------------------------------------------------------===//
#ifndef DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_OVERLOADED_CLASS_I1_H_
#define DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_OVERLOADED_CLASS_I1_H_
#include <vector>
// This is a template function that instantiates a template type. It
// should be responsible for the type because all possible
// instantiations come from the same file.
template<class T> void MyFunc() {
std::vector<T> v;
v.resize(10);
}
#endif // DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_OVERLOADED_CLASS_I1_H_
/**** IWYU_SUMMARY
(tests/cxx/overloaded_class-i1.h has correct #includes/fwd-decls)
***** IWYU_SUMMARY */

View File

@ -1,33 +1,33 @@
//===--- overloaded_class.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.
//
//===----------------------------------------------------------------------===//
// Tests the case where a template type is instantiated inside a
// template function. If all the possible instantiations come
// from the same place, we want the template function to be
// responsible for the template type, and not the caller.
#include "tests/cxx/overloaded_class-d1.h"
int main() {
// IWYU: MyFunc is...*overloaded_class-i1.h
MyFunc<int>();
}
/**** IWYU_SUMMARY
tests/cxx/overloaded_class.cc should add these lines:
#include "tests/cxx/overloaded_class-i1.h"
tests/cxx/overloaded_class.cc should remove these lines:
- #include "tests/cxx/overloaded_class-d1.h" // lines XX-XX
The full include-list for tests/cxx/overloaded_class.cc:
#include "tests/cxx/overloaded_class-i1.h" // for MyFunc
***** IWYU_SUMMARY */
//===--- overloaded_class.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.
//
//===----------------------------------------------------------------------===//
// Tests the case where a template type is instantiated inside a
// template function. If all the possible instantiations come
// from the same place, we want the template function to be
// responsible for the template type, and not the caller.
#include "tests/cxx/overloaded_class-d1.h"
int main() {
// IWYU: MyFunc is...*overloaded_class-i1.h
MyFunc<int>();
}
/**** IWYU_SUMMARY
tests/cxx/overloaded_class.cc should add these lines:
#include "tests/cxx/overloaded_class-i1.h"
tests/cxx/overloaded_class.cc should remove these lines:
- #include "tests/cxx/overloaded_class-d1.h" // lines XX-XX
The full include-list for tests/cxx/overloaded_class.cc:
#include "tests/cxx/overloaded_class-i1.h" // for MyFunc
***** IWYU_SUMMARY */

View File

@ -1,24 +1,24 @@
//===--- precomputed_tpl_args-d1.h - 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.
//
//===----------------------------------------------------------------------===//
// Tests the precomputed template-arg-use list in iwyu_cache.cc.
#include "tests/cxx/precomputed_tpl_args-i1.h"
// Provide another class that we have a std::allocator specialization for.
class D1SpecializationClass { };
namespace std {
template<> class less<D1SpecializationClass> {
public:
bool operator()(const D1SpecializationClass&, const D1SpecializationClass&) {
return true;
}
};
}
//===--- precomputed_tpl_args-d1.h - 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.
//
//===----------------------------------------------------------------------===//
// Tests the precomputed template-arg-use list in iwyu_cache.cc.
#include "tests/cxx/precomputed_tpl_args-i1.h"
// Provide another class that we have a std::allocator specialization for.
class D1SpecializationClass { };
namespace std {
template<> class less<D1SpecializationClass> {
public:
bool operator()(const D1SpecializationClass&, const D1SpecializationClass&) {
return true;
}
};
}

View File

@ -1,24 +1,24 @@
//===--- precomputed_tpl_args-i1.h - 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.
//
//===----------------------------------------------------------------------===//
#include <functional>
class IndirectClass { };
// Provide another class that we have a std::allocator specialization for.
class SpecializationClass { };
namespace std {
template<> class less<SpecializationClass> {
public:
bool operator()(const SpecializationClass&, const SpecializationClass&) {
return true;
}
};
}
//===--- precomputed_tpl_args-i1.h - 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.
//
//===----------------------------------------------------------------------===//
#include <functional>
class IndirectClass { };
// Provide another class that we have a std::allocator specialization for.
class SpecializationClass { };
namespace std {
template<> class less<SpecializationClass> {
public:
bool operator()(const SpecializationClass&, const SpecializationClass&) {
return true;
}
};
}

View File

@ -1,98 +1,98 @@
//===--- precomputed_tpl_args.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.
//
//===----------------------------------------------------------------------===//
// Tests the precomputed template-arg-use list in iwyu_cache.cc.
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include "tests/cxx/precomputed_tpl_args-d1.h"
template <typename T> struct Identity {
T t;
};
// IWYU: IndirectClass needs a declaration
// IWYU: IndirectClass is...*precomputed_tpl_args-i1.h
std::vector<IndirectClass> ic_vec;
// IWYU: IndirectClass needs a declaration
// IWYU: IndirectClass is...*precomputed_tpl_args-i1.h
std::vector<Identity<IndirectClass> > i_ic_vec;
// IWYU: IndirectClass needs a declaration
std::vector<IndirectClass*> icptr_vec;
// IWYU: IndirectClass needs a declaration
// IWYU: IndirectClass is...*precomputed_tpl_args-i1.h
std::set<IndirectClass> ic_set;
// This class provides a specialization of less that we should see.
// IWYU: SpecializationClass needs a declaration
// IWYU: SpecializationClass is...*precomputed_tpl_args-i1.h
// IWYU: std::less is...*precomputed_tpl_args-i1.h
std::set<SpecializationClass> sc_set;
// This class provides a specialization of less that we should see,
// in d1.h. We should be sure not to remove -d1.h as a result!
std::set<D1SpecializationClass> d1sc_set;
// We were seeing a bug where, inside a typedef, we got an incorrect
// iwyu violation report for less<>. Make sure that's fixed.
// (This should be a new type from above so we don't hit the cache.)
typedef std::set<int> IntSet;
// Call the constructor to cause it to be instantiated, so iwyu visits it.
IntSet int_set;
// bitset should not be precomputed, since it has a non-class arg.
std::bitset<5> bitset;
// When considering a precomputed type (like map<>) inside a templated
// class, make sure that we only consider the precomputed args that
// are part of the instantiation of the templated class. That is,
// for map<T, SpecializationClass>, we should only consider T.
template<typename T> class TemplatedClass {
// TODO(csilvers): IWYU: SpecializationClass is...*precomputed_tpl_args-i1.h
// TODO(csilvers): IWYU: std::less is...*precomputed_tpl_args-i1.h
// IWYU: SpecializationClass needs a declaration
std::map<SpecializationClass, T> t1;
// TODO(csilvers): IWYU: IndirectClass is...*precomputed_tpl_args-i1.h
// IWYU: IndirectClass needs a declaration
std::map<T, IndirectClass> t3;
};
// IWYU: IndirectClass needs a declaration
// IWYU: IndirectClass is...*precomputed_tpl_args-i1.h
TemplatedClass<IndirectClass> tc_ic;
// TODO(csilvers): IWYU: std::less is...*precomputed_tpl_args-i1.h
// IWYU: SpecializationClass needs a declaration
// IWYU: SpecializationClass is...*precomputed_tpl_args-i1.h
TemplatedClass<SpecializationClass> tc_sc;
/**** IWYU_SUMMARY
tests/cxx/precomputed_tpl_args.cc should add these lines:
#include "tests/cxx/precomputed_tpl_args-i1.h"
tests/cxx/precomputed_tpl_args.cc should remove these lines:
The full include-list for tests/cxx/precomputed_tpl_args.cc:
#include <bitset> // for bitset
#include <map> // for map
#include <set> // for set
#include <vector> // for vector
#include "tests/cxx/precomputed_tpl_args-d1.h" // for D1SpecializationClass, less
#include "tests/cxx/precomputed_tpl_args-i1.h" // for IndirectClass, SpecializationClass, less
***** IWYU_SUMMARY */
//===--- precomputed_tpl_args.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.
//
//===----------------------------------------------------------------------===//
// Tests the precomputed template-arg-use list in iwyu_cache.cc.
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include "tests/cxx/precomputed_tpl_args-d1.h"
template <typename T> struct Identity {
T t;
};
// IWYU: IndirectClass needs a declaration
// IWYU: IndirectClass is...*precomputed_tpl_args-i1.h
std::vector<IndirectClass> ic_vec;
// IWYU: IndirectClass needs a declaration
// IWYU: IndirectClass is...*precomputed_tpl_args-i1.h
std::vector<Identity<IndirectClass> > i_ic_vec;
// IWYU: IndirectClass needs a declaration
std::vector<IndirectClass*> icptr_vec;
// IWYU: IndirectClass needs a declaration
// IWYU: IndirectClass is...*precomputed_tpl_args-i1.h
std::set<IndirectClass> ic_set;
// This class provides a specialization of less that we should see.
// IWYU: SpecializationClass needs a declaration
// IWYU: SpecializationClass is...*precomputed_tpl_args-i1.h
// IWYU: std::less is...*precomputed_tpl_args-i1.h
std::set<SpecializationClass> sc_set;
// This class provides a specialization of less that we should see,
// in d1.h. We should be sure not to remove -d1.h as a result!
std::set<D1SpecializationClass> d1sc_set;
// We were seeing a bug where, inside a typedef, we got an incorrect
// iwyu violation report for less<>. Make sure that's fixed.
// (This should be a new type from above so we don't hit the cache.)
typedef std::set<int> IntSet;
// Call the constructor to cause it to be instantiated, so iwyu visits it.
IntSet int_set;
// bitset should not be precomputed, since it has a non-class arg.
std::bitset<5> bitset;
// When considering a precomputed type (like map<>) inside a templated
// class, make sure that we only consider the precomputed args that
// are part of the instantiation of the templated class. That is,
// for map<T, SpecializationClass>, we should only consider T.
template<typename T> class TemplatedClass {
// TODO(csilvers): IWYU: SpecializationClass is...*precomputed_tpl_args-i1.h
// TODO(csilvers): IWYU: std::less is...*precomputed_tpl_args-i1.h
// IWYU: SpecializationClass needs a declaration
std::map<SpecializationClass, T> t1;
// TODO(csilvers): IWYU: IndirectClass is...*precomputed_tpl_args-i1.h
// IWYU: IndirectClass needs a declaration
std::map<T, IndirectClass> t3;
};
// IWYU: IndirectClass needs a declaration
// IWYU: IndirectClass is...*precomputed_tpl_args-i1.h
TemplatedClass<IndirectClass> tc_ic;
// TODO(csilvers): IWYU: std::less is...*precomputed_tpl_args-i1.h
// IWYU: SpecializationClass needs a declaration
// IWYU: SpecializationClass is...*precomputed_tpl_args-i1.h
TemplatedClass<SpecializationClass> tc_sc;
/**** IWYU_SUMMARY
tests/cxx/precomputed_tpl_args.cc should add these lines:
#include "tests/cxx/precomputed_tpl_args-i1.h"
tests/cxx/precomputed_tpl_args.cc should remove these lines:
The full include-list for tests/cxx/precomputed_tpl_args.cc:
#include <bitset> // for bitset
#include <map> // for map
#include <set> // for set
#include <vector> // for vector
#include "tests/cxx/precomputed_tpl_args-d1.h" // for D1SpecializationClass, less
#include "tests/cxx/precomputed_tpl_args-i1.h" // for IndirectClass, SpecializationClass, less
***** IWYU_SUMMARY */

View File

@ -1,15 +1,15 @@
//===--- prefix_header_includes-d1.h - 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.
//
//===----------------------------------------------------------------------===//
#ifndef DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_PREFIX_HEADER_INCLUDES_D1_H_
#define DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_PREFIX_HEADER_INCLUDES_D1_H_
class CommandLineIncludeD1 {};
#endif // DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_PREFIX_HEADER_INCLUDES_D1_H_
//===--- prefix_header_includes-d1.h - 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.
//
//===----------------------------------------------------------------------===//
#ifndef DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_PREFIX_HEADER_INCLUDES_D1_H_
#define DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_PREFIX_HEADER_INCLUDES_D1_H_
class CommandLineIncludeD1 {};
#endif // DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_PREFIX_HEADER_INCLUDES_D1_H_

View File

@ -1,17 +1,17 @@
//===--- prefix_header_includes-d2.h - 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.
//
//===----------------------------------------------------------------------===//
#ifndef DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_PREFIX_HEADER_INCLUDES_D2_H_
#define DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_PREFIX_HEADER_INCLUDES_D2_H_
#include "tests/cxx/prefix_header_includes-i1.h"
class CommandLineIncludeD2 {};
#endif // DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_PREFIX_HEADER_INCLUDES_D2_H_
//===--- prefix_header_includes-d2.h - 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.
//
//===----------------------------------------------------------------------===//
#ifndef DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_PREFIX_HEADER_INCLUDES_D2_H_
#define DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_PREFIX_HEADER_INCLUDES_D2_H_
#include "tests/cxx/prefix_header_includes-i1.h"
class CommandLineIncludeD2 {};
#endif // DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_PREFIX_HEADER_INCLUDES_D2_H_

View File

@ -1,15 +1,15 @@
//===--- prefix_header_includes-d3.h - 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.
//
//===----------------------------------------------------------------------===//
#ifndef DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_PREFIX_HEADER_INCLUDES_D3_H_
#define DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_PREFIX_HEADER_INCLUDES_D3_H_
class CommandLineIncludeD3 {};
#endif // DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_PREFIX_HEADER_INCLUDES_D3_H_
//===--- prefix_header_includes-d3.h - 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.
//
//===----------------------------------------------------------------------===//
#ifndef DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_PREFIX_HEADER_INCLUDES_D3_H_
#define DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_PREFIX_HEADER_INCLUDES_D3_H_
class CommandLineIncludeD3 {};
#endif // DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_PREFIX_HEADER_INCLUDES_D3_H_

View File

@ -1,15 +1,15 @@
//===--- prefix_header_includes-d4.h - 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.
//
//===----------------------------------------------------------------------===//
#ifndef DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_PREFIX_HEADER_INCLUDES_D4_H_
#define DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_PREFIX_HEADER_INCLUDES_D4_H_
class CommandLineIncludeD4 {};
#endif // DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_PREFIX_HEADER_INCLUDES_D4_H_
//===--- prefix_header_includes-d4.h - 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.
//
//===----------------------------------------------------------------------===//
#ifndef DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_PREFIX_HEADER_INCLUDES_D4_H_
#define DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_PREFIX_HEADER_INCLUDES_D4_H_
class CommandLineIncludeD4 {};
#endif // DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_PREFIX_HEADER_INCLUDES_D4_H_

View File

@ -1,15 +1,15 @@
//===--- prefix_header_includes-i1.h - 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.
//
//===----------------------------------------------------------------------===//
#ifndef DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_PREFIX_HEADER_INCLUDES_I1_H_
#define DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_PREFIX_HEADER_INCLUDES_I1_H_
class CommandLineIncludeI1 {};
#endif // DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_PREFIX_HEADER_INCLUDES_I1_H_
//===--- prefix_header_includes-i1.h - 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.
//
//===----------------------------------------------------------------------===//
#ifndef DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_PREFIX_HEADER_INCLUDES_I1_H_
#define DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_PREFIX_HEADER_INCLUDES_I1_H_
class CommandLineIncludeI1 {};
#endif // DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_PREFIX_HEADER_INCLUDES_I1_H_

View File

@ -1,56 +1,56 @@
//===--- prefix_header_includes_add.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.
//
//===----------------------------------------------------------------------===//
// Tests --prefix_header_includes option. All prefix_header_includes_*.cc files
// are the same to show the difference between --prefix_header_includes values.
#include "tests/cxx/direct.h"
#include "tests/cxx/prefix_header_includes-d1.h"
// Included in source code and via command line option.
CommandLineIncludeD1 cli_d1;
// Included via command line option only.
// IWYU: CommandLineIncludeD2 is...*prefix_header_includes-d2.h
CommandLineIncludeD2 cli_d2;
// Forward declared in source code and included via command line option.
class CommandLineIncludeD3;
CommandLineIncludeD3* cli_d3_ptr;
// Included via command line option only.
// IWYU: CommandLineIncludeD4 needs a declaration
CommandLineIncludeD4* cli_d4_ptr;
// Test that is_prefix_header property is preserved for indirect includes.
// IWYU: CommandLineIncludeI1 is...*prefix_header_includes-i1.h
CommandLineIncludeI1 cli_i1;
// Test not prefix header include.
// IWYU: IndirectClass is...*indirect.h
IndirectClass ic;
/**** IWYU_SUMMARY
tests/cxx/prefix_header_includes_add.cc should add these lines:
#include "tests/cxx/indirect.h"
#include "tests/cxx/prefix_header_includes-d2.h"
#include "tests/cxx/prefix_header_includes-i1.h"
class CommandLineIncludeD4;
tests/cxx/prefix_header_includes_add.cc should remove these lines:
- #include "tests/cxx/direct.h" // lines XX-XX
The full include-list for tests/cxx/prefix_header_includes_add.cc:
#include "tests/cxx/indirect.h" // for IndirectClass
#include "tests/cxx/prefix_header_includes-d1.h" // for CommandLineIncludeD1
#include "tests/cxx/prefix_header_includes-d2.h" // for CommandLineIncludeD2
#include "tests/cxx/prefix_header_includes-i1.h" // for CommandLineIncludeI1
class CommandLineIncludeD3; // lines XX-XX
class CommandLineIncludeD4;
***** IWYU_SUMMARY */
//===--- prefix_header_includes_add.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.
//
//===----------------------------------------------------------------------===//
// Tests --prefix_header_includes option. All prefix_header_includes_*.cc files
// are the same to show the difference between --prefix_header_includes values.
#include "tests/cxx/direct.h"
#include "tests/cxx/prefix_header_includes-d1.h"
// Included in source code and via command line option.
CommandLineIncludeD1 cli_d1;
// Included via command line option only.
// IWYU: CommandLineIncludeD2 is...*prefix_header_includes-d2.h
CommandLineIncludeD2 cli_d2;
// Forward declared in source code and included via command line option.
class CommandLineIncludeD3;
CommandLineIncludeD3* cli_d3_ptr;
// Included via command line option only.
// IWYU: CommandLineIncludeD4 needs a declaration
CommandLineIncludeD4* cli_d4_ptr;
// Test that is_prefix_header property is preserved for indirect includes.
// IWYU: CommandLineIncludeI1 is...*prefix_header_includes-i1.h
CommandLineIncludeI1 cli_i1;
// Test not prefix header include.
// IWYU: IndirectClass is...*indirect.h
IndirectClass ic;
/**** IWYU_SUMMARY
tests/cxx/prefix_header_includes_add.cc should add these lines:
#include "tests/cxx/indirect.h"
#include "tests/cxx/prefix_header_includes-d2.h"
#include "tests/cxx/prefix_header_includes-i1.h"
class CommandLineIncludeD4;
tests/cxx/prefix_header_includes_add.cc should remove these lines:
- #include "tests/cxx/direct.h" // lines XX-XX
The full include-list for tests/cxx/prefix_header_includes_add.cc:
#include "tests/cxx/indirect.h" // for IndirectClass
#include "tests/cxx/prefix_header_includes-d1.h" // for CommandLineIncludeD1
#include "tests/cxx/prefix_header_includes-d2.h" // for CommandLineIncludeD2
#include "tests/cxx/prefix_header_includes-i1.h" // for CommandLineIncludeI1
class CommandLineIncludeD3; // lines XX-XX
class CommandLineIncludeD4;
***** IWYU_SUMMARY */

View File

@ -1,50 +1,50 @@
//===--- prefix_header_includes_keep.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.
//
//===----------------------------------------------------------------------===//
// Tests --prefix_header_includes option. All prefix_header_includes_*.cc files
// are the same to show the difference between --prefix_header_includes values.
#include "tests/cxx/direct.h"
#include "tests/cxx/prefix_header_includes-d1.h"
// Included in source code and via command line option.
CommandLineIncludeD1 cli_d1;
// Included via command line option only.
// IWYU: CommandLineIncludeD2 is...*prefix_header_includes-d2.h
CommandLineIncludeD2 cli_d2;
// Forward declared in source code and included via command line option.
class CommandLineIncludeD3;
CommandLineIncludeD3* cli_d3_ptr;
// Included via command line option only.
// IWYU: CommandLineIncludeD4 needs a declaration
CommandLineIncludeD4* cli_d4_ptr;
// Test that is_prefix_header property is preserved for indirect includes.
// IWYU: CommandLineIncludeI1 is...*prefix_header_includes-i1.h
CommandLineIncludeI1 cli_i1;
// Test not prefix header include.
// IWYU: IndirectClass is...*indirect.h
IndirectClass ic;
/**** IWYU_SUMMARY
tests/cxx/prefix_header_includes_keep.cc should add these lines:
#include "tests/cxx/indirect.h"
tests/cxx/prefix_header_includes_keep.cc should remove these lines:
- #include "tests/cxx/direct.h" // lines XX-XX
The full include-list for tests/cxx/prefix_header_includes_keep.cc:
#include "tests/cxx/indirect.h" // for IndirectClass
#include "tests/cxx/prefix_header_includes-d1.h" // for CommandLineIncludeD1
class CommandLineIncludeD3; // lines XX-XX
***** IWYU_SUMMARY */
//===--- prefix_header_includes_keep.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.
//
//===----------------------------------------------------------------------===//
// Tests --prefix_header_includes option. All prefix_header_includes_*.cc files
// are the same to show the difference between --prefix_header_includes values.
#include "tests/cxx/direct.h"
#include "tests/cxx/prefix_header_includes-d1.h"
// Included in source code and via command line option.
CommandLineIncludeD1 cli_d1;
// Included via command line option only.
// IWYU: CommandLineIncludeD2 is...*prefix_header_includes-d2.h
CommandLineIncludeD2 cli_d2;
// Forward declared in source code and included via command line option.
class CommandLineIncludeD3;
CommandLineIncludeD3* cli_d3_ptr;
// Included via command line option only.
// IWYU: CommandLineIncludeD4 needs a declaration
CommandLineIncludeD4* cli_d4_ptr;
// Test that is_prefix_header property is preserved for indirect includes.
// IWYU: CommandLineIncludeI1 is...*prefix_header_includes-i1.h
CommandLineIncludeI1 cli_i1;
// Test not prefix header include.
// IWYU: IndirectClass is...*indirect.h
IndirectClass ic;
/**** IWYU_SUMMARY
tests/cxx/prefix_header_includes_keep.cc should add these lines:
#include "tests/cxx/indirect.h"
tests/cxx/prefix_header_includes_keep.cc should remove these lines:
- #include "tests/cxx/direct.h" // lines XX-XX
The full include-list for tests/cxx/prefix_header_includes_keep.cc:
#include "tests/cxx/indirect.h" // for IndirectClass
#include "tests/cxx/prefix_header_includes-d1.h" // for CommandLineIncludeD1
class CommandLineIncludeD3; // lines XX-XX
***** IWYU_SUMMARY */

View File

@ -1,50 +1,50 @@
//===--- prefix_header_includes_remove.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.
//
//===----------------------------------------------------------------------===//
// Tests --prefix_header_includes option. All prefix_header_includes_*.cc files
// are the same to show the difference between --prefix_header_includes values.
#include "tests/cxx/direct.h"
#include "tests/cxx/prefix_header_includes-d1.h"
// Included in source code and via command line option.
CommandLineIncludeD1 cli_d1;
// Included via command line option only.
// IWYU: CommandLineIncludeD2 is...*prefix_header_includes-d2.h
CommandLineIncludeD2 cli_d2;
// Forward declared in source code and included via command line option.
class CommandLineIncludeD3;
CommandLineIncludeD3* cli_d3_ptr;
// Included via command line option only.
// IWYU: CommandLineIncludeD4 needs a declaration
CommandLineIncludeD4* cli_d4_ptr;
// Test that is_prefix_header property is preserved for indirect includes.
// IWYU: CommandLineIncludeI1 is...*prefix_header_includes-i1.h
CommandLineIncludeI1 cli_i1;
// Test not prefix header include.
// IWYU: IndirectClass is...*indirect.h
IndirectClass ic;
/**** IWYU_SUMMARY
tests/cxx/prefix_header_includes_remove.cc should add these lines:
#include "tests/cxx/indirect.h"
tests/cxx/prefix_header_includes_remove.cc should remove these lines:
- #include "tests/cxx/direct.h" // lines XX-XX
- #include "tests/cxx/prefix_header_includes-d1.h" // lines XX-XX
- class CommandLineIncludeD3; // lines XX-XX
The full include-list for tests/cxx/prefix_header_includes_remove.cc:
#include "tests/cxx/indirect.h" // for IndirectClass
***** IWYU_SUMMARY */
//===--- prefix_header_includes_remove.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.
//
//===----------------------------------------------------------------------===//
// Tests --prefix_header_includes option. All prefix_header_includes_*.cc files
// are the same to show the difference between --prefix_header_includes values.
#include "tests/cxx/direct.h"
#include "tests/cxx/prefix_header_includes-d1.h"
// Included in source code and via command line option.
CommandLineIncludeD1 cli_d1;
// Included via command line option only.
// IWYU: CommandLineIncludeD2 is...*prefix_header_includes-d2.h
CommandLineIncludeD2 cli_d2;
// Forward declared in source code and included via command line option.
class CommandLineIncludeD3;
CommandLineIncludeD3* cli_d3_ptr;
// Included via command line option only.
// IWYU: CommandLineIncludeD4 needs a declaration
CommandLineIncludeD4* cli_d4_ptr;
// Test that is_prefix_header property is preserved for indirect includes.
// IWYU: CommandLineIncludeI1 is...*prefix_header_includes-i1.h
CommandLineIncludeI1 cli_i1;
// Test not prefix header include.
// IWYU: IndirectClass is...*indirect.h
IndirectClass ic;
/**** IWYU_SUMMARY
tests/cxx/prefix_header_includes_remove.cc should add these lines:
#include "tests/cxx/indirect.h"
tests/cxx/prefix_header_includes_remove.cc should remove these lines:
- #include "tests/cxx/direct.h" // lines XX-XX
- #include "tests/cxx/prefix_header_includes-d1.h" // lines XX-XX
- class CommandLineIncludeD3; // lines XX-XX
The full include-list for tests/cxx/prefix_header_includes_remove.cc:
#include "tests/cxx/indirect.h" // for IndirectClass
***** IWYU_SUMMARY */

View File

@ -1,15 +1,15 @@
//===--- re_fwd_decl-d1.h - 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.
//
//===----------------------------------------------------------------------===//
#include "tests/cxx/indirect.h"
class Direct {};
class Indirect;
class FullUse {};
//===--- re_fwd_decl-d1.h - 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.
//
//===----------------------------------------------------------------------===//
#include "tests/cxx/indirect.h"
class Direct {};
class Indirect;
class FullUse {};

View File

@ -1,40 +1,40 @@
//===--- re_fwd_decl.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.
//
//===----------------------------------------------------------------------===//
// If we use a class in a way that only requires a forward-declaration,
// and the class is defined in some file we directly #include, we don't
// need the forward-decl here. But if it's only *declared* in a file
// we directly #include, we *do* need the forward-decl.
#include "tests/cxx/re_fwd_decl.h"
#include "tests/cxx/re_fwd_decl-d1.h"
Direct* d = 0;
// IWYU: Indirect needs a declaration
Indirect* i = 0;
// This is not an iwyu violation because it's declared in the .h file
DeclaredInH* dih = 0;
// This forces us to #include re_fwd_decl-d1.h. Without this, iwyu would
// just suggest replacing the #include with 'class Direct'.
FullUse fu;
/**** IWYU_SUMMARY
tests/cxx/re_fwd_decl.cc should add these lines:
class Indirect;
tests/cxx/re_fwd_decl.cc should remove these lines:
The full include-list for tests/cxx/re_fwd_decl.cc:
#include "tests/cxx/re_fwd_decl.h"
#include "tests/cxx/re_fwd_decl-d1.h" // for Direct (ptr only), FullUse
class Indirect;
***** IWYU_SUMMARY */
//===--- re_fwd_decl.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.
//
//===----------------------------------------------------------------------===//
// If we use a class in a way that only requires a forward-declaration,
// and the class is defined in some file we directly #include, we don't
// need the forward-decl here. But if it's only *declared* in a file
// we directly #include, we *do* need the forward-decl.
#include "tests/cxx/re_fwd_decl.h"
#include "tests/cxx/re_fwd_decl-d1.h"
Direct* d = 0;
// IWYU: Indirect needs a declaration
Indirect* i = 0;
// This is not an iwyu violation because it's declared in the .h file
DeclaredInH* dih = 0;
// This forces us to #include re_fwd_decl-d1.h. Without this, iwyu would
// just suggest replacing the #include with 'class Direct'.
FullUse fu;
/**** IWYU_SUMMARY
tests/cxx/re_fwd_decl.cc should add these lines:
class Indirect;
tests/cxx/re_fwd_decl.cc should remove these lines:
The full include-list for tests/cxx/re_fwd_decl.cc:
#include "tests/cxx/re_fwd_decl.h"
#include "tests/cxx/re_fwd_decl-d1.h" // for Direct (ptr only), FullUse
class Indirect;
***** IWYU_SUMMARY */

View File

@ -1,18 +1,18 @@
//===--- re_fwd_decl.h - 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.
//
//===----------------------------------------------------------------------===//
class DeclaredInH;
DeclaredInH* use = 0;
/**** IWYU_SUMMARY
(tests/cxx/re_fwd_decl.h has correct #includes/fwd-decls)
***** IWYU_SUMMARY */
//===--- re_fwd_decl.h - 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.
//
//===----------------------------------------------------------------------===//
class DeclaredInH;
DeclaredInH* use = 0;
/**** IWYU_SUMMARY
(tests/cxx/re_fwd_decl.h has correct #includes/fwd-decls)
***** IWYU_SUMMARY */

View File

@ -1,15 +1,15 @@
//===--- redecls-d1.h - 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.
//
//===----------------------------------------------------------------------===//
// These are the redeclarable types, according to
// http://clang.llvm.org/doxygen/classclang_1_1Redeclarable.html
typedef int MyTypedef;
void Fn();
extern float var;
//===--- redecls-d1.h - 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.
//
//===----------------------------------------------------------------------===//
// These are the redeclarable types, according to
// http://clang.llvm.org/doxygen/classclang_1_1Redeclarable.html
typedef int MyTypedef;
void Fn();
extern float var;

View File

@ -1,14 +1,14 @@
//===--- redecls-d2.h - 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.
//
//===----------------------------------------------------------------------===//
// This looks suspiciously like redecls-d1.h. :-)
typedef int MyTypedef;
void Fn();
extern float var;
//===--- redecls-d2.h - 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.
//
//===----------------------------------------------------------------------===//
// This looks suspiciously like redecls-d1.h. :-)
typedef int MyTypedef;
void Fn();
extern float var;

View File

@ -1,33 +1,33 @@
//===--- redecls.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.
//
//===----------------------------------------------------------------------===//
// For types that can be declared in many places -- functions,
// typedefs, variables, and the like -- make sure that we accept
// any declaration as satisfying a use. In order to minimize
// chances that we're only looking at one of the redecls but are
// happening to pick the one in the same file as the use, we
// put the use-file in the "middle".
#include "tests/cxx/redecls-d1.h"
#include "tests/cxx/redecls.h"
#include "tests/cxx/redecls-d2.h"
/**** IWYU_SUMMARY
tests/cxx/redecls.cc should add these lines:
tests/cxx/redecls.cc should remove these lines:
- #include "tests/cxx/redecls-d1.h" // lines XX-XX
- #include "tests/cxx/redecls-d2.h" // lines XX-XX
The full include-list for tests/cxx/redecls.cc:
#include "tests/cxx/redecls.h"
***** IWYU_SUMMARY */
//===--- redecls.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.
//
//===----------------------------------------------------------------------===//
// For types that can be declared in many places -- functions,
// typedefs, variables, and the like -- make sure that we accept
// any declaration as satisfying a use. In order to minimize
// chances that we're only looking at one of the redecls but are
// happening to pick the one in the same file as the use, we
// put the use-file in the "middle".
#include "tests/cxx/redecls-d1.h"
#include "tests/cxx/redecls.h"
#include "tests/cxx/redecls-d2.h"
/**** IWYU_SUMMARY
tests/cxx/redecls.cc should add these lines:
tests/cxx/redecls.cc should remove these lines:
- #include "tests/cxx/redecls-d1.h" // lines XX-XX
- #include "tests/cxx/redecls-d2.h" // lines XX-XX
The full include-list for tests/cxx/redecls.cc:
#include "tests/cxx/redecls.h"
***** IWYU_SUMMARY */

View File

@ -1,39 +1,39 @@
//===--- redecls.h - 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.
//
//===----------------------------------------------------------------------===//
#include "tests/cxx/redecls-d1.h"
// This looks suspiciously like redecls-d1.h and redecls-d2.h. But with
// uses, of course.
typedef int MyTypedef;
void Fn();
extern float var;
// Put this after our decls to encourage clang to associate the uses
// below with the declarations in -d2.h, rather than this file.
#include "tests/cxx/redecls-d2.h"
void Uses() {
MyTypedef mt;
Fn();
(void)var;
}
/**** IWYU_SUMMARY
tests/cxx/redecls.h should add these lines:
tests/cxx/redecls.h should remove these lines:
- #include "tests/cxx/redecls-d1.h" // lines XX-XX
- #include "tests/cxx/redecls-d2.h" // lines XX-XX
The full include-list for tests/cxx/redecls.h:
***** IWYU_SUMMARY */
//===--- redecls.h - 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.
//
//===----------------------------------------------------------------------===//
#include "tests/cxx/redecls-d1.h"
// This looks suspiciously like redecls-d1.h and redecls-d2.h. But with
// uses, of course.
typedef int MyTypedef;
void Fn();
extern float var;
// Put this after our decls to encourage clang to associate the uses
// below with the declarations in -d2.h, rather than this file.
#include "tests/cxx/redecls-d2.h"
void Uses() {
MyTypedef mt;
Fn();
(void)var;
}
/**** IWYU_SUMMARY
tests/cxx/redecls.h should add these lines:
tests/cxx/redecls.h should remove these lines:
- #include "tests/cxx/redecls-d1.h" // lines XX-XX
- #include "tests/cxx/redecls-d2.h" // lines XX-XX
The full include-list for tests/cxx/redecls.h:
***** IWYU_SUMMARY */

View File

@ -1,41 +1,41 @@
//===--- 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.
//
//===----------------------------------------------------------------------===//
// 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 */
//===--- 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.
//
//===----------------------------------------------------------------------===//
// 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 */

View File

@ -1,24 +1,24 @@
//===--- self_include.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.
//
//===----------------------------------------------------------------------===//
// Tests that we don't crash when a file includes itself.
#ifndef SEEN
#define SEEN
#include "tests/cxx/self_include.cc"
#endif
/**** IWYU_SUMMARY
(tests/cxx/self_include.cc has correct #includes/fwd-decls)
***** IWYU_SUMMARY */
//===--- self_include.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.
//
//===----------------------------------------------------------------------===//
// Tests that we don't crash when a file includes itself.
#ifndef SEEN
#define SEEN
#include "tests/cxx/self_include.cc"
#endif
/**** IWYU_SUMMARY
(tests/cxx/self_include.cc has correct #includes/fwd-decls)
***** IWYU_SUMMARY */

View File

@ -1,106 +1,106 @@
//===--- sizeof_reference.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.
//
//===----------------------------------------------------------------------===//
// Tests that sizeof(reference) is treated the same as
// sizeof(underlying_object), like it's supposed to be.
#include <stddef.h>
#include "tests/cxx/direct.h"
template <typename T> struct IndirectTemplateStruct {
T value; // require full type information for t;
};
template <typename T> struct SizeofTakingStruct {
char value[sizeof(T)];
};
template <typename T> struct SizeofTakingStructRef {
char value[sizeof(T&)];
};
template <typename T> struct SizeofTakingStructTpl {
char value[sizeof(IndirectTemplateStruct<T>)];
};
template <typename T> struct SizeofTakingStructTplRef {
char value[sizeof(IndirectTemplateStruct<T&>)];
};
template <typename T> struct SizeofTakingStructTplRef2 {
char value5[sizeof(IndirectTemplateStruct<T>&)];
};
// IWYU: IndirectClass is...*indirect.h
// IWYU: IndirectClass needs a declaration
size_t s = sizeof(IndirectClass&);
// This needs the full type of IndirectTemplateStruct, but also
// IndirectClass, which is used in the IndirectTemplateStruct
// instantiation.
// IWYU: IndirectClass is...*indirect.h
// IWYU: IndirectClass needs a declaration
size_t s2 = sizeof(IndirectTemplateStruct<IndirectClass>&);
// This does not need the full type information for IndirectClass.
// IWYU: IndirectClass needs a declaration
size_t s3 = sizeof(IndirectTemplateStruct<IndirectClass&>);
// This needs the full type information of IndirectClass because the
// subclass takes the sizeof().
// IWYU: IndirectClass is...*indirect.h
// IWYU: IndirectClass needs a declaration
size_t s4 = sizeof(SizeofTakingStruct<IndirectClass&>);
// Also check when sizeof is on a variable, not a type.
// IWYU: IndirectClass is...*indirect.h
IndirectClass dummy;
// IWYU: IndirectClass needs a declaration
IndirectClass& ref = dummy;
// IWYU: IndirectClass is...*indirect.h
size_t s5 = sizeof(dummy);
// IWYU: IndirectClass is...*indirect.h
// IWYU: IndirectClass needs a declaration
SizeofTakingStruct<IndirectClass&> sizeof_taking_struct1;
// IWYU: IndirectClass is...*indirect.h
// IWYU: IndirectClass needs a declaration
SizeofTakingStructRef<IndirectClass> sizeof_taking_struct2;
// Not sure why, but C++ doesn't require full type of IndirectClass here.
// IWYU: IndirectClass needs a declaration
SizeofTakingStructTpl<IndirectClass&> sizeof_taking_struct3;
// Not sure why, but C++ doesn't require full type of IndirectClass here.
// IWYU: IndirectClass needs a declaration
SizeofTakingStructTplRef<IndirectClass> sizeof_taking_struct4;
// IWYU: IndirectClass is...*indirect.h
// IWYU: IndirectClass needs a declaration
SizeofTakingStructTplRef2<IndirectClass> sizeof_taking_struct5;
// Not sure why, but C++ doesn't require full type of IndirectClass here.
// IWYU: IndirectClass needs a declaration
SizeofTakingStructTplRef2<IndirectClass&> sizeof_taking_struct6;
/**** IWYU_SUMMARY
tests/cxx/sizeof_reference.cc should add these lines:
#include "tests/cxx/indirect.h"
tests/cxx/sizeof_reference.cc should remove these lines:
- #include "tests/cxx/direct.h" // lines XX-XX
The full include-list for tests/cxx/sizeof_reference.cc:
#include <stddef.h> // for size_t
#include "tests/cxx/indirect.h" // for IndirectClass
***** IWYU_SUMMARY */
//===--- sizeof_reference.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.
//
//===----------------------------------------------------------------------===//
// Tests that sizeof(reference) is treated the same as
// sizeof(underlying_object), like it's supposed to be.
#include <stddef.h>
#include "tests/cxx/direct.h"
template <typename T> struct IndirectTemplateStruct {
T value; // require full type information for t;
};
template <typename T> struct SizeofTakingStruct {
char value[sizeof(T)];
};
template <typename T> struct SizeofTakingStructRef {
char value[sizeof(T&)];
};
template <typename T> struct SizeofTakingStructTpl {
char value[sizeof(IndirectTemplateStruct<T>)];
};
template <typename T> struct SizeofTakingStructTplRef {
char value[sizeof(IndirectTemplateStruct<T&>)];
};
template <typename T> struct SizeofTakingStructTplRef2 {
char value5[sizeof(IndirectTemplateStruct<T>&)];
};
// IWYU: IndirectClass is...*indirect.h
// IWYU: IndirectClass needs a declaration
size_t s = sizeof(IndirectClass&);
// This needs the full type of IndirectTemplateStruct, but also
// IndirectClass, which is used in the IndirectTemplateStruct
// instantiation.
// IWYU: IndirectClass is...*indirect.h
// IWYU: IndirectClass needs a declaration
size_t s2 = sizeof(IndirectTemplateStruct<IndirectClass>&);
// This does not need the full type information for IndirectClass.
// IWYU: IndirectClass needs a declaration
size_t s3 = sizeof(IndirectTemplateStruct<IndirectClass&>);
// This needs the full type information of IndirectClass because the
// subclass takes the sizeof().
// IWYU: IndirectClass is...*indirect.h
// IWYU: IndirectClass needs a declaration
size_t s4 = sizeof(SizeofTakingStruct<IndirectClass&>);
// Also check when sizeof is on a variable, not a type.
// IWYU: IndirectClass is...*indirect.h
IndirectClass dummy;
// IWYU: IndirectClass needs a declaration
IndirectClass& ref = dummy;
// IWYU: IndirectClass is...*indirect.h
size_t s5 = sizeof(dummy);
// IWYU: IndirectClass is...*indirect.h
// IWYU: IndirectClass needs a declaration
SizeofTakingStruct<IndirectClass&> sizeof_taking_struct1;
// IWYU: IndirectClass is...*indirect.h
// IWYU: IndirectClass needs a declaration
SizeofTakingStructRef<IndirectClass> sizeof_taking_struct2;
// Not sure why, but C++ doesn't require full type of IndirectClass here.
// IWYU: IndirectClass needs a declaration
SizeofTakingStructTpl<IndirectClass&> sizeof_taking_struct3;
// Not sure why, but C++ doesn't require full type of IndirectClass here.
// IWYU: IndirectClass needs a declaration
SizeofTakingStructTplRef<IndirectClass> sizeof_taking_struct4;
// IWYU: IndirectClass is...*indirect.h
// IWYU: IndirectClass needs a declaration
SizeofTakingStructTplRef2<IndirectClass> sizeof_taking_struct5;
// Not sure why, but C++ doesn't require full type of IndirectClass here.
// IWYU: IndirectClass needs a declaration
SizeofTakingStructTplRef2<IndirectClass&> sizeof_taking_struct6;
/**** IWYU_SUMMARY
tests/cxx/sizeof_reference.cc should add these lines:
#include "tests/cxx/indirect.h"
tests/cxx/sizeof_reference.cc should remove these lines:
- #include "tests/cxx/direct.h" // lines XX-XX
The full include-list for tests/cxx/sizeof_reference.cc:
#include <stddef.h> // for size_t
#include "tests/cxx/indirect.h" // for IndirectClass
***** IWYU_SUMMARY */

View File

@ -1,12 +1,12 @@
//===--- specialization_needs_decl-d1.h - 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.
//
//===----------------------------------------------------------------------===//
template <typename T> struct TplStruct { };
template <> struct TplStruct<float> { };
//===--- specialization_needs_decl-d1.h - 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.
//
//===----------------------------------------------------------------------===//
template <typename T> struct TplStruct { };
template <> struct TplStruct<float> { };

View File

@ -1,33 +1,33 @@
//===--- specialization_needs_decl.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.
//
//===----------------------------------------------------------------------===//
// Tests that when we specialize a template class, we require a declaration
// of that class. However, forward-declaring a specialization doesn't
// require a definition.
#include "tests/cxx/specialization_needs_decl-d1.h"
template<> struct TplStruct<int> { };
// Forward-declaring a specialization is the same: we don't require
// the definition.
template<> struct TplStruct<float>;
/**** IWYU_SUMMARY
tests/cxx/specialization_needs_decl.cc should add these lines:
template <typename T> struct TplStruct;
tests/cxx/specialization_needs_decl.cc should remove these lines:
- #include "tests/cxx/specialization_needs_decl-d1.h" // lines XX-XX
The full include-list for tests/cxx/specialization_needs_decl.cc:
template <typename T> struct TplStruct;
***** IWYU_SUMMARY */
//===--- specialization_needs_decl.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.
//
//===----------------------------------------------------------------------===//
// Tests that when we specialize a template class, we require a declaration
// of that class. However, forward-declaring a specialization doesn't
// require a definition.
#include "tests/cxx/specialization_needs_decl-d1.h"
template<> struct TplStruct<int> { };
// Forward-declaring a specialization is the same: we don't require
// the definition.
template<> struct TplStruct<float>;
/**** IWYU_SUMMARY
tests/cxx/specialization_needs_decl.cc should add these lines:
template <typename T> struct TplStruct;
tests/cxx/specialization_needs_decl.cc should remove these lines:
- #include "tests/cxx/specialization_needs_decl-d1.h" // lines XX-XX
The full include-list for tests/cxx/specialization_needs_decl.cc:
template <typename T> struct TplStruct;
***** IWYU_SUMMARY */

View File

@ -1,14 +1,14 @@
//===--- system_namespaces-d1.h - 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.
//
//===----------------------------------------------------------------------===//
// We're not supposed to define anything in std, but we do anyway for this test.
namespace std {
class StdClass { };
}
//===--- system_namespaces-d1.h - 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.
//
//===----------------------------------------------------------------------===//
// We're not supposed to define anything in std, but we do anyway for this test.
namespace std {
class StdClass { };
}

View File

@ -1,14 +1,14 @@
//===--- system_namespaces-d2.h - 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.
//
//===----------------------------------------------------------------------===//
// We're not supposed to define anything in std, but we do anyway for this test.
namespace __gnu_cxx {
class SystemClass { };
}
//===--- system_namespaces-d2.h - 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.
//
//===----------------------------------------------------------------------===//
// We're not supposed to define anything in std, but we do anyway for this test.
namespace __gnu_cxx {
class SystemClass { };
}

View File

@ -1,14 +1,14 @@
//===--- system_namespaces-d3.h - 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.
//
//===----------------------------------------------------------------------===//
// We're not supposed to define anything in std, but we do anyway for this test.
namespace notsys_ns {
template <typename T> class TplClass { };
}
//===--- system_namespaces-d3.h - 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.
//
//===----------------------------------------------------------------------===//
// We're not supposed to define anything in std, but we do anyway for this test.
namespace notsys_ns {
template <typename T> class TplClass { };
}

View File

@ -1,42 +1,42 @@
//===--- system_namespaces.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.
//
//===----------------------------------------------------------------------===//
// Tests that we correctly replace forward declares with #includes for
// items in a system namespace: std or __gnu_cxx or the like.
#include "tests/cxx/system_namespaces-d1.h"
#include "tests/cxx/system_namespaces-d2.h"
#include "tests/cxx/system_namespaces-d3.h"
std::StdClass* foo = 0;
__gnu_cxx::SystemClass* bar = 0;
typedef int __system_type;
notsys_ns::TplClass<__system_type>* baz = 0;
// The summary is where all the action is on this test. Only TplClass
// should be replaceable by a forward-declare, because only it is
// exposing a symbol in a non-system namespace.
/**** IWYU_SUMMARY
tests/cxx/system_namespaces.cc should add these lines:
namespace notsys_ns { template <typename T> class TplClass; }
tests/cxx/system_namespaces.cc should remove these lines:
- #include "tests/cxx/system_namespaces-d3.h" // lines XX-XX
The full include-list for tests/cxx/system_namespaces.cc:
#include "tests/cxx/system_namespaces-d1.h" // for StdClass
#include "tests/cxx/system_namespaces-d2.h" // for SystemClass
namespace notsys_ns { template <typename T> class TplClass; }
***** IWYU_SUMMARY */
//===--- system_namespaces.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.
//
//===----------------------------------------------------------------------===//
// Tests that we correctly replace forward declares with #includes for
// items in a system namespace: std or __gnu_cxx or the like.
#include "tests/cxx/system_namespaces-d1.h"
#include "tests/cxx/system_namespaces-d2.h"
#include "tests/cxx/system_namespaces-d3.h"
std::StdClass* foo = 0;
__gnu_cxx::SystemClass* bar = 0;
typedef int __system_type;
notsys_ns::TplClass<__system_type>* baz = 0;
// The summary is where all the action is on this test. Only TplClass
// should be replaceable by a forward-declare, because only it is
// exposing a symbol in a non-system namespace.
/**** IWYU_SUMMARY
tests/cxx/system_namespaces.cc should add these lines:
namespace notsys_ns { template <typename T> class TplClass; }
tests/cxx/system_namespaces.cc should remove these lines:
- #include "tests/cxx/system_namespaces-d3.h" // lines XX-XX
The full include-list for tests/cxx/system_namespaces.cc:
#include "tests/cxx/system_namespaces-d1.h" // for StdClass
#include "tests/cxx/system_namespaces-d2.h" // for SystemClass
namespace notsys_ns { template <typename T> class TplClass; }
***** IWYU_SUMMARY */

View File

@ -1,163 +1,163 @@
//===--- template_args.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.
//
//===----------------------------------------------------------------------===//
// Tests unusual and complex use of template arguments, such as
// function-proto template arguments, for both classes and functions.
#include "tests/cxx/direct.h"
// ---------------------------------------------------------------
// IWYU: IndirectClass needs a declaration
char Foo(IndirectClass ic);
template <typename F> struct FunctionStruct;
template <typename R, typename A1> struct FunctionStruct<R(A1)> {
R result;
char Argument1[sizeof(A1)];
};
void FunctionProtoClassArguments() {
// IWYU: IndirectClass needs a declaration
// IWYU: IndirectClass is...*indirect.h
FunctionStruct<char(IndirectClass&)> f1;
(void)f1;
// IWYU: IndirectClass needs a declaration
// IWYU: IndirectClass is...*indirect.h
FunctionStruct<IndirectClass(char)> f2;
(void)f2;
}
// ---------------------------------------------------------------
template <typename T> struct PointerStruct { // T should be an IndirectClass*
static int a(T t) { return t->a; }
};
template <typename T> struct DoublePointerStruct {
static int a(T t) { return (*t)->a; }
};
template <typename T> struct PointerStruct2 {
static int a(T* t) { return t->a; }
};
template <typename T> struct DoublePointerStruct2 {
static int a(T** t) { return (*t)->a; }
};
void PointerClassArguments() {
// IWYU: IndirectClass needs a declaration
IndirectClass* ic = 0;
// IWYU: IndirectClass needs a declaration
// IWYU: IndirectClass is...*indirect.h
PointerStruct<IndirectClass*>::a(ic);
// IWYU: IndirectClass needs a declaration
// IWYU: IndirectClass is...*indirect.h
DoublePointerStruct<IndirectClass**>::a(&ic);
// IWYU: IndirectClass needs a declaration
// IWYU: IndirectClass is...*indirect.h
PointerStruct2<IndirectClass>::a(ic);
// IWYU: IndirectClass needs a declaration
// IWYU: IndirectClass is...*indirect.h
DoublePointerStruct2<IndirectClass>::a(&ic);
}
// ---------------------------------------------------------------
template<typename T> struct Outer { T t; };
template<typename T> struct Inner { T t; };
void NestedTemplateArguments() {
// IWYU: IndirectClass needs a declaration
// IWYU: IndirectClass is...*indirect.h
Outer<Inner<IndirectClass> > oi;
(void)oi;
// IWYU: IndirectClass needs a declaration
Outer<Inner<IndirectClass>* > oip;
(void)oip;
// IWYU: IndirectClass needs a declaration
Outer<Inner<IndirectClass> >* opi;
(void)opi;
}
// ---------------------------------------------------------------
template<typename T> struct CreateTemporary {
static T a() { return T(); }
template<typename U> static U b() { return U(); }
static T statica() { return T(); }
template<typename U> static U staticb() { return U(); }
};
void TestCreateTemporary() {
// IWYU: IndirectClass needs a declaration
CreateTemporary<IndirectClass> ct;
// IWYU: IndirectClass is...*indirect.h
ct.a();
// IWYU: IndirectClass is...*indirect.h
// IWYU: IndirectClass needs a declaration
ct.b<IndirectClass>();
// IWYU: IndirectClass is...*indirect.h
// IWYU: IndirectClass needs a declaration
CreateTemporary<IndirectClass>::statica();
// IWYU: IndirectClass is...*indirect.h
// IWYU: IndirectClass needs a declaration
CreateTemporary<int>::staticb<IndirectClass>();
}
// ---------------------------------------------------------------
// IWYU: IndirectClass is...*indirect.h
typedef IndirectClass LocalClass;
void TestResugaringOfTypedefs() {
FunctionStruct<char(LocalClass&)> f1;
(void)f1;
LocalClass* lc = 0;
PointerStruct<LocalClass*>::a(lc);
DoublePointerStruct<LocalClass**>::a(&lc);
PointerStruct2<LocalClass>::a(lc);
DoublePointerStruct2<LocalClass>::a(&lc);
Outer<Inner<LocalClass> > oi;
(void)oi;
CreateTemporary<LocalClass>::a();
CreateTemporary<int>::b<LocalClass>();
}
// ---------------------------------------------------------------
/**** IWYU_SUMMARY
tests/cxx/template_args.cc should add these lines:
#include "tests/cxx/indirect.h"
tests/cxx/template_args.cc should remove these lines:
- #include "tests/cxx/direct.h" // lines XX-XX
The full include-list for tests/cxx/template_args.cc:
#include "tests/cxx/indirect.h" // for IndirectClass
template <typename F> struct FunctionStruct; // lines XX-XX
***** IWYU_SUMMARY */
//===--- template_args.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.
//
//===----------------------------------------------------------------------===//
// Tests unusual and complex use of template arguments, such as
// function-proto template arguments, for both classes and functions.
#include "tests/cxx/direct.h"
// ---------------------------------------------------------------
// IWYU: IndirectClass needs a declaration
char Foo(IndirectClass ic);
template <typename F> struct FunctionStruct;
template <typename R, typename A1> struct FunctionStruct<R(A1)> {
R result;
char Argument1[sizeof(A1)];
};
void FunctionProtoClassArguments() {
// IWYU: IndirectClass needs a declaration
// IWYU: IndirectClass is...*indirect.h
FunctionStruct<char(IndirectClass&)> f1;
(void)f1;
// IWYU: IndirectClass needs a declaration
// IWYU: IndirectClass is...*indirect.h
FunctionStruct<IndirectClass(char)> f2;
(void)f2;
}
// ---------------------------------------------------------------
template <typename T> struct PointerStruct { // T should be an IndirectClass*
static int a(T t) { return t->a; }
};
template <typename T> struct DoublePointerStruct {
static int a(T t) { return (*t)->a; }
};
template <typename T> struct PointerStruct2 {
static int a(T* t) { return t->a; }
};
template <typename T> struct DoublePointerStruct2 {
static int a(T** t) { return (*t)->a; }
};
void PointerClassArguments() {
// IWYU: IndirectClass needs a declaration
IndirectClass* ic = 0;
// IWYU: IndirectClass needs a declaration
// IWYU: IndirectClass is...*indirect.h
PointerStruct<IndirectClass*>::a(ic);
// IWYU: IndirectClass needs a declaration
// IWYU: IndirectClass is...*indirect.h
DoublePointerStruct<IndirectClass**>::a(&ic);
// IWYU: IndirectClass needs a declaration
// IWYU: IndirectClass is...*indirect.h
PointerStruct2<IndirectClass>::a(ic);
// IWYU: IndirectClass needs a declaration
// IWYU: IndirectClass is...*indirect.h
DoublePointerStruct2<IndirectClass>::a(&ic);
}
// ---------------------------------------------------------------
template<typename T> struct Outer { T t; };
template<typename T> struct Inner { T t; };
void NestedTemplateArguments() {
// IWYU: IndirectClass needs a declaration
// IWYU: IndirectClass is...*indirect.h
Outer<Inner<IndirectClass> > oi;
(void)oi;
// IWYU: IndirectClass needs a declaration
Outer<Inner<IndirectClass>* > oip;
(void)oip;
// IWYU: IndirectClass needs a declaration
Outer<Inner<IndirectClass> >* opi;
(void)opi;
}
// ---------------------------------------------------------------
template<typename T> struct CreateTemporary {
static T a() { return T(); }
template<typename U> static U b() { return U(); }
static T statica() { return T(); }
template<typename U> static U staticb() { return U(); }
};
void TestCreateTemporary() {
// IWYU: IndirectClass needs a declaration
CreateTemporary<IndirectClass> ct;
// IWYU: IndirectClass is...*indirect.h
ct.a();
// IWYU: IndirectClass is...*indirect.h
// IWYU: IndirectClass needs a declaration
ct.b<IndirectClass>();
// IWYU: IndirectClass is...*indirect.h
// IWYU: IndirectClass needs a declaration
CreateTemporary<IndirectClass>::statica();
// IWYU: IndirectClass is...*indirect.h
// IWYU: IndirectClass needs a declaration
CreateTemporary<int>::staticb<IndirectClass>();
}
// ---------------------------------------------------------------
// IWYU: IndirectClass is...*indirect.h
typedef IndirectClass LocalClass;
void TestResugaringOfTypedefs() {
FunctionStruct<char(LocalClass&)> f1;
(void)f1;
LocalClass* lc = 0;
PointerStruct<LocalClass*>::a(lc);
DoublePointerStruct<LocalClass**>::a(&lc);
PointerStruct2<LocalClass>::a(lc);
DoublePointerStruct2<LocalClass>::a(&lc);
Outer<Inner<LocalClass> > oi;
(void)oi;
CreateTemporary<LocalClass>::a();
CreateTemporary<int>::b<LocalClass>();
}
// ---------------------------------------------------------------
/**** IWYU_SUMMARY
tests/cxx/template_args.cc should add these lines:
#include "tests/cxx/indirect.h"
tests/cxx/template_args.cc should remove these lines:
- #include "tests/cxx/direct.h" // lines XX-XX
The full include-list for tests/cxx/template_args.cc:
#include "tests/cxx/indirect.h" // for IndirectClass
template <typename F> struct FunctionStruct; // lines XX-XX
***** IWYU_SUMMARY */

View File

@ -1,11 +1,11 @@
//===--- template_specialization-d1.h - 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.
//
//===----------------------------------------------------------------------===//
#include "tests/cxx/template_specialization-i1.h"
#include "tests/cxx/template_specialization-i2.h"
//===--- template_specialization-d1.h - 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.
//
//===----------------------------------------------------------------------===//
#include "tests/cxx/template_specialization-i1.h"
#include "tests/cxx/template_specialization-i2.h"

View File

@ -1,10 +1,10 @@
//===--- template_specialization-i1.h - 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.
//
//===----------------------------------------------------------------------===//
template<class T> class Foo { };
//===--- template_specialization-i1.h - 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.
//
//===----------------------------------------------------------------------===//
template<class T> class Foo { };

View File

@ -1,10 +1,10 @@
//===--- template_specialization-i2.h - 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.
//
//===----------------------------------------------------------------------===//
template<> class Foo<int> { };
//===--- template_specialization-i2.h - 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.
//
//===----------------------------------------------------------------------===//
template<> class Foo<int> { };

View File

@ -1,55 +1,55 @@
//===--- template_specialization.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.
//
//===----------------------------------------------------------------------===//
// Tests that when we instantiate a specialized template, we attribute
// it to the right location.
#include "tests/cxx/template_specialization-d1.h"
template<typename T> class Foo;
// IWYU: Foo is...*template_specialization-i2.h
Foo<int> foo;
// Even though Foo<int> has a specialization, it doesn't matter
// because forward-declaring is ok.
Foo<int>* foo_ptr;
// Check we do the right thing when we're a template template arg, too.
// IWYU: Foo is...*template_specialization-i1.h
template <template<typename U> class T = Foo> struct TplTplStruct {
// TODO(csilvers): it's probably correct to say we need
// template_specialization-i1.h here, because if someone doesn't
// specify any tpl args when instantiating us, we'll create a
// Foo<int>, so as tpl authors we're responsible for the definition
// of Foo<int>. This is pretty unlikely to happen in practice.
T<int> u;
};
TplTplStruct<> tts;
// TODO(csilvers): This should find the -i2.h location (for Foo<int>),
// not -i1.h (for Foo<T>).
// IWYU: Foo is...*template_specialization-i1.h
TplTplStruct<Foo> tts2;
/**** IWYU_SUMMARY
tests/cxx/template_specialization.cc should add these lines:
#include "tests/cxx/template_specialization-i1.h"
#include "tests/cxx/template_specialization-i2.h"
tests/cxx/template_specialization.cc should remove these lines:
- #include "tests/cxx/template_specialization-d1.h" // lines XX-XX
- template <typename T> class Foo; // lines XX-XX
The full include-list for tests/cxx/template_specialization.cc:
#include "tests/cxx/template_specialization-i1.h" // for Foo
#include "tests/cxx/template_specialization-i2.h" // for Foo
***** IWYU_SUMMARY */
//===--- template_specialization.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.
//
//===----------------------------------------------------------------------===//
// Tests that when we instantiate a specialized template, we attribute
// it to the right location.
#include "tests/cxx/template_specialization-d1.h"
template<typename T> class Foo;
// IWYU: Foo is...*template_specialization-i2.h
Foo<int> foo;
// Even though Foo<int> has a specialization, it doesn't matter
// because forward-declaring is ok.
Foo<int>* foo_ptr;
// Check we do the right thing when we're a template template arg, too.
// IWYU: Foo is...*template_specialization-i1.h
template <template<typename U> class T = Foo> struct TplTplStruct {
// TODO(csilvers): it's probably correct to say we need
// template_specialization-i1.h here, because if someone doesn't
// specify any tpl args when instantiating us, we'll create a
// Foo<int>, so as tpl authors we're responsible for the definition
// of Foo<int>. This is pretty unlikely to happen in practice.
T<int> u;
};
TplTplStruct<> tts;
// TODO(csilvers): This should find the -i2.h location (for Foo<int>),
// not -i1.h (for Foo<T>).
// IWYU: Foo is...*template_specialization-i1.h
TplTplStruct<Foo> tts2;
/**** IWYU_SUMMARY
tests/cxx/template_specialization.cc should add these lines:
#include "tests/cxx/template_specialization-i1.h"
#include "tests/cxx/template_specialization-i2.h"
tests/cxx/template_specialization.cc should remove these lines:
- #include "tests/cxx/template_specialization-d1.h" // lines XX-XX
- template <typename T> class Foo; // lines XX-XX
The full include-list for tests/cxx/template_specialization.cc:
#include "tests/cxx/template_specialization-i1.h" // for Foo
#include "tests/cxx/template_specialization-i2.h" // for Foo
***** IWYU_SUMMARY */

View File

@ -1,44 +1,44 @@
//===--- templated_constructor.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.
//
//===----------------------------------------------------------------------===//
// Tests that we handle correctly the case of templated constructors.
#include "tests/cxx/direct.h"
struct TemplatedConstructor {
template<typename T> TemplatedConstructor(const T* obj, int dummy) {
a_ = obj->a;
}
int a_;
};
int main() {
// IWYU: IndirectClass needs a declaration
IndirectClass* ic = 0;
// IWYU: IndirectClass is...*indirect.h
TemplatedConstructor tc(ic, 1);
// IWYU: IndirectClass is...*indirect.h
TemplatedConstructor* tcp = new TemplatedConstructor(ic, 1);
}
/**** IWYU_SUMMARY
tests/cxx/templated_constructor.cc should add these lines:
#include "tests/cxx/indirect.h"
tests/cxx/templated_constructor.cc should remove these lines:
- #include "tests/cxx/direct.h" // lines XX-XX
The full include-list for tests/cxx/templated_constructor.cc:
#include "tests/cxx/indirect.h" // for IndirectClass
***** IWYU_SUMMARY */
//===--- templated_constructor.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.
//
//===----------------------------------------------------------------------===//
// Tests that we handle correctly the case of templated constructors.
#include "tests/cxx/direct.h"
struct TemplatedConstructor {
template<typename T> TemplatedConstructor(const T* obj, int dummy) {
a_ = obj->a;
}
int a_;
};
int main() {
// IWYU: IndirectClass needs a declaration
IndirectClass* ic = 0;
// IWYU: IndirectClass is...*indirect.h
TemplatedConstructor tc(ic, 1);
// IWYU: IndirectClass is...*indirect.h
TemplatedConstructor* tcp = new TemplatedConstructor(ic, 1);
}
/**** IWYU_SUMMARY
tests/cxx/templated_constructor.cc should add these lines:
#include "tests/cxx/indirect.h"
tests/cxx/templated_constructor.cc should remove these lines:
- #include "tests/cxx/direct.h" // lines XX-XX
The full include-list for tests/cxx/templated_constructor.cc:
#include "tests/cxx/indirect.h" // for IndirectClass
***** IWYU_SUMMARY */

View File

@ -1,12 +1,12 @@
//===--- typedefs_and_resugaring-d1.h - 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.
//
//===----------------------------------------------------------------------===//
class IndirectClass;
typedef IndirectClass MyTypedef;
//===--- typedefs_and_resugaring-d1.h - 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.
//
//===----------------------------------------------------------------------===//
class IndirectClass;
typedef IndirectClass MyTypedef;

View File

@ -1,57 +1,57 @@
//===--- typedefs_and_resugaring.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.
//
//===----------------------------------------------------------------------===//
// Tests that when we have a typedef where the author disclaims
// responsibility (so the user has to #include the underlying type),
// we don't run into problems in a template context where the
// underlying type gets resugared back to the original type.
//
// In other words, this protects against regressions involving the
// following bug we had in iwyu:
//
// ReportTypeUse was reporting on the use of a typedef type, then on
// the use of the underlying type (since it decided the typedef-user
// was responsible for the underlying type). The typedef type was a
// template parameter, though, so for the underlying type, iwyu was
// doing type-resugaring and getting back to the same original type
// that we were trying to recurse on! That is, TypedefType -> recurse
// on UnderlyingType -> resugared to TypedefType -> recurse on
// UnderlyingType -> infinite loop.
#include "tests/cxx/direct.h"
#include "tests/cxx/typedefs_and_resugaring-d1.h"
template <typename T> void TplFn() {
T t;
(void)t;
}
int main() {
// TplFn uses MyTypedef. We are also responsible for IndirectClass
// since the MyTypedef author decided not to be. This tests we
// don't get into an infinite loop where we go to mark the need for
// IndirectClass, but it gets resugared back to MyTypedef (which is
// the template arg).
// IWYU: IndirectClass is...*indirect.h
TplFn<MyTypedef>();
}
/**** IWYU_SUMMARY
tests/cxx/typedefs_and_resugaring.cc should add these lines:
#include "tests/cxx/indirect.h"
tests/cxx/typedefs_and_resugaring.cc should remove these lines:
- #include "tests/cxx/direct.h" // lines XX-XX
The full include-list for tests/cxx/typedefs_and_resugaring.cc:
#include "tests/cxx/indirect.h" // for IndirectClass
#include "tests/cxx/typedefs_and_resugaring-d1.h" // for MyTypedef
***** IWYU_SUMMARY */
//===--- typedefs_and_resugaring.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.
//
//===----------------------------------------------------------------------===//
// Tests that when we have a typedef where the author disclaims
// responsibility (so the user has to #include the underlying type),
// we don't run into problems in a template context where the
// underlying type gets resugared back to the original type.
//
// In other words, this protects against regressions involving the
// following bug we had in iwyu:
//
// ReportTypeUse was reporting on the use of a typedef type, then on
// the use of the underlying type (since it decided the typedef-user
// was responsible for the underlying type). The typedef type was a
// template parameter, though, so for the underlying type, iwyu was
// doing type-resugaring and getting back to the same original type
// that we were trying to recurse on! That is, TypedefType -> recurse
// on UnderlyingType -> resugared to TypedefType -> recurse on
// UnderlyingType -> infinite loop.
#include "tests/cxx/direct.h"
#include "tests/cxx/typedefs_and_resugaring-d1.h"
template <typename T> void TplFn() {
T t;
(void)t;
}
int main() {
// TplFn uses MyTypedef. We are also responsible for IndirectClass
// since the MyTypedef author decided not to be. This tests we
// don't get into an infinite loop where we go to mark the need for
// IndirectClass, but it gets resugared back to MyTypedef (which is
// the template arg).
// IWYU: IndirectClass is...*indirect.h
TplFn<MyTypedef>();
}
/**** IWYU_SUMMARY
tests/cxx/typedefs_and_resugaring.cc should add these lines:
#include "tests/cxx/indirect.h"
tests/cxx/typedefs_and_resugaring.cc should remove these lines:
- #include "tests/cxx/direct.h" // lines XX-XX
The full include-list for tests/cxx/typedefs_and_resugaring.cc:
#include "tests/cxx/indirect.h" // for IndirectClass
#include "tests/cxx/typedefs_and_resugaring-d1.h" // for MyTypedef
***** IWYU_SUMMARY */

View File

@ -1,15 +1,15 @@
//===--- uses_printf-d1.h - 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.
//
//===----------------------------------------------------------------------===//
#ifndef DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_USES_PRINTF_D1_H_
#define DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_USES_PRINTF_D1_H_
#include <cstdio>
#endif // DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_USES_PRINTF_D1_H_
//===--- uses_printf-d1.h - 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.
//
//===----------------------------------------------------------------------===//
#ifndef DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_USES_PRINTF_D1_H_
#define DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_USES_PRINTF_D1_H_
#include <cstdio>
#endif // DEVTOOLS_MAINTENANCE_INCLUDE_WHAT_YOU_USE_TESTS_USES_PRINTF_D1_H_

View File

@ -1,28 +1,28 @@
//===--- uses_printf.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.
//
//===----------------------------------------------------------------------===//
#include "tests/cxx/uses_printf-d1.h"
void hello() {
// IWYU: printf is...*<stdio.h>
printf("Hello, world!\n");
}
/**** IWYU_SUMMARY
tests/cxx/uses_printf.cc should add these lines:
#include <stdio.h>
tests/cxx/uses_printf.cc should remove these lines:
- #include "tests/cxx/uses_printf-d1.h" // lines XX-XX
The full include-list for tests/cxx/uses_printf.cc:
#include <stdio.h> // for printf
***** IWYU_SUMMARY */
//===--- uses_printf.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.
//
//===----------------------------------------------------------------------===//
#include "tests/cxx/uses_printf-d1.h"
void hello() {
// IWYU: printf is...*<stdio.h>
printf("Hello, world!\n");
}
/**** IWYU_SUMMARY
tests/cxx/uses_printf.cc should add these lines:
#include <stdio.h>
tests/cxx/uses_printf.cc should remove these lines:
- #include "tests/cxx/uses_printf-d1.h" // lines XX-XX
The full include-list for tests/cxx/uses_printf.cc:
#include <stdio.h> // for printf
***** IWYU_SUMMARY */

View File

@ -1,51 +1,51 @@
//===--- varargs_and_references.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.
//
//===----------------------------------------------------------------------===//
// When passing a class to a function that takes vararg arguments,
// compilers seem to require the full type information for the class
// (though the behavior is technically undefined). Test that IWYU
// notices this. (It only matters for references, of course.)
//
// TODO(csilvers): Clarify what the intended behavior here is; see discussion on
// OCL 23543695.
#include "tests/cxx/direct.h"
// Just to make things more complicated, put a default argument before
// the varargs.
int Function(int x, int y = 5, ...) { return 0; }
// To make things even *more* complicated, try a function pointer.
int (*function_p)(int, int, ...) = &Function;
int main() {
// IWYU: IndirectClass is...*indirect.h
IndirectClass ic;
// IWYU: IndirectClass needs a declaration
const IndirectClass& ref = ic;
// IWYU: IndirectClass is...*indirect.h
(void)sizeof(Function(1, 2, ref));
// IWYU: IndirectClass is...*indirect.h
(void)sizeof((*function_p)(1, 2, ref));
// IWYU: IndirectClass is...*indirect.h
(void)sizeof((*function_p)(1, 2, 3, 4, 5, ref));
}
/**** IWYU_SUMMARY
tests/cxx/varargs_and_references.cc should add these lines:
#include "tests/cxx/indirect.h"
tests/cxx/varargs_and_references.cc should remove these lines:
- #include "tests/cxx/direct.h" // lines XX-XX
The full include-list for tests/cxx/varargs_and_references.cc:
#include "tests/cxx/indirect.h" // for IndirectClass
***** IWYU_SUMMARY */
//===--- varargs_and_references.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.
//
//===----------------------------------------------------------------------===//
// When passing a class to a function that takes vararg arguments,
// compilers seem to require the full type information for the class
// (though the behavior is technically undefined). Test that IWYU
// notices this. (It only matters for references, of course.)
//
// TODO(csilvers): Clarify what the intended behavior here is; see discussion on
// OCL 23543695.
#include "tests/cxx/direct.h"
// Just to make things more complicated, put a default argument before
// the varargs.
int Function(int x, int y = 5, ...) { return 0; }
// To make things even *more* complicated, try a function pointer.
int (*function_p)(int, int, ...) = &Function;
int main() {
// IWYU: IndirectClass is...*indirect.h
IndirectClass ic;
// IWYU: IndirectClass needs a declaration
const IndirectClass& ref = ic;
// IWYU: IndirectClass is...*indirect.h
(void)sizeof(Function(1, 2, ref));
// IWYU: IndirectClass is...*indirect.h
(void)sizeof((*function_p)(1, 2, ref));
// IWYU: IndirectClass is...*indirect.h
(void)sizeof((*function_p)(1, 2, 3, 4, 5, ref));
}
/**** IWYU_SUMMARY
tests/cxx/varargs_and_references.cc should add these lines:
#include "tests/cxx/indirect.h"
tests/cxx/varargs_and_references.cc should remove these lines:
- #include "tests/cxx/direct.h" // lines XX-XX
The full include-list for tests/cxx/varargs_and_references.cc:
#include "tests/cxx/indirect.h" // for IndirectClass
***** IWYU_SUMMARY */

View File

@ -1,95 +1,95 @@
//===--- virtual_tpl_method.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.
//
//===----------------------------------------------------------------------===//
// Normally, C++ only instantiates methods on template classes when
// the methods are called. But for virtual methods, they're
// instantiated when the key method for the template class is
// instantiated. Since template classes rarely have key methods, that
// means they're instantiated when the class is instantiated. We test
// that iwyu correctly handles that situation.
#include "tests/cxx/direct.h"
// TODO(csilvers): can take this out when TODOs below are removed.
// It's in here only to make the IWYU_SUMMARY look like it should.
// IWYU: IndirectClass is...*indirect.h
IndirectClass unused;
template <typename T> struct Deleter {
Deleter(T* t) : t_(t) {}
virtual void Delete() { delete t_; }
static int NothingToDoWithDelete() { return 1; };
T* t_;
};
// Note we require the full type even though we don't call Delete.
// IWYU: IndirectClass is...*indirect.h
// IWYU: IndirectClass needs a declaration
Deleter<IndirectClass> d(0);
// IWYU: IndirectClass needs a declaration
Deleter<IndirectClass>* pd
// Another way to instantiate a template, also requirs the full type.
// IWYU: IndirectClass is...*indirect.h
// IWYU: IndirectClass needs a declaration
= new Deleter<IndirectClass>(0);
// This also instantiates the template, and thus requires the deleted-type.
// IWYU: IndirectClass is...*indirect.h
// IWYU: IndirectClass needs a declaration
int id = Deleter<IndirectClass>::NothingToDoWithDelete();
template <typename T> struct NonvirtualDeleter {
NonvirtualDeleter(T* t) : t_(t) {}
void Delete() { delete t_; }
static int NothingToDoWithDelete() { return 1; };
T* t_;
};
// None of these should require the full type.
// IWYU: IndirectClass needs a declaration
NonvirtualDeleter<IndirectClass> nd(0);
// IWYU: IndirectClass needs a declaration
NonvirtualDeleter<IndirectClass>* pnd
// IWYU: IndirectClass needs a declaration
= new NonvirtualDeleter<IndirectClass>(0);
// IWYU: IndirectClass needs a declaration
int ind = NonvirtualDeleter<IndirectClass>::NothingToDoWithDelete();
template <typename T> struct NonTplArgDeleter {
virtual void Delete() {
// IWYU: IndirectClass needs a declaration
IndirectClass* ic = 0;
// IWYU: IndirectClass is...*indirect.h
delete ic;
}
};
// These should not require the full type, for the normal reason that
// they're not a template arg.
NonTplArgDeleter<int> ntad;
/**** IWYU_SUMMARY
tests/cxx/virtual_tpl_method.cc should add these lines:
#include "tests/cxx/indirect.h"
tests/cxx/virtual_tpl_method.cc should remove these lines:
- #include "tests/cxx/direct.h" // lines XX-XX
The full include-list for tests/cxx/virtual_tpl_method.cc:
#include "tests/cxx/indirect.h" // for IndirectClass
***** IWYU_SUMMARY */
//===--- virtual_tpl_method.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.
//
//===----------------------------------------------------------------------===//
// Normally, C++ only instantiates methods on template classes when
// the methods are called. But for virtual methods, they're
// instantiated when the key method for the template class is
// instantiated. Since template classes rarely have key methods, that
// means they're instantiated when the class is instantiated. We test
// that iwyu correctly handles that situation.
#include "tests/cxx/direct.h"
// TODO(csilvers): can take this out when TODOs below are removed.
// It's in here only to make the IWYU_SUMMARY look like it should.
// IWYU: IndirectClass is...*indirect.h
IndirectClass unused;
template <typename T> struct Deleter {
Deleter(T* t) : t_(t) {}
virtual void Delete() { delete t_; }
static int NothingToDoWithDelete() { return 1; };
T* t_;
};
// Note we require the full type even though we don't call Delete.
// IWYU: IndirectClass is...*indirect.h
// IWYU: IndirectClass needs a declaration
Deleter<IndirectClass> d(0);
// IWYU: IndirectClass needs a declaration
Deleter<IndirectClass>* pd
// Another way to instantiate a template, also requirs the full type.
// IWYU: IndirectClass is...*indirect.h
// IWYU: IndirectClass needs a declaration
= new Deleter<IndirectClass>(0);
// This also instantiates the template, and thus requires the deleted-type.
// IWYU: IndirectClass is...*indirect.h
// IWYU: IndirectClass needs a declaration
int id = Deleter<IndirectClass>::NothingToDoWithDelete();
template <typename T> struct NonvirtualDeleter {
NonvirtualDeleter(T* t) : t_(t) {}
void Delete() { delete t_; }
static int NothingToDoWithDelete() { return 1; };
T* t_;
};
// None of these should require the full type.
// IWYU: IndirectClass needs a declaration
NonvirtualDeleter<IndirectClass> nd(0);
// IWYU: IndirectClass needs a declaration
NonvirtualDeleter<IndirectClass>* pnd
// IWYU: IndirectClass needs a declaration
= new NonvirtualDeleter<IndirectClass>(0);
// IWYU: IndirectClass needs a declaration
int ind = NonvirtualDeleter<IndirectClass>::NothingToDoWithDelete();
template <typename T> struct NonTplArgDeleter {
virtual void Delete() {
// IWYU: IndirectClass needs a declaration
IndirectClass* ic = 0;
// IWYU: IndirectClass is...*indirect.h
delete ic;
}
};
// These should not require the full type, for the normal reason that
// they're not a template arg.
NonTplArgDeleter<int> ntad;
/**** IWYU_SUMMARY
tests/cxx/virtual_tpl_method.cc should add these lines:
#include "tests/cxx/indirect.h"
tests/cxx/virtual_tpl_method.cc should remove these lines:
- #include "tests/cxx/direct.h" // lines XX-XX
The full include-list for tests/cxx/virtual_tpl_method.cc:
#include "tests/cxx/indirect.h" // for IndirectClass
***** IWYU_SUMMARY */