Commit b934cc19 authored by hjk's avatar hjk Committed by Erik Verbruggen
Browse files

C++: pass #include_next down to CppPreprocessor::tryIncludeFile



This does not yet resolve the file using the proper mechanism.

Change-Id: I04913e8b01ae0c3411961f0c1cffe07202f06a0a
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@digia.com>
parent 40eecd87
...@@ -68,7 +68,8 @@ class CPLUSPLUS_EXPORT Client ...@@ -68,7 +68,8 @@ class CPLUSPLUS_EXPORT Client
public: public:
enum IncludeType { enum IncludeType {
IncludeLocal, IncludeLocal,
IncludeGlobal IncludeGlobal,
IncludeNext
}; };
public: public:
......
...@@ -1407,9 +1407,10 @@ void Preprocessor::handlePreprocessorDirective(PPToken *tk) ...@@ -1407,9 +1407,10 @@ void Preprocessor::handlePreprocessorDirective(PPToken *tk)
else if (!skipping() && directive == ppUndef) else if (!skipping() && directive == ppUndef)
handleUndefDirective(tk); handleUndefDirective(tk);
else if (!skipping() && (directive == ppInclude else if (!skipping() && (directive == ppInclude
|| directive == ppIncludeNext
|| directive == ppImport)) || directive == ppImport))
handleIncludeDirective(tk); handleIncludeDirective(tk, false);
else if (!skipping() && directive == ppIncludeNext)
handleIncludeDirective(tk, true);
else if (directive == ppIf) else if (directive == ppIf)
handleIfDirective(tk); handleIfDirective(tk);
else if (directive == ppIfDef) else if (directive == ppIfDef)
...@@ -1428,7 +1429,7 @@ void Preprocessor::handlePreprocessorDirective(PPToken *tk) ...@@ -1428,7 +1429,7 @@ void Preprocessor::handlePreprocessorDirective(PPToken *tk)
} }
void Preprocessor::handleIncludeDirective(PPToken *tk) void Preprocessor::handleIncludeDirective(PPToken *tk, bool includeNext)
{ {
m_state.m_lexer->setScanAngleStringLiteralTokens(true); m_state.m_lexer->setScanAngleStringLiteralTokens(true);
lex(tk); // consume "include" token lex(tk); // consume "include" token
...@@ -1451,7 +1452,9 @@ void Preprocessor::handleIncludeDirective(PPToken *tk) ...@@ -1451,7 +1452,9 @@ void Preprocessor::handleIncludeDirective(PPToken *tk)
// qDebug("include [[%s]]", included.toUtf8().constData()); // qDebug("include [[%s]]", included.toUtf8().constData());
Client::IncludeType mode; Client::IncludeType mode;
if (included.at(0) == '"') if (includeNext)
mode = Client::IncludeNext;
else if (included.at(0) == '"')
mode = Client::IncludeLocal; mode = Client::IncludeLocal;
else if (included.at(0) == '<') else if (included.at(0) == '<')
mode = Client::IncludeGlobal; mode = Client::IncludeGlobal;
......
...@@ -155,7 +155,7 @@ private: ...@@ -155,7 +155,7 @@ private:
void scanActualArgument(PPToken *tk, QVector<PPToken> *tokens); void scanActualArgument(PPToken *tk, QVector<PPToken> *tokens);
void handlePreprocessorDirective(PPToken *tk); void handlePreprocessorDirective(PPToken *tk);
void handleIncludeDirective(PPToken *tk); void handleIncludeDirective(PPToken *tk, bool includeNext);
void handleDefineDirective(PPToken *tk); void handleDefineDirective(PPToken *tk);
QByteArray expand(PPToken *tk, PPToken *lastConditionToken = 0); QByteArray expand(PPToken *tk, PPToken *lastConditionToken = 0);
const Internal::PPToken evalExpression(PPToken *tk, Value &result); const Internal::PPToken evalExpression(PPToken *tk, Value &result);
......
...@@ -373,13 +373,15 @@ QString CppPreprocessor::tryIncludeFile(QString &fileName, IncludeType type, uns ...@@ -373,13 +373,15 @@ QString CppPreprocessor::tryIncludeFile(QString &fileName, IncludeType type, uns
return QString(); return QString();
} }
}
const QString originalFileName = fileName; const QString originalFileName = fileName;
const QString contents = tryIncludeFile_helper(fileName, type, revision); const QString contents = tryIncludeFile_helper(fileName, type, revision);
if (type == IncludeGlobal)
m_fileNameCache.insert(originalFileName, fileName); m_fileNameCache.insert(originalFileName, fileName);
return contents; return contents;
}
// IncludeLocal, IncludeNext
return tryIncludeFile_helper(fileName, type, revision);
} }
QString CppPreprocessor::cleanPath(const QString &path) QString CppPreprocessor::cleanPath(const QString &path)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment