clang 19.0.0git
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
clang::SemaCodeCompletion Class Reference

#include "clang/Sema/SemaCodeCompletion.h"

Inheritance diagram for clang::SemaCodeCompletion:
Inheritance graph


struct  CodeCompleteExpressionData

Public Types

enum  ParserCompletionContext {
  PCC_Namespace , PCC_Class , PCC_ObjCInterface , PCC_ObjCImplementation ,
  PCC_ObjCInstanceVariableList , PCC_Template , PCC_MemberTemplate , PCC_Expression ,
  PCC_Statement , PCC_ForInit , PCC_Condition , PCC_RecoveryInFunction ,
  PCC_Type , PCC_ParenthesizedExpression , PCC_LocalDeclarationSpecifiers , PCC_TopLevelOrExpression
 Describes the context in which code completion occurs. More...
enum class  AttributeCompletion { Attribute , Scope , None }
using TemplateTy = OpaquePtr< TemplateName >
using DeclGroupPtrTy = OpaquePtr< DeclGroupRef >

Public Member Functions

 SemaCodeCompletion (Sema &S, CodeCompleteConsumer *CompletionConsumer)
void CodeCompleteModuleImport (SourceLocation ImportLoc, ModuleIdPath Path)
void CodeCompleteOrdinaryName (Scope *S, ParserCompletionContext CompletionContext)
void CodeCompleteDeclSpec (Scope *S, DeclSpec &DS, bool AllowNonIdentifiers, bool AllowNestedNameSpecifiers)
void CodeCompleteExpression (Scope *S, const CodeCompleteExpressionData &Data)
 Perform code-completion in an expression context when we know what type we're looking for.
void CodeCompleteExpression (Scope *S, QualType PreferredType, bool IsParenthesized=false)
void CodeCompleteMemberReferenceExpr (Scope *S, Expr *Base, Expr *OtherOpBase, SourceLocation OpLoc, bool IsArrow, bool IsBaseExprStatement, QualType PreferredType)
void CodeCompletePostfixExpression (Scope *S, ExprResult LHS, QualType PreferredType)
void CodeCompleteTag (Scope *S, unsigned TagSpec)
void CodeCompleteTypeQualifiers (DeclSpec &DS)
void CodeCompleteFunctionQualifiers (DeclSpec &DS, Declarator &D, const VirtSpecifiers *VS=nullptr)
void CodeCompleteBracketDeclarator (Scope *S)
void CodeCompleteCase (Scope *S)
void CodeCompleteAttribute (AttributeCommonInfo::Syntax Syntax, AttributeCompletion Completion=AttributeCompletion::Attribute, const IdentifierInfo *Scope=nullptr)
QualType ProduceCallSignatureHelp (Expr *Fn, ArrayRef< Expr * > Args, SourceLocation OpenParLoc)
 Determines the preferred type of the current function argument, by examining the signatures of all possible overloads.
QualType ProduceConstructorSignatureHelp (QualType Type, SourceLocation Loc, ArrayRef< Expr * > Args, SourceLocation OpenParLoc, bool Braced)
QualType ProduceCtorInitMemberSignatureHelp (Decl *ConstructorDecl, CXXScopeSpec SS, ParsedType TemplateTypeTy, ArrayRef< Expr * > ArgExprs, IdentifierInfo *II, SourceLocation OpenParLoc, bool Braced)
QualType ProduceTemplateArgumentSignatureHelp (TemplateTy, ArrayRef< ParsedTemplateArgument >, SourceLocation LAngleLoc)
void CodeCompleteInitializer (Scope *S, Decl *D)
void CodeCompleteDesignator (const QualType BaseType, llvm::ArrayRef< Expr * > InitExprs, const Designation &D)
 Trigger code completion for a record of BaseType.
void CodeCompleteAfterIf (Scope *S, bool IsBracedThen)
void CodeCompleteQualifiedId (Scope *S, CXXScopeSpec &SS, bool EnteringContext, bool IsUsingDeclaration, QualType BaseType, QualType PreferredType)
void CodeCompleteUsing (Scope *S)
void CodeCompleteUsingDirective (Scope *S)
void CodeCompleteNamespaceDecl (Scope *S)
void CodeCompleteNamespaceAliasDecl (Scope *S)
void CodeCompleteOperatorName (Scope *S)
void CodeCompleteConstructorInitializer (Decl *Constructor, ArrayRef< CXXCtorInitializer * > Initializers)
void CodeCompleteLambdaIntroducer (Scope *S, LambdaIntroducer &Intro, bool AfterAmpersand)
void CodeCompleteAfterFunctionEquals (Declarator &D)
void CodeCompleteObjCAtDirective (Scope *S)
void CodeCompleteObjCAtVisibility (Scope *S)
void CodeCompleteObjCAtStatement (Scope *S)
void CodeCompleteObjCAtExpression (Scope *S)
void CodeCompleteObjCPropertyFlags (Scope *S, ObjCDeclSpec &ODS)
void CodeCompleteObjCPropertyGetter (Scope *S)
void CodeCompleteObjCPropertySetter (Scope *S)
void CodeCompleteObjCPassingType (Scope *S, ObjCDeclSpec &DS, bool IsParameter)
void CodeCompleteObjCMessageReceiver (Scope *S)
void CodeCompleteObjCSuperMessage (Scope *S, SourceLocation SuperLoc, ArrayRef< const IdentifierInfo * > SelIdents, bool AtArgumentExpression)
void CodeCompleteObjCClassMessage (Scope *S, ParsedType Receiver, ArrayRef< const IdentifierInfo * > SelIdents, bool AtArgumentExpression, bool IsSuper=false)
void CodeCompleteObjCInstanceMessage (Scope *S, Expr *Receiver, ArrayRef< const IdentifierInfo * > SelIdents, bool AtArgumentExpression, ObjCInterfaceDecl *Super=nullptr)
void CodeCompleteObjCForCollection (Scope *S, DeclGroupPtrTy IterationVar)
void CodeCompleteObjCSelector (Scope *S, ArrayRef< const IdentifierInfo * > SelIdents)
void CodeCompleteObjCProtocolReferences (ArrayRef< IdentifierLocPair > Protocols)
void CodeCompleteObjCProtocolDecl (Scope *S)
void CodeCompleteObjCInterfaceDecl (Scope *S)
void CodeCompleteObjCClassForwardDecl (Scope *S)
void CodeCompleteObjCSuperclass (Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
void CodeCompleteObjCImplementationDecl (Scope *S)
void CodeCompleteObjCInterfaceCategory (Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
void CodeCompleteObjCImplementationCategory (Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
void CodeCompleteObjCPropertyDefinition (Scope *S)
void CodeCompleteObjCPropertySynthesizeIvar (Scope *S, IdentifierInfo *PropertyName)
void CodeCompleteObjCMethodDecl (Scope *S, std::optional< bool > IsInstanceMethod, ParsedType ReturnType)
void CodeCompleteObjCMethodDeclSelector (Scope *S, bool IsInstanceMethod, bool AtParameterName, ParsedType ReturnType, ArrayRef< const IdentifierInfo * > SelIdents)
void CodeCompleteObjCClassPropertyRefExpr (Scope *S, const IdentifierInfo &ClassName, SourceLocation ClassNameLoc, bool IsBaseExprStatement)
void CodeCompletePreprocessorDirective (bool InConditional)
void CodeCompleteInPreprocessorConditionalExclusion (Scope *S)
void CodeCompletePreprocessorMacroName (bool IsDefinition)
void CodeCompletePreprocessorExpression ()
void CodeCompletePreprocessorMacroArgument (Scope *S, IdentifierInfo *Macro, MacroInfo *MacroInfo, unsigned Argument)
void CodeCompleteIncludedFile (llvm::StringRef Dir, bool IsAngled)
void CodeCompleteNaturalLanguage ()
void CodeCompleteAvailabilityPlatformName ()
void GatherGlobalCodeCompletions (CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, SmallVectorImpl< CodeCompletionResult > &Results)
- Public Member Functions inherited from clang::SemaBase
 SemaBase (Sema &S)
ASTContextgetASTContext () const
DiagnosticsEnginegetDiagnostics () const
const LangOptionsgetLangOpts () const
SemaDiagnosticBuilder Diag (SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
 Emit a diagnostic.
SemaDiagnosticBuilder Diag (SourceLocation Loc, const PartialDiagnostic &PD, bool DeferHint=false)
 Emit a partial diagnostic.
PartialDiagnostic PDiag (unsigned DiagID=0)
 Build a partial diagnostic.

Public Attributes

 Code-completion consumer.
- Public Attributes inherited from clang::SemaBase

Detailed Description

Definition at line 37 of file SemaCodeCompletion.h.

Member Typedef Documentation

◆ DeclGroupPtrTy

Definition at line 42 of file SemaCodeCompletion.h.

◆ TemplateTy

Definition at line 41 of file SemaCodeCompletion.h.

Member Enumeration Documentation

◆ AttributeCompletion


Definition at line 117 of file SemaCodeCompletion.h.

◆ ParserCompletionContext

Describes the context in which code completion occurs.


Code completion occurs at top-level or namespace context.


Code completion occurs within a class, struct, or union.


Code completion occurs within an Objective-C interface, protocol, or category.


Code completion occurs within an Objective-C implementation or category implementation.


Code completion occurs within the list of instance variables in an Objective-C interface, protocol, category, or implementation.


Code completion occurs following one or more template headers.


Code completion occurs following one or more template headers within a class.


Code completion occurs within an expression.


Code completion occurs within a statement, which may also be an expression or a declaration.


Code completion occurs at the beginning of the initialization statement (or expression) in a for loop.


Code completion occurs within the condition of an if, while, switch, or for statement.


Code completion occurs within the body of a function on a recovery path, where we do not have a specific handle on our position in the grammar.


Code completion occurs where only a type is permitted.


Code completion occurs in a parenthesized expression, which might also be a type cast.


Code completion occurs within a sequence of declaration specifiers within a function, method, or block.


Code completion occurs at top-level in a REPL session.

Definition at line 48 of file SemaCodeCompletion.h.

Constructor & Destructor Documentation

◆ SemaCodeCompletion()

SemaCodeCompletion::SemaCodeCompletion ( Sema S,
CodeCompleteConsumer CompletionConsumer 

Definition at line 10350 of file SemaCodeComplete.cpp.

Member Function Documentation

◆ CodeCompleteAfterFunctionEquals()

void SemaCodeCompletion::CodeCompleteAfterFunctionEquals ( Declarator D)

◆ CodeCompleteAfterIf()

void SemaCodeCompletion::CodeCompleteAfterIf ( Scope S,
bool  IsBracedThen 

◆ CodeCompleteAttribute()

void SemaCodeCompletion::CodeCompleteAttribute ( AttributeCommonInfo::Syntax  Syntax,
AttributeCompletion  Completion = AttributeCompletion::Attribute,
const IdentifierInfo Scope = nullptr 

◆ CodeCompleteAvailabilityPlatformName()

void SemaCodeCompletion::CodeCompleteAvailabilityPlatformName ( )

◆ CodeCompleteBracketDeclarator()

void SemaCodeCompletion::CodeCompleteBracketDeclarator ( Scope S)

Definition at line 6008 of file SemaCodeComplete.cpp.

◆ CodeCompleteCase()

void SemaCodeCompletion::CodeCompleteCase ( Scope S)

◆ CodeCompleteConstructorInitializer()

void SemaCodeCompletion::CodeCompleteConstructorInitializer ( Decl Constructor,
ArrayRef< CXXCtorInitializer * >  Initializers 

◆ CodeCompleteDeclSpec()

void SemaCodeCompletion::CodeCompleteDeclSpec ( Scope S,
DeclSpec DS,
bool  AllowNonIdentifiers,
bool  AllowNestedNameSpecifiers 

◆ CodeCompleteDesignator()

void SemaCodeCompletion::CodeCompleteDesignator ( const QualType  BaseType,
llvm::ArrayRef< Expr * >  InitExprs,
const Designation D 

Trigger code completion for a record of BaseType.

InitExprs are expressions in the initializer list seen so far and D is the current Designation being parsed.

Definition at line 6577 of file SemaCodeComplete.cpp.

References clang::CodeCompletionContext::CCC_DotMemberAccess, clang::Sema::CurContext, getAsRecordDecl(), getDesignatedType(), HandleCodeCompleteResults(), clang::QualType::isNull(), and clang::Result.

◆ CodeCompleteExpression() [1/2]

void SemaCodeCompletion::CodeCompleteExpression ( Scope S,
const CodeCompleteExpressionData Data 

◆ CodeCompleteExpression() [2/2]

void SemaCodeCompletion::CodeCompleteExpression ( Scope S,
QualType  PreferredType,
bool  IsParenthesized = false 

Definition at line 4925 of file SemaCodeComplete.cpp.

◆ CodeCompleteFunctionQualifiers()

void SemaCodeCompletion::CodeCompleteFunctionQualifiers ( DeclSpec DS,
Declarator D,
const VirtSpecifiers VS = nullptr 

◆ CodeCompleteIncludedFile()

void SemaCodeCompletion::CodeCompleteIncludedFile ( llvm::StringRef  Dir,
bool  IsAngled 

◆ CodeCompleteInitializer()

void SemaCodeCompletion::CodeCompleteInitializer ( Scope S,
Decl D 

Definition at line 6612 of file SemaCodeComplete.cpp.

References clang::Data, and clang::ValueDecl::getType().

◆ CodeCompleteInPreprocessorConditionalExclusion()

void SemaCodeCompletion::CodeCompleteInPreprocessorConditionalExclusion ( Scope S)

Definition at line 10090 of file SemaCodeComplete.cpp.

References PCC_Namespace, and PCC_RecoveryInFunction.

◆ CodeCompleteLambdaIntroducer()

void SemaCodeCompletion::CodeCompleteLambdaIntroducer ( Scope S,
LambdaIntroducer Intro,
bool  AfterAmpersand 

◆ CodeCompleteMemberReferenceExpr()

void SemaCodeCompletion::CodeCompleteMemberReferenceExpr ( Scope S,
Expr Base,
Expr OtherOpBase,
SourceLocation  OpLoc,
bool  IsArrow,
bool  IsBaseExprStatement,
QualType  PreferredType 

◆ CodeCompleteModuleImport()

void SemaCodeCompletion::CodeCompleteModuleImport ( SourceLocation  ImportLoc,
ModuleIdPath  Path 

◆ CodeCompleteNamespaceAliasDecl()

void SemaCodeCompletion::CodeCompleteNamespaceAliasDecl ( Scope S)

◆ CodeCompleteNamespaceDecl()

void SemaCodeCompletion::CodeCompleteNamespaceDecl ( Scope S)

◆ CodeCompleteNaturalLanguage()

void SemaCodeCompletion::CodeCompleteNaturalLanguage ( )

◆ CodeCompleteObjCAtDirective()

void SemaCodeCompletion::CodeCompleteObjCAtDirective ( Scope S)

◆ CodeCompleteObjCAtExpression()

void SemaCodeCompletion::CodeCompleteObjCAtExpression ( Scope S)

◆ CodeCompleteObjCAtStatement()

void SemaCodeCompletion::CodeCompleteObjCAtStatement ( Scope S)

◆ CodeCompleteObjCAtVisibility()

void SemaCodeCompletion::CodeCompleteObjCAtVisibility ( Scope S)

◆ CodeCompleteObjCClassForwardDecl()

void SemaCodeCompletion::CodeCompleteObjCClassForwardDecl ( Scope S)

◆ CodeCompleteObjCClassMessage()

void SemaCodeCompletion::CodeCompleteObjCClassMessage ( Scope S,
ParsedType  Receiver,
ArrayRef< const IdentifierInfo * >  SelIdents,
bool  AtArgumentExpression,
bool  IsSuper = false 

◆ CodeCompleteObjCClassPropertyRefExpr()

void SemaCodeCompletion::CodeCompleteObjCClassPropertyRefExpr ( Scope S,
const IdentifierInfo ClassName,
SourceLocation  ClassNameLoc,
bool  IsBaseExprStatement 

◆ CodeCompleteObjCForCollection()

void SemaCodeCompletion::CodeCompleteObjCForCollection ( Scope S,
DeclGroupPtrTy  IterationVar 

◆ CodeCompleteObjCImplementationCategory()

void SemaCodeCompletion::CodeCompleteObjCImplementationCategory ( Scope S,
IdentifierInfo ClassName,
SourceLocation  ClassNameLoc 

◆ CodeCompleteObjCImplementationDecl()

void SemaCodeCompletion::CodeCompleteObjCImplementationDecl ( Scope S)

◆ CodeCompleteObjCInstanceMessage()

void SemaCodeCompletion::CodeCompleteObjCInstanceMessage ( Scope S,
Expr Receiver,
ArrayRef< const IdentifierInfo * >  SelIdents,
bool  AtArgumentExpression,
ObjCInterfaceDecl Super = nullptr 

◆ CodeCompleteObjCInterfaceCategory()

void SemaCodeCompletion::CodeCompleteObjCInterfaceCategory ( Scope S,
IdentifierInfo ClassName,
SourceLocation  ClassNameLoc 

◆ CodeCompleteObjCInterfaceDecl()

void SemaCodeCompletion::CodeCompleteObjCInterfaceDecl ( Scope S)

◆ CodeCompleteObjCMessageReceiver()

void SemaCodeCompletion::CodeCompleteObjCMessageReceiver ( Scope S)

◆ CodeCompleteObjCMethodDecl()

void SemaCodeCompletion::CodeCompleteObjCMethodDecl ( Scope S,
std::optional< bool IsInstanceMethod,
ParsedType  ReturnType 

◆ CodeCompleteObjCMethodDeclSelector()

void SemaCodeCompletion::CodeCompleteObjCMethodDeclSelector ( Scope S,
bool  IsInstanceMethod,
bool  AtParameterName,
ParsedType  ReturnType,
ArrayRef< const IdentifierInfo * >  SelIdents 

◆ CodeCompleteObjCPassingType()

void SemaCodeCompletion::CodeCompleteObjCPassingType ( Scope S,
ObjCDeclSpec DS,
bool  IsParameter 

◆ CodeCompleteObjCPropertyDefinition()

void SemaCodeCompletion::CodeCompleteObjCPropertyDefinition ( Scope S)

◆ CodeCompleteObjCPropertyFlags()

void SemaCodeCompletion::CodeCompleteObjCPropertyFlags ( Scope S,
ObjCDeclSpec ODS 

◆ CodeCompleteObjCPropertyGetter()

void SemaCodeCompletion::CodeCompleteObjCPropertyGetter ( Scope S)

◆ CodeCompleteObjCPropertySetter()

void SemaCodeCompletion::CodeCompleteObjCPropertySetter ( Scope S)

◆ CodeCompleteObjCPropertySynthesizeIvar()

void SemaCodeCompletion::CodeCompleteObjCPropertySynthesizeIvar ( Scope S,
IdentifierInfo PropertyName 

◆ CodeCompleteObjCProtocolDecl()

void SemaCodeCompletion::CodeCompleteObjCProtocolDecl ( Scope S)

◆ CodeCompleteObjCProtocolReferences()

void SemaCodeCompletion::CodeCompleteObjCProtocolReferences ( ArrayRef< IdentifierLocPair Protocols)

◆ CodeCompleteObjCSelector()

void SemaCodeCompletion::CodeCompleteObjCSelector ( Scope S,
ArrayRef< const IdentifierInfo * >  SelIdents 

◆ CodeCompleteObjCSuperclass()

void SemaCodeCompletion::CodeCompleteObjCSuperclass ( Scope S,
IdentifierInfo ClassName,
SourceLocation  ClassNameLoc 

◆ CodeCompleteObjCSuperMessage()

void SemaCodeCompletion::CodeCompleteObjCSuperMessage ( Scope S,
SourceLocation  SuperLoc,
ArrayRef< const IdentifierInfo * >  SelIdents,
bool  AtArgumentExpression 

◆ CodeCompleteOperatorName()

void SemaCodeCompletion::CodeCompleteOperatorName ( Scope S)

◆ CodeCompleteOrdinaryName()

void SemaCodeCompletion::CodeCompleteOrdinaryName ( Scope S,
SemaCodeCompletion::ParserCompletionContext  CompletionContext 

◆ CodeCompletePostfixExpression()

void SemaCodeCompletion::CodeCompletePostfixExpression ( Scope S,
ExprResult  LHS,
QualType  PreferredType 

◆ CodeCompletePreprocessorDirective()

void SemaCodeCompletion::CodeCompletePreprocessorDirective ( bool  InConditional)

◆ CodeCompletePreprocessorExpression()

void SemaCodeCompletion::CodeCompletePreprocessorExpression ( )

◆ CodeCompletePreprocessorMacroArgument()

void SemaCodeCompletion::CodeCompletePreprocessorMacroArgument ( Scope S,
IdentifierInfo Macro,
MacroInfo MacroInfo,
unsigned  Argument 

Definition at line 10150 of file SemaCodeComplete.cpp.

◆ CodeCompletePreprocessorMacroName()

void SemaCodeCompletion::CodeCompletePreprocessorMacroName ( bool  IsDefinition)

◆ CodeCompleteQualifiedId()

void SemaCodeCompletion::CodeCompleteQualifiedId ( Scope S,
CXXScopeSpec SS,
bool  EnteringContext,
bool  IsUsingDeclaration,
QualType  BaseType,
QualType  PreferredType 

◆ CodeCompleteTag()

void SemaCodeCompletion::CodeCompleteTag ( Scope S,
unsigned  TagSpec 

◆ CodeCompleteTypeQualifiers()

void SemaCodeCompletion::CodeCompleteTypeQualifiers ( DeclSpec DS)

◆ CodeCompleteUsing()

void SemaCodeCompletion::CodeCompleteUsing ( Scope S)

◆ CodeCompleteUsingDirective()

void SemaCodeCompletion::CodeCompleteUsingDirective ( Scope S)

◆ GatherGlobalCodeCompletions()

void SemaCodeCompletion::GatherGlobalCodeCompletions ( CodeCompletionAllocator Allocator,
CodeCompletionTUInfo CCTUInfo,
SmallVectorImpl< CodeCompletionResult > &  Results 

◆ ProduceCallSignatureHelp()

QualType SemaCodeCompletion::ProduceCallSignatureHelp ( Expr Fn,
ArrayRef< Expr * >  Args,
SourceLocation  OpenParLoc 

◆ ProduceConstructorSignatureHelp()

QualType SemaCodeCompletion::ProduceConstructorSignatureHelp ( QualType  Type,
SourceLocation  Loc,
ArrayRef< Expr * >  Args,
SourceLocation  OpenParLoc,
bool  Braced 

◆ ProduceCtorInitMemberSignatureHelp()

QualType SemaCodeCompletion::ProduceCtorInitMemberSignatureHelp ( Decl ConstructorDecl,
CXXScopeSpec  SS,
ParsedType  TemplateTypeTy,
ArrayRef< Expr * >  ArgExprs,
IdentifierInfo II,
SourceLocation  OpenParLoc,
bool  Braced 

Definition at line 6478 of file SemaCodeComplete.cpp.

References clang::Sema::tryLookupCtorInitMemberDecl().

◆ ProduceTemplateArgumentSignatureHelp()

QualType SemaCodeCompletion::ProduceTemplateArgumentSignatureHelp ( TemplateTy  ParsedTemplate,
ArrayRef< ParsedTemplateArgument Args,
SourceLocation  LAngleLoc 

Member Data Documentation

◆ CodeCompleter

CodeCompleteConsumer* clang::SemaCodeCompletion::CodeCompleter

Code-completion consumer.

Definition at line 45 of file SemaCodeCompletion.h.

Referenced by AddRecordMembersCompletionResults(), and ProduceSignatureHelp().

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