clang  6.0.0svn
Classes | Macros | Typedefs | Enumerations | Functions
SemaCodeComplete.cpp File Reference
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/ExprObjC.h"
#include "clang/AST/QualTypeNames.h"
#include "clang/Basic/CharInfo.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/MacroInfo.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Sema/CodeCompleteConsumer.h"
#include "clang/Sema/Lookup.h"
#include "clang/Sema/Overload.h"
#include "clang/Sema/Scope.h"
#include "clang/Sema/ScopeInfo.h"
#include "clang/Sema/SemaInternal.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/SmallBitVector.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/Twine.h"
#include <list>
#include <map>
#include <vector>
#include "clang/Basic/OperatorKinds.def"
Include dependency graph for SemaCodeComplete.cpp:

Go to the source code of this file.

Classes

class  ResultBuilder::ShadowMapEntry::iterator
 
class  ResultBuilder::ShadowMapEntry::iterator::pointer
 
struct  clang::Sema::CodeCompleteExpressionData
 

Macros

#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly)   case OO_##Name: OperatorName = "operator" Spelling; break;
 
#define OVERLOADED_OPERATOR_MULTI(Name, Spelling, Unary, Binary, MemberOnly)
 
#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly)
 
#define OBJC_AT_KEYWORD_NAME(NeedAt, Keyword)   ((NeedAt)? "@" Keyword : Keyword)
 Macro that optionally prepends an "@" to the string literal passed in via Keyword, depending on whether NeedAt is true or false. More...
 

Typedefs

typedef llvm::SmallPtrSet< IdentifierInfo *, 16 > AddedPropertiesSet
 The set of properties that have already been added, referenced by property name. More...
 
typedef CodeCompleteConsumer::OverloadCandidate ResultCandidate
 
typedef llvm::DenseMap< Selector, llvm::PointerIntPair< ObjCMethodDecl *, 1, bool > > KnownMethodsMap
 

Enumerations

enum  ObjCMethodKind { MK_Any, MK_ZeroArgSelector, MK_OneArgSelector }
 Describes the kind of Objective-C method that we want to find via code completion. More...
 

Functions

static NestedNameSpecifiergetRequiredQualification (ASTContext &Context, const DeclContext *CurContext, const DeclContext *TargetContext)
 Compute the qualification required to get from the current context (CurContext) to the target context (TargetContext). More...
 
static bool isReservedName (const IdentifierInfo *Id, bool doubleUnderscoreOnly=false)
 Determine whether Id is a name reserved for the implementation (C99 7.1.3, C++ [lib.global.names]). More...
 
static bool shouldIgnoreDueToReservedName (const NamedDecl *ND, Sema &SemaRef)
 
static bool isObjCReceiverType (ASTContext &C, QualType T)
 
static void AddTypeSpecifierResults (const LangOptions &LangOpts, ResultBuilder &Results)
 Add type specifiers for the current language as keyword results. More...
 
static void AddStorageSpecifiers (Sema::ParserCompletionContext CCC, const LangOptions &LangOpts, ResultBuilder &Results)
 
static void AddFunctionSpecifiers (Sema::ParserCompletionContext CCC, const LangOptions &LangOpts, ResultBuilder &Results)
 
static void AddObjCExpressionResults (ResultBuilder &Results, bool NeedAt)
 
static void AddObjCStatementResults (ResultBuilder &Results, bool NeedAt)
 
static void AddObjCVisibilityResults (const LangOptions &LangOpts, ResultBuilder &Results, bool NeedAt)
 
static void AddObjCImplementationResults (const LangOptions &LangOpts, ResultBuilder &Results, bool NeedAt)
 
static void AddObjCInterfaceResults (const LangOptions &LangOpts, ResultBuilder &Results, bool NeedAt)
 
static void AddObjCTopLevelResults (ResultBuilder &Results, bool NeedAt)
 
static void AddTypedefResult (ResultBuilder &Results)
 
static bool WantTypesInContext (Sema::ParserCompletionContext CCC, const LangOptions &LangOpts)
 
static PrintingPolicy getCompletionPrintingPolicy (const ASTContext &Context, const Preprocessor &PP)
 
static PrintingPolicy getCompletionPrintingPolicy (Sema &S)
 Retrieve a printing policy suitable for code completion. More...
 
static const char * GetCompletionTypeString (QualType T, ASTContext &Context, const PrintingPolicy &Policy, CodeCompletionAllocator &Allocator)
 Retrieve the string representation of the given type as a string that has the appropriate lifetime for code completion. More...
 
static void addThisCompletion (Sema &S, ResultBuilder &Results)
 Add a completion for "this", if we're in a member function. More...
 
static void AddStaticAssertResult (CodeCompletionBuilder &Builder, ResultBuilder &Results, const LangOptions &LangOpts)
 
static void AddOrdinaryNameResults (Sema::ParserCompletionContext CCC, Scope *S, Sema &SemaRef, ResultBuilder &Results)
 Add language constructs that show up for "ordinary" names. More...
 
