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

Jan Svoboda via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 9 10:02:27 PDT 2023


Author: Jan Svoboda
Date: 2023-08-09T09:55:07-07:00
New Revision: acf57858c1acb4ff776a1d734b86e1c05303132a

URL: https://github.com/llvm/llvm-project/commit/acf57858c1acb4ff776a1d734b86e1c05303132a
DIFF: https://github.com/llvm/llvm-project/commit/acf57858c1acb4ff776a1d734b86e1c05303132a.diff

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

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.

Reviewed By: benlangmuir, MaskRay

Differential Revision: https://reviews.llvm.org/D157054

Added: 
    

Modified: 
    clang/lib/Frontend/CompilerInvocation.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index c4082db0090733..87190093767b05 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -615,7 +615,7 @@ static unsigned getOptimizationLevelSize(ArgList &Args) {
 static void GenerateArg(ArgumentConsumer Consumer,
                         llvm::opt::OptSpecifier OptSpecifier) {
   Option Opt = getDriverOptTable().getOption(OptSpecifier);
-  denormalizeSimpleFlag(Consumer, Opt.getPrefix() + Opt.getName(),
+  denormalizeSimpleFlag(Consumer, Opt.getPrefixedName(),
                         Option::OptionClass::FlagClass, 0);
 }
 
@@ -623,8 +623,7 @@ static void GenerateArg(ArgumentConsumer Consumer,
                         llvm::opt::OptSpecifier OptSpecifier,
                         const Twine &Value) {
   Option Opt = getDriverOptTable().getOption(OptSpecifier);
-  denormalizeString(Consumer, Opt.getPrefix() + Opt.getName(), Opt.getKind(), 0,
-                    Value);
+  denormalizeString(Consumer, Opt.getPrefixedName(), Opt.getKind(), 0, Value);
 }
 
 // Parse command line arguments into CompilerInvocation.


        


More information about the cfe-commits mailing list