Commit 7bb2d833 authored by Nikolai Kosjar's avatar Nikolai Kosjar

CppTools: Predefine __func__ and friends

...so the built-in parser can handle them.

Change-Id: Iff69638f8939c3c4dced99699a3357dd94b23c71
Task-number: QTCREATORBUG-15431
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@theqtcompany.com>
parent ebf26ca1
......@@ -32,12 +32,29 @@
#include "cppsourceprocessor.h"
#include "editordocumenthandle.h"
#include <projectexplorer/projectexplorerconstants.h>
#include <utils/qtcassert.h>
using namespace CPlusPlus;
using namespace CppTools;
using namespace CppTools::Internal;
static QByteArray overwrittenToolchainDefines(const ProjectPart &projectPart)
{
QByteArray defines;
// MSVC's predefined macros like __FUNCSIG__ expand to itself.
// We can't parse this, so redefine to the empty string literal.
if (projectPart.toolchainType == ProjectExplorer::Constants::MSVC_TOOLCHAIN_TYPEID) {
defines += "#define __FUNCSIG__ \"\"\n"
"#define __FUNCDNAME__ \"\"\n"
"#define __FUNCTION__ \"\"\n";
}
return defines;
}
BuiltinEditorDocumentParser::BuiltinEditorDocumentParser(const QString &filePath)
: BaseEditorDocumentParser(filePath)
{
......@@ -74,6 +91,7 @@ void BuiltinEditorDocumentParser::updateHelper(const InMemoryInfo &info)
if (const ProjectPart::Ptr part = baseState.projectPart) {
configFile += part->toolchainDefines;
configFile += overwrittenToolchainDefines(*part.data());
configFile += part->projectDefines;
headerPaths = part->headerPaths;
projectConfigFile = part->projectConfigFile;
......
......@@ -190,6 +190,12 @@ const char pp_configuration[] =
"#define _Pragma(x)\n" // C99 _Pragma operator
"#define __func__ \"\"\n"
// ### add macros for gcc
"#define __PRETTY_FUNCTION__ \"\"\n"
"#define __FUNCTION__ \"\"\n"
// ### add macros for win32
"#define __cdecl\n"
"#define __stdcall\n"
......
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