[clang] NFC: format clang/lib/Sema/Sema.cpp (PR #83974)
Takuto Ikuta via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 5 00:37:00 PST 2024
https://github.com/atetubou created https://github.com/llvm/llvm-project/pull/83974
This is to avoid modifying unrelated code when auto format is on in our editor.
>From 8d660f8a15b04285a4218a22944aef902d645b27 Mon Sep 17 00:00:00 2001
From: Takuto Ikuta <tikuta at google.com>
Date: Tue, 5 Mar 2024 17:34:15 +0900
Subject: [PATCH] NFC: format clang/lib/Sema/Sema.cpp
---
clang/lib/Sema/Sema.cpp | 223 +++++++++++++++++++++-------------------
1 file changed, 118 insertions(+), 105 deletions(-)
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index cfb653e665ea03..fe00dc3198fdc0 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -269,8 +269,8 @@ void Sema::Initialize() {
SC->InitializeSema(*this);
// Tell the external Sema source about this Sema object.
- if (ExternalSemaSource *ExternalSema
- = dyn_cast_or_null<ExternalSemaSource>(Context.getExternalSource()))
+ if (ExternalSemaSource *ExternalSema =
+ dyn_cast_or_null<ExternalSemaSource>(Context.getExternalSource()))
ExternalSema->InitializeSema(*this);
// This needs to happen after ExternalSemaSource::InitializeSema(this) or we
@@ -295,7 +295,6 @@ void Sema::Initialize() {
PushOnScopeChains(Context.getUInt128Decl(), TUScope);
}
-
// Initialize predefined Objective-C types:
if (getLangOpts().ObjC) {
// If 'SEL' does not yet refer to any declarations, make it refer to the
@@ -361,7 +360,6 @@ void Sema::Initialize() {
// 32-bit integer and OpenCLC v2.0, s6.1.1 int is always 32-bit wide.
addImplicitTypedef("atomic_flag", Context.getAtomicType(Context.IntTy));
-
// OpenCL v2.0 s6.13.11.6:
// - The atomic_long and atomic_ulong types are supported if the
// cl_khr_int64_base_atomics and cl_khr_int64_extended_atomics
@@ -410,7 +408,6 @@ void Sema::Initialize() {
addImplicitTypedef("atomic_long", AtomicLongT);
addImplicitTypedef("atomic_ulong", AtomicULongT);
-
if (Context.getTypeSize(Context.getSizeType()) == 64) {
AddPointerSizeDependentTypes();
}
@@ -425,17 +422,17 @@ void Sema::Initialize() {
}
if (Context.getTargetInfo().hasAArch64SVETypes()) {
-#define SVE_TYPE(Name, Id, SingletonId) \
- addImplicitTypedef(Name, Context.SingletonId);
+#define SVE_TYPE(Name, Id, SingletonId) \
+ addImplicitTypedef(Name, Context.SingletonId);
#include "clang/Basic/AArch64SVEACLETypes.def"
}
if (Context.getTargetInfo().getTriple().isPPC64()) {
-#define PPC_VECTOR_MMA_TYPE(Name, Id, Size) \
- addImplicitTypedef(#Name, Context.Id##Ty);
+#define PPC_VECTOR_MMA_TYPE(Name, Id, Size) \
+ addImplicitTypedef(#Name, Context.Id##Ty);
#include "clang/Basic/PPCTypes.def"
-#define PPC_VECTOR_VSX_TYPE(Name, Id, Size) \
- addImplicitTypedef(#Name, Context.Id##Ty);
+#define PPC_VECTOR_VSX_TYPE(Name, Id, Size) \
+ addImplicitTypedef(#Name, Context.Id##Ty);
#include "clang/Basic/PPCTypes.def"
}
@@ -467,7 +464,8 @@ Sema::~Sema() {
assert(InstantiatingSpecializations.empty() &&
"failed to clean up an InstantiatingTemplate?");
- if (VisContext) FreeVisContext();
+ if (VisContext)
+ FreeVisContext();
// Kill all the active scopes.
for (sema::FunctionScopeInfo *FSI : FunctionScopes)
@@ -478,8 +476,8 @@ Sema::~Sema() {
SC->ForgetSema();
// Detach from the external Sema source.
- if (ExternalSemaSource *ExternalSema
- = dyn_cast_or_null<ExternalSemaSource>(Context.getExternalSource()))
+ if (ExternalSemaSource *ExternalSema =
+ dyn_cast_or_null<ExternalSemaSource>(Context.getExternalSource()))
ExternalSema->ForgetSema();
// Delete cached satisfactions.
@@ -517,11 +515,12 @@ void Sema::runWithSufficientStackSpace(SourceLocation Loc,
/// context. If we're still in a system header, and we can plausibly
/// make the relevant declaration unavailable instead of erroring, do
/// so and return true.
-bool Sema::makeUnavailableInSystemHeader(SourceLocation loc,
- UnavailableAttr::ImplicitReason reason) {
+bool Sema::makeUnavailableInSystemHeader(
+ SourceLocation loc, UnavailableAttr::ImplicitReason reason) {
// If we're not in a function, it's an error.
FunctionDecl *fn = dyn_cast<FunctionDecl>(CurContext);
- if (!fn) return false;
+ if (!fn)
+ return false;
// If we're in template instantiation, it's an error.
if (inTemplateInstantiation())
@@ -532,7 +531,8 @@ bool Sema::makeUnavailableInSystemHeader(SourceLocation loc,
return false;
// If the function is already unavailable, it's not an error.
- if (fn->hasAttr<UnavailableAttr>()) return true;
+ if (fn->hasAttr<UnavailableAttr>())
+ return true;
fn->addAttr(UnavailableAttr::CreateImplicit(Context, "", reason, loc));
return true;
@@ -542,8 +542,8 @@ ASTMutationListener *Sema::getASTMutationListener() const {
return getASTConsumer().GetASTMutationListener();
}
-///Registers an external source. If an external source already exists,
-/// creates a multiplex external source and appends to it.
+/// Registers an external source. If an external source already exists,
+/// creates a multiplex external source and appends to it.
///
///\param[in] E - A non-null external sema source.
///
@@ -633,8 +633,8 @@ void Sema::diagnoseZeroToNullptrConversion(CastKind Kind, const Expr *E) {
/// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
/// If there is already an implicit cast, merge into the existing one.
/// The result is of the given category.
-ExprResult Sema::ImpCastExprToType(Expr *E, QualType Ty,
- CastKind Kind, ExprValueKind VK,
+ExprResult Sema::ImpCastExprToType(Expr *E, QualType Ty, CastKind Kind,
+ ExprValueKind VK,
const CXXCastPath *BasePath,
CheckedConversionKind CCK) {
#ifndef NDEBUG
@@ -716,16 +716,26 @@ ExprResult Sema::ImpCastExprToType(Expr *E, QualType Ty,
/// to the conversion from scalar type ScalarTy to the Boolean type.
CastKind Sema::ScalarTypeToBooleanCastKind(QualType ScalarTy) {
switch (ScalarTy->getScalarTypeKind()) {
- case Type::STK_Bool: return CK_NoOp;
- case Type::STK_CPointer: return CK_PointerToBoolean;
- case Type::STK_BlockPointer: return CK_PointerToBoolean;
- case Type::STK_ObjCObjectPointer: return CK_PointerToBoolean;
- case Type::STK_MemberPointer: return CK_MemberPointerToBoolean;
- case Type::STK_Integral: return CK_IntegralToBoolean;
- case Type::STK_Floating: return CK_FloatingToBoolean;
- case Type::STK_IntegralComplex: return CK_IntegralComplexToBoolean;
- case Type::STK_FloatingComplex: return CK_FloatingComplexToBoolean;
- case Type::STK_FixedPoint: return CK_FixedPointToBoolean;
+ case Type::STK_Bool:
+ return CK_NoOp;
+ case Type::STK_CPointer:
+ return CK_PointerToBoolean;
+ case Type::STK_BlockPointer:
+ return CK_PointerToBoolean;
+ case Type::STK_ObjCObjectPointer:
+ return CK_PointerToBoolean;
+ case Type::STK_MemberPointer:
+ return CK_MemberPointerToBoolean;
+ case Type::STK_Integral:
+ return CK_IntegralToBoolean;
+ case Type::STK_Floating:
+ return CK_FloatingToBoolean;
+ case Type::STK_IntegralComplex:
+ return CK_IntegralComplexToBoolean;
+ case Type::STK_FloatingComplex:
+ return CK_FloatingComplexToBoolean;
+ case Type::STK_FixedPoint:
+ return CK_FixedPointToBoolean;
}
llvm_unreachable("unknown scalar type kind");
}
@@ -812,15 +822,17 @@ bool Sema::isExternalWithNoLinkageType(const ValueDecl *VD) const {
/// Obtains a sorted list of functions and variables that are undefined but
/// ODR-used.
void Sema::getUndefinedButUsed(
- SmallVectorImpl<std::pair<NamedDecl *, SourceLocation> > &Undefined) {
+ SmallVectorImpl<std::pair<NamedDecl *, SourceLocation>> &Undefined) {
for (const auto &UndefinedUse : UndefinedButUsed) {
NamedDecl *ND = UndefinedUse.first;
// Ignore attributes that have become invalid.
- if (ND->isInvalidDecl()) continue;
+ if (ND->isInvalidDecl())
+ continue;
// __attribute__((weakref)) is basically a definition.
- if (ND->hasAttr<WeakRefAttr>()) continue;
+ if (ND->hasAttr<WeakRefAttr>())
+ continue;
if (isa<CXXDeductionGuideDecl>(ND))
continue;
@@ -835,8 +847,7 @@ void Sema::getUndefinedButUsed(
if (const auto *FD = dyn_cast<FunctionDecl>(ND)) {
if (FD->isDefined())
continue;
- if (FD->isExternallyVisible() &&
- !isExternalWithNoLinkageType(FD) &&
+ if (FD->isExternallyVisible() && !isExternalWithNoLinkageType(FD) &&
!FD->getMostRecentDecl()->isInlined() &&
!FD->hasAttr<ExcludeFromExplicitInstantiationAttr>())
continue;
@@ -846,8 +857,7 @@ void Sema::getUndefinedButUsed(
const auto *VD = cast<VarDecl>(ND);
if (VD->hasDefinition() != VarDecl::DeclarationOnly)
continue;
- if (VD->isExternallyVisible() &&
- !isExternalWithNoLinkageType(VD) &&
+ if (VD->isExternallyVisible() && !isExternalWithNoLinkageType(VD) &&
!VD->getMostRecentDecl()->isInline() &&
!VD->hasAttr<ExcludeFromExplicitInstantiationAttr>())
continue;
@@ -865,13 +875,15 @@ void Sema::getUndefinedButUsed(
/// checkUndefinedButUsed - Check for undefined objects with internal linkage
/// or that are inline.
static void checkUndefinedButUsed(Sema &S) {
- if (S.UndefinedButUsed.empty()) return;
+ if (S.UndefinedButUsed.empty())
+ return;
// Collect all the still-undefined entities with internal linkage.
SmallVector<std::pair<NamedDecl *, SourceLocation>, 16> Undefined;
S.getUndefinedButUsed(Undefined);
S.UndefinedButUsed.clear();
- if (Undefined.empty()) return;
+ if (Undefined.empty())
+ return;
for (const auto &Undef : Undefined) {
ValueDecl *VD = cast<ValueDecl>(Undef.first);
@@ -890,7 +902,7 @@ static void checkUndefinedButUsed(Sema &S) {
S.Diag(VD->getLocation(), isExternallyVisible(VD->getType()->getLinkage())
? diag::ext_undefined_internal_type
: diag::err_undefined_internal_type)
- << isa<VarDecl>(VD) << VD;
+ << isa<VarDecl>(VD) << VD;
} else if (!VD->isExternallyVisible()) {
// FIXME: We can promote this to an error. The function or variable can't
// be defined anywhere else, so the program must necessarily violate the
@@ -936,8 +948,7 @@ void Sema::LoadExternalWeakUndeclaredIdentifiers() {
(void)WeakUndeclaredIdentifiers[WeakID.first].insert(WeakID.second);
}
-
-typedef llvm::DenseMap<const CXXRecordDecl*, bool> RecordCompleteMap;
+typedef llvm::DenseMap<const CXXRecordDecl *, bool> RecordCompleteMap;
/// Returns true, if all methods and nested classes of the given
/// CXXRecordDecl are defined in this translation unit.
@@ -952,8 +963,7 @@ static bool MethodsAndNestedClassesComplete(const CXXRecordDecl *RD,
if (!RD->isCompleteDefinition())
return false;
bool Complete = true;
- for (DeclContext::decl_iterator I = RD->decls_begin(),
- E = RD->decls_end();
+ for (DeclContext::decl_iterator I = RD->decls_begin(), E = RD->decls_end();
I != E && Complete; ++I) {
if (const CXXMethodDecl *M = dyn_cast<CXXMethodDecl>(*I))
Complete = M->isDefined() || M->isDefaulted() ||
@@ -964,13 +974,13 @@ static bool MethodsAndNestedClassesComplete(const CXXRecordDecl *RD,
// performed semantic analysis on it yet, so we cannot know if the type
// can be considered complete.
Complete = !F->getTemplatedDecl()->isLateTemplateParsed() &&
- F->getTemplatedDecl()->isDefined();
+ F->getTemplatedDecl()->isDefined();
else if (const CXXRecordDecl *R = dyn_cast<CXXRecordDecl>(*I)) {
if (R->isInjectedClassName())
continue;
if (R->hasDefinition())
- Complete = MethodsAndNestedClassesComplete(R->getDefinition(),
- MNCComplete);
+ Complete =
+ MethodsAndNestedClassesComplete(R->getDefinition(), MNCComplete);
else
Complete = false;
}
@@ -1006,7 +1016,7 @@ static bool IsRecordFullyDefined(const CXXRecordDecl *RD,
} else {
// Friend functions are available through the NamedDecl of FriendDecl.
if (const FunctionDecl *FD =
- dyn_cast<FunctionDecl>((*I)->getFriendDecl()))
+ dyn_cast<FunctionDecl>((*I)->getFriendDecl()))
Complete = FD->isDefined();
else
// This is a template friend, give up.
@@ -1079,8 +1089,8 @@ void Sema::ActOnEndOfTranslationUnitFragment(TUFragmentKind Kind) {
for (auto PII : Pending)
if (auto Func = dyn_cast<FunctionDecl>(PII.first))
Func->setInstantiationIsPending(true);
- PendingInstantiations.insert(PendingInstantiations.begin(),
- Pending.begin(), Pending.end());
+ PendingInstantiations.insert(PendingInstantiations.begin(), Pending.begin(),
+ Pending.end());
}
{
@@ -1108,8 +1118,8 @@ void Sema::ActOnEndOfTranslationUnitFragment(TUFragmentKind Kind) {
/// translation unit when EOF is reached and all but the top-level scope is
/// popped.
void Sema::ActOnEndOfTranslationUnit() {
- assert(DelayedDiagnostics.getCurrentPool() == nullptr
- && "reached end of translation unit with a pool attached?");
+ assert(DelayedDiagnostics.getCurrentPool() == nullptr &&
+ "reached end of translation unit with a pool attached?");
// If code completion is enabled, don't perform any end-of-translation-unit
// work.
@@ -1327,8 +1337,8 @@ void Sema::ActOnEndOfTranslationUnit() {
if (!VD || VD->isInvalidDecl() || !Seen.insert(VD).second)
continue;
- if (const IncompleteArrayType *ArrayT
- = Context.getAsIncompleteArrayType(VD->getType())) {
+ if (const IncompleteArrayType *ArrayT =
+ Context.getAsIncompleteArrayType(VD->getType())) {
// Set the length of the array to 1 (C99 6.9.2p5).
Diag(VD->getLocation(), diag::warn_tentative_incomplete_array);
llvm::APInt One(Context.getTypeSize(Context.getSizeType()), true);
@@ -1385,7 +1395,7 @@ void Sema::ActOnEndOfTranslationUnit() {
if (FD->getStorageClass() == SC_Static &&
!FD->isInlineSpecified() &&
!SourceMgr.isInMainFile(
- SourceMgr.getExpansionLoc(FD->getLocation())))
+ SourceMgr.getExpansionLoc(FD->getLocation())))
Diag(DiagD->getLocation(),
diag::warn_unneeded_static_internal_decl)
<< DiagD << DiagRange;
@@ -1446,7 +1456,7 @@ void Sema::ActOnEndOfTranslationUnit() {
if (RD && !RD->isUnion() &&
IsRecordFullyDefined(RD, RecordsComplete, MNCComplete)) {
Diag(D->getLocation(), diag::warn_unused_private_field)
- << D->getDeclName();
+ << D->getDeclName();
}
}
}
@@ -1474,7 +1484,6 @@ void Sema::ActOnEndOfTranslationUnit() {
TUScope = nullptr;
}
-
//===----------------------------------------------------------------------===//
// Helper functions.
//===----------------------------------------------------------------------===//
@@ -1490,7 +1499,8 @@ DeclContext *Sema::getFunctionLevelDeclContext(bool AllowLambda) const {
cast<CXXMethodDecl>(DC)->getOverloadedOperator() == OO_Call &&
cast<CXXRecordDecl>(DC->getParent())->isLambda()) {
DC = DC->getParent()->getParent();
- } else break;
+ } else
+ break;
}
return DC;
@@ -1533,8 +1543,8 @@ void Sema::EmitCurrentDiagnostic(unsigned DiagID) {
// issue I am not seeing yet), then there should at least be a clarifying
// comment somewhere.
if (std::optional<TemplateDeductionInfo *> Info = isSFINAEContext()) {
- switch (DiagnosticIDs::getDiagnosticSFINAEResponse(
- Diags.getCurrentDiagID())) {
+ switch (
+ DiagnosticIDs::getDiagnosticSFINAEResponse(Diags.getCurrentDiagID())) {
case DiagnosticIDs::SFINAE_Report:
// We'll report the diagnostic below.
break;
@@ -1548,8 +1558,9 @@ void Sema::EmitCurrentDiagnostic(unsigned DiagID) {
// template-deduction information.
if (*Info && !(*Info)->hasSFINAEDiagnostic()) {
Diagnostic DiagInfo(&Diags);
- (*Info)->addSFINAEDiagnostic(DiagInfo.getLocation(),
- PartialDiagnostic(DiagInfo, Context.getDiagAllocator()));
+ (*Info)->addSFINAEDiagnostic(
+ DiagInfo.getLocation(),
+ PartialDiagnostic(DiagInfo, Context.getDiagAllocator()));
}
Diags.setLastDiagnosticIgnored(true);
@@ -1573,8 +1584,9 @@ void Sema::EmitCurrentDiagnostic(unsigned DiagID) {
// template-deduction information.
if (*Info && !(*Info)->hasSFINAEDiagnostic()) {
Diagnostic DiagInfo(&Diags);
- (*Info)->addSFINAEDiagnostic(DiagInfo.getLocation(),
- PartialDiagnostic(DiagInfo, Context.getDiagAllocator()));
+ (*Info)->addSFINAEDiagnostic(
+ DiagInfo.getLocation(),
+ PartialDiagnostic(DiagInfo, Context.getDiagAllocator()));
}
Diags.setLastDiagnosticIgnored(true);
@@ -1595,8 +1607,9 @@ void Sema::EmitCurrentDiagnostic(unsigned DiagID) {
// template-deduction information;
if (*Info) {
Diagnostic DiagInfo(&Diags);
- (*Info)->addSuppressedDiagnostic(DiagInfo.getLocation(),
- PartialDiagnostic(DiagInfo, Context.getDiagAllocator()));
+ (*Info)->addSuppressedDiagnostic(
+ DiagInfo.getLocation(),
+ PartialDiagnostic(DiagInfo, Context.getDiagAllocator()));
}
// Suppress this diagnostic.
@@ -1733,8 +1746,7 @@ class DeferredDiagnosticsEmitter
}
void checkVar(VarDecl *VD) {
- assert(VD->isFileVarDecl() &&
- "Should only check file-scope variables");
+ assert(VD->isFileVarDecl() && "Should only check file-scope variables");
if (auto *Init = VD->getInit()) {
auto DevTy = OMPDeclareTargetDeclAttr::getDeviceType(VD);
bool IsDev = DevTy && (*DevTy == OMPDeclareTargetDeclAttr::DT_NoHost ||
@@ -2106,7 +2118,8 @@ void Sema::checkTypeSupport(QualType Ty, SourceLocation Loc, ValueDecl *D) {
/// expansion loc.
bool Sema::findMacroSpelling(SourceLocation &locref, StringRef name) {
SourceLocation loc = locref;
- if (!loc.isMacroID()) return false;
+ if (!loc.isMacroID())
+ return false;
// There's no good way right now to look at the intermediate
// expansions, so just jump to the expansion location.
@@ -2164,8 +2177,8 @@ void Sema::PushFunctionScope() {
}
void Sema::PushBlockScope(Scope *BlockScope, BlockDecl *Block) {
- FunctionScopes.push_back(new BlockScopeInfo(getDiagnostics(),
- BlockScope, Block));
+ FunctionScopes.push_back(
+ new BlockScopeInfo(getDiagnostics(), BlockScope, Block));
CapturingFunctionScopes++;
}
@@ -2242,10 +2255,9 @@ static void markEscapingByrefs(const FunctionScopeInfo &FSI, Sema &S) {
QualType CapType = BC.getVariable()->getType();
if (CapType.hasNonTrivialToPrimitiveDestructCUnion() ||
CapType.hasNonTrivialToPrimitiveCopyCUnion())
- S.checkNonTrivialCUnion(BC.getVariable()->getType(),
- BD->getCaretLocation(),
- Sema::NTCUC_BlockCapture,
- Sema::NTCUK_Destruct|Sema::NTCUK_Copy);
+ S.checkNonTrivialCUnion(
+ BC.getVariable()->getType(), BD->getCaretLocation(),
+ Sema::NTCUC_BlockCapture, Sema::NTCUK_Destruct | Sema::NTCUK_Copy);
}
}
@@ -2292,8 +2304,8 @@ Sema::PopFunctionScopeInfo(const AnalysisBasedWarnings::Policy *WP,
return Scope;
}
-void Sema::PoppedFunctionScopeDeleter::
-operator()(sema::FunctionScopeInfo *Scope) const {
+void Sema::PoppedFunctionScopeDeleter::operator()(
+ sema::FunctionScopeInfo *Scope) const {
if (!Scope->isPlainFunction())
Self->CapturingFunctionScopes--;
// Stash the function scope for later reuse if it's for a normal function.
@@ -2346,8 +2358,7 @@ BlockScopeInfo *Sema::getCurBlock() {
return nullptr;
auto CurBSI = dyn_cast<BlockScopeInfo>(FunctionScopes.back());
- if (CurBSI && CurBSI->TheDecl &&
- !CurBSI->TheDecl->Encloses(CurContext)) {
+ if (CurBSI && CurBSI->TheDecl && !CurBSI->TheDecl->Encloses(CurContext)) {
// We have switched contexts due to template instantiation.
assert(!CodeSynthesisContexts.empty());
return nullptr;
@@ -2411,14 +2422,14 @@ LambdaScopeInfo *Sema::getCurLambda(bool IgnoreNonLambdaCapturingScope) {
// We have a generic lambda if we parsed auto parameters, or we have
// an associated template parameter list.
LambdaScopeInfo *Sema::getCurGenericLambda() {
- if (LambdaScopeInfo *LSI = getCurLambda()) {
- return (LSI->TemplateParams.size() ||
- LSI->GLTemplateParameterList) ? LSI : nullptr;
+ if (LambdaScopeInfo *LSI = getCurLambda()) {
+ return (LSI->TemplateParams.size() || LSI->GLTemplateParameterList)
+ ? LSI
+ : nullptr;
}
return nullptr;
}
-
void Sema::ActOnComment(SourceRange Comment) {
if (!LangOpts.RetainCommentsFromSystemHeaders &&
SourceMgr.isInSystemHeader(Comment.getBegin()))
@@ -2444,8 +2455,8 @@ void Sema::ActOnComment(SourceRange Comment) {
llvm_unreachable("if this is an almost Doxygen comment, "
"it should be ordinary");
}
- Diag(Comment.getBegin(), diag::warn_not_a_doxygen_trailing_member_comment) <<
- FixItHint::CreateReplacement(MagicMarkerRange, MagicMarkerText);
+ Diag(Comment.getBegin(), diag::warn_not_a_doxygen_trailing_member_comment)
+ << FixItHint::CreateReplacement(MagicMarkerRange, MagicMarkerText);
}
Context.addComment(RC);
}
@@ -2454,18 +2465,18 @@ void Sema::ActOnComment(SourceRange Comment) {
ExternalSemaSource::~ExternalSemaSource() {}
char ExternalSemaSource::ID;
-void ExternalSemaSource::ReadMethodPool(Selector Sel) { }
-void ExternalSemaSource::updateOutOfDateSelector(Selector Sel) { }
+void ExternalSemaSource::ReadMethodPool(Selector Sel) {}
+void ExternalSemaSource::updateOutOfDateSelector(Selector Sel) {}
void ExternalSemaSource::ReadKnownNamespaces(
- SmallVectorImpl<NamespaceDecl *> &Namespaces) {
-}
+ SmallVectorImpl<NamespaceDecl *> &Namespaces) {}
void ExternalSemaSource::ReadUndefinedButUsed(
llvm::MapVector<NamedDecl *, SourceLocation> &Undefined) {}
-void ExternalSemaSource::ReadMismatchingDeleteExpressions(llvm::MapVector<
- FieldDecl *, llvm::SmallVector<std::pair<SourceLocation, bool>, 4>> &) {}
+void ExternalSemaSource::ReadMismatchingDeleteExpressions(
+ llvm::MapVector<FieldDecl *,
+ llvm::SmallVector<std::pair<SourceLocation, bool>, 4>> &) {}
/// Figure out if an expression could be turned into a call.
///
@@ -2486,7 +2497,7 @@ bool Sema::tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy,
const OverloadExpr *Overloads = nullptr;
bool IsMemExpr = false;
if (E.getType() == Context.OverloadTy) {
- OverloadExpr::FindResult FR = OverloadExpr::find(const_cast<Expr*>(&E));
+ OverloadExpr::FindResult FR = OverloadExpr::find(const_cast<Expr *>(&E));
// Ignore overloads that are pointer-to-member constants.
if (FR.HasFormOfMemberPointer)
@@ -2503,15 +2514,16 @@ bool Sema::tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy,
if (Overloads) {
for (OverloadExpr::decls_iterator it = Overloads->decls_begin(),
- DeclsEnd = Overloads->decls_end(); it != DeclsEnd; ++it) {
+ DeclsEnd = Overloads->decls_end();
+ it != DeclsEnd; ++it) {
OverloadSet.addDecl(*it);
// Check whether the function is a non-template, non-member which takes no
// arguments.
if (IsMemExpr)
continue;
- if (const FunctionDecl *OverloadDecl
- = dyn_cast<FunctionDecl>((*it)->getUnderlyingDecl())) {
+ if (const FunctionDecl *OverloadDecl =
+ dyn_cast<FunctionDecl>((*it)->getUnderlyingDecl())) {
if (OverloadDecl->getMinRequiredArguments() == 0) {
if (!ZeroArgCallReturnTy.isNull() && !Ambiguous &&
(!IsMV || !(OverloadDecl->isCPUDispatchMultiVersion() ||
@@ -2589,7 +2601,8 @@ static void noteOverloads(Sema &S, const UnresolvedSetImpl &Overloads,
unsigned ShownOverloads = 0;
unsigned SuppressedOverloads = 0;
for (UnresolvedSetImpl::iterator It = Overloads.begin(),
- DeclsEnd = Overloads.end(); It != DeclsEnd; ++It) {
+ DeclsEnd = Overloads.end();
+ It != DeclsEnd; ++It) {
if (ShownOverloads >= S.Diags.getNumOverloadCandidatesToShow()) {
++SuppressedOverloads;
continue;
@@ -2613,7 +2626,7 @@ static void noteOverloads(Sema &S, const UnresolvedSetImpl &Overloads,
if (SuppressedOverloads)
S.Diag(FinalNoteLoc, diag::note_ovl_too_many_candidates)
- << SuppressedOverloads;
+ << SuppressedOverloads;
}
static void notePlausibleOverloads(Sema &S, SourceLocation Loc,
@@ -2624,7 +2637,8 @@ static void notePlausibleOverloads(Sema &S, SourceLocation Loc,
UnresolvedSet<2> PlausibleOverloads;
for (OverloadExpr::decls_iterator It = Overloads.begin(),
- DeclsEnd = Overloads.end(); It != DeclsEnd; ++It) {
+ DeclsEnd = Overloads.end();
+ It != DeclsEnd; ++It) {
const auto *OverloadDecl = cast<FunctionDecl>(*It);
QualType OverloadResultTy = OverloadDecl->getReturnType();
if (IsPlausibleResult(OverloadResultTy))
@@ -2639,10 +2653,8 @@ static void notePlausibleOverloads(Sema &S, SourceLocation Loc,
/// outside the call.
static bool IsCallableWithAppend(const Expr *E) {
E = E->IgnoreImplicit();
- return (!isa<CStyleCastExpr>(E) &&
- !isa<UnaryOperator>(E) &&
- !isa<BinaryOperator>(E) &&
- !isa<CXXOperatorCallExpr>(E));
+ return (!isa<CStyleCastExpr>(E) && !isa<UnaryOperator>(E) &&
+ !isa<BinaryOperator>(E) && !isa<CXXOperatorCallExpr>(E));
}
static bool IsCPUDispatchCPUSpecificMultiVersion(const Expr *E) {
@@ -2695,7 +2707,8 @@ bool Sema::tryToRecoverWithCall(ExprResult &E, const PartialDiagnostic &PD,
return true;
}
}
- if (!ForceComplain) return false;
+ if (!ForceComplain)
+ return false;
bool IsMV = IsCPUDispatchCPUSpecificMultiVersion(E.get());
Diag(Loc, PD) << /*not zero-arg*/ 0 << IsMV << Range;
More information about the cfe-commits
mailing list