зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1501821 - Update clang-plugin in order to make it compatiable with clang 8.0.0 trunk. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D10806 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
9c21a42638
Коммит
4f5c3e9078
|
@ -50,11 +50,11 @@ void ArithmeticArgChecker::check(const MatchFinder::MatchResult &Result) {
|
|||
"cannot pass an arithmetic expression of built-in types to %0";
|
||||
const Expr *Expression = Result.Nodes.getNodeAs<Expr>("node");
|
||||
if (const CallExpr *Call = Result.Nodes.getNodeAs<CallExpr>("call")) {
|
||||
diag(Expression->getLocStart(), Error, DiagnosticIDs::Error)
|
||||
diag(Expression->getBeginLoc(), Error, DiagnosticIDs::Error)
|
||||
<< Call->getDirectCallee();
|
||||
} else if (const CXXConstructExpr *Ctr =
|
||||
Result.Nodes.getNodeAs<CXXConstructExpr>("call")) {
|
||||
diag(Expression->getLocStart(), Error, DiagnosticIDs::Error)
|
||||
diag(Expression->getBeginLoc(), Error, DiagnosticIDs::Error)
|
||||
<< Ctr->getConstructor();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ void AssertAssignmentChecker::check(const MatchFinder::MatchResult &Result) {
|
|||
const CallExpr *FuncCall = Result.Nodes.getNodeAs<CallExpr>("funcCall");
|
||||
|
||||
if (FuncCall && hasSideEffectAssignment(FuncCall)) {
|
||||
diag(FuncCall->getLocStart(), "Forbidden assignment in assert expression",
|
||||
diag(FuncCall->getBeginLoc(), "Forbidden assignment in assert expression",
|
||||
DiagnosticIDs::Error);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ static void Report(const Decl* D, const char* message)
|
|||
DiagnosticsEngine& Diag = Context.getDiagnostics();
|
||||
unsigned ID = Diag.getDiagnosticIDs()->getCustomDiagID(
|
||||
DiagnosticIDs::Warning, message);
|
||||
Diag.Report(D->getLocStart(), ID);
|
||||
Diag.Report(D->getBeginLoc(), ID);
|
||||
}
|
||||
|
||||
CustomAttributesSet GetAttributes(const Decl* D)
|
||||
|
|
|
@ -220,7 +220,7 @@ void DanglingOnTemporaryChecker::check(const MatchFinder::MatchResult &Result) {
|
|||
<< MemberCall->getSourceRange();
|
||||
|
||||
// We indicate the escape statement.
|
||||
diag(EscapeStmt->getLocStart(), EscapeStmtNote, DiagnosticIDs::Note)
|
||||
diag(EscapeStmt->getBeginLoc(), EscapeStmtNote, DiagnosticIDs::Note)
|
||||
<< EscapeStmt->getSourceRange();
|
||||
|
||||
// We build the escape note along with its source range.
|
||||
|
|
|
@ -25,10 +25,10 @@ void ExplicitOperatorBoolChecker::check(
|
|||
!hasCustomAttribute<moz_implicit>(Method) &&
|
||||
!ASTIsInSystemHeader(Method->getASTContext(), *Method) &&
|
||||
isInterestingDeclForImplicitConversion(Method)) {
|
||||
diag(Method->getLocStart(), "bad implicit conversion operator for %0",
|
||||
diag(Method->getBeginLoc(), "bad implicit conversion operator for %0",
|
||||
DiagnosticIDs::Error)
|
||||
<< Clazz;
|
||||
diag(Method->getLocStart(), "consider adding the explicit keyword to %0",
|
||||
diag(Method->getBeginLoc(), "consider adding the explicit keyword to %0",
|
||||
DiagnosticIDs::Note)
|
||||
<< "'operator bool'";
|
||||
}
|
||||
|
|
|
@ -92,8 +92,8 @@ void KungFuDeathGripChecker::check(const MatchFinder::MatchResult &Result) {
|
|||
}
|
||||
|
||||
// We cannot provide the note if we don't have an initializer
|
||||
diag(D->getLocStart(), Error, DiagnosticIDs::Error)
|
||||
diag(D->getBeginLoc(), Error, DiagnosticIDs::Error)
|
||||
<< D->getType() << ErrThing;
|
||||
diag(E->getLocStart(), Note, DiagnosticIDs::Note)
|
||||
diag(E->getBeginLoc(), Note, DiagnosticIDs::Note)
|
||||
<< NoteThing << getNameChecked(D);
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ void MustReturnFromCallerChecker::check(
|
|||
assert(Block && "This statement should be within the CFG!");
|
||||
|
||||
if (!immediatelyReturns(Block, Result.Context, CallIndex + 1)) {
|
||||
diag(Call->getLocStart(),
|
||||
diag(Call->getBeginLoc(),
|
||||
"You must immediately return after calling this function",
|
||||
DiagnosticIDs::Error);
|
||||
}
|
||||
|
|
|
@ -55,10 +55,10 @@ void MustUseChecker::handleUnusedExprResult(const Stmt *Statement) {
|
|||
E = E->IgnoreImplicit(); // Ignore ExprWithCleanup etc. implicit wrappers
|
||||
QualType T = E->getType();
|
||||
if (MustUse.hasEffectiveAnnotation(T) && !isIgnoredExprForMustUse(E)) {
|
||||
diag(E->getLocStart(), "Unused value of must-use type %0",
|
||||
diag(E->getBeginLoc(), "Unused value of must-use type %0",
|
||||
DiagnosticIDs::Error)
|
||||
<< T;
|
||||
MustUse.dumpAnnotationReason(*this, T, E->getLocStart());
|
||||
MustUse.dumpAnnotationReason(*this, T, E->getBeginLoc());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,11 +46,11 @@ void NaNExprChecker::check(const MatchFinder::MatchResult &Result) {
|
|||
std::distance(LHSExpr->child_begin(), LHSExpr->child_end()) == 1 &&
|
||||
std::distance(RHSExpr->child_begin(), RHSExpr->child_end()) == 1 &&
|
||||
*LHSExpr->child_begin() == LHS && *RHSExpr->child_begin() == RHS) {
|
||||
diag(Expression->getLocStart(),
|
||||
diag(Expression->getBeginLoc(),
|
||||
"comparing a floating point value to itself for "
|
||||
"NaN checking can lead to incorrect results",
|
||||
DiagnosticIDs::Error);
|
||||
diag(Expression->getLocStart(), "consider using mozilla::IsNaN instead",
|
||||
diag(Expression->getBeginLoc(), "consider using mozilla::IsNaN instead",
|
||||
DiagnosticIDs::Note);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ void NeedsNoVTableTypeChecker::check(const MatchFinder::MatchResult &Result) {
|
|||
}
|
||||
}
|
||||
|
||||
diag(Specialization->getLocStart(),
|
||||
diag(Specialization->getBeginLoc(),
|
||||
"%0 cannot be instantiated because %1 has a VTable",
|
||||
DiagnosticIDs::Error)
|
||||
<< Specialization << Offender;
|
||||
|
|
|
@ -22,7 +22,7 @@ void NoAddRefReleaseOnReturnChecker::check(
|
|||
if (auto *Call = dyn_cast<CallExpr>(Base)) {
|
||||
if (auto *Callee = Call->getDirectCallee()) {
|
||||
if (hasCustomAttribute<moz_no_addref_release_on_return>(Callee)) {
|
||||
diag(Call->getLocStart(),
|
||||
diag(Call->getBeginLoc(),
|
||||
"%1 cannot be called on the return value of %0",
|
||||
DiagnosticIDs::Error)
|
||||
<< Callee << dyn_cast<CXXMethodDecl>(Member->getMemberDecl());
|
||||
|
|
|
@ -39,10 +39,10 @@ void NoDuplicateRefCntMemberChecker::check(
|
|||
const char *Note2 =
|
||||
"Consider using the _INHERITED macros for AddRef and Release here";
|
||||
|
||||
diag(D->getLocStart(), Error, DiagnosticIDs::Error) << D;
|
||||
diag(BaseRefCntMember->getLocStart(), Note1, DiagnosticIDs::Note)
|
||||
diag(D->getBeginLoc(), Error, DiagnosticIDs::Error) << D;
|
||||
diag(BaseRefCntMember->getBeginLoc(), Note1, DiagnosticIDs::Note)
|
||||
<< BaseRefCntMember->getParent();
|
||||
diag(RefCntMember->getLocStart(), Note2, DiagnosticIDs::Note);
|
||||
diag(RefCntMember->getBeginLoc(), Note2, DiagnosticIDs::Note);
|
||||
}
|
||||
|
||||
if (FoundRefCntBase) {
|
||||
|
@ -51,10 +51,10 @@ void NoDuplicateRefCntMemberChecker::check(
|
|||
const char *Note = "Superclass %0 has an mRefCnt member";
|
||||
|
||||
// superclass has mRefCnt, and another superclass also has an mRefCnt
|
||||
diag(D->getLocStart(), Error, DiagnosticIDs::Error) << D;
|
||||
diag(BaseRefCntMember->getLocStart(), Note, DiagnosticIDs::Note)
|
||||
diag(D->getBeginLoc(), Error, DiagnosticIDs::Error) << D;
|
||||
diag(BaseRefCntMember->getBeginLoc(), Note, DiagnosticIDs::Note)
|
||||
<< BaseRefCntMember->getParent();
|
||||
diag(FoundRefCntBase->getLocStart(), Note, DiagnosticIDs::Note)
|
||||
diag(FoundRefCntBase->getBeginLoc(), Note, DiagnosticIDs::Note)
|
||||
<< FoundRefCntBase->getParent();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,10 +25,10 @@ void ParamTraitsEnumChecker::check(const MatchFinder::MatchResult &Result) {
|
|||
}
|
||||
|
||||
if (TypePtr->isEnumeralType()) {
|
||||
diag(Decl->getLocStart(),
|
||||
diag(Decl->getBeginLoc(),
|
||||
"Custom ParamTraits implementation for an enum type",
|
||||
DiagnosticIDs::Error);
|
||||
diag(Decl->getLocStart(),
|
||||
diag(Decl->getBeginLoc(),
|
||||
"Please use a helper class for example ContiguousEnumSerializer",
|
||||
DiagnosticIDs::Note);
|
||||
}
|
||||
|
|
|
@ -144,7 +144,7 @@ bool RefCountedInsideLambdaChecker::ThisVisitor::VisitCXXThisExpr(
|
|||
CXXThisExpr *This) {
|
||||
QualType Pointee = This->getType()->getPointeeType();
|
||||
if (!Pointee.isNull() && isClassRefCounted(Pointee)) {
|
||||
Checker.emitDiagnostics(This->getLocStart(), "this", Pointee);
|
||||
Checker.emitDiagnostics(This->getBeginLoc(), "this", Pointee);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ void ScopeChecker::check(const MatchFinder::MatchResult &Result) {
|
|||
Variety = AV_Automatic;
|
||||
}
|
||||
T = D->getType();
|
||||
Loc = D->getLocStart();
|
||||
Loc = D->getBeginLoc();
|
||||
} else if (const CXXNewExpr *E = Result.Nodes.getNodeAs<CXXNewExpr>("node")) {
|
||||
// New allocates things on the heap.
|
||||
// We don't consider placement new to do anything, as it doesn't actually
|
||||
|
@ -73,7 +73,7 @@ void ScopeChecker::check(const MatchFinder::MatchResult &Result) {
|
|||
if (!isPlacementNew(E)) {
|
||||
Variety = AV_Heap;
|
||||
T = E->getAllocatedType();
|
||||
Loc = E->getLocStart();
|
||||
Loc = E->getBeginLoc();
|
||||
}
|
||||
} else if (const MaterializeTemporaryExpr *E =
|
||||
Result.Nodes.getNodeAs<MaterializeTemporaryExpr>("node")) {
|
||||
|
@ -108,14 +108,14 @@ void ScopeChecker::check(const MatchFinder::MatchResult &Result) {
|
|||
break;
|
||||
}
|
||||
T = E->getType().getUnqualifiedType();
|
||||
Loc = E->getLocStart();
|
||||
Loc = E->getBeginLoc();
|
||||
} else if (const CallExpr *E = Result.Nodes.getNodeAs<CallExpr>("node")) {
|
||||
T = E->getType()->getPointeeType();
|
||||
if (!T.isNull()) {
|
||||
// This will always allocate on the heap, as the heapAllocator() check
|
||||
// was made in the matcher
|
||||
Variety = AV_Heap;
|
||||
Loc = E->getLocStart();
|
||||
Loc = E->getBeginLoc();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,8 +53,8 @@ void SprintfLiteralChecker::check(const MatchFinder::MatchResult &Result) {
|
|||
return;
|
||||
}
|
||||
|
||||
diag(D->getLocStart(), Error, DiagnosticIDs::Error) << Name << Replacement;
|
||||
diag(D->getLocStart(), Note, DiagnosticIDs::Note) << Name;
|
||||
diag(D->getBeginLoc(), Error, DiagnosticIDs::Error) << Name << Replacement;
|
||||
diag(D->getBeginLoc(), Note, DiagnosticIDs::Note) << Name;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -76,9 +76,9 @@ void SprintfLiteralChecker::check(const MatchFinder::MatchResult &Result) {
|
|||
uint64_t Size = Type->getSize().getZExtValue();
|
||||
uint64_t Lit = Literal->getValue().getZExtValue();
|
||||
if (Size <= Lit) {
|
||||
diag(D->getLocStart(), Error, DiagnosticIDs::Error)
|
||||
diag(D->getBeginLoc(), Error, DiagnosticIDs::Error)
|
||||
<< Name << Replacement;
|
||||
diag(D->getLocStart(), Note, DiagnosticIDs::Note) << Name;
|
||||
diag(D->getBeginLoc(), Note, DiagnosticIDs::Note) << Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,5 +25,5 @@ void TrivialCtorDtorChecker::check(const MatchFinder::MatchResult &Result) {
|
|||
Node->hasTrivialDefaultConstructor());
|
||||
bool BadDtor = !Node->hasTrivialDestructor();
|
||||
if (BadCtor || BadDtor)
|
||||
diag(Node->getLocStart(), Error, DiagnosticIDs::Error) << Node;
|
||||
diag(Node->getBeginLoc(), Error, DiagnosticIDs::Error) << Node;
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ inline bool hasSideEffectAssignment(const Expr *Expression) {
|
|||
template <class T>
|
||||
inline bool ASTIsInSystemHeader(const ASTContext &AC, const T &D) {
|
||||
auto &SourceManager = AC.getSourceManager();
|
||||
auto ExpansionLoc = SourceManager.getExpansionLoc(D.getLocStart());
|
||||
auto ExpansionLoc = SourceManager.getExpansionLoc(D.getBeginLoc());
|
||||
if (ExpansionLoc.isInvalid()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ inline bool isIgnoredPathForImplicitConversion(const Decl *Declaration) {
|
|||
|
||||
inline bool isIgnoredPathForSprintfLiteral(const CallExpr *Call,
|
||||
const SourceManager &SM) {
|
||||
SourceLocation Loc = Call->getLocStart();
|
||||
SourceLocation Loc = Call->getBeginLoc();
|
||||
SmallString<1024> FileName = SM.getFilename(Loc);
|
||||
llvm::sys::fs::make_absolute(FileName);
|
||||
llvm::sys::path::reverse_iterator Begin = llvm::sys::path::rbegin(FileName),
|
||||
|
@ -428,7 +428,7 @@ inline bool inThirdPartyPath(const Decl *D) {
|
|||
}
|
||||
|
||||
inline bool inThirdPartyPath(const Stmt *S, ASTContext *context) {
|
||||
SourceLocation Loc = S->getLocStart();
|
||||
SourceLocation Loc = S->getBeginLoc();
|
||||
const SourceManager &SM = context->getSourceManager();
|
||||
auto ExpansionLoc = SM.getExpansionLoc(Loc);
|
||||
if (ExpansionLoc.isInvalid()) {
|
||||
|
|
|
@ -34,6 +34,12 @@
|
|||
#include "JSONFormatter.h"
|
||||
#include "StringOperations.h"
|
||||
|
||||
#if CLANG_VERSION_FULL < 800
|
||||
// Starting with Clang 8.0 some basic functions have been renamed
|
||||
#define getBeginLoc getLocStart
|
||||
#define getEndLoc getLocEnd
|
||||
#endif
|
||||
|
||||
using namespace clang;
|
||||
|
||||
const std::string GENERATED("__GENERATED__" PATHSEP_STRING);
|
||||
|
@ -1021,7 +1027,7 @@ public:
|
|||
// the parameters in that case.
|
||||
if (ParamLoc.first == FuncLoc.first) {
|
||||
// Assume parameters are in order, so we always take the last one.
|
||||
End = Param->getLocEnd();
|
||||
End = Param->getEndLoc();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1039,13 +1045,13 @@ public:
|
|||
if (CXXRecordDecl* D2 = dyn_cast<CXXRecordDecl>(D)) {
|
||||
// But if there are parameters, we want to include those as well.
|
||||
for (CXXBaseSpecifier& Base : D2->bases()) {
|
||||
std::pair<FileID, unsigned> Loc = SM.getDecomposedLoc(Base.getLocEnd());
|
||||
std::pair<FileID, unsigned> Loc = SM.getDecomposedLoc(Base.getEndLoc());
|
||||
|
||||
// It's possible there are macros involved or something. We don't include
|
||||
// the parameters in that case.
|
||||
if (Loc.first == FuncLoc.first) {
|
||||
// Assume parameters are in order, so we always take the last one.
|
||||
End = Base.getLocEnd();
|
||||
End = Base.getEndLoc();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1128,7 +1134,7 @@ public:
|
|||
int Flags = 0;
|
||||
const char *Kind = "def";
|
||||
const char *PrettyKind = "?";
|
||||
SourceRange PeekRange(D->getLocStart(), D->getLocEnd());
|
||||
SourceRange PeekRange(D->getBeginLoc(), D->getEndLoc());
|
||||
if (FunctionDecl *D2 = dyn_cast<FunctionDecl>(D)) {
|
||||
if (D2->isTemplateInstantiation()) {
|
||||
D = D2->getTemplateInstantiationPattern();
|
||||
|
|
|
@ -33,6 +33,12 @@ typedef std::unique_ptr<ASTConsumer> ASTConsumerPtr;
|
|||
typedef ASTConsumer *ASTConsumerPtr;
|
||||
#endif
|
||||
|
||||
#if CLANG_VERSION_FULL < 800
|
||||
// Starting with Clang 8.0 some basic functions have been renamed
|
||||
#define getBeginLoc getLocStart
|
||||
#define getEndLoc getLocEnd
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_NEW_ASTMATCHER_NAMES
|
||||
// In clang 3.8, a number of AST matchers were renamed to better match the
|
||||
// respective AST node. We use the new names, and #define them to the old
|
||||
|
|
Загрузка…
Ссылка в новой задаче