diff options
-rw-r--r-- | compilerplugins/clang/salbool.cxx | 40 | ||||
-rw-r--r-- | framework/inc/properties.h | 2 | ||||
-rw-r--r-- | framework/inc/protocols.h | 4 | ||||
-rw-r--r-- | include/cppuhelper/interfacecontainer.h | 4 | ||||
-rw-r--r-- | sal/qa/osl/security/osl_Security_Const.h | 2 |
5 files changed, 39 insertions, 13 deletions
diff --git a/compilerplugins/clang/salbool.cxx b/compilerplugins/clang/salbool.cxx index 4b123c77b020..e5e9754d7961 100644 --- a/compilerplugins/clang/salbool.cxx +++ b/compilerplugins/clang/salbool.cxx @@ -9,6 +9,7 @@ #include <algorithm> #include <cassert> +#include <limits> #include <set> #include <string> @@ -144,14 +145,19 @@ public: bool TraverseStaticAssertDecl(StaticAssertDecl * decl); + bool TraverseLinkageSpecDecl(LinkageSpecDecl * decl); + private: bool isFromCIncludeFile(SourceLocation spellingLocation) const; + bool isSharedCAndCppCode(SourceLocation location) const; + bool isInSpecialMainFile(SourceLocation spellingLocation) const; bool rewrite(SourceLocation location); std::set<VarDecl const *> varDecls_; + unsigned int externCContexts_ = 0; }; void SalBool::run() { @@ -282,10 +288,9 @@ bool SalBool::VisitCStyleCastExpr(CStyleCastExpr * expr) { StringRef name { Lexer::getImmediateMacroName( loc, compiler.getSourceManager(), compiler.getLangOpts()) }; if (name == "sal_False" || name == "sal_True") { - auto callLoc = compiler.getSourceManager().getSpellingLoc( - compiler.getSourceManager().getImmediateMacroCallerLoc( - loc)); - if (!isFromCIncludeFile(callLoc)) { + auto callLoc = compiler.getSourceManager() + .getImmediateMacroCallerLoc(loc); + if (!isSharedCAndCppCode(callLoc)) { SourceLocation argLoc; if (compat::isMacroArgExpansion( compiler, expr->getLocStart(), &argLoc) @@ -301,17 +306,19 @@ bool SalBool::VisitCStyleCastExpr(CStyleCastExpr * expr) { } bool b = name == "sal_True"; if (rewriter != nullptr) { + auto callSpellLoc = compiler.getSourceManager() + .getSpellingLoc(callLoc); unsigned n = Lexer::MeasureTokenLength( - callLoc, compiler.getSourceManager(), + callSpellLoc, compiler.getSourceManager(), compiler.getLangOpts()); if (StringRef( compiler.getSourceManager().getCharacterData( - callLoc), + callSpellLoc), n) == name) { return replaceText( - callLoc, n, b ? "true" : "false"); + callSpellLoc, n, b ? "true" : "false"); } } report( @@ -725,6 +732,15 @@ bool SalBool::TraverseStaticAssertDecl(StaticAssertDecl * decl) { || RecursiveASTVisitor::TraverseStaticAssertDecl(decl); } +bool SalBool::TraverseLinkageSpecDecl(LinkageSpecDecl * decl) { + assert(externCContexts_ != std::numeric_limits<unsigned int>::max()); //TODO + ++externCContexts_; + bool ret = RecursiveASTVisitor::TraverseLinkageSpecDecl(decl); + assert(externCContexts_ != 0); + --externCContexts_; + return ret; +} + bool SalBool::isFromCIncludeFile(SourceLocation spellingLocation) const { return !compiler.getSourceManager().isInMainFile(spellingLocation) && (StringRef( @@ -733,6 +749,16 @@ bool SalBool::isFromCIncludeFile(SourceLocation spellingLocation) const { .endswith(".h")); } +bool SalBool::isSharedCAndCppCode(SourceLocation location) const { + // Assume that code is intended to be shared between C and C++ if it comes + // from an include file ending in .h, and is either in an extern "C" context + // or the body of a macro definition: + return + isFromCIncludeFile(compiler.getSourceManager().getSpellingLoc(location)) + && (externCContexts_ != 0 + || compiler.getSourceManager().isMacroBodyExpansion(location)); +} + bool SalBool::isInSpecialMainFile(SourceLocation spellingLocation) const { if (!compiler.getSourceManager().isInMainFile(spellingLocation)) { return false; diff --git a/framework/inc/properties.h b/framework/inc/properties.h index 383225ffeece..78f4701b9412 100644 --- a/framework/inc/properties.h +++ b/framework/inc/properties.h @@ -157,7 +157,7 @@ class PropHelper css::uno::Any& aOldValue , css::uno::Any& aChangedValue ) { - bool bChanged = sal_False; + bool bChanged = false; // clear return parameter to be sure, to put out only valid values ... aOldValue.clear(); diff --git a/framework/inc/protocols.h b/framework/inc/protocols.h index d729d6f72235..b93f292e0f15 100644 --- a/framework/inc/protocols.h +++ b/framework/inc/protocols.h @@ -82,7 +82,7 @@ class ProtocolCheck */ static bool isProtocol( const OUString& sURL, EProtocol eRequired ) { - bool bRet = sal_False; + bool bRet = false; switch(eRequired) { case E_PRIVATE: @@ -116,7 +116,7 @@ class ProtocolCheck bRet = sURL.startsWith(SPECIALPROTOCOL_NEWS); break; default: - bRet = sal_False; + bRet = false; break; } return bRet; diff --git a/include/cppuhelper/interfacecontainer.h b/include/cppuhelper/interfacecontainer.h index 07b296e5b7d2..2a88f39e5648 100644 --- a/include/cppuhelper/interfacecontainer.h +++ b/include/cppuhelper/interfacecontainer.h @@ -450,8 +450,8 @@ struct OBroadcastHelperVar OBroadcastHelperVar( ::osl::Mutex & rMutex_ ) : rMutex( rMutex_ ) , aLC( rMutex_ ) - , bDisposed( sal_False ) - , bInDispose( sal_False ) + , bDisposed( false ) + , bInDispose( false ) {} /** diff --git a/sal/qa/osl/security/osl_Security_Const.h b/sal/qa/osl/security/osl_Security_Const.h index 84619f0964b2..83dd21f31f14 100644 --- a/sal/qa/osl/security/osl_Security_Const.h +++ b/sal/qa/osl/security/osl_Security_Const.h @@ -51,7 +51,7 @@ const char pTestString[17] = "Sun Microsystems"; ::rtl::OUString strUserName, strComputerName, strHomeDirectory; ::rtl::OUString strConfigDirectory, strUserID; -bool isAdmin = sal_False; +bool isAdmin = false; #endif // INCLUDED_SAL_QA_OSL_SECURITY_OSL_SECURITY_CONST_H |