clang  11.0.0git
Public Member Functions | List of all members
clang::PreferredTypeBuilder Class Reference

Keeps track of expected type during expression parsing. More...

#include "clang/Sema/Sema.h"

Public Member Functions

 PreferredTypeBuilder ()=default
 
 PreferredTypeBuilder (QualType Type)
 
void enterCondition (Sema &S, SourceLocation Tok)
 
void enterReturn (Sema &S, SourceLocation Tok)
 
void enterVariableInit (SourceLocation Tok, Decl *D)
 
void enterFunctionArgument (SourceLocation Tok, llvm::function_ref< QualType()> ComputeType)
 Computing a type for the function argument may require running overloading, so we postpone its computation until it is actually needed. More...
 
void enterParenExpr (SourceLocation Tok, SourceLocation LParLoc)
 
void enterUnary (Sema &S, SourceLocation Tok, tok::TokenKind OpKind, SourceLocation OpLoc)
 
void enterBinary (Sema &S, SourceLocation Tok, Expr *LHS, tok::TokenKind Op)
 
void enterMemAccess (Sema &S, SourceLocation Tok, Expr *Base)
 
void enterSubscript (Sema &S, SourceLocation Tok, Expr *LHS)
 
void enterTypeCast (SourceLocation Tok, QualType CastType)
 Handles all type casts, including C-style cast, C++ casts, etc. More...
 
QualType get (SourceLocation Tok) const
 

Detailed Description

Keeps track of expected type during expression parsing.

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 allows to avoid updating the type on hot paths in the parser.

Definition at line 293 of file Sema.h.

Constructor & Destructor Documentation

◆ PreferredTypeBuilder() [1/2]

clang::PreferredTypeBuilder::PreferredTypeBuilder ( )
default

◆ PreferredTypeBuilder() [2/2]

clang::PreferredTypeBuilder::PreferredTypeBuilder ( QualType  Type)
inlineexplicit

Definition at line 296 of file Sema.h.

Member Function Documentation

◆ enterBinary()

void PreferredTypeBuilder::enterBinary ( Sema S,
SourceLocation  Tok,
Expr LHS,
tok::TokenKind  Op 
)

◆ enterCondition()

void PreferredTypeBuilder::enterCondition ( Sema S,
SourceLocation  Tok 
)

Definition at line 573 of file SemaCodeComplete.cpp.

◆ enterFunctionArgument()

void PreferredTypeBuilder::enterFunctionArgument ( SourceLocation  Tok,
llvm::function_ref< QualType()>  ComputeType 
)

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.

Definition at line 408 of file SemaCodeComplete.cpp.

References clang::format::Tok.

Referenced by clang::Parser::ParseUnqualifiedId().

◆ enterMemAccess()

void PreferredTypeBuilder::enterMemAccess ( Sema S,
SourceLocation  Tok,
Expr Base 
)

Definition at line 539 of file SemaCodeComplete.cpp.

◆ enterParenExpr()

void PreferredTypeBuilder::enterParenExpr ( SourceLocation  Tok,
SourceLocation  LParLoc 
)

Definition at line 415 of file SemaCodeComplete.cpp.

References clang::format::Tok.

◆ enterReturn()

void PreferredTypeBuilder::enterReturn ( Sema S,
SourceLocation  Tok 
)

Definition at line 383 of file SemaCodeComplete.cpp.

◆ enterSubscript()

void PreferredTypeBuilder::enterSubscript ( Sema S,
SourceLocation  Tok,
Expr LHS 
)

Definition at line 559 of file SemaCodeComplete.cpp.

◆ enterTypeCast()

void PreferredTypeBuilder::enterTypeCast ( SourceLocation  Tok,
QualType  CastType 
)

Handles all type casts, including C-style cast, C++ casts, etc.

Definition at line 566 of file SemaCodeComplete.cpp.

References clang::QualType::getCanonicalType(), clang::QualType::isNull(), and clang::format::Tok.

◆ enterUnary()

void PreferredTypeBuilder::enterUnary ( Sema S,
SourceLocation  Tok,
tok::TokenKind  OpKind,
SourceLocation  OpLoc 
)

Definition at line 551 of file SemaCodeComplete.cpp.

◆ enterVariableInit()

void PreferredTypeBuilder::enterVariableInit ( SourceLocation  Tok,
Decl D 
)

Definition at line 401 of file SemaCodeComplete.cpp.

References clang::format::Tok.

◆ get()

QualType clang::PreferredTypeBuilder::get ( SourceLocation  Tok) const
inline

Definition at line 319 of file Sema.h.

Referenced by CheckArrayDesignatorSyntax(), and clang::Parser::ParseAssignmentExpression().


The documentation for this class was generated from the following files: