From 8fb258b85e82e2d520d1ae20226c3f89af22d019 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Wed, 12 Apr 2023 16:33:59 +0200 Subject: [PATCH] ClangCodeModel: Make use of QT_ANNOTATE_FUNCTION() See qtbase/6c54e10144e7af02f4c35e20e5f375a0cf280b8b. Fixes: QTCREATORBUG-28970 Change-Id: I7500c1e25a63d2a1cda66259c5ebd84976c27335 Reviewed-by: Reviewed-by: David Schulz --- src/plugins/cppeditor/compileroptionsbuilder.cpp | 7 +++++++ src/plugins/cppeditor/compileroptionsbuilder.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/plugins/cppeditor/compileroptionsbuilder.cpp b/src/plugins/cppeditor/compileroptionsbuilder.cpp index d2c5e16325f..5f092121214 100644 --- a/src/plugins/cppeditor/compileroptionsbuilder.cpp +++ b/src/plugins/cppeditor/compileroptionsbuilder.cpp @@ -130,6 +130,7 @@ QStringList CompilerOptionsBuilder::build(ProjectFile::Kind fileKind, undefineCppLanguageFeatureMacrosForMsvc2015(); addDefineFunctionMacrosMsvc(); addDefineFunctionMacrosQnx(); + addQtMacros(); addHeaderPathOptions(); @@ -786,6 +787,12 @@ void CompilerOptionsBuilder::addDefineFunctionMacrosQnx() addMacros({{"_LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE"}}); } +void CompilerOptionsBuilder::addQtMacros() +{ + if (m_projectPart.qtVersion != QtMajorVersion::None) + addMacros({{"QT_ANNOTATE_FUNCTION(x)", "__attribute__((annotate(#x)))"}}); +} + void CompilerOptionsBuilder::reset() { m_options.clear(); diff --git a/src/plugins/cppeditor/compileroptionsbuilder.h b/src/plugins/cppeditor/compileroptionsbuilder.h index 0e8c1a5fad0..d47a7e87e3d 100644 --- a/src/plugins/cppeditor/compileroptionsbuilder.h +++ b/src/plugins/cppeditor/compileroptionsbuilder.h @@ -62,6 +62,7 @@ public: void undefineClangVersionMacrosForMsvc(); void addDefineFunctionMacrosQnx(); + void addQtMacros(); // Add custom options void add(const QString &arg, bool gccOnlyOption = false);