compilerplugins/clang/check.cxx |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 88bba21f83ce47a517dabc637fb421ac9bad5416
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Mon Apr 4 15:41:16 2022 +0200
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Mon Apr 4 17:30:52 2022 +0200

    Fix GlobalNamespace check
    
    ...so that e.g. building on F36 with -stdlib=libc++ doesn't fail with
    
    > i18nutil/source/utility/paper.cxx:311:75: error: NullToPointer 
ValueDependentIsNotNull ZeroLiteral -> nullptr [loplugin:nullptr]
    >         locale_t loc = newlocale(LC_PAPER_MASK, "", 
static_cast<locale_t>(0));
    >                                                                           
^
    
    when the locale_t typedef declaration is nested in extern "C" (from
    /usr/include/stdlib.h) which in turn is nested in extern "C++" (from LLVM's
    include/c++/v1/math.h)
    
    Change-Id: Ie81d7425cda231954bdbab47c3a0431dc7c27f5f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132520
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/compilerplugins/clang/check.cxx b/compilerplugins/clang/check.cxx
index 003224a21ba1..9952e285b2b5 100644
--- a/compilerplugins/clang/check.cxx
+++ b/compilerplugins/clang/check.cxx
@@ -191,7 +191,10 @@ namespace {
 
 bool isGlobalNamespace(clang::DeclContext const * context) {
     assert(context != nullptr);
-    return (context->isLookupContext() ? context : 
context->getLookupParent())->isTranslationUnit();
+    while (!context->isLookupContext()) {
+        context = context->getLookupParent();
+    }
+    return context->isTranslationUnit();
 }
 
 }

Reply via email to