summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/salbool.cxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-09-16 09:14:06 +0200
committerStephan Bergmann <sbergman@redhat.com>2014-09-16 09:14:29 +0200
commite36badb98d0bb5866a297cb51c3e95cdce62d8da (patch)
tree28c1e00e0950b9722cb06520bf15f4d4e7c7721b /compilerplugins/clang/salbool.cxx
parent3bd267a3d8e6e7b6c7247f119f3795c2c60fbf8e (diff)
Fix workaround for bug in Clang 3.2 FunctionDecl::isInlined
Change-Id: I9b0b6affc60ae030b644fdd13eecfb1aed1f472a
Diffstat (limited to 'compilerplugins/clang/salbool.cxx')
-rw-r--r--compilerplugins/clang/salbool.cxx31
1 files changed, 17 insertions, 14 deletions
diff --git a/compilerplugins/clang/salbool.cxx b/compilerplugins/clang/salbool.cxx
index 2a64fe4a5066..e541766847a3 100644
--- a/compilerplugins/clang/salbool.cxx
+++ b/compilerplugins/clang/salbool.cxx
@@ -24,6 +24,20 @@ bool isSalBool(QualType type) {
return t != nullptr && t->getDecl()->getNameAsString() == "sal_Bool";
}
+// Clang 3.2 FunctionDecl::isInlined doesn't work as advertised ("Determine
+// whether this function should be inlined, because it is either marked 'inline'
+// or 'constexpr' or is a member function of a class that was defined in the
+// class body.") but mis-classifies salhelper::Timer's isTicking, isExpired, and
+// expiresBefore members as defined in salhelper/source/timer.cxx as inlined:
+bool isInlined(FunctionDecl const & decl) {
+#if (__clang_major__ == 3 && __clang_minor__ >= 3) || __clang_major__ > 3
+ return decl->isInlined();
+#else
+ (void)decl;
+ return false;
+#endif
+}
+
// It appears that, given a function declaration, there is no way to determine
// the language linkage of the function's type, only of the function's name
// (via FunctionDecl::isExternC); however, in a case like
@@ -324,7 +338,7 @@ bool SalBool::VisitParmVarDecl(ParmVarDecl const * decl) {
|| (isInUnoIncludeFile(
compiler.getSourceManager().getSpellingLoc(
f->getNameInfo().getLoc()))
- && (!f->isInlined() || f->hasAttr<DeprecatedAttr>()
+ && (!isInlined(*f) || f->hasAttr<DeprecatedAttr>()
|| decl->getType()->isReferenceType()
|| hasBoolOverload(f, false)))
|| f->isDeleted() || hasBoolOverload(f, true)))
@@ -497,18 +511,7 @@ bool SalBool::VisitFunctionDecl(FunctionDecl const * decl) {
|| (isInUnoIncludeFile(
compiler.getSourceManager().getSpellingLoc(
f->getNameInfo().getLoc()))
- && (
-// Clang 3.2 FunctionDecl::isInlined doesn't work as advertised ("Determine
-// whether this function should be inlined, because it is either marked 'inline'
-// or 'constexpr' or is a member function of a class that was defined in the
-// class body.") but mis-classifies salhelper::Timer's isTicking, isExpired, and
-// expiresBefore members as defined in salhelper/source/timer.cxx as inlined:
-#if (__clang_major__ == 3 && __clang_minor__ >= 3) || __clang_major__ > 3
- !f->isInlined()
-#else
- true
-#endif
- || f->hasAttr<DeprecatedAttr>()))))
+ && (!isInlined(*f) || f->hasAttr<DeprecatedAttr>()))))
{
SourceLocation loc { decl->getLocStart() };
SourceLocation l { compiler.getSourceManager().getExpansionLoc(
@@ -544,7 +547,7 @@ bool SalBool::VisitFunctionDecl(FunctionDecl const * decl) {
{
report(
DiagnosticsEngine::Warning,
- "use \"bool\" instead of \"sal_Bool\" as return type%0",
+ "use \"bool\" instead of \"sal_Bool\" as return type%0 [%1 %2]",
loc)
<< (k == OverrideKind::MAYBE
? (" (unless this member function overrides a dependent"