summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Grasman <kim.grasman@gmail.com>2017-05-02 17:09:42 +0200
committerKim Gräsman <kim.grasman@gmail.com>2017-05-17 19:48:32 +0200
commit669dd9334565675ca82d1fb54703eb2f325aa866 (patch)
treec848df8156e6d7fb3c08fbab66d47719092ced90
parent301f8ccc426c7ca1d2216d5bf6ffc3a284c49868 (diff)
Break out typedef-in-template tests from badinc
No functional change, but I discovered bug while doing this, so added a TODO.
-rwxr-xr-xrun_iwyu_tests.py1
-rw-r--r--tests/cxx/badinc.cc5
-rw-r--r--tests/cxx/badinc.h9
-rw-r--r--tests/cxx/typedef_in_template-d1.h15
-rw-r--r--tests/cxx/typedef_in_template-i1.h22
-rw-r--r--tests/cxx/typedef_in_template.cc51
6 files changed, 89 insertions, 14 deletions
diff --git a/run_iwyu_tests.py b/run_iwyu_tests.py
index e0ac89c..b0252ab 100755
--- a/run_iwyu_tests.py
+++ b/run_iwyu_tests.py
@@ -173,6 +173,7 @@ class OneIwyuTest(unittest.TestCase):
'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': ['.'],
diff --git a/tests/cxx/badinc.cc b/tests/cxx/badinc.cc
index fd68f92..23c5f0a 100644
--- a/tests/cxx/badinc.cc
+++ b/tests/cxx/badinc.cc
@@ -619,11 +619,6 @@ H_TemplateStruct<I1_TemplateClass<int> > h_template_struct_tplclass_arg;
// via a default template argument.
// IWYU: I2_TemplateClass::~I2_TemplateClass<.*> is...*badinc-i2-inl.h
H_TemplateTemplateClass<> h_templatetemplateclass;
-// These do not need the full type for I1_Class because they're tpl params.
-// IWYU: I1_Class needs a declaration
-H_TypedefStruct<I1_Class>::t_type h_typdef_struct_t;
-// IWYU: I1_Class needs a declaration
-H_TypedefStruct<I1_Class>::pair_type h_typdef_struct_pair;
// IWYU: I2_Class is...*badinc-i2.h
// IWYU: I2_Class needs a declaration
// IWYU: I2_TemplateFn is...*badinc-i2.h
diff --git a/tests/cxx/badinc.h b/tests/cxx/badinc.h
index c20dd33..4bf1461 100644
--- a/tests/cxx/badinc.h
+++ b/tests/cxx/badinc.h
@@ -274,13 +274,6 @@ template<class T, class Functor = OperateOn<T> > class H_TemplateStruct {
void a() { return ts.a(); }
};
-template<class T> struct H_TypedefStruct {
- // Should not be an iwyu violation for T
- typedef T t_type;
- // IWYU: std::pair is...*<utility>
- typedef std::pair<T, T> pair_type;
-};
-
// IWYU: I2_EnumForTypedefs is...*badinc-i2.h
typedef I2_EnumForTypedefs H_Typedef;
// IWYU: std::set is...*<set>
@@ -382,7 +375,6 @@ H_TemplateTemplateClass<H_TemplateClass> h_i2_templatetemlpate_class;
tests/cxx/badinc.h should add these lines:
#include <stdio.h>
#include <set>
-#include <utility>
#include <vector>
#include "tests/cxx/badinc-i2-inl.h"
#include "tests/cxx/badinc-i2.h"
@@ -400,7 +392,6 @@ The full include-list for tests/cxx/badinc.h:
#include <queue> // for queue
#include <set> // for set
#include <string> // for string
-#include <utility> // for pair
#include <vector> // for vector
#include "tests/cxx/badinc-d3.h" // for D3_Enum, D3_Enum::D31
#include "tests/cxx/badinc-i2-inl.h" // for I2_Class::I2_Class, I2_Class::InlFileFn, I2_Class::InlFileStaticFn, I2_Class::InlFileTemplateFn, I2_Class::~I2_Class, I2_TemplateClass::I2_TemplateClass<FOO>, I2_TemplateClass::InlFileTemplateClassFn, I2_TemplateClass::~I2_TemplateClass<FOO>
diff --git a/tests/cxx/typedef_in_template-d1.h b/tests/cxx/typedef_in_template-d1.h
new file mode 100644
index 0000000..5877b7f
--- /dev/null
+++ b/tests/cxx/typedef_in_template-d1.h
@@ -0,0 +1,15 @@
+//===--- typedef_in_template-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 INCLUDE_WHAT_YOU_USE_TESTS_CXX_TYPEDEF_IN_TEMPLATE_D1_H_
+#define INCLUDE_WHAT_YOU_USE_TESTS_CXX_TYPEDEF_IN_TEMPLATE_D1_H_
+
+#include "tests/cxx/typedef_in_template-i1.h"
+
+#endif // INCLUDE_WHAT_YOU_USE_TESTS_CXX_TYPEDEF_IN_TEMPLATE_D1_H_
diff --git a/tests/cxx/typedef_in_template-i1.h b/tests/cxx/typedef_in_template-i1.h
new file mode 100644
index 0000000..62dd2d2
--- /dev/null
+++ b/tests/cxx/typedef_in_template-i1.h
@@ -0,0 +1,22 @@
+//===--- typedef_in_template-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 INCLUDE_WHAT_YOU_USE_TESTS_CXX_TYPEDEF_IN_TEMPLATE_I1_H_
+#define INCLUDE_WHAT_YOU_USE_TESTS_CXX_TYPEDEF_IN_TEMPLATE_I1_H_
+
+class Class {};
+
+template<class T, class U>
+struct Pair {
+ T first;
+ U second;
+};
+
+#endif // INCLUDE_WHAT_YOU_USE_TESTS_CXX_TYPEDEF_IN_TEMPLATE_I1_H_
diff --git a/tests/cxx/typedef_in_template.cc b/tests/cxx/typedef_in_template.cc
new file mode 100644
index 0000000..5e5dacc
--- /dev/null
+++ b/tests/cxx/typedef_in_template.cc
@@ -0,0 +1,51 @@
+//===--- typedef_in_template.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/typedef_in_template-d1.h"
+
+template<class T>
+class Container {
+ public:
+ // Should not be an iwyu violation for T
+ typedef T value_type;
+
+ // IWYU: Pair is...*typedef_in_template-i1.h
+ typedef Pair<T,T> pair_type;
+};
+
+
+void Declarations() {
+ // These do not need the full type for Class because they're template params.
+
+ // TODO: This is almost certainly wrong, see bug #431
+ // We should not require the full definition of Class for passing it as a
+ // template argument, but we must require it when the typedef it's aliasing
+ // is full-used.
+ // The bug has instructions for how to provoke the error more obviously.
+
+ // IWYU: Class needs a declaration
+ Container<Class>::value_type vt;
+
+ // IWYU: Class needs a declaration
+ Container<Class>::pair_type pt;
+}
+
+
+/**** IWYU_SUMMARY
+
+tests/cxx/typedef_in_template.cc should add these lines:
+#include "tests/cxx/typedef_in_template-i1.h"
+
+tests/cxx/typedef_in_template.cc should remove these lines:
+- #include "tests/cxx/typedef_in_template-d1.h" // lines XX-XX
+
+The full include-list for tests/cxx/typedef_in_template.cc:
+#include "tests/cxx/typedef_in_template-i1.h" // for Class (ptr only), Pair
+
+***** IWYU_SUMMARY */