static void AddResultTypeChunk (ASTContext &Context, const PrintingPolicy &Policy, const NamedDecl *ND, QualType BaseType, CodeCompletionBuilder &Result)
 If the given declaration has an associated type, add it as a result type chunk. More...
 
static void MaybeAddSentinel (Preprocessor &PP, const NamedDecl *FunctionOrMethod, CodeCompletionBuilder &Result)
 
static std::string formatObjCParamQualifiers (unsigned ObjCQuals, QualType &Type)
 
static void findTypeLocationForBlockDecl (const TypeSourceInfo *TSInfo, FunctionTypeLoc &Block, FunctionProtoTypeLoc &BlockProto, bool SuppressBlock=false)
 Tries to find the most appropriate type location for an Objective-C block placeholder. More...
 
static std::string formatBlockPlaceholder (const PrintingPolicy &Policy, const NamedDecl *BlockDecl, FunctionTypeLoc &Block, FunctionProtoTypeLoc &BlockProto, bool SuppressBlockName, bool SuppressBlock, Optional< ArrayRef< QualType >> ObjCSubsts)
 Returns a placeholder string that corresponds to an Objective-C block declaration. More...
 
static std::string FormatFunctionParameter (const PrintingPolicy &Policy, const ParmVarDecl *Param, bool SuppressName=false, bool SuppressBlock=false, Optional< ArrayRef< QualType >> ObjCSubsts=None)
 
static std::string GetDefaultValueString (const ParmVarDecl *Param, const SourceManager &SM, const LangOptions &LangOpts)
 
static void AddFunctionParameterChunks (Preprocessor &PP, const PrintingPolicy &Policy, const FunctionDecl *Function, CodeCompletionBuilder &Result, unsigned Start=0, bool InOptional=false)
 Add function parameter chunks to the given code completion string. More...
 
static void AddTemplateParameterChunks (ASTContext &Context, const PrintingPolicy &Policy, const TemplateDecl *Template, CodeCompletionBuilder &Result, unsigned MaxParameters=0, unsigned Start=0, bool InDefaultArg=false)
 Add template parameter chunks to the given code completion string. More...
 
static void AddQualifierToCompletionString (CodeCompletionBuilder &Result, NestedNameSpecifier *Qualifier, bool QualifierIsInformative, ASTContext &Context, const PrintingPolicy &Policy)
 Add a qualifier to the given code-completion string, if the provided nested-name-specifier is non-NULL. More...
 
static void AddFunctionTypeQualsToCompletionString (CodeCompletionBuilder &Result, const FunctionDecl *Function)
 
static void AddTypedNameChunk (ASTContext &Context, const PrintingPolicy &Policy, const NamedDecl *ND, CodeCompletionBuilder &Result)
 Add the name of the given declaration. More...
 
static void AddOverloadParameterChunks (ASTContext &Context, const PrintingPolicy &Policy, const FunctionDecl *Function, const FunctionProtoType *Prototype, CodeCompletionBuilder &Result, unsigned CurrentArg, unsigned Start=0, bool InOptional=false)
 Add function overload parameter chunks to the given code completion string. More...
 
static void AddMacroResults (Preprocessor &PP, ResultBuilder &Results, bool IncludeUndefined, bool TargetTypeIsPointer=false)
 
static void AddPrettyFunctionResults (const LangOptions &LangOpts, ResultBuilder &Results)
 
static void HandleCodeCompleteResults (Sema *S, CodeCompleteConsumer *CodeCompleter, CodeCompletionContext Context, CodeCompletionResult *Results, unsigned NumResults)
 
static enum CodeCompletionContext::Kind mapCodeCompletionContext (Sema &S, Sema::ParserCompletionContext PCC)
 
static void MaybeAddOverrideCalls (Sema &S, DeclContext *InContext, ResultBuilder &Results)
 If we're in a C++ virtual member function, add completion results that invoke the functions we override, since it's common to invoke the overridden function as well as adding new functionality. More...
 
static void AddClassMessageCompletions (Sema &SemaRef, Scope *S, ParsedType Receiver, ArrayRef< IdentifierInfo *> SelIdents, bool AtArgumentExpression, bool IsSuper, ResultBuilder &Results)
 
static ObjCContainerDeclgetContainerDef (ObjCContainerDecl *Container)
 Retrieve the container definition, if any? More...
 
static void AddObjCBlockCall (ASTContext &Context, const PrintingPolicy &Policy, CodeCompletionBuilder &Builder, const NamedDecl *BD, const FunctionTypeLoc &BlockLoc, const FunctionProtoTypeLoc &BlockProtoLoc)
 Adds a block invocation code completion result for the given block declaration BD. More...
 
static void AddObjCProperties (const CodeCompletionContext &CCContext, ObjCContainerDecl *Container, bool AllowCategories, bool AllowNullaryMethods, DeclContext *CurContext, AddedPropertiesSet &AddedProperties, ResultBuilder &Results, bool IsBaseExprStatement=false, bool IsClassProperty=false)
 
static void AddRecordMembersCompletionResults (Sema &SemaRef, ResultBuilder &Results, Scope *S, QualType BaseType, RecordDecl *RD)
 
static void AddTypeQualifierResults (DeclSpec &DS, ResultBuilder &Results, const LangOptions &LangOpts)
 
static bool anyNullArguments (ArrayRef< Expr *> Args)
 
static void mergeCandidatesWithResults (Sema &SemaRef, SmallVectorImpl< ResultCandidate > &Results, OverloadCandidateSet &CandidateSet, SourceLocation Loc)
 
static QualType getParamType (Sema &SemaRef, ArrayRef< ResultCandidate > Candidates, unsigned N)
 Get the type of the Nth parameter from a given set of overload candidates. More...
 
static void CodeCompleteOverloadResults (Sema &SemaRef, Scope *S, MutableArrayRef< ResultCandidate > Candidates, unsigned CurrentArg, bool CompleteExpressionWithCurrentArg=true)
 
static bool isNamespaceScope (Scope *S)
 Determine whether this scope denotes a namespace. More...
 
static bool ObjCPropertyFlagConflicts (unsigned Attributes, unsigned NewFlag)
 Determine whether the addition of the given flag to an Objective-C property's attributes will cause a conflict. More...
 
static bool isAcceptableObjCSelector (Selector Sel, ObjCMethodKind WantKind, ArrayRef< IdentifierInfo *> SelIdents, bool AllowSameLength=true)
 
static bool isAcceptableObjCMethod (ObjCMethodDecl *Method, ObjCMethodKind WantKind, ArrayRef< IdentifierInfo *> SelIdents, bool AllowSameLength=true)
 
static void AddObjCMethods (ObjCContainerDecl *Container, bool WantInstanceMethods, ObjCMethodKind WantKind, ArrayRef< IdentifierInfo *> SelIdents, DeclContext *CurContext, VisitedSelectorSet &Selectors, bool AllowSameLength, ResultBuilder &Results, bool InOriginalClass=true, bool IsRootClass=false)
 Add all of the Objective-C methods in the given Objective-C container to the set of results. More...
 
static ObjCInterfaceDeclGetAssumedMessageSendExprType (Expr *E)
 When we have an expression with type "id", we may assume that it has some more-specific class type based on knowledge of common uses of Objective-C. More...
 
static ObjCMethodDeclAddSuperSendCompletion (Sema &S, bool NeedSuperKeyword, ArrayRef< IdentifierInfo *> SelIdents, ResultBuilder &Results)
 
static QualType getPreferredArgumentTypeForMessageSend (ResultBuilder &Results, unsigned NumSelIdents)
 Given a set of code-completion results for the argument of a message send, determine the preferred type (if any) for that argument expression. More...
 
static void AddProtocolResults (DeclContext *Ctx, DeclContext *CurContext, bool OnlyForwardDeclarations, ResultBuilder &Results)
 Add all of the protocol declarations that we find in the given (translation unit) context. More...
 
static void AddInterfaceResults (DeclContext *Ctx, DeclContext *CurContext, bool OnlyForwardDeclarations, bool OnlyUnimplemented, ResultBuilder &Results)
 Add all of the Objective-C interface declarations that we find in the given (translation unit) context. More...
 
static void FindImplementableMethods (ASTContext &Context, ObjCContainerDecl *Container, Optional< bool > WantInstanceMethods, QualType ReturnType, KnownMethodsMap &KnownMethods, bool InOriginalClass=true)
 Find all of the methods that reside in the given container (and its superclasses, protocols, etc.) that meet the given criteria. More...
 
static void AddObjCPassingTypeChunk (QualType Type, unsigned ObjCDeclQuals, ASTContext &Context, const PrintingPolicy &Policy, CodeCompletionBuilder &Builder)
 Add the parenthesized return or parameter type chunk to a code completion string. More...
 
static bool InheritsFromClassNamed (ObjCInterfaceDecl *Class, StringRef Name)
 Determine whether the given class is or inherits from a class by the given name. More...
 
static void AddObjCKeyValueCompletions (ObjCPropertyDecl *Property, bool IsInstanceMethod, QualType ReturnType, ASTContext &Context, VisitedSelectorSet &KnownSelectors, ResultBuilder &Results)
 Add code completions for Objective-C Key-Value Coding (KVC) and Key-Value Observing (KVO). More...
 

Macro Definition Documentation

◆ OBJC_AT_KEYWORD_NAME

#define OBJC_AT_KEYWORD_NAME (   NeedAt,
  Keyword 
)    ((NeedAt)? "@" Keyword : Keyword)

Macro that optionally prepends an "@" to the string literal passed in via Keyword, depending on whether NeedAt is true or false.

Definition at line 4978 of file SemaCodeComplete.cpp.

Referenced by AddObjCImplementationResults(), AddObjCInterfaceResults(), and AddObjCVisibilityResults().

◆ OVERLOADED_OPERATOR [1/2]

#define OVERLOADED_OPERATOR (   Name,
  Spelling,
  Token,
  Unary,
  Binary,
  MemberOnly 
)    case OO_##Name: OperatorName = "operator" Spelling; break;

◆ OVERLOADED_OPERATOR [2/2]

#define OVERLOADED_OPERATOR (   Name,
  Spelling,
  Token,
  Unary,
  Binary,
  MemberOnly 
)
Value:
if (std::strcmp(Spelling, "?")) \
Results.AddResult(Result(Spelling));

◆ OVERLOADED_OPERATOR_MULTI

#define OVERLOADED_OPERATOR_MULTI (   Name,
  Spelling,
  Unary,
  Binary,
  MemberOnly 
)

Typedef Documentation

◆ AddedPropertiesSet

typedef llvm::SmallPtrSet<IdentifierInfo*, 16> AddedPropertiesSet

The set of properties that have already been added, referenced by property name.

Definition at line 3709 of file SemaCodeComplete.cpp.

◆ KnownMethodsMap

typedef llvm::DenseMap< Selector, llvm::PointerIntPair<ObjCMethodDecl *, 1, bool> > KnownMethodsMap

Definition at line 6669 of file SemaCodeComplete.cpp.

◆ ResultCandidate

Definition at line 4297 of file SemaCodeComplete.cpp.

Enumeration Type Documentation

◆ ObjCMethodKind

Describes the kind of Objective-C method that we want to find via code completion.

Enumerator
MK_Any 

Any kind of method, provided it means other specified criteria.

MK_ZeroArgSelector 

Zero-argument (unary) selector.

MK_OneArgSelector 

One-argument selector.

Definition at line 5348 of file SemaCodeComplete.cpp.

Function Documentation

◆ AddClassMessageCompletions()

static void AddClassMessageCompletions ( Sema SemaRef,
Scope S,
ParsedType  Receiver,
ArrayRef< IdentifierInfo *>  SelIdents,
bool  AtArgumentExpression,
bool  IsSuper,
ResultBuilder &  Results 
)
static

◆ AddFunctionParameterChunks()

static void AddFunctionParameterChunks ( Preprocessor PP,
const PrintingPolicy Policy,
const FunctionDecl Function,
CodeCompletionBuilder Result,
unsigned  Start = 0,
bool  InOptional = false 
)
static

◆ AddFunctionSpecifiers()

static void AddFunctionSpecifiers ( Sema::ParserCompletionContext  CCC,
const LangOptions LangOpts,
ResultBuilder &  Results 
)
static

◆ AddFunctionTypeQualsToCompletionString()

static void AddFunctionTypeQualsToCompletionString ( CodeCompletionBuilder Result,
const FunctionDecl Function 
)
static

◆ AddInterfaceResults()

static void AddInterfaceResults ( DeclContext Ctx,
DeclContext CurContext,
bool  OnlyForwardDeclarations,
bool  OnlyUnimplemented,
ResultBuilder &  Results 
)
static

Add all of the Objective-C interface declarations that we find in the given (translation unit) context.

Definition at line 6376 of file SemaCodeComplete.cpp.

References clang::DeclContext::decls().

Referenced by clang::Sema::CodeCompleteObjCImplementationDecl(), clang::Sema::CodeCompleteObjCInterfaceDecl(), and clang::Sema::CodeCompleteObjCSuperclass().

◆ AddMacroResults()

static void AddMacroResults ( Preprocessor PP,
ResultBuilder &  Results,
bool  IncludeUndefined,
bool  TargetTypeIsPointer = false 
)
static

◆ AddObjCBlockCall()

static void AddObjCBlockCall ( ASTContext Context,
const PrintingPolicy Policy,
CodeCompletionBuilder Builder,
const NamedDecl BD,
const FunctionTypeLoc BlockLoc,
const FunctionProtoTypeLoc BlockProtoLoc 
)
static

Adds a block invocation code completion result for the given block declaration BD.

Definition at line 3731 of file SemaCodeComplete.cpp.

◆ AddObjCExpressionResults()

static void AddObjCExpressionResults ( ResultBuilder &  Results,
bool  NeedAt 
)
static

◆ AddObjCImplementationResults()

static void AddObjCImplementationResults ( const LangOptions LangOpts,
ResultBuilder &  Results,
bool  NeedAt 
)
static

◆ AddObjCInterfaceResults()

static void AddObjCInterfaceResults ( const LangOptions LangOpts,
ResultBuilder &  Results,
bool  NeedAt 
)
static

◆ AddObjCKeyValueCompletions()

static void AddObjCKeyValueCompletions ( ObjCPropertyDecl Property,
bool  IsInstanceMethod,
QualType  ReturnType,
ASTContext Context,
VisitedSelectorSet &  KnownSelectors,
ResultBuilder &  Results 
)
static

Add code completions for Objective-C Key-Value Coding (KVC) and Key-Value Observing (KVO).

Definition at line 6790 of file SemaCodeComplete.cpp.

◆ AddObjCMethods()

static void AddObjCMethods ( ObjCContainerDecl Container,
bool  WantInstanceMethods,
ObjCMethodKind  WantKind,
ArrayRef< IdentifierInfo *>  SelIdents,
DeclContext CurContext,
VisitedSelectorSet &  Selectors,
bool  AllowSameLength,
ResultBuilder &  Results,
bool  InOriginalClass = true,
bool  IsRootClass = false 
)
static

Add all of the Objective-C methods in the given Objective-C container to the set of results.

The container will be a class, protocol, category, or implementation of any of the above. This mether will recurse to include methods from the superclasses of classes along with their categories, protocols, and implementations.

Parameters
Containerthe container in which we'll look to find methods.
WantInstanceMethodsWhether to add instance methods (only); if false, this routine will add factory methods (only).
CurContextthe context in which we're performing the lookup that finds methods.
AllowSameLengthWhether we allow a method to be added to the list when it has the same number of parameters as we have selector identifiers.
Resultsthe structure into which we'll add results.

Definition at line 5412 of file SemaCodeComplete.cpp.

Referenced by AddClassMessageCompletions(), clang::Sema::CodeCompleteObjCPropertyGetter(), and clang::Sema::CodeCompleteObjCPropertySetter().

◆ AddObjCPassingTypeChunk()

static void AddObjCPassingTypeChunk ( QualType  Type,
unsigned  ObjCDeclQuals,
ASTContext Context,
const PrintingPolicy Policy,
CodeCompletionBuilder Builder 
)
static

Add the parenthesized return or parameter type chunk to a code completion string.

Definition at line 6761 of file SemaCodeComplete.cpp.

◆ AddObjCProperties()

static void AddObjCProperties ( const CodeCompletionContext CCContext,
ObjCContainerDecl Container,
bool  AllowCategories,
bool  AllowNullaryMethods,
DeclContext CurContext,
AddedPropertiesSet AddedProperties,
ResultBuilder &  Results,
bool  IsBaseExprStatement = false,
bool  IsClassProperty = false 
)
static

◆ AddObjCStatementResults()

static void AddObjCStatementResults ( ResultBuilder &  Results,
bool  NeedAt 
)
static

◆ AddObjCTopLevelResults()

static void AddObjCTopLevelResults ( ResultBuilder &  Results,
bool  NeedAt 
)
static

◆ AddObjCVisibilityResults()

static void AddObjCVisibilityResults ( const LangOptions LangOpts,
ResultBuilder &  Results,
bool  NeedAt 
)
static

◆ AddOrdinaryNameResults()

static void AddOrdinaryNameResults ( Sema::ParserCompletionContext  CCC,
Scope S,
Sema SemaRef,
ResultBuilder &  Results 
)
static

Add language constructs that show up for "ordinary" names.

while (condition) { statements }

Definition at line 1582 of file SemaCodeComplete.cpp.

Referenced by clang::Sema::CodeCompleteAfterIf().

◆ AddOverloadParameterChunks()

static void AddOverloadParameterChunks ( ASTContext Context,
const PrintingPolicy Policy,
const FunctionDecl Function,
const FunctionProtoType Prototype,
CodeCompletionBuilder Result,
unsigned  CurrentArg,
unsigned  Start = 0,
bool  InOptional = false 
)
static

Add function overload parameter chunks to the given code completion string.

Definition at line 3032 of file SemaCodeComplete.cpp.

◆ AddPrettyFunctionResults()

static void AddPrettyFunctionResults ( const LangOptions LangOpts,
ResultBuilder &  Results 
)
static

Definition at line 3276 of file SemaCodeComplete.cpp.

References clang::CCP_Constant.

◆ AddProtocolResults()

static void AddProtocolResults ( DeclContext Ctx,
DeclContext CurContext,
bool  OnlyForwardDeclarations,
ResultBuilder &  Results 
)
static

Add all of the protocol declarations that we find in the given (translation unit) context.

Definition at line 6311 of file SemaCodeComplete.cpp.

References clang::DeclContext::decls().

Referenced by clang::Sema::CodeCompleteObjCProtocolDecl(), and clang::Sema::CodeCompleteObjCProtocolReferences().

◆ AddQualifierToCompletionString()

static void AddQualifierToCompletionString ( CodeCompletionBuilder Result,
NestedNameSpecifier Qualifier,
bool  QualifierIsInformative,
ASTContext Context,
const PrintingPolicy Policy 
)
static

Add a qualifier to the given code-completion string, if the provided nested-name-specifier is non-NULL.

Definition at line 2590 of file SemaCodeComplete.cpp.

◆ AddRecordMembersCompletionResults()

static void AddRecordMembersCompletionResults ( Sema SemaRef,
ResultBuilder &  Results,
Scope S,
QualType  BaseType,
RecordDecl RD 
)
static

◆ AddResultTypeChunk()

static void AddResultTypeChunk ( ASTContext Context,
const PrintingPolicy Policy,
const NamedDecl ND,
QualType  BaseType,
CodeCompletionBuilder Result 
)
static

If the given declaration has an associated type, add it as a result type chunk.

Definition at line 2129 of file SemaCodeComplete.cpp.

Referenced by clang::CodeCompletionBuilder::getCodeCompletionTUInfo().

◆ AddStaticAssertResult()

static void AddStaticAssertResult ( CodeCompletionBuilder Builder,
ResultBuilder &  Results,
const LangOptions LangOpts 
)
static

Definition at line 1566 of file SemaCodeComplete.cpp.

◆ AddStorageSpecifiers()

static void AddStorageSpecifiers ( Sema::ParserCompletionContext  CCC,
const LangOptions LangOpts,
ResultBuilder &  Results 
)
static

Definition at line 1384 of file SemaCodeComplete.cpp.

◆ AddSuperSendCompletion()

static ObjCMethodDecl* AddSuperSendCompletion ( Sema S,
bool  NeedSuperKeyword,
ArrayRef< IdentifierInfo *>  SelIdents,
ResultBuilder &  Results 
)
static
Parameters
SThe semantic analysis object.
NeedSuperKeywordWhether we need to prefix this completion with the "super" keyword. Otherwise, we just need to provide the arguments.
SelIdentsThe identifiers in the selector that have already been provided as arguments for a send to "super".
ResultsThe set of results to augment.
Returns
the Objective-C method declaration that would be invoked by this "super" completion. If NULL, no completion was added.

Definition at line 5723 of file SemaCodeComplete.cpp.

References clang::Sema::Context, clang::ObjCMethodDecl::getClassInterface(), clang::Sema::getCurMethodDecl(), clang::ObjCContainerDecl::getMethod(), clang::ObjCMethodDecl::getSelector(), clang::ObjCInterfaceDecl::getSuperClass(), clang::ASTContext::hasSameUnqualifiedType(), clang::ObjCMethodDecl::isInstanceMethod(), clang::ObjCMethodDecl::isVariadic(), clang::ObjCInterfaceDecl::known_categories(), clang::ObjCMethodDecl::param_begin(), clang::ObjCMethodDecl::param_end(), and clang::ObjCMethodDecl::param_size().

Referenced by AddClassMessageCompletions(), and clang::Sema::CodeCompleteObjCMessageReceiver().

◆ AddTemplateParameterChunks()

static void AddTemplateParameterChunks ( ASTContext Context,
const PrintingPolicy Policy,
const TemplateDecl Template,
CodeCompletionBuilder Result,
unsigned  MaxParameters = 0,
unsigned  Start = 0,
bool  InDefaultArg = false 
)
static

Add template parameter chunks to the given code completion string.

Definition at line 2507 of file SemaCodeComplete.cpp.

◆ addThisCompletion()

static void addThisCompletion ( Sema S,
ResultBuilder &  Results 
)
static

Add a completion for "this", if we're in a member function.

Definition at line 1550 of file SemaCodeComplete.cpp.

Referenced by clang::Sema::CodeCompleteLambdaIntroducer(), and clang::Sema::CodeCompleteObjCMessageReceiver().

◆ AddTypedefResult()

static void AddTypedefResult ( ResultBuilder &  Results)
static

Definition at line 1459 of file SemaCodeComplete.cpp.

◆ AddTypedNameChunk()

static void AddTypedNameChunk ( ASTContext Context,
const PrintingPolicy Policy,
const NamedDecl ND,
CodeCompletionBuilder Result 
)
static

Add the name of the given declaration.

Definition at line 2647 of file SemaCodeComplete.cpp.

◆ AddTypeQualifierResults()

static void AddTypeQualifierResults ( DeclSpec DS,
ResultBuilder &  Results,
const LangOptions LangOpts 
)
static

◆ AddTypeSpecifierResults()

static void AddTypeSpecifierResults ( const LangOptions LangOpts,
ResultBuilder &  Results 
)
static

Add type specifiers for the current language as keyword results.

Definition at line 1302 of file SemaCodeComplete.cpp.

References clang::CCP_Type.

Referenced by clang::Sema::CodeCompleteOperatorName().

◆ anyNullArguments()

static bool anyNullArguments ( ArrayRef< Expr *>  Args)
static

Definition at line 4286 of file SemaCodeComplete.cpp.

Referenced by clang::Sema::CodeCompleteCall().

◆ CodeCompleteOverloadResults()

static void CodeCompleteOverloadResults ( Sema SemaRef,
Scope S,
MutableArrayRef< ResultCandidate Candidates,
unsigned  CurrentArg,
bool  CompleteExpressionWithCurrentArg = true 
)
static

◆ FindImplementableMethods()

static void FindImplementableMethods ( ASTContext Context,
ObjCContainerDecl Container,
Optional< bool WantInstanceMethods,
QualType  ReturnType,
KnownMethodsMap KnownMethods,
bool  InOriginalClass = true 
)
static

Find all of the methods that reside in the given container (and its superclasses, protocols, etc.) that meet the given criteria.

Insert those methods into the map of known methods, indexed by selector so they can be easily found.

Definition at line 6675 of file SemaCodeComplete.cpp.

Referenced by clang::Sema::CodeCompleteObjCMethodDecl().

◆ findTypeLocationForBlockDecl()

static void findTypeLocationForBlockDecl ( const TypeSourceInfo TSInfo,
FunctionTypeLoc Block,
FunctionProtoTypeLoc BlockProto,
bool  SuppressBlock = false 
)
static

Tries to find the most appropriate type location for an Objective-C block placeholder.

This function ignores things like typedefs and qualifiers in order to present the most relevant and accurate block placeholders in code completion results.

Definition at line 2232 of file SemaCodeComplete.cpp.

References formatBlockPlaceholder(), clang::TypeLoc::getAs(), clang::TypeSourceInfo::getTypeLoc(), clang::TypeLoc::getUnqualifiedLoc(), and clang::TypeLoc::IgnoreParens().

Referenced by FormatFunctionParameter().

◆ formatBlockPlaceholder()

static std::string formatBlockPlaceholder ( const PrintingPolicy Policy,
const NamedDecl BlockDecl,
FunctionTypeLoc Block,
FunctionProtoTypeLoc BlockProto,
bool  SuppressBlockName,
bool  SuppressBlock,
Optional< ArrayRef< QualType >>  ObjCSubsts 
)
static

Returns a placeholder string that corresponds to an Objective-C block declaration.

Parameters
BlockDeclA declaration with an Objective-C block type.
BlockThe most relevant type location for that block type.
SuppressBlockNameDetermines wether or not the name of the block declaration is included in the resulting string.

Definition at line 2370 of file SemaCodeComplete.cpp.

References clang::QualType::getAsStringInternal(), clang::Decl::getASTContext(), clang::FunctionTypeLoc::getNumParams(), clang::FunctionType::getReturnType(), clang::ConcreteTypeLoc< Base, Derived, TypeClass, LocalData >::getTypePtr(), clang::InheritingConcreteTypeLoc< Base, Derived, TypeClass >::getTypePtr(), clang::FunctionProtoType::isVariadic(), clang::Type::isVoidType(), clang::Result, and clang::QualType::substObjCTypeArgs().

Referenced by findTypeLocationForBlockDecl(), and FormatFunctionParameter().

◆ FormatFunctionParameter()

static std::string FormatFunctionParameter ( const PrintingPolicy Policy,
const ParmVarDecl Param,
bool  SuppressName = false,
bool  SuppressBlock = false,
Optional< ArrayRef< QualType >>  ObjCSubsts = None 
)
static

◆ formatObjCParamQualifiers()

static std::string formatObjCParamQualifiers ( unsigned  ObjCQuals,
QualType Type 
)
static

◆ GetAssumedMessageSendExprType()

static ObjCInterfaceDecl* GetAssumedMessageSendExprType ( Expr E)
static

When we have an expression with type "id", we may assume that it has some more-specific class type based on knowledge of common uses of Objective-C.

This routine returns that class type, or NULL if no better result could be determined.

Definition at line 5640 of file SemaCodeComplete.cpp.

◆ getCompletionPrintingPolicy() [1/2]

static PrintingPolicy getCompletionPrintingPolicy ( const ASTContext Context,
const Preprocessor PP 
)
static

◆ getCompletionPrintingPolicy() [2/2]

static PrintingPolicy getCompletionPrintingPolicy ( Sema S)
static

Retrieve a printing policy suitable for code completion.

Definition at line 1511 of file SemaCodeComplete.cpp.

◆ GetCompletionTypeString()

static const char* GetCompletionTypeString ( QualType  T,
ASTContext Context,
const PrintingPolicy Policy,
CodeCompletionAllocator Allocator 
)
static

Retrieve the string representation of the given type as a string that has the appropriate lifetime for code completion.

This routine provides a fast path where we provide constant strings for common type names.

Definition at line 1520 of file SemaCodeComplete.cpp.

◆ getContainerDef()

static ObjCContainerDecl* getContainerDef ( ObjCContainerDecl Container)
static

Retrieve the container definition, if any?

Definition at line 3712 of file SemaCodeComplete.cpp.

◆ GetDefaultValueString()

static std::string GetDefaultValueString ( const ParmVarDecl Param,
const SourceManager SM,
const LangOptions LangOpts 
)
static

◆ getParamType()

static QualType getParamType ( Sema SemaRef,
ArrayRef< ResultCandidate Candidates,
unsigned  N 
)
static

