[PATCH] D157054: [clang] NFC: Use compile-time option spelling when generating command line

Jan Svoboda via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 3 16:06:30 PDT 2023


jansvoboda11 created this revision.
jansvoboda11 added a reviewer: benlangmuir.
Herald added a subscriber: ributzka.
Herald added a project: All.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When generating command lines, use the option spelling generated by TableGen (`StringLiteral`) instead of constructing it at runtime. This saves some needless allocations.

Depends on D157029 <https://reviews.llvm.org/D157029>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157054

Files:
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===================================================================
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -628,7 +628,7 @@
                         llvm::opt::OptSpecifier OptSpecifier,
                         CompilerInvocation::StringAllocator SA) {
   Option Opt = getDriverOptTable().getOption(OptSpecifier);
-  denormalizeSimpleFlag(Args, SA(Opt.getPrefix() + Opt.getName()), SA,
+  denormalizeSimpleFlag(Args, Opt.getSpelling(), SA,
                         Option::OptionClass::FlagClass, 0);
 }
 
@@ -637,8 +637,7 @@
                         const Twine &Value,
                         CompilerInvocation::StringAllocator SA) {
   Option Opt = getDriverOptTable().getOption(OptSpecifier);
-  denormalizeString(Args, SA(Opt.getPrefix() + Opt.getName()), SA,
-                    Opt.getKind(), 0, Value);
+  denormalizeString(Args, Opt.getSpelling(), SA, Opt.getKind(), 0, Value);
 }
 
 // Parse command line arguments into CompilerInvocation.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157054.547040.patch
Type: text/x-patch
Size: 1059 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230803/16d99471/attachment.bin>


More information about the cfe-commits mailing list