compilerplugins/clang/check.cxx | 13 ++++++++++--- compilerplugins/clang/check.hxx | 4 +++- include/drawinglayer/processor2d/d2dpixelprocessor2d.hxx | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-)
New commits: commit e816ca42f9f5d21ae50939559900c1aede994d0e Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Thu Dec 22 09:39:52 2022 +0100 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Thu Dec 22 10:44:42 2022 +0000 -Werror,-Wmicrosoft-extra-qualification (clang-cl) Change-Id: I7f0f551110d1df4e27d89ac1016fb5ff3f71151d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144736 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/include/drawinglayer/processor2d/d2dpixelprocessor2d.hxx b/include/drawinglayer/processor2d/d2dpixelprocessor2d.hxx index 3d84d6dd42af..a08fef7b7ae2 100644 --- a/include/drawinglayer/processor2d/d2dpixelprocessor2d.hxx +++ b/include/drawinglayer/processor2d/d2dpixelprocessor2d.hxx @@ -80,7 +80,7 @@ class DRAWINGLAYER_DLLPUBLIC D2DPixelProcessor2D : public BaseProcessor2D processMarkerArrayPrimitive2D(const primitive2d::MarkerArrayPrimitive2D& rMarkerArrayCandidate); void processBackgroundColorPrimitive2D( const primitive2d::BackgroundColorPrimitive2D& rBackgroundColorCandidate); - void D2DPixelProcessor2D::processPolygonStrokePrimitive2D( + void processPolygonStrokePrimitive2D( const primitive2d::PolygonStrokePrimitive2D& rPolygonStrokeCandidate); void processLineRectanglePrimitive2D( const primitive2d::LineRectanglePrimitive2D& rLineRectanglePrimitive2D); commit 28f248a3397b50ae6047a7a907f5a159b1b1d310 Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Thu Dec 22 09:33:05 2022 +0100 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Thu Dec 22 10:44:35 2022 +0000 Make namespace checks look through LinkageSpecs My clang-cl --with-visual-studio=2022preview build against VS 2022 Preview 17.5.0 Preview 2.0 had started to fail with > [build CPT] compilerplugins/clang/test/getstr.cxx > error: 'error' diagnostics expected but not seen: > File compilerplugins/clang/test/getstr.cxx Line 42: directly use object of type '{{(rtl::)?}}OString' in a call of 'operator <<', instead of calling 'getStr' first [loplugin:getstr] > File compilerplugins/clang/test/getstr.cxx Line 48: directly use object of type 'S' (aka 'rtl::OString') in a call of 'operator <<', instead of calling 'getStr' first [loplugin:getstr] > File compilerplugins/clang/test/getstr.cxx Line 49: directly use object of type 'rtl::OString' in a call of 'operator <<', instead of calling 'getStr' first [loplugin:getstr] > File compilerplugins/clang/test/getstr.cxx Line 55: directly use object of type 'rtl::OString' in a call of 'operator <<', instead of calling 'getStr' first [loplugin:getstr] > File compilerplugins/clang/test/getstr.cxx Line 57: directly use object of type '{{(rtl::)?}}OString' in a call of 'operator <<', instead of calling 'getStr' first [loplugin:getstr] > 5 errors generated. apparently because C:/Program Files/Microsoft Visual Studio/2022/Preview/VC/Tools/MSVC/14.35.32124/include/ostream now contains [...] > _EXPORT_STD extern "C++" template <class _Elem, class _Traits> > class basic_ostream : virtual public basic_ios<_Elem, _Traits> { // control insertions into a stream buffer [...] with a wrapping extern "C++", so the call to StdNamespace() in > if (!loplugin::TypeCheck(expr->getArg(0)->getType()) > .ClassOrStruct("basic_ostream") > .StdNamespace()) //TODO: check template args in compilerplugins/clang/getstr.cxx no longer matched Change-Id: Iaeb461d5aa855a8602c5c6f791407c08a1c5d309 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144735 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/compilerplugins/clang/check.cxx b/compilerplugins/clang/check.cxx index 93fd7c7f7307..7be98bf97d5c 100644 --- a/compilerplugins/clang/check.cxx +++ b/compilerplugins/clang/check.cxx @@ -202,7 +202,7 @@ TerminalCheck ContextCheck::GlobalNamespace() const { TerminalCheck ContextCheck::StdNamespace() const { return TerminalCheck( - context_ != nullptr && context_->isStdNamespace()); + context_ != nullptr && lookThroughLinkageSpec()->isStdNamespace()); } namespace { @@ -224,15 +224,22 @@ bool isStdOrNestedNamespace(clang::DeclContext const * context) { } TerminalCheck ContextCheck::StdOrNestedNamespace() const { - return TerminalCheck(context_ != nullptr && isStdOrNestedNamespace(context_)); + return TerminalCheck(context_ != nullptr && isStdOrNestedNamespace(lookThroughLinkageSpec())); } ContextCheck ContextCheck::AnonymousNamespace() const { - auto n = llvm::dyn_cast_or_null<clang::NamespaceDecl>(context_); + auto n = llvm::dyn_cast_or_null<clang::NamespaceDecl>(lookThroughLinkageSpec()); return ContextCheck( n != nullptr && n->isAnonymousNamespace() ? n->getParent() : nullptr); } +clang::DeclContext const * ContextCheck::lookThroughLinkageSpec() const { + if (context_ != nullptr && context_->getDeclKind() == clang::Decl::LinkageSpec) { + return context_->getParent(); + } + return context_; +} + namespace { bool BaseCheckNotSomethingInterestingSubclass(const clang::CXXRecordDecl *BaseDefinition) { diff --git a/compilerplugins/clang/check.hxx b/compilerplugins/clang/check.hxx index 9c35acff7b5e..4ac311759832 100644 --- a/compilerplugins/clang/check.hxx +++ b/compilerplugins/clang/check.hxx @@ -140,6 +140,8 @@ public: explicit ContextCheck(const clang::NamespaceDecl * decl ) : context_( decl ) {} private: + clang::DeclContext const * lookThroughLinkageSpec() const; + clang::DeclContext const * const context_; }; @@ -277,7 +279,7 @@ ContextCheck DeclCheck::Var(llvm::StringRef id) const ContextCheck ContextCheck::Namespace(llvm::StringRef id) const { if (context_) { - auto n = llvm::dyn_cast<clang::NamespaceDecl>(context_); + auto n = llvm::dyn_cast<clang::NamespaceDecl>(lookThroughLinkageSpec()); if (n != nullptr) { auto const i = n->getIdentifier(); if (i != nullptr && i->getName() == id) {