aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaStmt.cpp
diff options
context:
space:
mode:
authorVlad Serebrennikov <serebrennikov.vladislav@gmail.com>2024-02-12 21:27:58 +0400
committerGitHub <noreply@github.com>2024-02-12 21:27:58 +0400
commitdfbe2bca1d8ccee87f032562fd60214ca8ea0d22 (patch)
treec2372de9d690dcf5b4cd6c8195e1d4ed8514115f /clang/lib/Sema/SemaStmt.cpp
parenta8b4c11f9d51f3d735f76c98367c87d6ff328a32 (diff)
downloadllvm-dfbe2bca1d8ccee87f032562fd60214ca8ea0d22.zip
llvm-dfbe2bca1d8ccee87f032562fd60214ca8ea0d22.tar.gz
llvm-dfbe2bca1d8ccee87f032562fd60214ca8ea0d22.tar.bz2
[clang][NFC] Refactor `Sema::TemplateDeductionResult` (#81398)
This patch converts `Sema::TemplateDeductionResult` into a scoped enum in namespace scope, making it eligible for forward declaring. This is useful in certain contexts, such as `preferred_type` annotations on bit-fields.
Diffstat (limited to 'clang/lib/Sema/SemaStmt.cpp')
-rw-r--r--clang/lib/Sema/SemaStmt.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index d9aaea8..dde3bd8 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -2326,7 +2326,8 @@ Sema::ActOnObjCForCollectionStmt(SourceLocation ForLoc,
FirstType = QualType();
TemplateDeductionResult Result = DeduceAutoType(
D->getTypeSourceInfo()->getTypeLoc(), DeducedInit, FirstType, Info);
- if (Result != TDK_Success && Result != TDK_AlreadyDiagnosed)
+ if (Result != TemplateDeductionResult::Success &&
+ Result != TemplateDeductionResult::AlreadyDiagnosed)
DiagnoseAutoDeductionFailure(D, DeducedInit);
if (FirstType.isNull()) {
D->setInvalidDecl();
@@ -2394,9 +2395,10 @@ static bool FinishForRangeVarDecl(Sema &SemaRef, VarDecl *Decl, Expr *Init,
SemaRef.Diag(Loc, DiagID) << Init->getType();
} else {
TemplateDeductionInfo Info(Init->getExprLoc());
- Sema::TemplateDeductionResult Result = SemaRef.DeduceAutoType(
+ TemplateDeductionResult Result = SemaRef.DeduceAutoType(
Decl->getTypeSourceInfo()->getTypeLoc(), Init, InitType, Info);
- if (Result != Sema::TDK_Success && Result != Sema::TDK_AlreadyDiagnosed)
+ if (Result != TemplateDeductionResult::Success &&
+ Result != TemplateDeductionResult::AlreadyDiagnosed)
SemaRef.Diag(Loc, DiagID) << Init->getType();
}
@@ -3865,14 +3867,14 @@ bool Sema::DeduceFunctionTypeFromReturnExpr(FunctionDecl *FD,
TemplateDeductionResult Res = DeduceAutoType(
OrigResultType, RetExpr, Deduced, Info, /*DependentDeduction=*/false,
/*IgnoreConstraints=*/false, &FailedTSC);
- if (Res != TDK_Success && FD->isInvalidDecl())
+ if (Res != TemplateDeductionResult::Success && FD->isInvalidDecl())
return true;
switch (Res) {
- case TDK_Success:
+ case TemplateDeductionResult::Success:
break;
- case TDK_AlreadyDiagnosed:
+ case TemplateDeductionResult::AlreadyDiagnosed:
return true;
- case TDK_Inconsistent: {
+ case TemplateDeductionResult::Inconsistent: {
// If a function with a declared return type that contains a placeholder
// type has multiple return statements, the return type is deduced for
// each return statement. [...] if the type deduced is not the same in