◆ getPreferredArgumentTypeForMessageSend()

static QualType getPreferredArgumentTypeForMessageSend ( ResultBuilder &  Results,
unsigned  NumSelIdents 
)
static

Given a set of code-completion results for the argument of a message send, determine the preferred type (if any) for that argument expression.

Definition at line 5929 of file SemaCodeComplete.cpp.

Referenced by clang::Sema::CodeCompleteObjCClassMessage().

◆ getRequiredQualification()

static NestedNameSpecifier* getRequiredQualification ( ASTContext Context,
const DeclContext CurContext,
const DeclContext TargetContext 
)
static

Compute the qualification required to get from the current context (CurContext) to the target context (TargetContext).

Parameters
Contextthe AST context in which the qualification will be used.
CurContextthe context where an entity is being named, which is typically based on the current scope.
TargetContextthe context in which the named entity actually resides.
Returns
a nested name specifier that refers into the target context, or NULL if no qualification is needed.

Definition at line 451 of file SemaCodeComplete.cpp.

Referenced by clang::Sema::CodeCompleteCase(), and shouldIgnoreDueToReservedName().

◆ HandleCodeCompleteResults()

static void HandleCodeCompleteResults ( Sema S,
CodeCompleteConsumer CodeCompleter,
CodeCompletionContext  Context,
CodeCompletionResult Results,
unsigned  NumResults 
)
static

◆ InheritsFromClassNamed()

static bool InheritsFromClassNamed ( ObjCInterfaceDecl Class,
StringRef  Name 
)
static

Determine whether the given class is or inherits from a class by the given name.

Definition at line 6777 of file SemaCodeComplete.cpp.

◆ isAcceptableObjCMethod()

static bool isAcceptableObjCMethod ( ObjCMethodDecl Method,
ObjCMethodKind  WantKind,
ArrayRef< IdentifierInfo *>  SelIdents,
bool  AllowSameLength = true 
)
static

◆ isAcceptableObjCSelector()

static bool isAcceptableObjCSelector ( Selector  Sel,
ObjCMethodKind  WantKind,
ArrayRef< IdentifierInfo *>  SelIdents,
bool  AllowSameLength = true 
)
static

◆ isNamespaceScope()

static bool isNamespaceScope ( Scope S)
static

Determine whether this scope denotes a namespace.

Definition at line 4924 of file SemaCodeComplete.cpp.

References clang::Scope::getEntity(), and clang::DeclContext::isFileContext().

Referenced by clang::Sema::CodeCompleteLambdaIntroducer().

◆ isObjCReceiverType()

static bool isObjCReceiverType ( ASTContext C,
QualType  T 
)
static

◆ isReservedName()

static bool isReservedName ( const IdentifierInfo Id,
bool  doubleUnderscoreOnly = false 
)
static

Determine whether Id is a name reserved for the implementation (C99 7.1.3, C++ [lib.global.names]).

Definition at line 486 of file SemaCodeComplete.cpp.

References clang::IdentifierInfo::getLength().

Referenced by shouldIgnoreDueToReservedName().

◆ mapCodeCompletionContext()

static enum CodeCompletionContext::Kind mapCodeCompletionContext ( Sema S,
Sema::ParserCompletionContext  PCC 
)
static

Definition at line 3298 of file SemaCodeComplete.cpp.

Referenced by clang::Sema::CodeCompleteAfterIf().

◆ MaybeAddOverrideCalls()

static void MaybeAddOverrideCalls ( Sema S,
DeclContext InContext,
ResultBuilder &  Results 
)
static

If we're in a C++ virtual member function, add completion results that invoke the functions we override, since it's common to invoke the overridden function as well as adding new functionality.

Parameters
SThe semantic analysis object for which we are generating results.
InContextThis context in which the nested-name-specifier preceding the code-completion point

Definition at line 3362 of file SemaCodeComplete.cpp.

Referenced by clang::Sema::CodeCompleteQualifiedId().

◆ MaybeAddSentinel()

static void MaybeAddSentinel ( Preprocessor PP,
const NamedDecl FunctionOrMethod,
CodeCompletionBuilder Result 
)
static

◆ mergeCandidatesWithResults()

static void mergeCandidatesWithResults ( Sema SemaRef,
SmallVectorImpl< ResultCandidate > &  Results,
OverloadCandidateSet CandidateSet,
SourceLocation  Loc 
)
static

◆ ObjCPropertyFlagConflicts()

static bool ObjCPropertyFlagConflicts ( unsigned  Attributes,
unsigned  NewFlag 
)
static

◆ shouldIgnoreDueToReservedName()

static bool shouldIgnoreDueToReservedName ( const NamedDecl ND,
Sema SemaRef 
)
static

◆ WantTypesInContext()

static bool WantTypesInContext ( Sema::ParserCompletionContext  CCC,
const LangOptions LangOpts 
)
static