CppTools: Predefine __func__ and friends

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

Change-Id: Iff69638f8939c3c4dced99699a3357dd94b23c71
Task-number: QTCREATORBUG-15431
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
This commit is contained in:
Nikolai Kosjar
2015-12-02 10:17:08 +01:00
parent ebf26ca125
commit 7bb2d833f1
2 changed files with 24 additions and 0 deletions

View File

@@ -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;

View File

@@ -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"