summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2022-08-01 09:13:46 +0200
committerhjk <hjk@qt.io>2022-08-01 12:18:06 +0000
commit2361353289ff86383f6577dc772818dfedd1eb8f (patch)
treea2498ad7bb9e75fad06c29761a7e12a01a02e8f7
parent960e99ecb18e1d4d54057ef5c540fc1bd611e336 (diff)
downloadqt-creator-2361353289ff86383f6577dc772818dfedd1eb8f.tar.gz
CPlusPlus: Remove Rreprocessor::run overload for QStrings
The preprocessor operates on QByteArray, making it less convenient to use strings helps preventing accidental conversion roundtrips. Change-Id: Ifb2068a8fed137c52b05f2979b99cbce3462151e Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r--src/libs/cplusplus/pp-engine.cpp5
-rw-r--r--src/libs/cplusplus/pp-engine.h1
-rw-r--r--src/plugins/cppeditor/cppcodestylesettingspage.cpp2
-rw-r--r--src/plugins/cppeditor/cpppointerdeclarationformatter_test.cpp7
-rw-r--r--tests/auto/cplusplus/preprocessor/tst_preprocessor.cpp2
5 files changed, 5 insertions, 12 deletions
diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp
index 57f1cebd47..d57db67f9e 100644
--- a/src/libs/cplusplus/pp-engine.cpp
+++ b/src/libs/cplusplus/pp-engine.cpp
@@ -748,11 +748,6 @@ Preprocessor::Preprocessor(Client *client, Environment *env)
{
}
-QByteArray Preprocessor::run(const QString &fileName, const QString &source)
-{
- return run(fileName, source.toUtf8());
-}
-
QByteArray Preprocessor::run(const QString &fileName,
const QByteArray &source,
bool noLines,
diff --git a/src/libs/cplusplus/pp-engine.h b/src/libs/cplusplus/pp-engine.h
index 8902cb7624..55d9c9d035 100644
--- a/src/libs/cplusplus/pp-engine.h
+++ b/src/libs/cplusplus/pp-engine.h
@@ -79,7 +79,6 @@ public:
public:
Preprocessor(Client *client, Environment *env);
- QByteArray run(const QString &filename, const QString &source);
QByteArray run(const QString &filename, const QByteArray &source,
bool noLines = false, bool markGeneratedTokens = true);
diff --git a/src/plugins/cppeditor/cppcodestylesettingspage.cpp b/src/plugins/cppeditor/cppcodestylesettingspage.cpp
index 594102a946..d8737a76ec 100644
--- a/src/plugins/cppeditor/cppcodestylesettingspage.cpp
+++ b/src/plugins/cppeditor/cppcodestylesettingspage.cpp
@@ -63,7 +63,7 @@ static void applyRefactorings(QTextDocument *textDocument, TextEditorWidget *edi
Environment env;
Preprocessor preprocess(nullptr, &env);
const QByteArray preprocessedSource
- = preprocess.run(QLatin1String("<no-file>"), textDocument->toPlainText());
+ = preprocess.run(QLatin1String("<no-file>"), textDocument->toPlainText().toUtf8());
Document::Ptr cppDocument = Document::create(QLatin1String("<no-file>"));
cppDocument->setUtf8Source(preprocessedSource);
diff --git a/src/plugins/cppeditor/cpppointerdeclarationformatter_test.cpp b/src/plugins/cppeditor/cpppointerdeclarationformatter_test.cpp
index 6d330f3aa6..83d4ca3828 100644
--- a/src/plugins/cppeditor/cpppointerdeclarationformatter_test.cpp
+++ b/src/plugins/cppeditor/cpppointerdeclarationformatter_test.cpp
@@ -75,8 +75,8 @@ public:
// Find cursor position and remove cursor marker '@'
int cursorPosition = 0;
- QString sourceWithoutCursorMarker = QLatin1String(source);
- const int pos = sourceWithoutCursorMarker.indexOf(QLatin1Char('@'));
+ QByteArray sourceWithoutCursorMarker = source;
+ const int pos = sourceWithoutCursorMarker.indexOf('@');
if (pos != -1) {
sourceWithoutCursorMarker.remove(pos, 1);
cursorPosition = pos;
@@ -85,8 +85,7 @@ public:
// Write source to temprorary file
CppEditor::Tests::TemporaryDir temporaryDir;
QVERIFY(temporaryDir.isValid());
- const QString filePath = temporaryDir.createFile("file.h",
- sourceWithoutCursorMarker.toUtf8());
+ const QString filePath = temporaryDir.createFile("file.h", sourceWithoutCursorMarker);
QVERIFY(!filePath.isEmpty());
// Preprocess source
diff --git a/tests/auto/cplusplus/preprocessor/tst_preprocessor.cpp b/tests/auto/cplusplus/preprocessor/tst_preprocessor.cpp
index b2b8e428e4..a03855c401 100644
--- a/tests/auto/cplusplus/preprocessor/tst_preprocessor.cpp
+++ b/tests/auto/cplusplus/preprocessor/tst_preprocessor.cpp
@@ -1841,7 +1841,7 @@ void tst_Preprocessor::include_guard()
MockClient client(&env, &output);
Preprocessor preprocess(&client, &env);
preprocess.setKeepComments(true);
- /*QByteArray prep =*/ preprocess.run(QLatin1String("<test-case>"), input);
+ /*QByteArray prep =*/ preprocess.run(QLatin1String("<test-case>"), input.toUtf8());
QCOMPARE(QString::fromUtf8(client.includeGuard()), includeGuard);
}