llvm.org GIT mirror llvm / 8b0afcf
[CommandLine] Provide parser<unsigned long> instantiation to allow cl::opt<uint64_t> on LP64 platforms Summary: And migrate opt<unsigned long long> to opt<uint64_t> Fixes PR19665 Differential Revision: https://reviews.llvm.org/D60933 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359068 91177308-0d34-0410-b5e6-96231b3b80d8 Fangrui Song 5 months ago
13 changed file(s) with 104 addition(s) and 77 deletion(s). Raw diff Collapse all Expand all
972972 extern template class basic_parser;
973973
974974 //--------------------------------------------------
975 // parser
976 //
977 template <>
978 class parser final : public basic_parser {
979 public:
980 parser(Option &O) : basic_parser(O) {}
981
982 // parse - Return true on error.
983 bool parse(Option &O, StringRef ArgName, StringRef Arg, unsigned long &Val);
984
985 // getValueName - Overload in subclass to provide a better default value.
986 StringRef getValueName() const override { return "ulong"; }
987
988 void printOptionDiff(const Option &O, unsigned long V, OptVal Default,
989 size_t GlobalWidth) const;
990
991 // An out-of-line virtual method to provide a 'home' for this class.
992 void anchor() override;
993 };
994
995 extern template class basic_parser;
996
997 //--------------------------------------------------
975998 // parser
976999 //
9771000 template <>
9851008 unsigned long long &Val);
9861009
9871010 // getValueName - Overload in subclass to provide a better default value.
988 StringRef getValueName() const override { return "uint"; }
1011 StringRef getValueName() const override { return "ulong"; }
9891012
9901013 void printOptionDiff(const Option &O, unsigned long long V, OptVal Default,
9911014 size_t GlobalWidth) const;
5353 template class basic_parser;
5454 template class basic_parser;
5555 template class basic_parser;
56 template class basic_parser;
5657 template class basic_parser;
5758 template class basic_parser;
5859 template class basic_parser;
7778 void parser::anchor() {}
7879 void parser::anchor() {}
7980 void parser::anchor() {}
81 void parser::anchor() {}
8082 void parser::anchor() {}
8183 void parser::anchor() {}
8284 void parser::anchor() {}
16621664 return false;
16631665 }
16641666
1667 // parser implementation
1668 //
1669 bool parser::parse(Option &O, StringRef ArgName, StringRef Arg,
1670 unsigned long &Value) {
1671
1672 if (Arg.getAsInteger(0, Value))
1673 return O.error("'" + Arg + "' value invalid for ulong argument!");
1674 return false;
1675 }
1676
16651677 // parser implementation
16661678 //
16671679 bool parser::parse(Option &O, StringRef ArgName,
16691681 unsigned long long &Value) {
16701682
16711683 if (Arg.getAsInteger(0, Value))
1672 return O.error("'" + Arg + "' value invalid for uint argument!");
1684 return O.error("'" + Arg + "' value invalid for ullong argument!");
16731685 return false;
16741686 }
16751687
18501862 PRINT_OPT_DIFF(boolOrDefault)
18511863 PRINT_OPT_DIFF(int)
18521864 PRINT_OPT_DIFF(unsigned)
1865 PRINT_OPT_DIFF(unsigned long)
18531866 PRINT_OPT_DIFF(unsigned long long)
18541867 PRINT_OPT_DIFF(double)
18551868 PRINT_OPT_DIFF(float)
2525
2626 #define DEBUG_TYPE "rng"
2727
28 // Tracking BUG: 19665
29 // http://llvm.org/bugs/show_bug.cgi?id=19665
30 //
31 // Do not change to cl::opt since this silently breaks argument parsing.
32 static cl::opt
33 Seed("rng-seed", cl::value_desc("seed"), cl::Hidden,
34 cl::desc("Seed for the random number generator"), cl::init(0));
28 static cl::opt Seed("rng-seed", cl::value_desc("seed"), cl::Hidden,
29 cl::desc("Seed for the random number generator"),
30 cl::init(0));
3531
3632 RandomNumberGenerator::RandomNumberGenerator(StringRef Salt) {
3733 LLVM_DEBUG(if (Seed == 0) dbgs()
320320 cl::desc("scale of asan shadow mapping"),
321321 cl::Hidden, cl::init(0));
322322
323 static cl::opt ClMappingOffset(
324 "asan-mapping-offset",
325 cl::desc("offset of asan shadow mapping [EXPERIMENTAL]"), cl::Hidden,
326 cl::init(0));
323 static cl::opt
324 ClMappingOffset("asan-mapping-offset",
325 cl::desc("offset of asan shadow mapping [EXPERIMENTAL]"),
326 cl::Hidden, cl::init(0));
327327
328328 // Optimization flags. Not user visible, used mostly for testing
329329 // and benchmarking the tool.
123123 // is accessed. The shadow mapping looks like:
124124 // Shadow = (Mem >> scale) + offset
125125
126 static cl::opt ClMappingOffset(
127 "hwasan-mapping-offset",
128 cl::desc("HWASan shadow mapping offset [EXPERIMENTAL]"), cl::Hidden,
129 cl::init(0));
126 static cl::opt
127 ClMappingOffset("hwasan-mapping-offset",
128 cl::desc("HWASan shadow mapping offset [EXPERIMENTAL]"),
129 cl::Hidden, cl::init(0));
130130
131131 static cl::opt
132132 ClWithIfunc("hwasan-with-ifunc",
303303
304304 // These options allow to specify custom memory map parameters
305305 // See MemoryMapParams for details.
306 static cl::opt ClAndMask("msan-and-mask",
307 cl::desc("Define custom MSan AndMask"),
308 cl::Hidden, cl::init(0));
309
310 static cl::opt ClXorMask("msan-xor-mask",
311 cl::desc("Define custom MSan XorMask"),
312 cl::Hidden, cl::init(0));
313
314 static cl::opt ClShadowBase("msan-shadow-base",
315 cl::desc("Define custom MSan ShadowBase"),
316 cl::Hidden, cl::init(0));
317
318 static cl::opt ClOriginBase("msan-origin-base",
319 cl::desc("Define custom MSan OriginBase"),
320 cl::Hidden, cl::init(0));
306 static cl::opt ClAndMask("msan-and-mask",
307 cl::desc("Define custom MSan AndMask"),
308 cl::Hidden, cl::init(0));
309
310 static cl::opt ClXorMask("msan-xor-mask",
311 cl::desc("Define custom MSan XorMask"),
312 cl::Hidden, cl::init(0));
313
314 static cl::opt ClShadowBase("msan-shadow-base",
315 cl::desc("Define custom MSan ShadowBase"),
316 cl::Hidden, cl::init(0));
317
318 static cl::opt ClOriginBase("msan-origin-base",
319 cl::desc("Define custom MSan OriginBase"),
320 cl::Hidden, cl::init(0));
321321
322322 static const char *const kMsanModuleCtorName = "msan.module_ctor";
323323 static const char *const kMsanInitName = "__msan_init";
3737 namespace llvm {
3838 namespace cfi_verify {
3939
40 unsigned long long SearchLengthForUndef;
41 unsigned long long SearchLengthForConditionalBranch;
42
43 static cl::opt SearchLengthForUndefArg(
40 uint64_t SearchLengthForUndef;
41 uint64_t SearchLengthForConditionalBranch;
42
43 static cl::opt SearchLengthForUndefArg(
4444 "search-length-undef",
4545 cl::desc("Specify the maximum amount of instructions "
4646 "to inspect when searching for an undefined "
4747 "instruction from a conditional branch."),
4848 cl::location(SearchLengthForUndef), cl::init(2));
4949
50 static cl::optnsigned long long, true> SearchLengthForConditionalBranchArg(
50 static cl::optint64_t, true> SearchLengthForConditionalBranchArg(
5151 "search-length-cb",
5252 cl::desc("Specify the maximum amount of instructions "
5353 "to inspect when searching for a conditional "
4545 namespace llvm {
4646 namespace cfi_verify {
4747
48 extern unsigned long long SearchLengthForUndef;
49 extern unsigned long long SearchLengthForConditionalBranch;
48 extern uint64_t SearchLengthForUndef;
49 extern uint64_t SearchLengthForConditionalBranch;
5050
5151 struct ConditionalBranchNode {
5252 uint64_t Address;
153153 "the -regex option is interpreted as a regular expression."),
154154 value_desc("pattern"), cat(DwarfDumpCategory));
155155 static alias NameAlias("n", desc("Alias for -name"), aliasopt(Name));
156 static optnsigned long long> Lookup("lookup",
156 static optint64_t>
157 Lookup("lookup",
157158 desc("Lookup
in the debug information and print out any "
158159 "available file, function, block and line table details."),
159160 value_desc("address"), cat(DwarfDumpCategory));
156156 ThinLTOCachePruningInterval("thinlto-cache-pruning-interval",
157157 cl::init(1200), cl::desc("Set ThinLTO cache pruning interval."));
158158
159 static cl::opt
160 ThinLTOCacheMaxSizeBytes("thinlto-cache-max-size-bytes",
159 static cl::opt ThinLTOCacheMaxSizeBytes(
160 "thinlto-cache-max-size-bytes",
161161 cl::desc("Set ThinLTO cache pruning directory maximum size in bytes."));
162162
163163 static cl::opt
8686 extern cl::opt UniversalHeaders;
8787 extern cl::opt WeakBind;
8888
89 static cl::optnsigned long long> AdjustVMA(
89 static cl::optint64_t> AdjustVMA(
9090 "adjust-vma",
9191 cl::desc("Increase the displayed address by the specified offset"),
9292 cl::value_desc("offset"), cl::init(0));
270270 cl::NotHidden, cl::Grouping,
271271 cl::aliasopt(PrintSource));
272272
273 static cl::optnsigned long long>
273 static cl::optint64_t>
274274 StartAddress("start-address", cl::desc("Disassemble beginning at address"),
275275 cl::value_desc("address"), cl::init(0));
276 static cl::opt
277 StopAddress("stop-address", cl::desc("Stop disassembly at address"),
278 cl::value_desc("address"), cl::init(UINT64_MAX));
276 static cl::opt StopAddress("stop-address",
277 cl::desc("Stop disassembly at address"),
278 cl::value_desc("address"),
279 cl::init(UINT64_MAX));
279280
280281 cl::opt SymbolTable("syms", cl::desc("Display the symbol table"));
281282 static cl::alias SymbolTableShort("t", cl::desc("Alias for --syms"),
9090 cl::desc("File containing RuntimeDyld verifier checks."),
9191 cl::ZeroOrMore);
9292
93 // Tracking BUG: 19665
94 // http://llvm.org/bugs/show_bug.cgi?id=19665
95 //
96 // Do not change these options to cl::opt since this silently breaks
97 // argument parsing.
98 static cl::opt
99 PreallocMemory("preallocate",
100 cl::desc("Allocate memory upfront rather than on-demand"),
101 cl::init(0));
102
103 static cl::opt
104 TargetAddrStart("target-addr-start",
105 cl::desc("For -verify only: start of phony target address "
106 "range."),
107 cl::init(4096), // Start at "page 1" - no allocating at "null".
108 cl::Hidden);
109
110 static cl::opt
111 TargetAddrEnd("target-addr-end",
112 cl::desc("For -verify only: end of phony target address range."),
113 cl::init(~0ULL),
114 cl::Hidden);
115
116 static cl::opt
117 TargetSectionSep("target-section-sep",
118 cl::desc("For -verify only: Separation between sections in "
119 "phony target address space."),
120 cl::init(0),
121 cl::Hidden);
93 static cl::opt
94 PreallocMemory("preallocate",
95 cl::desc("Allocate memory upfront rather than on-demand"),
96 cl::init(0));
97
98 static cl::opt TargetAddrStart(
99 "target-addr-start",
100 cl::desc("For -verify only: start of phony target address "
101 "range."),
102 cl::init(4096), // Start at "page 1" - no allocating at "null".
103 cl::Hidden);
104
105 static cl::opt TargetAddrEnd(
106 "target-addr-end",
107 cl::desc("For -verify only: end of phony target address range."),
108 cl::init(~0ULL), cl::Hidden);
109
110 static cl::opt TargetSectionSep(
111 "target-section-sep",
112 cl::desc("For -verify only: Separation between sections in "
113 "phony target address space."),
114 cl::init(0), cl::Hidden);
122115
123116 static cl::list
124117 SpecificSectionMappings("map-section",
133133 cl::desc("Print verbose line info"));
134134
135135 // -adjust-vma
136 static cl::optnsigned long long>
136 static cl::optint64_t>
137137 ClAdjustVMA("adjust-vma", cl::init(0), cl::value_desc("offset"),
138138 cl::desc("Add specified offset to object file addresses"));
139139