@@ -381,6 +381,8 @@ class ResultBuilder {
381
381
} // namespace
382
382
383
383
void PreferredTypeBuilder::enterReturn (Sema &S, SourceLocation Tok) {
384
+ if (!Enabled)
385
+ return ;
384
386
if (isa<BlockDecl>(S.CurContext )) {
385
387
if (sema::BlockScopeInfo *BSI = S.getCurBlock ()) {
386
388
ComputeType = nullptr ;
@@ -399,6 +401,8 @@ void PreferredTypeBuilder::enterReturn(Sema &S, SourceLocation Tok) {
399
401
}
400
402
401
403
void PreferredTypeBuilder::enterVariableInit (SourceLocation Tok, Decl *D) {
404
+ if (!Enabled)
405
+ return ;
402
406
auto *VD = llvm::dyn_cast_or_null<ValueDecl>(D);
403
407
ComputeType = nullptr ;
404
408
Type = VD ? VD->getType () : QualType ();
@@ -410,20 +414,26 @@ static QualType getDesignatedType(QualType BaseType, const Designation &Desig);
410
414
void PreferredTypeBuilder::enterDesignatedInitializer (SourceLocation Tok,
411
415
QualType BaseType,
412
416
const Designation &D) {
417
+ if (!Enabled)
418
+ return ;
413
419
ComputeType = nullptr ;
414
420
Type = getDesignatedType (BaseType, D);
415
421
ExpectedLoc = Tok;
416
422
}
417
423
418
424
void PreferredTypeBuilder::enterFunctionArgument (
419
425
SourceLocation Tok, llvm::function_ref<QualType()> ComputeType) {
426
+ if (!Enabled)
427
+ return ;
420
428
this ->ComputeType = ComputeType;
421
429
Type = QualType ();
422
430
ExpectedLoc = Tok;
423
431
}
424
432
425
433
void PreferredTypeBuilder::enterParenExpr (SourceLocation Tok,
426
434
SourceLocation LParLoc) {
435
+ if (!Enabled)
436
+ return ;
427
437
// expected type for parenthesized expression does not change.
428
438
if (ExpectedLoc == LParLoc)
429
439
ExpectedLoc = Tok;
@@ -541,14 +551,16 @@ static QualType getPreferredTypeOfUnaryArg(Sema &S, QualType ContextType,
541
551
542
552
void PreferredTypeBuilder::enterBinary (Sema &S, SourceLocation Tok, Expr *LHS,
543
553
tok::TokenKind Op) {
554
+ if (!Enabled)
555
+ return ;
544
556
ComputeType = nullptr ;
545
557
Type = getPreferredTypeOfBinaryRHS (S, LHS, Op);
546
558
ExpectedLoc = Tok;
547
559
}
548
560
549
561
void PreferredTypeBuilder::enterMemAccess (Sema &S, SourceLocation Tok,
550
562
Expr *Base) {
551
- if (!Base)
563
+ if (!Enabled || ! Base)
552
564
return ;
553
565
// Do we have expected type for Base?
554
566
if (ExpectedLoc != Base->getBeginLoc ())
@@ -561,26 +573,34 @@ void PreferredTypeBuilder::enterMemAccess(Sema &S, SourceLocation Tok,
561
573
void PreferredTypeBuilder::enterUnary (Sema &S, SourceLocation Tok,
562
574
tok::TokenKind OpKind,
563
575
SourceLocation OpLoc) {
576
+ if (!Enabled)
577
+ return ;
564
578
ComputeType = nullptr ;
565
579
Type = getPreferredTypeOfUnaryArg (S, this ->get (OpLoc), OpKind);
566
580
ExpectedLoc = Tok;
567
581
}
568
582
569
583
void PreferredTypeBuilder::enterSubscript (Sema &S, SourceLocation Tok,
570
584
Expr *LHS) {
585
+ if (!Enabled)
586
+ return ;
571
587
ComputeType = nullptr ;
572
588
Type = S.getASTContext ().IntTy ;
573
589
ExpectedLoc = Tok;
574
590
}
575
591
576
592
void PreferredTypeBuilder::enterTypeCast (SourceLocation Tok,
577
593
QualType CastType) {
594
+ if (!Enabled)
595
+ return ;
578
596
ComputeType = nullptr ;
579
597
Type = !CastType.isNull () ? CastType.getCanonicalType () : QualType ();
580
598
ExpectedLoc = Tok;
581
599
}
582
600
583
601
void PreferredTypeBuilder::enterCondition (Sema &S, SourceLocation Tok) {
602
+ if (!Enabled)
603
+ return ;
584
604
ComputeType = nullptr ;
585
605
Type = S.getASTContext ().BoolTy ;
586
606
ExpectedLoc = Tok;
0 commit comments