diff options
-rw-r--r-- | CHANGES | 3 | ||||
-rw-r--r-- | sphinx/domains/c.py | 14 | ||||
-rw-r--r-- | sphinx/domains/cpp.py | 10 | ||||
-rw-r--r-- | sphinx/util/cfamily.py | 1 |
4 files changed, 27 insertions, 1 deletions
@@ -16,6 +16,9 @@ Features added Bugs fixed ---------- +* C, don't deepcopy the entire symbol table and make a mess every time an + enumerator is handled. + Testing -------- diff --git a/sphinx/domains/c.py b/sphinx/domains/c.py index 36a8f1f65..ce4d6336a 100644 --- a/sphinx/domains/c.py +++ b/sphinx/domains/c.py @@ -1330,6 +1330,10 @@ class ASTDeclaration(ASTBaseBase): # set by CObject._add_enumerator_to_parent self.enumeratorScopedSymbol = None # type: Symbol + def clone(self) -> "ASTDeclaration": + return ASTDeclaration(self.objectType, self.directiveType, + self.declaration.clone(), self.semicolon) + @property def name(self) -> ASTNestedName: return self.declaration.name @@ -1419,6 +1423,16 @@ class Symbol: debug_lookup = False debug_show_tree = False + def __copy__(self): + assert False # shouldn't happen + + def __deepcopy__(self, memo): + if self.parent: + assert False # shouldn't happen + else: + # the domain base class makes a copy of the initial data, which is fine + return Symbol(None, None, None, None) + @staticmethod def debug_print(*args: Any) -> None: print(Symbol.debug_indent_string * Symbol.debug_indent, end="") diff --git a/sphinx/domains/cpp.py b/sphinx/domains/cpp.py index 1783db491..d770946bf 100644 --- a/sphinx/domains/cpp.py +++ b/sphinx/domains/cpp.py @@ -3781,6 +3781,16 @@ class Symbol: debug_lookup = False # overridden by the corresponding config value debug_show_tree = False # overridden by the corresponding config value + def __copy__(self): + assert False # shouldn't happen + + def __deepcopy__(self, memo): + if self.parent: + assert False # shouldn't happen + else: + # the domain base class makes a copy of the initial data, which is fine + return Symbol(None, None, None, None, None, None) + @staticmethod def debug_print(*args: Any) -> None: print(Symbol.debug_indent_string * Symbol.debug_indent, end="") diff --git a/sphinx/util/cfamily.py b/sphinx/util/cfamily.py index edccf96a7..a1c4bad2d 100644 --- a/sphinx/util/cfamily.py +++ b/sphinx/util/cfamily.py @@ -110,7 +110,6 @@ class ASTBaseBase: __hash__ = None # type: Callable[[], int] def clone(self) -> Any: - """Clone a definition expression node.""" return deepcopy(self) def _stringify(self, transform: StringifyTransform) -> str: |