summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikolai Kosjar <nikolai.kosjar@theqtcompany.com>2015-11-16 16:47:46 +0100
committerNikolai Kosjar <nikolai.kosjar@theqtcompany.com>2015-11-23 14:22:15 +0000
commitc88d18c310637a138b9f01b54151b1d7c8e3eb16 (patch)
tree116fbf658f45c9c9f8673d05993dcc43b1f96a54
parent499589096a54181bfdbfad5bc2ba50dc945d0934 (diff)
downloadqt-creator-c88d18c310637a138b9f01b54151b1d7c8e3eb16.tar.gz
Clang: Print command line arguments quoted
Change-Id: I82d664f259040b0024d9e1d4df4235442bc6ac73 Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
-rw-r--r--src/tools/clangbackend/ipcsource/commandlinearguments.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/tools/clangbackend/ipcsource/commandlinearguments.cpp b/src/tools/clangbackend/ipcsource/commandlinearguments.cpp
index 41c80430be..5a0aa0e8e9 100644
--- a/src/tools/clangbackend/ipcsource/commandlinearguments.cpp
+++ b/src/tools/clangbackend/ipcsource/commandlinearguments.cpp
@@ -30,6 +30,8 @@
#include "commandlinearguments.h"
+#include <utf8string.h>
+
#include <iostream>
namespace ClangBackEnd {
@@ -67,13 +69,23 @@ const char *CommandLineArguments::at(int position) const
return m_arguments.at(uint(position));
}
+static Utf8String maybeQuoted(const char *argumentAsCString)
+{
+ const auto quotationMark = Utf8StringLiteral("\"");
+ const auto argument = Utf8String::fromUtf8(argumentAsCString);
+
+ if (argument.contains(quotationMark))
+ return argument;
+
+ return quotationMark + argument + quotationMark;
+}
+
void CommandLineArguments::print() const
{
using namespace std;
-
cerr << "Arguments to libclang:";
for (const auto &argument : m_arguments)
- cerr << ' ' << argument;
+ cerr << ' ' << maybeQuoted(argument).constData();
cerr << endl;
}