[clang] 08ccea0 - [clang][cli] NFC: Use .str() instead of operator<<

Jan Svoboda via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 2 04:14:33 PST 2021


Author: Jan Svoboda
Date: 2021-03-02T13:14:00+01:00
New Revision: 08ccea019fda514ae36454f8d607b6c3cb08698e

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

LOG: [clang][cli] NFC: Use .str() instead of operator<<

Added: 
    

Modified: 
    clang/lib/Frontend/CompilerInvocation.cpp
    clang/lib/Frontend/TestModuleFileExtension.cpp
    clang/lib/Frontend/TestModuleFileExtension.h

Removed: 
    


################################################################################
diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 664b6783b1b3..b0654f9d706e 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2475,14 +2475,9 @@ static void GenerateFrontendArgs(const FrontendOptions &Opts,
     for (const auto &PluginArg : PluginArgs.second)
       GenerateArg(Args, OPT_plugin_arg, PluginArgs.first + PluginArg, SA);
 
-  for (const auto &Ext : Opts.ModuleFileExtensions) {
-    if (auto *TestExt = dyn_cast_or_null<TestModuleFileExtension>(Ext.get())) {
-      std::string Buffer;
-      llvm::raw_string_ostream OS(Buffer);
-      OS << *TestExt;
-      GenerateArg(Args, OPT_ftest_module_file_extension_EQ, OS.str(), SA);
-    }
-  }
+  for (const auto &Ext : Opts.ModuleFileExtensions)
+    if (auto *TestExt = dyn_cast_or_null<TestModuleFileExtension>(Ext.get()))
+      GenerateArg(Args, OPT_ftest_module_file_extension_EQ, TestExt->str(), SA);
 
   if (!Opts.CodeCompletionAt.FileName.empty())
     GenerateArg(Args, OPT_code_completion_at, Opts.CodeCompletionAt.ToString(),

diff  --git a/clang/lib/Frontend/TestModuleFileExtension.cpp b/clang/lib/Frontend/TestModuleFileExtension.cpp
index 04609691950d..ec147e16c569 100644
--- a/clang/lib/Frontend/TestModuleFileExtension.cpp
+++ b/clang/lib/Frontend/TestModuleFileExtension.cpp
@@ -128,11 +128,10 @@ TestModuleFileExtension::createExtensionReader(
                                                     new TestModuleFileExtension::Reader(this, Stream));
 }
 
-namespace clang {
-llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
-                              const TestModuleFileExtension &Extension) {
-  return OS << Extension.BlockName << ":" << Extension.MajorVersion << ":"
-            << Extension.MinorVersion << ":" << Extension.Hashed << ":"
-            << Extension.UserInfo;
+std::string TestModuleFileExtension::str() const {
+  std::string Buffer;
+  llvm::raw_string_ostream OS(Buffer);
+  OS << BlockName << ":" << MajorVersion << ":" << MinorVersion << ":" << Hashed
+     << ":" << UserInfo;
+  return OS.str();
 }
-} // namespace clang

diff  --git a/clang/lib/Frontend/TestModuleFileExtension.h b/clang/lib/Frontend/TestModuleFileExtension.h
index df4b718a1f68..ee7312502e24 100644
--- a/clang/lib/Frontend/TestModuleFileExtension.h
+++ b/clang/lib/Frontend/TestModuleFileExtension.h
@@ -70,9 +70,7 @@ class TestModuleFileExtension : public ModuleFileExtension {
     return E->getKind() == MFEK_Test;
   }
 
-  /// Serialize the extension.
-  friend llvm::raw_ostream &
-  operator<<(llvm::raw_ostream &OS, const TestModuleFileExtension &Extension);
+  std::string str() const;
 };
 
 } // end namespace clang


        


More information about the cfe-commits mailing list