MCPcopy Create free account
hub / github.com/FastLED/FastLED / _insert_fl_noexcept

Function _insert_fl_noexcept

ci/lint/clang_tidy/noexcept_platforms.py:150–224  ·  view source on GitHub ↗

Insert FL_NOEXCEPT into a function signature line. Returns modified line, or None if insertion is not possible.

(line: str)

Source from the content-addressed store, hash-verified

148
149
150def _insert_fl_noexcept(line: str) -> str | None:
151 """Insert FL_NOEXCEPT into a function signature line.
152
153 Returns modified line, or None if insertion is not possible.
154 """
155 if "FL_NOEXCEPT" in line or "noexcept" in line:
156 return None
157
158 code = line.rstrip()
159
160 # Skip trailing return types and initializer lists
161 if "->" in code:
162 return None
163 stripped = code.lstrip()
164 if stripped.startswith(":") or stripped.startswith(","):
165 return None
166
167 # Find the balanced closing paren
168 depth = 0
169 close_pos = -1
170 for i, ch in enumerate(code):
171 if ch == "(":
172 depth += 1
173 elif ch == ")":
174 depth -= 1
175 if depth == 0:
176 close_pos = i
177 break
178
179 if close_pos == -1:
180 return None
181
182 # Skip array subscripts after paren
183 after_paren = code[close_pos + 1 :].lstrip()
184 if after_paren.startswith("["):
185 return None
186
187 # Advance past ) and const/volatile qualifiers
188 pos = close_pos + 1
189 rest_raw = code[pos:]
190 rest = rest_raw.lstrip()
191 pos += len(rest_raw) - len(rest)
192
193 if rest.startswith("const") and (len(rest) == 5 or not rest[5].isalnum()):
194 pos += 5
195 rest = code[pos:].lstrip()
196 pos += len(code[pos:]) - len(rest)
197
198 if rest.startswith("volatile") and (len(rest) == 8 or not rest[8].isalnum()):
199 pos += 8
200 rest = code[pos:].lstrip()
201 pos += len(code[pos:]) - len(rest)
202
203 before = code[:pos].rstrip()
204 after = code[pos:].lstrip()
205
206 # Skip operator() and destructors
207 if re.search(r"\boperator\s*\(\s*\)\s*$", before):

Callers 1

_apply_fixesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected