mirror of
git://code.qt.io/qt/qt5.git
synced 2026-02-02 03:36:54 +08:00
Task-number: QTQAINFRA-6720
Pick-to: 6.5
Change-Id: Idb303652355b8937ea199a3415101d49f27a2e98
Reviewed-by: Teemu Holappa <teemu.holappa@qt.io>
(cherry picked from commit cf921a5146)
Reviewed-by: Ville-Pekka Karhu <ville-pekka.karhu@qt.io>
35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
#Copyright (C) 2024 The Qt Company Ltd
|
|
#SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
|
|
|
import re
|
|
|
|
import axivion.config
|
|
from axivion.analysis.post_processing import FilterAction
|
|
from bauhaus import ir
|
|
|
|
analysis = axivion.config.get_analysis()
|
|
|
|
qt_inline_pattern = re.compile(r"QT_.*_INLINE(_IMPL)?_SINCE\(\d+,\d+\)")
|
|
def exclude_inlined_by_qt_inline_macro(sv, ir_graph):
|
|
node = ir_graph.get_node(ir.Physical, sv.primary_sloc.pir_node_number)
|
|
|
|
# we have to check on the token stream as the macro might expand to nothing
|
|
# -> only the invocation is in the IR, but not in the AST of the routine decl / def
|
|
preceeding_string = ""
|
|
|
|
token = node.Token
|
|
while True:
|
|
try:
|
|
token_value = re.sub('^#\\s+', '#', token.Value)
|
|
if token_value in {';', '{', '}', '#define'}:
|
|
break
|
|
preceeding_string = token.Value + preceeding_string
|
|
token = token.prev()
|
|
except StopIteration:
|
|
break
|
|
if re.match(qt_inline_pattern, preceeding_string):
|
|
return FilterAction.exclude
|
|
return FilterAction.normal
|
|
|
|
analysis['Qt-Generic-NoFunctionDefinitionInHeader'].post_processing.add_filter(exclude_inlined_by_qt_inline_macro, inputs=[ir.Graph])
|