diff options
Diffstat (limited to 'src/Utils.h')
-rw-r--r-- | src/Utils.h | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/Utils.h b/src/Utils.h index 49dbc8a1..dd92a961 100644 --- a/src/Utils.h +++ b/src/Utils.h @@ -26,7 +26,9 @@ #define MOREWARNINGS_UTILS_H #include "clazy_export.h" +#include "SourceCompatibilityHelpers.h" +#include <clang/Basic/SourceManager.h> #include <clang/AST/DeclCXX.h> #include <clang/AST/Expr.h> #include <clang/AST/ExprCXX.h> @@ -127,18 +129,18 @@ namespace Utils { CLAZYLIB_EXPORT bool containsStringLiteral(clang::Stmt *, bool allowEmpty = true, int depth = -1); CLAZYLIB_EXPORT bool isInsideOperatorCall(clang::ParentMap *map, clang::Stmt *s, - const std::vector<std::string> &anyOf); + const std::vector<llvm::StringRef> &anyOf); CLAZYLIB_EXPORT bool insideCTORCall(clang::ParentMap *map, clang::Stmt *s, - const std::vector<std::string> &anyOf); + const std::vector<llvm::StringRef> &anyOf); // returns true if the ternary operator has two string literal arguments, such as: // foo ? "bar" : "baz" CLAZYLIB_EXPORT bool ternaryOperatorIsOfStringLiteral(clang::ConditionalOperator*); CLAZYLIB_EXPORT bool isAssignOperator(clang::CXXOperatorCallExpr *op, - const std::string &className, - const std::string &argumentType, const clang::LangOptions &lo); + llvm::StringRef className, + llvm::StringRef argumentType, const clang::LangOptions &lo); CLAZYLIB_EXPORT bool isImplicitCastTo(clang::Stmt *, const std::string &); @@ -274,10 +276,26 @@ namespace Utils { const clang::SourceManager &sm, const clang::LangOptions &lo); + inline bool isMainFile(const clang::SourceManager &sm, clang::SourceLocation loc) + { + if (loc.isMacroID()) + loc = sm.getExpansionLoc(loc); + + return sm.isInFileID(loc, sm.getMainFileID()); + } + /** * Returns true if the string literal contains escaped bytes, such as \x12, \123, \u00F6. */ bool literalContainsEscapedBytes(clang::StringLiteral *lt, const clang::SourceManager &sm, const clang::LangOptions &lo); + + /** + * Returns true if this method overrides one from the base class + */ + inline bool methodOverrides(clang::CXXMethodDecl *method) + { + return method && method->isVirtual() && method->size_overridden_methods() > 0; + } } #endif |