[clang] [llvm] Handle leading underscores in update_cc_test_checks.py (PR #121800)

Alexander Richardson via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 7 11:34:44 PST 2025


================
@@ -650,6 +655,16 @@ def get_triple_from_march(march):
     print("Cannot find a triple. Assume 'x86'", file=sys.stderr)
     return "x86"
 
+def get_global_underscores(raw_tool_output):
+    m = DATA_LAYOUT_RE.search(raw_tool_output)
+    if not m:
+        return False
+    data_layout = m.group("layout")
+    idx = data_layout.find("m:")
+    if idx < 0:
+        return False
+    ch = data_layout[idx + 2]
+    return ch == 'o' or ch == 'x'
----------------
arichardson wrote:

```suggestion
def get_globals_name_prefix(raw_tool_output):
    m = DATA_LAYOUT_RE.search(raw_tool_output)
    if not m:
        return ''
    data_layout = m.group("layout")
    idx = data_layout.find("m:")
    if idx < 0:
        return ''
    ch = data_layout[idx + 2]
    return '_' if ch == 'o' or ch == 'x' else ''
```

I think it would be better to return the globals prefix to make this a bit more flexible in case there are other mangling schemes we need to support in the future.

https://github.com/llvm/llvm-project/pull/121800


More information about the llvm-commits mailing list