diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2014-04-15 16:53:51 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-04-15 16:57:23 +0200 |
commit | e5199d3d78721c962f53a8675d5245e4b839bdc3 (patch) | |
tree | 4fb9d013954199c26ca343dd4874b1f46fdcb071 /compilerplugins/clang/compat.hxx | |
parent | c5265586e635d294708f6af10697134a95a26e08 (diff) |
Flag unreferrenced functions only declared in the main file, not an include
...which appears to be a good heuristic to identify functions that are either
unused or should better be declared just once in an include file. (It also
filters out SAL_DLLPUBLIC extern "C" function definitions, which are most likely
meant to be referenced dynamically via dlsym.)
Change-Id: I7fb78cb836b971791704851535dcfbda2b2f5bc0
Diffstat (limited to 'compilerplugins/clang/compat.hxx')
-rw-r--r-- | compilerplugins/clang/compat.hxx | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/compilerplugins/clang/compat.hxx b/compilerplugins/clang/compat.hxx index 3d265722c044..7389f636d0bf 100644 --- a/compilerplugins/clang/compat.hxx +++ b/compilerplugins/clang/compat.hxx @@ -20,7 +20,9 @@ #include "clang/AST/Type.h" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/DiagnosticIDs.h" +#include "clang/Basic/Linkage.h" #include "clang/Basic/SourceManager.h" +#include "clang/Basic/Visibility.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/raw_ostream.h" @@ -52,6 +54,28 @@ inline bool isExternCContext(clang::DeclContext const & ctxt) { #endif } +#if (__clang_major__ == 3 && __clang_minor__ >= 3) || __clang_major__ > 3 +typedef clang::LinkageInfo LinkageInfo; +#else +typedef clang::NamedDecl::LinkageInfo LinkageInfo; +#endif + +inline clang::Linkage getLinkage(LinkageInfo const & info) { +#if (__clang_major__ == 3 && __clang_minor__ >= 3) || __clang_major__ > 3 + return info.getLinkage(); +#else + return info.linkage(); +#endif +} + +inline clang::Visibility getVisibility(LinkageInfo const & info) { +#if (__clang_major__ == 3 && __clang_minor__ >= 3) || __clang_major__ > 3 + return info.getVisibility(); +#else + return info.visibility(); +#endif +} + inline bool isFirstDecl(clang::FunctionDecl const & decl) { #if (__clang_major__ == 3 && __clang_minor__ >= 4) || __clang_major__ > 3 return decl.isFirstDecl(); |