[clang] [clang] Introduce `SemaCodeCompletion` (PR #92311)
Vlad Serebrennikov via cfe-commits
cfe-commits at lists.llvm.org
Wed May 15 13:04:44 PDT 2024
https://github.com/Endilll created https://github.com/llvm/llvm-project/pull/92311
This patch continues previous efforts to split `Sema` up, this time covering code completion.
Context can be found in #84184.
Dropping `Code` prefix from function names in `SemaCodeCompletion` would make sense, but I think this PR has enough changes already.
As usual, formatting changes are done as a separate commit. Hopefully this helps with the review.
>From 97ddce01bc6ac2ed7563ce19ae7dd9420e512dd9 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov <serebrennikov.vladislav at gmail.com>
Date: Wed, 15 May 2024 22:54:58 +0300
Subject: [PATCH 1/2] [clang] Introduce `SemaCodeCompletion`
---
clang/include/clang/Parse/Parser.h | 3 +-
clang/include/clang/Sema/Sema.h | 225 +----
clang/include/clang/Sema/SemaCodeCompletion.h | 237 +++++
clang/lib/Frontend/ASTUnit.cpp | 3 +-
clang/lib/Parse/ParseDecl.cpp | 37 +-
clang/lib/Parse/ParseDeclCXX.cpp | 35 +-
clang/lib/Parse/ParseExpr.cpp | 21 +-
clang/lib/Parse/ParseExprCXX.cpp | 19 +-
clang/lib/Parse/ParseInit.cpp | 5 +-
clang/lib/Parse/ParseObjc.cpp | 89 +-
clang/lib/Parse/ParseOpenMP.cpp | 5 +-
clang/lib/Parse/ParsePragma.cpp | 3 +-
clang/lib/Parse/ParseStmt.cpp | 19 +-
clang/lib/Parse/ParseTemplate.cpp | 2 +-
clang/lib/Parse/Parser.cpp | 37 +-
clang/lib/Sema/Sema.cpp | 5 +-
clang/lib/Sema/SemaCodeComplete.cpp | 897 +++++++++---------
17 files changed, 850 insertions(+), 792 deletions(-)
create mode 100644 clang/include/clang/Sema/SemaCodeCompletion.h
diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h
index 7a8c2bcde804e..6c2105e400dca 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -18,6 +18,7 @@
#include "clang/Lex/CodeCompletionHandler.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Sema/Sema.h"
+#include "clang/Sema/SemaCodeCompletion.h"
#include "clang/Sema/SemaObjC.h"
#include "clang/Sema/SemaOpenMP.h"
#include "llvm/ADT/SmallVector.h"
@@ -2998,7 +2999,7 @@ class Parser : public CodeCompletionHandler {
IdentifierInfo *TryParseCXX11AttributeIdentifier(
SourceLocation &Loc,
- Sema::AttributeCompletion Completion = Sema::AttributeCompletion::None,
+ SemaCodeCompletion::AttributeCompletion Completion = SemaCodeCompletion::AttributeCompletion::None,
const IdentifierInfo *EnclosingScope = nullptr);
void MaybeParseHLSLAnnotations(Declarator &D,
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 6a414aa57f32b..8b35959a6285b 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -167,6 +167,7 @@ class Preprocessor;
class PseudoDestructorTypeStorage;
class PseudoObjectExpr;
class QualType;
+class SemaCodeCompletion;
class SemaCUDA;
class SemaHLSL;
class SemaObjC;
@@ -481,9 +482,8 @@ class Sema final : public SemaBase {
// 29. C++ Variadic Templates (SemaTemplateVariadic.cpp)
// 30. Constraints and Concepts (SemaConcept.cpp)
// 31. Types (SemaType.cpp)
- // 32. Code Completion (SemaCodeComplete.cpp)
- // 33. FixIt Helpers (SemaFixItUtils.cpp)
- // 34. Name Lookup for RISC-V Vector Intrinsic (SemaRISCVVectorLookup.cpp)
+ // 32. FixIt Helpers (SemaFixItUtils.cpp)
+ // 33. Name Lookup for RISC-V Vector Intrinsic (SemaRISCVVectorLookup.cpp)
/// \name Semantic Analysis
/// Implementations are in Sema.cpp
@@ -984,6 +984,11 @@ class Sema final : public SemaBase {
/// CurContext - This is the current declaration context of parsing.
DeclContext *CurContext;
+ SemaCodeCompletion &CodeCompletion() {
+ assert(CodeCompletionPtr);
+ return *CodeCompletionPtr;
+ }
+
SemaCUDA &CUDA() {
assert(CUDAPtr);
return *CUDAPtr;
@@ -1044,6 +1049,7 @@ class Sema final : public SemaBase {
mutable IdentifierInfo *Ident_super;
+ std::unique_ptr<SemaCodeCompletion> CodeCompletionPtr;
std::unique_ptr<SemaCUDA> CUDAPtr;
std::unique_ptr<SemaHLSL> HLSLPtr;
std::unique_ptr<SemaObjC> ObjCPtr;
@@ -4799,6 +4805,11 @@ class Sema final : public SemaBase {
DelayedDiagnostics.popUndelayed(state);
}
+ ValueDecl *tryLookupCtorInitMemberDecl(CXXRecordDecl *ClassDecl,
+ CXXScopeSpec &SS,
+ ParsedType TemplateTypeTy,
+ IdentifierInfo *MemberOrBase);
+
private:
void setupImplicitSpecialMemberType(CXXMethodDecl *SpecialMem,
QualType ResultTy,
@@ -4809,11 +4820,6 @@ class Sema final : public SemaBase {
// of a ComparisonCategoryType enumerator.
llvm::SmallBitVector FullyCheckedComparisonCategories;
- ValueDecl *tryLookupCtorInitMemberDecl(CXXRecordDecl *ClassDecl,
- CXXScopeSpec &SS,
- ParsedType TemplateTypeTy,
- IdentifierInfo *MemberOrBase);
-
/// Check if there is a field shadowing.
void CheckShadowInheritedFields(const SourceLocation &Loc,
DeclarationName FieldName,
@@ -11651,209 +11657,6 @@ class Sema final : public SemaBase {
//
//
- /// \name Code Completion
- /// Implementations are in SemaCodeComplete.cpp
- ///@{
-
-public:
- /// Code-completion consumer.
- CodeCompleteConsumer *CodeCompleter;
-
- /// Describes the context in which code completion occurs.
- enum ParserCompletionContext {
- /// Code completion occurs at top-level or namespace context.
- PCC_Namespace,
- /// Code completion occurs within a class, struct, or union.
- PCC_Class,
- /// Code completion occurs within an Objective-C interface, protocol,
- /// or category.
- PCC_ObjCInterface,
- /// Code completion occurs within an Objective-C implementation or
- /// category implementation
- PCC_ObjCImplementation,
- /// Code completion occurs within the list of instance variables
- /// in an Objective-C interface, protocol, category, or implementation.
- PCC_ObjCInstanceVariableList,
- /// Code completion occurs following one or more template
- /// headers.
- PCC_Template,
- /// Code completion occurs following one or more template
- /// headers within a class.
- PCC_MemberTemplate,
- /// Code completion occurs within an expression.
- PCC_Expression,
- /// Code completion occurs within a statement, which may
- /// also be an expression or a declaration.
- PCC_Statement,
- /// Code completion occurs at the beginning of the
- /// initialization statement (or expression) in a for loop.
- PCC_ForInit,
- /// Code completion occurs within the condition of an if,
- /// while, switch, or for statement.
- PCC_Condition,
- /// 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.
- PCC_RecoveryInFunction,
- /// Code completion occurs where only a type is permitted.
- PCC_Type,
- /// Code completion occurs in a parenthesized expression, which
- /// might also be a type cast.
- PCC_ParenthesizedExpression,
- /// Code completion occurs within a sequence of declaration
- /// specifiers within a function, method, or block.
- PCC_LocalDeclarationSpecifiers,
- /// Code completion occurs at top-level in a REPL session
- PCC_TopLevelOrExpression,
- };
-
- void CodeCompleteModuleImport(SourceLocation ImportLoc, ModuleIdPath Path);
- void CodeCompleteOrdinaryName(Scope *S,
- ParserCompletionContext CompletionContext);
- void CodeCompleteDeclSpec(Scope *S, DeclSpec &DS, bool AllowNonIdentifiers,
- bool AllowNestedNameSpecifiers);
-
- struct CodeCompleteExpressionData;
- void CodeCompleteExpression(Scope *S, const CodeCompleteExpressionData &Data);
- 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);
- enum class AttributeCompletion {
- Attribute,
- Scope,
- None,
- };
- void CodeCompleteAttribute(
- AttributeCommonInfo::Syntax Syntax,
- AttributeCompletion Completion = AttributeCompletion::Attribute,
- const IdentifierInfo *Scope = nullptr);
- /// Determines the preferred type of the current function argument, by
- /// examining the signatures of all possible overloads.
- /// Returns null if unknown or ambiguous, or if code completion is off.
- ///
- /// If the code completion point has been reached, also reports the function
- /// signatures that were considered.
- ///
- /// FIXME: rename to GuessCallArgumentType to reduce confusion.
- QualType ProduceCallSignatureHelp(Expr *Fn, ArrayRef<Expr *> Args,
- SourceLocation OpenParLoc);
- 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);
- /// Trigger code completion for a record of \p BaseType. \p InitExprs are
- /// expressions in the initializer list seen so far and \p D is the current
- /// Designation being parsed.
- void CodeCompleteDesignator(const QualType BaseType,
- llvm::ArrayRef<Expr *> InitExprs,
- const Designation &D);
- 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);
-
- ///@}
-
- //
- //
- // -------------------------------------------------------------------------
- //
- //
-
/// \name FixIt Helpers
/// Implementations are in SemaFixItUtils.cpp
///@{
diff --git a/clang/include/clang/Sema/SemaCodeCompletion.h b/clang/include/clang/Sema/SemaCodeCompletion.h
new file mode 100644
index 0000000000000..6bf0f2473cbf4
--- /dev/null
+++ b/clang/include/clang/Sema/SemaCodeCompletion.h
@@ -0,0 +1,237 @@
+//===----- SemaCodeCompletion.h ------ Code completion support ------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// This file declares facilities that support code completion.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_SEMA_SEMACODECOMPLETION_H
+#define LLVM_CLANG_SEMA_SEMACODECOMPLETION_H
+
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/Type.h"
+#include "clang/Basic/AttributeCommonInfo.h"
+#include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Lex/MacroInfo.h"
+#include "clang/Lex/ModuleLoader.h"
+#include "clang/Sema/CodeCompleteConsumer.h"
+#include "clang/Sema/DeclSpec.h"
+#include "clang/Sema/Designator.h"
+#include "clang/Sema/Ownership.h"
+#include "clang/Sema/Scope.h"
+#include "clang/Sema/SemaBase.h"
+#include "llvm/ADT/StringRef.h"
+#include <optional>
+
+namespace clang {
+
+class SemaCodeCompletion : public SemaBase {
+public:
+ SemaCodeCompletion(Sema &S, CodeCompleteConsumer *CompletionConsumer);
+
+ using TemplateTy = OpaquePtr<TemplateName>;
+ using DeclGroupPtrTy = OpaquePtr<DeclGroupRef>;
+
+ /// Code-completion consumer.
+ CodeCompleteConsumer *CodeCompleter;
+
+ /// Describes the context in which code completion occurs.
+ enum ParserCompletionContext {
+ /// Code completion occurs at top-level or namespace context.
+ PCC_Namespace,
+ /// Code completion occurs within a class, struct, or union.
+ PCC_Class,
+ /// Code completion occurs within an Objective-C interface, protocol,
+ /// or category.
+ PCC_ObjCInterface,
+ /// Code completion occurs within an Objective-C implementation or
+ /// category implementation
+ PCC_ObjCImplementation,
+ /// Code completion occurs within the list of instance variables
+ /// in an Objective-C interface, protocol, category, or implementation.
+ PCC_ObjCInstanceVariableList,
+ /// Code completion occurs following one or more template
+ /// headers.
+ PCC_Template,
+ /// Code completion occurs following one or more template
+ /// headers within a class.
+ PCC_MemberTemplate,
+ /// Code completion occurs within an expression.
+ PCC_Expression,
+ /// Code completion occurs within a statement, which may
+ /// also be an expression or a declaration.
+ PCC_Statement,
+ /// Code completion occurs at the beginning of the
+ /// initialization statement (or expression) in a for loop.
+ PCC_ForInit,
+ /// Code completion occurs within the condition of an if,
+ /// while, switch, or for statement.
+ PCC_Condition,
+ /// 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.
+ PCC_RecoveryInFunction,
+ /// Code completion occurs where only a type is permitted.
+ PCC_Type,
+ /// Code completion occurs in a parenthesized expression, which
+ /// might also be a type cast.
+ PCC_ParenthesizedExpression,
+ /// Code completion occurs within a sequence of declaration
+ /// specifiers within a function, method, or block.
+ PCC_LocalDeclarationSpecifiers,
+ /// Code completion occurs at top-level in a REPL session
+ PCC_TopLevelOrExpression,
+ };
+
+ void CodeCompleteModuleImport(SourceLocation ImportLoc, ModuleIdPath Path);
+ void CodeCompleteOrdinaryName(Scope *S,
+ ParserCompletionContext CompletionContext);
+ void CodeCompleteDeclSpec(Scope *S, DeclSpec &DS, bool AllowNonIdentifiers,
+ bool AllowNestedNameSpecifiers);
+
+ struct CodeCompleteExpressionData;
+ void CodeCompleteExpression(Scope *S, const CodeCompleteExpressionData &Data);
+ 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);
+ enum class AttributeCompletion {
+ Attribute,
+ Scope,
+ None,
+ };
+ void CodeCompleteAttribute(
+ AttributeCommonInfo::Syntax Syntax,
+ AttributeCompletion Completion = AttributeCompletion::Attribute,
+ const IdentifierInfo *Scope = nullptr);
+ /// Determines the preferred type of the current function argument, by
+ /// examining the signatures of all possible overloads.
+ /// Returns null if unknown or ambiguous, or if code completion is off.
+ ///
+ /// If the code completion point has been reached, also reports the function
+ /// signatures that were considered.
+ ///
+ /// FIXME: rename to GuessCallArgumentType to reduce confusion.
+ QualType ProduceCallSignatureHelp(Expr *Fn, ArrayRef<Expr *> Args,
+ SourceLocation OpenParLoc);
+ 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);
+ /// Trigger code completion for a record of \p BaseType. \p InitExprs are
+ /// expressions in the initializer list seen so far and \p D is the current
+ /// Designation being parsed.
+ void CodeCompleteDesignator(const QualType BaseType,
+ llvm::ArrayRef<Expr *> InitExprs,
+ const Designation &D);
+ 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);
+};
+
+} // namespace clang
+
+#endif // LLVM_CLANG_SEMA_SEMACODECOMPLETION_H
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 755aaddc0ad74..3d8d9a9d8b26e 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -56,6 +56,7 @@
#include "clang/Sema/CodeCompleteConsumer.h"
#include "clang/Sema/CodeCompleteOptions.h"
#include "clang/Sema/Sema.h"
+#include "clang/Sema/SemaCodeCompletion.h"
#include "clang/Serialization/ASTBitCodes.h"
#include "clang/Serialization/ASTReader.h"
#include "clang/Serialization/ASTWriter.h"
@@ -375,7 +376,7 @@ void ASTUnit::CacheCodeCompletionResults() {
SmallVector<Result, 8> Results;
CachedCompletionAllocator = std::make_shared<GlobalCodeCompletionAllocator>();
CodeCompletionTUInfo CCTUInfo(CachedCompletionAllocator);
- TheSema->GatherGlobalCodeCompletions(*CachedCompletionAllocator,
+ TheSema->CodeCompletion().GatherGlobalCodeCompletions(*CachedCompletionAllocator,
CCTUInfo, Results);
// Translate global code completions into cached completions.
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 6d026878d3276..a23af05b9bed1 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -27,6 +27,7 @@
#include "clang/Sema/ParsedTemplate.h"
#include "clang/Sema/Scope.h"
#include "clang/Sema/SemaCUDA.h"
+#include "clang/Sema/SemaCodeCompletion.h"
#include "clang/Sema/SemaDiagnostic.h"
#include "clang/Sema/SemaObjC.h"
#include "clang/Sema/SemaOpenMP.h"
@@ -218,7 +219,7 @@ void Parser::ParseGNUAttributes(ParsedAttributes &Attrs,
break;
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteAttribute(AttributeCommonInfo::Syntax::AS_GNU);
+ Actions.CodeCompletion().CodeCompleteAttribute(AttributeCommonInfo::Syntax::AS_GNU);
break;
}
IdentifierInfo *AttrName = Tok.getIdentifierInfo();
@@ -895,7 +896,7 @@ void Parser::ParseMicrosoftDeclSpecs(ParsedAttributes &Attrs) {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteAttribute(AttributeCommonInfo::AS_Declspec);
+ Actions.CodeCompletion().CodeCompleteAttribute(AttributeCommonInfo::AS_Declspec);
return;
}
@@ -2286,7 +2287,7 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS,
// Check to see if we have a function *definition* which must have a body.
if (Tok.is(tok::equal) && NextToken().is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteAfterFunctionEquals(D);
+ Actions.CodeCompletion().CodeCompleteAfterFunctionEquals(D);
return nullptr;
}
// We're at the point where the parsing of function declarator is finished.
@@ -2722,7 +2723,7 @@ Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes(
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteInitializer(getCurScope(), ThisDecl);
+ Actions.CodeCompletion().CodeCompleteInitializer(getCurScope(), ThisDecl);
Actions.FinalizeDeclaration(ThisDecl);
return nullptr;
}
@@ -2767,7 +2768,7 @@ Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes(
auto ThisVarDecl = dyn_cast_or_null<VarDecl>(ThisDecl);
auto RunSignatureHelp = [&]() {
- QualType PreferredType = Actions.ProduceConstructorSignatureHelp(
+ QualType PreferredType = Actions.CodeCompletion().ProduceConstructorSignatureHelp(
ThisVarDecl->getType()->getCanonicalTypeInternal(),
ThisDecl->getLocation(), Exprs, T.getOpenLocation(),
/*Braced=*/false);
@@ -2791,7 +2792,7 @@ Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes(
if (SawError) {
if (ThisVarDecl && PP.isCodeCompletionReached() && !CalledSignatureHelp) {
- Actions.ProduceConstructorSignatureHelp(
+ Actions.CodeCompletion().ProduceConstructorSignatureHelp(
ThisVarDecl->getType()->getCanonicalTypeInternal(),
ThisDecl->getLocation(), Exprs, T.getOpenLocation(),
/*Braced=*/false);
@@ -3634,7 +3635,7 @@ void Parser::ParseDeclarationSpecifiers(
continue;
case tok::code_completion: {
- Sema::ParserCompletionContext CCC = Sema::PCC_Namespace;
+ SemaCodeCompletion::ParserCompletionContext CCC = SemaCodeCompletion::PCC_Namespace;
if (DS.hasTypeSpecifier()) {
bool AllowNonIdentifiers
= (getCurScope()->getFlags() & (Scope::ControlScope |
@@ -3647,7 +3648,7 @@ void Parser::ParseDeclarationSpecifiers(
(DSContext == DeclSpecContext::DSC_class && DS.isFriendSpecified());
cutOffParsing();
- Actions.CodeCompleteDeclSpec(getCurScope(), DS,
+ Actions.CodeCompletion().CodeCompleteDeclSpec(getCurScope(), DS,
AllowNonIdentifiers,
AllowNestedNameSpecifiers);
return;
@@ -3655,17 +3656,17 @@ void Parser::ParseDeclarationSpecifiers(
// Class context can appear inside a function/block, so prioritise that.
if (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate)
- CCC = DSContext == DeclSpecContext::DSC_class ? Sema::PCC_MemberTemplate
- : Sema::PCC_Template;
+ CCC = DSContext == DeclSpecContext::DSC_class ? SemaCodeCompletion::PCC_MemberTemplate
+ : SemaCodeCompletion::PCC_Template;
else if (DSContext == DeclSpecContext::DSC_class)
- CCC = Sema::PCC_Class;
+ CCC = SemaCodeCompletion::PCC_Class;
else if (getCurScope()->getFnParent() || getCurScope()->getBlockParent())
- CCC = Sema::PCC_LocalDeclarationSpecifiers;
+ CCC = SemaCodeCompletion::PCC_LocalDeclarationSpecifiers;
else if (CurParsedObjCImpl)
- CCC = Sema::PCC_ObjCImplementation;
+ CCC = SemaCodeCompletion::PCC_ObjCImplementation;
cutOffParsing();
- Actions.CodeCompleteOrdinaryName(getCurScope(), CCC);
+ Actions.CodeCompletion().CodeCompleteOrdinaryName(getCurScope(), CCC);
return;
}
@@ -5075,7 +5076,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS,
if (Tok.is(tok::code_completion)) {
// Code completion for an enum name.
cutOffParsing();
- Actions.CodeCompleteTag(getCurScope(), DeclSpec::TST_enum);
+ Actions.CodeCompletion().CodeCompleteTag(getCurScope(), DeclSpec::TST_enum);
DS.SetTypeSpecError(); // Needed by ActOnUsingDeclaration.
return;
}
@@ -6265,7 +6266,7 @@ void Parser::ParseTypeQualifierListOpt(
if (CodeCompletionHandler)
(*CodeCompletionHandler)();
else
- Actions.CodeCompleteTypeQualifiers(DS);
+ Actions.CodeCompletion().CodeCompleteTypeQualifiers(DS);
return;
case tok::kw_const:
@@ -7406,7 +7407,7 @@ void Parser::ParseFunctionDeclarator(Declarator &D,
/*AtomicAllowed*/ false,
/*IdentifierRequired=*/false,
llvm::function_ref<void()>([&]() {
- Actions.CodeCompleteFunctionQualifiers(DS, D);
+ Actions.CodeCompletion().CodeCompleteFunctionQualifiers(DS, D);
}));
if (!DS.getSourceRange().getEnd().isInvalid()) {
EndLoc = DS.getSourceRange().getEnd();
@@ -7969,7 +7970,7 @@ void Parser::ParseBracketDeclarator(Declarator &D) {
return;
} else if (Tok.getKind() == tok::code_completion) {
cutOffParsing();
- Actions.CodeCompleteBracketDeclarator(getCurScope());
+ Actions.CodeCompletion().CodeCompleteBracketDeclarator(getCurScope());
return;
}
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index 65ddebca49bc6..de40a27fdd1b7 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -27,6 +27,7 @@
#include "clang/Sema/EnterExpressionEvaluationContext.h"
#include "clang/Sema/ParsedTemplate.h"
#include "clang/Sema/Scope.h"
+#include "clang/Sema/SemaCodeCompletion.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/TimeProfiler.h"
#include <optional>
@@ -69,7 +70,7 @@ Parser::DeclGroupPtrTy Parser::ParseNamespace(DeclaratorContext Context,
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteNamespaceDecl(getCurScope());
+ Actions.CodeCompletion().CodeCompleteNamespaceDecl(getCurScope());
return nullptr;
}
@@ -309,7 +310,7 @@ Decl *Parser::ParseNamespaceAlias(SourceLocation NamespaceLoc,
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteNamespaceAliasDecl(getCurScope());
+ Actions.CodeCompletion().CodeCompleteNamespaceAliasDecl(getCurScope());
return nullptr;
}
@@ -492,7 +493,7 @@ Parser::DeclGroupPtrTy Parser::ParseUsingDirectiveOrDeclaration(
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteUsing(getCurScope());
+ Actions.CodeCompletion().CodeCompleteUsing(getCurScope());
return nullptr;
}
@@ -542,7 +543,7 @@ Decl *Parser::ParseUsingDirective(DeclaratorContext Context,
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteUsingDirective(getCurScope());
+ Actions.CodeCompletion().CodeCompleteUsingDirective(getCurScope());
return nullptr;
}
@@ -733,7 +734,7 @@ Parser::DeclGroupPtrTy Parser::ParseUsingDeclaration(
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteUsing(getCurScope());
+ Actions.CodeCompletion().CodeCompleteUsing(getCurScope());
return nullptr;
}
@@ -1680,7 +1681,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
if (Tok.is(tok::code_completion)) {
// Code completion for a struct, class, or union name.
cutOffParsing();
- Actions.CodeCompleteTag(getCurScope(), TagType);
+ Actions.CodeCompletion().CodeCompleteTag(getCurScope(), TagType);
return;
}
@@ -2722,7 +2723,7 @@ void Parser::MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(
ParseTypeQualifierListOpt(
DS, AR_NoAttributesParsed, false,
/*IdentifierRequired=*/false, llvm::function_ref<void()>([&]() {
- Actions.CodeCompleteFunctionQualifiers(DS, D, &VS);
+ Actions.CodeCompletion().CodeCompleteFunctionQualifiers(DS, D, &VS);
}));
D.ExtendWithDeclSpec(DS);
@@ -3085,7 +3086,7 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
DefinitionKind = FunctionDefinitionKind::Deleted;
else if (KW.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteAfterFunctionEquals(DeclaratorInfo);
+ Actions.CodeCompletion().CodeCompleteAfterFunctionEquals(DeclaratorInfo);
return nullptr;
}
}
@@ -3894,7 +3895,7 @@ void Parser::ParseConstructorInitializer(Decl *ConstructorDecl) {
do {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteConstructorInitializer(ConstructorDecl,
+ Actions.CodeCompletion().CodeCompleteConstructorInitializer(ConstructorDecl,
MemInitializers);
return;
}
@@ -4015,7 +4016,7 @@ MemInitResult Parser::ParseMemInitializer(Decl *ConstructorDecl) {
auto RunSignatureHelp = [&] {
if (TemplateTypeTy.isInvalid())
return QualType();
- QualType PreferredType = Actions.ProduceCtorInitMemberSignatureHelp(
+ QualType PreferredType = Actions.CodeCompletion().ProduceCtorInitMemberSignatureHelp(
ConstructorDecl, SS, TemplateTypeTy.get(), ArgExprs, II,
T.getOpenLocation(), /*Braced=*/false);
CalledSignatureHelp = true;
@@ -4404,7 +4405,7 @@ void Parser::PopParsingClass(Sema::ParsingClassState state) {
/// it is considered an identifier.
IdentifierInfo *
Parser::TryParseCXX11AttributeIdentifier(SourceLocation &Loc,
- Sema::AttributeCompletion Completion,
+ SemaCodeCompletion::AttributeCompletion Completion,
const IdentifierInfo *Scope) {
switch (Tok.getKind()) {
default:
@@ -4419,7 +4420,7 @@ Parser::TryParseCXX11AttributeIdentifier(SourceLocation &Loc,
case tok::code_completion:
cutOffParsing();
- Actions.CodeCompleteAttribute(getLangOpts().CPlusPlus ? ParsedAttr::AS_CXX11
+ Actions.CodeCompletion().CodeCompleteAttribute(getLangOpts().CPlusPlus ? ParsedAttr::AS_CXX11
: ParsedAttr::AS_C23,
Completion, Scope);
return nullptr;
@@ -4804,7 +4805,7 @@ void Parser::ParseCXX11AttributeSpecifierInternal(ParsedAttributes &Attrs,
ConsumeToken();
CommonScopeName = TryParseCXX11AttributeIdentifier(
- CommonScopeLoc, Sema::AttributeCompletion::Scope);
+ CommonScopeLoc, SemaCodeCompletion::AttributeCompletion::Scope);
if (!CommonScopeName) {
Diag(Tok.getLocation(), diag::err_expected) << tok::identifier;
SkipUntil(tok::r_square, tok::colon, StopBeforeMatch);
@@ -4833,7 +4834,7 @@ void Parser::ParseCXX11AttributeSpecifierInternal(ParsedAttributes &Attrs,
IdentifierInfo *ScopeName = nullptr, *AttrName = nullptr;
AttrName = TryParseCXX11AttributeIdentifier(
- AttrLoc, Sema::AttributeCompletion::Attribute, CommonScopeName);
+ AttrLoc, SemaCodeCompletion::AttributeCompletion::Attribute, CommonScopeName);
if (!AttrName)
// Break out to the "expected ']'" diagnostic.
break;
@@ -4844,7 +4845,7 @@ void Parser::ParseCXX11AttributeSpecifierInternal(ParsedAttributes &Attrs,
ScopeLoc = AttrLoc;
AttrName = TryParseCXX11AttributeIdentifier(
- AttrLoc, Sema::AttributeCompletion::Attribute, ScopeName);
+ AttrLoc, SemaCodeCompletion::AttributeCompletion::Attribute, ScopeName);
if (!AttrName) {
Diag(Tok.getLocation(), diag::err_expected) << tok::identifier;
SkipUntil(tok::r_square, tok::comma, StopAtSemi | StopBeforeMatch);
@@ -5068,8 +5069,8 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes &Attrs) {
StopAtSemi | StopBeforeMatch | StopAtCodeCompletion);
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteAttribute(AttributeCommonInfo::AS_Microsoft,
- Sema::AttributeCompletion::Attribute,
+ Actions.CodeCompletion().CodeCompleteAttribute(AttributeCommonInfo::AS_Microsoft,
+ SemaCodeCompletion::AttributeCompletion::Attribute,
/*Scope=*/nullptr);
break;
}
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 9cd7d20fc4d58..03404404d575f 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -31,6 +31,7 @@
#include "clang/Sema/ParsedTemplate.h"
#include "clang/Sema/Scope.h"
#include "clang/Sema/SemaCUDA.h"
+#include "clang/Sema/SemaCodeCompletion.h"
#include "clang/Sema/SemaObjC.h"
#include "clang/Sema/SemaOpenACC.h"
#include "clang/Sema/SemaOpenMP.h"
@@ -168,7 +169,7 @@ Parser::ParseExpressionWithLeadingExtension(SourceLocation ExtLoc) {
ExprResult Parser::ParseAssignmentExpression(TypeCastState isTypeCast) {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteExpression(getCurScope(),
+ Actions.CodeCompletion().CodeCompleteExpression(getCurScope(),
PreferredType.get(Tok.getLocation()));
return ExprError();
}
@@ -187,7 +188,7 @@ ExprResult Parser::ParseAssignmentExpression(TypeCastState isTypeCast) {
ExprResult Parser::ParseConditionalExpression() {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteExpression(getCurScope(),
+ Actions.CodeCompletion().CodeCompleteExpression(getCurScope(),
PreferredType.get(Tok.getLocation()));
return ExprError();
}
@@ -1215,7 +1216,7 @@ ExprResult Parser::ParseCastExpression(CastParseKind ParseKind,
if (Tok.is(tok::code_completion) && &II != Ident_super) {
cutOffParsing();
- Actions.CodeCompleteObjCClassPropertyRefExpr(
+ Actions.CodeCompletion().CodeCompleteObjCClassPropertyRefExpr(
getCurScope(), II, ILoc, ExprStatementTokLoc == ILoc);
return ExprError();
}
@@ -1811,7 +1812,7 @@ ExprResult Parser::ParseCastExpression(CastParseKind ParseKind,
break;
case tok::code_completion: {
cutOffParsing();
- Actions.CodeCompleteExpression(getCurScope(),
+ Actions.CodeCompletion().CodeCompleteExpression(getCurScope(),
PreferredType.get(Tok.getLocation()));
return ExprError();
}
@@ -1956,7 +1957,7 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
return LHS;
cutOffParsing();
- Actions.CodeCompletePostfixExpression(
+ Actions.CodeCompletion().CodeCompletePostfixExpression(
getCurScope(), LHS, PreferredType.get(Tok.getLocation()));
return ExprError();
@@ -2154,7 +2155,7 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
ExprVector ArgExprs;
auto RunSignatureHelp = [&]() -> QualType {
- QualType PreferredType = Actions.ProduceCallSignatureHelp(
+ QualType PreferredType = Actions.CodeCompletion().ProduceCallSignatureHelp(
LHS.get(), ArgExprs, PT.getOpenLocation());
CalledSignatureHelp = true;
return PreferredType;
@@ -2279,7 +2280,7 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
// Code completion for a member access expression.
cutOffParsing();
- Actions.CodeCompleteMemberReferenceExpr(
+ Actions.CodeCompletion().CodeCompleteMemberReferenceExpr(
getCurScope(), Base, CorrectedBase, OpLoc, OpKind == tok::arrow,
Base && ExprStatementTokLoc == Base->getBeginLoc(),
PreferredType.get(Tok.getLocation()));
@@ -3001,7 +3002,7 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr,
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteExpression(
+ Actions.CodeCompletion().CodeCompleteExpression(
getCurScope(), PreferredType.get(Tok.getLocation()),
/*IsParenthesized=*/ExprType >= CompoundLiteral);
return ExprError();
@@ -3678,7 +3679,7 @@ bool Parser::ParseSimpleExpressionList(SmallVectorImpl<Expr *> &Exprs) {
void Parser::ParseBlockId(SourceLocation CaretLoc) {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Type);
+ Actions.CodeCompletion().CodeCompleteOrdinaryName(getCurScope(), SemaCodeCompletion::PCC_Type);
return;
}
@@ -3867,7 +3868,7 @@ std::optional<AvailabilitySpec> Parser::ParseAvailabilitySpec() {
// Parse the platform name.
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteAvailabilityPlatformName();
+ Actions.CodeCompletion().CodeCompleteAvailabilityPlatformName();
return std::nullopt;
}
if (Tok.isNot(tok::identifier)) {
diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp
index 825031da358ad..af2ab3347ec16 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -23,6 +23,7 @@
#include "clang/Sema/EnterExpressionEvaluationContext.h"
#include "clang/Sema/ParsedTemplate.h"
#include "clang/Sema/Scope.h"
+#include "clang/Sema/SemaCodeCompletion.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
#include <numeric>
@@ -270,7 +271,7 @@ bool Parser::ParseOptionalCXXScopeSpecifier(
cutOffParsing();
// Code completion for a nested-name-specifier, where the code
// completion token follows the '::'.
- Actions.CodeCompleteQualifiedId(getCurScope(), SS, EnteringContext,
+ Actions.CodeCompletion().CodeCompleteQualifiedId(getCurScope(), SS, EnteringContext,
InUsingDeclaration, ObjectType.get(),
SavedType.get(SS.getBeginLoc()));
// Include code completion token into the range of the scope otherwise
@@ -954,7 +955,7 @@ bool Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro,
if (Tok.is(tok::code_completion) &&
!(getLangOpts().ObjC && Tentative)) {
cutOffParsing();
- Actions.CodeCompleteLambdaIntroducer(getCurScope(), Intro,
+ Actions.CodeCompletion().CodeCompleteLambdaIntroducer(getCurScope(), Intro,
/*AfterAmpersand=*/false);
break;
}
@@ -971,9 +972,9 @@ bool Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro,
// If we're in Objective-C++ and we have a bare '[', then this is more
// likely to be a message receiver.
if (getLangOpts().ObjC && Tentative && First)
- Actions.CodeCompleteObjCMessageReceiver(getCurScope());
+ Actions.CodeCompletion().CodeCompleteObjCMessageReceiver(getCurScope());
else
- Actions.CodeCompleteLambdaIntroducer(getCurScope(), Intro,
+ Actions.CodeCompletion().CodeCompleteLambdaIntroducer(getCurScope(), Intro,
/*AfterAmpersand=*/false);
break;
}
@@ -1020,7 +1021,7 @@ bool Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro,
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteLambdaIntroducer(getCurScope(), Intro,
+ Actions.CodeCompletion().CodeCompleteLambdaIntroducer(getCurScope(), Intro,
/*AfterAmpersand=*/true);
break;
}
@@ -2031,7 +2032,7 @@ Parser::ParseCXXTypeConstructExpression(const DeclSpec &DS) {
auto RunSignatureHelp = [&]() {
QualType PreferredType;
if (TypeRep)
- PreferredType = Actions.ProduceConstructorSignatureHelp(
+ PreferredType = Actions.CodeCompletion().ProduceConstructorSignatureHelp(
TypeRep.get()->getCanonicalTypeInternal(), DS.getEndLoc(), Exprs,
T.getOpenLocation(), /*Braced=*/false);
CalledSignatureHelp = true;
@@ -2140,7 +2141,7 @@ Parser::ParseCXXCondition(StmtResult *InitStmt, SourceLocation Loc,
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Condition);
+ Actions.CodeCompletion().CodeCompleteOrdinaryName(getCurScope(), SemaCodeCompletion::PCC_Condition);
return Sema::ConditionError();
}
@@ -2792,7 +2793,7 @@ bool Parser::ParseUnqualifiedIdOperator(CXXScopeSpec &SS, bool EnteringContext,
// Don't try to parse any further.
cutOffParsing();
// Code completion for the operator name.
- Actions.CodeCompleteOperatorName(getCurScope());
+ Actions.CodeCompletion().CodeCompleteOperatorName(getCurScope());
return true;
}
@@ -3350,7 +3351,7 @@ Parser::ParseCXXNewExpression(bool UseGlobal, SourceLocation Start) {
// the passing DeclaratorInfo is valid, e.g. running SignatureHelp on
// `new decltype(invalid) (^)`.
if (TypeRep)
- PreferredType = Actions.ProduceConstructorSignatureHelp(
+ PreferredType = Actions.CodeCompletion().ProduceConstructorSignatureHelp(
TypeRep.get()->getCanonicalTypeInternal(),
DeclaratorInfo.getEndLoc(), ConstructorArgs, ConstructorLParen,
/*Braced=*/false);
diff --git a/clang/lib/Parse/ParseInit.cpp b/clang/lib/Parse/ParseInit.cpp
index 04e4419f4d459..b972a5a118b6a 100644
--- a/clang/lib/Parse/ParseInit.cpp
+++ b/clang/lib/Parse/ParseInit.cpp
@@ -18,6 +18,7 @@
#include "clang/Sema/EnterExpressionEvaluationContext.h"
#include "clang/Sema/Ownership.h"
#include "clang/Sema/Scope.h"
+#include "clang/Sema/SemaCodeCompletion.h"
#include "clang/Sema/SemaObjC.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
@@ -204,7 +205,7 @@ ExprResult Parser::ParseInitializerWithPotentialDesignator(
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteDesignator(DesignatorCompletion.PreferredBaseType,
+ Actions.CodeCompletion().CodeCompleteDesignator(DesignatorCompletion.PreferredBaseType,
DesignatorCompletion.InitExprs, Desig);
return ExprError();
}
@@ -471,7 +472,7 @@ ExprResult Parser::ParseBraceInitializer() {
auto RunSignatureHelp = [&] {
QualType PreferredType;
if (!LikelyType.isNull())
- PreferredType = Actions.ProduceConstructorSignatureHelp(
+ PreferredType = Actions.CodeCompletion().ProduceConstructorSignatureHelp(
LikelyType->getCanonicalTypeInternal(), T.getOpenLocation(),
InitExprs, T.getOpenLocation(), /*Braced=*/true);
CalledSignatureHelp = true;
diff --git a/clang/lib/Parse/ParseObjc.cpp b/clang/lib/Parse/ParseObjc.cpp
index 4cb04b3534738..d511719476292 100644
--- a/clang/lib/Parse/ParseObjc.cpp
+++ b/clang/lib/Parse/ParseObjc.cpp
@@ -20,6 +20,7 @@
#include "clang/Parse/RAIIObjectsForParser.h"
#include "clang/Sema/DeclSpec.h"
#include "clang/Sema/Scope.h"
+#include "clang/Sema/SemaCodeCompletion.h"
#include "clang/Sema/SemaObjC.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
@@ -56,7 +57,7 @@ Parser::ParseObjCAtDirectives(ParsedAttributes &DeclAttrs,
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteObjCAtDirective(getCurScope());
+ Actions.CodeCompletion().CodeCompleteObjCAtDirective(getCurScope());
return nullptr;
}
@@ -156,7 +157,7 @@ Parser::ParseObjCAtClassDeclaration(SourceLocation atLoc) {
MaybeSkipAttributes(tok::objc_class);
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteObjCClassForwardDecl(getCurScope());
+ Actions.CodeCompletion().CodeCompleteObjCClassForwardDecl(getCurScope());
return Actions.ConvertDeclToDeclGroup(nullptr);
}
if (expectIdentifier()) {
@@ -242,7 +243,7 @@ Decl *Parser::ParseObjCAtInterfaceDeclaration(SourceLocation AtLoc,
// Code completion after '@interface'.
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteObjCInterfaceDecl(getCurScope());
+ Actions.CodeCompletion().CodeCompleteObjCInterfaceDecl(getCurScope());
return nullptr;
}
@@ -276,7 +277,7 @@ Decl *Parser::ParseObjCAtInterfaceDeclaration(SourceLocation AtLoc,
IdentifierInfo *categoryId = nullptr;
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteObjCInterfaceCategory(getCurScope(), nameId, nameLoc);
+ Actions.CodeCompletion().CodeCompleteObjCInterfaceCategory(getCurScope(), nameId, nameLoc);
return nullptr;
}
@@ -331,7 +332,7 @@ Decl *Parser::ParseObjCAtInterfaceDeclaration(SourceLocation AtLoc,
// Code completion of superclass names.
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteObjCSuperclass(getCurScope(), nameId, nameLoc);
+ Actions.CodeCompletion().CodeCompleteObjCSuperclass(getCurScope(), nameId, nameLoc);
return nullptr;
}
@@ -508,7 +509,7 @@ ObjCTypeParamList *Parser::parseObjCTypeParamListOrProtocolRefs(
// FIXME: If these aren't protocol references, we'll need different
// completions.
cutOffParsing();
- Actions.CodeCompleteObjCProtocolReferences(protocolIdents);
+ Actions.CodeCompletion().CodeCompleteObjCProtocolReferences(protocolIdents);
// FIXME: Better recovery here?.
return nullptr;
@@ -681,9 +682,9 @@ void Parser::ParseObjCInterfaceDeclList(tok::ObjCKeywordKind contextKey,
// Code completion within an Objective-C interface.
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteOrdinaryName(getCurScope(),
- CurParsedObjCImpl? Sema::PCC_ObjCImplementation
- : Sema::PCC_ObjCInterface);
+ Actions.CodeCompletion().CodeCompleteOrdinaryName(getCurScope(),
+ CurParsedObjCImpl? SemaCodeCompletion::PCC_ObjCImplementation
+ : SemaCodeCompletion::PCC_ObjCInterface);
return;
}
@@ -720,7 +721,7 @@ void Parser::ParseObjCInterfaceDeclList(tok::ObjCKeywordKind contextKey,
const auto &NextTok = NextToken();
if (NextTok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteObjCAtDirective(getCurScope());
+ Actions.CodeCompletion().CodeCompleteObjCAtDirective(getCurScope());
return;
}
@@ -895,7 +896,7 @@ void Parser::ParseObjCPropertyAttribute(ObjCDeclSpec &DS) {
while (true) {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteObjCPropertyFlags(getCurScope(), DS);
+ Actions.CodeCompletion().CodeCompleteObjCPropertyFlags(getCurScope(), DS);
return;
}
const IdentifierInfo *II = Tok.getIdentifierInfo();
@@ -943,9 +944,9 @@ void Parser::ParseObjCPropertyAttribute(ObjCDeclSpec &DS) {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
if (IsSetter)
- Actions.CodeCompleteObjCPropertySetter(getCurScope());
+ Actions.CodeCompletion().CodeCompleteObjCPropertySetter(getCurScope());
else
- Actions.CodeCompleteObjCPropertyGetter(getCurScope());
+ Actions.CodeCompletion().CodeCompleteObjCPropertyGetter(getCurScope());
return;
}
@@ -1196,7 +1197,7 @@ void Parser::ParseObjCTypeQualifierList(ObjCDeclSpec &DS,
while (true) {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteObjCPassingType(
+ Actions.CodeCompletion().CodeCompleteObjCPassingType(
getCurScope(), DS, Context == DeclaratorContext::ObjCParameter);
return;
}
@@ -1390,7 +1391,7 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteObjCMethodDecl(getCurScope(), mType == tok::minus,
+ Actions.CodeCompletion().CodeCompleteObjCMethodDecl(getCurScope(), mType == tok::minus,
/*ReturnType=*/nullptr);
return nullptr;
}
@@ -1409,7 +1410,7 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteObjCMethodDecl(getCurScope(), mType == tok::minus,
+ Actions.CodeCompletion().CodeCompleteObjCMethodDecl(getCurScope(), mType == tok::minus,
ReturnType);
return nullptr;
}
@@ -1472,7 +1473,7 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
if (Tok.is(tok::code_completion)) {
cutOffParsing();
KeyIdents.push_back(SelIdent);
- Actions.CodeCompleteObjCMethodDeclSelector(getCurScope(),
+ Actions.CodeCompletion().CodeCompleteObjCMethodDeclSelector(getCurScope(),
mType == tok::minus,
/*AtParameterName=*/true,
ReturnType, KeyIdents);
@@ -1496,7 +1497,7 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
// Code completion for the next piece of the selector.
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteObjCMethodDeclSelector(getCurScope(),
+ Actions.CodeCompletion().CodeCompleteObjCMethodDeclSelector(getCurScope(),
mType == tok::minus,
/*AtParameterName=*/false,
ReturnType, KeyIdents);
@@ -1583,7 +1584,7 @@ ParseObjCProtocolReferences(SmallVectorImpl<Decl *> &Protocols,
while (true) {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteObjCProtocolReferences(ProtocolIdents);
+ Actions.CodeCompletion().CodeCompleteObjCProtocolReferences(ProtocolIdents);
return true;
}
@@ -1681,9 +1682,9 @@ void Parser::parseObjCTypeArgsOrProtocolQualifiers(
QualType BaseT = Actions.GetTypeFromParser(baseType);
cutOffParsing();
if (!BaseT.isNull() && BaseT->acceptsObjCTypeParams()) {
- Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Type);
+ Actions.CodeCompletion().CodeCompleteOrdinaryName(getCurScope(), SemaCodeCompletion::PCC_Type);
} else {
- Actions.CodeCompleteObjCProtocolReferences(identifierLocPairs);
+ Actions.CodeCompletion().CodeCompleteObjCProtocolReferences(identifierLocPairs);
}
return;
}
@@ -1958,7 +1959,7 @@ void Parser::ParseObjCClassInstanceVariables(ObjCContainerDecl *interfaceDecl,
if (TryConsumeToken(tok::at)) { // parse objc-visibility-spec
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteObjCAtVisibility(getCurScope());
+ Actions.CodeCompletion().CodeCompleteObjCAtVisibility(getCurScope());
return;
}
@@ -1989,8 +1990,8 @@ void Parser::ParseObjCClassInstanceVariables(ObjCContainerDecl *interfaceDecl,
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteOrdinaryName(getCurScope(),
- Sema::PCC_ObjCInstanceVariableList);
+ Actions.CodeCompletion().CodeCompleteOrdinaryName(getCurScope(),
+ SemaCodeCompletion::PCC_ObjCInstanceVariableList);
return;
}
@@ -2057,7 +2058,7 @@ Parser::ParseObjCAtProtocolDeclaration(SourceLocation AtLoc,
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteObjCProtocolDecl(getCurScope());
+ Actions.CodeCompletion().CodeCompleteObjCProtocolDecl(getCurScope());
return nullptr;
}
@@ -2155,7 +2156,7 @@ Parser::ParseObjCAtImplementationDeclaration(SourceLocation AtLoc,
// Code completion after '@implementation'.
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteObjCImplementationDecl(getCurScope());
+ Actions.CodeCompletion().CodeCompleteObjCImplementationDecl(getCurScope());
return nullptr;
}
@@ -2193,7 +2194,7 @@ Parser::ParseObjCAtImplementationDeclaration(SourceLocation AtLoc,
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteObjCImplementationCategory(getCurScope(), nameId, nameLoc);
+ Actions.CodeCompletion().CodeCompleteObjCImplementationCategory(getCurScope(), nameId, nameLoc);
return nullptr;
}
@@ -2367,7 +2368,7 @@ Decl *Parser::ParseObjCPropertySynthesize(SourceLocation atLoc) {
while (true) {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteObjCPropertyDefinition(getCurScope());
+ Actions.CodeCompletion().CodeCompleteObjCPropertyDefinition(getCurScope());
return nullptr;
}
@@ -2385,7 +2386,7 @@ Decl *Parser::ParseObjCPropertySynthesize(SourceLocation atLoc) {
// property '=' ivar-name
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteObjCPropertySynthesizeIvar(getCurScope(), propertyId);
+ Actions.CodeCompletion().CodeCompleteObjCPropertySynthesizeIvar(getCurScope(), propertyId);
return nullptr;
}
@@ -2444,7 +2445,7 @@ Decl *Parser::ParseObjCPropertyDynamic(SourceLocation atLoc) {
while (true) {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteObjCPropertyDefinition(getCurScope());
+ Actions.CodeCompletion().CodeCompleteObjCPropertyDefinition(getCurScope());
return nullptr;
}
@@ -2782,7 +2783,7 @@ StmtResult Parser::ParseObjCAtStatement(SourceLocation AtLoc,
ParsedStmtContext StmtCtx) {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteObjCAtStatement(getCurScope());
+ Actions.CodeCompletion().CodeCompleteObjCAtStatement(getCurScope());
return StmtError();
}
@@ -2823,7 +2824,7 @@ ExprResult Parser::ParseObjCAtExpression(SourceLocation AtLoc) {
switch (Tok.getKind()) {
case tok::code_completion:
cutOffParsing();
- Actions.CodeCompleteObjCAtExpression(getCurScope());
+ Actions.CodeCompletion().CodeCompleteObjCAtExpression(getCurScope());
return ExprError();
case tok::minus:
@@ -3071,7 +3072,7 @@ ExprResult Parser::ParseObjCMessageExpression() {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteObjCMessageReceiver(getCurScope());
+ Actions.CodeCompletion().CodeCompleteObjCMessageReceiver(getCurScope());
return ExprError();
}
@@ -3208,13 +3209,13 @@ Parser::ParseObjCMessageExpressionBody(SourceLocation LBracLoc,
if (Tok.is(tok::code_completion)) {
cutOffParsing();
if (SuperLoc.isValid())
- Actions.CodeCompleteObjCSuperMessage(getCurScope(), SuperLoc,
+ Actions.CodeCompletion().CodeCompleteObjCSuperMessage(getCurScope(), SuperLoc,
std::nullopt, false);
else if (ReceiverType)
- Actions.CodeCompleteObjCClassMessage(getCurScope(), ReceiverType,
+ Actions.CodeCompletion().CodeCompleteObjCClassMessage(getCurScope(), ReceiverType,
std::nullopt, false);
else
- Actions.CodeCompleteObjCInstanceMessage(getCurScope(), ReceiverExpr,
+ Actions.CodeCompletion().CodeCompleteObjCInstanceMessage(getCurScope(), ReceiverExpr,
std::nullopt, false);
return ExprError();
}
@@ -3246,15 +3247,15 @@ Parser::ParseObjCMessageExpressionBody(SourceLocation LBracLoc,
if (Tok.is(tok::code_completion)) {
cutOffParsing();
if (SuperLoc.isValid())
- Actions.CodeCompleteObjCSuperMessage(getCurScope(), SuperLoc,
+ Actions.CodeCompletion().CodeCompleteObjCSuperMessage(getCurScope(), SuperLoc,
KeyIdents,
/*AtArgumentExpression=*/true);
else if (ReceiverType)
- Actions.CodeCompleteObjCClassMessage(getCurScope(), ReceiverType,
+ Actions.CodeCompletion().CodeCompleteObjCClassMessage(getCurScope(), ReceiverType,
KeyIdents,
/*AtArgumentExpression=*/true);
else
- Actions.CodeCompleteObjCInstanceMessage(getCurScope(), ReceiverExpr,
+ Actions.CodeCompletion().CodeCompleteObjCInstanceMessage(getCurScope(), ReceiverExpr,
KeyIdents,
/*AtArgumentExpression=*/true);
@@ -3284,15 +3285,15 @@ Parser::ParseObjCMessageExpressionBody(SourceLocation LBracLoc,
if (Tok.is(tok::code_completion)) {
cutOffParsing();
if (SuperLoc.isValid())
- Actions.CodeCompleteObjCSuperMessage(getCurScope(), SuperLoc,
+ Actions.CodeCompletion().CodeCompleteObjCSuperMessage(getCurScope(), SuperLoc,
KeyIdents,
/*AtArgumentExpression=*/false);
else if (ReceiverType)
- Actions.CodeCompleteObjCClassMessage(getCurScope(), ReceiverType,
+ Actions.CodeCompletion().CodeCompleteObjCClassMessage(getCurScope(), ReceiverType,
KeyIdents,
/*AtArgumentExpression=*/false);
else
- Actions.CodeCompleteObjCInstanceMessage(getCurScope(), ReceiverExpr,
+ Actions.CodeCompletion().CodeCompleteObjCInstanceMessage(getCurScope(), ReceiverExpr,
KeyIdents,
/*AtArgumentExpression=*/false);
return ExprError();
@@ -3635,7 +3636,7 @@ ExprResult Parser::ParseObjCSelectorExpression(SourceLocation AtLoc) {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteObjCSelector(getCurScope(), KeyIdents);
+ Actions.CodeCompletion().CodeCompleteObjCSelector(getCurScope(), KeyIdents);
return ExprError();
}
@@ -3661,7 +3662,7 @@ ExprResult Parser::ParseObjCSelectorExpression(SourceLocation AtLoc) {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteObjCSelector(getCurScope(), KeyIdents);
+ Actions.CodeCompletion().CodeCompleteObjCSelector(getCurScope(), KeyIdents);
return ExprError();
}
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index ca2c6d69eb985..e8bd52b2f46f1 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -21,6 +21,7 @@
#include "clang/Parse/RAIIObjectsForParser.h"
#include "clang/Sema/EnterExpressionEvaluationContext.h"
#include "clang/Sema/Scope.h"
+#include "clang/Sema/SemaCodeCompletion.h"
#include "clang/Sema/SemaOpenMP.h"
#include "llvm/ADT/PointerIntPair.h"
#include "llvm/ADT/StringSwitch.h"
@@ -460,7 +461,7 @@ void Parser::ParseOpenMPReductionInitializerForDecl(VarDecl *OmpPrivParm) {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteInitializer(getCurScope(), OmpPrivParm);
+ Actions.CodeCompletion().CodeCompleteInitializer(getCurScope(), OmpPrivParm);
Actions.FinalizeDeclaration(OmpPrivParm);
return;
}
@@ -484,7 +485,7 @@ void Parser::ParseOpenMPReductionInitializerForDecl(VarDecl *OmpPrivParm) {
SourceLocation LParLoc = T.getOpenLocation();
auto RunSignatureHelp = [this, OmpPrivParm, LParLoc, &Exprs]() {
- QualType PreferredType = Actions.ProduceConstructorSignatureHelp(
+ QualType PreferredType = Actions.CodeCompletion().ProduceConstructorSignatureHelp(
OmpPrivParm->getType()->getCanonicalTypeInternal(),
OmpPrivParm->getLocation(), Exprs, LParLoc, /*Braced=*/false);
CalledSignatureHelp = true;
diff --git a/clang/lib/Parse/ParsePragma.cpp b/clang/lib/Parse/ParsePragma.cpp
index cd0fab5fe31d3..c2aaf2fd96328 100644
--- a/clang/lib/Parse/ParsePragma.cpp
+++ b/clang/lib/Parse/ParsePragma.cpp
@@ -21,6 +21,7 @@
#include "clang/Parse/RAIIObjectsForParser.h"
#include "clang/Sema/EnterExpressionEvaluationContext.h"
#include "clang/Sema/Scope.h"
+#include "clang/Sema/SemaCodeCompletion.h"
#include "clang/Sema/SemaCUDA.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringSwitch.h"
@@ -1924,7 +1925,7 @@ void Parser::HandlePragmaAttribute() {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
// FIXME: suppress completion of unsupported attributes?
- Actions.CodeCompleteAttribute(AttributeCommonInfo::Syntax::AS_GNU);
+ Actions.CodeCompletion().CodeCompleteAttribute(AttributeCommonInfo::Syntax::AS_GNU);
return SkipToEnd();
}
diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index e0116d3003100..c690177c236a1 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -22,6 +22,7 @@
#include "clang/Sema/DeclSpec.h"
#include "clang/Sema/EnterExpressionEvaluationContext.h"
#include "clang/Sema/Scope.h"
+#include "clang/Sema/SemaCodeCompletion.h"
#include "clang/Sema/SemaObjC.h"
#include "clang/Sema/SemaOpenMP.h"
#include "clang/Sema/TypoCorrection.h"
@@ -191,7 +192,7 @@ StmtResult Parser::ParseStatementOrDeclarationAfterAttributes(
case tok::code_completion:
cutOffParsing();
- Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Statement);
+ Actions.CodeCompletion().CodeCompleteOrdinaryName(getCurScope(), SemaCodeCompletion::PCC_Statement);
return StmtError();
case tok::identifier:
@@ -843,7 +844,7 @@ StmtResult Parser::ParseCaseStatement(ParsedStmtContext StmtCtx,
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteCase(getCurScope());
+ Actions.CodeCompletion().CodeCompleteCase(getCurScope());
return StmtError();
}
@@ -1649,7 +1650,7 @@ StmtResult Parser::ParseIfStatement(SourceLocation *TrailingElseLoc) {
InnerScope.Exit();
} else if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteAfterIf(getCurScope(), IsBracedThen);
+ Actions.CodeCompletion().CodeCompleteAfterIf(getCurScope(), IsBracedThen);
return StmtError();
} else if (InnerStatementTrailingElseLoc.isValid()) {
Diag(InnerStatementTrailingElseLoc, diag::warn_dangling_else);
@@ -2040,9 +2041,9 @@ StmtResult Parser::ParseForStatement(SourceLocation *TrailingElseLoc) {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteOrdinaryName(getCurScope(),
- C99orCXXorObjC? Sema::PCC_ForInit
- : Sema::PCC_Expression);
+ Actions.CodeCompletion().CodeCompleteOrdinaryName(getCurScope(),
+ C99orCXXorObjC? SemaCodeCompletion::PCC_ForInit
+ : SemaCodeCompletion::PCC_Expression);
return StmtError();
}
@@ -2117,7 +2118,7 @@ StmtResult Parser::ParseForStatement(SourceLocation *TrailingElseLoc) {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteObjCForCollection(getCurScope(), DG);
+ Actions.CodeCompletion().CodeCompleteObjCForCollection(getCurScope(), DG);
return StmtError();
}
Collection = ParseExpression();
@@ -2154,7 +2155,7 @@ StmtResult Parser::ParseForStatement(SourceLocation *TrailingElseLoc) {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteObjCForCollection(getCurScope(), nullptr);
+ Actions.CodeCompletion().CodeCompleteObjCForCollection(getCurScope(), nullptr);
return StmtError();
}
Collection = ParseExpression();
@@ -2431,7 +2432,7 @@ StmtResult Parser::ParseReturnStatement() {
// FIXME: Code completion for co_return.
if (Tok.is(tok::code_completion) && !IsCoreturn) {
cutOffParsing();
- Actions.CodeCompleteExpression(getCurScope(),
+ Actions.CodeCompletion().CodeCompleteExpression(getCurScope(),
PreferredType.get(Tok.getLocation()));
return StmtError();
}
diff --git a/clang/lib/Parse/ParseTemplate.cpp b/clang/lib/Parse/ParseTemplate.cpp
index 665253a6674d2..6de06b2c6e09c 100644
--- a/clang/lib/Parse/ParseTemplate.cpp
+++ b/clang/lib/Parse/ParseTemplate.cpp
@@ -1535,7 +1535,7 @@ bool Parser::ParseTemplateArgumentList(TemplateArgList &TemplateArgs,
if (!Template)
return QualType();
CalledSignatureHelp = true;
- return Actions.ProduceTemplateArgumentSignatureHelp(Template, TemplateArgs,
+ return Actions.CodeCompletion().ProduceTemplateArgumentSignatureHelp(Template, TemplateArgs,
OpenLoc);
};
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index 869b9c6669c27..2cac76005cddb 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -21,6 +21,7 @@
#include "clang/Sema/DeclSpec.h"
#include "clang/Sema/ParsedTemplate.h"
#include "clang/Sema/Scope.h"
+#include "clang/Sema/SemaCodeCompletion.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/TimeProfiler.h"
using namespace clang;
@@ -944,20 +945,20 @@ Parser::ParseExternalDeclaration(ParsedAttributes &Attrs,
cutOffParsing();
if (CurParsedObjCImpl) {
// Code-complete Objective-C methods even without leading '-'/'+' prefix.
- Actions.CodeCompleteObjCMethodDecl(getCurScope(),
+ Actions.CodeCompletion().CodeCompleteObjCMethodDecl(getCurScope(),
/*IsInstanceMethod=*/std::nullopt,
/*ReturnType=*/nullptr);
}
- Sema::ParserCompletionContext PCC;
+ SemaCodeCompletion::ParserCompletionContext PCC;
if (CurParsedObjCImpl) {
- PCC = Sema::PCC_ObjCImplementation;
+ PCC = SemaCodeCompletion::PCC_ObjCImplementation;
} else if (PP.isIncrementalProcessingEnabled()) {
- PCC = Sema::PCC_TopLevelOrExpression;
+ PCC = SemaCodeCompletion::PCC_TopLevelOrExpression;
} else {
- PCC = Sema::PCC_Namespace;
+ PCC = SemaCodeCompletion::PCC_Namespace;
};
- Actions.CodeCompleteOrdinaryName(getCurScope(), PCC);
+ Actions.CodeCompletion().CodeCompleteOrdinaryName(getCurScope(), PCC);
return nullptr;
case tok::kw_import: {
Sema::ModuleImportState IS = Sema::ModuleImportState::NotACXX20Module;
@@ -2280,54 +2281,54 @@ SourceLocation Parser::handleUnexpectedCodeCompletionToken() {
for (Scope *S = getCurScope(); S; S = S->getParent()) {
if (S->isFunctionScope()) {
cutOffParsing();
- Actions.CodeCompleteOrdinaryName(getCurScope(),
- Sema::PCC_RecoveryInFunction);
+ Actions.CodeCompletion().CodeCompleteOrdinaryName(getCurScope(),
+ SemaCodeCompletion::PCC_RecoveryInFunction);
return PrevTokLocation;
}
if (S->isClassScope()) {
cutOffParsing();
- Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Class);
+ Actions.CodeCompletion().CodeCompleteOrdinaryName(getCurScope(), SemaCodeCompletion::PCC_Class);
return PrevTokLocation;
}
}
cutOffParsing();
- Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Namespace);
+ Actions.CodeCompletion().CodeCompleteOrdinaryName(getCurScope(), SemaCodeCompletion::PCC_Namespace);
return PrevTokLocation;
}
// Code-completion pass-through functions
void Parser::CodeCompleteDirective(bool InConditional) {
- Actions.CodeCompletePreprocessorDirective(InConditional);
+ Actions.CodeCompletion().CodeCompletePreprocessorDirective(InConditional);
}
void Parser::CodeCompleteInConditionalExclusion() {
- Actions.CodeCompleteInPreprocessorConditionalExclusion(getCurScope());
+ Actions.CodeCompletion().CodeCompleteInPreprocessorConditionalExclusion(getCurScope());
}
void Parser::CodeCompleteMacroName(bool IsDefinition) {
- Actions.CodeCompletePreprocessorMacroName(IsDefinition);
+ Actions.CodeCompletion().CodeCompletePreprocessorMacroName(IsDefinition);
}
void Parser::CodeCompletePreprocessorExpression() {
- Actions.CodeCompletePreprocessorExpression();
+ Actions.CodeCompletion().CodeCompletePreprocessorExpression();
}
void Parser::CodeCompleteMacroArgument(IdentifierInfo *Macro,
MacroInfo *MacroInfo,
unsigned ArgumentIndex) {
- Actions.CodeCompletePreprocessorMacroArgument(getCurScope(), Macro, MacroInfo,
+ Actions.CodeCompletion().CodeCompletePreprocessorMacroArgument(getCurScope(), Macro, MacroInfo,
ArgumentIndex);
}
void Parser::CodeCompleteIncludedFile(llvm::StringRef Dir, bool IsAngled) {
- Actions.CodeCompleteIncludedFile(Dir, IsAngled);
+ Actions.CodeCompletion().CodeCompleteIncludedFile(Dir, IsAngled);
}
void Parser::CodeCompleteNaturalLanguage() {
- Actions.CodeCompleteNaturalLanguage();
+ Actions.CodeCompletion().CodeCompleteNaturalLanguage();
}
bool Parser::ParseMicrosoftIfExistsCondition(IfExistsCondition& Result) {
@@ -2681,7 +2682,7 @@ bool Parser::ParseModuleName(
if (!Tok.is(tok::identifier)) {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompleteModuleImport(UseLoc, Path);
+ Actions.CodeCompletion().CodeCompleteModuleImport(UseLoc, Path);
return true;
}
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 5d6ce233c775d..48cc8901a5933 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -41,6 +41,7 @@
#include "clang/Sema/RISCVIntrinsicManager.h"
#include "clang/Sema/Scope.h"
#include "clang/Sema/ScopeInfo.h"
+#include "clang/Sema/SemaCodeCompletion.h"
#include "clang/Sema/SemaCUDA.h"
#include "clang/Sema/SemaConsumer.h"
#include "clang/Sema/SemaHLSL.h"
@@ -202,6 +203,7 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
LateTemplateParser(nullptr), LateTemplateParserCleanup(nullptr),
OpaqueParser(nullptr), CurContext(nullptr), ExternalSource(nullptr),
CurScope(nullptr), Ident_super(nullptr),
+ CodeCompletionPtr(std::make_unique<SemaCodeCompletion>(*this, CodeCompleter)),
CUDAPtr(std::make_unique<SemaCUDA>(*this)),
HLSLPtr(std::make_unique<SemaHLSL>(*this)),
ObjCPtr(std::make_unique<SemaObjC>(*this)),
@@ -225,8 +227,7 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
TyposCorrected(0), IsBuildingRecoveryCallExpr(false), NumSFINAEErrors(0),
AccessCheckingSFINAE(false), CurrentInstantiationScope(nullptr),
InNonInstantiationSFINAEContext(false), NonInstantiationEntries(0),
- ArgumentPackSubstitutionIndex(-1), SatisfactionCache(Context),
- CodeCompleter(CodeCompleter) {
+ ArgumentPackSubstitutionIndex(-1), SatisfactionCache(Context) {
assert(pp.TUKind == TUKind);
TUScope = nullptr;
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp
index 328641ed94881..5095c10f535f2 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -9,6 +9,7 @@
// This file defines the code-completion semantic actions.
//
//===----------------------------------------------------------------------===//
+#include "clang/Sema/SemaCodeCompletion.h"
#include "clang/AST/ASTConcept.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclBase.h"
@@ -246,8 +247,8 @@ class ResultBuilder {
/// Whether we should include code patterns in the completion
/// results.
bool includeCodePatterns() const {
- return SemaRef.CodeCompleter &&
- SemaRef.CodeCompleter->includeCodePatterns();
+ return SemaRef.CodeCompletion().CodeCompleter &&
+ SemaRef.CodeCompletion().CodeCompleter->includeCodePatterns();
}
/// Set the filter used for code-completion results.
@@ -1863,7 +1864,7 @@ static void AddTypeSpecifierResults(const LangOptions &LangOpts,
Results.AddResult(Result("_Nullable", CCP_Type));
}
-static void AddStorageSpecifiers(Sema::ParserCompletionContext CCC,
+static void AddStorageSpecifiers(SemaCodeCompletion::ParserCompletionContext CCC,
const LangOptions &LangOpts,
ResultBuilder &Results) {
typedef CodeCompletionResult Result;
@@ -1889,13 +1890,13 @@ static void AddStorageSpecifiers(Sema::ParserCompletionContext CCC,
}
}
-static void AddFunctionSpecifiers(Sema::ParserCompletionContext CCC,
+static void AddFunctionSpecifiers(SemaCodeCompletion::ParserCompletionContext CCC,
const LangOptions &LangOpts,
ResultBuilder &Results) {
typedef CodeCompletionResult Result;
switch (CCC) {
- case Sema::PCC_Class:
- case Sema::PCC_MemberTemplate:
+ case SemaCodeCompletion::PCC_Class:
+ case SemaCodeCompletion::PCC_MemberTemplate:
if (LangOpts.CPlusPlus) {
Results.AddResult(Result("explicit"));
Results.AddResult(Result("friend"));
@@ -1904,24 +1905,24 @@ static void AddFunctionSpecifiers(Sema::ParserCompletionContext CCC,
}
[[fallthrough]];
- case Sema::PCC_ObjCInterface:
- case Sema::PCC_ObjCImplementation:
- case Sema::PCC_Namespace:
- case Sema::PCC_Template:
+ case SemaCodeCompletion::PCC_ObjCInterface:
+ case SemaCodeCompletion::PCC_ObjCImplementation:
+ case SemaCodeCompletion::PCC_Namespace:
+ case SemaCodeCompletion::PCC_Template:
if (LangOpts.CPlusPlus || LangOpts.C99)
Results.AddResult(Result("inline"));
break;
- case Sema::PCC_ObjCInstanceVariableList:
- case Sema::PCC_Expression:
- case Sema::PCC_Statement:
- case Sema::PCC_TopLevelOrExpression:
- case Sema::PCC_ForInit:
- case Sema::PCC_Condition:
- case Sema::PCC_RecoveryInFunction:
- case Sema::PCC_Type:
- case Sema::PCC_ParenthesizedExpression:
- case Sema::PCC_LocalDeclarationSpecifiers:
+ case SemaCodeCompletion::PCC_ObjCInstanceVariableList:
+ case SemaCodeCompletion::PCC_Expression:
+ case SemaCodeCompletion::PCC_Statement:
+ case SemaCodeCompletion::PCC_TopLevelOrExpression:
+ case SemaCodeCompletion::PCC_ForInit:
+ case SemaCodeCompletion::PCC_Condition:
+ case SemaCodeCompletion::PCC_RecoveryInFunction:
+ case SemaCodeCompletion::PCC_Type:
+ case SemaCodeCompletion::PCC_ParenthesizedExpression:
+ case SemaCodeCompletion::PCC_LocalDeclarationSpecifiers:
break;
}
}
@@ -1960,31 +1961,31 @@ static void AddUsingAliasResult(CodeCompletionBuilder &Builder,
Results.AddResult(CodeCompletionResult(Builder.TakeString()));
}
-static bool WantTypesInContext(Sema::ParserCompletionContext CCC,
+static bool WantTypesInContext(SemaCodeCompletion::ParserCompletionContext CCC,
const LangOptions &LangOpts) {
switch (CCC) {
- case Sema::PCC_Namespace:
- case Sema::PCC_Class:
- case Sema::PCC_ObjCInstanceVariableList:
- case Sema::PCC_Template:
- case Sema::PCC_MemberTemplate:
- case Sema::PCC_Statement:
- case Sema::PCC_RecoveryInFunction:
- case Sema::PCC_Type:
- case Sema::PCC_ParenthesizedExpression:
- case Sema::PCC_LocalDeclarationSpecifiers:
- case Sema::PCC_TopLevelOrExpression:
+ case SemaCodeCompletion::PCC_Namespace:
+ case SemaCodeCompletion::PCC_Class:
+ case SemaCodeCompletion::PCC_ObjCInstanceVariableList:
+ case SemaCodeCompletion::PCC_Template:
+ case SemaCodeCompletion::PCC_MemberTemplate:
+ case SemaCodeCompletion::PCC_Statement:
+ case SemaCodeCompletion::PCC_RecoveryInFunction:
+ case SemaCodeCompletion::PCC_Type:
+ case SemaCodeCompletion::PCC_ParenthesizedExpression:
+ case SemaCodeCompletion::PCC_LocalDeclarationSpecifiers:
+ case SemaCodeCompletion::PCC_TopLevelOrExpression:
return true;
- case Sema::PCC_Expression:
- case Sema::PCC_Condition:
+ case SemaCodeCompletion::PCC_Expression:
+ case SemaCodeCompletion::PCC_Condition:
return LangOpts.CPlusPlus;
- case Sema::PCC_ObjCInterface:
- case Sema::PCC_ObjCImplementation:
+ case SemaCodeCompletion::PCC_ObjCInterface:
+ case SemaCodeCompletion::PCC_ObjCImplementation:
return false;
- case Sema::PCC_ForInit:
+ case SemaCodeCompletion::PCC_ForInit:
return LangOpts.CPlusPlus || LangOpts.ObjC || LangOpts.C99;
}
@@ -2131,14 +2132,14 @@ static void AddOverrideResults(ResultBuilder &Results,
}
/// Add language constructs that show up for "ordinary" names.
-static void AddOrdinaryNameResults(Sema::ParserCompletionContext CCC, Scope *S,
+static void AddOrdinaryNameResults(SemaCodeCompletion::ParserCompletionContext CCC, Scope *S,
Sema &SemaRef, ResultBuilder &Results) {
CodeCompletionAllocator &Allocator = Results.getAllocator();
CodeCompletionBuilder Builder(Allocator, Results.getCodeCompletionTUInfo());
typedef CodeCompletionResult Result;
switch (CCC) {
- case Sema::PCC_Namespace:
+ case SemaCodeCompletion::PCC_Namespace:
if (SemaRef.getLangOpts().CPlusPlus) {
if (Results.includeCodePatterns()) {
// namespace <identifier> { declarations }
@@ -2194,7 +2195,7 @@ static void AddOrdinaryNameResults(Sema::ParserCompletionContext CCC, Scope *S,
AddTypedefResult(Results);
[[fallthrough]];
- case Sema::PCC_Class:
+ case SemaCodeCompletion::PCC_Class:
if (SemaRef.getLangOpts().CPlusPlus) {
// Using declaration
Builder.AddTypedTextChunk("using");
@@ -2221,7 +2222,7 @@ static void AddOrdinaryNameResults(Sema::ParserCompletionContext CCC, Scope *S,
AddStaticAssertResult(Builder, Results, SemaRef.getLangOpts());
- if (CCC == Sema::PCC_Class) {
+ if (CCC == SemaCodeCompletion::PCC_Class) {
AddTypedefResult(Results);
bool IsNotInheritanceScope = !S->isClassInheritanceScope();
@@ -2252,8 +2253,8 @@ static void AddOrdinaryNameResults(Sema::ParserCompletionContext CCC, Scope *S,
}
[[fallthrough]];
- case Sema::PCC_Template:
- case Sema::PCC_MemberTemplate:
+ case SemaCodeCompletion::PCC_Template:
+ case SemaCodeCompletion::PCC_MemberTemplate:
if (SemaRef.getLangOpts().CPlusPlus && Results.includeCodePatterns()) {
// template < parameters >
Builder.AddTypedTextChunk("template");
@@ -2269,25 +2270,25 @@ static void AddOrdinaryNameResults(Sema::ParserCompletionContext CCC, Scope *S,
AddFunctionSpecifiers(CCC, SemaRef.getLangOpts(), Results);
break;
- case Sema::PCC_ObjCInterface:
+ case SemaCodeCompletion::PCC_ObjCInterface:
AddObjCInterfaceResults(SemaRef.getLangOpts(), Results, true);
AddStorageSpecifiers(CCC, SemaRef.getLangOpts(), Results);
AddFunctionSpecifiers(CCC, SemaRef.getLangOpts(), Results);
break;
- case Sema::PCC_ObjCImplementation:
+ case SemaCodeCompletion::PCC_ObjCImplementation:
AddObjCImplementationResults(SemaRef.getLangOpts(), Results, true);
AddStorageSpecifiers(CCC, SemaRef.getLangOpts(), Results);
AddFunctionSpecifiers(CCC, SemaRef.getLangOpts(), Results);
break;
- case Sema::PCC_ObjCInstanceVariableList:
+ case SemaCodeCompletion::PCC_ObjCInstanceVariableList:
AddObjCVisibilityResults(SemaRef.getLangOpts(), Results, true);
break;
- case Sema::PCC_RecoveryInFunction:
- case Sema::PCC_TopLevelOrExpression:
- case Sema::PCC_Statement: {
+ case SemaCodeCompletion::PCC_RecoveryInFunction:
+ case SemaCodeCompletion::PCC_TopLevelOrExpression:
+ case SemaCodeCompletion::PCC_Statement: {
if (SemaRef.getLangOpts().CPlusPlus11)
AddUsingAliasResult(Builder, Results);
@@ -2524,15 +2525,15 @@ static void AddOrdinaryNameResults(Sema::ParserCompletionContext CCC, Scope *S,
[[fallthrough]];
// Fall through (for statement expressions).
- case Sema::PCC_ForInit:
- case Sema::PCC_Condition:
+ case SemaCodeCompletion::PCC_ForInit:
+ case SemaCodeCompletion::PCC_Condition:
AddStorageSpecifiers(CCC, SemaRef.getLangOpts(), Results);
// Fall through: conditions and statements can have expressions.
[[fallthrough]];
- case Sema::PCC_ParenthesizedExpression:
+ case SemaCodeCompletion::PCC_ParenthesizedExpression:
if (SemaRef.getLangOpts().ObjCAutoRefCount &&
- CCC == Sema::PCC_ParenthesizedExpression) {
+ CCC == SemaCodeCompletion::PCC_ParenthesizedExpression) {
// (__bridge <type>)<expression>
Builder.AddTypedTextChunk("__bridge");
Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
@@ -2560,7 +2561,7 @@ static void AddOrdinaryNameResults(Sema::ParserCompletionContext CCC, Scope *S,
// Fall through
[[fallthrough]];
- case Sema::PCC_Expression: {
+ case SemaCodeCompletion::PCC_Expression: {
if (SemaRef.getLangOpts().CPlusPlus) {
// 'this', if we're in a non-static member function.
addThisCompletion(SemaRef, Results);
@@ -2758,15 +2759,15 @@ static void AddOrdinaryNameResults(Sema::ParserCompletionContext CCC, Scope *S,
break;
}
- case Sema::PCC_Type:
- case Sema::PCC_LocalDeclarationSpecifiers:
+ case SemaCodeCompletion::PCC_Type:
+ case SemaCodeCompletion::PCC_LocalDeclarationSpecifiers:
break;
}
if (WantTypesInContext(CCC, SemaRef.getLangOpts()))
AddTypeSpecifierResults(SemaRef.getLangOpts(), Results);
- if (SemaRef.getLangOpts().CPlusPlus && CCC != Sema::PCC_Type)
+ if (SemaRef.getLangOpts().CPlusPlus && CCC != SemaCodeCompletion::PCC_Type)
Results.AddResult(Result("operator"));
}
@@ -4241,59 +4242,59 @@ static void HandleCodeCompleteResults(Sema *S,
}
static CodeCompletionContext
-mapCodeCompletionContext(Sema &S, Sema::ParserCompletionContext PCC) {
+mapCodeCompletionContext(Sema &S, SemaCodeCompletion::ParserCompletionContext PCC) {
switch (PCC) {
- case Sema::PCC_Namespace:
+ case SemaCodeCompletion::PCC_Namespace:
return CodeCompletionContext::CCC_TopLevel;
- case Sema::PCC_Class:
+ case SemaCodeCompletion::PCC_Class:
return CodeCompletionContext::CCC_ClassStructUnion;
- case Sema::PCC_ObjCInterface:
+ case SemaCodeCompletion::PCC_ObjCInterface:
return CodeCompletionContext::CCC_ObjCInterface;
- case Sema::PCC_ObjCImplementation:
+ case SemaCodeCompletion::PCC_ObjCImplementation:
return CodeCompletionContext::CCC_ObjCImplementation;
- case Sema::PCC_ObjCInstanceVariableList:
+ case SemaCodeCompletion::PCC_ObjCInstanceVariableList:
return CodeCompletionContext::CCC_ObjCIvarList;
- case Sema::PCC_Template:
- case Sema::PCC_MemberTemplate:
+ case SemaCodeCompletion::PCC_Template:
+ case SemaCodeCompletion::PCC_MemberTemplate:
if (S.CurContext->isFileContext())
return CodeCompletionContext::CCC_TopLevel;
if (S.CurContext->isRecord())
return CodeCompletionContext::CCC_ClassStructUnion;
return CodeCompletionContext::CCC_Other;
- case Sema::PCC_RecoveryInFunction:
+ case SemaCodeCompletion::PCC_RecoveryInFunction:
return CodeCompletionContext::CCC_Recovery;
- case Sema::PCC_ForInit:
+ case SemaCodeCompletion::PCC_ForInit:
if (S.getLangOpts().CPlusPlus || S.getLangOpts().C99 ||
S.getLangOpts().ObjC)
return CodeCompletionContext::CCC_ParenthesizedExpression;
else
return CodeCompletionContext::CCC_Expression;
- case Sema::PCC_Expression:
+ case SemaCodeCompletion::PCC_Expression:
return CodeCompletionContext::CCC_Expression;
- case Sema::PCC_Condition:
+ case SemaCodeCompletion::PCC_Condition:
return CodeCompletionContext(CodeCompletionContext::CCC_Expression,
S.getASTContext().BoolTy);
- case Sema::PCC_Statement:
+ case SemaCodeCompletion::PCC_Statement:
return CodeCompletionContext::CCC_Statement;
- case Sema::PCC_Type:
+ case SemaCodeCompletion::PCC_Type:
return CodeCompletionContext::CCC_Type;
- case Sema::PCC_ParenthesizedExpression:
+ case SemaCodeCompletion::PCC_ParenthesizedExpression:
return CodeCompletionContext::CCC_ParenthesizedExpression;
- case Sema::PCC_LocalDeclarationSpecifiers:
+ case SemaCodeCompletion::PCC_LocalDeclarationSpecifiers:
return CodeCompletionContext::CCC_Type;
- case Sema::PCC_TopLevelOrExpression:
+ case SemaCodeCompletion::PCC_TopLevelOrExpression:
return CodeCompletionContext::CCC_TopLevelOrExpression;
}
@@ -4366,10 +4367,10 @@ static void MaybeAddOverrideCalls(Sema &S, DeclContext *InContext,
}
}
-void Sema::CodeCompleteModuleImport(SourceLocation ImportLoc,
+void SemaCodeCompletion::CodeCompleteModuleImport(SourceLocation ImportLoc,
ModuleIdPath Path) {
typedef CodeCompletionResult Result;
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_Other);
Results.EnterNewScope();
@@ -4380,7 +4381,7 @@ void Sema::CodeCompleteModuleImport(SourceLocation ImportLoc,
if (Path.empty()) {
// Enumerate all top-level modules.
SmallVector<Module *, 8> Modules;
- PP.getHeaderSearchInfo().collectAllModules(Modules);
+ SemaRef.PP.getHeaderSearchInfo().collectAllModules(Modules);
for (unsigned I = 0, N = Modules.size(); I != N; ++I) {
Builder.AddTypedTextChunk(
Builder.getAllocator().CopyString(Modules[I]->Name));
@@ -4392,7 +4393,7 @@ void Sema::CodeCompleteModuleImport(SourceLocation ImportLoc,
} else if (getLangOpts().Modules) {
// Load the named module.
Module *Mod =
- PP.getModuleLoader().loadModule(ImportLoc, Path, Module::AllVisible,
+ SemaRef.PP.getModuleLoader().loadModule(ImportLoc, Path, Module::AllVisible,
/*IsInclusionDirective=*/false);
// Enumerate submodules.
if (Mod) {
@@ -4407,15 +4408,15 @@ void Sema::CodeCompleteModuleImport(SourceLocation ImportLoc,
}
}
Results.ExitScope();
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteOrdinaryName(Scope *S,
- ParserCompletionContext CompletionContext) {
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+void SemaCodeCompletion::CodeCompleteOrdinaryName(Scope *S,
+ SemaCodeCompletion::ParserCompletionContext CompletionContext) {
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
- mapCodeCompletionContext(*this, CompletionContext));
+ mapCodeCompletionContext(SemaRef, CompletionContext));
Results.EnterNewScope();
// Determine how to filter results, e.g., so that the names of
@@ -4446,7 +4447,7 @@ void Sema::CodeCompleteOrdinaryName(Scope *S,
Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
if (getLangOpts().CPlusPlus)
- MaybeAddOverrideCalls(*this, /*InContext=*/nullptr, Results);
+ MaybeAddOverrideCalls(SemaRef, /*InContext=*/nullptr, Results);
break;
case PCC_RecoveryInFunction:
@@ -4456,17 +4457,17 @@ void Sema::CodeCompleteOrdinaryName(Scope *S,
// If we are in a C++ non-static member function, check the qualifiers on
// the member function to filter/prioritize the results list.
- auto ThisType = getCurrentThisType();
+ auto ThisType = SemaRef.getCurrentThisType();
if (!ThisType.isNull())
Results.setObjectTypeQualifiers(ThisType->getPointeeType().getQualifiers(),
VK_LValue);
- CodeCompletionDeclConsumer Consumer(Results, CurContext);
- LookupVisibleDecls(S, LookupOrdinaryName, Consumer,
+ CodeCompletionDeclConsumer Consumer(Results, SemaRef.CurContext);
+ SemaRef.LookupVisibleDecls(S, SemaRef.LookupOrdinaryName, Consumer,
CodeCompleter->includeGlobals(),
CodeCompleter->loadExternal());
- AddOrdinaryNameResults(CompletionContext, S, *this, Results);
+ AddOrdinaryNameResults(CompletionContext, S, SemaRef, Results);
Results.ExitScope();
switch (CompletionContext) {
@@ -4494,9 +4495,9 @@ void Sema::CodeCompleteOrdinaryName(Scope *S,
}
if (CodeCompleter->includeMacros())
- AddMacroResults(PP, Results, CodeCompleter->loadExternal(), false);
+ AddMacroResults(SemaRef.PP, Results, CodeCompleter->loadExternal(), false);
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
@@ -4506,12 +4507,12 @@ AddClassMessageCompletions(Sema &SemaRef, Scope *S, ParsedType Receiver,
bool AtArgumentExpression, bool IsSuper,
ResultBuilder &Results);
-void Sema::CodeCompleteDeclSpec(Scope *S, DeclSpec &DS,
+void SemaCodeCompletion::CodeCompleteDeclSpec(Scope *S, DeclSpec &DS,
bool AllowNonIdentifiers,
bool AllowNestedNameSpecifiers) {
typedef CodeCompletionResult Result;
ResultBuilder Results(
- *this, CodeCompleter->getAllocator(),
+ SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
AllowNestedNameSpecifiers
// FIXME: Try to separate codepath leading here to deduce whether we
@@ -4540,8 +4541,8 @@ void Sema::CodeCompleteDeclSpec(Scope *S, DeclSpec &DS,
if (AllowNestedNameSpecifiers) {
Results.allowNestedNameSpecifiers();
Results.setFilter(&ResultBuilder::IsImpossibleToSatisfy);
- CodeCompletionDeclConsumer Consumer(Results, CurContext);
- LookupVisibleDecls(S, LookupNestedNameSpecifierName, Consumer,
+ CodeCompletionDeclConsumer Consumer(Results, SemaRef.CurContext);
+ SemaRef.LookupVisibleDecls(S, Sema::LookupNestedNameSpecifierName, Consumer,
CodeCompleter->includeGlobals(),
CodeCompleter->loadExternal());
Results.setFilter(nullptr);
@@ -4565,14 +4566,14 @@ void Sema::CodeCompleteDeclSpec(Scope *S, DeclSpec &DS,
0) {
ParsedType T = DS.getRepAsType();
if (!T.get().isNull() && T.get()->isObjCObjectOrInterfaceType())
- AddClassMessageCompletions(*this, S, T, std::nullopt, false, false,
+ AddClassMessageCompletions(SemaRef, S, T, std::nullopt, false, false,
Results);
}
// Note that we intentionally suppress macro results here, since we do not
// encourage using macros to produce the names of entities.
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
@@ -4592,12 +4593,12 @@ static const char *noUnderscoreAttrScope(llvm::StringRef Scope) {
return nullptr;
}
-void Sema::CodeCompleteAttribute(AttributeCommonInfo::Syntax Syntax,
+void SemaCodeCompletion::CodeCompleteAttribute(AttributeCommonInfo::Syntax Syntax,
AttributeCompletion Completion,
const IdentifierInfo *InScope) {
if (Completion == AttributeCompletion::None)
return;
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_Attribute);
@@ -4626,7 +4627,7 @@ void Sema::CodeCompleteAttribute(AttributeCommonInfo::Syntax Syntax,
llvm::DenseSet<llvm::StringRef> FoundScopes;
auto AddCompletions = [&](const ParsedAttrInfo &A) {
- if (A.IsTargetSpecific && !A.existsInTarget(Context.getTargetInfo()))
+ if (A.IsTargetSpecific && !A.existsInTarget(getASTContext().getTargetInfo()))
return;
if (!A.acceptsLangOpts(getLangOpts()))
return;
@@ -4724,11 +4725,11 @@ void Sema::CodeCompleteAttribute(AttributeCommonInfo::Syntax Syntax,
for (const auto &Entry : ParsedAttrInfoRegistry::entries())
AddCompletions(*Entry.instantiate());
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-struct Sema::CodeCompleteExpressionData {
+struct SemaCodeCompletion::CodeCompleteExpressionData {
CodeCompleteExpressionData(QualType PreferredType = QualType(),
bool IsParenthesized = false)
: PreferredType(PreferredType), IntegralConstantExpression(false),
@@ -4841,10 +4842,10 @@ static void AddLambdaCompletion(ResultBuilder &Results,
/// Perform code-completion in an expression context when we know what
/// type we're looking for.
-void Sema::CodeCompleteExpression(Scope *S,
+void SemaCodeCompletion::CodeCompleteExpression(Scope *S,
const CodeCompleteExpressionData &Data) {
ResultBuilder Results(
- *this, CodeCompleter->getAllocator(),
+ SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext(
Data.IsParenthesized
@@ -4869,13 +4870,13 @@ void Sema::CodeCompleteExpression(Scope *S,
for (unsigned I = 0, N = Data.IgnoreDecls.size(); I != N; ++I)
Results.Ignore(Data.IgnoreDecls[I]);
- CodeCompletionDeclConsumer Consumer(Results, CurContext);
- LookupVisibleDecls(S, LookupOrdinaryName, Consumer,
+ CodeCompletionDeclConsumer Consumer(Results, SemaRef.CurContext);
+ SemaRef.LookupVisibleDecls(S, Sema::LookupOrdinaryName, Consumer,
CodeCompleter->includeGlobals(),
CodeCompleter->loadExternal());
Results.EnterNewScope();
- AddOrdinaryNameResults(PCC, S, *this, Results);
+ AddOrdinaryNameResults(PCC, S, SemaRef, Results);
Results.ExitScope();
bool PreferredTypeIsPointer = false;
@@ -4889,7 +4890,7 @@ void Sema::CodeCompleteExpression(Scope *S,
Enum = Def;
// FIXME: collect covered enumerators in cases like:
// if (x == my_enum::one) { ... } else if (x == ^) {}
- AddEnumerators(Results, Context, Enum, CurContext, CoveredEnumerators());
+ AddEnumerators(Results, getASTContext(), Enum, SemaRef.CurContext, CoveredEnumerators());
}
}
@@ -4898,7 +4899,7 @@ void Sema::CodeCompleteExpression(Scope *S,
AddPrettyFunctionResults(getLangOpts(), Results);
if (CodeCompleter->includeMacros())
- AddMacroResults(PP, Results, CodeCompleter->loadExternal(), false,
+ AddMacroResults(SemaRef.PP, Results, CodeCompleter->loadExternal(), false,
PreferredTypeIsPointer);
// Complete a lambda expression when preferred type is a function.
@@ -4908,17 +4909,17 @@ void Sema::CodeCompleteExpression(Scope *S,
AddLambdaCompletion(Results, F->getParamTypes(), getLangOpts());
}
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteExpression(Scope *S, QualType PreferredType,
+void SemaCodeCompletion::CodeCompleteExpression(Scope *S, QualType PreferredType,
bool IsParenthesized) {
return CodeCompleteExpression(
S, CodeCompleteExpressionData(PreferredType, IsParenthesized));
}
-void Sema::CodeCompletePostfixExpression(Scope *S, ExprResult E,
+void SemaCodeCompletion::CodeCompletePostfixExpression(Scope *S, ExprResult E,
QualType PreferredType) {
if (E.isInvalid())
CodeCompleteExpression(S, PreferredType);
@@ -5183,9 +5184,9 @@ AddRecordMembersCompletionResults(Sema &SemaRef, ResultBuilder &Results,
FixIts.emplace_back(*AccessOpFixIt);
CodeCompletionDeclConsumer Consumer(Results, RD, BaseType, std::move(FixIts));
SemaRef.LookupVisibleDecls(RD, Sema::LookupMemberName, Consumer,
- SemaRef.CodeCompleter->includeGlobals(),
+ SemaRef.CodeCompletion().CodeCompleter->includeGlobals(),
/*IncludeDependentBases=*/true,
- SemaRef.CodeCompleter->loadExternal());
+ SemaRef.CodeCompletion().CodeCompleter->loadExternal());
if (SemaRef.getLangOpts().CPlusPlus) {
if (!Results.empty()) {
@@ -5701,7 +5702,7 @@ Expr *unwrapParenList(Expr *Base) {
} // namespace
-void Sema::CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base,
+void SemaCodeCompletion::CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base,
Expr *OtherOpBase,
SourceLocation OpLoc, bool IsArrow,
bool IsBaseExprStatement,
@@ -5711,7 +5712,7 @@ void Sema::CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base,
if (!Base || !CodeCompleter)
return;
- ExprResult ConvertedBase = PerformMemberExprBaseConversion(Base, IsArrow);
+ ExprResult ConvertedBase = SemaRef.PerformMemberExprBaseConversion(Base, IsArrow);
if (ConvertedBase.isInvalid())
return;
QualType ConvertedBaseType = getApproximateType(ConvertedBase.get());
@@ -5736,7 +5737,7 @@ void Sema::CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base,
CodeCompletionContext CCContext(contextKind, ConvertedBaseType);
CCContext.setPreferredType(PreferredType);
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(), CCContext,
&ResultBuilder::IsMember);
@@ -5745,7 +5746,7 @@ void Sema::CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base,
if (!Base)
return false;
- ExprResult ConvertedBase = PerformMemberExprBaseConversion(Base, IsArrow);
+ ExprResult ConvertedBase = SemaRef.PerformMemberExprBaseConversion(Base, IsArrow);
if (ConvertedBase.isInvalid())
return false;
Base = ConvertedBase.get();
@@ -5768,7 +5769,7 @@ void Sema::CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base,
}
if (RecordDecl *RD = getAsRecordDecl(BaseType)) {
- AddRecordMembersCompletionResults(*this, Results, S, BaseType, BaseKind,
+ AddRecordMembersCompletionResults(SemaRef, Results, S, BaseType, BaseKind,
RD, std::move(AccessOpFixIt));
} else if (const auto *TTPT =
dyn_cast<TemplateTypeParmType>(BaseType.getTypePtr())) {
@@ -5778,7 +5779,7 @@ void Sema::CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base,
if (R.Operator != Operator)
continue;
CodeCompletionResult Result(
- R.render(*this, CodeCompleter->getAllocator(),
+ R.render(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo()));
if (AccessOpFixIt)
Result.FixIts.push_back(*AccessOpFixIt);
@@ -5798,14 +5799,14 @@ void Sema::CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base,
// Add property results based on our interface.
assert(ObjCPtr && "Non-NULL pointer guaranteed above!");
AddObjCProperties(CCContext, ObjCPtr->getInterfaceDecl(), true,
- /*AllowNullaryMethods=*/true, CurContext,
+ /*AllowNullaryMethods=*/true, SemaRef.CurContext,
AddedProperties, Results, IsBaseExprStatement);
}
// Add properties from the protocols in a qualified interface.
for (auto *I : BaseType->castAs<ObjCObjectPointerType>()->quals())
AddObjCProperties(CCContext, I, true, /*AllowNullaryMethods=*/true,
- CurContext, AddedProperties, Results,
+ SemaRef.CurContext, AddedProperties, Results,
IsBaseExprStatement, /*IsClassProperty*/ false,
/*InOriginalClass*/ false);
} else if ((IsArrow && BaseType->isObjCObjectPointerType()) ||
@@ -5827,8 +5828,8 @@ void Sema::CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base,
if (Class) {
CodeCompletionDeclConsumer Consumer(Results, Class, BaseType);
Results.setFilter(&ResultBuilder::IsObjCIvar);
- LookupVisibleDecls(
- Class, LookupMemberName, Consumer, CodeCompleter->includeGlobals(),
+ SemaRef.LookupVisibleDecls(
+ Class, Sema::LookupMemberName, Consumer, CodeCompleter->includeGlobals(),
/*IncludeDependentBases=*/false, CodeCompleter->loadExternal());
}
}
@@ -5854,36 +5855,36 @@ void Sema::CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base,
return;
// Hand off the results found for code completion.
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteObjCClassPropertyRefExpr(Scope *S,
+void SemaCodeCompletion::CodeCompleteObjCClassPropertyRefExpr(Scope *S,
const IdentifierInfo &ClassName,
SourceLocation ClassNameLoc,
bool IsBaseExprStatement) {
const IdentifierInfo *ClassNamePtr = &ClassName;
ObjCInterfaceDecl *IFace =
- ObjC().getObjCInterfaceDecl(ClassNamePtr, ClassNameLoc);
+ SemaRef.ObjC().getObjCInterfaceDecl(ClassNamePtr, ClassNameLoc);
if (!IFace)
return;
CodeCompletionContext CCContext(
CodeCompletionContext::CCC_ObjCPropertyAccess);
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(), CCContext,
&ResultBuilder::IsMember);
Results.EnterNewScope();
AddedPropertiesSet AddedProperties;
AddObjCProperties(CCContext, IFace, true,
- /*AllowNullaryMethods=*/true, CurContext, AddedProperties,
+ /*AllowNullaryMethods=*/true, SemaRef.CurContext, AddedProperties,
Results, IsBaseExprStatement,
/*IsClassProperty=*/true);
Results.ExitScope();
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteTag(Scope *S, unsigned TagSpec) {
+void SemaCodeCompletion::CodeCompleteTag(Scope *S, unsigned TagSpec) {
if (!CodeCompleter)
return;
@@ -5912,25 +5913,25 @@ void Sema::CodeCompleteTag(Scope *S, unsigned TagSpec) {
llvm_unreachable("Unknown type specifier kind in CodeCompleteTag");
}
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(), ContextKind);
- CodeCompletionDeclConsumer Consumer(Results, CurContext);
+ CodeCompletionDeclConsumer Consumer(Results, SemaRef.CurContext);
// First pass: look for tags.
Results.setFilter(Filter);
- LookupVisibleDecls(S, LookupTagName, Consumer,
+ SemaRef.LookupVisibleDecls(S, Sema::LookupTagName, Consumer,
CodeCompleter->includeGlobals(),
CodeCompleter->loadExternal());
if (CodeCompleter->includeGlobals()) {
// Second pass: look for nested name specifiers.
Results.setFilter(&ResultBuilder::IsNestedNameSpecifier);
- LookupVisibleDecls(S, LookupNestedNameSpecifierName, Consumer,
+ SemaRef.LookupVisibleDecls(S, Sema::LookupNestedNameSpecifierName, Consumer,
CodeCompleter->includeGlobals(),
CodeCompleter->loadExternal());
}
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
@@ -5948,25 +5949,25 @@ static void AddTypeQualifierResults(DeclSpec &DS, ResultBuilder &Results,
Results.AddResult("__unaligned");
}
-void Sema::CodeCompleteTypeQualifiers(DeclSpec &DS) {
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+void SemaCodeCompletion::CodeCompleteTypeQualifiers(DeclSpec &DS) {
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_TypeQualifiers);
Results.EnterNewScope();
- AddTypeQualifierResults(DS, Results, LangOpts);
+ AddTypeQualifierResults(DS, Results, getLangOpts());
Results.ExitScope();
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteFunctionQualifiers(DeclSpec &DS, Declarator &D,
+void SemaCodeCompletion::CodeCompleteFunctionQualifiers(DeclSpec &DS, Declarator &D,
const VirtSpecifiers *VS) {
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_TypeQualifiers);
Results.EnterNewScope();
- AddTypeQualifierResults(DS, Results, LangOpts);
- if (LangOpts.CPlusPlus11) {
+ AddTypeQualifierResults(DS, Results, getLangOpts());
+ if (getLangOpts().CPlusPlus11) {
Results.AddResult("noexcept");
if (D.getContext() == DeclaratorContext::Member && !D.isCtorOrDtor() &&
!D.isStaticMember()) {
@@ -5977,19 +5978,19 @@ void Sema::CodeCompleteFunctionQualifiers(DeclSpec &DS, Declarator &D,
}
}
Results.ExitScope();
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteBracketDeclarator(Scope *S) {
+void SemaCodeCompletion::CodeCompleteBracketDeclarator(Scope *S) {
CodeCompleteExpression(S, QualType(getASTContext().getSizeType()));
}
-void Sema::CodeCompleteCase(Scope *S) {
- if (getCurFunction()->SwitchStack.empty() || !CodeCompleter)
+void SemaCodeCompletion::CodeCompleteCase(Scope *S) {
+ if (SemaRef.getCurFunction()->SwitchStack.empty() || !CodeCompleter)
return;
- SwitchStmt *Switch = getCurFunction()->SwitchStack.back().getPointer();
+ SwitchStmt *Switch = SemaRef.getCurFunction()->SwitchStack.back().getPointer();
// Condition expression might be invalid, do not continue in this case.
if (!Switch->getCond())
return;
@@ -6046,15 +6047,15 @@ void Sema::CodeCompleteCase(Scope *S) {
}
// Add any enumerators that have not yet been mentioned.
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_Expression);
- AddEnumerators(Results, Context, Enum, CurContext, Enumerators);
+ AddEnumerators(Results, getASTContext(), Enum, SemaRef.CurContext, Enumerators);
if (CodeCompleter->includeMacros()) {
- AddMacroResults(PP, Results, CodeCompleter->loadExternal(), false);
+ AddMacroResults(SemaRef.PP, Results, CodeCompleter->loadExternal(), false);
}
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
@@ -6136,7 +6137,7 @@ ProduceSignatureHelp(Sema &SemaRef, MutableArrayRef<ResultCandidate> Candidates,
if (Candidates.empty())
return QualType();
if (SemaRef.getPreprocessor().isCodeCompletionReached())
- SemaRef.CodeCompleter->ProcessOverloadCandidates(
+ SemaRef.CodeCompletion().CodeCompleter->ProcessOverloadCandidates(
SemaRef, CurrentArg, Candidates.data(), Candidates.size(), OpenParLoc,
Braced);
return getParamType(SemaRef, Candidates, CurrentArg);
@@ -6190,7 +6191,7 @@ static FunctionProtoTypeLoc GetPrototypeLoc(Expr *Fn) {
return {};
}
-QualType Sema::ProduceCallSignatureHelp(Expr *Fn, ArrayRef<Expr *> Args,
+QualType SemaCodeCompletion::ProduceCallSignatureHelp(Expr *Fn, ArrayRef<Expr *> Args,
SourceLocation OpenParLoc) {
Fn = unwrapParenList(Fn);
if (!CodeCompleter || !Fn)
@@ -6214,7 +6215,7 @@ QualType Sema::ProduceCallSignatureHelp(Expr *Fn, ArrayRef<Expr *> Args,
OverloadCandidateSet CandidateSet(Loc, OverloadCandidateSet::CSK_Normal);
if (auto ULE = dyn_cast<UnresolvedLookupExpr>(NakedFn)) {
- AddOverloadedCallCandidates(ULE, ArgsWithoutDependentTypes, CandidateSet,
+ SemaRef.AddOverloadedCallCandidates(ULE, ArgsWithoutDependentTypes, CandidateSet,
/*PartialOverloading=*/true);
} else if (auto UME = dyn_cast<UnresolvedMemberExpr>(NakedFn)) {
TemplateArgumentListInfo TemplateArgsBuffer, *TemplateArgs = nullptr;
@@ -6231,7 +6232,7 @@ QualType Sema::ProduceCallSignatureHelp(Expr *Fn, ArrayRef<Expr *> Args,
UnresolvedSet<8> Decls;
Decls.append(UME->decls_begin(), UME->decls_end());
const bool FirstArgumentIsBase = !UME->isImplicitAccess() && UME->getBase();
- AddFunctionCandidates(Decls, ArgExprs, CandidateSet, TemplateArgs,
+ SemaRef.AddFunctionCandidates(Decls, ArgExprs, CandidateSet, TemplateArgs,
/*SuppressUserConversions=*/false,
/*PartialOverloading=*/true, FirstArgumentIsBase);
} else {
@@ -6245,7 +6246,7 @@ QualType Sema::ProduceCallSignatureHelp(Expr *Fn, ArrayRef<Expr *> Args,
!FD->getType()->getAs<FunctionProtoType>())
Results.push_back(ResultCandidate(FD));
else
- AddOverloadCandidate(FD, DeclAccessPair::make(FD, FD->getAccess()),
+ SemaRef.AddOverloadCandidate(FD, DeclAccessPair::make(FD, FD->getAccess()),
ArgsWithoutDependentTypes, CandidateSet,
/*SuppressUserConversions=*/false,
/*PartialOverloading=*/true);
@@ -6254,16 +6255,16 @@ QualType Sema::ProduceCallSignatureHelp(Expr *Fn, ArrayRef<Expr *> Args,
// If expression's type is CXXRecordDecl, it may overload the function
// call operator, so we check if it does and add them as candidates.
// A complete type is needed to lookup for member function call operators.
- if (isCompleteType(Loc, NakedFn->getType())) {
+ if (SemaRef.isCompleteType(Loc, NakedFn->getType())) {
DeclarationName OpName =
- Context.DeclarationNames.getCXXOperatorName(OO_Call);
- LookupResult R(*this, OpName, Loc, LookupOrdinaryName);
- LookupQualifiedName(R, DC);
+ getASTContext().DeclarationNames.getCXXOperatorName(OO_Call);
+ LookupResult R(SemaRef, OpName, Loc, Sema::LookupOrdinaryName);
+ SemaRef.LookupQualifiedName(R, DC);
R.suppressDiagnostics();
SmallVector<Expr *, 12> ArgExprs(1, NakedFn);
ArgExprs.append(ArgsWithoutDependentTypes.begin(),
ArgsWithoutDependentTypes.end());
- AddFunctionCandidates(R.asUnresolvedSet(), ArgExprs, CandidateSet,
+ SemaRef.AddFunctionCandidates(R.asUnresolvedSet(), ArgExprs, CandidateSet,
/*ExplicitArgs=*/nullptr,
/*SuppressUserConversions=*/false,
/*PartialOverloading=*/true);
@@ -6278,7 +6279,7 @@ QualType Sema::ProduceCallSignatureHelp(Expr *Fn, ArrayRef<Expr *> Args,
T = T->getPointeeType();
if (auto FP = T->getAs<FunctionProtoType>()) {
- if (!TooManyArguments(FP->getNumParams(),
+ if (!SemaRef.TooManyArguments(FP->getNumParams(),
ArgsWithoutDependentTypes.size(),
/*PartialOverloading=*/true) ||
FP->isVariadic()) {
@@ -6293,8 +6294,8 @@ QualType Sema::ProduceCallSignatureHelp(Expr *Fn, ArrayRef<Expr *> Args,
Results.push_back(ResultCandidate(FT));
}
}
- mergeCandidatesWithResults(*this, Results, CandidateSet, Loc, Args.size());
- QualType ParamType = ProduceSignatureHelp(*this, Results, Args.size(),
+ mergeCandidatesWithResults(SemaRef, Results, CandidateSet, Loc, Args.size());
+ QualType ParamType = ProduceSignatureHelp(SemaRef, Results, Args.size(),
OpenParLoc, /*Braced=*/false);
return !CandidateSet.empty() ? ParamType : QualType();
}
@@ -6366,7 +6367,7 @@ getNextAggregateIndexAfterDesignatedInit(const ResultCandidate &Aggregate,
return DesignatedIndex + ArgsAfterDesignator + 1;
}
-QualType Sema::ProduceConstructorSignatureHelp(QualType Type,
+QualType SemaCodeCompletion::ProduceConstructorSignatureHelp(QualType Type,
SourceLocation Loc,
ArrayRef<Expr *> Args,
SourceLocation OpenParLoc,
@@ -6377,7 +6378,7 @@ QualType Sema::ProduceConstructorSignatureHelp(QualType Type,
// A complete type is needed to lookup for constructors.
RecordDecl *RD =
- isCompleteType(Loc, Type) ? Type->getAsRecordDecl() : nullptr;
+ SemaRef.isCompleteType(Loc, Type) ? Type->getAsRecordDecl() : nullptr;
if (!RD)
return Type;
CXXRecordDecl *CRD = dyn_cast<CXXRecordDecl>(RD);
@@ -6389,7 +6390,7 @@ QualType Sema::ProduceConstructorSignatureHelp(QualType Type,
// FIXME: it would be nice to support "unwrapping" aggregates that contain
// a single subaggregate, like std::array<T, N> -> T __elements[N].
if (Braced && !RD->isUnion() &&
- (!LangOpts.CPlusPlus || (CRD && CRD->isAggregate()))) {
+ (!getLangOpts().CPlusPlus || (CRD && CRD->isAggregate()))) {
ResultCandidate AggregateSig(RD);
unsigned AggregateSize = AggregateSig.getNumParams();
@@ -6399,7 +6400,7 @@ QualType Sema::ProduceConstructorSignatureHelp(QualType Type,
if (*NextIndex >= AggregateSize)
return Type;
Results.push_back(AggregateSig);
- return ProduceSignatureHelp(*this, Results, *NextIndex, OpenParLoc,
+ return ProduceSignatureHelp(SemaRef, Results, *NextIndex, OpenParLoc,
Braced);
}
@@ -6413,36 +6414,36 @@ QualType Sema::ProduceConstructorSignatureHelp(QualType Type,
if (CRD) {
OverloadCandidateSet CandidateSet(Loc, OverloadCandidateSet::CSK_Normal);
- for (NamedDecl *C : LookupConstructors(CRD)) {
+ for (NamedDecl *C : SemaRef.LookupConstructors(CRD)) {
if (auto *FD = dyn_cast<FunctionDecl>(C)) {
// FIXME: we can't yet provide correct signature help for initializer
// list constructors, so skip them entirely.
- if (Braced && LangOpts.CPlusPlus && isInitListConstructor(FD))
+ if (Braced && getLangOpts().CPlusPlus && SemaRef.isInitListConstructor(FD))
continue;
- AddOverloadCandidate(FD, DeclAccessPair::make(FD, C->getAccess()), Args,
+ SemaRef.AddOverloadCandidate(FD, DeclAccessPair::make(FD, C->getAccess()), Args,
CandidateSet,
/*SuppressUserConversions=*/false,
/*PartialOverloading=*/true,
/*AllowExplicit*/ true);
} else if (auto *FTD = dyn_cast<FunctionTemplateDecl>(C)) {
- if (Braced && LangOpts.CPlusPlus &&
- isInitListConstructor(FTD->getTemplatedDecl()))
+ if (Braced && getLangOpts().CPlusPlus &&
+ SemaRef.isInitListConstructor(FTD->getTemplatedDecl()))
continue;
- AddTemplateOverloadCandidate(
+ SemaRef.AddTemplateOverloadCandidate(
FTD, DeclAccessPair::make(FTD, C->getAccess()),
/*ExplicitTemplateArgs=*/nullptr, Args, CandidateSet,
/*SuppressUserConversions=*/false,
/*PartialOverloading=*/true);
}
}
- mergeCandidatesWithResults(*this, Results, CandidateSet, Loc, Args.size());
+ mergeCandidatesWithResults(SemaRef, Results, CandidateSet, Loc, Args.size());
}
- return ProduceSignatureHelp(*this, Results, Args.size(), OpenParLoc, Braced);
+ return ProduceSignatureHelp(SemaRef, Results, Args.size(), OpenParLoc, Braced);
}
-QualType Sema::ProduceCtorInitMemberSignatureHelp(
+QualType SemaCodeCompletion::ProduceCtorInitMemberSignatureHelp(
Decl *ConstructorDecl, CXXScopeSpec SS, ParsedType TemplateTypeTy,
ArrayRef<Expr *> ArgExprs, IdentifierInfo *II, SourceLocation OpenParLoc,
bool Braced) {
@@ -6454,7 +6455,7 @@ QualType Sema::ProduceCtorInitMemberSignatureHelp(
if (!Constructor)
return QualType();
// FIXME: Add support for Base class constructors as well.
- if (ValueDecl *MemberDecl = tryLookupCtorInitMemberDecl(
+ if (ValueDecl *MemberDecl = SemaRef.tryLookupCtorInitMemberDecl(
Constructor->getParent(), SS, TemplateTypeTy, II))
return ProduceConstructorSignatureHelp(MemberDecl->getType(),
MemberDecl->getLocation(), ArgExprs,
@@ -6484,7 +6485,7 @@ static bool argMatchesTemplateParams(const ParsedTemplateArgument &Arg,
llvm_unreachable("Unhandled switch case");
}
-QualType Sema::ProduceTemplateArgumentSignatureHelp(
+QualType SemaCodeCompletion::ProduceTemplateArgumentSignatureHelp(
TemplateTy ParsedTemplate, ArrayRef<ParsedTemplateArgument> Args,
SourceLocation LAngleLoc) {
if (!CodeCompleter || !ParsedTemplate)
@@ -6512,7 +6513,7 @@ QualType Sema::ProduceTemplateArgumentSignatureHelp(
if (const auto *TD = llvm::dyn_cast<TemplateDecl>(ND))
Consider(TD);
}
- return ProduceSignatureHelp(*this, Results, Args.size(), LAngleLoc,
+ return ProduceSignatureHelp(SemaRef, Results, Args.size(), LAngleLoc,
/*Braced=*/false);
}
@@ -6541,7 +6542,7 @@ static QualType getDesignatedType(QualType BaseType, const Designation &Desig) {
return BaseType;
}
-void Sema::CodeCompleteDesignator(QualType BaseType,
+void SemaCodeCompletion::CodeCompleteDesignator(QualType BaseType,
llvm::ArrayRef<Expr *> InitExprs,
const Designation &D) {
BaseType = getDesignatedType(BaseType, D);
@@ -6553,7 +6554,7 @@ void Sema::CodeCompleteDesignator(QualType BaseType,
CodeCompletionContext CCC(CodeCompletionContext::CCC_DotMemberAccess,
BaseType);
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(), CCC);
Results.EnterNewScope();
@@ -6569,14 +6570,14 @@ void Sema::CodeCompleteDesignator(QualType BaseType,
// FIXME: Make use of previous designators to mark any fields before those
// inaccessible, and also compute the next initializer priority.
ResultBuilder::Result Result(FD, Results.getBasePriority(FD));
- Results.AddResult(Result, CurContext, /*Hiding=*/nullptr);
+ Results.AddResult(Result, SemaRef.CurContext, /*Hiding=*/nullptr);
}
Results.ExitScope();
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteInitializer(Scope *S, Decl *D) {
+void SemaCodeCompletion::CodeCompleteInitializer(Scope *S, Decl *D) {
ValueDecl *VD = dyn_cast_or_null<ValueDecl>(D);
if (!VD) {
CodeCompleteOrdinaryName(S, PCC_Expression);
@@ -6591,19 +6592,19 @@ void Sema::CodeCompleteInitializer(Scope *S, Decl *D) {
CodeCompleteExpression(S, Data);
}
-void Sema::CodeCompleteAfterIf(Scope *S, bool IsBracedThen) {
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+void SemaCodeCompletion::CodeCompleteAfterIf(Scope *S, bool IsBracedThen) {
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
- mapCodeCompletionContext(*this, PCC_Statement));
+ mapCodeCompletionContext(SemaRef, PCC_Statement));
Results.setFilter(&ResultBuilder::IsOrdinaryName);
Results.EnterNewScope();
- CodeCompletionDeclConsumer Consumer(Results, CurContext);
- LookupVisibleDecls(S, LookupOrdinaryName, Consumer,
+ CodeCompletionDeclConsumer Consumer(Results, SemaRef.CurContext);
+ SemaRef.LookupVisibleDecls(S, Sema::LookupOrdinaryName, Consumer,
CodeCompleter->includeGlobals(),
CodeCompleter->loadExternal());
- AddOrdinaryNameResults(PCC_Statement, S, *this, Results);
+ AddOrdinaryNameResults(PCC_Statement, S, SemaRef, Results);
// "else" block
CodeCompletionBuilder Builder(Results.getAllocator(),
@@ -6649,13 +6650,13 @@ void Sema::CodeCompleteAfterIf(Scope *S, bool IsBracedThen) {
AddPrettyFunctionResults(getLangOpts(), Results);
if (CodeCompleter->includeMacros())
- AddMacroResults(PP, Results, CodeCompleter->loadExternal(), false);
+ AddMacroResults(SemaRef.PP, Results, CodeCompleter->loadExternal(), false);
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS,
+void SemaCodeCompletion::CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS,
bool EnteringContext,
bool IsUsingDeclaration, QualType BaseType,
QualType PreferredType) {
@@ -6674,34 +6675,34 @@ void Sema::CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS,
// As SS is invalid, we try to collect accessible contexts from the current
// scope with a dummy lookup so that the completion consumer can try to
// guess what the specified scope is.
- ResultBuilder DummyResults(*this, CodeCompleter->getAllocator(),
+ ResultBuilder DummyResults(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(), CC);
if (!PreferredType.isNull())
DummyResults.setPreferredType(PreferredType);
if (S->getEntity()) {
CodeCompletionDeclConsumer Consumer(DummyResults, S->getEntity(),
BaseType);
- LookupVisibleDecls(S, LookupOrdinaryName, Consumer,
+ SemaRef.LookupVisibleDecls(S, Sema::LookupOrdinaryName, Consumer,
/*IncludeGlobalScope=*/false,
/*LoadExternal=*/false);
}
- HandleCodeCompleteResults(this, CodeCompleter,
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
DummyResults.getCompletionContext(), nullptr, 0);
return;
}
// Always pretend to enter a context to ensure that a dependent type
// resolves to a dependent record.
- DeclContext *Ctx = computeDeclContext(SS, /*EnteringContext=*/true);
+ DeclContext *Ctx = SemaRef.computeDeclContext(SS, /*EnteringContext=*/true);
// Try to instantiate any non-dependent declaration contexts before
// we look in them. Bail out if we fail.
NestedNameSpecifier *NNS = SS.getScopeRep();
if (NNS != nullptr && SS.isValid() && !NNS->isDependent()) {
- if (Ctx == nullptr || RequireCompleteDeclContext(SS, Ctx))
+ if (Ctx == nullptr || SemaRef.RequireCompleteDeclContext(SS, Ctx))
return;
}
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(), CC);
if (!PreferredType.isNull())
Results.setPreferredType(PreferredType);
@@ -6722,7 +6723,7 @@ void Sema::CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS,
if (R.Operator != ConceptInfo::Member::Colons)
continue;
Results.AddResult(CodeCompletionResult(
- R.render(*this, CodeCompleter->getAllocator(),
+ R.render(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo())));
}
}
@@ -6734,23 +6735,23 @@ void Sema::CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS,
// in a context that permits expressions. This is a general issue with
// qualified-id completions.
if (Ctx && !EnteringContext)
- MaybeAddOverrideCalls(*this, Ctx, Results);
+ MaybeAddOverrideCalls(SemaRef, Ctx, Results);
Results.ExitScope();
if (Ctx &&
(CodeCompleter->includeNamespaceLevelDecls() || !Ctx->isFileContext())) {
CodeCompletionDeclConsumer Consumer(Results, Ctx, BaseType);
- LookupVisibleDecls(Ctx, LookupOrdinaryName, Consumer,
+ SemaRef.LookupVisibleDecls(Ctx, Sema::LookupOrdinaryName, Consumer,
/*IncludeGlobalScope=*/true,
/*IncludeDependentBases=*/true,
CodeCompleter->loadExternal());
}
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteUsing(Scope *S) {
+void SemaCodeCompletion::CodeCompleteUsing(Scope *S) {
if (!CodeCompleter)
return;
@@ -6759,7 +6760,7 @@ void Sema::CodeCompleteUsing(Scope *S) {
CodeCompletionContext Context(CodeCompletionContext::CCC_SymbolOrNewName);
Context.setIsUsingDeclaration(true);
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(), Context,
&ResultBuilder::IsNestedNameSpecifier);
Results.EnterNewScope();
@@ -6770,48 +6771,48 @@ void Sema::CodeCompleteUsing(Scope *S) {
// After "using", we can see anything that would start a
// nested-name-specifier.
- CodeCompletionDeclConsumer Consumer(Results, CurContext);
- LookupVisibleDecls(S, LookupOrdinaryName, Consumer,
+ CodeCompletionDeclConsumer Consumer(Results, SemaRef.CurContext);
+ SemaRef.LookupVisibleDecls(S, Sema::LookupOrdinaryName, Consumer,
CodeCompleter->includeGlobals(),
CodeCompleter->loadExternal());
Results.ExitScope();
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteUsingDirective(Scope *S) {
+void SemaCodeCompletion::CodeCompleteUsingDirective(Scope *S) {
if (!CodeCompleter)
return;
// After "using namespace", we expect to see a namespace name or namespace
// alias.
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_Namespace,
&ResultBuilder::IsNamespaceOrAlias);
Results.EnterNewScope();
- CodeCompletionDeclConsumer Consumer(Results, CurContext);
- LookupVisibleDecls(S, LookupOrdinaryName, Consumer,
+ CodeCompletionDeclConsumer Consumer(Results, SemaRef.CurContext);
+ SemaRef.LookupVisibleDecls(S, Sema::LookupOrdinaryName, Consumer,
CodeCompleter->includeGlobals(),
CodeCompleter->loadExternal());
Results.ExitScope();
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteNamespaceDecl(Scope *S) {
+void SemaCodeCompletion::CodeCompleteNamespaceDecl(Scope *S) {
if (!CodeCompleter)
return;
DeclContext *Ctx = S->getEntity();
if (!S->getParent())
- Ctx = Context.getTranslationUnitDecl();
+ Ctx = getASTContext().getTranslationUnitDecl();
bool SuppressedGlobalResults =
Ctx && !CodeCompleter->includeGlobals() && isa<TranslationUnitDecl>(Ctx);
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
SuppressedGlobalResults
? CodeCompletionContext::CCC_Namespace
@@ -6840,37 +6841,37 @@ void Sema::CodeCompleteNamespaceDecl(Scope *S) {
Results.AddResult(
CodeCompletionResult(NS->second, Results.getBasePriority(NS->second),
nullptr),
- CurContext, nullptr, false);
+ SemaRef.CurContext, nullptr, false);
Results.ExitScope();
}
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteNamespaceAliasDecl(Scope *S) {
+void SemaCodeCompletion::CodeCompleteNamespaceAliasDecl(Scope *S) {
if (!CodeCompleter)
return;
// After "namespace", we expect to see a namespace or alias.
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_Namespace,
&ResultBuilder::IsNamespaceOrAlias);
- CodeCompletionDeclConsumer Consumer(Results, CurContext);
- LookupVisibleDecls(S, LookupOrdinaryName, Consumer,
+ CodeCompletionDeclConsumer Consumer(Results, SemaRef.CurContext);
+ SemaRef.LookupVisibleDecls(S, Sema::LookupOrdinaryName, Consumer,
CodeCompleter->includeGlobals(),
CodeCompleter->loadExternal());
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteOperatorName(Scope *S) {
+void SemaCodeCompletion::CodeCompleteOperatorName(Scope *S) {
if (!CodeCompleter)
return;
typedef CodeCompletionResult Result;
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_Type,
&ResultBuilder::IsType);
@@ -6885,8 +6886,8 @@ void Sema::CodeCompleteOperatorName(Scope *S) {
// Add any type names visible from the current scope
Results.allowNestedNameSpecifiers();
- CodeCompletionDeclConsumer Consumer(Results, CurContext);
- LookupVisibleDecls(S, LookupOrdinaryName, Consumer,
+ CodeCompletionDeclConsumer Consumer(Results, SemaRef.CurContext);
+ SemaRef.LookupVisibleDecls(S, Sema::LookupOrdinaryName, Consumer,
CodeCompleter->includeGlobals(),
CodeCompleter->loadExternal());
@@ -6894,22 +6895,22 @@ void Sema::CodeCompleteOperatorName(Scope *S) {
AddTypeSpecifierResults(getLangOpts(), Results);
Results.ExitScope();
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteConstructorInitializer(
+void SemaCodeCompletion::CodeCompleteConstructorInitializer(
Decl *ConstructorD, ArrayRef<CXXCtorInitializer *> Initializers) {
if (!ConstructorD)
return;
- AdjustDeclIfTemplate(ConstructorD);
+ SemaRef.AdjustDeclIfTemplate(ConstructorD);
auto *Constructor = dyn_cast<CXXConstructorDecl>(ConstructorD);
if (!Constructor)
return;
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_Symbol);
Results.EnterNewScope();
@@ -6919,7 +6920,7 @@ void Sema::CodeCompleteConstructorInitializer(
llvm::SmallPtrSet<CanQualType, 4> InitializedBases;
for (unsigned I = 0, E = Initializers.size(); I != E; ++I) {
if (Initializers[I]->isBaseInitializer())
- InitializedBases.insert(Context.getCanonicalType(
+ InitializedBases.insert(getASTContext().getCanonicalType(
QualType(Initializers[I]->getBaseClass(), 0)));
else
InitializedFields.insert(
@@ -6927,7 +6928,7 @@ void Sema::CodeCompleteConstructorInitializer(
}
// Add completions for base classes.
- PrintingPolicy Policy = getCompletionPrintingPolicy(*this);
+ PrintingPolicy Policy = getCompletionPrintingPolicy(SemaRef);
bool SawLastInitializer = Initializers.empty();
CXXRecordDecl *ClassDecl = Constructor->getParent();
@@ -6937,9 +6938,9 @@ void Sema::CodeCompleteConstructorInitializer(
Builder.AddTypedTextChunk(Name);
Builder.AddChunk(CodeCompletionString::CK_LeftParen);
if (const auto *Function = dyn_cast<FunctionDecl>(ND))
- AddFunctionParameterChunks(PP, Policy, Function, Builder);
+ AddFunctionParameterChunks(SemaRef.PP, Policy, Function, Builder);
else if (const auto *FunTemplDecl = dyn_cast<FunctionTemplateDecl>(ND))
- AddFunctionParameterChunks(PP, Policy, FunTemplDecl->getTemplatedDecl(),
+ AddFunctionParameterChunks(SemaRef.PP, Policy, FunTemplDecl->getTemplatedDecl(),
Builder);
Builder.AddChunk(CodeCompletionString::CK_RightParen);
return Builder.TakeString();
@@ -6972,7 +6973,7 @@ void Sema::CodeCompleteConstructorInitializer(
FD->getType().getAsString(Policy))
: Name,
FD);
- auto Ctors = getConstructors(Context, RD);
+ auto Ctors = getConstructors(getASTContext(), RD);
if (Ctors.begin() == Ctors.end())
return AddDefaultCtorInit(Name, Name, RD);
for (const NamedDecl *Ctor : Ctors) {
@@ -6999,11 +7000,11 @@ void Sema::CodeCompleteConstructorInitializer(
};
for (const auto &Base : ClassDecl->bases()) {
- if (!InitializedBases.insert(Context.getCanonicalType(Base.getType()))
+ if (!InitializedBases.insert(getASTContext().getCanonicalType(Base.getType()))
.second) {
SawLastInitializer =
!Initializers.empty() && Initializers.back()->isBaseInitializer() &&
- Context.hasSameUnqualifiedType(
+ getASTContext().hasSameUnqualifiedType(
Base.getType(), QualType(Initializers.back()->getBaseClass(), 0));
continue;
}
@@ -7014,11 +7015,11 @@ void Sema::CodeCompleteConstructorInitializer(
// Add completions for virtual base classes.
for (const auto &Base : ClassDecl->vbases()) {
- if (!InitializedBases.insert(Context.getCanonicalType(Base.getType()))
+ if (!InitializedBases.insert(getASTContext().getCanonicalType(Base.getType()))
.second) {
SawLastInitializer =
!Initializers.empty() && Initializers.back()->isBaseInitializer() &&
- Context.hasSameUnqualifiedType(
+ getASTContext().hasSameUnqualifiedType(
Base.getType(), QualType(Initializers.back()->getBaseClass(), 0));
continue;
}
@@ -7045,7 +7046,7 @@ void Sema::CodeCompleteConstructorInitializer(
}
Results.ExitScope();
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
@@ -7058,9 +7059,9 @@ static bool isNamespaceScope(Scope *S) {
return DC->isFileContext();
}
-void Sema::CodeCompleteLambdaIntroducer(Scope *S, LambdaIntroducer &Intro,
+void SemaCodeCompletion::CodeCompleteLambdaIntroducer(Scope *S, LambdaIntroducer &Intro,
bool AfterAmpersand) {
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_Other);
Results.EnterNewScope();
@@ -7086,24 +7087,24 @@ void Sema::CodeCompleteLambdaIntroducer(Scope *S, LambdaIntroducer &Intro,
if (Known.insert(Var->getIdentifier()).second)
Results.AddResult(CodeCompletionResult(Var, CCP_LocalDeclaration),
- CurContext, nullptr, false);
+ SemaRef.CurContext, nullptr, false);
}
}
// Add 'this', if it would be valid.
if (!IncludedThis && !AfterAmpersand && Intro.Default != LCD_ByCopy)
- addThisCompletion(*this, Results);
+ addThisCompletion(SemaRef, Results);
Results.ExitScope();
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteAfterFunctionEquals(Declarator &D) {
- if (!LangOpts.CPlusPlus11)
+void SemaCodeCompletion::CodeCompleteAfterFunctionEquals(Declarator &D) {
+ if (!getLangOpts().CPlusPlus11)
return;
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_Other);
auto ShouldAddDefault = [&D, this]() {
@@ -7123,7 +7124,7 @@ void Sema::CodeCompleteAfterFunctionEquals(Declarator &D) {
// verify that it is the copy or move assignment?
if (Op == OverloadedOperatorKind::OO_Equal)
return true;
- if (LangOpts.CPlusPlus20 &&
+ if (getLangOpts().CPlusPlus20 &&
(Op == OverloadedOperatorKind::OO_EqualEqual ||
Op == OverloadedOperatorKind::OO_ExclaimEqual ||
Op == OverloadedOperatorKind::OO_Less ||
@@ -7143,7 +7144,7 @@ void Sema::CodeCompleteAfterFunctionEquals(Declarator &D) {
// first function declaration.
Results.AddResult("delete");
Results.ExitScope();
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
@@ -7244,19 +7245,19 @@ static void AddObjCTopLevelResults(ResultBuilder &Results, bool NeedAt) {
}
}
-void Sema::CodeCompleteObjCAtDirective(Scope *S) {
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+void SemaCodeCompletion::CodeCompleteObjCAtDirective(Scope *S) {
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_Other);
Results.EnterNewScope();
- if (isa<ObjCImplDecl>(CurContext))
+ if (isa<ObjCImplDecl>(SemaRef.CurContext))
AddObjCImplementationResults(getLangOpts(), Results, false);
- else if (CurContext->isObjCContainer())
+ else if (SemaRef.CurContext->isObjCContainer())
AddObjCInterfaceResults(getLangOpts(), Results, false);
else
AddObjCTopLevelResults(Results, false);
Results.ExitScope();
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
@@ -7381,37 +7382,37 @@ static void AddObjCVisibilityResults(const LangOptions &LangOpts,
Results.AddResult(Result(OBJC_AT_KEYWORD_NAME(NeedAt, "package")));
}
-void Sema::CodeCompleteObjCAtVisibility(Scope *S) {
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+void SemaCodeCompletion::CodeCompleteObjCAtVisibility(Scope *S) {
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_Other);
Results.EnterNewScope();
AddObjCVisibilityResults(getLangOpts(), Results, false);
Results.ExitScope();
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteObjCAtStatement(Scope *S) {
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+void SemaCodeCompletion::CodeCompleteObjCAtStatement(Scope *S) {
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_Other);
Results.EnterNewScope();
AddObjCStatementResults(Results, false);
AddObjCExpressionResults(Results, false);
Results.ExitScope();
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteObjCAtExpression(Scope *S) {
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+void SemaCodeCompletion::CodeCompleteObjCAtExpression(Scope *S) {
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_Other);
Results.EnterNewScope();
AddObjCExpressionResults(Results, false);
Results.ExitScope();
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
@@ -7448,13 +7449,13 @@ static bool ObjCPropertyFlagConflicts(unsigned Attributes, unsigned NewFlag) {
return false;
}
-void Sema::CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS) {
+void SemaCodeCompletion::CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS) {
if (!CodeCompleter)
return;
unsigned Attributes = ODS.getPropertyAttributes();
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_Other);
Results.EnterNewScope();
@@ -7517,7 +7518,7 @@ void Sema::CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS) {
Results.AddResult(CodeCompletionResult("null_resettable"));
}
Results.ExitScope();
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
@@ -7677,12 +7678,12 @@ static void AddObjCMethods(ObjCContainerDecl *Container,
IsRootClass);
}
-void Sema::CodeCompleteObjCPropertyGetter(Scope *S) {
+void SemaCodeCompletion::CodeCompleteObjCPropertyGetter(Scope *S) {
// Try to find the interface where getters might live.
- ObjCInterfaceDecl *Class = dyn_cast_or_null<ObjCInterfaceDecl>(CurContext);
+ ObjCInterfaceDecl *Class = dyn_cast_or_null<ObjCInterfaceDecl>(SemaRef.CurContext);
if (!Class) {
if (ObjCCategoryDecl *Category =
- dyn_cast_or_null<ObjCCategoryDecl>(CurContext))
+ dyn_cast_or_null<ObjCCategoryDecl>(SemaRef.CurContext))
Class = Category->getClassInterface();
if (!Class)
@@ -7690,26 +7691,26 @@ void Sema::CodeCompleteObjCPropertyGetter(Scope *S) {
}
// Find all of the potential getters.
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_Other);
Results.EnterNewScope();
VisitedSelectorSet Selectors;
- AddObjCMethods(Class, true, MK_ZeroArgSelector, std::nullopt, CurContext,
+ AddObjCMethods(Class, true, MK_ZeroArgSelector, std::nullopt, SemaRef.CurContext,
Selectors,
/*AllowSameLength=*/true, Results);
Results.ExitScope();
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteObjCPropertySetter(Scope *S) {
+void SemaCodeCompletion::CodeCompleteObjCPropertySetter(Scope *S) {
// Try to find the interface where setters might live.
- ObjCInterfaceDecl *Class = dyn_cast_or_null<ObjCInterfaceDecl>(CurContext);
+ ObjCInterfaceDecl *Class = dyn_cast_or_null<ObjCInterfaceDecl>(SemaRef.CurContext);
if (!Class) {
if (ObjCCategoryDecl *Category =
- dyn_cast_or_null<ObjCCategoryDecl>(CurContext))
+ dyn_cast_or_null<ObjCCategoryDecl>(SemaRef.CurContext))
Class = Category->getClassInterface();
if (!Class)
@@ -7717,24 +7718,24 @@ void Sema::CodeCompleteObjCPropertySetter(Scope *S) {
}
// Find all of the potential getters.
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_Other);
Results.EnterNewScope();
VisitedSelectorSet Selectors;
- AddObjCMethods(Class, true, MK_OneArgSelector, std::nullopt, CurContext,
+ AddObjCMethods(Class, true, MK_OneArgSelector, std::nullopt, SemaRef.CurContext,
Selectors,
/*AllowSameLength=*/true, Results);
Results.ExitScope();
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteObjCPassingType(Scope *S, ObjCDeclSpec &DS,
+void SemaCodeCompletion::CodeCompleteObjCPassingType(Scope *S, ObjCDeclSpec &DS,
bool IsParameter) {
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_Type);
Results.EnterNewScope();
@@ -7771,7 +7772,7 @@ void Sema::CodeCompleteObjCPassingType(Scope *S, ObjCDeclSpec &DS,
// an action, e.g.,
// IBAction)<#selector#>:(id)sender
if (DS.getObjCDeclQualifier() == 0 && !IsParameter &&
- PP.isMacroDefined("IBAction")) {
+ SemaRef.PP.isMacroDefined("IBAction")) {
CodeCompletionBuilder Builder(Results.getAllocator(),
Results.getCodeCompletionTUInfo(),
CCP_CodePattern, CXAvailability_Available);
@@ -7792,20 +7793,20 @@ void Sema::CodeCompleteObjCPassingType(Scope *S, ObjCDeclSpec &DS,
}
// Add various builtin type names and specifiers.
- AddOrdinaryNameResults(PCC_Type, S, *this, Results);
+ AddOrdinaryNameResults(PCC_Type, S, SemaRef, Results);
Results.ExitScope();
// Add the various type names
Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
- CodeCompletionDeclConsumer Consumer(Results, CurContext);
- LookupVisibleDecls(S, LookupOrdinaryName, Consumer,
+ CodeCompletionDeclConsumer Consumer(Results, SemaRef.CurContext);
+ SemaRef.LookupVisibleDecls(S, Sema::LookupOrdinaryName, Consumer,
CodeCompleter->includeGlobals(),
CodeCompleter->loadExternal());
if (CodeCompleter->includeMacros())
- AddMacroResults(PP, Results, CodeCompleter->loadExternal(), false);
+ AddMacroResults(SemaRef.PP, Results, CodeCompleter->loadExternal(), false);
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
@@ -7997,49 +7998,49 @@ AddSuperSendCompletion(Sema &S, bool NeedSuperKeyword,
return SuperMethod;
}
-void Sema::CodeCompleteObjCMessageReceiver(Scope *S) {
+void SemaCodeCompletion::CodeCompleteObjCMessageReceiver(Scope *S) {
typedef CodeCompletionResult Result;
ResultBuilder Results(
- *this, CodeCompleter->getAllocator(),
+ SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_ObjCMessageReceiver,
getLangOpts().CPlusPlus11
? &ResultBuilder::IsObjCMessageReceiverOrLambdaCapture
: &ResultBuilder::IsObjCMessageReceiver);
- CodeCompletionDeclConsumer Consumer(Results, CurContext);
+ CodeCompletionDeclConsumer Consumer(Results, SemaRef.CurContext);
Results.EnterNewScope();
- LookupVisibleDecls(S, LookupOrdinaryName, Consumer,
+ SemaRef.LookupVisibleDecls(S, Sema::LookupOrdinaryName, Consumer,
CodeCompleter->includeGlobals(),
CodeCompleter->loadExternal());
// If we are in an Objective-C method inside a class that has a superclass,
// add "super" as an option.
- if (ObjCMethodDecl *Method = getCurMethodDecl())
+ if (ObjCMethodDecl *Method = SemaRef.getCurMethodDecl())
if (ObjCInterfaceDecl *Iface = Method->getClassInterface())
if (Iface->getSuperClass()) {
Results.AddResult(Result("super"));
- AddSuperSendCompletion(*this, /*NeedSuperKeyword=*/true, std::nullopt,
+ AddSuperSendCompletion(SemaRef, /*NeedSuperKeyword=*/true, std::nullopt,
Results);
}
if (getLangOpts().CPlusPlus11)
- addThisCompletion(*this, Results);
+ addThisCompletion(SemaRef, Results);
Results.ExitScope();
if (CodeCompleter->includeMacros())
- AddMacroResults(PP, Results, CodeCompleter->loadExternal(), false);
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ AddMacroResults(SemaRef.PP, Results, CodeCompleter->loadExternal(), false);
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteObjCSuperMessage(
+void SemaCodeCompletion::CodeCompleteObjCSuperMessage(
Scope *S, SourceLocation SuperLoc,
ArrayRef<const IdentifierInfo *> SelIdents, bool AtArgumentExpression) {
ObjCInterfaceDecl *CDecl = nullptr;
- if (ObjCMethodDecl *CurMethod = getCurMethodDecl()) {
+ if (ObjCMethodDecl *CurMethod = SemaRef.getCurMethodDecl()) {
// Figure out which interface we're in.
CDecl = CurMethod->getClassInterface();
if (!CDecl)
@@ -8062,13 +8063,13 @@ void Sema::CodeCompleteObjCSuperMessage(
} else {
// "super" may be the name of a type or variable. Figure out which
// it is.
- const IdentifierInfo *Super = getSuperIdentifier();
- NamedDecl *ND = LookupSingleName(S, Super, SuperLoc, LookupOrdinaryName);
+ const IdentifierInfo *Super = SemaRef.getSuperIdentifier();
+ NamedDecl *ND = SemaRef.LookupSingleName(S, Super, SuperLoc, Sema::LookupOrdinaryName);
if ((CDecl = dyn_cast_or_null<ObjCInterfaceDecl>(ND))) {
// "super" names an interface. Use it.
} else if (TypeDecl *TD = dyn_cast_or_null<TypeDecl>(ND)) {
if (const ObjCObjectType *Iface =
- Context.getTypeDeclType(TD)->getAs<ObjCObjectType>())
+ getASTContext().getTypeDeclType(TD)->getAs<ObjCObjectType>())
CDecl = Iface->getInterface();
} else if (ND && isa<UnresolvedUsingTypenameDecl>(ND)) {
// "super" names an unresolved type; we can't be more specific.
@@ -8078,7 +8079,7 @@ void Sema::CodeCompleteObjCSuperMessage(
SourceLocation TemplateKWLoc;
UnqualifiedId id;
id.setIdentifier(Super, SuperLoc);
- ExprResult SuperExpr = ActOnIdExpression(S, SS, TemplateKWLoc, id,
+ ExprResult SuperExpr = SemaRef.ActOnIdExpression(S, SS, TemplateKWLoc, id,
/*HasTrailingLParen=*/false,
/*IsAddressOfOperand=*/false);
return CodeCompleteObjCInstanceMessage(S, (Expr *)SuperExpr.get(),
@@ -8090,7 +8091,7 @@ void Sema::CodeCompleteObjCSuperMessage(
ParsedType Receiver;
if (CDecl)
- Receiver = ParsedType::make(Context.getObjCInterfaceType(CDecl));
+ Receiver = ParsedType::make(getASTContext().getObjCInterfaceType(CDecl));
return CodeCompleteObjCClassMessage(S, Receiver, SelIdents,
AtArgumentExpression,
/*IsSuper=*/true);
@@ -8206,19 +8207,19 @@ AddClassMessageCompletions(Sema &SemaRef, Scope *S, ParsedType Receiver,
Results.ExitScope();
}
-void Sema::CodeCompleteObjCClassMessage(
+void SemaCodeCompletion::CodeCompleteObjCClassMessage(
Scope *S, ParsedType Receiver, ArrayRef<const IdentifierInfo *> SelIdents,
bool AtArgumentExpression, bool IsSuper) {
- QualType T = this->GetTypeFromParser(Receiver);
+ QualType T = SemaRef.GetTypeFromParser(Receiver);
ResultBuilder Results(
- *this, CodeCompleter->getAllocator(),
+ SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext(CodeCompletionContext::CCC_ObjCClassMessage, T,
SelIdents));
- AddClassMessageCompletions(*this, S, Receiver, SelIdents,
+ AddClassMessageCompletions(SemaRef, S, Receiver, SelIdents,
AtArgumentExpression, IsSuper, Results);
// If we're actually at the argument expression (rather than prior to the
@@ -8236,21 +8237,22 @@ void Sema::CodeCompleteObjCClassMessage(
return;
}
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteObjCInstanceMessage(
+void SemaCodeCompletion::CodeCompleteObjCInstanceMessage(
Scope *S, Expr *Receiver, ArrayRef<const IdentifierInfo *> SelIdents,
bool AtArgumentExpression, ObjCInterfaceDecl *Super) {
typedef CodeCompletionResult Result;
+ ASTContext &Context = getASTContext();
Expr *RecExpr = static_cast<Expr *>(Receiver);
// If necessary, apply function/array conversion to the receiver.
// C99 6.7.5.3p[7,8].
if (RecExpr) {
- ExprResult Conv = DefaultFunctionArrayLvalueConversion(RecExpr);
+ ExprResult Conv = SemaRef.DefaultFunctionArrayLvalueConversion(RecExpr);
if (Conv.isInvalid()) // conversion failed. bail.
return;
RecExpr = Conv.get();
@@ -8275,7 +8277,7 @@ void Sema::CodeCompleteObjCInstanceMessage(
Context.getObjCObjectPointerType(Context.getObjCInterfaceType(IFace));
}
} else if (RecExpr && getLangOpts().CPlusPlus) {
- ExprResult Conv = PerformContextuallyConvertToObjCPointer(RecExpr);
+ ExprResult Conv = SemaRef.PerformContextuallyConvertToObjCPointer(RecExpr);
if (Conv.isUsable()) {
RecExpr = Conv.get();
ReceiverType = RecExpr->getType();
@@ -8284,7 +8286,7 @@ void Sema::CodeCompleteObjCInstanceMessage(
// Build the set of methods we can see.
ResultBuilder Results(
- *this, CodeCompleter->getAllocator(),
+ SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext(CodeCompletionContext::CCC_ObjCInstanceMessage,
ReceiverType, SelIdents));
@@ -8295,13 +8297,13 @@ void Sema::CodeCompleteObjCInstanceMessage(
// completion.
if (Super) {
if (ObjCMethodDecl *SuperMethod =
- AddSuperSendCompletion(*this, false, SelIdents, Results))
+ AddSuperSendCompletion(SemaRef, false, SelIdents, Results))
Results.Ignore(SuperMethod);
}
// If we're inside an Objective-C method definition, prefer its selector to
// others.
- if (ObjCMethodDecl *CurMethod = getCurMethodDecl())
+ if (ObjCMethodDecl *CurMethod = SemaRef.getCurMethodDecl())
Results.setPreferredSelector(CurMethod->getSelector());
// Keep track of the selectors we've already added.
@@ -8312,9 +8314,9 @@ void Sema::CodeCompleteObjCInstanceMessage(
// class method.
if (ReceiverType->isObjCClassType() ||
ReceiverType->isObjCQualifiedClassType()) {
- if (ObjCMethodDecl *CurMethod = getCurMethodDecl()) {
+ if (ObjCMethodDecl *CurMethod = SemaRef.getCurMethodDecl()) {
if (ObjCInterfaceDecl *ClassDecl = CurMethod->getClassInterface())
- AddObjCMethods(ClassDecl, false, MK_Any, SelIdents, CurContext,
+ AddObjCMethods(ClassDecl, false, MK_Any, SelIdents, SemaRef.CurContext,
Selectors, AtArgumentExpression, Results);
}
}
@@ -8323,7 +8325,7 @@ void Sema::CodeCompleteObjCInstanceMessage(
ReceiverType->getAsObjCQualifiedIdType()) {
// Search protocols for instance methods.
for (auto *I : QualID->quals())
- AddObjCMethods(I, true, MK_Any, SelIdents, CurContext, Selectors,
+ AddObjCMethods(I, true, MK_Any, SelIdents, SemaRef.CurContext, Selectors,
AtArgumentExpression, Results);
}
// Handle messages to a pointer to interface type.
@@ -8331,11 +8333,11 @@ void Sema::CodeCompleteObjCInstanceMessage(
ReceiverType->getAsObjCInterfacePointerType()) {
// Search the class, its superclasses, etc., for instance methods.
AddObjCMethods(IFacePtr->getInterfaceDecl(), true, MK_Any, SelIdents,
- CurContext, Selectors, AtArgumentExpression, Results);
+ SemaRef.CurContext, Selectors, AtArgumentExpression, Results);
// Search protocols for instance methods.
for (auto *I : IFacePtr->quals())
- AddObjCMethods(I, true, MK_Any, SelIdents, CurContext, Selectors,
+ AddObjCMethods(I, true, MK_Any, SelIdents, SemaRef.CurContext, Selectors,
AtArgumentExpression, Results);
}
// Handle messages to "id".
@@ -8345,19 +8347,19 @@ void Sema::CodeCompleteObjCInstanceMessage(
// If we have an external source, load the entire class method
// pool from the AST file.
- if (ExternalSource) {
- for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors();
+ if (SemaRef.ExternalSource) {
+ for (uint32_t I = 0, N = SemaRef.ExternalSource->GetNumExternalSelectors();
I != N; ++I) {
- Selector Sel = ExternalSource->GetExternalSelector(I);
- if (Sel.isNull() || ObjC().MethodPool.count(Sel))
+ Selector Sel = SemaRef.ExternalSource->GetExternalSelector(I);
+ if (Sel.isNull() || SemaRef.ObjC().MethodPool.count(Sel))
continue;
- ObjC().ReadMethodPool(Sel);
+ SemaRef.ObjC().ReadMethodPool(Sel);
}
}
- for (SemaObjC::GlobalMethodPool::iterator M = ObjC().MethodPool.begin(),
- MEnd = ObjC().MethodPool.end();
+ for (SemaObjC::GlobalMethodPool::iterator M = SemaRef.ObjC().MethodPool.begin(),
+ MEnd = SemaRef.ObjC().MethodPool.end();
M != MEnd; ++M) {
for (ObjCMethodList *MethList = &M->second.first;
MethList && MethList->getMethod(); MethList = MethList->getNext()) {
@@ -8371,7 +8373,7 @@ void Sema::CodeCompleteObjCInstanceMessage(
Results.getBasePriority(MethList->getMethod()), nullptr);
R.StartParameter = SelIdents.size();
R.AllParametersAreInformative = false;
- Results.MaybeAddResult(R, CurContext);
+ Results.MaybeAddResult(R, SemaRef.CurContext);
}
}
}
@@ -8392,11 +8394,11 @@ void Sema::CodeCompleteObjCInstanceMessage(
return;
}
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteObjCForCollection(Scope *S,
+void SemaCodeCompletion::CodeCompleteObjCForCollection(Scope *S,
DeclGroupPtrTy IterationVar) {
CodeCompleteExpressionData Data;
Data.ObjCCollection = true;
@@ -8412,27 +8414,27 @@ void Sema::CodeCompleteObjCForCollection(Scope *S,
CodeCompleteExpression(S, Data);
}
-void Sema::CodeCompleteObjCSelector(
+void SemaCodeCompletion::CodeCompleteObjCSelector(
Scope *S, ArrayRef<const IdentifierInfo *> SelIdents) {
// If we have an external source, load the entire class method
// pool from the AST file.
- if (ExternalSource) {
- for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors(); I != N;
+ if (SemaRef.ExternalSource) {
+ for (uint32_t I = 0, N = SemaRef.ExternalSource->GetNumExternalSelectors(); I != N;
++I) {
- Selector Sel = ExternalSource->GetExternalSelector(I);
- if (Sel.isNull() || ObjC().MethodPool.count(Sel))
+ Selector Sel = SemaRef.ExternalSource->GetExternalSelector(I);
+ if (Sel.isNull() || SemaRef.ObjC().MethodPool.count(Sel))
continue;
- ObjC().ReadMethodPool(Sel);
+ SemaRef.ObjC().ReadMethodPool(Sel);
}
}
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_SelectorName);
Results.EnterNewScope();
- for (SemaObjC::GlobalMethodPool::iterator M = ObjC().MethodPool.begin(),
- MEnd = ObjC().MethodPool.end();
+ for (SemaObjC::GlobalMethodPool::iterator M = SemaRef.ObjC().MethodPool.begin(),
+ MEnd = SemaRef.ObjC().MethodPool.end();
M != MEnd; ++M) {
Selector Sel = M->first;
@@ -8466,7 +8468,7 @@ void Sema::CodeCompleteObjCSelector(
}
Results.ExitScope();
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
@@ -8487,9 +8489,9 @@ static void AddProtocolResults(DeclContext *Ctx, DeclContext *CurContext,
}
}
-void Sema::CodeCompleteObjCProtocolReferences(
+void SemaCodeCompletion::CodeCompleteObjCProtocolReferences(
ArrayRef<IdentifierLocPair> Protocols) {
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_ObjCProtocolName);
@@ -8501,22 +8503,22 @@ void Sema::CodeCompleteObjCProtocolReferences(
// FIXME: This doesn't work when caching code-completion results.
for (const IdentifierLocPair &Pair : Protocols)
if (ObjCProtocolDecl *Protocol =
- ObjC().LookupProtocol(Pair.first, Pair.second))
+ SemaRef.ObjC().LookupProtocol(Pair.first, Pair.second))
Results.Ignore(Protocol);
// Add all protocols.
- AddProtocolResults(Context.getTranslationUnitDecl(), CurContext, false,
+ AddProtocolResults(getASTContext().getTranslationUnitDecl(), SemaRef.CurContext, false,
Results);
Results.ExitScope();
}
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteObjCProtocolDecl(Scope *) {
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+void SemaCodeCompletion::CodeCompleteObjCProtocolDecl(Scope *) {
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_ObjCProtocolName);
@@ -8524,13 +8526,13 @@ void Sema::CodeCompleteObjCProtocolDecl(Scope *) {
Results.EnterNewScope();
// Add all protocols.
- AddProtocolResults(Context.getTranslationUnitDecl(), CurContext, true,
+ AddProtocolResults(getASTContext().getTranslationUnitDecl(), SemaRef.CurContext, true,
Results);
Results.ExitScope();
}
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
@@ -8553,91 +8555,91 @@ static void AddInterfaceResults(DeclContext *Ctx, DeclContext *CurContext,
}
}
-void Sema::CodeCompleteObjCInterfaceDecl(Scope *S) {
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+void SemaCodeCompletion::CodeCompleteObjCInterfaceDecl(Scope *S) {
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_ObjCInterfaceName);
Results.EnterNewScope();
if (CodeCompleter->includeGlobals()) {
// Add all classes.
- AddInterfaceResults(Context.getTranslationUnitDecl(), CurContext, false,
+ AddInterfaceResults(getASTContext().getTranslationUnitDecl(), SemaRef.CurContext, false,
false, Results);
}
Results.ExitScope();
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteObjCClassForwardDecl(Scope *S) {
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+void SemaCodeCompletion::CodeCompleteObjCClassForwardDecl(Scope *S) {
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_ObjCClassForwardDecl);
Results.EnterNewScope();
if (CodeCompleter->includeGlobals()) {
// Add all classes.
- AddInterfaceResults(Context.getTranslationUnitDecl(), CurContext, false,
+ AddInterfaceResults(getASTContext().getTranslationUnitDecl(), SemaRef.CurContext, false,
false, Results);
}
Results.ExitScope();
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteObjCSuperclass(Scope *S, IdentifierInfo *ClassName,
+void SemaCodeCompletion::CodeCompleteObjCSuperclass(Scope *S, IdentifierInfo *ClassName,
SourceLocation ClassNameLoc) {
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_ObjCInterfaceName);
Results.EnterNewScope();
// Make sure that we ignore the class we're currently defining.
NamedDecl *CurClass =
- LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
+ SemaRef.LookupSingleName(SemaRef.TUScope, ClassName, ClassNameLoc, Sema::LookupOrdinaryName);
if (CurClass && isa<ObjCInterfaceDecl>(CurClass))
Results.Ignore(CurClass);
if (CodeCompleter->includeGlobals()) {
// Add all classes.
- AddInterfaceResults(Context.getTranslationUnitDecl(), CurContext, false,
+ AddInterfaceResults(getASTContext().getTranslationUnitDecl(), SemaRef.CurContext, false,
false, Results);
}
Results.ExitScope();
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteObjCImplementationDecl(Scope *S) {
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+void SemaCodeCompletion::CodeCompleteObjCImplementationDecl(Scope *S) {
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_ObjCImplementation);
Results.EnterNewScope();
if (CodeCompleter->includeGlobals()) {
// Add all unimplemented classes.
- AddInterfaceResults(Context.getTranslationUnitDecl(), CurContext, false,
+ AddInterfaceResults(getASTContext().getTranslationUnitDecl(), SemaRef.CurContext, false,
true, Results);
}
Results.ExitScope();
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteObjCInterfaceCategory(Scope *S,
+void SemaCodeCompletion::CodeCompleteObjCInterfaceCategory(Scope *S,
IdentifierInfo *ClassName,
SourceLocation ClassNameLoc) {
typedef CodeCompletionResult Result;
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_ObjCCategoryName);
@@ -8645,7 +8647,7 @@ void Sema::CodeCompleteObjCInterfaceCategory(Scope *S,
// interface.
llvm::SmallPtrSet<IdentifierInfo *, 16> CategoryNames;
NamedDecl *CurClass =
- LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
+ SemaRef.LookupSingleName(SemaRef.TUScope, ClassName, ClassNameLoc, Sema::LookupOrdinaryName);
if (ObjCInterfaceDecl *Class =
dyn_cast_or_null<ObjCInterfaceDecl>(CurClass)) {
for (const auto *Cat : Class->visible_categories())
@@ -8654,20 +8656,20 @@ void Sema::CodeCompleteObjCInterfaceCategory(Scope *S,
// Add all of the categories we know about.
Results.EnterNewScope();
- TranslationUnitDecl *TU = Context.getTranslationUnitDecl();
+ TranslationUnitDecl *TU = getASTContext().getTranslationUnitDecl();
for (const auto *D : TU->decls())
if (const auto *Category = dyn_cast<ObjCCategoryDecl>(D))
if (CategoryNames.insert(Category->getIdentifier()).second)
Results.AddResult(
Result(Category, Results.getBasePriority(Category), nullptr),
- CurContext, nullptr, false);
+ SemaRef.CurContext, nullptr, false);
Results.ExitScope();
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteObjCImplementationCategory(Scope *S,
+void SemaCodeCompletion::CodeCompleteObjCImplementationCategory(Scope *S,
IdentifierInfo *ClassName,
SourceLocation ClassNameLoc) {
typedef CodeCompletionResult Result;
@@ -8676,12 +8678,12 @@ void Sema::CodeCompleteObjCImplementationCategory(Scope *S,
// program itself is ill-formed. However, we'll try to be helpful still by
// providing the list of all of the categories we know about.
NamedDecl *CurClass =
- LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
+ SemaRef.LookupSingleName(SemaRef.TUScope, ClassName, ClassNameLoc, Sema::LookupOrdinaryName);
ObjCInterfaceDecl *Class = dyn_cast_or_null<ObjCInterfaceDecl>(CurClass);
if (!Class)
return CodeCompleteObjCInterfaceCategory(S, ClassName, ClassNameLoc);
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_ObjCCategoryName);
@@ -8696,7 +8698,7 @@ void Sema::CodeCompleteObjCImplementationCategory(Scope *S,
if ((!IgnoreImplemented || !Cat->getImplementation()) &&
CategoryNames.insert(Cat->getIdentifier()).second)
Results.AddResult(Result(Cat, Results.getBasePriority(Cat), nullptr),
- CurContext, nullptr, false);
+ SemaRef.CurContext, nullptr, false);
}
Class = Class->getSuperClass();
@@ -8704,18 +8706,18 @@ void Sema::CodeCompleteObjCImplementationCategory(Scope *S,
}
Results.ExitScope();
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteObjCPropertyDefinition(Scope *S) {
+void SemaCodeCompletion::CodeCompleteObjCPropertyDefinition(Scope *S) {
CodeCompletionContext CCContext(CodeCompletionContext::CCC_Other);
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(), CCContext);
// Figure out where this @synthesize lives.
ObjCContainerDecl *Container =
- dyn_cast_or_null<ObjCContainerDecl>(CurContext);
+ dyn_cast_or_null<ObjCContainerDecl>(SemaRef.CurContext);
if (!Container || (!isa<ObjCImplementationDecl>(Container) &&
!isa<ObjCCategoryImplDecl>(Container)))
return;
@@ -8732,29 +8734,29 @@ void Sema::CodeCompleteObjCPropertyDefinition(Scope *S) {
if (ObjCImplementationDecl *ClassImpl =
dyn_cast<ObjCImplementationDecl>(Container))
AddObjCProperties(CCContext, ClassImpl->getClassInterface(), false,
- /*AllowNullaryMethods=*/false, CurContext,
+ /*AllowNullaryMethods=*/false, SemaRef.CurContext,
AddedProperties, Results);
else
AddObjCProperties(CCContext,
cast<ObjCCategoryImplDecl>(Container)->getCategoryDecl(),
- false, /*AllowNullaryMethods=*/false, CurContext,
+ false, /*AllowNullaryMethods=*/false, SemaRef.CurContext,
AddedProperties, Results);
Results.ExitScope();
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteObjCPropertySynthesizeIvar(
+void SemaCodeCompletion::CodeCompleteObjCPropertySynthesizeIvar(
Scope *S, IdentifierInfo *PropertyName) {
typedef CodeCompletionResult Result;
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_Other);
// Figure out where this @synthesize lives.
ObjCContainerDecl *Container =
- dyn_cast_or_null<ObjCContainerDecl>(CurContext);
+ dyn_cast_or_null<ObjCContainerDecl>(SemaRef.CurContext);
if (!Container || (!isa<ObjCImplementationDecl>(Container) &&
!isa<ObjCCategoryImplDecl>(Container)))
return;
@@ -8770,7 +8772,7 @@ void Sema::CodeCompleteObjCPropertySynthesizeIvar(
->getClassInterface();
// Determine the type of the property we're synthesizing.
- QualType PropertyType = Context.getObjCIdType();
+ QualType PropertyType = getASTContext().getObjCIdType();
if (Class) {
if (ObjCPropertyDecl *Property = Class->FindPropertyDeclaration(
PropertyName, ObjCPropertyQueryKind::OBJC_PR_query_instance)) {
@@ -8794,7 +8796,7 @@ void Sema::CodeCompleteObjCPropertySynthesizeIvar(
for (ObjCIvarDecl *Ivar = Class->all_declared_ivar_begin(); Ivar;
Ivar = Ivar->getNextIvar()) {
Results.AddResult(Result(Ivar, Results.getBasePriority(Ivar), nullptr),
- CurContext, nullptr, false);
+ SemaRef.CurContext, nullptr, false);
// Determine whether we've seen an ivar with a name similar to the
// property.
@@ -8823,9 +8825,9 @@ void Sema::CodeCompleteObjCPropertySynthesizeIvar(
CodeCompletionBuilder Builder(Allocator, Results.getCodeCompletionTUInfo(),
Priority, CXAvailability_Available);
- PrintingPolicy Policy = getCompletionPrintingPolicy(*this);
+ PrintingPolicy Policy = getCompletionPrintingPolicy(SemaRef);
Builder.AddResultTypeChunk(
- GetCompletionTypeString(PropertyType, Context, Policy, Allocator));
+ GetCompletionTypeString(PropertyType, getASTContext(), Policy, Allocator));
Builder.AddTypedTextChunk(Allocator.CopyString(NameWithPrefix));
Results.AddResult(
Result(Builder.TakeString(), Priority, CXCursor_ObjCIvarDecl));
@@ -8833,7 +8835,7 @@ void Sema::CodeCompleteObjCPropertySynthesizeIvar(
Results.ExitScope();
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
@@ -9573,15 +9575,16 @@ static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property,
}
}
-void Sema::CodeCompleteObjCMethodDecl(Scope *S,
+void SemaCodeCompletion::CodeCompleteObjCMethodDecl(Scope *S,
std::optional<bool> IsInstanceMethod,
ParsedType ReturnTy) {
+ ASTContext &Context = getASTContext();
// Determine the return type of the method we're declaring, if
// provided.
- QualType ReturnType = GetTypeFromParser(ReturnTy);
+ QualType ReturnType = SemaRef.GetTypeFromParser(ReturnTy);
Decl *IDecl = nullptr;
- if (CurContext->isObjCContainer()) {
- ObjCContainerDecl *OCD = dyn_cast<ObjCContainerDecl>(CurContext);
+ if (SemaRef.CurContext->isObjCContainer()) {
+ ObjCContainerDecl *OCD = dyn_cast<ObjCContainerDecl>(SemaRef.CurContext);
IDecl = OCD;
}
// Determine where we should start searching for methods.
@@ -9605,7 +9608,7 @@ void Sema::CodeCompleteObjCMethodDecl(Scope *S,
}
if (!SearchDecl) {
- HandleCodeCompleteResults(this, CodeCompleter,
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
CodeCompletionContext::CCC_Other, nullptr, 0);
return;
}
@@ -9617,11 +9620,11 @@ void Sema::CodeCompleteObjCMethodDecl(Scope *S,
// Add declarations or definitions for each of the known methods.
typedef CodeCompletionResult Result;
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_Other);
Results.EnterNewScope();
- PrintingPolicy Policy = getCompletionPrintingPolicy(*this);
+ PrintingPolicy Policy = getCompletionPrintingPolicy(SemaRef);
for (KnownMethodsMap::iterator M = KnownMethods.begin(),
MEnd = KnownMethods.end();
M != MEnd; ++M) {
@@ -9746,38 +9749,38 @@ void Sema::CodeCompleteObjCMethodDecl(Scope *S,
Results.ExitScope();
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteObjCMethodDeclSelector(
+void SemaCodeCompletion::CodeCompleteObjCMethodDeclSelector(
Scope *S, bool IsInstanceMethod, bool AtParameterName, ParsedType ReturnTy,
ArrayRef<const IdentifierInfo *> SelIdents) {
// If we have an external source, load the entire class method
// pool from the AST file.
- if (ExternalSource) {
- for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors(); I != N;
+ if (SemaRef.ExternalSource) {
+ for (uint32_t I = 0, N = SemaRef.ExternalSource->GetNumExternalSelectors(); I != N;
++I) {
- Selector Sel = ExternalSource->GetExternalSelector(I);
- if (Sel.isNull() || ObjC().MethodPool.count(Sel))
+ Selector Sel = SemaRef.ExternalSource->GetExternalSelector(I);
+ if (Sel.isNull() || SemaRef.ObjC().MethodPool.count(Sel))
continue;
- ObjC().ReadMethodPool(Sel);
+ SemaRef.ObjC().ReadMethodPool(Sel);
}
}
// Build the set of methods we can see.
typedef CodeCompletionResult Result;
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_Other);
if (ReturnTy)
- Results.setPreferredType(GetTypeFromParser(ReturnTy).getNonReferenceType());
+ Results.setPreferredType(SemaRef.GetTypeFromParser(ReturnTy).getNonReferenceType());
Results.EnterNewScope();
- for (SemaObjC::GlobalMethodPool::iterator M = ObjC().MethodPool.begin(),
- MEnd = ObjC().MethodPool.end();
+ for (SemaObjC::GlobalMethodPool::iterator M = SemaRef.ObjC().MethodPool.begin(),
+ MEnd = SemaRef.ObjC().MethodPool.end();
M != MEnd; ++M) {
for (ObjCMethodList *MethList = IsInstanceMethod ? &M->second.first
: &M->second.second;
@@ -9809,7 +9812,7 @@ void Sema::CodeCompleteObjCMethodDeclSelector(
R.StartParameter = SelIdents.size();
R.AllParametersAreInformative = false;
R.DeclaringEntity = true;
- Results.MaybeAddResult(R, CurContext);
+ Results.MaybeAddResult(R, SemaRef.CurContext);
}
}
@@ -9817,7 +9820,7 @@ void Sema::CodeCompleteObjCMethodDeclSelector(
if (!AtParameterName && !SelIdents.empty() &&
SelIdents.front()->getName().starts_with("init")) {
- for (const auto &M : PP.macros()) {
+ for (const auto &M : SemaRef.PP.macros()) {
if (M.first->getName() != "NS_DESIGNATED_INITIALIZER")
continue;
Results.EnterNewScope();
@@ -9831,12 +9834,12 @@ void Sema::CodeCompleteObjCMethodDeclSelector(
}
}
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompletePreprocessorDirective(bool InConditional) {
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+void SemaCodeCompletion::CodeCompletePreprocessorDirective(bool InConditional) {
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_PreprocessorDirective);
Results.EnterNewScope();
@@ -10001,17 +10004,17 @@ void Sema::CodeCompletePreprocessorDirective(bool InConditional) {
// FIXME: we don't support #assert or #unassert, so don't suggest them.
Results.ExitScope();
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteInPreprocessorConditionalExclusion(Scope *S) {
- CodeCompleteOrdinaryName(S, S->getFnParent() ? Sema::PCC_RecoveryInFunction
- : Sema::PCC_Namespace);
+void SemaCodeCompletion::CodeCompleteInPreprocessorConditionalExclusion(Scope *S) {
+ CodeCompleteOrdinaryName(S, S->getFnParent() ? SemaCodeCompletion::PCC_RecoveryInFunction
+ : SemaCodeCompletion::PCC_Namespace);
}
-void Sema::CodeCompletePreprocessorMacroName(bool IsDefinition) {
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+void SemaCodeCompletion::CodeCompletePreprocessorMacroName(bool IsDefinition) {
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
IsDefinition ? CodeCompletionContext::CCC_MacroName
: CodeCompletionContext::CCC_MacroNameUse);
@@ -10020,8 +10023,8 @@ void Sema::CodeCompletePreprocessorMacroName(bool IsDefinition) {
CodeCompletionBuilder Builder(Results.getAllocator(),
Results.getCodeCompletionTUInfo());
Results.EnterNewScope();
- for (Preprocessor::macro_iterator M = PP.macro_begin(),
- MEnd = PP.macro_end();
+ for (Preprocessor::macro_iterator M = SemaRef.PP.macro_begin(),
+ MEnd = SemaRef.PP.macro_end();
M != MEnd; ++M) {
Builder.AddTypedTextChunk(
Builder.getAllocator().CopyString(M->first->getName()));
@@ -10033,17 +10036,17 @@ void Sema::CodeCompletePreprocessorMacroName(bool IsDefinition) {
// FIXME: Can we detect when the user just wrote an include guard above?
}
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompletePreprocessorExpression() {
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+void SemaCodeCompletion::CodeCompletePreprocessorExpression() {
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_PreprocessorExpression);
if (CodeCompleter->includeMacros())
- AddMacroResults(PP, Results, CodeCompleter->loadExternal(), true);
+ AddMacroResults(SemaRef.PP, Results, CodeCompleter->loadExternal(), true);
// defined (<macro>)
Results.EnterNewScope();
@@ -10057,11 +10060,11 @@ void Sema::CodeCompletePreprocessorExpression() {
Results.AddResult(Builder.TakeString());
Results.ExitScope();
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompletePreprocessorMacroArgument(Scope *S,
+void SemaCodeCompletion::CodeCompletePreprocessorMacroArgument(Scope *S,
IdentifierInfo *Macro,
MacroInfo *MacroInfo,
unsigned Argument) {
@@ -10075,7 +10078,7 @@ void Sema::CodeCompletePreprocessorMacroArgument(Scope *S,
// This handles completion inside an #include filename, e.g. #include <foo/ba
// We look for the directory "foo" under each directory on the include path,
// list its files, and reassemble the appropriate #include.
-void Sema::CodeCompleteIncludedFile(llvm::StringRef Dir, bool Angled) {
+void SemaCodeCompletion::CodeCompleteIncludedFile(llvm::StringRef Dir, bool Angled) {
// RelDir should use /, but unescaped \ is possible on windows!
// Our completions will normalize to / for simplicity, this case is rare.
std::string RelDir = llvm::sys::path::convert_to_slash(Dir);
@@ -10083,9 +10086,9 @@ void Sema::CodeCompleteIncludedFile(llvm::StringRef Dir, bool Angled) {
SmallString<128> NativeRelDir = StringRef(RelDir);
llvm::sys::path::native(NativeRelDir);
llvm::vfs::FileSystem &FS =
- getSourceManager().getFileManager().getVirtualFileSystem();
+ SemaRef.getSourceManager().getFileManager().getVirtualFileSystem();
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_IncludedFile);
llvm::DenseSet<StringRef> SeenResults; // To deduplicate results.
@@ -10197,11 +10200,11 @@ void Sema::CodeCompleteIncludedFile(llvm::StringRef Dir, bool Angled) {
// Finally with all our helpers, we can scan the include path.
// Do this in standard order so deduplication keeps the right file.
// (In case we decide to add more details to the results later).
- const auto &S = PP.getHeaderSearchInfo();
+ const auto &S = SemaRef.PP.getHeaderSearchInfo();
using llvm::make_range;
if (!Angled) {
// The current directory is on the include path for "quoted" includes.
- if (auto CurFile = PP.getCurrentFileLexer()->getFileEntry())
+ if (auto CurFile = SemaRef.PP.getCurrentFileLexer()->getFileEntry())
AddFilesFromIncludeDir(CurFile->getDir().getName(), false,
DirectoryLookup::LT_NormalDir);
for (const auto &D : make_range(S.quoted_dir_begin(), S.quoted_dir_end()))
@@ -10212,18 +10215,18 @@ void Sema::CodeCompleteIncludedFile(llvm::StringRef Dir, bool Angled) {
for (const auto &D : make_range(S.system_dir_begin(), S.system_dir_end()))
AddFilesFromDirLookup(D, true);
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::CodeCompleteNaturalLanguage() {
- HandleCodeCompleteResults(this, CodeCompleter,
+void SemaCodeCompletion::CodeCompleteNaturalLanguage() {
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
CodeCompletionContext::CCC_NaturalLanguage, nullptr,
0);
}
-void Sema::CodeCompleteAvailabilityPlatformName() {
- ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+void SemaCodeCompletion::CodeCompleteAvailabilityPlatformName() {
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_Other);
Results.EnterNewScope();
@@ -10234,28 +10237,30 @@ void Sema::CodeCompleteAvailabilityPlatformName() {
Twine(Platform) + "ApplicationExtension")));
}
Results.ExitScope();
- HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
Results.data(), Results.size());
}
-void Sema::GatherGlobalCodeCompletions(
+void SemaCodeCompletion::GatherGlobalCodeCompletions(
CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo,
SmallVectorImpl<CodeCompletionResult> &Results) {
- ResultBuilder Builder(*this, Allocator, CCTUInfo,
+ ResultBuilder Builder(SemaRef, Allocator, CCTUInfo,
CodeCompletionContext::CCC_Recovery);
if (!CodeCompleter || CodeCompleter->includeGlobals()) {
CodeCompletionDeclConsumer Consumer(Builder,
- Context.getTranslationUnitDecl());
- LookupVisibleDecls(Context.getTranslationUnitDecl(), LookupAnyName,
+ getASTContext().getTranslationUnitDecl());
+ SemaRef.LookupVisibleDecls(getASTContext().getTranslationUnitDecl(), Sema::LookupAnyName,
Consumer,
!CodeCompleter || CodeCompleter->loadExternal());
}
if (!CodeCompleter || CodeCompleter->includeMacros())
- AddMacroResults(PP, Builder,
+ AddMacroResults(SemaRef.PP, Builder,
!CodeCompleter || CodeCompleter->loadExternal(), true);
Results.clear();
Results.insert(Results.end(), Builder.data(),
Builder.data() + Builder.size());
}
+
+SemaCodeCompletion::SemaCodeCompletion(Sema &S, CodeCompleteConsumer *CompletionConsumer) : SemaBase(S), CodeCompleter(CompletionConsumer) {}
>From c91bbd8efc45b0975256bc692ddb5342e3e81a95 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov <serebrennikov.vladislav at gmail.com>
Date: Wed, 15 May 2024 22:56:03 +0300
Subject: [PATCH 2/2] Run clang-format
---
clang/include/clang/Parse/Parser.h | 3 +-
clang/lib/Frontend/ASTUnit.cpp | 4 +-
clang/lib/Parse/ParseDecl.cpp | 43 +-
clang/lib/Parse/ParseDeclCXX.cpp | 40 +-
clang/lib/Parse/ParseExpr.cpp | 20 +-
clang/lib/Parse/ParseExprCXX.cpp | 41 +-
clang/lib/Parse/ParseInit.cpp | 5 +-
clang/lib/Parse/ParseObjc.cpp | 121 ++---
clang/lib/Parse/ParseOpenMP.cpp | 10 +-
clang/lib/Parse/ParsePragma.cpp | 5 +-
clang/lib/Parse/ParseStmt.cpp | 19 +-
clang/lib/Parse/ParseTemplate.cpp | 4 +-
clang/lib/Parse/Parser.cpp | 24 +-
clang/lib/Sema/Sema.cpp | 5 +-
clang/lib/Sema/SemaCodeComplete.cpp | 673 ++++++++++++++++------------
15 files changed, 570 insertions(+), 447 deletions(-)
diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h
index 6c2105e400dca..cefeba90b2c92 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -2999,7 +2999,8 @@ class Parser : public CodeCompletionHandler {
IdentifierInfo *TryParseCXX11AttributeIdentifier(
SourceLocation &Loc,
- SemaCodeCompletion::AttributeCompletion Completion = SemaCodeCompletion::AttributeCompletion::None,
+ SemaCodeCompletion::AttributeCompletion Completion =
+ SemaCodeCompletion::AttributeCompletion::None,
const IdentifierInfo *EnclosingScope = nullptr);
void MaybeParseHLSLAnnotations(Declarator &D,
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 3d8d9a9d8b26e..8d24d5d422520 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -376,8 +376,8 @@ void ASTUnit::CacheCodeCompletionResults() {
SmallVector<Result, 8> Results;
CachedCompletionAllocator = std::make_shared<GlobalCodeCompletionAllocator>();
CodeCompletionTUInfo CCTUInfo(CachedCompletionAllocator);
- TheSema->CodeCompletion().GatherGlobalCodeCompletions(*CachedCompletionAllocator,
- CCTUInfo, Results);
+ TheSema->CodeCompletion().GatherGlobalCodeCompletions(
+ *CachedCompletionAllocator, CCTUInfo, Results);
// Translate global code completions into cached completions.
llvm::DenseMap<CanQualType, unsigned> CompletionTypes;
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index a23af05b9bed1..1dbdd22d3ed45 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -219,7 +219,8 @@ void Parser::ParseGNUAttributes(ParsedAttributes &Attrs,
break;
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteAttribute(AttributeCommonInfo::Syntax::AS_GNU);
+ Actions.CodeCompletion().CodeCompleteAttribute(
+ AttributeCommonInfo::Syntax::AS_GNU);
break;
}
IdentifierInfo *AttrName = Tok.getIdentifierInfo();
@@ -896,7 +897,8 @@ void Parser::ParseMicrosoftDeclSpecs(ParsedAttributes &Attrs) {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteAttribute(AttributeCommonInfo::AS_Declspec);
+ Actions.CodeCompletion().CodeCompleteAttribute(
+ AttributeCommonInfo::AS_Declspec);
return;
}
@@ -2723,7 +2725,8 @@ Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes(
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteInitializer(getCurScope(), ThisDecl);
+ Actions.CodeCompletion().CodeCompleteInitializer(getCurScope(),
+ ThisDecl);
Actions.FinalizeDeclaration(ThisDecl);
return nullptr;
}
@@ -2768,10 +2771,11 @@ Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes(
auto ThisVarDecl = dyn_cast_or_null<VarDecl>(ThisDecl);
auto RunSignatureHelp = [&]() {
- QualType PreferredType = Actions.CodeCompletion().ProduceConstructorSignatureHelp(
- ThisVarDecl->getType()->getCanonicalTypeInternal(),
- ThisDecl->getLocation(), Exprs, T.getOpenLocation(),
- /*Braced=*/false);
+ QualType PreferredType =
+ Actions.CodeCompletion().ProduceConstructorSignatureHelp(
+ ThisVarDecl->getType()->getCanonicalTypeInternal(),
+ ThisDecl->getLocation(), Exprs, T.getOpenLocation(),
+ /*Braced=*/false);
CalledSignatureHelp = true;
return PreferredType;
};
@@ -3635,7 +3639,8 @@ void Parser::ParseDeclarationSpecifiers(
continue;
case tok::code_completion: {
- SemaCodeCompletion::ParserCompletionContext CCC = SemaCodeCompletion::PCC_Namespace;
+ SemaCodeCompletion::ParserCompletionContext CCC =
+ SemaCodeCompletion::PCC_Namespace;
if (DS.hasTypeSpecifier()) {
bool AllowNonIdentifiers
= (getCurScope()->getFlags() & (Scope::ControlScope |
@@ -3648,16 +3653,16 @@ void Parser::ParseDeclarationSpecifiers(
(DSContext == DeclSpecContext::DSC_class && DS.isFriendSpecified());
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteDeclSpec(getCurScope(), DS,
- AllowNonIdentifiers,
- AllowNestedNameSpecifiers);
+ Actions.CodeCompletion().CodeCompleteDeclSpec(
+ getCurScope(), DS, AllowNonIdentifiers, AllowNestedNameSpecifiers);
return;
}
// Class context can appear inside a function/block, so prioritise that.
if (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate)
- CCC = DSContext == DeclSpecContext::DSC_class ? SemaCodeCompletion::PCC_MemberTemplate
- : SemaCodeCompletion::PCC_Template;
+ CCC = DSContext == DeclSpecContext::DSC_class
+ ? SemaCodeCompletion::PCC_MemberTemplate
+ : SemaCodeCompletion::PCC_Template;
else if (DSContext == DeclSpecContext::DSC_class)
CCC = SemaCodeCompletion::PCC_Class;
else if (getCurScope()->getFnParent() || getCurScope()->getBlockParent())
@@ -7403,12 +7408,12 @@ void Parser::ParseFunctionDeclarator(Declarator &D,
// with the pure-specifier in the same way.
// Parse cv-qualifier-seq[opt].
- ParseTypeQualifierListOpt(DS, AR_NoAttributesParsed,
- /*AtomicAllowed*/ false,
- /*IdentifierRequired=*/false,
- llvm::function_ref<void()>([&]() {
- Actions.CodeCompletion().CodeCompleteFunctionQualifiers(DS, D);
- }));
+ ParseTypeQualifierListOpt(
+ DS, AR_NoAttributesParsed,
+ /*AtomicAllowed*/ false,
+ /*IdentifierRequired=*/false, llvm::function_ref<void()>([&]() {
+ Actions.CodeCompletion().CodeCompleteFunctionQualifiers(DS, D);
+ }));
if (!DS.getSourceRange().getEnd().isInvalid()) {
EndLoc = DS.getSourceRange().getEnd();
}
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index de40a27fdd1b7..2cf4d1560f682 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -3086,7 +3086,8 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
DefinitionKind = FunctionDefinitionKind::Deleted;
else if (KW.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteAfterFunctionEquals(DeclaratorInfo);
+ Actions.CodeCompletion().CodeCompleteAfterFunctionEquals(
+ DeclaratorInfo);
return nullptr;
}
}
@@ -3895,8 +3896,8 @@ void Parser::ParseConstructorInitializer(Decl *ConstructorDecl) {
do {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteConstructorInitializer(ConstructorDecl,
- MemInitializers);
+ Actions.CodeCompletion().CodeCompleteConstructorInitializer(
+ ConstructorDecl, MemInitializers);
return;
}
@@ -4016,9 +4017,10 @@ MemInitResult Parser::ParseMemInitializer(Decl *ConstructorDecl) {
auto RunSignatureHelp = [&] {
if (TemplateTypeTy.isInvalid())
return QualType();
- QualType PreferredType = Actions.CodeCompletion().ProduceCtorInitMemberSignatureHelp(
- ConstructorDecl, SS, TemplateTypeTy.get(), ArgExprs, II,
- T.getOpenLocation(), /*Braced=*/false);
+ QualType PreferredType =
+ Actions.CodeCompletion().ProduceCtorInitMemberSignatureHelp(
+ ConstructorDecl, SS, TemplateTypeTy.get(), ArgExprs, II,
+ T.getOpenLocation(), /*Braced=*/false);
CalledSignatureHelp = true;
return PreferredType;
};
@@ -4403,10 +4405,9 @@ void Parser::PopParsingClass(Sema::ParsingClassState state) {
/// If a keyword or an alternative token that satisfies the syntactic
/// requirements of an identifier is contained in an attribute-token,
/// it is considered an identifier.
-IdentifierInfo *
-Parser::TryParseCXX11AttributeIdentifier(SourceLocation &Loc,
- SemaCodeCompletion::AttributeCompletion Completion,
- const IdentifierInfo *Scope) {
+IdentifierInfo *Parser::TryParseCXX11AttributeIdentifier(
+ SourceLocation &Loc, SemaCodeCompletion::AttributeCompletion Completion,
+ const IdentifierInfo *Scope) {
switch (Tok.getKind()) {
default:
// Identifiers and keywords have identifier info attached.
@@ -4420,9 +4421,9 @@ Parser::TryParseCXX11AttributeIdentifier(SourceLocation &Loc,
case tok::code_completion:
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteAttribute(getLangOpts().CPlusPlus ? ParsedAttr::AS_CXX11
- : ParsedAttr::AS_C23,
- Completion, Scope);
+ Actions.CodeCompletion().CodeCompleteAttribute(
+ getLangOpts().CPlusPlus ? ParsedAttr::AS_CXX11 : ParsedAttr::AS_C23,
+ Completion, Scope);
return nullptr;
case tok::numeric_constant: {
@@ -4834,7 +4835,8 @@ void Parser::ParseCXX11AttributeSpecifierInternal(ParsedAttributes &Attrs,
IdentifierInfo *ScopeName = nullptr, *AttrName = nullptr;
AttrName = TryParseCXX11AttributeIdentifier(
- AttrLoc, SemaCodeCompletion::AttributeCompletion::Attribute, CommonScopeName);
+ AttrLoc, SemaCodeCompletion::AttributeCompletion::Attribute,
+ CommonScopeName);
if (!AttrName)
// Break out to the "expected ']'" diagnostic.
break;
@@ -4845,7 +4847,8 @@ void Parser::ParseCXX11AttributeSpecifierInternal(ParsedAttributes &Attrs,
ScopeLoc = AttrLoc;
AttrName = TryParseCXX11AttributeIdentifier(
- AttrLoc, SemaCodeCompletion::AttributeCompletion::Attribute, ScopeName);
+ AttrLoc, SemaCodeCompletion::AttributeCompletion::Attribute,
+ ScopeName);
if (!AttrName) {
Diag(Tok.getLocation(), diag::err_expected) << tok::identifier;
SkipUntil(tok::r_square, tok::comma, StopAtSemi | StopBeforeMatch);
@@ -5069,9 +5072,10 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes &Attrs) {
StopAtSemi | StopBeforeMatch | StopAtCodeCompletion);
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteAttribute(AttributeCommonInfo::AS_Microsoft,
- SemaCodeCompletion::AttributeCompletion::Attribute,
- /*Scope=*/nullptr);
+ Actions.CodeCompletion().CodeCompleteAttribute(
+ AttributeCommonInfo::AS_Microsoft,
+ SemaCodeCompletion::AttributeCompletion::Attribute,
+ /*Scope=*/nullptr);
break;
}
if (Tok.isNot(tok::identifier)) // ']', but also eof
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 03404404d575f..eb7447fa038e4 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -169,8 +169,8 @@ Parser::ParseExpressionWithLeadingExtension(SourceLocation ExtLoc) {
ExprResult Parser::ParseAssignmentExpression(TypeCastState isTypeCast) {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteExpression(getCurScope(),
- PreferredType.get(Tok.getLocation()));
+ Actions.CodeCompletion().CodeCompleteExpression(
+ getCurScope(), PreferredType.get(Tok.getLocation()));
return ExprError();
}
@@ -188,8 +188,8 @@ ExprResult Parser::ParseAssignmentExpression(TypeCastState isTypeCast) {
ExprResult Parser::ParseConditionalExpression() {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteExpression(getCurScope(),
- PreferredType.get(Tok.getLocation()));
+ Actions.CodeCompletion().CodeCompleteExpression(
+ getCurScope(), PreferredType.get(Tok.getLocation()));
return ExprError();
}
@@ -1812,8 +1812,8 @@ ExprResult Parser::ParseCastExpression(CastParseKind ParseKind,
break;
case tok::code_completion: {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteExpression(getCurScope(),
- PreferredType.get(Tok.getLocation()));
+ Actions.CodeCompletion().CodeCompleteExpression(
+ getCurScope(), PreferredType.get(Tok.getLocation()));
return ExprError();
}
#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case tok::kw___##Trait:
@@ -2155,8 +2155,9 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
ExprVector ArgExprs;
auto RunSignatureHelp = [&]() -> QualType {
- QualType PreferredType = Actions.CodeCompletion().ProduceCallSignatureHelp(
- LHS.get(), ArgExprs, PT.getOpenLocation());
+ QualType PreferredType =
+ Actions.CodeCompletion().ProduceCallSignatureHelp(
+ LHS.get(), ArgExprs, PT.getOpenLocation());
CalledSignatureHelp = true;
return PreferredType;
};
@@ -3679,7 +3680,8 @@ bool Parser::ParseSimpleExpressionList(SmallVectorImpl<Expr *> &Exprs) {
void Parser::ParseBlockId(SourceLocation CaretLoc) {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteOrdinaryName(getCurScope(), SemaCodeCompletion::PCC_Type);
+ Actions.CodeCompletion().CodeCompleteOrdinaryName(
+ getCurScope(), SemaCodeCompletion::PCC_Type);
return;
}
diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp
index af2ab3347ec16..e149b1a0fb5ef 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -271,9 +271,9 @@ bool Parser::ParseOptionalCXXScopeSpecifier(
cutOffParsing();
// Code completion for a nested-name-specifier, where the code
// completion token follows the '::'.
- Actions.CodeCompletion().CodeCompleteQualifiedId(getCurScope(), SS, EnteringContext,
- InUsingDeclaration, ObjectType.get(),
- SavedType.get(SS.getBeginLoc()));
+ Actions.CodeCompletion().CodeCompleteQualifiedId(
+ getCurScope(), SS, EnteringContext, InUsingDeclaration,
+ ObjectType.get(), SavedType.get(SS.getBeginLoc()));
// Include code completion token into the range of the scope otherwise
// when we try to annotate the scope tokens the dangling code completion
// token will cause assertion in
@@ -955,8 +955,9 @@ bool Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro,
if (Tok.is(tok::code_completion) &&
!(getLangOpts().ObjC && Tentative)) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteLambdaIntroducer(getCurScope(), Intro,
- /*AfterAmpersand=*/false);
+ Actions.CodeCompletion().CodeCompleteLambdaIntroducer(
+ getCurScope(), Intro,
+ /*AfterAmpersand=*/false);
break;
}
@@ -974,8 +975,9 @@ bool Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro,
if (getLangOpts().ObjC && Tentative && First)
Actions.CodeCompletion().CodeCompleteObjCMessageReceiver(getCurScope());
else
- Actions.CodeCompletion().CodeCompleteLambdaIntroducer(getCurScope(), Intro,
- /*AfterAmpersand=*/false);
+ Actions.CodeCompletion().CodeCompleteLambdaIntroducer(
+ getCurScope(), Intro,
+ /*AfterAmpersand=*/false);
break;
}
@@ -1021,8 +1023,9 @@ bool Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro,
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteLambdaIntroducer(getCurScope(), Intro,
- /*AfterAmpersand=*/true);
+ Actions.CodeCompletion().CodeCompleteLambdaIntroducer(
+ getCurScope(), Intro,
+ /*AfterAmpersand=*/true);
break;
}
}
@@ -2032,9 +2035,10 @@ Parser::ParseCXXTypeConstructExpression(const DeclSpec &DS) {
auto RunSignatureHelp = [&]() {
QualType PreferredType;
if (TypeRep)
- PreferredType = Actions.CodeCompletion().ProduceConstructorSignatureHelp(
- TypeRep.get()->getCanonicalTypeInternal(), DS.getEndLoc(), Exprs,
- T.getOpenLocation(), /*Braced=*/false);
+ PreferredType =
+ Actions.CodeCompletion().ProduceConstructorSignatureHelp(
+ TypeRep.get()->getCanonicalTypeInternal(), DS.getEndLoc(),
+ Exprs, T.getOpenLocation(), /*Braced=*/false);
CalledSignatureHelp = true;
return PreferredType;
};
@@ -2141,7 +2145,8 @@ Parser::ParseCXXCondition(StmtResult *InitStmt, SourceLocation Loc,
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteOrdinaryName(getCurScope(), SemaCodeCompletion::PCC_Condition);
+ Actions.CodeCompletion().CodeCompleteOrdinaryName(
+ getCurScope(), SemaCodeCompletion::PCC_Condition);
return Sema::ConditionError();
}
@@ -3351,10 +3356,12 @@ Parser::ParseCXXNewExpression(bool UseGlobal, SourceLocation Start) {
// the passing DeclaratorInfo is valid, e.g. running SignatureHelp on
// `new decltype(invalid) (^)`.
if (TypeRep)
- PreferredType = Actions.CodeCompletion().ProduceConstructorSignatureHelp(
- TypeRep.get()->getCanonicalTypeInternal(),
- DeclaratorInfo.getEndLoc(), ConstructorArgs, ConstructorLParen,
- /*Braced=*/false);
+ PreferredType =
+ Actions.CodeCompletion().ProduceConstructorSignatureHelp(
+ TypeRep.get()->getCanonicalTypeInternal(),
+ DeclaratorInfo.getEndLoc(), ConstructorArgs,
+ ConstructorLParen,
+ /*Braced=*/false);
CalledSignatureHelp = true;
return PreferredType;
};
diff --git a/clang/lib/Parse/ParseInit.cpp b/clang/lib/Parse/ParseInit.cpp
index b972a5a118b6a..432ddc74b1087 100644
--- a/clang/lib/Parse/ParseInit.cpp
+++ b/clang/lib/Parse/ParseInit.cpp
@@ -205,8 +205,9 @@ ExprResult Parser::ParseInitializerWithPotentialDesignator(
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteDesignator(DesignatorCompletion.PreferredBaseType,
- DesignatorCompletion.InitExprs, Desig);
+ Actions.CodeCompletion().CodeCompleteDesignator(
+ DesignatorCompletion.PreferredBaseType,
+ DesignatorCompletion.InitExprs, Desig);
return ExprError();
}
if (Tok.isNot(tok::identifier)) {
diff --git a/clang/lib/Parse/ParseObjc.cpp b/clang/lib/Parse/ParseObjc.cpp
index d511719476292..e3cb810e2d8c3 100644
--- a/clang/lib/Parse/ParseObjc.cpp
+++ b/clang/lib/Parse/ParseObjc.cpp
@@ -277,7 +277,8 @@ Decl *Parser::ParseObjCAtInterfaceDeclaration(SourceLocation AtLoc,
IdentifierInfo *categoryId = nullptr;
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteObjCInterfaceCategory(getCurScope(), nameId, nameLoc);
+ Actions.CodeCompletion().CodeCompleteObjCInterfaceCategory(
+ getCurScope(), nameId, nameLoc);
return nullptr;
}
@@ -332,7 +333,8 @@ Decl *Parser::ParseObjCAtInterfaceDeclaration(SourceLocation AtLoc,
// Code completion of superclass names.
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteObjCSuperclass(getCurScope(), nameId, nameLoc);
+ Actions.CodeCompletion().CodeCompleteObjCSuperclass(getCurScope(), nameId,
+ nameLoc);
return nullptr;
}
@@ -509,7 +511,8 @@ ObjCTypeParamList *Parser::parseObjCTypeParamListOrProtocolRefs(
// FIXME: If these aren't protocol references, we'll need different
// completions.
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteObjCProtocolReferences(protocolIdents);
+ Actions.CodeCompletion().CodeCompleteObjCProtocolReferences(
+ protocolIdents);
// FIXME: Better recovery here?.
return nullptr;
@@ -682,9 +685,10 @@ void Parser::ParseObjCInterfaceDeclList(tok::ObjCKeywordKind contextKey,
// Code completion within an Objective-C interface.
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteOrdinaryName(getCurScope(),
- CurParsedObjCImpl? SemaCodeCompletion::PCC_ObjCImplementation
- : SemaCodeCompletion::PCC_ObjCInterface);
+ Actions.CodeCompletion().CodeCompleteOrdinaryName(
+ getCurScope(), CurParsedObjCImpl
+ ? SemaCodeCompletion::PCC_ObjCImplementation
+ : SemaCodeCompletion::PCC_ObjCInterface);
return;
}
@@ -944,9 +948,11 @@ void Parser::ParseObjCPropertyAttribute(ObjCDeclSpec &DS) {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
if (IsSetter)
- Actions.CodeCompletion().CodeCompleteObjCPropertySetter(getCurScope());
+ Actions.CodeCompletion().CodeCompleteObjCPropertySetter(
+ getCurScope());
else
- Actions.CodeCompletion().CodeCompleteObjCPropertyGetter(getCurScope());
+ Actions.CodeCompletion().CodeCompleteObjCPropertyGetter(
+ getCurScope());
return;
}
@@ -1391,8 +1397,9 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteObjCMethodDecl(getCurScope(), mType == tok::minus,
- /*ReturnType=*/nullptr);
+ Actions.CodeCompletion().CodeCompleteObjCMethodDecl(getCurScope(),
+ mType == tok::minus,
+ /*ReturnType=*/nullptr);
return nullptr;
}
@@ -1410,8 +1417,8 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteObjCMethodDecl(getCurScope(), mType == tok::minus,
- ReturnType);
+ Actions.CodeCompletion().CodeCompleteObjCMethodDecl(
+ getCurScope(), mType == tok::minus, ReturnType);
return nullptr;
}
@@ -1473,10 +1480,9 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
if (Tok.is(tok::code_completion)) {
cutOffParsing();
KeyIdents.push_back(SelIdent);
- Actions.CodeCompletion().CodeCompleteObjCMethodDeclSelector(getCurScope(),
- mType == tok::minus,
- /*AtParameterName=*/true,
- ReturnType, KeyIdents);
+ Actions.CodeCompletion().CodeCompleteObjCMethodDeclSelector(
+ getCurScope(), mType == tok::minus,
+ /*AtParameterName=*/true, ReturnType, KeyIdents);
return nullptr;
}
@@ -1497,10 +1503,9 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
// Code completion for the next piece of the selector.
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteObjCMethodDeclSelector(getCurScope(),
- mType == tok::minus,
- /*AtParameterName=*/false,
- ReturnType, KeyIdents);
+ Actions.CodeCompletion().CodeCompleteObjCMethodDeclSelector(
+ getCurScope(), mType == tok::minus,
+ /*AtParameterName=*/false, ReturnType, KeyIdents);
return nullptr;
}
@@ -1584,7 +1589,8 @@ ParseObjCProtocolReferences(SmallVectorImpl<Decl *> &Protocols,
while (true) {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteObjCProtocolReferences(ProtocolIdents);
+ Actions.CodeCompletion().CodeCompleteObjCProtocolReferences(
+ ProtocolIdents);
return true;
}
@@ -1682,9 +1688,11 @@ void Parser::parseObjCTypeArgsOrProtocolQualifiers(
QualType BaseT = Actions.GetTypeFromParser(baseType);
cutOffParsing();
if (!BaseT.isNull() && BaseT->acceptsObjCTypeParams()) {
- Actions.CodeCompletion().CodeCompleteOrdinaryName(getCurScope(), SemaCodeCompletion::PCC_Type);
+ Actions.CodeCompletion().CodeCompleteOrdinaryName(
+ getCurScope(), SemaCodeCompletion::PCC_Type);
} else {
- Actions.CodeCompletion().CodeCompleteObjCProtocolReferences(identifierLocPairs);
+ Actions.CodeCompletion().CodeCompleteObjCProtocolReferences(
+ identifierLocPairs);
}
return;
}
@@ -1990,8 +1998,8 @@ void Parser::ParseObjCClassInstanceVariables(ObjCContainerDecl *interfaceDecl,
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteOrdinaryName(getCurScope(),
- SemaCodeCompletion::PCC_ObjCInstanceVariableList);
+ Actions.CodeCompletion().CodeCompleteOrdinaryName(
+ getCurScope(), SemaCodeCompletion::PCC_ObjCInstanceVariableList);
return;
}
@@ -2194,7 +2202,8 @@ Parser::ParseObjCAtImplementationDeclaration(SourceLocation AtLoc,
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteObjCImplementationCategory(getCurScope(), nameId, nameLoc);
+ Actions.CodeCompletion().CodeCompleteObjCImplementationCategory(
+ getCurScope(), nameId, nameLoc);
return nullptr;
}
@@ -2368,7 +2377,8 @@ Decl *Parser::ParseObjCPropertySynthesize(SourceLocation atLoc) {
while (true) {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteObjCPropertyDefinition(getCurScope());
+ Actions.CodeCompletion().CodeCompleteObjCPropertyDefinition(
+ getCurScope());
return nullptr;
}
@@ -2386,7 +2396,8 @@ Decl *Parser::ParseObjCPropertySynthesize(SourceLocation atLoc) {
// property '=' ivar-name
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteObjCPropertySynthesizeIvar(getCurScope(), propertyId);
+ Actions.CodeCompletion().CodeCompleteObjCPropertySynthesizeIvar(
+ getCurScope(), propertyId);
return nullptr;
}
@@ -2445,7 +2456,8 @@ Decl *Parser::ParseObjCPropertyDynamic(SourceLocation atLoc) {
while (true) {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteObjCPropertyDefinition(getCurScope());
+ Actions.CodeCompletion().CodeCompleteObjCPropertyDefinition(
+ getCurScope());
return nullptr;
}
@@ -3209,14 +3221,14 @@ Parser::ParseObjCMessageExpressionBody(SourceLocation LBracLoc,
if (Tok.is(tok::code_completion)) {
cutOffParsing();
if (SuperLoc.isValid())
- Actions.CodeCompletion().CodeCompleteObjCSuperMessage(getCurScope(), SuperLoc,
- std::nullopt, false);
+ Actions.CodeCompletion().CodeCompleteObjCSuperMessage(
+ getCurScope(), SuperLoc, std::nullopt, false);
else if (ReceiverType)
- Actions.CodeCompletion().CodeCompleteObjCClassMessage(getCurScope(), ReceiverType,
- std::nullopt, false);
+ Actions.CodeCompletion().CodeCompleteObjCClassMessage(
+ getCurScope(), ReceiverType, std::nullopt, false);
else
- Actions.CodeCompletion().CodeCompleteObjCInstanceMessage(getCurScope(), ReceiverExpr,
- std::nullopt, false);
+ Actions.CodeCompletion().CodeCompleteObjCInstanceMessage(
+ getCurScope(), ReceiverExpr, std::nullopt, false);
return ExprError();
}
@@ -3247,17 +3259,17 @@ Parser::ParseObjCMessageExpressionBody(SourceLocation LBracLoc,
if (Tok.is(tok::code_completion)) {
cutOffParsing();
if (SuperLoc.isValid())
- Actions.CodeCompletion().CodeCompleteObjCSuperMessage(getCurScope(), SuperLoc,
- KeyIdents,
- /*AtArgumentExpression=*/true);
+ Actions.CodeCompletion().CodeCompleteObjCSuperMessage(
+ getCurScope(), SuperLoc, KeyIdents,
+ /*AtArgumentExpression=*/true);
else if (ReceiverType)
- Actions.CodeCompletion().CodeCompleteObjCClassMessage(getCurScope(), ReceiverType,
- KeyIdents,
- /*AtArgumentExpression=*/true);
+ Actions.CodeCompletion().CodeCompleteObjCClassMessage(
+ getCurScope(), ReceiverType, KeyIdents,
+ /*AtArgumentExpression=*/true);
else
- Actions.CodeCompletion().CodeCompleteObjCInstanceMessage(getCurScope(), ReceiverExpr,
- KeyIdents,
- /*AtArgumentExpression=*/true);
+ Actions.CodeCompletion().CodeCompleteObjCInstanceMessage(
+ getCurScope(), ReceiverExpr, KeyIdents,
+ /*AtArgumentExpression=*/true);
return ExprError();
}
@@ -3285,17 +3297,17 @@ Parser::ParseObjCMessageExpressionBody(SourceLocation LBracLoc,
if (Tok.is(tok::code_completion)) {
cutOffParsing();
if (SuperLoc.isValid())
- Actions.CodeCompletion().CodeCompleteObjCSuperMessage(getCurScope(), SuperLoc,
- KeyIdents,
- /*AtArgumentExpression=*/false);
+ Actions.CodeCompletion().CodeCompleteObjCSuperMessage(
+ getCurScope(), SuperLoc, KeyIdents,
+ /*AtArgumentExpression=*/false);
else if (ReceiverType)
- Actions.CodeCompletion().CodeCompleteObjCClassMessage(getCurScope(), ReceiverType,
- KeyIdents,
- /*AtArgumentExpression=*/false);
+ Actions.CodeCompletion().CodeCompleteObjCClassMessage(
+ getCurScope(), ReceiverType, KeyIdents,
+ /*AtArgumentExpression=*/false);
else
- Actions.CodeCompletion().CodeCompleteObjCInstanceMessage(getCurScope(), ReceiverExpr,
- KeyIdents,
- /*AtArgumentExpression=*/false);
+ Actions.CodeCompletion().CodeCompleteObjCInstanceMessage(
+ getCurScope(), ReceiverExpr, KeyIdents,
+ /*AtArgumentExpression=*/false);
return ExprError();
}
@@ -3662,7 +3674,8 @@ ExprResult Parser::ParseObjCSelectorExpression(SourceLocation AtLoc) {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteObjCSelector(getCurScope(), KeyIdents);
+ Actions.CodeCompletion().CodeCompleteObjCSelector(getCurScope(),
+ KeyIdents);
return ExprError();
}
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index e8bd52b2f46f1..e959dd6378f46 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -461,7 +461,8 @@ void Parser::ParseOpenMPReductionInitializerForDecl(VarDecl *OmpPrivParm) {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteInitializer(getCurScope(), OmpPrivParm);
+ Actions.CodeCompletion().CodeCompleteInitializer(getCurScope(),
+ OmpPrivParm);
Actions.FinalizeDeclaration(OmpPrivParm);
return;
}
@@ -485,9 +486,10 @@ void Parser::ParseOpenMPReductionInitializerForDecl(VarDecl *OmpPrivParm) {
SourceLocation LParLoc = T.getOpenLocation();
auto RunSignatureHelp = [this, OmpPrivParm, LParLoc, &Exprs]() {
- QualType PreferredType = Actions.CodeCompletion().ProduceConstructorSignatureHelp(
- OmpPrivParm->getType()->getCanonicalTypeInternal(),
- OmpPrivParm->getLocation(), Exprs, LParLoc, /*Braced=*/false);
+ QualType PreferredType =
+ Actions.CodeCompletion().ProduceConstructorSignatureHelp(
+ OmpPrivParm->getType()->getCanonicalTypeInternal(),
+ OmpPrivParm->getLocation(), Exprs, LParLoc, /*Braced=*/false);
CalledSignatureHelp = true;
return PreferredType;
};
diff --git a/clang/lib/Parse/ParsePragma.cpp b/clang/lib/Parse/ParsePragma.cpp
index c2aaf2fd96328..643fdac287d18 100644
--- a/clang/lib/Parse/ParsePragma.cpp
+++ b/clang/lib/Parse/ParsePragma.cpp
@@ -21,8 +21,8 @@
#include "clang/Parse/RAIIObjectsForParser.h"
#include "clang/Sema/EnterExpressionEvaluationContext.h"
#include "clang/Sema/Scope.h"
-#include "clang/Sema/SemaCodeCompletion.h"
#include "clang/Sema/SemaCUDA.h"
+#include "clang/Sema/SemaCodeCompletion.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringSwitch.h"
#include <optional>
@@ -1925,7 +1925,8 @@ void Parser::HandlePragmaAttribute() {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
// FIXME: suppress completion of unsupported attributes?
- Actions.CodeCompletion().CodeCompleteAttribute(AttributeCommonInfo::Syntax::AS_GNU);
+ Actions.CodeCompletion().CodeCompleteAttribute(
+ AttributeCommonInfo::Syntax::AS_GNU);
return SkipToEnd();
}
diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index c690177c236a1..b0af04451166c 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -192,7 +192,8 @@ StmtResult Parser::ParseStatementOrDeclarationAfterAttributes(
case tok::code_completion:
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteOrdinaryName(getCurScope(), SemaCodeCompletion::PCC_Statement);
+ Actions.CodeCompletion().CodeCompleteOrdinaryName(
+ getCurScope(), SemaCodeCompletion::PCC_Statement);
return StmtError();
case tok::identifier:
@@ -2041,9 +2042,9 @@ StmtResult Parser::ParseForStatement(SourceLocation *TrailingElseLoc) {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteOrdinaryName(getCurScope(),
- C99orCXXorObjC? SemaCodeCompletion::PCC_ForInit
- : SemaCodeCompletion::PCC_Expression);
+ Actions.CodeCompletion().CodeCompleteOrdinaryName(
+ getCurScope(), C99orCXXorObjC ? SemaCodeCompletion::PCC_ForInit
+ : SemaCodeCompletion::PCC_Expression);
return StmtError();
}
@@ -2118,7 +2119,8 @@ StmtResult Parser::ParseForStatement(SourceLocation *TrailingElseLoc) {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteObjCForCollection(getCurScope(), DG);
+ Actions.CodeCompletion().CodeCompleteObjCForCollection(getCurScope(),
+ DG);
return StmtError();
}
Collection = ParseExpression();
@@ -2155,7 +2157,8 @@ StmtResult Parser::ParseForStatement(SourceLocation *TrailingElseLoc) {
if (Tok.is(tok::code_completion)) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteObjCForCollection(getCurScope(), nullptr);
+ Actions.CodeCompletion().CodeCompleteObjCForCollection(getCurScope(),
+ nullptr);
return StmtError();
}
Collection = ParseExpression();
@@ -2432,8 +2435,8 @@ StmtResult Parser::ParseReturnStatement() {
// FIXME: Code completion for co_return.
if (Tok.is(tok::code_completion) && !IsCoreturn) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteExpression(getCurScope(),
- PreferredType.get(Tok.getLocation()));
+ Actions.CodeCompletion().CodeCompleteExpression(
+ getCurScope(), PreferredType.get(Tok.getLocation()));
return StmtError();
}
diff --git a/clang/lib/Parse/ParseTemplate.cpp b/clang/lib/Parse/ParseTemplate.cpp
index 6de06b2c6e09c..cb1828ec856f0 100644
--- a/clang/lib/Parse/ParseTemplate.cpp
+++ b/clang/lib/Parse/ParseTemplate.cpp
@@ -1535,8 +1535,8 @@ bool Parser::ParseTemplateArgumentList(TemplateArgList &TemplateArgs,
if (!Template)
return QualType();
CalledSignatureHelp = true;
- return Actions.CodeCompletion().ProduceTemplateArgumentSignatureHelp(Template, TemplateArgs,
- OpenLoc);
+ return Actions.CodeCompletion().ProduceTemplateArgumentSignatureHelp(
+ Template, TemplateArgs, OpenLoc);
};
do {
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index 2cac76005cddb..f19c2d5c69f88 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -945,9 +945,10 @@ Parser::ParseExternalDeclaration(ParsedAttributes &Attrs,
cutOffParsing();
if (CurParsedObjCImpl) {
// Code-complete Objective-C methods even without leading '-'/'+' prefix.
- Actions.CodeCompletion().CodeCompleteObjCMethodDecl(getCurScope(),
- /*IsInstanceMethod=*/std::nullopt,
- /*ReturnType=*/nullptr);
+ Actions.CodeCompletion().CodeCompleteObjCMethodDecl(
+ getCurScope(),
+ /*IsInstanceMethod=*/std::nullopt,
+ /*ReturnType=*/nullptr);
}
SemaCodeCompletion::ParserCompletionContext PCC;
@@ -2281,20 +2282,22 @@ SourceLocation Parser::handleUnexpectedCodeCompletionToken() {
for (Scope *S = getCurScope(); S; S = S->getParent()) {
if (S->isFunctionScope()) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteOrdinaryName(getCurScope(),
- SemaCodeCompletion::PCC_RecoveryInFunction);
+ Actions.CodeCompletion().CodeCompleteOrdinaryName(
+ getCurScope(), SemaCodeCompletion::PCC_RecoveryInFunction);
return PrevTokLocation;
}
if (S->isClassScope()) {
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteOrdinaryName(getCurScope(), SemaCodeCompletion::PCC_Class);
+ Actions.CodeCompletion().CodeCompleteOrdinaryName(
+ getCurScope(), SemaCodeCompletion::PCC_Class);
return PrevTokLocation;
}
}
cutOffParsing();
- Actions.CodeCompletion().CodeCompleteOrdinaryName(getCurScope(), SemaCodeCompletion::PCC_Namespace);
+ Actions.CodeCompletion().CodeCompleteOrdinaryName(
+ getCurScope(), SemaCodeCompletion::PCC_Namespace);
return PrevTokLocation;
}
@@ -2305,7 +2308,8 @@ void Parser::CodeCompleteDirective(bool InConditional) {
}
void Parser::CodeCompleteInConditionalExclusion() {
- Actions.CodeCompletion().CodeCompleteInPreprocessorConditionalExclusion(getCurScope());
+ Actions.CodeCompletion().CodeCompleteInPreprocessorConditionalExclusion(
+ getCurScope());
}
void Parser::CodeCompleteMacroName(bool IsDefinition) {
@@ -2319,8 +2323,8 @@ void Parser::CodeCompletePreprocessorExpression() {
void Parser::CodeCompleteMacroArgument(IdentifierInfo *Macro,
MacroInfo *MacroInfo,
unsigned ArgumentIndex) {
- Actions.CodeCompletion().CodeCompletePreprocessorMacroArgument(getCurScope(), Macro, MacroInfo,
- ArgumentIndex);
+ Actions.CodeCompletion().CodeCompletePreprocessorMacroArgument(
+ getCurScope(), Macro, MacroInfo, ArgumentIndex);
}
void Parser::CodeCompleteIncludedFile(llvm::StringRef Dir, bool IsAngled) {
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 48cc8901a5933..05783e09be6d8 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -41,8 +41,8 @@
#include "clang/Sema/RISCVIntrinsicManager.h"
#include "clang/Sema/Scope.h"
#include "clang/Sema/ScopeInfo.h"
-#include "clang/Sema/SemaCodeCompletion.h"
#include "clang/Sema/SemaCUDA.h"
+#include "clang/Sema/SemaCodeCompletion.h"
#include "clang/Sema/SemaConsumer.h"
#include "clang/Sema/SemaHLSL.h"
#include "clang/Sema/SemaInternal.h"
@@ -203,7 +203,8 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
LateTemplateParser(nullptr), LateTemplateParserCleanup(nullptr),
OpaqueParser(nullptr), CurContext(nullptr), ExternalSource(nullptr),
CurScope(nullptr), Ident_super(nullptr),
- CodeCompletionPtr(std::make_unique<SemaCodeCompletion>(*this, CodeCompleter)),
+ CodeCompletionPtr(
+ std::make_unique<SemaCodeCompletion>(*this, CodeCompleter)),
CUDAPtr(std::make_unique<SemaCUDA>(*this)),
HLSLPtr(std::make_unique<SemaHLSL>(*this)),
ObjCPtr(std::make_unique<SemaObjC>(*this)),
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp
index 5095c10f535f2..ad3ca4cc94ca6 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -9,7 +9,6 @@
// This file defines the code-completion semantic actions.
//
//===----------------------------------------------------------------------===//
-#include "clang/Sema/SemaCodeCompletion.h"
#include "clang/AST/ASTConcept.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclBase.h"
@@ -42,6 +41,7 @@
#include "clang/Sema/Scope.h"
#include "clang/Sema/ScopeInfo.h"
#include "clang/Sema/Sema.h"
+#include "clang/Sema/SemaCodeCompletion.h"
#include "clang/Sema/SemaInternal.h"
#include "clang/Sema/SemaObjC.h"
#include "llvm/ADT/ArrayRef.h"
@@ -1864,9 +1864,9 @@ static void AddTypeSpecifierResults(const LangOptions &LangOpts,
Results.AddResult(Result("_Nullable", CCP_Type));
}
-static void AddStorageSpecifiers(SemaCodeCompletion::ParserCompletionContext CCC,
- const LangOptions &LangOpts,
- ResultBuilder &Results) {
+static void
+AddStorageSpecifiers(SemaCodeCompletion::ParserCompletionContext CCC,
+ const LangOptions &LangOpts, ResultBuilder &Results) {
typedef CodeCompletionResult Result;
// Note: we don't suggest either "auto" or "register", because both
// are pointless as storage specifiers. Elsewhere, we suggest "auto"
@@ -1890,9 +1890,9 @@ static void AddStorageSpecifiers(SemaCodeCompletion::ParserCompletionContext CCC
}
}
-static void AddFunctionSpecifiers(SemaCodeCompletion::ParserCompletionContext CCC,
- const LangOptions &LangOpts,
- ResultBuilder &Results) {
+static void
+AddFunctionSpecifiers(SemaCodeCompletion::ParserCompletionContext CCC,
+ const LangOptions &LangOpts, ResultBuilder &Results) {
typedef CodeCompletionResult Result;
switch (CCC) {
case SemaCodeCompletion::PCC_Class:
@@ -2132,8 +2132,9 @@ static void AddOverrideResults(ResultBuilder &Results,
}
/// Add language constructs that show up for "ordinary" names.
-static void AddOrdinaryNameResults(SemaCodeCompletion::ParserCompletionContext CCC, Scope *S,
- Sema &SemaRef, ResultBuilder &Results) {
+static void
+AddOrdinaryNameResults(SemaCodeCompletion::ParserCompletionContext CCC,
+ Scope *S, Sema &SemaRef, ResultBuilder &Results) {
CodeCompletionAllocator &Allocator = Results.getAllocator();
CodeCompletionBuilder Builder(Allocator, Results.getCodeCompletionTUInfo());
@@ -4242,7 +4243,8 @@ static void HandleCodeCompleteResults(Sema *S,
}
static CodeCompletionContext
-mapCodeCompletionContext(Sema &S, SemaCodeCompletion::ParserCompletionContext PCC) {
+mapCodeCompletionContext(Sema &S,
+ SemaCodeCompletion::ParserCompletionContext PCC) {
switch (PCC) {
case SemaCodeCompletion::PCC_Namespace:
return CodeCompletionContext::CCC_TopLevel;
@@ -4368,7 +4370,7 @@ static void MaybeAddOverrideCalls(Sema &S, DeclContext *InContext,
}
void SemaCodeCompletion::CodeCompleteModuleImport(SourceLocation ImportLoc,
- ModuleIdPath Path) {
+ ModuleIdPath Path) {
typedef CodeCompletionResult Result;
ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
@@ -4392,9 +4394,9 @@ void SemaCodeCompletion::CodeCompleteModuleImport(SourceLocation ImportLoc,
}
} else if (getLangOpts().Modules) {
// Load the named module.
- Module *Mod =
- SemaRef.PP.getModuleLoader().loadModule(ImportLoc, Path, Module::AllVisible,
- /*IsInclusionDirective=*/false);
+ Module *Mod = SemaRef.PP.getModuleLoader().loadModule(
+ ImportLoc, Path, Module::AllVisible,
+ /*IsInclusionDirective=*/false);
// Enumerate submodules.
if (Mod) {
for (auto *Submodule : Mod->submodules()) {
@@ -4408,12 +4410,13 @@ void SemaCodeCompletion::CodeCompleteModuleImport(SourceLocation ImportLoc,
}
}
Results.ExitScope();
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
-void SemaCodeCompletion::CodeCompleteOrdinaryName(Scope *S,
- SemaCodeCompletion::ParserCompletionContext CompletionContext) {
+void SemaCodeCompletion::CodeCompleteOrdinaryName(
+ Scope *S, SemaCodeCompletion::ParserCompletionContext CompletionContext) {
ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
mapCodeCompletionContext(SemaRef, CompletionContext));
@@ -4464,8 +4467,8 @@ void SemaCodeCompletion::CodeCompleteOrdinaryName(Scope *S,
CodeCompletionDeclConsumer Consumer(Results, SemaRef.CurContext);
SemaRef.LookupVisibleDecls(S, SemaRef.LookupOrdinaryName, Consumer,
- CodeCompleter->includeGlobals(),
- CodeCompleter->loadExternal());
+ CodeCompleter->includeGlobals(),
+ CodeCompleter->loadExternal());
AddOrdinaryNameResults(CompletionContext, S, SemaRef, Results);
Results.ExitScope();
@@ -4497,8 +4500,9 @@ void SemaCodeCompletion::CodeCompleteOrdinaryName(Scope *S,
if (CodeCompleter->includeMacros())
AddMacroResults(SemaRef.PP, Results, CodeCompleter->loadExternal(), false);
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
static void
@@ -4508,8 +4512,8 @@ AddClassMessageCompletions(Sema &SemaRef, Scope *S, ParsedType Receiver,
ResultBuilder &Results);
void SemaCodeCompletion::CodeCompleteDeclSpec(Scope *S, DeclSpec &DS,
- bool AllowNonIdentifiers,
- bool AllowNestedNameSpecifiers) {
+ bool AllowNonIdentifiers,
+ bool AllowNestedNameSpecifiers) {
typedef CodeCompletionResult Result;
ResultBuilder Results(
SemaRef, CodeCompleter->getAllocator(),
@@ -4542,9 +4546,9 @@ void SemaCodeCompletion::CodeCompleteDeclSpec(Scope *S, DeclSpec &DS,
Results.allowNestedNameSpecifiers();
Results.setFilter(&ResultBuilder::IsImpossibleToSatisfy);
CodeCompletionDeclConsumer Consumer(Results, SemaRef.CurContext);
- SemaRef.LookupVisibleDecls(S, Sema::LookupNestedNameSpecifierName, Consumer,
- CodeCompleter->includeGlobals(),
- CodeCompleter->loadExternal());
+ SemaRef.LookupVisibleDecls(S, Sema::LookupNestedNameSpecifierName,
+ Consumer, CodeCompleter->includeGlobals(),
+ CodeCompleter->loadExternal());
Results.setFilter(nullptr);
}
}
@@ -4573,8 +4577,9 @@ void SemaCodeCompletion::CodeCompleteDeclSpec(Scope *S, DeclSpec &DS,
// Note that we intentionally suppress macro results here, since we do not
// encourage using macros to produce the names of entities.
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
static const char *underscoreAttrScope(llvm::StringRef Scope) {
@@ -4593,9 +4598,9 @@ static const char *noUnderscoreAttrScope(llvm::StringRef Scope) {
return nullptr;
}
-void SemaCodeCompletion::CodeCompleteAttribute(AttributeCommonInfo::Syntax Syntax,
- AttributeCompletion Completion,
- const IdentifierInfo *InScope) {
+void SemaCodeCompletion::CodeCompleteAttribute(
+ AttributeCommonInfo::Syntax Syntax, AttributeCompletion Completion,
+ const IdentifierInfo *InScope) {
if (Completion == AttributeCompletion::None)
return;
ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
@@ -4627,7 +4632,8 @@ void SemaCodeCompletion::CodeCompleteAttribute(AttributeCommonInfo::Syntax Synta
llvm::DenseSet<llvm::StringRef> FoundScopes;
auto AddCompletions = [&](const ParsedAttrInfo &A) {
- if (A.IsTargetSpecific && !A.existsInTarget(getASTContext().getTargetInfo()))
+ if (A.IsTargetSpecific &&
+ !A.existsInTarget(getASTContext().getTargetInfo()))
return;
if (!A.acceptsLangOpts(getLangOpts()))
return;
@@ -4725,8 +4731,9 @@ void SemaCodeCompletion::CodeCompleteAttribute(AttributeCommonInfo::Syntax Synta
for (const auto &Entry : ParsedAttrInfoRegistry::entries())
AddCompletions(*Entry.instantiate());
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
struct SemaCodeCompletion::CodeCompleteExpressionData {
@@ -4842,8 +4849,8 @@ static void AddLambdaCompletion(ResultBuilder &Results,
/// Perform code-completion in an expression context when we know what
/// type we're looking for.
-void SemaCodeCompletion::CodeCompleteExpression(Scope *S,
- const CodeCompleteExpressionData &Data) {
+void SemaCodeCompletion::CodeCompleteExpression(
+ Scope *S, const CodeCompleteExpressionData &Data) {
ResultBuilder Results(
SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
@@ -4872,8 +4879,8 @@ void SemaCodeCompletion::CodeCompleteExpression(Scope *S,
CodeCompletionDeclConsumer Consumer(Results, SemaRef.CurContext);
SemaRef.LookupVisibleDecls(S, Sema::LookupOrdinaryName, Consumer,
- CodeCompleter->includeGlobals(),
- CodeCompleter->loadExternal());
+ CodeCompleter->includeGlobals(),
+ CodeCompleter->loadExternal());
Results.EnterNewScope();
AddOrdinaryNameResults(PCC, S, SemaRef, Results);
@@ -4890,7 +4897,8 @@ void SemaCodeCompletion::CodeCompleteExpression(Scope *S,
Enum = Def;
// FIXME: collect covered enumerators in cases like:
// if (x == my_enum::one) { ... } else if (x == ^) {}
- AddEnumerators(Results, getASTContext(), Enum, SemaRef.CurContext, CoveredEnumerators());
+ AddEnumerators(Results, getASTContext(), Enum, SemaRef.CurContext,
+ CoveredEnumerators());
}
}
@@ -4909,18 +4917,20 @@ void SemaCodeCompletion::CodeCompleteExpression(Scope *S,
AddLambdaCompletion(Results, F->getParamTypes(), getLangOpts());
}
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
-void SemaCodeCompletion::CodeCompleteExpression(Scope *S, QualType PreferredType,
- bool IsParenthesized) {
+void SemaCodeCompletion::CodeCompleteExpression(Scope *S,
+ QualType PreferredType,
+ bool IsParenthesized) {
return CodeCompleteExpression(
S, CodeCompleteExpressionData(PreferredType, IsParenthesized));
}
void SemaCodeCompletion::CodeCompletePostfixExpression(Scope *S, ExprResult E,
- QualType PreferredType) {
+ QualType PreferredType) {
if (E.isInvalid())
CodeCompleteExpression(S, PreferredType);
else if (getLangOpts().ObjC)
@@ -5183,10 +5193,11 @@ AddRecordMembersCompletionResults(Sema &SemaRef, ResultBuilder &Results,
if (AccessOpFixIt)
FixIts.emplace_back(*AccessOpFixIt);
CodeCompletionDeclConsumer Consumer(Results, RD, BaseType, std::move(FixIts));
- SemaRef.LookupVisibleDecls(RD, Sema::LookupMemberName, Consumer,
- SemaRef.CodeCompletion().CodeCompleter->includeGlobals(),
- /*IncludeDependentBases=*/true,
- SemaRef.CodeCompletion().CodeCompleter->loadExternal());
+ SemaRef.LookupVisibleDecls(
+ RD, Sema::LookupMemberName, Consumer,
+ SemaRef.CodeCompletion().CodeCompleter->includeGlobals(),
+ /*IncludeDependentBases=*/true,
+ SemaRef.CodeCompletion().CodeCompleter->loadExternal());
if (SemaRef.getLangOpts().CPlusPlus) {
if (!Results.empty()) {
@@ -5702,17 +5713,16 @@ Expr *unwrapParenList(Expr *Base) {
} // namespace
-void SemaCodeCompletion::CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base,
- Expr *OtherOpBase,
- SourceLocation OpLoc, bool IsArrow,
- bool IsBaseExprStatement,
- QualType PreferredType) {
+void SemaCodeCompletion::CodeCompleteMemberReferenceExpr(
+ Scope *S, Expr *Base, Expr *OtherOpBase, SourceLocation OpLoc, bool IsArrow,
+ bool IsBaseExprStatement, QualType PreferredType) {
Base = unwrapParenList(Base);
OtherOpBase = unwrapParenList(OtherOpBase);
if (!Base || !CodeCompleter)
return;
- ExprResult ConvertedBase = SemaRef.PerformMemberExprBaseConversion(Base, IsArrow);
+ ExprResult ConvertedBase =
+ SemaRef.PerformMemberExprBaseConversion(Base, IsArrow);
if (ConvertedBase.isInvalid())
return;
QualType ConvertedBaseType = getApproximateType(ConvertedBase.get());
@@ -5746,7 +5756,8 @@ void SemaCodeCompletion::CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base,
if (!Base)
return false;
- ExprResult ConvertedBase = SemaRef.PerformMemberExprBaseConversion(Base, IsArrow);
+ ExprResult ConvertedBase =
+ SemaRef.PerformMemberExprBaseConversion(Base, IsArrow);
if (ConvertedBase.isInvalid())
return false;
Base = ConvertedBase.get();
@@ -5828,9 +5839,10 @@ void SemaCodeCompletion::CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base,
if (Class) {
CodeCompletionDeclConsumer Consumer(Results, Class, BaseType);
Results.setFilter(&ResultBuilder::IsObjCIvar);
- SemaRef.LookupVisibleDecls(
- Class, Sema::LookupMemberName, Consumer, CodeCompleter->includeGlobals(),
- /*IncludeDependentBases=*/false, CodeCompleter->loadExternal());
+ SemaRef.LookupVisibleDecls(Class, Sema::LookupMemberName, Consumer,
+ CodeCompleter->includeGlobals(),
+ /*IncludeDependentBases=*/false,
+ CodeCompleter->loadExternal());
}
}
@@ -5855,14 +5867,14 @@ void SemaCodeCompletion::CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base,
return;
// Hand off the results found for code completion.
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
-void SemaCodeCompletion::CodeCompleteObjCClassPropertyRefExpr(Scope *S,
- const IdentifierInfo &ClassName,
- SourceLocation ClassNameLoc,
- bool IsBaseExprStatement) {
+void SemaCodeCompletion::CodeCompleteObjCClassPropertyRefExpr(
+ Scope *S, const IdentifierInfo &ClassName, SourceLocation ClassNameLoc,
+ bool IsBaseExprStatement) {
const IdentifierInfo *ClassNamePtr = &ClassName;
ObjCInterfaceDecl *IFace =
SemaRef.ObjC().getObjCInterfaceDecl(ClassNamePtr, ClassNameLoc);
@@ -5876,12 +5888,13 @@ void SemaCodeCompletion::CodeCompleteObjCClassPropertyRefExpr(Scope *S,
Results.EnterNewScope();
AddedPropertiesSet AddedProperties;
AddObjCProperties(CCContext, IFace, true,
- /*AllowNullaryMethods=*/true, SemaRef.CurContext, AddedProperties,
- Results, IsBaseExprStatement,
+ /*AllowNullaryMethods=*/true, SemaRef.CurContext,
+ AddedProperties, Results, IsBaseExprStatement,
/*IsClassProperty=*/true);
Results.ExitScope();
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
void SemaCodeCompletion::CodeCompleteTag(Scope *S, unsigned TagSpec) {
@@ -5920,19 +5933,20 @@ void SemaCodeCompletion::CodeCompleteTag(Scope *S, unsigned TagSpec) {
// First pass: look for tags.
Results.setFilter(Filter);
SemaRef.LookupVisibleDecls(S, Sema::LookupTagName, Consumer,
- CodeCompleter->includeGlobals(),
- CodeCompleter->loadExternal());
+ CodeCompleter->includeGlobals(),
+ CodeCompleter->loadExternal());
if (CodeCompleter->includeGlobals()) {
// Second pass: look for nested name specifiers.
Results.setFilter(&ResultBuilder::IsNestedNameSpecifier);
SemaRef.LookupVisibleDecls(S, Sema::LookupNestedNameSpecifierName, Consumer,
- CodeCompleter->includeGlobals(),
- CodeCompleter->loadExternal());
+ CodeCompleter->includeGlobals(),
+ CodeCompleter->loadExternal());
}
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
static void AddTypeQualifierResults(DeclSpec &DS, ResultBuilder &Results,
@@ -5956,12 +5970,13 @@ void SemaCodeCompletion::CodeCompleteTypeQualifiers(DeclSpec &DS) {
Results.EnterNewScope();
AddTypeQualifierResults(DS, Results, getLangOpts());
Results.ExitScope();
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
-void SemaCodeCompletion::CodeCompleteFunctionQualifiers(DeclSpec &DS, Declarator &D,
- const VirtSpecifiers *VS) {
+void SemaCodeCompletion::CodeCompleteFunctionQualifiers(
+ DeclSpec &DS, Declarator &D, const VirtSpecifiers *VS) {
ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_TypeQualifiers);
@@ -5978,8 +5993,9 @@ void SemaCodeCompletion::CodeCompleteFunctionQualifiers(DeclSpec &DS, Declarator
}
}
Results.ExitScope();
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
void SemaCodeCompletion::CodeCompleteBracketDeclarator(Scope *S) {
@@ -5990,7 +6006,8 @@ void SemaCodeCompletion::CodeCompleteCase(Scope *S) {
if (SemaRef.getCurFunction()->SwitchStack.empty() || !CodeCompleter)
return;
- SwitchStmt *Switch = SemaRef.getCurFunction()->SwitchStack.back().getPointer();
+ SwitchStmt *Switch =
+ SemaRef.getCurFunction()->SwitchStack.back().getPointer();
// Condition expression might be invalid, do not continue in this case.
if (!Switch->getCond())
return;
@@ -6050,13 +6067,15 @@ void SemaCodeCompletion::CodeCompleteCase(Scope *S) {
ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_Expression);
- AddEnumerators(Results, getASTContext(), Enum, SemaRef.CurContext, Enumerators);
+ AddEnumerators(Results, getASTContext(), Enum, SemaRef.CurContext,
+ Enumerators);
if (CodeCompleter->includeMacros()) {
AddMacroResults(SemaRef.PP, Results, CodeCompleter->loadExternal(), false);
}
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
static bool anyNullArguments(ArrayRef<Expr *> Args) {
@@ -6191,8 +6210,9 @@ static FunctionProtoTypeLoc GetPrototypeLoc(Expr *Fn) {
return {};
}
-QualType SemaCodeCompletion::ProduceCallSignatureHelp(Expr *Fn, ArrayRef<Expr *> Args,
- SourceLocation OpenParLoc) {
+QualType
+SemaCodeCompletion::ProduceCallSignatureHelp(Expr *Fn, ArrayRef<Expr *> Args,
+ SourceLocation OpenParLoc) {
Fn = unwrapParenList(Fn);
if (!CodeCompleter || !Fn)
return QualType();
@@ -6215,8 +6235,9 @@ QualType SemaCodeCompletion::ProduceCallSignatureHelp(Expr *Fn, ArrayRef<Expr *>
OverloadCandidateSet CandidateSet(Loc, OverloadCandidateSet::CSK_Normal);
if (auto ULE = dyn_cast<UnresolvedLookupExpr>(NakedFn)) {
- SemaRef.AddOverloadedCallCandidates(ULE, ArgsWithoutDependentTypes, CandidateSet,
- /*PartialOverloading=*/true);
+ SemaRef.AddOverloadedCallCandidates(ULE, ArgsWithoutDependentTypes,
+ CandidateSet,
+ /*PartialOverloading=*/true);
} else if (auto UME = dyn_cast<UnresolvedMemberExpr>(NakedFn)) {
TemplateArgumentListInfo TemplateArgsBuffer, *TemplateArgs = nullptr;
if (UME->hasExplicitTemplateArgs()) {
@@ -6233,8 +6254,9 @@ QualType SemaCodeCompletion::ProduceCallSignatureHelp(Expr *Fn, ArrayRef<Expr *>
Decls.append(UME->decls_begin(), UME->decls_end());
const bool FirstArgumentIsBase = !UME->isImplicitAccess() && UME->getBase();
SemaRef.AddFunctionCandidates(Decls, ArgExprs, CandidateSet, TemplateArgs,
- /*SuppressUserConversions=*/false,
- /*PartialOverloading=*/true, FirstArgumentIsBase);
+ /*SuppressUserConversions=*/false,
+ /*PartialOverloading=*/true,
+ FirstArgumentIsBase);
} else {
FunctionDecl *FD = nullptr;
if (auto *MCE = dyn_cast<MemberExpr>(NakedFn))
@@ -6246,10 +6268,11 @@ QualType SemaCodeCompletion::ProduceCallSignatureHelp(Expr *Fn, ArrayRef<Expr *>
!FD->getType()->getAs<FunctionProtoType>())
Results.push_back(ResultCandidate(FD));
else
- SemaRef.AddOverloadCandidate(FD, DeclAccessPair::make(FD, FD->getAccess()),
- ArgsWithoutDependentTypes, CandidateSet,
- /*SuppressUserConversions=*/false,
- /*PartialOverloading=*/true);
+ SemaRef.AddOverloadCandidate(FD,
+ DeclAccessPair::make(FD, FD->getAccess()),
+ ArgsWithoutDependentTypes, CandidateSet,
+ /*SuppressUserConversions=*/false,
+ /*PartialOverloading=*/true);
} else if (auto DC = NakedFn->getType()->getAsCXXRecordDecl()) {
// If expression's type is CXXRecordDecl, it may overload the function
@@ -6264,10 +6287,11 @@ QualType SemaCodeCompletion::ProduceCallSignatureHelp(Expr *Fn, ArrayRef<Expr *>
SmallVector<Expr *, 12> ArgExprs(1, NakedFn);
ArgExprs.append(ArgsWithoutDependentTypes.begin(),
ArgsWithoutDependentTypes.end());
- SemaRef.AddFunctionCandidates(R.asUnresolvedSet(), ArgExprs, CandidateSet,
- /*ExplicitArgs=*/nullptr,
- /*SuppressUserConversions=*/false,
- /*PartialOverloading=*/true);
+ SemaRef.AddFunctionCandidates(R.asUnresolvedSet(), ArgExprs,
+ CandidateSet,
+ /*ExplicitArgs=*/nullptr,
+ /*SuppressUserConversions=*/false,
+ /*PartialOverloading=*/true);
}
} else {
// Lastly we check whether expression's type is function pointer or
@@ -6280,8 +6304,8 @@ QualType SemaCodeCompletion::ProduceCallSignatureHelp(Expr *Fn, ArrayRef<Expr *>
if (auto FP = T->getAs<FunctionProtoType>()) {
if (!SemaRef.TooManyArguments(FP->getNumParams(),
- ArgsWithoutDependentTypes.size(),
- /*PartialOverloading=*/true) ||
+ ArgsWithoutDependentTypes.size(),
+ /*PartialOverloading=*/true) ||
FP->isVariadic()) {
if (P) {
Results.push_back(ResultCandidate(P));
@@ -6367,11 +6391,9 @@ getNextAggregateIndexAfterDesignatedInit(const ResultCandidate &Aggregate,
return DesignatedIndex + ArgsAfterDesignator + 1;
}
-QualType SemaCodeCompletion::ProduceConstructorSignatureHelp(QualType Type,
- SourceLocation Loc,
- ArrayRef<Expr *> Args,
- SourceLocation OpenParLoc,
- bool Braced) {
+QualType SemaCodeCompletion::ProduceConstructorSignatureHelp(
+ QualType Type, SourceLocation Loc, ArrayRef<Expr *> Args,
+ SourceLocation OpenParLoc, bool Braced) {
if (!CodeCompleter)
return QualType();
SmallVector<ResultCandidate, 8> Results;
@@ -6418,13 +6440,14 @@ QualType SemaCodeCompletion::ProduceConstructorSignatureHelp(QualType Type,
if (auto *FD = dyn_cast<FunctionDecl>(C)) {
// FIXME: we can't yet provide correct signature help for initializer
// list constructors, so skip them entirely.
- if (Braced && getLangOpts().CPlusPlus && SemaRef.isInitListConstructor(FD))
+ if (Braced && getLangOpts().CPlusPlus &&
+ SemaRef.isInitListConstructor(FD))
continue;
- SemaRef.AddOverloadCandidate(FD, DeclAccessPair::make(FD, C->getAccess()), Args,
- CandidateSet,
- /*SuppressUserConversions=*/false,
- /*PartialOverloading=*/true,
- /*AllowExplicit*/ true);
+ SemaRef.AddOverloadCandidate(
+ FD, DeclAccessPair::make(FD, C->getAccess()), Args, CandidateSet,
+ /*SuppressUserConversions=*/false,
+ /*PartialOverloading=*/true,
+ /*AllowExplicit*/ true);
} else if (auto *FTD = dyn_cast<FunctionTemplateDecl>(C)) {
if (Braced && getLangOpts().CPlusPlus &&
SemaRef.isInitListConstructor(FTD->getTemplatedDecl()))
@@ -6437,10 +6460,12 @@ QualType SemaCodeCompletion::ProduceConstructorSignatureHelp(QualType Type,
/*PartialOverloading=*/true);
}
}
- mergeCandidatesWithResults(SemaRef, Results, CandidateSet, Loc, Args.size());
+ mergeCandidatesWithResults(SemaRef, Results, CandidateSet, Loc,
+ Args.size());
}
- return ProduceSignatureHelp(SemaRef, Results, Args.size(), OpenParLoc, Braced);
+ return ProduceSignatureHelp(SemaRef, Results, Args.size(), OpenParLoc,
+ Braced);
}
QualType SemaCodeCompletion::ProduceCtorInitMemberSignatureHelp(
@@ -6542,9 +6567,8 @@ static QualType getDesignatedType(QualType BaseType, const Designation &Desig) {
return BaseType;
}
-void SemaCodeCompletion::CodeCompleteDesignator(QualType BaseType,
- llvm::ArrayRef<Expr *> InitExprs,
- const Designation &D) {
+void SemaCodeCompletion::CodeCompleteDesignator(
+ QualType BaseType, llvm::ArrayRef<Expr *> InitExprs, const Designation &D) {
BaseType = getDesignatedType(BaseType, D);
if (BaseType.isNull())
return;
@@ -6573,8 +6597,9 @@ void SemaCodeCompletion::CodeCompleteDesignator(QualType BaseType,
Results.AddResult(Result, SemaRef.CurContext, /*Hiding=*/nullptr);
}
Results.ExitScope();
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
void SemaCodeCompletion::CodeCompleteInitializer(Scope *S, Decl *D) {
@@ -6601,8 +6626,8 @@ void SemaCodeCompletion::CodeCompleteAfterIf(Scope *S, bool IsBracedThen) {
CodeCompletionDeclConsumer Consumer(Results, SemaRef.CurContext);
SemaRef.LookupVisibleDecls(S, Sema::LookupOrdinaryName, Consumer,
- CodeCompleter->includeGlobals(),
- CodeCompleter->loadExternal());
+ CodeCompleter->includeGlobals(),
+ CodeCompleter->loadExternal());
AddOrdinaryNameResults(PCC_Statement, S, SemaRef, Results);
@@ -6652,14 +6677,16 @@ void SemaCodeCompletion::CodeCompleteAfterIf(Scope *S, bool IsBracedThen) {
if (CodeCompleter->includeMacros())
AddMacroResults(SemaRef.PP, Results, CodeCompleter->loadExternal(), false);
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
void SemaCodeCompletion::CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS,
- bool EnteringContext,
- bool IsUsingDeclaration, QualType BaseType,
- QualType PreferredType) {
+ bool EnteringContext,
+ bool IsUsingDeclaration,
+ QualType BaseType,
+ QualType PreferredType) {
if (SS.isEmpty() || !CodeCompleter)
return;
@@ -6683,8 +6710,8 @@ void SemaCodeCompletion::CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS,
CodeCompletionDeclConsumer Consumer(DummyResults, S->getEntity(),
BaseType);
SemaRef.LookupVisibleDecls(S, Sema::LookupOrdinaryName, Consumer,
- /*IncludeGlobalScope=*/false,
- /*LoadExternal=*/false);
+ /*IncludeGlobalScope=*/false,
+ /*LoadExternal=*/false);
}
HandleCodeCompleteResults(&SemaRef, CodeCompleter,
DummyResults.getCompletionContext(), nullptr, 0);
@@ -6742,13 +6769,14 @@ void SemaCodeCompletion::CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS,
(CodeCompleter->includeNamespaceLevelDecls() || !Ctx->isFileContext())) {
CodeCompletionDeclConsumer Consumer(Results, Ctx, BaseType);
SemaRef.LookupVisibleDecls(Ctx, Sema::LookupOrdinaryName, Consumer,
- /*IncludeGlobalScope=*/true,
- /*IncludeDependentBases=*/true,
- CodeCompleter->loadExternal());
+ /*IncludeGlobalScope=*/true,
+ /*IncludeDependentBases=*/true,
+ CodeCompleter->loadExternal());
}
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
void SemaCodeCompletion::CodeCompleteUsing(Scope *S) {
@@ -6773,12 +6801,13 @@ void SemaCodeCompletion::CodeCompleteUsing(Scope *S) {
// nested-name-specifier.
CodeCompletionDeclConsumer Consumer(Results, SemaRef.CurContext);
SemaRef.LookupVisibleDecls(S, Sema::LookupOrdinaryName, Consumer,
- CodeCompleter->includeGlobals(),
- CodeCompleter->loadExternal());
+ CodeCompleter->includeGlobals(),
+ CodeCompleter->loadExternal());
Results.ExitScope();
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
void SemaCodeCompletion::CodeCompleteUsingDirective(Scope *S) {
@@ -6794,11 +6823,12 @@ void SemaCodeCompletion::CodeCompleteUsingDirective(Scope *S) {
Results.EnterNewScope();
CodeCompletionDeclConsumer Consumer(Results, SemaRef.CurContext);
SemaRef.LookupVisibleDecls(S, Sema::LookupOrdinaryName, Consumer,
- CodeCompleter->includeGlobals(),
- CodeCompleter->loadExternal());
+ CodeCompleter->includeGlobals(),
+ CodeCompleter->loadExternal());
Results.ExitScope();
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
void SemaCodeCompletion::CodeCompleteNamespaceDecl(Scope *S) {
@@ -6845,8 +6875,9 @@ void SemaCodeCompletion::CodeCompleteNamespaceDecl(Scope *S) {
Results.ExitScope();
}
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
void SemaCodeCompletion::CodeCompleteNamespaceAliasDecl(Scope *S) {
@@ -6860,10 +6891,11 @@ void SemaCodeCompletion::CodeCompleteNamespaceAliasDecl(Scope *S) {
&ResultBuilder::IsNamespaceOrAlias);
CodeCompletionDeclConsumer Consumer(Results, SemaRef.CurContext);
SemaRef.LookupVisibleDecls(S, Sema::LookupOrdinaryName, Consumer,
- CodeCompleter->includeGlobals(),
- CodeCompleter->loadExternal());
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ CodeCompleter->includeGlobals(),
+ CodeCompleter->loadExternal());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
void SemaCodeCompletion::CodeCompleteOperatorName(Scope *S) {
@@ -6888,15 +6920,16 @@ void SemaCodeCompletion::CodeCompleteOperatorName(Scope *S) {
Results.allowNestedNameSpecifiers();
CodeCompletionDeclConsumer Consumer(Results, SemaRef.CurContext);
SemaRef.LookupVisibleDecls(S, Sema::LookupOrdinaryName, Consumer,
- CodeCompleter->includeGlobals(),
- CodeCompleter->loadExternal());
+ CodeCompleter->includeGlobals(),
+ CodeCompleter->loadExternal());
// Add any type specifiers
AddTypeSpecifierResults(getLangOpts(), Results);
Results.ExitScope();
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
void SemaCodeCompletion::CodeCompleteConstructorInitializer(
@@ -6940,8 +6973,8 @@ void SemaCodeCompletion::CodeCompleteConstructorInitializer(
if (const auto *Function = dyn_cast<FunctionDecl>(ND))
AddFunctionParameterChunks(SemaRef.PP, Policy, Function, Builder);
else if (const auto *FunTemplDecl = dyn_cast<FunctionTemplateDecl>(ND))
- AddFunctionParameterChunks(SemaRef.PP, Policy, FunTemplDecl->getTemplatedDecl(),
- Builder);
+ AddFunctionParameterChunks(SemaRef.PP, Policy,
+ FunTemplDecl->getTemplatedDecl(), Builder);
Builder.AddChunk(CodeCompletionString::CK_RightParen);
return Builder.TakeString();
};
@@ -7000,7 +7033,8 @@ void SemaCodeCompletion::CodeCompleteConstructorInitializer(
};
for (const auto &Base : ClassDecl->bases()) {
- if (!InitializedBases.insert(getASTContext().getCanonicalType(Base.getType()))
+ if (!InitializedBases
+ .insert(getASTContext().getCanonicalType(Base.getType()))
.second) {
SawLastInitializer =
!Initializers.empty() && Initializers.back()->isBaseInitializer() &&
@@ -7015,7 +7049,8 @@ void SemaCodeCompletion::CodeCompleteConstructorInitializer(
// Add completions for virtual base classes.
for (const auto &Base : ClassDecl->vbases()) {
- if (!InitializedBases.insert(getASTContext().getCanonicalType(Base.getType()))
+ if (!InitializedBases
+ .insert(getASTContext().getCanonicalType(Base.getType()))
.second) {
SawLastInitializer =
!Initializers.empty() && Initializers.back()->isBaseInitializer() &&
@@ -7046,8 +7081,9 @@ void SemaCodeCompletion::CodeCompleteConstructorInitializer(
}
Results.ExitScope();
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
/// Determine whether this scope denotes a namespace.
@@ -7059,8 +7095,9 @@ static bool isNamespaceScope(Scope *S) {
return DC->isFileContext();
}
-void SemaCodeCompletion::CodeCompleteLambdaIntroducer(Scope *S, LambdaIntroducer &Intro,
- bool AfterAmpersand) {
+void SemaCodeCompletion::CodeCompleteLambdaIntroducer(Scope *S,
+ LambdaIntroducer &Intro,
+ bool AfterAmpersand) {
ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_Other);
@@ -7097,8 +7134,9 @@ void SemaCodeCompletion::CodeCompleteLambdaIntroducer(Scope *S, LambdaIntroducer
Results.ExitScope();
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
void SemaCodeCompletion::CodeCompleteAfterFunctionEquals(Declarator &D) {
@@ -7144,8 +7182,9 @@ void SemaCodeCompletion::CodeCompleteAfterFunctionEquals(Declarator &D) {
// first function declaration.
Results.AddResult("delete");
Results.ExitScope();
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
/// Macro that optionally prepends an "@" to the string literal passed in via
@@ -7257,8 +7296,9 @@ void SemaCodeCompletion::CodeCompleteObjCAtDirective(Scope *S) {
else
AddObjCTopLevelResults(Results, false);
Results.ExitScope();
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
static void AddObjCExpressionResults(ResultBuilder &Results, bool NeedAt) {
@@ -7389,8 +7429,9 @@ void SemaCodeCompletion::CodeCompleteObjCAtVisibility(Scope *S) {
Results.EnterNewScope();
AddObjCVisibilityResults(getLangOpts(), Results, false);
Results.ExitScope();
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
void SemaCodeCompletion::CodeCompleteObjCAtStatement(Scope *S) {
@@ -7401,8 +7442,9 @@ void SemaCodeCompletion::CodeCompleteObjCAtStatement(Scope *S) {
AddObjCStatementResults(Results, false);
AddObjCExpressionResults(Results, false);
Results.ExitScope();
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
void SemaCodeCompletion::CodeCompleteObjCAtExpression(Scope *S) {
@@ -7412,8 +7454,9 @@ void SemaCodeCompletion::CodeCompleteObjCAtExpression(Scope *S) {
Results.EnterNewScope();
AddObjCExpressionResults(Results, false);
Results.ExitScope();
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
/// Determine whether the addition of the given flag to an Objective-C
@@ -7449,7 +7492,8 @@ static bool ObjCPropertyFlagConflicts(unsigned Attributes, unsigned NewFlag) {
return false;
}
-void SemaCodeCompletion::CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS) {
+void SemaCodeCompletion::CodeCompleteObjCPropertyFlags(Scope *S,
+ ObjCDeclSpec &ODS) {
if (!CodeCompleter)
return;
@@ -7518,8 +7562,9 @@ void SemaCodeCompletion::CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &O
Results.AddResult(CodeCompletionResult("null_resettable"));
}
Results.ExitScope();
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
/// Describes the kind of Objective-C method that we want to find
@@ -7680,7 +7725,8 @@ static void AddObjCMethods(ObjCContainerDecl *Container,
void SemaCodeCompletion::CodeCompleteObjCPropertyGetter(Scope *S) {
// Try to find the interface where getters might live.
- ObjCInterfaceDecl *Class = dyn_cast_or_null<ObjCInterfaceDecl>(SemaRef.CurContext);
+ ObjCInterfaceDecl *Class =
+ dyn_cast_or_null<ObjCInterfaceDecl>(SemaRef.CurContext);
if (!Class) {
if (ObjCCategoryDecl *Category =
dyn_cast_or_null<ObjCCategoryDecl>(SemaRef.CurContext))
@@ -7697,17 +7743,19 @@ void SemaCodeCompletion::CodeCompleteObjCPropertyGetter(Scope *S) {
Results.EnterNewScope();
VisitedSelectorSet Selectors;
- AddObjCMethods(Class, true, MK_ZeroArgSelector, std::nullopt, SemaRef.CurContext,
- Selectors,
+ AddObjCMethods(Class, true, MK_ZeroArgSelector, std::nullopt,
+ SemaRef.CurContext, Selectors,
/*AllowSameLength=*/true, Results);
Results.ExitScope();
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
void SemaCodeCompletion::CodeCompleteObjCPropertySetter(Scope *S) {
// Try to find the interface where setters might live.
- ObjCInterfaceDecl *Class = dyn_cast_or_null<ObjCInterfaceDecl>(SemaRef.CurContext);
+ ObjCInterfaceDecl *Class =
+ dyn_cast_or_null<ObjCInterfaceDecl>(SemaRef.CurContext);
if (!Class) {
if (ObjCCategoryDecl *Category =
dyn_cast_or_null<ObjCCategoryDecl>(SemaRef.CurContext))
@@ -7724,17 +7772,18 @@ void SemaCodeCompletion::CodeCompleteObjCPropertySetter(Scope *S) {
Results.EnterNewScope();
VisitedSelectorSet Selectors;
- AddObjCMethods(Class, true, MK_OneArgSelector, std::nullopt, SemaRef.CurContext,
- Selectors,
+ AddObjCMethods(Class, true, MK_OneArgSelector, std::nullopt,
+ SemaRef.CurContext, Selectors,
/*AllowSameLength=*/true, Results);
Results.ExitScope();
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
void SemaCodeCompletion::CodeCompleteObjCPassingType(Scope *S, ObjCDeclSpec &DS,
- bool IsParameter) {
+ bool IsParameter) {
ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_Type);
@@ -7800,14 +7849,15 @@ void SemaCodeCompletion::CodeCompleteObjCPassingType(Scope *S, ObjCDeclSpec &DS,
Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
CodeCompletionDeclConsumer Consumer(Results, SemaRef.CurContext);
SemaRef.LookupVisibleDecls(S, Sema::LookupOrdinaryName, Consumer,
- CodeCompleter->includeGlobals(),
- CodeCompleter->loadExternal());
+ CodeCompleter->includeGlobals(),
+ CodeCompleter->loadExternal());
if (CodeCompleter->includeMacros())
AddMacroResults(SemaRef.PP, Results, CodeCompleter->loadExternal(), false);
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
/// When we have an expression with type "id", we may assume
@@ -8011,8 +8061,8 @@ void SemaCodeCompletion::CodeCompleteObjCMessageReceiver(Scope *S) {
CodeCompletionDeclConsumer Consumer(Results, SemaRef.CurContext);
Results.EnterNewScope();
SemaRef.LookupVisibleDecls(S, Sema::LookupOrdinaryName, Consumer,
- CodeCompleter->includeGlobals(),
- CodeCompleter->loadExternal());
+ CodeCompleter->includeGlobals(),
+ CodeCompleter->loadExternal());
// If we are in an Objective-C method inside a class that has a superclass,
// add "super" as an option.
@@ -8032,8 +8082,9 @@ void SemaCodeCompletion::CodeCompleteObjCMessageReceiver(Scope *S) {
if (CodeCompleter->includeMacros())
AddMacroResults(SemaRef.PP, Results, CodeCompleter->loadExternal(), false);
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
void SemaCodeCompletion::CodeCompleteObjCSuperMessage(
@@ -8064,7 +8115,8 @@ void SemaCodeCompletion::CodeCompleteObjCSuperMessage(
// "super" may be the name of a type or variable. Figure out which
// it is.
const IdentifierInfo *Super = SemaRef.getSuperIdentifier();
- NamedDecl *ND = SemaRef.LookupSingleName(S, Super, SuperLoc, Sema::LookupOrdinaryName);
+ NamedDecl *ND =
+ SemaRef.LookupSingleName(S, Super, SuperLoc, Sema::LookupOrdinaryName);
if ((CDecl = dyn_cast_or_null<ObjCInterfaceDecl>(ND))) {
// "super" names an interface. Use it.
} else if (TypeDecl *TD = dyn_cast_or_null<TypeDecl>(ND)) {
@@ -8079,9 +8131,10 @@ void SemaCodeCompletion::CodeCompleteObjCSuperMessage(
SourceLocation TemplateKWLoc;
UnqualifiedId id;
id.setIdentifier(Super, SuperLoc);
- ExprResult SuperExpr = SemaRef.ActOnIdExpression(S, SS, TemplateKWLoc, id,
- /*HasTrailingLParen=*/false,
- /*IsAddressOfOperand=*/false);
+ ExprResult SuperExpr =
+ SemaRef.ActOnIdExpression(S, SS, TemplateKWLoc, id,
+ /*HasTrailingLParen=*/false,
+ /*IsAddressOfOperand=*/false);
return CodeCompleteObjCInstanceMessage(S, (Expr *)SuperExpr.get(),
SelIdents, AtArgumentExpression);
}
@@ -8237,8 +8290,9 @@ void SemaCodeCompletion::CodeCompleteObjCClassMessage(
return;
}
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
void SemaCodeCompletion::CodeCompleteObjCInstanceMessage(
@@ -8333,7 +8387,8 @@ void SemaCodeCompletion::CodeCompleteObjCInstanceMessage(
ReceiverType->getAsObjCInterfacePointerType()) {
// Search the class, its superclasses, etc., for instance methods.
AddObjCMethods(IFacePtr->getInterfaceDecl(), true, MK_Any, SelIdents,
- SemaRef.CurContext, Selectors, AtArgumentExpression, Results);
+ SemaRef.CurContext, Selectors, AtArgumentExpression,
+ Results);
// Search protocols for instance methods.
for (auto *I : IFacePtr->quals())
@@ -8348,7 +8403,8 @@ void SemaCodeCompletion::CodeCompleteObjCInstanceMessage(
// If we have an external source, load the entire class method
// pool from the AST file.
if (SemaRef.ExternalSource) {
- for (uint32_t I = 0, N = SemaRef.ExternalSource->GetNumExternalSelectors();
+ for (uint32_t I = 0,
+ N = SemaRef.ExternalSource->GetNumExternalSelectors();
I != N; ++I) {
Selector Sel = SemaRef.ExternalSource->GetExternalSelector(I);
if (Sel.isNull() || SemaRef.ObjC().MethodPool.count(Sel))
@@ -8358,8 +8414,9 @@ void SemaCodeCompletion::CodeCompleteObjCInstanceMessage(
}
}
- for (SemaObjC::GlobalMethodPool::iterator M = SemaRef.ObjC().MethodPool.begin(),
- MEnd = SemaRef.ObjC().MethodPool.end();
+ for (SemaObjC::GlobalMethodPool::iterator
+ M = SemaRef.ObjC().MethodPool.begin(),
+ MEnd = SemaRef.ObjC().MethodPool.end();
M != MEnd; ++M) {
for (ObjCMethodList *MethList = &M->second.first;
MethList && MethList->getMethod(); MethList = MethList->getNext()) {
@@ -8394,12 +8451,13 @@ void SemaCodeCompletion::CodeCompleteObjCInstanceMessage(
return;
}
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
-void SemaCodeCompletion::CodeCompleteObjCForCollection(Scope *S,
- DeclGroupPtrTy IterationVar) {
+void SemaCodeCompletion::CodeCompleteObjCForCollection(
+ Scope *S, DeclGroupPtrTy IterationVar) {
CodeCompleteExpressionData Data;
Data.ObjCCollection = true;
@@ -8419,8 +8477,8 @@ void SemaCodeCompletion::CodeCompleteObjCSelector(
// If we have an external source, load the entire class method
// pool from the AST file.
if (SemaRef.ExternalSource) {
- for (uint32_t I = 0, N = SemaRef.ExternalSource->GetNumExternalSelectors(); I != N;
- ++I) {
+ for (uint32_t I = 0, N = SemaRef.ExternalSource->GetNumExternalSelectors();
+ I != N; ++I) {
Selector Sel = SemaRef.ExternalSource->GetExternalSelector(I);
if (Sel.isNull() || SemaRef.ObjC().MethodPool.count(Sel))
continue;
@@ -8433,8 +8491,9 @@ void SemaCodeCompletion::CodeCompleteObjCSelector(
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_SelectorName);
Results.EnterNewScope();
- for (SemaObjC::GlobalMethodPool::iterator M = SemaRef.ObjC().MethodPool.begin(),
- MEnd = SemaRef.ObjC().MethodPool.end();
+ for (SemaObjC::GlobalMethodPool::iterator
+ M = SemaRef.ObjC().MethodPool.begin(),
+ MEnd = SemaRef.ObjC().MethodPool.end();
M != MEnd; ++M) {
Selector Sel = M->first;
@@ -8468,8 +8527,9 @@ void SemaCodeCompletion::CodeCompleteObjCSelector(
}
Results.ExitScope();
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
/// Add all of the protocol declarations that we find in the given
@@ -8507,14 +8567,15 @@ void SemaCodeCompletion::CodeCompleteObjCProtocolReferences(
Results.Ignore(Protocol);
// Add all protocols.
- AddProtocolResults(getASTContext().getTranslationUnitDecl(), SemaRef.CurContext, false,
- Results);
+ AddProtocolResults(getASTContext().getTranslationUnitDecl(),
+ SemaRef.CurContext, false, Results);
Results.ExitScope();
}
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
void SemaCodeCompletion::CodeCompleteObjCProtocolDecl(Scope *) {
@@ -8526,14 +8587,15 @@ void SemaCodeCompletion::CodeCompleteObjCProtocolDecl(Scope *) {
Results.EnterNewScope();
// Add all protocols.
- AddProtocolResults(getASTContext().getTranslationUnitDecl(), SemaRef.CurContext, true,
- Results);
+ AddProtocolResults(getASTContext().getTranslationUnitDecl(),
+ SemaRef.CurContext, true, Results);
Results.ExitScope();
}
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
/// Add all of the Objective-C interface declarations that we find in
@@ -8563,14 +8625,15 @@ void SemaCodeCompletion::CodeCompleteObjCInterfaceDecl(Scope *S) {
if (CodeCompleter->includeGlobals()) {
// Add all classes.
- AddInterfaceResults(getASTContext().getTranslationUnitDecl(), SemaRef.CurContext, false,
- false, Results);
+ AddInterfaceResults(getASTContext().getTranslationUnitDecl(),
+ SemaRef.CurContext, false, false, Results);
}
Results.ExitScope();
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
void SemaCodeCompletion::CodeCompleteObjCClassForwardDecl(Scope *S) {
@@ -8581,39 +8644,41 @@ void SemaCodeCompletion::CodeCompleteObjCClassForwardDecl(Scope *S) {
if (CodeCompleter->includeGlobals()) {
// Add all classes.
- AddInterfaceResults(getASTContext().getTranslationUnitDecl(), SemaRef.CurContext, false,
- false, Results);
+ AddInterfaceResults(getASTContext().getTranslationUnitDecl(),
+ SemaRef.CurContext, false, false, Results);
}
Results.ExitScope();
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
-void SemaCodeCompletion::CodeCompleteObjCSuperclass(Scope *S, IdentifierInfo *ClassName,
- SourceLocation ClassNameLoc) {
+void SemaCodeCompletion::CodeCompleteObjCSuperclass(
+ Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc) {
ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
CodeCompleter->getCodeCompletionTUInfo(),
CodeCompletionContext::CCC_ObjCInterfaceName);
Results.EnterNewScope();
// Make sure that we ignore the class we're currently defining.
- NamedDecl *CurClass =
- SemaRef.LookupSingleName(SemaRef.TUScope, ClassName, ClassNameLoc, Sema::LookupOrdinaryName);
+ NamedDecl *CurClass = SemaRef.LookupSingleName(
+ SemaRef.TUScope, ClassName, ClassNameLoc, Sema::LookupOrdinaryName);
if (CurClass && isa<ObjCInterfaceDecl>(CurClass))
Results.Ignore(CurClass);
if (CodeCompleter->includeGlobals()) {
// Add all classes.
- AddInterfaceResults(getASTContext().getTranslationUnitDecl(), SemaRef.CurContext, false,
- false, Results);
+ AddInterfaceResults(getASTContext().getTranslationUnitDecl(),
+ SemaRef.CurContext, false, false, Results);
}
Results.ExitScope();
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
void SemaCodeCompletion::CodeCompleteObjCImplementationDecl(Scope *S) {
@@ -8624,19 +8689,19 @@ void SemaCodeCompletion::CodeCompleteObjCImplementationDecl(Scope *S) {
if (CodeCompleter->includeGlobals()) {
// Add all unimplemented classes.
- AddInterfaceResults(getASTContext().getTranslationUnitDecl(), SemaRef.CurContext, false,
- true, Results);
+ AddInterfaceResults(getASTContext().getTranslationUnitDecl(),
+ SemaRef.CurContext, false, true, Results);
}
Results.ExitScope();
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
-void SemaCodeCompletion::CodeCompleteObjCInterfaceCategory(Scope *S,
- IdentifierInfo *ClassName,
- SourceLocation ClassNameLoc) {
+void SemaCodeCompletion::CodeCompleteObjCInterfaceCategory(
+ Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc) {
typedef CodeCompletionResult Result;
ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
@@ -8646,8 +8711,8 @@ void SemaCodeCompletion::CodeCompleteObjCInterfaceCategory(Scope *S,
// Ignore any categories we find that have already been implemented by this
// interface.
llvm::SmallPtrSet<IdentifierInfo *, 16> CategoryNames;
- NamedDecl *CurClass =
- SemaRef.LookupSingleName(SemaRef.TUScope, ClassName, ClassNameLoc, Sema::LookupOrdinaryName);
+ NamedDecl *CurClass = SemaRef.LookupSingleName(
+ SemaRef.TUScope, ClassName, ClassNameLoc, Sema::LookupOrdinaryName);
if (ObjCInterfaceDecl *Class =
dyn_cast_or_null<ObjCInterfaceDecl>(CurClass)) {
for (const auto *Cat : Class->visible_categories())
@@ -8665,20 +8730,20 @@ void SemaCodeCompletion::CodeCompleteObjCInterfaceCategory(Scope *S,
SemaRef.CurContext, nullptr, false);
Results.ExitScope();
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
-void SemaCodeCompletion::CodeCompleteObjCImplementationCategory(Scope *S,
- IdentifierInfo *ClassName,
- SourceLocation ClassNameLoc) {
+void SemaCodeCompletion::CodeCompleteObjCImplementationCategory(
+ Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc) {
typedef CodeCompletionResult Result;
// Find the corresponding interface. If we couldn't find the interface, the
// program itself is ill-formed. However, we'll try to be helpful still by
// providing the list of all of the categories we know about.
- NamedDecl *CurClass =
- SemaRef.LookupSingleName(SemaRef.TUScope, ClassName, ClassNameLoc, Sema::LookupOrdinaryName);
+ NamedDecl *CurClass = SemaRef.LookupSingleName(
+ SemaRef.TUScope, ClassName, ClassNameLoc, Sema::LookupOrdinaryName);
ObjCInterfaceDecl *Class = dyn_cast_or_null<ObjCInterfaceDecl>(CurClass);
if (!Class)
return CodeCompleteObjCInterfaceCategory(S, ClassName, ClassNameLoc);
@@ -8706,8 +8771,9 @@ void SemaCodeCompletion::CodeCompleteObjCImplementationCategory(Scope *S,
}
Results.ExitScope();
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
void SemaCodeCompletion::CodeCompleteObjCPropertyDefinition(Scope *S) {
@@ -8743,8 +8809,9 @@ void SemaCodeCompletion::CodeCompleteObjCPropertyDefinition(Scope *S) {
AddedProperties, Results);
Results.ExitScope();
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
void SemaCodeCompletion::CodeCompleteObjCPropertySynthesizeIvar(
@@ -8826,8 +8893,8 @@ void SemaCodeCompletion::CodeCompleteObjCPropertySynthesizeIvar(
Priority, CXAvailability_Available);
PrintingPolicy Policy = getCompletionPrintingPolicy(SemaRef);
- Builder.AddResultTypeChunk(
- GetCompletionTypeString(PropertyType, getASTContext(), Policy, Allocator));
+ Builder.AddResultTypeChunk(GetCompletionTypeString(
+ PropertyType, getASTContext(), Policy, Allocator));
Builder.AddTypedTextChunk(Allocator.CopyString(NameWithPrefix));
Results.AddResult(
Result(Builder.TakeString(), Priority, CXCursor_ObjCIvarDecl));
@@ -8835,8 +8902,9 @@ void SemaCodeCompletion::CodeCompleteObjCPropertySynthesizeIvar(
Results.ExitScope();
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
// Mapping from selectors to the methods that implement that selector, along
@@ -9575,9 +9643,8 @@ static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property,
}
}
-void SemaCodeCompletion::CodeCompleteObjCMethodDecl(Scope *S,
- std::optional<bool> IsInstanceMethod,
- ParsedType ReturnTy) {
+void SemaCodeCompletion::CodeCompleteObjCMethodDecl(
+ Scope *S, std::optional<bool> IsInstanceMethod, ParsedType ReturnTy) {
ASTContext &Context = getASTContext();
// Determine the return type of the method we're declaring, if
// provided.
@@ -9749,8 +9816,9 @@ void SemaCodeCompletion::CodeCompleteObjCMethodDecl(Scope *S,
Results.ExitScope();
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
void SemaCodeCompletion::CodeCompleteObjCMethodDeclSelector(
@@ -9759,8 +9827,8 @@ void SemaCodeCompletion::CodeCompleteObjCMethodDeclSelector(
// If we have an external source, load the entire class method
// pool from the AST file.
if (SemaRef.ExternalSource) {
- for (uint32_t I = 0, N = SemaRef.ExternalSource->GetNumExternalSelectors(); I != N;
- ++I) {
+ for (uint32_t I = 0, N = SemaRef.ExternalSource->GetNumExternalSelectors();
+ I != N; ++I) {
Selector Sel = SemaRef.ExternalSource->GetExternalSelector(I);
if (Sel.isNull() || SemaRef.ObjC().MethodPool.count(Sel))
continue;
@@ -9776,11 +9844,13 @@ void SemaCodeCompletion::CodeCompleteObjCMethodDeclSelector(
CodeCompletionContext::CCC_Other);
if (ReturnTy)
- Results.setPreferredType(SemaRef.GetTypeFromParser(ReturnTy).getNonReferenceType());
+ Results.setPreferredType(
+ SemaRef.GetTypeFromParser(ReturnTy).getNonReferenceType());
Results.EnterNewScope();
- for (SemaObjC::GlobalMethodPool::iterator M = SemaRef.ObjC().MethodPool.begin(),
- MEnd = SemaRef.ObjC().MethodPool.end();
+ for (SemaObjC::GlobalMethodPool::iterator
+ M = SemaRef.ObjC().MethodPool.begin(),
+ MEnd = SemaRef.ObjC().MethodPool.end();
M != MEnd; ++M) {
for (ObjCMethodList *MethList = IsInstanceMethod ? &M->second.first
: &M->second.second;
@@ -9834,8 +9904,9 @@ void SemaCodeCompletion::CodeCompleteObjCMethodDeclSelector(
}
}
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
void SemaCodeCompletion::CodeCompletePreprocessorDirective(bool InConditional) {
@@ -10004,13 +10075,16 @@ void SemaCodeCompletion::CodeCompletePreprocessorDirective(bool InConditional) {
// FIXME: we don't support #assert or #unassert, so don't suggest them.
Results.ExitScope();
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
-void SemaCodeCompletion::CodeCompleteInPreprocessorConditionalExclusion(Scope *S) {
- CodeCompleteOrdinaryName(S, S->getFnParent() ? SemaCodeCompletion::PCC_RecoveryInFunction
- : SemaCodeCompletion::PCC_Namespace);
+void SemaCodeCompletion::CodeCompleteInPreprocessorConditionalExclusion(
+ Scope *S) {
+ CodeCompleteOrdinaryName(S, S->getFnParent()
+ ? SemaCodeCompletion::PCC_RecoveryInFunction
+ : SemaCodeCompletion::PCC_Namespace);
}
void SemaCodeCompletion::CodeCompletePreprocessorMacroName(bool IsDefinition) {
@@ -10036,8 +10110,9 @@ void SemaCodeCompletion::CodeCompletePreprocessorMacroName(bool IsDefinition) {
// FIXME: Can we detect when the user just wrote an include guard above?
}
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
void SemaCodeCompletion::CodeCompletePreprocessorExpression() {
@@ -10060,14 +10135,13 @@ void SemaCodeCompletion::CodeCompletePreprocessorExpression() {
Results.AddResult(Builder.TakeString());
Results.ExitScope();
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
-void SemaCodeCompletion::CodeCompletePreprocessorMacroArgument(Scope *S,
- IdentifierInfo *Macro,
- MacroInfo *MacroInfo,
- unsigned Argument) {
+void SemaCodeCompletion::CodeCompletePreprocessorMacroArgument(
+ Scope *S, IdentifierInfo *Macro, MacroInfo *MacroInfo, unsigned Argument) {
// FIXME: In the future, we could provide "overload" results, much like we
// do for function calls.
@@ -10078,7 +10152,8 @@ void SemaCodeCompletion::CodeCompletePreprocessorMacroArgument(Scope *S,
// This handles completion inside an #include filename, e.g. #include <foo/ba
// We look for the directory "foo" under each directory on the include path,
// list its files, and reassemble the appropriate #include.
-void SemaCodeCompletion::CodeCompleteIncludedFile(llvm::StringRef Dir, bool Angled) {
+void SemaCodeCompletion::CodeCompleteIncludedFile(llvm::StringRef Dir,
+ bool Angled) {
// RelDir should use /, but unescaped \ is possible on windows!
// Our completions will normalize to / for simplicity, this case is rare.
std::string RelDir = llvm::sys::path::convert_to_slash(Dir);
@@ -10215,8 +10290,9 @@ void SemaCodeCompletion::CodeCompleteIncludedFile(llvm::StringRef Dir, bool Angl
for (const auto &D : make_range(S.system_dir_begin(), S.system_dir_end()))
AddFilesFromDirLookup(D, true);
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
void SemaCodeCompletion::CodeCompleteNaturalLanguage() {
@@ -10237,8 +10313,9 @@ void SemaCodeCompletion::CodeCompleteAvailabilityPlatformName() {
Twine(Platform) + "ApplicationExtension")));
}
Results.ExitScope();
- HandleCodeCompleteResults(&SemaRef, CodeCompleter, Results.getCompletionContext(),
- Results.data(), Results.size());
+ HandleCodeCompleteResults(&SemaRef, CodeCompleter,
+ Results.getCompletionContext(), Results.data(),
+ Results.size());
}
void SemaCodeCompletion::GatherGlobalCodeCompletions(
@@ -10247,11 +10324,11 @@ void SemaCodeCompletion::GatherGlobalCodeCompletions(
ResultBuilder Builder(SemaRef, Allocator, CCTUInfo,
CodeCompletionContext::CCC_Recovery);
if (!CodeCompleter || CodeCompleter->includeGlobals()) {
- CodeCompletionDeclConsumer Consumer(Builder,
- getASTContext().getTranslationUnitDecl());
- SemaRef.LookupVisibleDecls(getASTContext().getTranslationUnitDecl(), Sema::LookupAnyName,
- Consumer,
- !CodeCompleter || CodeCompleter->loadExternal());
+ CodeCompletionDeclConsumer Consumer(
+ Builder, getASTContext().getTranslationUnitDecl());
+ SemaRef.LookupVisibleDecls(getASTContext().getTranslationUnitDecl(),
+ Sema::LookupAnyName, Consumer,
+ !CodeCompleter || CodeCompleter->loadExternal());
}
if (!CodeCompleter || CodeCompleter->includeMacros())
@@ -10263,4 +10340,6 @@ void SemaCodeCompletion::GatherGlobalCodeCompletions(
Builder.data() + Builder.size());
}
-SemaCodeCompletion::SemaCodeCompletion(Sema &S, CodeCompleteConsumer *CompletionConsumer) : SemaBase(S), CodeCompleter(CompletionConsumer) {}
+SemaCodeCompletion::SemaCodeCompletion(Sema &S,
+ CodeCompleteConsumer *CompletionConsumer)
+ : SemaBase(S), CodeCompleter(CompletionConsumer) {}
More information about the cfe-commits
mailing list