diff options
author | Kim Grasman <kim.grasman@gmail.com> | 2017-06-30 11:19:26 +0200 |
---|---|---|
committer | Kim Grasman <kim.grasman@gmail.com> | 2017-07-16 16:18:45 +0200 |
commit | c6c4520c0b0a0ad2ba22218ef2aa3f0b81ecbc6f (patch) | |
tree | 505cdce32aa150399a49c064cdcfab0519841285 | |
parent | b7669f4dea1da5190508da0764b604e9507d5032 (diff) |
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") |