aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Warta <[email protected]>2017-10-19 10:24:30 +0200
committerSimon Warta <[email protected]>2017-10-19 10:45:57 +0200
commit4a5b134633a94f11a83afa7feeded90392315790 (patch)
tree96d97b58e98928f96735ae015da75901ad2fdcef
parent5b3696864396ab24c2da47106721cf25721a4468 (diff)
Allow trailing comments for include matchers
-rwxr-xr-xconfigure.py7
-rwxr-xr-xsrc/scripts/python_unittests.py10
2 files changed, 14 insertions, 3 deletions
diff --git a/configure.py b/configure.py
index 902a77312..5bebd78d1 100755
--- a/configure.py
+++ b/configure.py
@@ -2440,12 +2440,13 @@ def portable_symlink(file_path, target_dir, method):
class AmalgamationHelper(object):
- _any_include = re.compile(r'#include <(.*)>$')
- _botan_include = re.compile(r'#include <botan/(.*)>$')
+ # All include types may have trailing comment like e.g. '#include <vector> // IWYU pragma: export'
+ _any_include = re.compile(r'#include <(.*)>')
+ _botan_include = re.compile(r'#include <botan/(.*)>')
# Only matches at the beginning of the line. By convention, this means that the include
# is not wrapped by condition macros
- _unconditional_std_include = re.compile(r'^#include <([^/\.]+|stddef.h)>$')
+ _unconditional_std_include = re.compile(r'^#include <([^/\.]+|stddef.h)>')
@staticmethod
def is_any_include(cpp_source_line):
diff --git a/src/scripts/python_unittests.py b/src/scripts/python_unittests.py
index 37fa25721..337f5369e 100755
--- a/src/scripts/python_unittests.py
+++ b/src/scripts/python_unittests.py
@@ -21,6 +21,7 @@ from configure import ModulesChooser # pylint: disable=wrong-import-position
class AmalgamationHelperTests(unittest.TestCase):
def test_matcher_std_includes(self):
self.assertEqual(AmalgamationHelper.is_unconditional_std_include("#include <string>"), "string")
+ self.assertEqual(AmalgamationHelper.is_unconditional_std_include("#include <string> // comment"), "string")
self.assertEqual(AmalgamationHelper.is_unconditional_std_include("#include <myfile.h>"), None)
self.assertEqual(AmalgamationHelper.is_unconditional_std_include("#include <unistd.h>"), None)
@@ -31,6 +32,10 @@ class AmalgamationHelperTests(unittest.TestCase):
"oids.h")
self.assertEqual(AmalgamationHelper.is_botan_include("#include <botan/internal/socket.h>"),
"internal/socket.h")
+ self.assertEqual(AmalgamationHelper.is_botan_include("#include <botan/oids.h> // comment"),
+ "oids.h")
+ self.assertEqual(AmalgamationHelper.is_botan_include("#include <botan/internal/socket.h> // comment"),
+ "internal/socket.h")
self.assertEqual(AmalgamationHelper.is_botan_include(" #include <botan/oids.h>"),
"oids.h")
self.assertEqual(AmalgamationHelper.is_botan_include(" #include <botan/internal/socket.h>"),
@@ -51,6 +56,11 @@ class AmalgamationHelperTests(unittest.TestCase):
self.assertEqual(AmalgamationHelper.is_any_include(" #include <unistd.h>"), "unistd.h")
self.assertEqual(AmalgamationHelper.is_any_include(" #include <botan/oids.h>"),
"botan/oids.h")
+ self.assertEqual(AmalgamationHelper.is_any_include("#include <string> // comment"), "string")
+ self.assertEqual(AmalgamationHelper.is_any_include("#include <myfile.h> // comment"), "myfile.h")
+ self.assertEqual(AmalgamationHelper.is_any_include("#include <unistd.h> // comment"), "unistd.h")
+ self.assertEqual(AmalgamationHelper.is_any_include("#include <botan/oids.h> // comment"),
+ "botan/oids.h")
class CompilerDetection(unittest.TestCase):