From 18505b352212a5e9eac07a8555ded232b5ece894 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Sj=C3=B6din?= Date: Tue, 18 Sep 2012 18:47:58 +0000 Subject: [PATCH] Add hidden flag to exclude aliases from output. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164158 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Other/llvm-nm-without-aliases.ll | 25 +++++++++++++++++++++++++ tools/llvm-nm/llvm-nm.cpp | 8 ++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 test/Other/llvm-nm-without-aliases.ll diff --git a/test/Other/llvm-nm-without-aliases.ll b/test/Other/llvm-nm-without-aliases.ll new file mode 100644 index 00000000000..9d9408c13b6 --- /dev/null +++ b/test/Other/llvm-nm-without-aliases.ll @@ -0,0 +1,25 @@ +; RUN: llvm-as < %s > %t +; RUN: llvm-nm -without-aliases < %t | FileCheck %s +; RUN: llvm-nm < %t | FileCheck --check-prefix=WITH %s + +; CHECK-NOT: T a0bar +; CHECK-NOT: T a0foo +; CHECK: T bar +; CHECK: T foo + +; WITH: T a0bar +; WITH: T a0foo +; WITH: T bar +; WITH: T foo + +@a0foo = alias void ()* @foo + +define void @foo() { + ret void +} + +@a0bar = alias void ()* @bar + +define void @bar() { + ret void +} diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp index eb52acc85db..0543e83f9cb 100644 --- a/tools/llvm-nm/llvm-nm.cpp +++ b/tools/llvm-nm/llvm-nm.cpp @@ -110,6 +110,9 @@ namespace { cl::opt SizeSort("size-sort", cl::desc("Sort symbols by size")); + cl::opt WithoutAliases("without-aliases", cl::Hidden, + cl::desc("Exclude aliases from output")); + bool PrintAddress = true; bool MultipleFiles = false; @@ -275,8 +278,9 @@ static void DumpSymbolNamesFromModule(Module *M) { std::for_each (M->begin(), M->end(), DumpSymbolNameForGlobalValue); std::for_each (M->global_begin(), M->global_end(), DumpSymbolNameForGlobalValue); - std::for_each (M->alias_begin(), M->alias_end(), - DumpSymbolNameForGlobalValue); + if (!WithoutAliases) + std::for_each (M->alias_begin(), M->alias_end(), + DumpSymbolNameForGlobalValue); SortAndPrintSymbolList(); } -- 2.34.1