convert conststringvar plugin to shared infrastructre
and move the duplicated hasExternalLinkage function to a common location Change-Id: I39a1990945666ff7a307b4ddd5e270da64ee1673 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88592 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
@@ -768,6 +768,31 @@ int derivedFromCount(QualType subclassQt, QualType baseclassQt)
|
||||
return derivedFromCount(subclassRecordDecl, baseclassRecordDecl);
|
||||
}
|
||||
|
||||
// It looks like Clang wrongly implements DR 4
|
||||
// (<http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#4>) and treats
|
||||
// a variable declared in an 'extern "..." {...}'-style linkage-specification as
|
||||
// if it contained the 'extern' specifier:
|
||||
bool hasExternalLinkage(VarDecl const * decl) {
|
||||
if (decl->getLinkageAndVisibility().getLinkage() != ExternalLinkage) {
|
||||
return false;
|
||||
}
|
||||
for (auto ctx = decl->getLexicalDeclContext();
|
||||
ctx->getDeclKind() != Decl::TranslationUnit;
|
||||
ctx = ctx->getLexicalParent())
|
||||
{
|
||||
if (auto ls = dyn_cast<LinkageSpecDecl>(ctx)) {
|
||||
if (!ls->hasBraces()) {
|
||||
return true;
|
||||
}
|
||||
if (auto prev = decl->getPreviousDecl()) {
|
||||
return hasExternalLinkage(prev);
|
||||
}
|
||||
return !decl->isInAnonymousNamespace();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
Reference in New Issue
Block a user