[PATCH] Assigning and copying command line option objects shouldn't be allowed.

Phabricator reviews at reviews.llvm.org
Wed Jan 21 17:51:41 PST 2015


REPOSITORY
  rL LLVM

http://reviews.llvm.org/D7114

Files:
  llvm/trunk/include/llvm/Support/CommandLine.h
  llvm/trunk/tools/lli/lli.cpp
  llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp
  llvm/trunk/tools/llvm-size/llvm-size.cpp

Index: llvm/trunk/tools/llvm-size/llvm-size.cpp
===================================================================
--- llvm/trunk/tools/llvm-size/llvm-size.cpp
+++ llvm/trunk/tools/llvm-size/llvm-size.cpp
@@ -709,7 +709,7 @@
 
   ToolName = argv[0];
   if (OutputFormatShort.getNumOccurrences())
-    OutputFormat = OutputFormatShort;
+    OutputFormat = static_cast<OutputFormatTy>(OutputFormatShort);
   if (RadixShort.getNumOccurrences())
     Radix = RadixShort;
 
Index: llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp
===================================================================
--- llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp
+++ llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp
@@ -38,7 +38,8 @@
 
 enum ProfileKinds { instr, sample };
 
-void mergeInstrProfile(cl::list<std::string> Inputs, StringRef OutputFilename) {
+void mergeInstrProfile(const cl::list<std::string> &Inputs,
+                       StringRef OutputFilename) {
   if (OutputFilename.compare("-") == 0)
     exitWithError("Cannot write indexed profdata format to stdout.");
 
@@ -64,7 +65,8 @@
   Writer.write(Output);
 }
 
-void mergeSampleProfile(cl::list<std::string> Inputs, StringRef OutputFilename,
+void mergeSampleProfile(const cl::list<std::string> &Inputs,
+                        StringRef OutputFilename,
                         sampleprof::SampleProfileFormat OutputFormat) {
   using namespace sampleprof;
   auto WriterOrErr = SampleProfileWriter::create(OutputFilename, OutputFormat);
Index: llvm/trunk/tools/lli/lli.cpp
===================================================================
--- llvm/trunk/tools/lli/lli.cpp
+++ llvm/trunk/tools/lli/lli.cpp
@@ -556,7 +556,7 @@
   // If the user specifically requested an argv[0] to pass into the program,
   // do it now.
   if (!FakeArgv0.empty()) {
-    InputFile = FakeArgv0;
+    InputFile = static_cast<std::string>(FakeArgv0);
   } else {
     // Otherwise, if there is a .bc suffix on the executable strip it off, it
     // might confuse the program.
Index: llvm/trunk/include/llvm/Support/CommandLine.h
===================================================================
--- llvm/trunk/include/llvm/Support/CommandLine.h
+++ llvm/trunk/include/llvm/Support/CommandLine.h
@@ -1180,6 +1180,10 @@
     return this->getValue();
   }
 
+  // Command line options should not be copyable
+  opt(const opt &) LLVM_DELETED_FUNCTION;
+  opt &operator=(const opt &) LLVM_DELETED_FUNCTION;
+
   // One option...
   template <class M0t>
   explicit opt(const M0t &M0)
@@ -1374,6 +1378,10 @@
 
   void setNumAdditionalVals(unsigned n) { Option::setNumAdditionalVals(n); }
 
+  // Command line options should not be copyable
+  list(const list &) LLVM_DELETED_FUNCTION;
+  list &operator=(const list &) LLVM_DELETED_FUNCTION;
+
   // One option...
   template <class M0t>
   explicit list(const M0t &M0)
@@ -1592,6 +1600,10 @@
     return Positions[optnum];
   }
 
+  // Command line options should not be copyable
+  bits(const bits &) LLVM_DELETED_FUNCTION;
+  bits &operator=(const bits &) LLVM_DELETED_FUNCTION;
+
   // One option...
   template <class M0t>
   explicit bits(const M0t &M0)
@@ -1725,6 +1737,10 @@
     AliasFor = &O;
   }
 
+  // Command line options should not be copyable
+  alias(const alias &) LLVM_DELETED_FUNCTION;
+  alias &operator=(const alias &) LLVM_DELETED_FUNCTION;
+
   // One option...
   template <class M0t>
   explicit alias(const M0t &M0)

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7114.18576.patch
Type: text/x-patch
Size: 3431 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150122/f02d7e6b/attachment.bin>


More information about the llvm-commits mailing list