diff options
Diffstat (limited to 'clang/lib/Sema/SemaCodeComplete.cpp')
-rw-r--r-- | clang/lib/Sema/SemaCodeComplete.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index 2feb02b..18605b32 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -381,6 +381,8 @@ public: } // namespace void PreferredTypeBuilder::enterReturn(Sema &S, SourceLocation Tok) { + if (!Enabled) + return; if (isa<BlockDecl>(S.CurContext)) { if (sema::BlockScopeInfo *BSI = S.getCurBlock()) { ComputeType = nullptr; @@ -399,6 +401,8 @@ void PreferredTypeBuilder::enterReturn(Sema &S, SourceLocation Tok) { } void PreferredTypeBuilder::enterVariableInit(SourceLocation Tok, Decl *D) { + if (!Enabled) + return; auto *VD = llvm::dyn_cast_or_null<ValueDecl>(D); ComputeType = nullptr; Type = VD ? VD->getType() : QualType(); @@ -410,6 +414,8 @@ static QualType getDesignatedType(QualType BaseType, const Designation &Desig); void PreferredTypeBuilder::enterDesignatedInitializer(SourceLocation Tok, QualType BaseType, const Designation &D) { + if (!Enabled) + return; ComputeType = nullptr; Type = getDesignatedType(BaseType, D); ExpectedLoc = Tok; @@ -417,6 +423,8 @@ void PreferredTypeBuilder::enterDesignatedInitializer(SourceLocation Tok, void PreferredTypeBuilder::enterFunctionArgument( SourceLocation Tok, llvm::function_ref<QualType()> ComputeType) { + if (!Enabled) + return; this->ComputeType = ComputeType; Type = QualType(); ExpectedLoc = Tok; @@ -424,6 +432,8 @@ void PreferredTypeBuilder::enterFunctionArgument( void PreferredTypeBuilder::enterParenExpr(SourceLocation Tok, SourceLocation LParLoc) { + if (!Enabled) + return; // expected type for parenthesized expression does not change. if (ExpectedLoc == LParLoc) ExpectedLoc = Tok; @@ -541,6 +551,8 @@ static QualType getPreferredTypeOfUnaryArg(Sema &S, QualType ContextType, void PreferredTypeBuilder::enterBinary(Sema &S, SourceLocation Tok, Expr *LHS, tok::TokenKind Op) { + if (!Enabled) + return; ComputeType = nullptr; Type = getPreferredTypeOfBinaryRHS(S, LHS, Op); ExpectedLoc = Tok; @@ -548,7 +560,7 @@ void PreferredTypeBuilder::enterBinary(Sema &S, SourceLocation Tok, Expr *LHS, void PreferredTypeBuilder::enterMemAccess(Sema &S, SourceLocation Tok, Expr *Base) { - if (!Base) + if (!Enabled || !Base) return; // Do we have expected type for Base? if (ExpectedLoc != Base->getBeginLoc()) @@ -561,6 +573,8 @@ void PreferredTypeBuilder::enterMemAccess(Sema &S, SourceLocation Tok, void PreferredTypeBuilder::enterUnary(Sema &S, SourceLocation Tok, tok::TokenKind OpKind, SourceLocation OpLoc) { + if (!Enabled) + return; ComputeType = nullptr; Type = getPreferredTypeOfUnaryArg(S, this->get(OpLoc), OpKind); ExpectedLoc = Tok; @@ -568,6 +582,8 @@ void PreferredTypeBuilder::enterUnary(Sema &S, SourceLocation Tok, void PreferredTypeBuilder::enterSubscript(Sema &S, SourceLocation Tok, Expr *LHS) { + if (!Enabled) + return; ComputeType = nullptr; Type = S.getASTContext().IntTy; ExpectedLoc = Tok; @@ -575,12 +591,16 @@ void PreferredTypeBuilder::enterSubscript(Sema &S, SourceLocation Tok, void PreferredTypeBuilder::enterTypeCast(SourceLocation Tok, QualType CastType) { + if (!Enabled) + return; ComputeType = nullptr; Type = !CastType.isNull() ? CastType.getCanonicalType() : QualType(); ExpectedLoc = Tok; } void PreferredTypeBuilder::enterCondition(Sema &S, SourceLocation Tok) { + if (!Enabled) + return; ComputeType = nullptr; Type = S.getASTContext().BoolTy; ExpectedLoc = Tok; |