[clang] [sema] Improve -Wsign-compare (PR #65684)
Shafik Yaghmour via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 8 08:37:24 PDT 2023
================
@@ -15277,35 +15351,33 @@ static void CheckImplicitConversion(Sema &S, Expr *E, QualType T,
}
}
-static void CheckConditionalOperator(Sema &S, AbstractConditionalOperator *E,
- SourceLocation CC, QualType T);
-
-static void CheckConditionalOperand(Sema &S, Expr *E, QualType T,
- SourceLocation CC, bool &ICContext) {
+void ImplicitConversionChecker::CheckConditionalOperand(Expr *E, QualType T,
+ SourceLocation CC,
+ bool &ICContext) {
E = E->IgnoreParenImpCasts();
// Diagnose incomplete type for second or third operand in C.
if (!S.getLangOpts().CPlusPlus && E->getType()->isRecordType())
S.RequireCompleteExprType(E, diag::err_incomplete_type);
if (auto *CO = dyn_cast<AbstractConditionalOperator>(E))
- return CheckConditionalOperator(S, CO, CC, T);
+ return CheckConditionalOperator(CO, CC, T);
- AnalyzeImplicitConversions(S, E, CC);
+ AnalyzeImplicitConversions(E, CC, false, true);
if (E->getType() != T)
return CheckImplicitConversion(S, E, T, CC, &ICContext);
}
-static void CheckConditionalOperator(Sema &S, AbstractConditionalOperator *E,
- SourceLocation CC, QualType T) {
- AnalyzeImplicitConversions(S, E->getCond(), E->getQuestionLoc());
+void ImplicitConversionChecker::CheckConditionalOperator(
+ AbstractConditionalOperator *E, SourceLocation CC, QualType T) {
+ AnalyzeImplicitConversions(E->getCond(), E->getQuestionLoc(), false, true);
----------------
shafik wrote:
```suggestion
AnalyzeImplicitConversions(E->getCond(), E->getQuestionLoc(), /*IsInitList=*/false, /*IsTopLevelExpr=*/true);
```
https://github.com/llvm/llvm-project/pull/65684
More information about the cfe-commits
mailing list