compilerplugins/clang/compat.hxx | 11 +++++++++++ compilerplugins/clang/literaltoboolconversion.cxx | 16 +++++----------- 2 files changed, 16 insertions(+), 11 deletions(-)
New commits: commit b4e5b8bc1d6be0d53843ac68ba86da4d8cd0c2b0 Author: Stephan Bergmann <sberg...@redhat.com> Date: Wed Apr 2 17:53:43 2014 +0200 Add compat::isInMainFile Change-Id: I0e155c6c68a43020110a8e1c0cb29cabdcade454 diff --git a/compilerplugins/clang/compat.hxx b/compilerplugins/clang/compat.hxx index 1f025e7..3d26572 100644 --- a/compilerplugins/clang/compat.hxx +++ b/compilerplugins/clang/compat.hxx @@ -20,6 +20,7 @@ #include "clang/AST/Type.h" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/DiagnosticIDs.h" +#include "clang/Basic/SourceManager.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/raw_ostream.h" @@ -101,6 +102,16 @@ inline unsigned getBuiltinCallee(clang::CallExpr const & expr) { #endif } +inline bool isInMainFile( + clang::SourceManager const & manager, clang::SourceLocation Loc) +{ +#if (__clang_major__ == 3 && __clang_minor__ >= 4) || __clang_major__ > 3 + return manager.isInMainFile(Loc); +#else + return manager.isFromMainFile(Loc); +#endif +} + inline unsigned getCustomDiagID( clang::DiagnosticsEngine & engine, clang::DiagnosticsEngine::Level L, llvm::StringRef FormatString) diff --git a/compilerplugins/clang/literaltoboolconversion.cxx b/compilerplugins/clang/literaltoboolconversion.cxx index c94e0d1..4c3c3a4 100644 --- a/compilerplugins/clang/literaltoboolconversion.cxx +++ b/compilerplugins/clang/literaltoboolconversion.cxx @@ -151,17 +151,11 @@ bool LiteralToBoolConversion::VisitImplicitCastExpr( bool LiteralToBoolConversion::isFromCIncludeFile( SourceLocation spellingLocation) const { -#if (__clang_major__ == 3 && __clang_minor__ >= 4) || __clang_major__ > 3 - if (compiler.getSourceManager().isInMainFile(spellingLocation)) { - return false; - } -#else - if (compiler.getSourceManager().isFromMainFile(spellingLocation)) { - return false; - } -#endif - return StringRef(compiler.getSourceManager().getPresumedLoc(spellingLocation) - .getFilename()).endswith(".h"); + return !compat::isInMainFile(compiler.getSourceManager(), spellingLocation) + && (StringRef( + compiler.getSourceManager().getPresumedLoc(spellingLocation) + .getFilename()) + .endswith(".h")); } bool LiteralToBoolConversion::isMacroBodyExpansion(SourceLocation location) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits