[llvm] r333120 - [llvm-strip] Minor fix of the usage of TableGen
Alexander Shaposhnikov via llvm-commits
llvm-commits at lists.llvm.org
Wed May 23 13:39:52 PDT 2018
Author: alexshap
Date: Wed May 23 13:39:52 2018
New Revision: 333120
URL: http://llvm.org/viewvc/llvm-project?rev=333120&view=rev
Log:
[llvm-strip] Minor fix of the usage of TableGen
This is a small follow-up to the revisions r333117 and r331663.
1. Avoid the name conflicts of the generated variables for prefixes.
2. Apply clang-format -i -style=llvm to llvm-objcopy.cpp once again.
3. Add a test for the flag with double dash.
Test plan: make check-all
Modified:
llvm/trunk/test/tools/llvm-objcopy/strip-all-and-keep-symbol.test
llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp
Modified: llvm/trunk/test/tools/llvm-objcopy/strip-all-and-keep-symbol.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-objcopy/strip-all-and-keep-symbol.test?rev=333120&r1=333119&r2=333120&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-objcopy/strip-all-and-keep-symbol.test (original)
+++ llvm/trunk/test/tools/llvm-objcopy/strip-all-and-keep-symbol.test Wed May 23 13:39:52 2018
@@ -10,6 +10,10 @@
# RUN: llvm-strip -keep-symbol=foo %t1
# RUN: cmp %t1 %t2
+# RUN: cp %t %t3
+# RUN: llvm-strip --keep-symbol foo %t3
+# RUN: cmp %t1 %t3
+
!ELF
FileHeader:
Class: ELFCLASS64
Modified: llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp?rev=333120&r1=333119&r2=333120&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp (original)
+++ llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp Wed May 23 13:39:52 2018
@@ -55,17 +55,25 @@ enum ObjcopyID {
#undef OPTION
};
-#define PREFIX(NAME, VALUE) const char *const NAME[] = VALUE;
+#define PREFIX(NAME, VALUE) const char *const OBJCOPY_##NAME[] = VALUE;
#include "ObjcopyOpts.inc"
#undef PREFIX
static const opt::OptTable::Info ObjcopyInfoTable[] = {
#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
HELPTEXT, METAVAR, VALUES) \
- {PREFIX, NAME, HELPTEXT, \
- METAVAR, OBJCOPY_##ID, opt::Option::KIND##Class, \
- PARAM, FLAGS, OBJCOPY_##GROUP, \
- OBJCOPY_##ALIAS, ALIASARGS, VALUES},
+ {OBJCOPY_##PREFIX, \
+ NAME, \
+ HELPTEXT, \
+ METAVAR, \
+ OBJCOPY_##ID, \
+ opt::Option::KIND##Class, \
+ PARAM, \
+ FLAGS, \
+ OBJCOPY_##GROUP, \
+ OBJCOPY_##ALIAS, \
+ ALIASARGS, \
+ VALUES},
#include "ObjcopyOpts.inc"
#undef OPTION
};
@@ -84,13 +92,17 @@ enum StripID {
#undef OPTION
};
+#define PREFIX(NAME, VALUE) const char *const STRIP_##NAME[] = VALUE;
+#include "StripOpts.inc"
+#undef PREFIX
+
static const opt::OptTable::Info StripInfoTable[] = {
#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
HELPTEXT, METAVAR, VALUES) \
- {PREFIX, NAME, HELPTEXT, \
- METAVAR, STRIP_##ID, opt::Option::KIND##Class, \
- PARAM, FLAGS, STRIP_##GROUP, \
- STRIP_##ALIAS, ALIASARGS, VALUES},
+ {STRIP_##PREFIX, NAME, HELPTEXT, \
+ METAVAR, STRIP_##ID, opt::Option::KIND##Class, \
+ PARAM, FLAGS, STRIP_##GROUP, \
+ STRIP_##ALIAS, ALIASARGS, VALUES},
#include "StripOpts.inc"
#undef OPTION
};
@@ -222,8 +234,9 @@ void HandleArgs(const CopyConfig &Config
if (!Config.SplitDWO.empty()) {
SplitDWOToFile(Config, Reader, Config.SplitDWO, OutputElfType);
}
-
- // TODO: update or remove symbols only if there is an option that affects them.
+
+ // TODO: update or remove symbols only if there is an option that affects
+ // them.
if (Obj.SymbolTable) {
Obj.SymbolTable->updateSymbols([&](Symbol &Sym) {
if ((Config.LocalizeHidden &&
@@ -378,7 +391,7 @@ void HandleArgs(const CopyConfig &Config
// This has to be the last predicate assignment.
// If the option --keep-symbol has been specified
- // and at least one of those symbols is present
+ // and at least one of those symbols is present
// (equivalently, the updated symbol table is not empty)
// the symbol table and the string table should not be removed.
if (!Config.SymbolsToKeep.empty() && !Obj.SymbolTable->empty()) {
@@ -557,7 +570,7 @@ CopyConfig ParseStripOptions(ArrayRef<co
for (auto Arg : InputArgs.filtered(STRIP_remove_section))
Config.ToRemove.push_back(Arg->getValue());
-
+
for (auto Arg : InputArgs.filtered(STRIP_keep_symbol))
Config.SymbolsToKeep.push_back(Arg->getValue());
More information about the llvm-commits
mailing list