[llvm] ea75c25 - [JITLInk][COFF] Remove unnecessary unique_ptr. (NFC)

Sunho Kim via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 30 16:08:54 PDT 2022


Author: Sunho Kim
Date: 2022-07-31T08:08:19+09:00
New Revision: ea75c25833c386bdafa5f13d8dc4a94c68e7e02e

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

LOG: [JITLInk][COFF] Remove unnecessary unique_ptr. (NFC)

Added: 
    

Modified: 
    llvm/lib/ExecutionEngine/JITLink/COFFDirectiveParser.cpp
    llvm/lib/ExecutionEngine/JITLink/COFFDirectiveParser.h
    llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ExecutionEngine/JITLink/COFFDirectiveParser.cpp b/llvm/lib/ExecutionEngine/JITLink/COFFDirectiveParser.cpp
index cc21279f7d0e..50d95dd9bfae 100644
--- a/llvm/lib/ExecutionEngine/JITLink/COFFDirectiveParser.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/COFFDirectiveParser.cpp
@@ -48,8 +48,7 @@ class COFFOptTable : public opt::OptTable {
 
 static COFFOptTable optTable;
 
-Expected<std::unique_ptr<opt::InputArgList>>
-COFFDirectiveParser::parse(StringRef Str) {
+Expected<opt::InputArgList> COFFDirectiveParser::parse(StringRef Str) {
   SmallVector<StringRef, 16> Tokens;
   SmallVector<const char *, 16> Buffer;
   cl::TokenizeWindowsCommandLineNoCopy(Str, saver, Tokens);
@@ -61,16 +60,15 @@ COFFDirectiveParser::parse(StringRef Str) {
   unsigned missingIndex;
   unsigned missingCount;
 
-  auto Result = std::make_unique<opt::InputArgList>(
-      optTable.ParseArgs(Buffer, missingIndex, missingCount));
+  auto Result = optTable.ParseArgs(Buffer, missingIndex, missingCount);
 
   if (missingCount)
     return make_error<JITLinkError>(Twine("COFF directive parsing failed: ") +
-                                    Result->getArgString(missingIndex) +
+                                    Result.getArgString(missingIndex) +
                                     " missing argument");
   LLVM_DEBUG({
-    for (auto *arg : Result->filtered(COFF_OPT_UNKNOWN))
-      dbgs() << "Unknown coff option argument: " << arg->getAsString(*Result)
+    for (auto *arg : Result.filtered(COFF_OPT_UNKNOWN))
+      dbgs() << "Unknown coff option argument: " << arg->getAsString(Result)
              << "\n";
   });
   return std::move(Result);

diff  --git a/llvm/lib/ExecutionEngine/JITLink/COFFDirectiveParser.h b/llvm/lib/ExecutionEngine/JITLink/COFFDirectiveParser.h
index bd3b6cf3e91f..3e4eedc63d6b 100644
--- a/llvm/lib/ExecutionEngine/JITLink/COFFDirectiveParser.h
+++ b/llvm/lib/ExecutionEngine/JITLink/COFFDirectiveParser.h
@@ -35,7 +35,7 @@ enum {
 /// https://docs.microsoft.com/en-us/cpp/preprocessor/comment-c-cpp?view=msvc-160
 class COFFDirectiveParser {
 public:
-  Expected<std::unique_ptr<opt::InputArgList>> parse(StringRef Str);
+  Expected<opt::InputArgList> parse(StringRef Str);
 
 private:
   llvm::BumpPtrAllocator bAlloc;

diff  --git a/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp b/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp
index 36b25c3ccc18..76d1b4305b84 100644
--- a/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp
@@ -286,7 +286,7 @@ Error COFFLinkGraphBuilder::handleDirectiveSection(StringRef Str) {
   auto Parsed = DirectiveParser.parse(Str);
   if (!Parsed)
     return Parsed.takeError();
-  for (auto *Arg : **Parsed) {
+  for (auto *Arg : *Parsed) {
     StringRef S = Arg->getValue();
     switch (Arg->getOption().getID()) {
     case COFF_OPT_alternatename: {


        


More information about the llvm-commits mailing list