Daniel Carvalho has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/39016 )

Change subject: util: Add verifier for opening braces of classes
......................................................................

util: Add verifier for opening braces of classes

Make sure that opening braces of classes are not declared
in the same line of the class name.

This does not work for multi-line classes.

Change-Id: I232df1a9ebd974b9f4f66e1d96d03b12513bd49f
Signed-off-by: Daniel R. Carvalho <[email protected]>
---
M util/style/verifiers.py
1 file changed, 27 insertions(+), 0 deletions(-)



diff --git a/util/style/verifiers.py b/util/style/verifiers.py
index 7d27fda..ddfc0fb 100644
--- a/util/style/verifiers.py
+++ b/util/style/verifiers.py
@@ -460,6 +460,33 @@
                               "comparisons with false/False.\n")
         return line

+class ClassBraces(LineVerifier):
+    """ Check if the opening braces of classes are not on the same line of
+        the class name.
+
+        @todo Make this work for multi-line class declarations. e.g.,
+
+            class MultiLineClass
+              : public BaseClass {
+    """
+
+    languages = set(('C', 'C++'))
+    test_name = 'class opening brace position'
+    opt_name = 'classbrace'
+
+    regex = re.compile(r'\A(\s*)(class\s+[A-Z].*\S)\s*\{')
+
+    def check_line(self, line, **kwargs):
+        return self.regex.search(line) == None
+
+    def fix_line(self, line, **kwargs):
+        match = self.regex.search(line)
+        if match:
+            # Group 1 is indentation, group 2 is class declaration
+            line = match.group(1) + match.group(2) + "\n" + \
+                match.group(1) + "{"
+        return line
+
 def is_verifier(cls):
     """Determine if a class is a Verifier that can be instantiated"""


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/39016
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I232df1a9ebd974b9f4f66e1d96d03b12513bd49f
Gerrit-Change-Number: 39016
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Carvalho <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to