forked from qt-creator/qt-creator
Fixed macro locations.
This commit is contained in:
@@ -481,12 +481,12 @@ void pp::operator () (const QByteArray &filename,
|
||||
const QByteArray &source,
|
||||
QByteArray *result)
|
||||
{
|
||||
const QByteArray previousFile = env.current_file;
|
||||
env.current_file = filename;
|
||||
const QByteArray previousFile = env.currentFile;
|
||||
env.currentFile = filename;
|
||||
|
||||
operator () (source, result);
|
||||
|
||||
env.current_file = previousFile;
|
||||
env.currentFile = previousFile;
|
||||
}
|
||||
|
||||
pp::State pp::createStateFromSource(const QByteArray &source) const
|
||||
@@ -518,7 +518,7 @@ void pp::operator()(const QByteArray &source, QByteArray *result)
|
||||
result->append(QByteArray::number(_dot->lineno));
|
||||
result->append(' ');
|
||||
result->append('"');
|
||||
result->append(env.current_file);
|
||||
result->append(env.currentFile);
|
||||
result->append('"');
|
||||
result->append('\n');
|
||||
} else {
|
||||
@@ -844,6 +844,8 @@ void pp::processDefine(TokenIterator firstToken, TokenIterator lastToken)
|
||||
}
|
||||
|
||||
Macro macro;
|
||||
macro.fileName = env.currentFile;
|
||||
macro.line = env.currentLine;
|
||||
macro.name = tokenText(*tk);
|
||||
++tk; // skip T_IDENTIFIER
|
||||
|
||||
|
||||
@@ -97,8 +97,6 @@ Macro *Environment::bind(const Macro &__macro)
|
||||
|
||||
Macro *m = new Macro (__macro);
|
||||
m->hashcode = hash_code(m->name);
|
||||
m->fileName = current_file;
|
||||
m->line = currentLine;
|
||||
|
||||
if (++_macro_count == _allocated_macros) {
|
||||
if (! _allocated_macros)
|
||||
@@ -122,11 +120,13 @@ Macro *Environment::bind(const Macro &__macro)
|
||||
return m;
|
||||
}
|
||||
|
||||
Macro *Environment::remove (const QByteArray &name)
|
||||
Macro *Environment::remove(const QByteArray &name)
|
||||
{
|
||||
Macro macro;
|
||||
macro.name = name;
|
||||
macro.hidden = true;
|
||||
macro.fileName = currentFile;
|
||||
macro.line = currentLine;
|
||||
return bind(macro);
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ private:
|
||||
void rehash();
|
||||
|
||||
public:
|
||||
QByteArray current_file;
|
||||
QByteArray currentFile;
|
||||
unsigned currentLine;
|
||||
bool hide_next;
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ const char *MacroExpander::operator () (const char *__first, const char *__last,
|
||||
__result->append(QByteArray::number(env.currentLine));
|
||||
__result->append(' ');
|
||||
__result->append('"');
|
||||
__result->append(env.current_file);
|
||||
__result->append(env.currentFile);
|
||||
__result->append('"');
|
||||
__result->append('\n');
|
||||
++lines;
|
||||
@@ -218,7 +218,7 @@ const char *MacroExpander::operator () (const char *__first, const char *__last,
|
||||
else if (fast_name == "__FILE__")
|
||||
{
|
||||
__result->append('"');
|
||||
__result->append(env.current_file);
|
||||
__result->append(env.currentFile);
|
||||
__result->append('"');
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -390,17 +390,17 @@ void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type)
|
||||
} else {
|
||||
Document::Ptr previousDoc = switchDocument(Document::create(fileName));
|
||||
|
||||
const QByteArray previousFile = env.current_file;
|
||||
const QByteArray previousFile = env.currentFile;
|
||||
const unsigned previousLine = env.currentLine;
|
||||
|
||||
env.current_file = QByteArray(m_currentDoc->translationUnit()->fileName(),
|
||||
env.currentFile = QByteArray(m_currentDoc->translationUnit()->fileName(),
|
||||
m_currentDoc->translationUnit()->fileNameLength());
|
||||
|
||||
QByteArray preprocessedCode;
|
||||
m_proc(contents, &preprocessedCode);
|
||||
//qDebug() << preprocessedCode;
|
||||
|
||||
env.current_file = previousFile;
|
||||
env.currentFile = previousFile;
|
||||
env.currentLine = previousLine;
|
||||
|
||||
m_currentDoc->setSource(preprocessedCode);
|
||||
|
||||
Reference in New Issue
Block a user