Format all lines with leading =

This is the unadorned output of:

    git grep -En "^\s*=" -- ':!tests/*' | grep-format

There are some examples with comments between the variable name and the
'=' that clang-format left unchanged.

No functional change.
This commit is contained in:
Kim Gräsman 2023-01-03 23:00:07 +01:00
parent 890a3150d7
commit b65c4b63a7
6 changed files with 90 additions and 95 deletions

78
iwyu.cc
View File

@ -571,8 +571,8 @@ class BaseAstVisitor : public RecursiveASTVisitor<Derived> {
const NamedDecl* member_decl = TypeToDeclAsWritten(type); const NamedDecl* member_decl = TypeToDeclAsWritten(type);
// We only want those fields that are c++ classes. // We only want those fields that are c++ classes.
if (const CXXRecordDecl* cxx_field_decl = DynCastFrom(member_decl)) { if (const CXXRecordDecl* cxx_field_decl = DynCastFrom(member_decl)) {
if (const CXXDestructorDecl* field_dtor if (const CXXDestructorDecl* field_dtor =
= cxx_field_decl->getDestructor()) { cxx_field_decl->getDestructor()) {
if (!this->getDerived().TraverseImplicitDestructorCall( if (!this->getDerived().TraverseImplicitDestructorCall(
const_cast<CXXDestructorDecl*>(field_dtor), type)) const_cast<CXXDestructorDecl*>(field_dtor), type))
return false; return false;
@ -864,8 +864,8 @@ class AstFlattenerVisitor : public BaseAstVisitor<AstFlattenerVisitor> {
bool Contains(const ASTNode& node) const { bool Contains(const ASTNode& node) const {
if (const TypeLoc* tl = node.GetAs<TypeLoc>()) { if (const TypeLoc* tl = node.GetAs<TypeLoc>()) {
return ContainsValue(typelocs, *tl); return ContainsValue(typelocs, *tl);
} else if (const NestedNameSpecifierLoc* nl } else if (const NestedNameSpecifierLoc* nl =
= node.GetAs<NestedNameSpecifierLoc>()) { node.GetAs<NestedNameSpecifierLoc>()) {
return ContainsValue(nnslocs, *nl); return ContainsValue(nnslocs, *nl);
} else if (const TemplateName* tn = node.GetAs<TemplateName>()) { } else if (const TemplateName* tn = node.GetAs<TemplateName>()) {
// The best we can do is to compare the associated decl // The best we can do is to compare the associated decl
@ -881,7 +881,7 @@ class AstFlattenerVisitor : public BaseAstVisitor<AstFlattenerVisitor> {
(void)ta; (void)ta;
return false; return false;
} else if (const TemplateArgumentLoc* tal = } else if (const TemplateArgumentLoc* tal =
node.GetAs<TemplateArgumentLoc>()) { node.GetAs<TemplateArgumentLoc>()) {
// TODO(csilvers): figure out how to compare template argument-locs // TODO(csilvers): figure out how to compare template argument-locs
(void)tal; (void)tal;
return false; return false;
@ -1440,10 +1440,10 @@ class IwyuBaseAstVisitor : public BaseAstVisitor<Derived> {
// //
// for type 'reference' it will return type T with which Foo was instantiated. // for type 'reference' it will return type T with which Foo was instantiated.
const Type* DesugarDependentTypedef(const TypedefType* typedef_type) { const Type* DesugarDependentTypedef(const TypedefType* typedef_type) {
const DeclContext* parent const DeclContext* parent =
= typedef_type->getDecl()->getLexicalDeclContext(); typedef_type->getDecl()->getLexicalDeclContext();
if (const ClassTemplateSpecializationDecl* template_parent if (const ClassTemplateSpecializationDecl* template_parent =
= DynCastFrom(parent)) { DynCastFrom(parent)) {
return DesugarDependentTypedef(typedef_type, template_parent); return DesugarDependentTypedef(typedef_type, template_parent);
} }
return typedef_type; return typedef_type;
@ -1451,8 +1451,8 @@ class IwyuBaseAstVisitor : public BaseAstVisitor<Derived> {
const Type* DesugarDependentTypedef( const Type* DesugarDependentTypedef(
const TypedefType* typedef_type, const RecordDecl* parent) { const TypedefType* typedef_type, const RecordDecl* parent) {
const Type* underlying_type const Type* underlying_type =
= typedef_type->getDecl()->getUnderlyingType().getTypePtr(); typedef_type->getDecl()->getUnderlyingType().getTypePtr();
if (const TypedefType* underlying_typedef = DynCastFrom(underlying_type)) { if (const TypedefType* underlying_typedef = DynCastFrom(underlying_type)) {
if (underlying_typedef->getDecl()->getLexicalDeclContext() == parent) { if (underlying_typedef->getDecl()->getLexicalDeclContext() == parent) {
return DesugarDependentTypedef(underlying_typedef, parent); return DesugarDependentTypedef(underlying_typedef, parent);
@ -1476,8 +1476,8 @@ class IwyuBaseAstVisitor : public BaseAstVisitor<Derived> {
} }
} }
const Type* deref_type const Type* deref_type =
= RemovePointersAndReferencesAsWritten(underlying_type); RemovePointersAndReferencesAsWritten(underlying_type);
if (isa<SubstTemplateTypeParmType>(underlying_type) || if (isa<SubstTemplateTypeParmType>(underlying_type) ||
CodeAuthorWantsJustAForwardDeclare(deref_type, GetLocation(decl))) { CodeAuthorWantsJustAForwardDeclare(deref_type, GetLocation(decl))) {
retval.insert(deref_type); retval.insert(deref_type);
@ -1622,8 +1622,8 @@ class IwyuBaseAstVisitor : public BaseAstVisitor<Derived> {
// underlying type. Instead, users of that typedef are. // underlying type. Instead, users of that typedef are.
const ASTNode* ast_node = MostElaboratedAncestor(current_ast_node()); const ASTNode* ast_node = MostElaboratedAncestor(current_ast_node());
if (!ast_node->ParentIsA<TypedefNameDecl>()) { if (!ast_node->ParentIsA<TypedefNameDecl>()) {
const set<const Type*>& underlying_types const set<const Type*>& underlying_types =
= GetCallerResponsibleTypesForTypedef(typedef_decl); GetCallerResponsibleTypesForTypedef(typedef_decl);
if (!underlying_types.empty()) { if (!underlying_types.empty()) {
VERRS(6) << "User, not author, of typedef " VERRS(6) << "User, not author, of typedef "
<< typedef_decl->getQualifiedNameAsString() << typedef_decl->getQualifiedNameAsString()
@ -1782,8 +1782,8 @@ class IwyuBaseAstVisitor : public BaseAstVisitor<Derived> {
if (CanIgnoreCurrentASTNode()) if (CanIgnoreCurrentASTNode())
return true; return true;
const Type* underlying_type = decl->getUnderlyingType().getTypePtr(); const Type* underlying_type = decl->getUnderlyingType().getTypePtr();
const Type* deref_type const Type* deref_type =
= RemovePointersAndReferencesAsWritten(underlying_type); RemovePointersAndReferencesAsWritten(underlying_type);
if (CodeAuthorWantsJustAForwardDeclare(deref_type, GetLocation(decl)) || if (CodeAuthorWantsJustAForwardDeclare(deref_type, GetLocation(decl)) ||
isa<SubstTemplateTypeParmType>(underlying_type)) { isa<SubstTemplateTypeParmType>(underlying_type)) {
@ -1839,16 +1839,16 @@ class IwyuBaseAstVisitor : public BaseAstVisitor<Derived> {
// ...except the return value. // ...except the return value.
const Type* return_type = Desugar(decl->getReturnType().getTypePtr()); const Type* return_type = Desugar(decl->getReturnType().getTypePtr());
const bool is_responsible_for_return_type const bool is_responsible_for_return_type =
= (!CanIgnoreType(return_type) && (!CanIgnoreType(return_type) &&
!IsPointerOrReferenceAsWritten(return_type) && !IsPointerOrReferenceAsWritten(return_type) &&
!CodeAuthorWantsJustAForwardDeclare(return_type, GetLocation(decl))); !CodeAuthorWantsJustAForwardDeclare(return_type, GetLocation(decl)));
// Don't bother to report here, when the language agrees with us // Don't bother to report here, when the language agrees with us
// we need the full type; that will be reported elsewhere, so // we need the full type; that will be reported elsewhere, so
// reporting here would be double-counting. // reporting here would be double-counting.
const bool type_use_reported_in_visit_function_type const bool type_use_reported_in_visit_function_type =
= (!current_ast_node()->in_forward_declare_context() || (!current_ast_node()->in_forward_declare_context() ||
!IsClassType(return_type)); !IsClassType(return_type));
if (is_responsible_for_return_type && if (is_responsible_for_return_type &&
!type_use_reported_in_visit_function_type) { !type_use_reported_in_visit_function_type) {
ReportTypeUse(GetLocation(decl), return_type, "(for fn return type)"); ReportTypeUse(GetLocation(decl), return_type, "(for fn return type)");
@ -2129,7 +2129,7 @@ class IwyuBaseAstVisitor : public BaseAstVisitor<Derived> {
const Expr* base_expr = expr->getBase()->IgnoreParenImpCasts(); const Expr* base_expr = expr->getBase()->IgnoreParenImpCasts();
const Type* base_type = GetTypeOf(base_expr); const Type* base_type = GetTypeOf(base_expr);
CHECK_(base_type && "Member's base does not have a type?"); CHECK_(base_type && "Member's base does not have a type?");
const Type* deref_base_type // For myvar->a, base-type will have a * const Type* deref_base_type // For myvar->a, base-type will have a *
= expr->isArrow() ? RemovePointerFromType(base_type) : base_type; = expr->isArrow() ? RemovePointerFromType(base_type) : base_type;
if (CanIgnoreType(base_type) && CanIgnoreType(deref_base_type)) if (CanIgnoreType(base_type) && CanIgnoreType(deref_base_type))
return true; return true;
@ -2566,8 +2566,8 @@ class IwyuBaseAstVisitor : public BaseAstVisitor<Derived> {
fn_type = current_ast_node()->template GetParentAs<FunctionProtoType>(); fn_type = current_ast_node()->template GetParentAs<FunctionProtoType>();
} }
if (!fn_type) { if (!fn_type) {
if (const FunctionDecl* fn_decl if (const FunctionDecl* fn_decl =
= current_ast_node()->template GetParentAs<FunctionDecl>()) current_ast_node()->template GetParentAs<FunctionDecl>())
fn_type = dyn_cast<FunctionProtoType>(GetTypeOf(fn_decl)); fn_type = dyn_cast<FunctionProtoType>(GetTypeOf(fn_decl));
} }
if (fn_type) { if (fn_type) {
@ -3410,8 +3410,8 @@ class InstantiatedTemplateVisitor
// them here. // them here.
AstFlattenerVisitor nodeset_getter(compiler()); AstFlattenerVisitor nodeset_getter(compiler());
// This gets to the decl for the (uninstantiated) template-as-written: // This gets to the decl for the (uninstantiated) template-as-written:
const FunctionDecl* decl_as_written const FunctionDecl* decl_as_written =
= fn_decl->getTemplateInstantiationPattern(); fn_decl->getTemplateInstantiationPattern();
if (!decl_as_written) { if (!decl_as_written) {
if (fn_decl->isImplicit()) { // TIP not set up for implicit methods if (fn_decl->isImplicit()) { // TIP not set up for implicit methods
// TODO(csilvers): handle implicit template methods // TODO(csilvers): handle implicit template methods
@ -3609,8 +3609,8 @@ class InstantiatedTemplateVisitor
if (resugared_type && !resugared_type->isPointerType()) { if (resugared_type && !resugared_type->isPointerType()) {
ReportTypeUse(caller_loc(), resugared_type); ReportTypeUse(caller_loc(), resugared_type);
// For a templated type, check the template args as well. // For a templated type, check the template args as well.
if (const TemplateSpecializationType* spec_type if (const TemplateSpecializationType* spec_type =
= DynCastFrom(resugared_type)) { DynCastFrom(resugared_type)) {
TraverseDataAndTypeMembersOfClassHelper(spec_type); TraverseDataAndTypeMembersOfClassHelper(spec_type);
} }
} }
@ -3757,8 +3757,8 @@ class IwyuAstConsumer
if (compiler()->getDiagnostics().hasUnrecoverableErrorOccurred()) if (compiler()->getDiagnostics().hasUnrecoverableErrorOccurred())
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
const set<const FileEntry*>* const files_to_report_iwyu_violations_for const set<const FileEntry*>* const files_to_report_iwyu_violations_for =
= preprocessor_info().files_to_report_iwyu_violations_for(); preprocessor_info().files_to_report_iwyu_violations_for();
// Some analysis, such as UsingDecl resolution, is deferred until the // Some analysis, such as UsingDecl resolution, is deferred until the
// entire AST is visited because it's only at that point that we know if // entire AST is visited because it's only at that point that we know if
@ -4199,8 +4199,8 @@ class IwyuAstConsumer
// If we're not in a forward-declare context, use of a template // If we're not in a forward-declare context, use of a template
// specialization requires having the full type information. // specialization requires having the full type information.
if (!CanForwardDeclareType(current_ast_node())) { if (!CanForwardDeclareType(current_ast_node())) {
const map<const Type*, const Type*> resugar_map const map<const Type*, const Type*> resugar_map =
= GetTplTypeResugarMapForClass(type); GetTplTypeResugarMapForClass(type);
instantiated_template_visitor_.ScanInstantiatedType(current_ast_node(), instantiated_template_visitor_.ScanInstantiatedType(current_ast_node(),
resugar_map); resugar_map);
@ -4262,8 +4262,8 @@ class IwyuAstConsumer
if (!IsTemplatizedFunctionDecl(callee) && !IsTemplatizedType(parent_type)) if (!IsTemplatizedFunctionDecl(callee) && !IsTemplatizedType(parent_type))
return true; return true;
map<const Type*, const Type*> resugar_map map<const Type*, const Type*> resugar_map =
= GetTplTypeResugarMapForFunction(callee, calling_expr); GetTplTypeResugarMapForFunction(callee, calling_expr);
if (parent_type) { // means we're a method of a class if (parent_type) { // means we're a method of a class
InsertAllInto(GetTplTypeResugarMapForClass(parent_type), &resugar_map); InsertAllInto(GetTplTypeResugarMapForClass(parent_type), &resugar_map);
@ -4305,8 +4305,8 @@ class IwyuAction : public ASTFrontendAction {
std::unique_ptr<PPCallbacks>(preprocessor_consumer)); std::unique_ptr<PPCallbacks>(preprocessor_consumer));
compiler.getPreprocessor().addCommentHandler(preprocessor_consumer); compiler.getPreprocessor().addCommentHandler(preprocessor_consumer);
auto* const visitor_state auto* const visitor_state =
= new VisitorState(&compiler, *preprocessor_consumer); new VisitorState(&compiler, *preprocessor_consumer);
return std::unique_ptr<IwyuAstConsumer>(new IwyuAstConsumer(visitor_state)); return std::unique_ptr<IwyuAstConsumer>(new IwyuAstConsumer(visitor_state));
} }
}; };

View File

@ -350,11 +350,10 @@ const NestedNameSpecifier* GetQualifier(const ASTNode* ast_node) {
const NestedNameSpecifier* nns = nullptr; const NestedNameSpecifier* nns = nullptr;
if (ast_node->IsA<TemplateName>()) { if (ast_node->IsA<TemplateName>()) {
const TemplateName* tn = ast_node->GetAs<TemplateName>(); const TemplateName* tn = ast_node->GetAs<TemplateName>();
if (const DependentTemplateName* dtn if (const DependentTemplateName* dtn = tn->getAsDependentTemplateName())
= tn->getAsDependentTemplateName())
nns = dtn->getQualifier(); nns = dtn->getQualifier();
else if (const QualifiedTemplateName* qtn else if (const QualifiedTemplateName* qtn =
= tn->getAsQualifiedTemplateName()) tn->getAsQualifiedTemplateName())
nns = qtn->getQualifier(); nns = qtn->getQualifier();
} }
if (!nns) nns = TryGetQualifier<ElaboratedType>(ast_node); if (!nns) nns = TryGetQualifier<ElaboratedType>(ast_node);
@ -729,8 +728,8 @@ static map<const Type*, const Type*> GetTplTypeResugarMapForFunctionNoCallExpr(
map<const Type*, const Type*> retval; map<const Type*, const Type*> retval;
if (!decl) // can be nullptr if the function call is via a function pointer if (!decl) // can be nullptr if the function call is via a function pointer
return retval; return retval;
if (const TemplateArgumentList* tpl_list if (const TemplateArgumentList* tpl_list =
= decl->getTemplateSpecializationArgs()) { decl->getTemplateSpecializationArgs()) {
for (unsigned i = start_arg; i < tpl_list->size(); ++i) { for (unsigned i = start_arg; i < tpl_list->size(); ++i) {
if (const Type* arg_type = GetTemplateArgAsType(tpl_list->get(i))) { if (const Type* arg_type = GetTemplateArgAsType(tpl_list->get(i))) {
retval[GetCanonicalType(arg_type)] = arg_type; retval[GetCanonicalType(arg_type)] = arg_type;
@ -826,8 +825,8 @@ map<const Type*, const Type*> GetTplTypeResugarMapForFunction(
fn_args = call_expr->getArgs(); fn_args = call_expr->getArgs();
num_args = call_expr->getNumArgs(); num_args = call_expr->getNumArgs();
const Expr* callee_expr = call_expr->getCallee()->IgnoreParenCasts(); const Expr* callee_expr = call_expr->getCallee()->IgnoreParenCasts();
const TemplateArgumentListInfo& explicit_tpl_args const TemplateArgumentListInfo& explicit_tpl_args =
= GetExplicitTplArgs(callee_expr); GetExplicitTplArgs(callee_expr);
if (explicit_tpl_args.size() > 0) { if (explicit_tpl_args.size() > 0) {
retval = GetTplTypeResugarMapForFunctionExplicitTplArgs( retval = GetTplTypeResugarMapForFunctionExplicitTplArgs(
decl, explicit_tpl_args); decl, explicit_tpl_args);
@ -835,8 +834,8 @@ map<const Type*, const Type*> GetTplTypeResugarMapForFunction(
} }
} else { } else {
// If calling_expr has explicit template args, then consider them. // If calling_expr has explicit template args, then consider them.
const TemplateArgumentListInfo& explicit_tpl_args const TemplateArgumentListInfo& explicit_tpl_args =
= GetExplicitTplArgs(calling_expr); GetExplicitTplArgs(calling_expr);
if (explicit_tpl_args.size() > 0) { if (explicit_tpl_args.size() > 0) {
retval = GetTplTypeResugarMapForFunctionExplicitTplArgs( retval = GetTplTypeResugarMapForFunctionExplicitTplArgs(
decl, explicit_tpl_args); decl, explicit_tpl_args);
@ -855,8 +854,8 @@ map<const Type*, const Type*> GetTplTypeResugarMapForFunction(
// operator<<(basic_ostream<char, T>& o, int i); // operator<<(basic_ostream<char, T>& o, int i);
// If I pass in an ostream as the first argument, then no part // If I pass in an ostream as the first argument, then no part
// of the (sugared) argument types match T, so we ignore it. // of the (sugared) argument types match T, so we ignore it.
const map<const Type*, const Type*>& desugared_types const map<const Type*, const Type*>& desugared_types =
= GetTplTypeResugarMapForFunctionNoCallExpr(decl, start_of_implicit_args); GetTplTypeResugarMapForFunctionNoCallExpr(decl, start_of_implicit_args);
// TODO(csilvers): SubstTemplateTypeParms are always desugared, // TODO(csilvers): SubstTemplateTypeParms are always desugared,
// making this less useful than it should be. // making this less useful than it should be.
@ -1254,15 +1253,14 @@ static const NamedDecl* TypeToDeclImpl(const Type* type, bool as_written) {
if (const TypedefType* typedef_type = DynCastFrom(type)) { if (const TypedefType* typedef_type = DynCastFrom(type)) {
return typedef_type->getDecl(); return typedef_type->getDecl();
} else if (const InjectedClassNameType* icn_type } else if (const InjectedClassNameType* icn_type =
= type->getAs<InjectedClassNameType>()) { type->getAs<InjectedClassNameType>()) {
return icn_type->getDecl(); return icn_type->getDecl();
} else if (as_written && template_decl && } else if (as_written && template_decl &&
isa<TypeAliasTemplateDecl>(template_decl)) { isa<TypeAliasTemplateDecl>(template_decl)) {
// A template type alias // A template type alias
return template_decl; return template_decl;
} else if (const RecordType* record_type } else if (const RecordType* record_type = type->getAs<RecordType>()) {
= type->getAs<RecordType>()) {
return record_type->getDecl(); return record_type->getDecl();
} else if (const TagType* tag_type = DynCastFrom(type)) { } else if (const TagType* tag_type = DynCastFrom(type)) {
return tag_type->getDecl(); // probably just enums return tag_type->getDecl(); // probably just enums
@ -1273,7 +1271,7 @@ static const NamedDecl* TypeToDeclImpl(const Type* type, bool as_written) {
// TODO(csilvers): is it possible to map from fn type to fn decl? // TODO(csilvers): is it possible to map from fn type to fn decl?
(void)function_type; (void)function_type;
return nullptr; return nullptr;
} else { } else {
return nullptr; return nullptr;
} }
} }
@ -1343,8 +1341,8 @@ GetTplTypeResugarMapForClassNoComponentTypes(const clang::Type* type) {
set<unsigned> explicit_args; // indices into tpl_args we've filled set<unsigned> explicit_args; // indices into tpl_args we've filled
TypeEnumerator type_enumerator; TypeEnumerator type_enumerator;
for (unsigned i = 0; i < tpl_spec_type->template_arguments().size(); ++i) { for (unsigned i = 0; i < tpl_spec_type->template_arguments().size(); ++i) {
set<const Type*> arg_components set<const Type*> arg_components =
= type_enumerator.Enumerate(tpl_spec_type->template_arguments()[i]); type_enumerator.Enumerate(tpl_spec_type->template_arguments()[i]);
// Go through all template types mentioned in the arg-as-written, // Go through all template types mentioned in the arg-as-written,
// and compare it against each of the types in the template decl // and compare it against each of the types in the template decl
// (the latter are all desugared). If there's a match, update // (the latter are all desugared). If there's a match, update
@ -1470,14 +1468,13 @@ const CXXDestructorDecl* GetSiblingDestructorFor(
const FunctionType* GetCalleeFunctionType(CallExpr* expr) { const FunctionType* GetCalleeFunctionType(CallExpr* expr) {
const Type* callee_type = expr->getCallee()->getType().getTypePtr(); const Type* callee_type = expr->getCallee()->getType().getTypePtr();
if (const PointerType* ptr_type if (const PointerType* ptr_type = callee_type->getAs<PointerType>()) {
= callee_type->getAs<PointerType>()) {
callee_type = ptr_type->getPointeeType().getTypePtr(); callee_type = ptr_type->getPointeeType().getTypePtr();
} else if (const BlockPointerType* bptr_type } else if (const BlockPointerType* bptr_type =
= callee_type->getAs<BlockPointerType>()) { callee_type->getAs<BlockPointerType>()) {
callee_type = bptr_type->getPointeeType().getTypePtr(); callee_type = bptr_type->getPointeeType().getTypePtr();
} else if (const MemberPointerType* mptr_type } else if (const MemberPointerType* mptr_type =
= callee_type->getAs<MemberPointerType>()) { callee_type->getAs<MemberPointerType>()) {
callee_type = mptr_type->getPointeeType().getTypePtr(); callee_type = mptr_type->getPointeeType().getTypePtr();
} }
return callee_type->getAs<FunctionType>(); return callee_type->getAs<FunctionType>();

View File

@ -72,8 +72,8 @@ map<const Type*, const Type*> FullUseCache::GetPrecomputedResugarMap(
// The code below doesn't handle template-template args/etc. None // The code below doesn't handle template-template args/etc. None
// of the types in kFullUseTypes should have those. Just verify, // of the types in kFullUseTypes should have those. Just verify,
// when we can. // when we can.
if (const ClassTemplateSpecializationDecl* tpl_spec_decl if (const ClassTemplateSpecializationDecl* tpl_spec_decl =
= DynCastFrom(tpl_decl)) { DynCastFrom(tpl_decl)) {
const TemplateArgumentList& all_tpl_args = tpl_spec_decl->getTemplateArgs(); const TemplateArgumentList& all_tpl_args = tpl_spec_decl->getTemplateArgs();
for (unsigned i = 0; i < all_tpl_args.size(); ++i) { for (unsigned i = 0; i < all_tpl_args.size(); ++i) {
CHECK_((all_tpl_args.get(i).getKind() == TemplateArgument::Type) CHECK_((all_tpl_args.get(i).getKind() == TemplateArgument::Type)

View File

@ -133,18 +133,16 @@ SourceLocation GetLocation(const clang::Stmt* stmt) {
return call_expr->getOperatorLoc(); return call_expr->getOperatorLoc();
} else if (const MemberExpr* member_expr = DynCastFrom(stmt)) { } else if (const MemberExpr* member_expr = DynCastFrom(stmt)) {
return GetMemberExprLocation(member_expr); return GetMemberExprLocation(member_expr);
} else if (const UnresolvedMemberExpr* member_expr } else if (const UnresolvedMemberExpr* member_expr = DynCastFrom(stmt)) {
= DynCastFrom(stmt)) {
if (member_expr->getOperatorLoc().isValid()) if (member_expr->getOperatorLoc().isValid())
return member_expr->getOperatorLoc(); return member_expr->getOperatorLoc();
} else if (const CXXDependentScopeMemberExpr* member_expr } else if (const CXXDependentScopeMemberExpr* member_expr =
= DynCastFrom(stmt)) { DynCastFrom(stmt)) {
if (member_expr->getOperatorLoc().isValid()) if (member_expr->getOperatorLoc().isValid())
return member_expr->getOperatorLoc(); return member_expr->getOperatorLoc();
} else if (const BinaryOperator* binary_op = DynCastFrom(stmt)) { } else if (const BinaryOperator* binary_op = DynCastFrom(stmt)) {
return binary_op->getOperatorLoc(); return binary_op->getOperatorLoc();
} else if (const ConditionalOperator* conditional_op = } else if (const ConditionalOperator* conditional_op = DynCastFrom(stmt)) {
DynCastFrom(stmt)) {
return conditional_op->getQuestionLoc(); return conditional_op->getQuestionLoc();
} else if (const UnaryOperator* unary_op = DynCastFrom(stmt)) { } else if (const UnaryOperator* unary_op = DynCastFrom(stmt)) {
// Drill through unary operators and parentheses, to get at the underlying // Drill through unary operators and parentheses, to get at the underlying

View File

@ -1425,9 +1425,9 @@ void CalculateIwyuForForwardDeclareUse(
const NamedDecl* dfn = GetTagDefinition(use->decl()); const NamedDecl* dfn = GetTagDefinition(use->decl());
if (dfn) { if (dfn) {
vector<string> headers vector<string> headers =
= GlobalIncludePicker().GetCandidateHeadersForFilepathIncludedFrom( GlobalIncludePicker().GetCandidateHeadersForFilepathIncludedFrom(
GetFilePath(dfn), GetFilePath(use->use_loc())); GetFilePath(dfn), GetFilePath(use->use_loc()));
for (const string& header : headers) { for (const string& header : headers) {
if (ContainsKey(desired_includes, header)) if (ContainsKey(desired_includes, header))
dfn_is_in_desired_includes = true; dfn_is_in_desired_includes = true;
@ -1491,8 +1491,8 @@ void CalculateIwyuForForwardDeclareUse(
// Be sure to store as a TemplateClassDecl if we're a templated // Be sure to store as a TemplateClassDecl if we're a templated
// class. // class.
if (const ClassTemplateSpecializationDecl* spec_decl if (const ClassTemplateSpecializationDecl* spec_decl =
= DynCastFrom(use->decl())) { DynCastFrom(use->decl())) {
use->reset_decl(spec_decl->getSpecializedTemplate()); use->reset_decl(spec_decl->getSpecializedTemplate());
} else if (const CXXRecordDecl* cxx_decl = DynCastFrom(use->decl())) { } else if (const CXXRecordDecl* cxx_decl = DynCastFrom(use->decl())) {
if (cxx_decl->getDescribedClassTemplate()) if (cxx_decl->getDescribedClassTemplate())
@ -1612,8 +1612,8 @@ void IwyuFileInfo::CalculateIwyuViolations(vector<OneUse>* uses) {
// The 'effective' direct includes are defined to be the current // The 'effective' direct includes are defined to be the current
// includes of associated, plus us. This is only used to decide // includes of associated, plus us. This is only used to decide
// when to give iwyu warnings. // when to give iwyu warnings.
const set<string> effective_direct_includes const set<string> effective_direct_includes =
= Union(associated_direct_includes, direct_includes()); Union(associated_direct_includes, direct_includes());
// (C2) + (C3) Find the minimal 'set cover' for all symbol uses. // (C2) + (C3) Find the minimal 'set cover' for all symbol uses.
const set<string> desired_set_cover = internal::CalculateMinimalIncludes( const set<string> desired_set_cover = internal::CalculateMinimalIncludes(

View File

@ -261,8 +261,8 @@ void IwyuPreprocessorInfo::HandlePragmaComment(SourceRange comment_range) {
return; return;
} }
const string quoted_this_file const string quoted_this_file =
= ConvertToQuotedInclude(GetFilePath(begin_loc)); ConvertToQuotedInclude(GetFilePath(begin_loc));
VERRS(8) << "Adding dynamic mapping for private pragma\n"; VERRS(8) << "Adding dynamic mapping for private pragma\n";
MutableGlobalIncludePicker()->AddMapping(quoted_this_file, MutableGlobalIncludePicker()->AddMapping(quoted_this_file,
@ -875,8 +875,8 @@ void IwyuPreprocessorInfo::ReportMacroUse(const string& name,
// As above, but get the definition location from macros_definition_loc_. // As above, but get the definition location from macros_definition_loc_.
void IwyuPreprocessorInfo::FindAndReportMacroUse(const string& name, void IwyuPreprocessorInfo::FindAndReportMacroUse(const string& name,
SourceLocation loc) { SourceLocation loc) {
if (const SourceLocation* dfn_loc if (const SourceLocation* dfn_loc =
= FindInMap(&macros_definition_loc_, name)) { FindInMap(&macros_definition_loc_, name)) {
ReportMacroUse(name, loc, *dfn_loc); ReportMacroUse(name, loc, *dfn_loc);
} }
} }
@ -887,8 +887,8 @@ void IwyuPreprocessorInfo::FindAndReportMacroUse(const string& name,
// Adds of includer's includes, direct or indirect, into retval. // Adds of includer's includes, direct or indirect, into retval.
void IwyuPreprocessorInfo::AddAllIncludesAsFileEntries( void IwyuPreprocessorInfo::AddAllIncludesAsFileEntries(
const FileEntry* includer, set<const FileEntry*>* retval) const { const FileEntry* includer, set<const FileEntry*>* retval) const {
set<const FileEntry*> direct_incs set<const FileEntry*> direct_incs =
= FileInfoOrEmptyFor(includer).direct_includes_as_fileentries(); FileInfoOrEmptyFor(includer).direct_includes_as_fileentries();
for (const FileEntry* include : direct_incs) { for (const FileEntry* include : direct_incs) {
if (ContainsKey(*retval, include)) // avoid infinite recursion if (ContainsKey(*retval, include)) // avoid infinite recursion
continue; continue;
@ -933,8 +933,8 @@ void IwyuPreprocessorInfo::PopulateIntendsToProvideMap() {
if (picker.IsPublic(file)) { if (picker.IsPublic(file)) {
AddAllIncludesAsFileEntries(file, &intends_to_provide_map_[file]); AddAllIncludesAsFileEntries(file, &intends_to_provide_map_[file]);
} else { } else {
const set<const FileEntry*>& direct_includes const set<const FileEntry*>& direct_includes =
= fileinfo.second.direct_includes_as_fileentries(); fileinfo.second.direct_includes_as_fileentries();
for (const FileEntry* inc : direct_includes) { for (const FileEntry* inc : direct_includes) {
intends_to_provide_map_[file].insert(inc); intends_to_provide_map_[file].insert(inc);
if (picker.IsPublic(inc)) if (picker.IsPublic(inc))
@ -948,8 +948,8 @@ void IwyuPreprocessorInfo::PopulateIntendsToProvideMap() {
const FileEntry* file = fileinfo.first; const FileEntry* file = fileinfo.first;
// See if a round-trip to string and back ends up at a different file. // See if a round-trip to string and back ends up at a different file.
const string quoted_include = ConvertToQuotedInclude(GetFilePath(file)); const string quoted_include = ConvertToQuotedInclude(GetFilePath(file));
const FileEntry* other_file const FileEntry* other_file =
= GetOrDefault(include_to_fileentry_map_, quoted_include, file); GetOrDefault(include_to_fileentry_map_, quoted_include, file);
if (other_file != file) { if (other_file != file) {
InsertAllInto(intends_to_provide_map_[file], InsertAllInto(intends_to_provide_map_[file],
&intends_to_provide_map_[other_file]); &intends_to_provide_map_[other_file]);
@ -1071,8 +1071,8 @@ const IwyuFileInfo& IwyuPreprocessorInfo::FileInfoOrEmptyFor(
bool IwyuPreprocessorInfo::PublicHeaderIntendsToProvide( bool IwyuPreprocessorInfo::PublicHeaderIntendsToProvide(
const FileEntry* public_header, const FileEntry* other_file) const { const FileEntry* public_header, const FileEntry* other_file) const {
if (const set<const FileEntry*>* provides if (const set<const FileEntry*>* provides =
= FindInMap(&intends_to_provide_map_, public_header)) { FindInMap(&intends_to_provide_map_, public_header)) {
return ContainsKey(*provides, other_file); return ContainsKey(*provides, other_file);
} }
return false; return false;
@ -1080,8 +1080,8 @@ bool IwyuPreprocessorInfo::PublicHeaderIntendsToProvide(
bool IwyuPreprocessorInfo::FileTransitivelyIncludes( bool IwyuPreprocessorInfo::FileTransitivelyIncludes(
const FileEntry* includer, const FileEntry* includee) const { const FileEntry* includer, const FileEntry* includee) const {
if (const set<const FileEntry*>* all_includes if (const set<const FileEntry*>* all_includes =
= FindInMap(&transitive_include_map_, includer)) { FindInMap(&transitive_include_map_, includer)) {
return ContainsKey(*all_includes, includee); return ContainsKey(*all_includes, includee);
} }
return false; return false;
@ -1089,8 +1089,8 @@ bool IwyuPreprocessorInfo::FileTransitivelyIncludes(
bool IwyuPreprocessorInfo::FileTransitivelyIncludes( bool IwyuPreprocessorInfo::FileTransitivelyIncludes(
const FileEntry* includer, const string& quoted_includee) const { const FileEntry* includer, const string& quoted_includee) const {
if (const set<const FileEntry*>* all_includes if (const set<const FileEntry*>* all_includes =
= FindInMap(&transitive_include_map_, includer)) { FindInMap(&transitive_include_map_, includer)) {
for (const FileEntry* include : *all_includes) { for (const FileEntry* include : *all_includes) {
if (ConvertToQuotedInclude(GetFilePath(include)) == quoted_includee) if (ConvertToQuotedInclude(GetFilePath(include)) == quoted_includee)
return true; return true;