class PreferredTypeBuilder
Declaration
class PreferredTypeBuilder { /* full declaration omitted */ };
Description
Tracks expected type during expression parsing, for use in code completion. The type is tied to a particular token, all functions that update or consume the type take a start location of the token they are looking at as a parameter. This avoids updating the type on hot paths in the parser.
Declared at: clang/include/clang/Sema/Sema.h:296
Member Variables
- private bool Enabled
- private clang::SourceLocation ExpectedLoc
- Start position of a token for which we store expected type.
- private clang::QualType Type
- Expected type for a token starting at ExpectedLoc.
- private llvm::function_ref<QualType()> ComputeType
- A function to compute expected type at ExpectedLoc. It is only considered if Type is null.
Method Overview
- public PreferredTypeBuilder(bool Enabled)
- public void enterBinary(clang::Sema & S, clang::SourceLocation Tok, clang::Expr * LHS, tok::TokenKind Op)
- public void enterCondition(clang::Sema & S, clang::SourceLocation Tok)
- public void enterDesignatedInitializer(clang::SourceLocation Tok, clang::QualType BaseType, const clang::Designation & D)
- public void enterFunctionArgument(clang::SourceLocation Tok, llvm::function_ref<QualType ()> ComputeType)
- public void enterMemAccess(clang::Sema & S, clang::SourceLocation Tok, clang::Expr * Base)
- public void enterParenExpr(clang::SourceLocation Tok, clang::SourceLocation LParLoc)
- public void enterReturn(clang::Sema & S, clang::SourceLocation Tok)
- public void enterSubscript(clang::Sema & S, clang::SourceLocation Tok, clang::Expr * LHS)
- public void enterTypeCast(clang::SourceLocation Tok, clang::QualType CastType)
- public void enterUnary(clang::Sema & S, clang::SourceLocation Tok, tok::TokenKind OpKind, clang::SourceLocation OpLoc)
- public void enterVariableInit(clang::SourceLocation Tok, clang::Decl * D)
- public clang::QualType get(clang::SourceLocation Tok) const
Methods
¶PreferredTypeBuilder(bool Enabled)
PreferredTypeBuilder(bool Enabled)
Declared at: clang/include/clang/Sema/Sema.h:298
Parameters
- bool Enabled
¶void enterBinary(clang::Sema& S,
clang::SourceLocation Tok,
clang::Expr* LHS,
tok::TokenKind Op)
void enterBinary(clang::Sema& S,
clang::SourceLocation Tok,
clang::Expr* LHS,
tok::TokenKind Op)
Declared at: clang/include/clang/Sema/Sema.h:321
Parameters
- clang::Sema& S
- clang::SourceLocation Tok
- clang::Expr* LHS
- tok::TokenKind Op
¶void enterCondition(clang::Sema& S,
clang::SourceLocation Tok)
void enterCondition(clang::Sema& S,
clang::SourceLocation Tok)
Declared at: clang/include/clang/Sema/Sema.h:300
Parameters
¶void enterDesignatedInitializer(
clang::SourceLocation Tok,
clang::QualType BaseType,
const clang::Designation& D)
void enterDesignatedInitializer(
clang::SourceLocation Tok,
clang::QualType BaseType,
const clang::Designation& D)
Description
Handles e.g. BaseType{ .D = Tok...
Declared at: clang/include/clang/Sema/Sema.h:304
Parameters
- clang::SourceLocation Tok
- clang::QualType BaseType
- const clang::Designation& D
¶void enterFunctionArgument(
clang::SourceLocation Tok,
llvm::function_ref<QualType()> ComputeType)
void enterFunctionArgument(
clang::SourceLocation Tok,
llvm::function_ref<QualType()> ComputeType)
Description
Computing a type for the function argument may require running overloading, so we postpone its computation until it is actually needed. Clients should be very careful when using this funciton, as it stores a function_ref, clients should make sure all calls to get() with the same location happen while function_ref is alive. The callback should also emit signature help as a side-effect, but only if the completion point has been reached.
Declared at: clang/include/clang/Sema/Sema.h:315
Parameters
- clang::SourceLocation Tok
- llvm::function_ref<QualType()> ComputeType
¶void enterMemAccess(clang::Sema& S,
clang::SourceLocation Tok,
clang::Expr* Base)
void enterMemAccess(clang::Sema& S,
clang::SourceLocation Tok,
clang::Expr* Base)
Declared at: clang/include/clang/Sema/Sema.h:322
Parameters
- clang::Sema& S
- clang::SourceLocation Tok
- clang::Expr* Base
¶void enterParenExpr(clang::SourceLocation Tok,
clang::SourceLocation LParLoc)
void enterParenExpr(clang::SourceLocation Tok,
clang::SourceLocation LParLoc)
Declared at: clang/include/clang/Sema/Sema.h:318
Parameters
- clang::SourceLocation Tok
- clang::SourceLocation LParLoc
¶void enterReturn(clang::Sema& S,
clang::SourceLocation Tok)
void enterReturn(clang::Sema& S,
clang::SourceLocation Tok)
Declared at: clang/include/clang/Sema/Sema.h:301
Parameters
¶void enterSubscript(clang::Sema& S,
clang::SourceLocation Tok,
clang::Expr* LHS)
void enterSubscript(clang::Sema& S,
clang::SourceLocation Tok,
clang::Expr* LHS)
Declared at: clang/include/clang/Sema/Sema.h:323
Parameters
- clang::Sema& S
- clang::SourceLocation Tok
- clang::Expr* LHS
¶void enterTypeCast(clang::SourceLocation Tok,
clang::QualType CastType)
void enterTypeCast(clang::SourceLocation Tok,
clang::QualType CastType)
Description
Handles all type casts, including C-style cast, C++ casts, etc.
Declared at: clang/include/clang/Sema/Sema.h:325
Parameters
- clang::SourceLocation Tok
- clang::QualType CastType
¶void enterUnary(clang::Sema& S,
clang::SourceLocation Tok,
tok::TokenKind OpKind,
clang::SourceLocation OpLoc)
void enterUnary(clang::Sema& S,
clang::SourceLocation Tok,
tok::TokenKind OpKind,
clang::SourceLocation OpLoc)
Declared at: clang/include/clang/Sema/Sema.h:319
Parameters
- clang::Sema& S
- clang::SourceLocation Tok
- tok::TokenKind OpKind
- clang::SourceLocation OpLoc
¶void enterVariableInit(clang::SourceLocation Tok,
clang::Decl* D)
void enterVariableInit(clang::SourceLocation Tok,
clang::Decl* D)
Declared at: clang/include/clang/Sema/Sema.h:302
Parameters
¶clang::QualType get(
clang::SourceLocation Tok) const
clang::QualType get(
clang::SourceLocation Tok) const
Description
Get the expected type associated with this location, if any. If the location is a function argument, determining the expected type involves considering all function overloads and the arguments so far. In this case, signature help for these function overloads will be reported as a side-effect (only if the completion point has been reached).
Declared at: clang/include/clang/Sema/Sema.h:333