aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
authorErik Verbruggen <[email protected]>2013-05-30 15:03:54 +0200
committerErik Verbruggen <[email protected]>2013-05-30 16:42:29 +0200
commitf2631ad031d936fb2a2e2ceeec39ff870bd9f6c8 (patch)
treedaddae32cf31cb640f1b69929f8dc24d120c646c /src/libs
parent271a96b19a17083d2cd7d2350aa83d3c11b462d3 (diff)
C++: do not strip trailing newlines in the preprocessor output.
Doing so resulted in an incorrect position for the EOF token when the preprocessed output would be parsed. That in turn leads to incorrect insertion positions for refactoring actions. This is especially true when a file contains only preprocessor directives: the EOF token would point to line 1 column 1, which is usually not the place where code should be inserted. Change-Id: I7d359aa7a6c04bc52c8b873fd49ad6afc3a77319 Reviewed-by: hjk <[email protected]>
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/cplusplus/pp-engine.cpp15
-rw-r--r--src/libs/cplusplus/pp-engine.h1
2 files changed, 0 insertions, 16 deletions
diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp
index 91aa73efb9b..77ff055b1bc 100644
--- a/src/libs/cplusplus/pp-engine.cpp
+++ b/src/libs/cplusplus/pp-engine.cpp
@@ -1332,19 +1332,6 @@ void Preprocessor::synchronizeOutputLines(const PPToken &tk, bool forceLine)
adjustForCommentOrStringNewlines(&m_env->currentLine, tk);
}
-void Preprocessor::removeTrailingOutputLines()
-{
- QByteArray &buffer = currentOutputBuffer();
- int i = buffer.size() - 1;
- while (i >= 0 && buffer.at(i) == '\n')
- --i;
- const int mightChop = buffer.size() - i - 1;
- if (mightChop > 1) {
- // Keep one new line at end.
- buffer.chop(mightChop - 1);
- }
-}
-
std::size_t Preprocessor::computeDistance(const Preprocessor::PPToken &tk, bool forceTillLine)
{
// Find previous non-space character or line begin.
@@ -1450,8 +1437,6 @@ void Preprocessor::preprocess(const QString &fileName, const QByteArray &source,
} while (tk.isNot(T_EOF_SYMBOL));
- removeTrailingOutputLines();
-
if (includeGuardMacroName) {
if (m_state.m_includeGuardState == State::IncludeGuardState_AfterDefine
|| m_state.m_includeGuardState == State::IncludeGuardState_AfterEndif)
diff --git a/src/libs/cplusplus/pp-engine.h b/src/libs/cplusplus/pp-engine.h
index f118a00da40..2614c107b15 100644
--- a/src/libs/cplusplus/pp-engine.h
+++ b/src/libs/cplusplus/pp-engine.h
@@ -237,7 +237,6 @@ private:
void maybeStartOutputLine();
void generateOutputLineMarker(unsigned lineno);
void synchronizeOutputLines(const PPToken &tk, bool forceLine = false);
- void removeTrailingOutputLines();
void enforceSpacing(const PPToken &tk, bool forceSpacing = false);
static std::size_t computeDistance(const PPToken &tk, bool forceTillLine = false);