Migrate test launch arguments to IWYU_ARGS

This commit is contained in:
Alexey Storozhev 2020-11-29 19:56:35 +00:00 committed by Kim Gräsman
parent bc0ec65ec0
commit 810c5b2de7
100 changed files with 226 additions and 153 deletions

View File

@ -61,163 +61,10 @@ class OneIwyuTest(unittest.TestCase):
# iwyu flags to run properly, add an entry to the map with
# key=cc-filename (relative to self.rootdir), value=list of flags.
flags_map = {
'backwards_includes.cc': [self.CheckAlsoExtension('-d*.h')],
'badinc.cc': [self.MappingFile('badinc.imp')],
'builtins_with_mapping.cc': [self.MappingFile('builtins_with_mapping.imp')],
'check_also.cc': [self.CheckAlsoExtension('-d1.h')],
'implicit_ctor.cc': [self.CheckAlsoExtension('-d1.h')],
'iwyu_stricter_than_cpp.cc': [self.CheckAlsoExtension('-autocast.h'),
self.CheckAlsoExtension('-fnreturn.h'),
self.CheckAlsoExtension('-typedefs.h'),
self.CheckAlsoExtension('-d2.h')],
'keep_includes.c': ['--keep=tests/c/keep_includes*.h'],
'keep_mapping.cc': [self.CheckAlsoExtension('-public.h'),
self.MappingFile('keep_mapping.imp')],
'keep_moc.cc': [self.CheckAlsoExtension('-i1.h')],
'macro_location.cc': [self.CheckAlsoExtension('-d2.h')],
'mapping_to_self.cc': [self.MappingFile('mapping_to_self.imp')],
'non_transitive_include.cc': [self.CheckAlsoExtension('-d*.h'),
'--transitive_includes_only'],
'no_h_includes_cc.cc': [self.CheckAlsoExtension('.c')],
'no_comments.cc': ['--no_comments'],
'no_fwd_decls.cc': ['--no_fwd_decls'],
'overloaded_class.cc': [self.CheckAlsoExtension('-i1.h')],
'pch_in_code.cc': ['--pch_in_code', '--prefix_header_includes=remove'],
'prefix_header_attribution.cc': ['--prefix_header_includes=remove'],
'prefix_header_includes_add.cc': ['--prefix_header_includes=add'],
'prefix_header_includes_keep.cc': ['--prefix_header_includes=keep'],
'prefix_header_includes_remove.cc': ['--prefix_header_includes=remove'],
'prefix_header_operator_new.cc': ['--prefix_header_includes=remove'],
'quoted_includes_first.cc': ['--pch_in_code', '--quoted_includes_first'],
'relative_exported_mapped_include.cc':
[self.MappingFile('relative_exported_mapped_include.imp')],
'cxx17ns.cc': ['--cxx17ns'],
}
prefix_headers = [self.Include('prefix_header_includes-d1.h'),
self.Include('prefix_header_includes-d2.h'),
self.Include('prefix_header_includes-d3.h'),
self.Include('prefix_header_includes-d4.h')]
clang_flags_map = {
'alias_template.cc': ['-std=c++11'],
'auto_type_within_template.cc': ['-std=c++11'],
# MSVC targets need to explicitly enable exceptions, so we do it for all.
'catch.cc': ['-fcxx-exceptions', '-fexceptions'],
'clmode.cc': ['--driver-mode=cl', '/GF', '/Os', '/W2'],
'conversion_ctor.cc': ['-std=c++11'],
'deleted_implicit.cc' : ['-std=c++11'],
'funcptrs.cc': ['-Wno-unused'],
'lambda_fwd_decl.cc': ['-std=c++11'],
'lateparsed_template.cc': ['-fdelayed-template-parsing'],
'macro_defined_by_includer.cc': [
'-std=c++11', '-DCOMMAND_LINE_TYPE=double',
self.Include('macro_defined_by_includer-prefix.h')],
'macro_location.cc': ['-Wno-sizeof-pointer-div'],
'ms_inline_asm.cc': ['-fms-extensions'],
'operator_new.cc': ['-std=c++17'],
'placement_new.cc': ['-std=c++17'],
'prefix_header_attribution.cc': [self.Include('prefix_header_attribution-d1.h')],
'prefix_header_includes_add.cc': prefix_headers,
'prefix_header_includes_keep.cc': prefix_headers,
'prefix_header_includes_remove.cc': prefix_headers,
'range_for.cc': ['-std=c++11'],
'typedef_in_template.cc': ['-std=c++11'],
'inheriting_ctor.cc': ['-std=c++11'],
'cxx17ns.cc': ['-std=c++17'],
}
include_map = {
'alias_template.cc': ['.'],
'array.cc': ['.'],
'associated_h_file_heuristic.cc': ['.'],
'associated_include.cc': ['.'],
'associated_skipped.cc': ['.'],
'backwards_includes.cc': ['.'],
'badinc.cc': ['.'],
'badinc-extradef.cc': ['.'],
'binary_type_trait.cc': ['.'],
'builtins_with_mapping.cc': ['.'],
'funcptrs.cc': ['.'],
'casts.cc': ['.'],
'catch.cc': ['.'],
'check_also.cc': ['.'],
'clmode.cc': ['.'],
'comment_pragmas.cc': ['.'],
'computed_include.cc': ['.'],
'conversion_ctor.cc': ['.'],
'cvr.cc': ['.'],
'default_template_arg_other_file.cc': ['.'],
'depopulated_h_file.cc': ['.'],
'derived_function_tpl_args.cc': ['.'],
'dotdot.cc': ['.'],
'double_include.cc': ['.'],
'elaborated_struct.c': ['.'],
'elaborated_type.cc': ['.'],
'enum_base.cc': ['.'],
'export_nesting.cc': ['.'],
'external_including_internal.cc': ['.'],
'forward_declare_in_macro.cc': ['.'],
'fullinfo_for_templates.cc': ['.'],
'fwd_decl_class_template.cc': ['.'],
'fwd_decl_final.cc': ['.'],
'fwd_decl_static_member.cc': ['.'],
'fwd_decl_with_instantiation.cc': ['.'],
'header_in_subdir.cc': ['.'],
'implicit_ctor.cc': ['.'],
'include_cycle.cc': ['.'],
'include_with_using.cc': ['.'],
'inline_namespace.cc': ['.'],
'internal/internal_files.cc': ['.'],
'iwyu_stricter_than_cpp.cc': ['.'],
'keep_includes.c': ['.'],
'keep_mapping.cc': ['.'],
'keep_moc.cc': ['.'],
'lateparsed_template.cc': ['.'],
'macro_defined_by_includer.cc': ['.'],
'macro_location.cc': ['.'],
'mapping_to_self.cc': ['.'],
'member_expr.cc': ['.'],
'multiple_include_paths.cc': ['.'],
'new_header_path_provided.cc': ['.'],
'no_comments.cc': ['.'],
'no_fwd_decl_nested_class.cc': ['.'],
'no_fwd_decls.cc': ['.'],
'no_h_includes_cc.cc': ['.'],
'non_transitive_include.cc': ['.'],
'operator_new.cc': ['.'],
'overloaded_class.cc': ['.'],
'pch_in_code.cc': ['.'],
'pointer_arith.cc': ['.'],
'placement_new.cc': ['.'],
'pragma_associated.cc': ['.'],
'precomputed_tpl_args.cc': ['.'],
'prefix_header_attribution.cc': ['.'],
'prefix_header_includes_add.cc': ['.'],
'prefix_header_includes_keep.cc': ['.'],
'prefix_header_includes_remove.cc': ['.'],
'quoted_includes_first.cc' : ['.'],
'range_for.cc': ['.'],
're_fwd_decl.cc': ['.'],
'redecls.cc': ['.'],
'relative_exported_mapped_include.cc': ['tests/cxx/subdir'],
'remove_fwd_decl_when_including.cc': ['.'],
'self_include.cc': ['.'],
'sizeof_in_template_arg.cc': ['.'],
'sizeof_reference.cc': ['.'],
'specialization_needs_decl.cc': ['.'],
'system_namespaces.cc': ['.'],
'template_args.cc': ['.'],
'templated_constructor.cc': ['.'],
'template_specialization.cc': ['.'],
'typedef_chain_in_template.cc': ['.'],
'typedef_chain_no_follow.cc': ['.'],
'typedef_in_template.cc': ['.'],
'typedefs_and_resugaring.cc': ['.'],
'unused_class_template_ctor.cc': ['.'],
'uses_printf.cc': ['.'],
'using_aliased_symbol.cc': ['.'],
'using_aliased_symbol_unused.cc': ['.'],
'varargs_and_references.cc': ['.'],
'virtual_tpl_method.cc': ['.'],
'cxx17ns.cc': ['.'],
}
# Internally, we like it when the paths start with rootdir.
self._iwyu_flags_map = dict((posixpath.join(self.rootdir, k), v)

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
#include "tests/c/elaborated_struct-d1.h"
// C basically never requires an explicit forward declaration, all uses of

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -Xiwyu --keep=tests/c/keep_includes*.h -I .
// keep_includes-d1.h is an empty file.
// Normally it would be removed.
// In this test we are exercising the --keep command line option.

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -std=c++11 -I .
// Tests alias templates. Does not test type aliases.
#include "tests/cxx/direct.h"

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Tests that we handle correctly identify a[i] as a full use of a.
#include "tests/cxx/direct.h"

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Tests that we correctly say that a .h is an 'associated' .h file
// of a .cc file if it occurs first and shares a basename.

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Tests that if we remove an include from an 'associated' .h file, we
// add it to the .cc file, but if we keep an include in an
// 'associated' .h file, we don't try to add it to the .cc file.

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// This is a half-way test. It lays out an include graph that would cause an
// assertion failure in IWYU (issue #738):
//

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -std=c++11
// Tests that IWYU doesn't crash when auto type is within template and has no
// deduced type.

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -Xiwyu --check_also="tests/cxx/*-d*.h" -I .
// This tests a few situations where iwyu sometimes attributes uses
// incorrectly. We want to make sure we catch these errors in our
// sanity-checking phase and don't suggest ridiculous #includes as

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// This is to test defining some methods in another translation unit.
#include "tests/cxx/badinc-i2.h"

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -Xiwyu --mapping_file=tests/cxx/badinc.imp -I .
// This is a unittest for include-what-you-use.
//
// NOTE: Historically, all end-to-end testing was done in this file,

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
#include "tests/cxx/binary_type_trait-d1.h"
int main() {

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -Xiwyu --mapping_file=tests/cxx/builtins_with_mapping.imp -I .
#include "tests/cxx/builtins_with_mapping.h"
#include "tests/cxx/builtins_with_mapping-d1.h"

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Tests that we handle correctly handle the various types of cast.
#include "tests/cxx/casts-d1.h"

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -fcxx-exceptions -fexceptions -I .
#include "tests/cxx/catch-exceptions.h"
int main() {

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -Xiwyu --check_also="tests/cxx/*-d1.h" -I .
// Tests the '--check_also' flag.
#include "check_also-d1.h" // part of the --check-also glob

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: --driver-mode=cl /GF /Os /W2 -I .
// This test will be executed with --driver-mode=cl and some MSVC-shaped
// flags to ensure we can run IWYU with MSVC-compatible command-line switches.

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Tests the pragma-like comment-commands that iwyu recognizes,
// as described at the top of iwyu_preprocessor.h.
//

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Tests computed #includes, i.e. #includes with macros.
#include "tests/cxx/computed_include.h"

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -std=c++11 -I .
// The smallest repro case for issue #89:
// http://code.google.com/p/include-what-you-use/issues/detail?id=89

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
#include "tests/cxx/cvr-derived.h" // for Derived
#include "tests/cxx/cvr-class.h" // for Class

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -Xiwyu --cxx17ns -std=c++17 -I .
#include "tests/cxx/cxx17ns-i1.h"
struct Two {

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Tests the equivalent of doing
// hash_set<MyClass> foo;
// where hash<MyClass> is defined in some .h file. This should

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -std=c++11
// Tests that we don't crash when instantiating implicit methods, or rather,
// that we avoid instantiating implicit methods when they are to be considered
// deleted.

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// The directly-included file contains only an inclusion of the file
// defining Foo. IWYU should recommend that inclusion be moved to this file.
#include "tests/cxx/depopulated_h_file.h"

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Tests calls to a templated function, especially ones where the
// calls do not specify the template args explicitly, but instead
// have them derived from the function arguments (including return

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Tests that IWYU path canonicalization helps understand that
// "tests/cxx/subdir/../indirect.h" and "tests/cxx/indirect.h" are the same
// file.

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Tests that when we include a file twice (that doesn't have a header
// guard), we don't get confused and ask it to delete a copy of all
// *its* includes, thinking it specifies each include twice.

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Test that elaborated types are handled correctly.
//
// An elaborated type is either a type prefixed by type kind, e.g. 'class Foo',

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
#include "tests/cxx/enum_base-d1.h"
// IWYU: int_t is...*tests/cxx/enum_base-i1.h

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
#include "tests/cxx/export_nesting.h"
Nested_Enum x;

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Tests that when a non-internal file #includes an internal file,
// that we don't try to map the include back to ourself, and protects
// against a regression of a bug where we were both including a file

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Tests that when we forward-declare in a macro, that the line
// numbers that iwyu emits about where the forward-declare lives in
// the code, use the macro-instantiation location, never the

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Test that when a template is typedef'd that the location of the definition, not
// any forward declaration, is included.

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -Wno-unused -I .
// Tests that function pointers make the right claims for involved types.
// Function pointer expressions come in three flavors:
//

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Test that a class template is properly forward declared. i1.h has
// the following definition:
// template <typename T> class ClassTemplateI1 {};

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
#include "tests/cxx/fwd_decl_final.h"
void FwdDeclFinal::testFinalTemplate(FinalTemplate<int>* finalTemplate) {

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Test that static data members can be forward declared even if they are not
// pointers or references.

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Tests a situation where iwyu got confused between forward-declarations
// and definitions. It happened when the .cc file needed a definition of
// a templated type and the .h only needed a forward-declaration. The

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Test that subdirs are correctly recognized
#include "subdir/direct_subdir.h"

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -Xiwyu --check_also="tests/cxx/*-d1.h" -I .
// If you define an API that accepts an argument of class type or
// const reference to a class type with an implicit constructor, you
// must provide the definition for the class.

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Tests that we properly handle the case of include-cycles (header files
// including themselves, possibly indirectly). We put all the header files
// in the /internal/ directory, because those files get automatically mapped.

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Tests that if we use a symbol from a .h file that the .h file has
// a 'using' declaration for, we don't consider replacing the use with
// a forward-declaration. On the other hand, if we don't depend on

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -std=c++11
#include "inheriting_ctor-d1.h"
// IWYU: Derived is defined in .*-i1.h

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Tests that IWYU never considers a decl inside an inline namespace
// forward-declarable, and that diagnostics never mention the inline namespace
// name (xyz::v1).

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Tests our handling of header files in /internal/. In particular,
// if the only includers are outside the internal directory, make sure
// we don't map the internal include to <built-in>.

View File

@ -7,6 +7,12 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -Xiwyu --check_also="tests/cxx/*-autocast.h" \
// -Xiwyu --check_also="tests/cxx/*-fnreturn.h" \
// -Xiwyu --check_also="tests/cxx/*-typedefs.h" \
// -Xiwyu --check_also="tests/cxx/*-d2.h" \
// -I .
// There are a few scenarios where iwyu requires a full type but c++
// doesn't.
//

View File

@ -7,6 +7,10 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -Xiwyu --check_also="tests/cxx/*-public.h" \
// -Xiwyu --mapping_file=tests/cxx/keep_mapping.imp \
// -I .
// The real test here is in keep_mapping-public.h.
#include "tests/cxx/keep_mapping-public.h"

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -Xiwyu --check_also="tests/cxx/*-i1.h" -I .
// Tests that IWYU never suggests to remove an include of a Qt .moc file.
// These files are handled by a separate Qt preprocessor (called 'moc'), and
// can't be analyzed in the normal C or C++ sense, The moc preprocessor does

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -std=c++11
// This test ensures that we do not add forward-declarations for lambdas.
// The use of the lambda in add() registers as a use of the generated anonymous
// functor type. Since it's defined in the same file, IWYU thinks a forward-decl

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -fdelayed-template-parsing -I .
// Tests IWYU handling of function templates when used with the MSVC-compatible
// -fdelayed-template-parsing flag.
//

View File

@ -7,6 +7,9 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -std=c++11 -DCOMMAND_LINE_TYPE=double \
// -include tests/cxx/macro_defined_by_includer-prefix.h -I .
// Tests a few macro patterns:
// * internal headers guarded by macro defined in designated header;
// * x-macros.

View File

@ -7,6 +7,9 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -Xiwyu --check_also="tests/cxx/*-d2.h" -Wno-sizeof-pointer-div \
// -I .
// 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

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -Xiwyu --mapping_file=tests/cxx/mapping_to_self.imp -I .
#include "tests/cxx/mapping_to_self.h"
/**** IWYU_SUMMARY

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Tests that we correctly detect iwyu use with member accesses.
#include "tests/cxx/member_expr-d1.h"

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -fms-extensions
// 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.

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// 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

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Tests that if include search path is provided, new includes are added with
// corresponding relative path. Compare with new_header_path_local.cc.

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -Xiwyu --no_comments -I .
// Test that passing the --no_comments switch to IWYU suppresses both
// '// lines NN-NN' and '// for symbol' comments.

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// 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

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -Xiwyu --no_fwd_decls -I .
// Test that passing the --no_fwd_decls switch to IWYU suggests including the
// corresponding header file even when the use is not a full use.
//

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -Xiwyu --check_also="tests/cxx/*.c" -I .
// Tests that we never suggest that a .h file #include a .cc file,
// even in cases where one .cc file #includes another one.

View File

@ -7,6 +7,10 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -Xiwyu --check_also="tests/cxx/*-d*.h" \
// -Xiwyu --transitive_includes_only \
// -I .
// 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

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -std=c++17 -I .
// Test that iwyu suggests the include for <new> be removed if only
// built-in functions are used.

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -Xiwyu --check_also="tests/cxx/*-i1.h" -I .
// 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

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -Xiwyu --pch_in_code -Xiwyu --prefix_header_includes=remove -I .
// Test IWYU's handling of precompiled headers explicitly included in code.
// This is a pattern popularized by MSVC and allowed by GCC, where an include
// directive is used as a marker to signal that a precompiled header should be

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -std=c++17 -I .
// Test that use of placement-new requires include of <new> in all the usual
// scenarios.
//

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Pointer arithmetic requires the full type of the pointed-to type, because
// type size is material to the calculations.

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
#include "tests/cxx/pragma_associated-d1.h" // IWYU pragma: associated
#include "tests/cxx/pragma_associated-d2.h" // IWYU pragma: associated
#include "tests/cxx/pragma_associated.h" // This still counts as associated.

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Tests the precomputed template-arg-use list in iwyu_cache.cc.
#include <vector>

View File

@ -7,6 +7,9 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -Xiwyu --prefix_header_includes=remove \
// -include tests/cxx/prefix_header_attribution-d1.h -I .
// Tests that when IWYU attributes macros and placement operator new to
// providing headers, it preserves enough information to detect if providing
// header is prefix header.

View File

@ -7,6 +7,13 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -Xiwyu --prefix_header_includes=add \
// -include tests/cxx/prefix_header_includes-d1.h \
// -include tests/cxx/prefix_header_includes-d2.h \
// -include tests/cxx/prefix_header_includes-d3.h \
// -include tests/cxx/prefix_header_includes-d4.h \
// -I .
// Tests --prefix_header_includes option. All prefix_header_includes_*.cc files
// are the same to show the difference between --prefix_header_includes values.

View File

@ -7,6 +7,13 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -Xiwyu --prefix_header_includes=keep \
// -include tests/cxx/prefix_header_includes-d1.h \
// -include tests/cxx/prefix_header_includes-d2.h \
// -include tests/cxx/prefix_header_includes-d3.h \
// -include tests/cxx/prefix_header_includes-d4.h \
// -I .
// Tests --prefix_header_includes option. All prefix_header_includes_*.cc files
// are the same to show the difference between --prefix_header_includes values.

View File

@ -7,6 +7,13 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -Xiwyu --prefix_header_includes=remove \
// -include tests/cxx/prefix_header_includes-d1.h \
// -include tests/cxx/prefix_header_includes-d2.h \
// -include tests/cxx/prefix_header_includes-d3.h \
// -include tests/cxx/prefix_header_includes-d4.h \
// -I .
// Tests --prefix_header_includes option. All prefix_header_includes_*.cc files
// are the same to show the difference between --prefix_header_includes values.

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -Xiwyu --prefix_header_includes=remove
// Tests that IWYU can tell if made-up, not encountered header is prefix header.
// The main difference between the current test and prefix_header_attribution.cc
// is that in this test <new> is included neither from source nor from command

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -Xiwyu --pch_in_code -Xiwyu --quoted_includes_first -I .
// Tests that IWYU will respect the --quoted_includes_first option.
#include "tests/cxx/pch.h" // this is the precompiled header

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -std=c++11 -I .
// Verify correct handling of the C++11 range-for statement.
// The range-init expression always needs the complete type.
// The loop variable should behave like any variable use.

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// 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

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// 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

View File

@ -7,6 +7,10 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -Xiwyu \
// --mapping_file=tests/cxx/relative_exported_mapped_include.imp \
// -I tests/cxx/subdir
// Ensure that when an include is added which is the public mapping of a
// symbol, that header can be added as a relative include rather than using a
// full path.

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// This tests the following behavior: when we need to #include a
// file to get the full type of Foo (here, Foo == IndirectClass),
// but a forward-declare will also suffice for another use of Foo,

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Tests that we don't crash when a file includes itself.
#ifndef SEEN

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
#include "tests/cxx/direct.h"
// This verifies that using sizeof(...) means that the argument of sizeof

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Tests that sizeof(reference) is treated the same as
// sizeof(underlying_object), like it's supposed to be.

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// 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.

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Tests that we correctly replace forward declares with #includes for
// items in a system namespace: std or __gnu_cxx or the like.

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Tests unusual and complex use of template arguments, such as
// function-proto template arguments, for both classes and functions.

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Tests that when we instantiate a specialized template, we attribute
// it to the right location.

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Tests that we handle correctly the case of templated constructors.
#include "tests/cxx/direct.h"

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Tests that if template declares a typedef depending on template argument,
// IWYU follows the typedef chain and uses underlying type that is not a
// typedef depending on template argument. Usually such typedefs are template

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Tests cases when IWYU should not follow typedef chain and should not suggest
// to include a file for underlying typedef type.

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -std=c++11 -I .
#include "tests/cxx/direct.h"
#include "tests/cxx/typedef_in_template-d1.h"

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// 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

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Tests that IWYU doesn't instantiate unused class template constructor
// because for certain template arguments some constructors can trigger Clang
// errors.

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
#include "tests/cxx/uses_printf-d1.h"
void hello() {

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Tests that when we include a file that exports a symbol via a using decl
// that we are required to include both the file with the original symbol and
// the file with the using decl.

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// Tests that when we include a file that contains a using decl, that we are not
// forced to include that file if the decl is not used.

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// 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

View File

@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// IWYU_ARGS: -I .
// 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