Copybara import of the project:
-- 7f117fa7a7060b36687e7544e8d7393d14a1fa90 by Yuval Tassa <tassa@google.com>: Handle clang AST loc nodes with elided 'line' in introspect codegen. Apple's math.h (included directly by mujoco.h) contains an anonymous union whose clang-JSON 'loc' lacks the 'line' key (clang elides it when unchanged from the previous node), crashing AstProcessor._make_anonymous_key with a KeyError during bindings regeneration on macOS. glibc's math.h has no such union, so this never bites on Linux. Fall back to an offset-based key for line-less nodes; these system-header structs are never referenced by MuJoCo types, so the key only needs to be unique. COPYBARA_INTEGRATE_REVIEW=https://github.com/google-deepmind/mujoco/pull/3411 from yuvaltassa:introspect-loc-fallback 7f117fa7a7060b36687e7544e8d7393d14a1fa90 PiperOrigin-RevId: 949626713 Change-Id: I9d99b427885ede18b075db6d4e507aa8bc0d049a
This commit is contained in:
committed by
Copybara-Service
parent
56a93979e0
commit
135b482c9d
@@ -332,9 +332,13 @@ class AstProcessor:
|
||||
)
|
||||
|
||||
def _make_anonymous_key(self, node: ClangJsonNode) -> str:
|
||||
line = node['loc']['line']
|
||||
col = node['loc']['col']
|
||||
return f'{line}:{col}'
|
||||
loc = node['loc']
|
||||
if 'line' not in loc:
|
||||
# Clang elides 'line' when unchanged from the previous node. This only
|
||||
# occurs for system-header structs never referenced by MuJoCo types, so
|
||||
# the key merely needs to be unique.
|
||||
return f"offset{loc.get('offset')}:{loc.get('col')}"
|
||||
return f"{loc['line']}:{loc['col']}"
|
||||
|
||||
|
||||
def _traverse(node, visitor):
|
||||
|
||||
Reference in New Issue
Block a user