Added workaround for supporting static_assert

This commit is contained in:
kevstone 2024-02-22 19:47:35 +00:00
parent d07769044f
commit 6b44bc21be
3 changed files with 17 additions and 1 deletions

View File

@ -14,6 +14,8 @@ class AstCodeCreator:
self._global_function_body = []
self._parse_args = [
#"-std=c11",
#"-v",
#"-fparse-all-comments",
#"-fdebug-macro",
#"-fmacro-backtrace-limit=0",
@ -104,6 +106,12 @@ class AstCodeCreator:
unsaved_files=None,
options=parse_options)
# Diagnostics:
for diag in self._translation_unit.diagnostics:
debug.line("DIAGNOSTICS", f"Severity: {diag.severity}")
debug.line("DIAGNOSTICS", f"Location: {diag.location}")
debug.line("DIAGNOSTICS", f"Message: {diag.spelling}")
self._ast_code = ast_code.AstCode(self._cfilename)
self.parse_root()

View File

@ -595,6 +595,13 @@ class AstParser:
return None
def parse_STATIC_ASSERT(self, node):
# static_assert isn't detected on some systems, so until this can be resolved we'll
# just return the tokens as a literal string...
assert False
debug.line("parse_STATIC_ASSERT", f"***WARNING*** Proper conversion not yet supported for static_assert - using the raw tokens...")
return literal.Literal(f"{' '.join(t.spelling for t in node.get_tokens())}")
parse_DECL_funcs = {
clang.cindex.CursorKind.FUNCTION_DECL: parse_FUNCTION_DECL,
clang.cindex.CursorKind.FUNCTION_TEMPLATE: parse_FUNCTION_TEMPLATE,
@ -606,6 +613,7 @@ class AstParser:
clang.cindex.CursorKind.TYPEDEF_DECL: parse_TYPEDEF_DECL,
clang.cindex.CursorKind.TYPE_ALIAS_DECL: parse_node_not_implemented,
clang.cindex.CursorKind.UNEXPOSED_DECL: parse_UNEXPOSED_DECL,
clang.cindex.CursorKind.STATIC_ASSERT: parse_STATIC_ASSERT,
}
def parse_DECL_node(self, node):

View File

@ -18,7 +18,7 @@ parser = argparse.ArgumentParser()
parser.add_argument("--type", default="")
parser.add_argument("--target", default="cpp/converted")
parser.add_argument("--debug", action="store_true")
parser.add_argument("--libclang", default="/usr/lib/llvm-16/lib/libclang.so")
parser.add_argument("--libclang", default="/usr/lib/llvm-17/lib/libclang.so")
parser.add_argument("path", nargs="+")
ARGS = parser.parse_args()