summaryrefslogtreecommitdiff
path: root/clang/utils/C++Tests/LLVM-Code-Symbols/check-symbols
diff options
context:
space:
mode:
authorCarlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au>2012-10-15 17:10:06 +1100
committerCarlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au>2012-10-15 17:10:06 +1100
commitbe1de4be954c80875ad4108e0a33e8e131b2f2c0 (patch)
tree1fbbecf276bf7c7bdcbb4dd446099d6d90eaa516 /clang/utils/C++Tests/LLVM-Code-Symbols/check-symbols
parentc4626a62754862d20b41e8a46a3574264ea80e6d (diff)
parentf1bd2e48c5324d3f7cda4090c87f8a5b6f463ce2 (diff)
Merge branch 'master' of ssh://bitbucket.org/czan/honours
Diffstat (limited to 'clang/utils/C++Tests/LLVM-Code-Symbols/check-symbols')
-rwxr-xr-xclang/utils/C++Tests/LLVM-Code-Symbols/check-symbols54
1 files changed, 54 insertions, 0 deletions
diff --git a/clang/utils/C++Tests/LLVM-Code-Symbols/check-symbols b/clang/utils/C++Tests/LLVM-Code-Symbols/check-symbols
new file mode 100755
index 0000000..cd54eed
--- /dev/null
+++ b/clang/utils/C++Tests/LLVM-Code-Symbols/check-symbols
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+
+import subprocess
+import difflib
+
+def capture_2(args0, args1):
+ import subprocess
+ p0 = subprocess.Popen(args0, stdin=None, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ p1 = subprocess.Popen(args1, stdin=p0.stdout, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ out,_ = p1.communicate()
+ return out
+
+def normalize_nm(data):
+ lines = data.split('\n')
+ lines.sort()
+
+ # FIXME: Ignore common symbols for now.
+ lines = [ln for ln in lines
+ if not ln.startswith(' C')]
+
+ return lines
+
+def main():
+ import sys
+ clang = sys.argv[1]
+ flags = sys.argv[2:]
+
+ # FIXME: Relax to include undefined symbols.
+ nm_args = ["llvm-nm", "-extern-only", "-defined-only"]
+
+ llvmgcc_args = ["llvm-gcc"] + flags + ["-emit-llvm","-c","-o","-"]
+ clang_args = [clang] + flags + ["-emit-llvm","-c","-o","-"]
+
+ llvmgcc_nm = capture_2(llvmgcc_args, nm_args)
+ clang_nm = capture_2(clang_args, nm_args)
+
+ llvmgcc_nm = normalize_nm(llvmgcc_nm)
+ clang_nm = normalize_nm(clang_nm)
+
+ if llvmgcc_nm == clang_nm:
+ sys.exit(0)
+
+ print ' '.join(llvmgcc_args), '|', ' '.join(nm_args)
+ print ' '.join(clang_args), '|', ' '.join(nm_args)
+ for line in difflib.unified_diff(llvmgcc_nm, clang_nm,
+ fromfile="llvm-gcc symbols",
+ tofile="clang symbols"):
+ print line
+ sys.exit(1)
+
+if __name__ == '__main__':
+ main()