summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/badstatics.cxx2
-rw-r--r--compilerplugins/clang/external.cxx10
-rw-r--r--compilerplugins/clang/refcounting.cxx2
-rw-r--r--compilerplugins/clang/staticmethods.cxx2
-rw-r--r--compilerplugins/clang/test/external.cxx12
5 files changed, 20 insertions, 8 deletions
diff --git a/compilerplugins/clang/badstatics.cxx b/compilerplugins/clang/badstatics.cxx
index 737330dd10c0..60abc11c222b 100644
--- a/compilerplugins/clang/badstatics.cxx
+++ b/compilerplugins/clang/badstatics.cxx
@@ -117,7 +117,7 @@ public:
|| type.Class("weak_ptr").StdNamespace() // not owning
|| type.Class("ImplWallpaper").GlobalNamespace() // very odd static instance here
|| type.Class("Application").GlobalNamespace() // numerous odd subclasses in vclmain::createApplication()
- || type.Class("DemoMtfApp").GlobalNamespace() // one of these Application with own VclPtr
+ || type.Class("DemoMtfApp").AnonymousNamespace().GlobalNamespace() // one of these Application with own VclPtr
)
{
return std::make_pair(false, std::vector<FieldDecl const*>());
diff --git a/compilerplugins/clang/external.cxx b/compilerplugins/clang/external.cxx
index 64da725cfff9..b31f620cf5ef 100644
--- a/compilerplugins/clang/external.cxx
+++ b/compilerplugins/clang/external.cxx
@@ -133,9 +133,6 @@ public:
bool VisitTagDecl(TagDecl* decl)
{
- /*TODO:*/
- if (!isa<EnumDecl>(decl))
- return true; // in general, moving classes into an unnamed namespace can break ADL
if (isa<ClassTemplateSpecializationDecl>(decl))
{
return true;
@@ -266,8 +263,6 @@ public:
bool VisitClassTemplateDecl(ClassTemplateDecl* decl)
{
- /*TODO:*/
- return true; // in general, moving classes or enumerations into an unnamed namespace can break ADL
if (!decl->isThisDeclarationADefinition())
{
return true;
@@ -329,6 +324,7 @@ private:
}
else
{
+ //TODO: Derived types are also affected!
CXXRecordDecl const* rec;
if (auto const d = dyn_cast<ClassTemplateDecl>(decl))
{
@@ -400,6 +396,10 @@ private:
if (auto const d1 = dyn_cast<FriendDecl>(d))
{
d = d1->getFriendDecl();
+ if (d == nullptr) // happens for 'friend struct S;'
+ {
+ continue;
+ }
}
FunctionDecl const* f;
if (auto const d1 = dyn_cast<FunctionTemplateDecl>(d))
diff --git a/compilerplugins/clang/refcounting.cxx b/compilerplugins/clang/refcounting.cxx
index c002a1499977..168d775b28d2 100644
--- a/compilerplugins/clang/refcounting.cxx
+++ b/compilerplugins/clang/refcounting.cxx
@@ -256,7 +256,7 @@ bool containsSalhelperReferenceObjectSubclass(const clang::Type* pType0) {
if (pTemplate) {
auto const dc = loplugin::DeclCheck(pTemplate);
if (dc.Class("Reference").Namespace("rtl").GlobalNamespace()
- || (dc.Class("OStoreHandle").Namespace("store")
+ || (dc.Class("OStoreHandle").AnonymousNamespace().Namespace("store")
.GlobalNamespace()))
{
return false;
diff --git a/compilerplugins/clang/staticmethods.cxx b/compilerplugins/clang/staticmethods.cxx
index 25e4d2c77473..6070ce860d82 100644
--- a/compilerplugins/clang/staticmethods.cxx
+++ b/compilerplugins/clang/staticmethods.cxx
@@ -173,7 +173,7 @@ bool StaticMethods::TraverseCXXMethodDecl(const CXXMethodDecl * pCXXMethodDecl)
// used in a function-pointer-table
if ((cdc.Class("SbiRuntime").GlobalNamespace()
&& startsWith(pCXXMethodDecl->getNameAsString(), "Step"))
- || (cdc.Class("OoxFormulaParserImpl").Namespace("xls").Namespace("oox")
+ || (cdc.Class("OoxFormulaParserImpl").AnonymousNamespace().Namespace("xls").Namespace("oox")
.GlobalNamespace())
|| cdc.Class("SwTableFormula").GlobalNamespace()
|| (cdc.Class("BiffFormulaParserImpl").Namespace("xls").Namespace("oox")
diff --git a/compilerplugins/clang/test/external.cxx b/compilerplugins/clang/test/external.cxx
index 28b7c6df01b7..6eb486a57fc1 100644
--- a/compilerplugins/clang/test/external.cxx
+++ b/compilerplugins/clang/test/external.cxx
@@ -20,6 +20,7 @@ int const n2 = 0; // no warning, internal linkage
constexpr int n3 = 0; // no warning, internal linkage
+// expected-error@+1 {{externally available entity 'S1' is not previously declared in an included file (if it is only used in this translation unit, put it in an unnamed namespace; otherwise, provide a declaration of it in an included file) [loplugin:external]}}
struct S1
{
friend void f1() {} // no warning for injected function (no place where to mark it `static`)
@@ -28,6 +29,7 @@ struct S1
friend void f2() {}
};
+// expected-error@+1 {{externally available entity 'S2' is not previously declared in an included file (if it is only used in this translation unit, put it in an unnamed namespace; otherwise, provide a declaration of it in an included file) [loplugin:external]}}
struct S2
{
friend void f1();
@@ -76,11 +78,21 @@ extern "C++" {
void fc(E const*);
}
+// expected-error@+1 {{externally available entity 'S1' is not previously declared in an included file (if it is only used in this translation unit, put it in an unnamed namespace; otherwise, provide a declaration of it in an included file) [loplugin:external]}}
struct S1
{
struct S2;
// No note about associating function; injected friend function not found by ADL:
friend void f2(E const*);
+ // expected-note@+1 {{a function associating 'N::S1' is declared here [loplugin:external]}}
+ friend void h(S1);
+};
+
+// expected-error@+1 {{externally available entity 'S3' is not previously declared in an included file (if it is only used in this translation unit, put it in an unnamed namespace; otherwise, provide a declaration of it in an included file) [loplugin:external]}}
+struct S3
+{
+ // expected-note@+1 {{another declaration is here [loplugin:external]}}
+ friend void h(S1);
};
inline namespace I2