diff --git a/compilerplugins/clang/plugin.cxx b/compilerplugins/clang/plugin.cxx index 57fdf83b79ff..edf91f33d19b 100644 --- a/compilerplugins/clang/plugin.cxx +++ b/compilerplugins/clang/plugin.cxx @@ -285,7 +285,8 @@ bool Plugin::isInUnoIncludeFile(SourceLocation spellingLocation) const || hasPathnamePrefix(name, SRCDIR "/include/sal/") || hasPathnamePrefix(name, SRCDIR "/include/salhelper/") || hasPathnamePrefix(name, SRCDIR "/include/typelib/") - || hasPathnamePrefix(name, SRCDIR "/include/uno/")); + || hasPathnamePrefix(name, SRCDIR "/include/uno/") + || hasPathnamePrefix(name, SDKDIR "/include/")); } bool Plugin::isInUnoIncludeFile(const FunctionDecl* functionDecl) const @@ -722,6 +723,16 @@ bool isSamePathname(StringRef pathname, StringRef other) pathname, other, [](StringRef p, StringRef a) { return p == a; }); } +bool isSameUnoIncludePathname(StringRef fullPathname, StringRef includePathname) +{ + llvm::SmallVector buf; + if (isSamePathname(fullPathname, (SRCDIR "/include/" + includePathname).toStringRef(buf))) { + return true; + } + buf.clear(); + return isSamePathname(fullPathname, (SDKDIR "/include/" + includePathname).toStringRef(buf)); +} + bool hasCLanguageLinkageType(FunctionDecl const * decl) { assert(decl != nullptr); if (decl->isExternC()) { diff --git a/compilerplugins/clang/plugin.hxx b/compilerplugins/clang/plugin.hxx index 540352df9868..1694bdb0782a 100644 --- a/compilerplugins/clang/plugin.hxx +++ b/compilerplugins/clang/plugin.hxx @@ -282,6 +282,10 @@ bool hasPathnamePrefix(StringRef pathname, StringRef prefix); // also contain backslashes: bool isSamePathname(StringRef pathname, StringRef other); +// Check whether fullPathname is either SRCDIR/include/includePathname or +// SDKDIR/include/includePathname: +bool isSameUnoIncludePathname(StringRef fullPathname, StringRef includePathname); + // It appears that, given a function declaration, there is no way to determine // the language linkage of the function's type, only of the function's name // (via FunctionDecl::isExternC); however, in a case like diff --git a/compilerplugins/clang/reservedid.cxx b/compilerplugins/clang/reservedid.cxx index 2c7e9c8659e4..2a52e5629b2c 100644 --- a/compilerplugins/clang/reservedid.cxx +++ b/compilerplugins/clang/reservedid.cxx @@ -113,14 +113,12 @@ void ReservedId::postRun() { auto loc = d->getLocation(); if (loc.isValid() && !ignoreLocation(loc)) { auto file = getFilenameOfLocation(loc); - if (!loplugin::isSamePathname( + if (!loplugin::isSameUnoIncludePathname( file, - SRCDIR - "/include/cppuhelper/implbase_ex_post.hxx") - && !loplugin::isSamePathname( + "cppuhelper/implbase_ex_post.hxx") + && !loplugin::isSameUnoIncludePathname( file, - SRCDIR - "/include/cppuhelper/implbase_ex_pre.hxx")) + "cppuhelper/implbase_ex_pre.hxx")) { report( DiagnosticsEngine::Warning, diff --git a/config_host/config_clang.h.in b/config_host/config_clang.h.in index c19c0875ce86..678c53128c4d 100644 --- a/config_host/config_clang.h.in +++ b/config_host/config_clang.h.in @@ -8,6 +8,7 @@ Settings related to Clang compiler plugins. #define CONFIG_CLANG_H #undef BUILDDIR +#undef SDKDIR #undef SRCDIR #undef WORKDIR diff --git a/configure.ac b/configure.ac index b130e1e5ec68..7c168e154c4d 100644 --- a/configure.ac +++ b/configure.ac @@ -5340,6 +5340,7 @@ AC_SUBST(P_SEP) AC_SUBST(WORKDIR) AC_SUBST(PLATFORMID) AC_SUBST(WINDOWS_X64) +AC_DEFINE_UNQUOTED(SDKDIR, "$INSTDIR/$SDKDIRNAME") AC_DEFINE_UNQUOTED(WORKDIR,"$WORKDIR") if test "$OS" = WNT -a "$COM" = MSC; then diff --git a/odk/CppunitTest_odk_checkapi.mk b/odk/CppunitTest_odk_checkapi.mk index 00a799139f1f..22dad8cab62a 100644 --- a/odk/CppunitTest_odk_checkapi.mk +++ b/odk/CppunitTest_odk_checkapi.mk @@ -9,29 +9,33 @@ $(eval $(call gb_CppunitTest_CppunitTest,odk_checkapi)) -$(eval $(call gb_CppunitTest_use_custom_headers,odk_checkapi,\ - odk/allheaders \ -)) - $(eval $(call gb_CppunitTest_add_exception_objects,odk_checkapi,\ odk/qa/checkapi/checkapi \ )) -$(eval $(call gb_CppunitTest_use_internal_comprehensive_api,odk_checkapi,\ - udkapi \ -)) - $(eval $(call gb_CppunitTest_add_cxxflags,odk_checkapi,\ $(gb_CXX03FLAGS) \ )) -$(eval $(call gb_CppunitTest_use_libraries,odk_checkapi,\ - cppu \ - cppuhelper \ - sal \ - salhelper \ -)) - $(eval $(call gb_CppunitTest_set_external_code,odk_checkapi)) +# The remaining lines must be in the given order, to set up a set of include paths that only +# contains the instdir SDK include directory, plus SOLARINC as needed for platform-specific +# includes, plus the workdir sub-directory containing the generated allheaders.hxx and the workdir +# sub-directory containing the generated UNOIDL include files (which are not bundled in the SDK but +# would rather get created on demand by the SDK's makefiles), plus whatever is needed for CppUnit: + +$(eval $(call gb_CppunitTest_set_include,odk_checkapi, \ + -I$(INSTDIR)/$(SDKDIRNAME)/include $(SOLARINC))) + +$(eval $(call gb_CppunitTest_use_custom_headers,odk_checkapi,\ + odk/allheaders \ +)) + +$(eval $(call gb_CppunitTest_use_internal_comprehensive_api,odk_checkapi,\ + udkapi \ +)) + +$(eval $(call gb_CppunitTest_use_external,odk_checkapi,cppunit)) + # vim: set noet sw=4 ts=4: diff --git a/solenv/gbuild/LinkTarget.mk b/solenv/gbuild/LinkTarget.mk index ba7518805bc7..bb6b4b1fedbc 100644 --- a/solenv/gbuild/LinkTarget.mk +++ b/solenv/gbuild/LinkTarget.mk @@ -1160,7 +1160,7 @@ endef # call gb_LinkTarget_set_include,linktarget,includes define gb_LinkTarget_set_include $(call gb_LinkTarget__check_srcdir_paths,$(1),\ - $(patsubst -I%,%,$(filter -I$(SRCDIR)/%,$(filter-out -I$(WORKDIR)/%,$(2))))) + $(patsubst -I%,%,$(filter -I$(SRCDIR)/%,$(filter-out -I$(INSTDIR)/% -I$(WORKDIR)/%,$(2))))) $(call gb_LinkTarget_get_target,$(1)) : INCLUDE := $(2) endef