summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/check.hxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2019-08-28 11:17:20 +0200
committerStephan Bergmann <sbergman@redhat.com>2019-08-28 12:47:21 +0200
commit5f3c2204eb7dbe82cc64bf0ade34ecfb4b9ffc05 (patch)
treecf0ad0f1ff2e5223ae09c8f57e5270f61971ac36 /compilerplugins/clang/check.hxx
parent28e2dc30149178bbe6f59e28ddef3f0bd62d4bb1 (diff)
New loplugin:stdfunction
...finding dubious additions to namespace std (concentrating on functions for now). C++17 [namespace.std]/1: "The behavior of a C ++ program is undefined if it adds declarations or definitions to namespace std or to a namespace within namespace std unless otherwise specified." This found ad4c7b97752b4da73808402604d6f96b39d920f5 "Avoid declaring function templates in namespace std" 042e30a3dc057aef4a02d95960e4dd4fb8d083ae "Avoid adding a function template declaration to namespace std" cae9240a76cdb0eeed92421930d3b4cbef0ac201 "Avoid adding a function declaration to namespace std" Change-Id: Ic2ba54e2a8bf931d5c58cedf499c0d1229eb2166 Reviewed-on: https://gerrit.libreoffice.org/78220 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins/clang/check.hxx')
-rw-r--r--compilerplugins/clang/check.hxx13
1 files changed, 5 insertions, 8 deletions
diff --git a/compilerplugins/clang/check.hxx b/compilerplugins/clang/check.hxx
index 0904e5f2f1a1..4ac4f8e99cb6 100644
--- a/compilerplugins/clang/check.hxx
+++ b/compilerplugins/clang/check.hxx
@@ -103,6 +103,9 @@ private:
class ContextCheck {
public:
+ explicit ContextCheck(clang::DeclContext const * context = nullptr):
+ context_(context) {}
+
explicit operator bool() const { return context_ != nullptr; }
TerminalCheck GlobalNamespace() const;
@@ -111,6 +114,8 @@ public:
TerminalCheck StdNamespace() const;
+ TerminalCheck StdOrNestedNamespace() const;
+
ContextCheck AnonymousNamespace() const;
inline ContextCheck Class(llvm::StringRef id) const;
@@ -120,14 +125,6 @@ public:
explicit ContextCheck(const clang::NamespaceDecl * decl ) : context_( decl ) {}
private:
- friend DeclCheck;
- friend TypeCheck;
- friend ContextCheck detail::checkRecordDecl(
- clang::Decl const * decl, clang::TagTypeKind tag, llvm::StringRef id);
-
- explicit ContextCheck(clang::DeclContext const * context = nullptr):
- context_(context) {}
-
clang::DeclContext const * const context_;
};