]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Ecc/c.py
BaseTools/ECC: Add a new type of exception
[mirror_edk2.git] / BaseTools / Source / Python / Ecc / c.py
index 7105cdf2a95110b0834d9a14a30fdbd0bb5e2970..0c377c6c4a9ba221745ee81a74661707ce04acb3 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # This file is used to be the c coding style checking of ECC tool\r
 #\r
-# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -1511,7 +1511,7 @@ def CheckFuncLayoutBody(FullFileName):
 \r
     FileTable = 'Identifier' + str(FileID)\r
     Db = GetDB()\r
-    SqlStatement = """ select BodyStartColumn, EndColumn, ID\r
+    SqlStatement = """ select BodyStartColumn, EndColumn, ID, Name\r
                        from Function\r
                        where BelongsToFile = %d\r
                    """ % (FileID)\r
@@ -1520,9 +1520,15 @@ def CheckFuncLayoutBody(FullFileName):
         return ErrorMsgList\r
     for Result in ResultSet:\r
         if Result[0] != 0:\r
-            PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_BODY, 'open brace should be at the very beginning of a line.', 'Function', Result[2])\r
+            if not EccGlobalData.gException.IsException(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_BODY, Result[3]):\r
+                PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_BODY,\r
+                              'The open brace should be at the very beginning of a line for the function [%s].' % Result[3],\r
+                              'Function', Result[2])\r
         if Result[1] != 0:\r
-            PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_BODY, 'close brace should be at the very beginning of a line.', 'Function', Result[2])\r
+            if not EccGlobalData.gException.IsException(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_BODY, Result[3]):\r
+                PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_FUNCTION_BODY,\r
+                              'The close brace should be at the very beginning of a line for the function [%s].' % Result[3],\r
+                              'Function', Result[2])\r
 \r
 def CheckFuncLayoutLocalVariable(FullFileName):\r
     ErrorMsgList = []\r
@@ -2144,7 +2150,7 @@ def CheckBooleanValueComparison(FullFileName):
                     PrintErrorMsg(ERROR_PREDICATE_EXPRESSION_CHECK_BOOLEAN_VALUE, 'Predicate Expression: %s' % Exp, FileTable, Str[2])\r
 \r
 \r
-def CheckHeaderFileData(FullFileName):\r
+def CheckHeaderFileData(FullFileName, AllTypedefFun=[]):\r
     ErrorMsgList = []\r
 \r
     FileID = GetTableID(FullFileName, ErrorMsgList)\r
@@ -2160,7 +2166,11 @@ def CheckHeaderFileData(FullFileName):
     ResultSet = Db.TblFile.Exec(SqlStatement)\r
     for Result in ResultSet:\r
         if not Result[1].startswith('extern'):\r
-            PrintErrorMsg(ERROR_INCLUDE_FILE_CHECK_DATA, 'Variable definition appears in header file', FileTable, Result[0])\r
+            for Item in AllTypedefFun:\r
+                if '(%s)' % Result[1] in Item:\r
+                    break\r
+            else:\r
+                PrintErrorMsg(ERROR_INCLUDE_FILE_CHECK_DATA, 'Variable definition appears in header file', FileTable, Result[0])\r
 \r
     SqlStatement = """ select ID\r
                        from Function\r