Reformat clang-plugin.cpp using clang-format, no bug

This commit is contained in:
Ehsan Akhgari 2016-02-05 10:29:26 -05:00
Родитель ef18719332
Коммит b49b986147
1 изменённых файлов: 46 добавлений и 41 удалений

Просмотреть файл

@ -5,8 +5,8 @@
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/Basic/Version.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendPluginRegistry.h"
@ -986,7 +986,8 @@ DiagnosticsMatcher::DiagnosticsMatcher() {
// lambda, where the declaration they reference is not inside the lambda.
// This excludes arguments and local variables, leaving only captured
// variables.
astMatcher.addMatcher(lambdaExpr().bind("lambda"), &refCountedInsideLambdaChecker);
astMatcher.addMatcher(lambdaExpr().bind("lambda"),
&refCountedInsideLambdaChecker);
// Older clang versions such as the ones used on the infra recognize these
// conversions as 'operator _Bool', but newer clang versions recognize these
@ -1015,24 +1016,26 @@ DiagnosticsMatcher::DiagnosticsMatcher() {
.bind("specialization"),
&nonMemMovableChecker);
astMatcher.addMatcher(
cxxConstructorDecl(isInterestingImplicitCtor(),
ofClass(allOf(isConcreteClass(), decl().bind("class"))),
unless(isMarkedImplicit()))
.bind("ctor"),
&explicitImplicitChecker);
astMatcher.addMatcher(cxxConstructorDecl(isInterestingImplicitCtor(),
ofClass(allOf(isConcreteClass(),
decl().bind("class"))),
unless(isMarkedImplicit()))
.bind("ctor"),
&explicitImplicitChecker);
astMatcher.addMatcher(varDecl(hasType(autoNonAutoableType())).bind("node"),
&noAutoTypeChecker);
astMatcher.addMatcher(cxxConstructorDecl(isExplicitMoveConstructor()).bind("node"),
&noExplicitMoveConstructorChecker);
astMatcher.addMatcher(
cxxConstructorDecl(isExplicitMoveConstructor()).bind("node"),
&noExplicitMoveConstructorChecker);
astMatcher.addMatcher(cxxConstructExpr(hasDeclaration(
cxxConstructorDecl(
isCompilerProvidedCopyConstructor(),
ofClass(hasRefCntMember())))).bind("node"),
&refCountedCopyConstructorChecker);
astMatcher.addMatcher(
cxxConstructExpr(
hasDeclaration(cxxConstructorDecl(isCompilerProvidedCopyConstructor(),
ofClass(hasRefCntMember()))))
.bind("node"),
&refCountedCopyConstructorChecker);
}
// These enum variants determine whether an allocation has occured in the code.
@ -1047,7 +1050,8 @@ enum AllocationVariety {
// XXX Currently the Decl* in the AutomaticTemporaryMap is unused, but it
// probably will be used at some point in the future, in order to produce better
// error messages.
typedef DenseMap<const MaterializeTemporaryExpr *, const Decl *> AutomaticTemporaryMap;
typedef DenseMap<const MaterializeTemporaryExpr *, const Decl *>
AutomaticTemporaryMap;
AutomaticTemporaryMap AutomaticTemporaries;
void DiagnosticsMatcher::ScopeChecker::run(
@ -1059,9 +1063,11 @@ void DiagnosticsMatcher::ScopeChecker::run(
SourceLocation Loc;
QualType T;
if (const ParmVarDecl *D = Result.Nodes.getNodeAs<ParmVarDecl>("parm_vardecl")) {
if (const ParmVarDecl *D =
Result.Nodes.getNodeAs<ParmVarDecl>("parm_vardecl")) {
if (const Expr *Default = D->getDefaultArg()) {
if (const MaterializeTemporaryExpr *E = dyn_cast<MaterializeTemporaryExpr>(Default)) {
if (const MaterializeTemporaryExpr *E =
dyn_cast<MaterializeTemporaryExpr>(Default)) {
// We have just found a ParmVarDecl which has, as its default argument,
// a MaterializeTemporaryExpr. We mark that MaterializeTemporaryExpr as
// automatic, by adding it to the AutomaticTemporaryMap.
@ -1100,18 +1106,17 @@ void DiagnosticsMatcher::ScopeChecker::run(
// XXX We maybe should mark these lifetimes as being due to a temporary
// which has had its lifetime extended, to improve the error messages.
switch (E->getStorageDuration()) {
case SD_FullExpression:
{
// Check if this temporary is allocated as a default argument!
// if it is, we want to pretend that it is automatic.
AutomaticTemporaryMap::iterator AutomaticTemporary = AutomaticTemporaries.find(E);
if (AutomaticTemporary != AutomaticTemporaries.end()) {
Variety = AV_Automatic;
} else {
Variety = AV_Temporary;
}
case SD_FullExpression: {
// Check if this temporary is allocated as a default argument!
// if it is, we want to pretend that it is automatic.
AutomaticTemporaryMap::iterator AutomaticTemporary =
AutomaticTemporaries.find(E);
if (AutomaticTemporary != AutomaticTemporaries.end()) {
Variety = AV_Automatic;
} else {
Variety = AV_Temporary;
}
break;
} break;
case SD_Automatic:
Variety = AV_Automatic;
break;
@ -1176,8 +1181,8 @@ void DiagnosticsMatcher::ScopeChecker::run(
case AV_Temporary:
GlobalClass.reportErrorIfPresent(Diag, T, Loc, GlobalID, TemporaryNoteID);
HeapClass.reportErrorIfPresent(Diag, T, Loc, HeapID, TemporaryNoteID);
NonTemporaryClass.reportErrorIfPresent(Diag, T, Loc,
NonTemporaryID, TemporaryNoteID);
NonTemporaryClass.reportErrorIfPresent(Diag, T, Loc, NonTemporaryID,
TemporaryNoteID);
break;
case AV_Heap:
@ -1287,8 +1292,8 @@ void DiagnosticsMatcher::RefCountedInsideLambdaChecker::run(
QualType Pointee = Capture.getCapturedVar()->getType()->getPointeeType();
if (!Pointee.isNull() && isClassRefCounted(Pointee)) {
Diag.Report(Capture.getLocation(), errorID)
<< Capture.getCapturedVar() << Pointee;
Diag.Report(Capture.getLocation(), errorID) << Capture.getCapturedVar()
<< Pointee;
Diag.Report(Capture.getLocation(), noteID);
}
}
@ -1456,7 +1461,7 @@ void DiagnosticsMatcher::NoExplicitMoveConstructorChecker::run(
// Everything we needed to know was checked in the matcher - we just report
// the error here
const CXXConstructorDecl *D =
Result.Nodes.getNodeAs<CXXConstructorDecl>("node");
Result.Nodes.getNodeAs<CXXConstructorDecl>("node");
Diag.Report(D->getLocation(), ErrorID);
}
@ -1468,16 +1473,16 @@ void DiagnosticsMatcher::RefCountedCopyConstructorChecker::run(
DiagnosticIDs::Error, "Invalid use of compiler-provided copy constructor "
"on refcounted type");
unsigned NoteID = Diag.getDiagnosticIDs()->getCustomDiagID(
DiagnosticIDs::Note, "The default copy constructor also copies the "
"default mRefCnt property, leading to reference "
"count imbalance issues. Please provide your own "
"copy constructor which only copies the fields which "
"need to be copied");
DiagnosticIDs::Note,
"The default copy constructor also copies the "
"default mRefCnt property, leading to reference "
"count imbalance issues. Please provide your own "
"copy constructor which only copies the fields which "
"need to be copied");
// Everything we needed to know was checked in the matcher - we just report
// the error here
const CXXConstructExpr *E =
Result.Nodes.getNodeAs<CXXConstructExpr>("node");
const CXXConstructExpr *E = Result.Nodes.getNodeAs<CXXConstructExpr>("node");
Diag.Report(E->getLocation(), ErrorID);
Diag.Report(E->getLocation(), NoteID);