diff options
author | Kim Grasman <kim.grasman@gmail.com> | 2017-06-30 11:19:26 +0200 |
---|---|---|
committer | Kim Gräsman <kim.grasman@gmail.com> | 2017-07-15 19:46:51 +0200 |
commit | 6e28b990ba80d36bb03614b321df54add725c675 (patch) | |
tree | f69e250fbf3656fe21e9244034d3331a5af512f1 | |
parent | 4fc7f61b415ff40ba14f85c010d29842d6d0611a (diff) |
Add .H as a known header extensionclang_4.0-r2
Both in IWYU and fix_includes.py.
Fix issue #452.
-rwxr-xr-x | fix_includes.py | 2 | ||||
-rwxr-xr-x | fix_includes_test.py | 17 | ||||
-rw-r--r-- | iwyu_path_util.cc | 1 |
3 files changed, 19 insertions, 1 deletions
diff --git a/fix_includes.py b/fix_includes.py index ace85f1..6bfdf77 100755 --- a/fix_includes.py +++ b/fix_includes.py @@ -1437,7 +1437,7 @@ def _IsMainCUInclude(line_info, filename): return False # First, normalize the includee by getting rid of -inl.h and .h # suffixes (for the #include) and the "'s around the #include line. - canonical_include = re.sub(r'(-inl\.h|\.h)$', + canonical_include = re.sub(r'(-inl\.h|\.h|\.H)$', '', line_info.key.replace('"', '')) # Then normalize includer by stripping extension and Google's test suffixes. canonical_file, _ = os.path.splitext(filename) diff --git a/fix_includes_test.py b/fix_includes_test.py index 21581c9..70bdc8f 100755 --- a/fix_includes_test.py +++ b/fix_includes_test.py @@ -3187,6 +3187,23 @@ The full include-list for barrier_includes.h: self.actual_after_contents) self.assertEqual(1, num_files_modified) + def testSortingMainCUIncludeWithUpperCaseH(self): + """Check that we identify when first .H file is a main-cu #include.""" + infile = """\ +#include <stdio.h> +#include "foo.H" +""" + expected_output = """\ +#include "foo.H" +#include <stdio.h> +""" + self.RegisterFileContents({'foo.cc': infile}) + num_files_modified = fix_includes.SortIncludesInFiles( + ['foo.cc'], self.flags) + self.assertListEqual(expected_output.strip().split('\n'), + self.actual_after_contents) + self.assertEqual(1, num_files_modified) + def testSortingMainCUIncludeInSameDirectoryWithInl(self): """Check that we identify when first -inl.h file is a main-cu #include.""" infile = """\ diff --git a/iwyu_path_util.cc b/iwyu_path_util.cc index f28d658..cc8eed6 100644 --- a/iwyu_path_util.cc +++ b/iwyu_path_util.cc @@ -94,6 +94,7 @@ string GetCanonicalName(string file_path) { file_path = NormalizeFilePath(file_path); bool stripped_ext = StripRight(&file_path, ".h") + || StripRight(&file_path, ".H") || StripRight(&file_path, ".hpp") || StripRight(&file_path, ".hxx") || StripRight(&file_path, ".hh") |