From ff8d958c14112027f11bf7543d78157f9a90b0cf Mon Sep 17 00:00:00 2001 From: Deepak Yadav Date: Sun, 24 May 2020 14:41:32 +0530 Subject: [PATCH] Fix for include .hxx file #155 --- cpp/find_warnings.py | 3 +-- test/a.hxx | 8 ++++++++ test/b.hxx | 14 ++++++++++++++ test/expected.txt | 2 ++ 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 test/a.hxx create mode 100644 test/b.hxx diff --git a/cpp/find_warnings.py b/cpp/find_warnings.py index 35e05b9..b7e11b6 100644 --- a/cpp/find_warnings.py +++ b/cpp/find_warnings.py @@ -182,8 +182,7 @@ def _read_and_parse_includes(self): module = self._get_module(node) filename = module.filename _, ext = os.path.splitext(filename) - if ext.lower() != '.hxx': - included_files[filename] = node, module + included_files[filename] = node, module if is_cpp_file(filename): self._add_warning( "should not #include C++ source file '{}'".format( diff --git a/test/a.hxx b/test/a.hxx new file mode 100644 index 0000000..c048748 --- /dev/null +++ b/test/a.hxx @@ -0,0 +1,8 @@ +#ifndef _A_H_ +#define _A_H_ + +#include "b.hxx" + +void myFunc(int a); + +#endif diff --git a/test/b.hxx b/test/b.hxx new file mode 100644 index 0000000..c234721 --- /dev/null +++ b/test/b.hxx @@ -0,0 +1,14 @@ +#ifndef _B_H_ +#define _B_H_ + +namespace Name1 { +class ABC { +public: + ABC(): int1(0) {} + int getInt() { return int1; } +private: + int int1; +}; +} + +#endif diff --git a/test/expected.txt b/test/expected.txt index 525f5dd..03bc172 100644 --- a/test/expected.txt +++ b/test/expected.txt @@ -1,3 +1,4 @@ +test/a.hxx:4: 'b.hxx' does not need to be #included test/baz.h:1: 'bar.h' does not need to be #included; use a forward declaration instead test/baz.h:2: 'bar_bis.h' does not need to be #included; use a forward declaration instead test/cxx.cxx:1: 'cxx' not found in any directly #included header @@ -18,6 +19,7 @@ test/foo.h:87: 'string' already #included on line 3 test/foo.h:113: 'not-used.h' does not need to be #included test/foo.h:150: 'AR' not used test/foo.h:221: unable to find 'dir//bar.h' +test/foo.h:307: 'foo.hxx' does not need to be #included; use a forward declaration instead test/foo.h:234 'Colon' has virtual methods without a virtual dtor test/foo.h:20: static data 'd' test/foo.h:101: static data 'ptof'