Skip to content

Commit 60a2794

Browse files
committed
Reduce more calls to getCanonicalSizeType
1 parent 18523f1 commit 60a2794

File tree

4 files changed

+18
-19
lines changed

4 files changed

+18
-19
lines changed

clang/lib/CodeGen/CGCoroutine.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,15 +1002,15 @@ RValue CodeGenFunction::EmitCoroutineIntrinsic(const CallExpr *E,
10021002
}
10031003
case llvm::Intrinsic::coro_size: {
10041004
auto &Context = getContext();
1005-
CanQualType SizeTy = Context.getCanonicalSizeType();
1006-
llvm::IntegerType *T = Builder.getIntNTy(Context.getTypeSize(SizeTy));
1005+
llvm::IntegerType *T =
1006+
Builder.getIntNTy(Context.getTypeSize(Context.getSizeType()));
10071007
llvm::Function *F = CGM.getIntrinsic(llvm::Intrinsic::coro_size, T);
10081008
return RValue::get(Builder.CreateCall(F));
10091009
}
10101010
case llvm::Intrinsic::coro_align: {
10111011
auto &Context = getContext();
1012-
CanQualType SizeTy = Context.getCanonicalSizeType();
1013-
llvm::IntegerType *T = Builder.getIntNTy(Context.getTypeSize(SizeTy));
1012+
llvm::IntegerType *T =
1013+
Builder.getIntNTy(Context.getTypeSize(Context.getSizeType()));
10141014
llvm::Function *F = CGM.getIntrinsic(llvm::Intrinsic::coro_align, T);
10151015
return RValue::get(Builder.CreateCall(F));
10161016
}

clang/lib/Sema/SemaChecking.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5238,8 +5238,10 @@ bool Sema::BuiltinVAStartARMMicrosoft(CallExpr *Call) {
52385238
<< 3 /* parameter mismatch */
52395239
<< 2 << Arg1->getType() << ConstCharPtrTy;
52405240

5241-
const QualType SizeTy = Context.getCanonicalSizeType();
5242-
if (Arg2Ty->getCanonicalTypeInternal().withoutLocalFastQualifiers() != SizeTy)
5241+
const QualType SizeTy = Context.getSizeType();
5242+
if (!Context.hasSameType(
5243+
Arg2Ty->getCanonicalTypeInternal().withoutLocalFastQualifiers(),
5244+
SizeTy))
52435245
Diag(Arg2->getBeginLoc(), diag::err_typecheck_convert_incompatible)
52445246
<< Arg2->getType() << SizeTy << 1 /* different class */
52455247
<< 0 /* qualifier difference */

clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,22 +1280,19 @@ static bool isStandardRealloc(const CallEvent &Call) {
12801280
const FunctionDecl *FD = dyn_cast<FunctionDecl>(Call.getDecl());
12811281
assert(FD);
12821282
ASTContext &AC = FD->getASTContext();
1283-
1284-
return FD->getDeclaredReturnType().getDesugaredType(AC) == AC.VoidPtrTy &&
1285-
FD->getParamDecl(0)->getType().getDesugaredType(AC) == AC.VoidPtrTy &&
1286-
FD->getParamDecl(1)->getType().getDesugaredType(AC) ==
1287-
AC.getCanonicalSizeType();
1283+
return AC.hasSameType(FD->getDeclaredReturnType(), AC.VoidPtrTy) &&
1284+
AC.hasSameType(FD->getParamDecl(0)->getType(), AC.VoidPtrTy) &&
1285+
AC.hasSameType(FD->getParamDecl(1)->getType(), AC.getSizeType());
12881286
}
12891287

12901288
static bool isGRealloc(const CallEvent &Call) {
12911289
const FunctionDecl *FD = dyn_cast<FunctionDecl>(Call.getDecl());
12921290
assert(FD);
12931291
ASTContext &AC = FD->getASTContext();
12941292

1295-
return FD->getDeclaredReturnType().getDesugaredType(AC) == AC.VoidPtrTy &&
1296-
FD->getParamDecl(0)->getType().getDesugaredType(AC) == AC.VoidPtrTy &&
1297-
FD->getParamDecl(1)->getType().getDesugaredType(AC) ==
1298-
AC.UnsignedLongTy;
1293+
return AC.hasSameType(FD->getDeclaredReturnType(), AC.VoidPtrTy) &&
1294+
AC.hasSameType(FD->getParamDecl(0)->getType(), AC.VoidPtrTy) &&
1295+
AC.hasSameType(FD->getParamDecl(1)->getType(), AC.UnsignedLongTy);
12991296
}
13001297

13011298
void MallocChecker::checkRealloc(ProgramStateRef State, const CallEvent &Call,
@@ -1906,7 +1903,7 @@ void MallocChecker::checkTaintedness(CheckerContext &C, const CallEvent &Call,
19061903
return;
19071904

19081905
SValBuilder &SVB = C.getSValBuilder();
1909-
QualType SizeTy = SVB.getContext().getCanonicalSizeType();
1906+
QualType SizeTy = SVB.getContext().getSizeType();
19101907
QualType CmpTy = SVB.getConditionType();
19111908
// In case the symbol is tainted, we give a warning if the
19121909
// size is larger than SIZE_MAX/4

clang/test/SemaCXX/microsoft-varargs-diagnostics.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,21 @@ void test_non_last_argument(int i, int j, ...) {
2222
va_list ap;
2323
__va_start(&ap, &i, 4);
2424
// expected-error@-1{{passing 'int *' to parameter of incompatible type 'const char *': type mismatch at 2nd parameter ('int *' vs 'const char *')}}
25-
// expected-error@-2{{passing 'int' to parameter of incompatible type 'unsigned int': type mismatch at 3rd parameter ('int' vs 'unsigned int')}}
25+
// expected-error@-2{{passing 'int' to parameter of incompatible type '__size_t' (aka 'unsigned int'): type mismatch at 3rd parameter ('int' vs '__size_t' (aka 'unsigned int'))}}
2626
}
2727

2828
void test_stack_allocated(int i, ...) {
2929
va_list ap;
3030
int j;
3131
__va_start(&ap, &j, 4);
3232
// expected-error@-1{{passing 'int *' to parameter of incompatible type 'const char *': type mismatch at 2nd parameter ('int *' vs 'const char *')}}
33-
// expected-error@-2{{passing 'int' to parameter of incompatible type 'unsigned int': type mismatch at 3rd parameter ('int' vs 'unsigned int')}}
33+
// expected-error@-2{{passing 'int' to parameter of incompatible type '__size_t' (aka 'unsigned int'): type mismatch at 3rd parameter ('int' vs '__size_t' (aka 'unsigned int'))}}
3434
}
3535

3636
void test_non_pointer_addressof(int i, ...) {
3737
va_list ap;
3838
__va_start(&ap, 1, 4);
3939
// expected-error@-1{{passing 'int' to parameter of incompatible type 'const char *': type mismatch at 2nd parameter ('int' vs 'const char *')}}
40-
// expected-error@-2{{passing 'int' to parameter of incompatible type 'unsigned int': type mismatch at 3rd parameter ('int' vs 'unsigned int')}}
40+
// expected-error@-2{{passing 'int' to parameter of incompatible type '__size_t' (aka 'unsigned int'): type mismatch at 3rd parameter ('int' vs '__size_t' (aka 'unsigned int'))}}
4141
}
4242

0 commit comments

Comments
 (0)