clang  16.0.0git
CodeCompleteConsumer.h
Go to the documentation of this file.
1 //===- CodeCompleteConsumer.h - Code Completion Interface -------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the CodeCompleteConsumer class.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_CLANG_SEMA_CODECOMPLETECONSUMER_H
14 #define LLVM_CLANG_SEMA_CODECOMPLETECONSUMER_H
15 
16 #include "clang-c/Index.h"
17 #include "clang/AST/Type.h"
18 #include "clang/Basic/LLVM.h"
19 #include "clang/Lex/MacroInfo.h"
21 #include "clang/Sema/DeclSpec.h"
22 #include "llvm/ADT/ArrayRef.h"
23 #include "llvm/ADT/DenseMap.h"
24 #include "llvm/ADT/None.h"
25 #include "llvm/ADT/Optional.h"
26 #include "llvm/ADT/SmallPtrSet.h"
27 #include "llvm/ADT/SmallVector.h"
28 #include "llvm/ADT/StringRef.h"
29 #include "llvm/Support/Allocator.h"
30 #include "llvm/Support/type_traits.h"
31 #include <cassert>
32 #include <memory>
33 #include <string>
34 #include <utility>
35 
36 namespace clang {
37 
38 class ASTContext;
39 class Decl;
40 class DeclContext;
41 class FunctionDecl;
42 class FunctionTemplateDecl;
43 class IdentifierInfo;
44 class LangOptions;
45 class NamedDecl;
46 class NestedNameSpecifier;
47 class Preprocessor;
48 class RawComment;
49 class Sema;
50 class UsingShadowDecl;
51 
52 /// Default priority values for code-completion results based
53 /// on their kind.
54 enum {
55  /// Priority for the next initialization in a constructor initializer
56  /// list.
58 
59  /// Priority for an enumeration constant inside a switch whose
60  /// condition is of the enumeration type.
62 
63  /// Priority for a send-to-super completion.
65 
66  /// Priority for a declaration that is in the local scope.
68 
69  /// Priority for a member declaration found from the current
70  /// method or member function.
72 
73  /// Priority for a language keyword (that isn't any of the other
74  /// categories).
76 
77  /// Priority for a code pattern.
79 
80  /// Priority for a non-type declaration.
82 
83  /// Priority for a type.
85 
86  /// Priority for a constant value (e.g., enumerator).
88 
89  /// Priority for a preprocessor macro.
90  CCP_Macro = 70,
91 
92  /// Priority for a nested-name-specifier.
94 
95  /// Priority for a result that isn't likely to be what the user wants,
96  /// but is included for completeness.
98 
99  /// Priority for the Objective-C "_cmd" implicit parameter.
101 };
102 
103 /// Priority value deltas that are added to code-completion results
104 /// based on the context of the result.
105 enum {
106  /// The result is in a base class.
108 
109  /// The result is a C++ non-static member function whose qualifiers
110  /// exactly match the object type on which the member function can be called.
112 
113  /// The selector of the given message exactly matches the selector
114  /// of the current method, which might imply that some kind of delegation
115  /// is occurring.
117 
118  /// Adjustment to the "bool" type in Objective-C, where the typedef
119  /// "BOOL" is preferred.
121 
122  /// Adjustment for KVC code pattern priorities when it doesn't look
123  /// like the
125 
126  /// An Objective-C method being used as a property.
128 
129  /// An Objective-C block property completed as a setter with a
130  /// block placeholder.
132 };
133 
134 /// Priority value factors by which we will divide or multiply the
135 /// priority of a code-completion result.
136 enum {
137  /// Divide by this factor when a code-completion result's type exactly
138  /// matches the type we expect.
140 
141  /// Divide by this factor when a code-completion result's type is
142  /// similar to the type we expect (e.g., both arithmetic types, both
143  /// Objective-C object pointer types).
145 };
146 
147 /// A simplified classification of types used when determining
148 /// "similar" types for code completion.
159 };
160 
161 /// Determine the simplified type class of the given canonical type.
163 
164 /// Determine the type that this declaration will have if it is used
165 /// as a type or in an expression.
166 QualType getDeclUsageType(ASTContext &C, const NamedDecl *ND);
167 
168 /// Determine the priority to be given to a macro code completion result
169 /// with the given name.
170 ///
171 /// \param MacroName The name of the macro.
172 ///
173 /// \param LangOpts Options describing the current language dialect.
174 ///
175 /// \param PreferredTypeIsPointer Whether the preferred type for the context
176 /// of this macro is a pointer type.
177 unsigned getMacroUsagePriority(StringRef MacroName,
178  const LangOptions &LangOpts,
179  bool PreferredTypeIsPointer = false);
180 
181 /// Determine the libclang cursor kind associated with the given
182 /// declaration.
183 CXCursorKind getCursorKindForDecl(const Decl *D);
184 
185 /// The context in which code completion occurred, so that the
186 /// code-completion consumer can process the results accordingly.
188 public:
189  enum Kind {
190  /// An unspecified code-completion context.
192 
193  /// An unspecified code-completion context where we should also add
194  /// macro completions.
196 
197  /// Code completion occurred within a "top-level" completion context,
198  /// e.g., at namespace or global scope.
200 
201  /// Code completion occurred within an Objective-C interface,
202  /// protocol, or category interface.
204 
205  /// Code completion occurred within an Objective-C implementation
206  /// or category implementation.
208 
209  /// Code completion occurred within the instance variable list of
210  /// an Objective-C interface, implementation, or category implementation.
212 
213  /// Code completion occurred within a class, struct, or union.
215 
216  /// Code completion occurred where a statement (or declaration) is
217  /// expected in a function, method, or block.
219 
220  /// Code completion occurred where an expression is expected.
222 
223  /// Code completion occurred where an Objective-C message receiver
224  /// is expected.
226 
227  /// Code completion occurred on the right-hand side of a member
228  /// access expression using the dot operator.
229  ///
230  /// The results of this completion are the members of the type being
231  /// accessed. The type itself is available via
232  /// \c CodeCompletionContext::getType().
234 
235  /// Code completion occurred on the right-hand side of a member
236  /// access expression using the arrow operator.
237  ///
238  /// The results of this completion are the members of the type being
239  /// accessed. The type itself is available via
240  /// \c CodeCompletionContext::getType().
242 
243  /// Code completion occurred on the right-hand side of an Objective-C
244  /// property access expression.
245  ///
246  /// The results of this completion are the members of the type being
247  /// accessed. The type itself is available via
248  /// \c CodeCompletionContext::getType().
250 
251  /// Code completion occurred after the "enum" keyword, to indicate
252  /// an enumeration name.
254 
255  /// Code completion occurred after the "union" keyword, to indicate
256  /// a union name.
258 
259  /// Code completion occurred after the "struct" or "class" keyword,
260  /// to indicate a struct or class name.
262 
263  /// Code completion occurred where a protocol name is expected.
265 
266  /// Code completion occurred where a namespace or namespace alias
267  /// is expected.
269 
270  /// Code completion occurred where a type name is expected.
272 
273  /// Code completion occurred where a new name is expected.
275 
276  /// Code completion occurred where both a new name and an existing symbol is
277  /// permissible.
279 
280  /// Code completion occurred where an existing name(such as type, function
281  /// or variable) is expected.
283 
284  /// Code completion occurred where an macro is being defined.
286 
287  /// Code completion occurred where a macro name is expected
288  /// (without any arguments, in the case of a function-like macro).
290 
291  /// Code completion occurred within a preprocessor expression.
293 
294  /// Code completion occurred where a preprocessor directive is
295  /// expected.
297 
298  /// Code completion occurred in a context where natural language is
299  /// expected, e.g., a comment or string literal.
300  ///
301  /// This context usually implies that no completions should be added,
302  /// unless they come from an appropriate natural-language dictionary.
304 
305  /// Code completion for a selector, as in an \@selector expression.
307 
308  /// Code completion within a type-qualifier list.
310 
311  /// Code completion in a parenthesized expression, which means that
312  /// we may also have types here in C and Objective-C (as well as in C++).
314 
315  /// Code completion where an Objective-C instance message is
316  /// expected.
318 
319  /// Code completion where an Objective-C class message is expected.
321 
322  /// Code completion where the name of an Objective-C class is
323  /// expected.
325 
326  /// Code completion where an Objective-C category name is expected.
328 
329  /// Code completion inside the filename part of a #include directive.
331 
332  /// Code completion of an attribute name.
334 
335  /// An unknown context, in which we are recovering from a parsing
336  /// error and don't know which completions we should give.
338  };
339 
341 
342 private:
343  Kind CCKind;
344 
345  /// Indicates whether we are completing a name of a using declaration, e.g.
346  /// using ^;
347  /// using a::^;
348  bool IsUsingDeclaration;
349 
350  /// The type that would prefer to see at this point (e.g., the type
351  /// of an initializer or function parameter).
352  QualType PreferredType;
353 
354  /// The type of the base object in a member access expression.
355  QualType BaseType;
356 
357  /// The identifiers for Objective-C selector parts.
358  ArrayRef<IdentifierInfo *> SelIdents;
359 
360  /// The scope specifier that comes before the completion token e.g.
361  /// "a::b::"
362  llvm::Optional<CXXScopeSpec> ScopeSpecifier;
363 
364  /// A set of declaration contexts visited by Sema when doing lookup for
365  /// code completion.
366  VisitedContextSet VisitedContexts;
367 
368 public:
369  /// Construct a new code-completion context of the given kind.
371  : CCKind(CCKind), IsUsingDeclaration(false), SelIdents(None) {}
372 
373  /// Construct a new code-completion context of the given kind.
375  ArrayRef<IdentifierInfo *> SelIdents = None)
376  : CCKind(CCKind), IsUsingDeclaration(false), SelIdents(SelIdents) {
377  if (CCKind == CCC_DotMemberAccess || CCKind == CCC_ArrowMemberAccess ||
378  CCKind == CCC_ObjCPropertyAccess || CCKind == CCC_ObjCClassMessage ||
379  CCKind == CCC_ObjCInstanceMessage)
380  BaseType = T;
381  else
382  PreferredType = T;
383  }
384 
385  bool isUsingDeclaration() const { return IsUsingDeclaration; }
386  void setIsUsingDeclaration(bool V) { IsUsingDeclaration = V; }
387 
388  /// Retrieve the kind of code-completion context.
389  Kind getKind() const { return CCKind; }
390 
391  /// Retrieve the type that this expression would prefer to have, e.g.,
392  /// if the expression is a variable initializer or a function argument, the
393  /// type of the corresponding variable or function parameter.
394  QualType getPreferredType() const { return PreferredType; }
395  void setPreferredType(QualType T) { PreferredType = T; }
396 
397  /// Retrieve the type of the base object in a member-access
398  /// expression.
399  QualType getBaseType() const { return BaseType; }
400 
401  /// Retrieve the Objective-C selector identifiers.
402  ArrayRef<IdentifierInfo *> getSelIdents() const { return SelIdents; }
403 
404  /// Determines whether we want C++ constructors as results within this
405  /// context.
406  bool wantConstructorResults() const;
407 
408  /// Sets the scope specifier that comes before the completion token.
409  /// This is expected to be set in code completions on qualfied specifiers
410  /// (e.g. "a::b::").
412  this->ScopeSpecifier = std::move(SS);
413  }
414 
415  /// Adds a visited context.
417  VisitedContexts.insert(Ctx);
418  }
419 
420  /// Retrieves all visited contexts.
422  return VisitedContexts;
423  }
424 
426  if (ScopeSpecifier)
427  return &*ScopeSpecifier;
428  return llvm::None;
429  }
430 };
431 
432 /// Get string representation of \p Kind, useful for debugging.
434 
435 /// A "string" used to describe how code completion can
436 /// be performed for an entity.
437 ///
438 /// A code completion string typically shows how a particular entity can be
439 /// used. For example, the code completion string for a function would show
440 /// the syntax to call it, including the parentheses, placeholders for the
441 /// arguments, etc.
443 public:
444  /// The different kinds of "chunks" that can occur within a code
445  /// completion string.
446  enum ChunkKind {
447  /// The piece of text that the user is expected to type to
448  /// match the code-completion string, typically a keyword or the name of a
449  /// declarator or macro.
451 
452  /// A piece of text that should be placed in the buffer, e.g.,
453  /// parentheses or a comma in a function call.
455 
456  /// A code completion string that is entirely optional. For example,
457  /// an optional code completion string that describes the default arguments
458  /// in a function call.
460 
461  /// A string that acts as a placeholder for, e.g., a function
462  /// call argument.
464 
465  /// A piece of text that describes something about the result but
466  /// should not be inserted into the buffer.
468  /// A piece of text that describes the type of an entity or, for
469  /// functions and methods, the return type.
471 
472  /// A piece of text that describes the parameter that corresponds
473  /// to the code-completion location within a function call, message send,
474  /// macro invocation, etc.
476 
477  /// A left parenthesis ('(').
479 
480  /// A right parenthesis (')').
482 
483  /// A left bracket ('[').
485 
486  /// A right bracket (']').
488 
489  /// A left brace ('{').
491 
492  /// A right brace ('}').
494 
495  /// A left angle bracket ('<').
497 
498  /// A right angle bracket ('>').
500 
501  /// A comma separator (',').
503 
504  /// A colon (':').
506 
507  /// A semicolon (';').
509 
510  /// An '=' sign.
512 
513  /// Horizontal whitespace (' ').
515 
516  /// Vertical whitespace ('\\n' or '\\r\\n', depending on the
517  /// platform).
519  };
520 
521  /// One piece of the code completion string.
522  struct Chunk {
523  /// The kind of data stored in this piece of the code completion
524  /// string.
526 
527  union {
528  /// The text string associated with a CK_Text, CK_Placeholder,
529  /// CK_Informative, or CK_Comma chunk.
530  /// The string is owned by the chunk and will be deallocated
531  /// (with delete[]) when the chunk is destroyed.
532  const char *Text;
533 
534  /// The code completion string associated with a CK_Optional chunk.
535  /// The optional code completion string is owned by the chunk, and will
536  /// be deallocated (with delete) when the chunk is destroyed.
538  };
539 
540  Chunk() : Text(nullptr) {}
541 
542  explicit Chunk(ChunkKind Kind, const char *Text = "");
543 
544  /// Create a new text chunk.
545  static Chunk CreateText(const char *Text);
546 
547  /// Create a new optional chunk.
549 
550  /// Create a new placeholder chunk.
551  static Chunk CreatePlaceholder(const char *Placeholder);
552 
553  /// Create a new informative chunk.
554  static Chunk CreateInformative(const char *Informative);
555 
556  /// Create a new result type chunk.
557  static Chunk CreateResultType(const char *ResultType);
558 
559  /// Create a new current-parameter chunk.
560  static Chunk CreateCurrentParameter(const char *CurrentParameter);
561  };
562 
563 private:
564  friend class CodeCompletionBuilder;
565  friend class CodeCompletionResult;
566 
567  /// The number of chunks stored in this string.
568  unsigned NumChunks : 16;
569 
570  /// The number of annotations for this code-completion result.
571  unsigned NumAnnotations : 16;
572 
573  /// The priority of this code-completion string.
574  unsigned Priority : 16;
575 
576  /// The availability of this code-completion result.
577  unsigned Availability : 2;
578 
579  /// The name of the parent context.
580  StringRef ParentName;
581 
582  /// A brief documentation comment attached to the declaration of
583  /// entity being completed by this result.
584  const char *BriefComment;
585 
586  CodeCompletionString(const Chunk *Chunks, unsigned NumChunks,
587  unsigned Priority, CXAvailabilityKind Availability,
588  const char **Annotations, unsigned NumAnnotations,
589  StringRef ParentName,
590  const char *BriefComment);
591  ~CodeCompletionString() = default;
592 
593 public:
594  CodeCompletionString(const CodeCompletionString &) = delete;
596 
597  using iterator = const Chunk *;
598 
599  iterator begin() const { return reinterpret_cast<const Chunk *>(this + 1); }
600  iterator end() const { return begin() + NumChunks; }
601  bool empty() const { return NumChunks == 0; }
602  unsigned size() const { return NumChunks; }
603 
604  const Chunk &operator[](unsigned I) const {
605  assert(I < size() && "Chunk index out-of-range");
606  return begin()[I];
607  }
608 
609  /// Returns the text in the first TypedText chunk.
610  const char *getTypedText() const;
611 
612  /// Returns the combined text from all TypedText chunks.
614 
615  /// Retrieve the priority of this code completion result.
616  unsigned getPriority() const { return Priority; }
617 
618  /// Retrieve the availability of this code completion result.
619  unsigned getAvailability() const { return Availability; }
620 
621  /// Retrieve the number of annotations for this code completion result.
622  unsigned getAnnotationCount() const;
623 
624  /// Retrieve the annotation string specified by \c AnnotationNr.
625  const char *getAnnotation(unsigned AnnotationNr) const;
626 
627  /// Retrieve the name of the parent context.
628  StringRef getParentContextName() const {
629  return ParentName;
630  }
631 
632  const char *getBriefComment() const {
633  return BriefComment;
634  }
635 
636  /// Retrieve a string representation of the code completion string,
637  /// which is mainly useful for debugging.
638  std::string getAsString() const;
639 };
640 
641 /// An allocator used specifically for the purpose of code completion.
642 class CodeCompletionAllocator : public llvm::BumpPtrAllocator {
643 public:
644  /// Copy the given string into this allocator.
645  const char *CopyString(const Twine &String);
646 };
647 
648 /// Allocator for a cached set of global code completions.
650 
652  llvm::DenseMap<const DeclContext *, StringRef> ParentNames;
653  std::shared_ptr<GlobalCodeCompletionAllocator> AllocatorRef;
654 
655 public:
657  std::shared_ptr<GlobalCodeCompletionAllocator> Allocator)
658  : AllocatorRef(std::move(Allocator)) {}
659 
660  std::shared_ptr<GlobalCodeCompletionAllocator> getAllocatorRef() const {
661  return AllocatorRef;
662  }
663 
665  assert(AllocatorRef);
666  return *AllocatorRef;
667  }
668 
669  StringRef getParentName(const DeclContext *DC);
670 };
671 
672 } // namespace clang
673 
674 namespace clang {
675 
676 /// A builder class used to construct new code-completion strings.
678 public:
680 
681 private:
682  CodeCompletionAllocator &Allocator;
683  CodeCompletionTUInfo &CCTUInfo;
684  unsigned Priority = 0;
686  StringRef ParentName;
687  const char *BriefComment = nullptr;
688 
689  /// The chunks stored in this string.
690  SmallVector<Chunk, 4> Chunks;
691 
692  SmallVector<const char *, 2> Annotations;
693 
694 public:
696  CodeCompletionTUInfo &CCTUInfo)
697  : Allocator(Allocator), CCTUInfo(CCTUInfo) {}
698 
700  CodeCompletionTUInfo &CCTUInfo,
701  unsigned Priority, CXAvailabilityKind Availability)
702  : Allocator(Allocator), CCTUInfo(CCTUInfo), Priority(Priority),
703  Availability(Availability) {}
704 
705  /// Retrieve the allocator into which the code completion
706  /// strings should be allocated.
707  CodeCompletionAllocator &getAllocator() const { return Allocator; }
708 
709  CodeCompletionTUInfo &getCodeCompletionTUInfo() const { return CCTUInfo; }
710 
711  /// Take the resulting completion string.
712  ///
713  /// This operation can only be performed once.
715 
716  /// Add a new typed-text chunk.
717  void AddTypedTextChunk(const char *Text);
718 
719  /// Add a new text chunk.
720  void AddTextChunk(const char *Text);
721 
722  /// Add a new optional chunk.
724 
725  /// Add a new placeholder chunk.
726  void AddPlaceholderChunk(const char *Placeholder);
727 
728  /// Add a new informative chunk.
729  void AddInformativeChunk(const char *Text);
730 
731  /// Add a new result-type chunk.
732  void AddResultTypeChunk(const char *ResultType);
733 
734  /// Add a new current-parameter chunk.
735  void AddCurrentParameterChunk(const char *CurrentParameter);
736 
737  /// Add a new chunk.
738  void AddChunk(CodeCompletionString::ChunkKind CK, const char *Text = "");
739 
740  void AddAnnotation(const char *A) { Annotations.push_back(A); }
741 
742  /// Add the parent context information to this code completion.
743  void addParentContext(const DeclContext *DC);
744 
745  const char *getBriefComment() const { return BriefComment; }
746  void addBriefComment(StringRef Comment);
747 
748  StringRef getParentName() const { return ParentName; }
749 };
750 
751 /// Captures a result of code completion.
753 public:
754  /// Describes the kind of result generated.
755  enum ResultKind {
756  /// Refers to a declaration.
758 
759  /// Refers to a keyword or symbol.
761 
762  /// Refers to a macro.
764 
765  /// Refers to a precomputed pattern.
767  };
768 
769  /// When Kind == RK_Declaration or RK_Pattern, the declaration we are
770  /// referring to. In the latter case, the declaration might be NULL.
771  const NamedDecl *Declaration = nullptr;
772 
773  union {
774  /// When Kind == RK_Keyword, the string representing the keyword
775  /// or symbol's spelling.
776  const char *Keyword;
777 
778  /// When Kind == RK_Pattern, the code-completion string that
779  /// describes the completion text to insert.
781 
782  /// When Kind == RK_Macro, the identifier that refers to a macro.
784  };
785 
786  /// The priority of this particular code-completion result.
787  unsigned Priority;
788 
789  /// Specifies which parameter (of a function, Objective-C method,
790  /// macro, etc.) we should start with when formatting the result.
791  unsigned StartParameter = 0;
792 
793  /// The kind of result stored here.
795 
796  /// The cursor kind that describes this result.
798 
799  /// The availability of this result.
801 
802  /// Fix-its that *must* be applied before inserting the text for the
803  /// corresponding completion.
804  ///
805  /// By default, CodeCompletionBuilder only returns completions with empty
806  /// fix-its. Extra completions with non-empty fix-its should be explicitly
807  /// requested by setting CompletionOptions::IncludeFixIts.
808  ///
809  /// For the clients to be able to compute position of the cursor after
810  /// applying fix-its, the following conditions are guaranteed to hold for
811  /// RemoveRange of the stored fix-its:
812  /// - Ranges in the fix-its are guaranteed to never contain the completion
813  /// point (or identifier under completion point, if any) inside them, except
814  /// at the start or at the end of the range.
815  /// - If a fix-it range starts or ends with completion point (or starts or
816  /// ends after the identifier under completion point), it will contain at
817  /// least one character. It allows to unambiguously recompute completion
818  /// point after applying the fix-it.
819  ///
820  /// The intuition is that provided fix-its change code around the identifier
821  /// we complete, but are not allowed to touch the identifier itself or the
822  /// completion point. One example of completions with corrections are the ones
823  /// replacing '.' with '->' and vice versa:
824  ///
825  /// std::unique_ptr<std::vector<int>> vec_ptr;
826  /// In 'vec_ptr.^', one of the completions is 'push_back', it requires
827  /// replacing '.' with '->'.
828  /// In 'vec_ptr->^', one of the completions is 'release', it requires
829  /// replacing '->' with '.'.
830  std::vector<FixItHint> FixIts;
831 
832  /// Whether this result is hidden by another name.
833  bool Hidden : 1;
834 
835  /// Whether this is a class member from base class.
836  bool InBaseClass : 1;
837 
838  /// Whether this result was found via lookup into a base class.
840 
841  /// Whether this declaration is the beginning of a
842  /// nested-name-specifier and, therefore, should be followed by '::'.
844 
845  /// Whether all parameters (of a function, Objective-C
846  /// method, etc.) should be considered "informative".
848 
849  /// Whether we're completing a declaration of the given entity,
850  /// rather than a use of that entity.
851  bool DeclaringEntity : 1;
852 
853  /// When completing a function, whether it can be a call. This will usually be
854  /// true, but we have some heuristics, e.g. when a pointer to a non-static
855  /// member function is completed outside of that class' scope, it can never
856  /// be a call.
858 
859  /// If the result should have a nested-name-specifier, this is it.
860  /// When \c QualifierIsInformative, the nested-name-specifier is
861  /// informative rather than required.
863 
864  /// If this Decl was unshadowed by using declaration, this can store a
865  /// pointer to the UsingShadowDecl which was used in the unshadowing process.
866  /// This information can be used to uprank CodeCompletionResults / which have
867  /// corresponding `using decl::qualified::name;` nearby.
868  const UsingShadowDecl *ShadowDecl = nullptr;
869 
870  /// If the result is RK_Macro, this can store the information about the macro
871  /// definition. This should be set in most cases but can be missing when
872  /// the macro has been undefined.
873  const MacroInfo *MacroDefInfo = nullptr;
874 
875  /// Build a result that refers to a declaration.
877  NestedNameSpecifier *Qualifier = nullptr,
878  bool QualifierIsInformative = false,
879  bool Accessible = true,
880  std::vector<FixItHint> FixIts = std::vector<FixItHint>())
886  // FIXME: Add assert to check FixIts range requirements.
887  computeCursorKindAndAvailability(Accessible);
888  }
889 
890  /// Build a result that refers to a keyword or symbol.
897 
898  /// Build a result that refers to a macro.
900  const MacroInfo *MI = nullptr,
901  unsigned Priority = CCP_Macro)
907 
908  /// Build a result that refers to a pattern.
913  const NamedDecl *D = nullptr)
919 
920  /// Build a result that refers to a pattern with an associated
921  /// declaration.
923  unsigned Priority)
928  computeCursorKindAndAvailability();
929  }
930 
931  /// Retrieve the declaration stored in this result. This might be nullptr if
932  /// Kind is RK_Pattern.
933  const NamedDecl *getDeclaration() const {
934  assert(((Kind == RK_Declaration) || (Kind == RK_Pattern)) &&
935  "Not a declaration or pattern result");
936  return Declaration;
937  }
938 
939  /// Retrieve the keyword stored in this result.
940  const char *getKeyword() const {
941  assert(Kind == RK_Keyword && "Not a keyword result");
942  return Keyword;
943  }
944 
945  /// Create a new code-completion string that describes how to insert
946  /// this result into a program.
947  ///
948  /// \param S The semantic analysis that created the result.
949  ///
950  /// \param Allocator The allocator that will be used to allocate the
951  /// string itself.
953  const CodeCompletionContext &CCContext,
954  CodeCompletionAllocator &Allocator,
955  CodeCompletionTUInfo &CCTUInfo,
956  bool IncludeBriefComments);
958  Preprocessor &PP,
959  const CodeCompletionContext &CCContext,
960  CodeCompletionAllocator &Allocator,
961  CodeCompletionTUInfo &CCTUInfo,
962  bool IncludeBriefComments);
963  /// Creates a new code-completion string for the macro result. Similar to the
964  /// above overloads, except this only requires preprocessor information.
965  /// The result kind must be `RK_Macro`.
968  CodeCompletionAllocator &Allocator,
969  CodeCompletionTUInfo &CCTUInfo);
970 
972  Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result,
973  bool IncludeBriefComments, const CodeCompletionContext &CCContext,
975 
977  Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result,
978  bool IncludeBriefComments, const CodeCompletionContext &CCContext,
980 
981  /// Retrieve the name that should be used to order a result.
982  ///
983  /// If the name needs to be constructed as a string, that string will be
984  /// saved into Saved and the returned StringRef will refer to it.
985  StringRef getOrderedName(std::string &Saved) const;
986 
987 private:
988  void computeCursorKindAndAvailability(bool Accessible = true);
989 };
990 
991 bool operator<(const CodeCompletionResult &X, const CodeCompletionResult &Y);
992 
993 inline bool operator>(const CodeCompletionResult &X,
994  const CodeCompletionResult &Y) {
995  return Y < X;
996 }
997 
998 inline bool operator<=(const CodeCompletionResult &X,
999  const CodeCompletionResult &Y) {
1000  return !(Y < X);
1001 }
1002 
1003 inline bool operator>=(const CodeCompletionResult &X,
1004  const CodeCompletionResult &Y) {
1005  return !(X < Y);
1006 }
1007 
1008 /// Abstract interface for a consumer of code-completion
1009 /// information.
1011 protected:
1013 
1014 public:
1016  public:
1017  /// Describes the type of overload candidate.
1019  /// The candidate is a function declaration.
1021 
1022  /// The candidate is a function template, arguments are being completed.
1024 
1025  /// The "candidate" is actually a variable, expression, or block
1026  /// for which we only have a function prototype.
1028 
1029  /// The candidate is a variable or expression of function type
1030  /// for which we have the location of the prototype declaration.
1032 
1033  /// The candidate is a template, template arguments are being completed.
1035 
1036  /// The candidate is aggregate initialization of a record type.
1038  };
1039 
1040  private:
1041  /// The kind of overload candidate.
1042  CandidateKind Kind;
1043 
1044  union {
1045  /// The function overload candidate, available when
1046  /// Kind == CK_Function.
1048 
1049  /// The function template overload candidate, available when
1050  /// Kind == CK_FunctionTemplate.
1052 
1053  /// The function type that describes the entity being called,
1054  /// when Kind == CK_FunctionType.
1056 
1057  /// The location of the function prototype that describes the entity being
1058  /// called, when Kind == CK_FunctionProtoTypeLoc.
1060 
1061  /// The template overload candidate, available when
1062  /// Kind == CK_Template.
1064 
1065  /// The class being aggregate-initialized,
1066  /// when Kind == CK_Aggregate
1068  };
1069 
1070  public:
1072  : Kind(CK_Function), Function(Function) {
1073  assert(Function != nullptr);
1074  }
1075 
1078  assert(FunctionTemplateDecl != nullptr);
1079  }
1080 
1082  : Kind(CK_FunctionType), Type(Type) {
1083  assert(Type != nullptr);
1084  }
1085 
1088  assert(!Prototype.isNull());
1089  }
1090 
1091  OverloadCandidate(const RecordDecl *Aggregate)
1092  : Kind(CK_Aggregate), AggregateType(Aggregate) {
1093  assert(Aggregate != nullptr);
1094  }
1095 
1097  : Kind(CK_Template), Template(Template) {}
1098 
1099  /// Determine the kind of overload candidate.
1100  CandidateKind getKind() const { return Kind; }
1101 
1102  /// Retrieve the function overload candidate or the templated
1103  /// function declaration for a function template.
1104  FunctionDecl *getFunction() const;
1105 
1106  /// Retrieve the function template overload candidate.
1108  assert(getKind() == CK_FunctionTemplate && "Not a function template");
1109  return FunctionTemplate;
1110  }
1111 
1112  /// Retrieve the function type of the entity, regardless of how the
1113  /// function is stored.
1114  const FunctionType *getFunctionType() const;
1115 
1116  /// Retrieve the function ProtoTypeLoc candidate.
1117  /// This can be called for any Kind, but returns null for kinds
1118  /// other than CK_FunctionProtoTypeLoc.
1120 
1121  const TemplateDecl *getTemplate() const {
1122  assert(getKind() == CK_Template && "Not a template");
1123  return Template;
1124  }
1125 
1126  /// Retrieve the aggregate type being initialized.
1127  const RecordDecl *getAggregate() const {
1128  assert(getKind() == CK_Aggregate);
1129  return AggregateType;
1130  }
1131 
1132  /// Get the number of parameters in this signature.
1133  unsigned getNumParams() const;
1134 
1135  /// Get the type of the Nth parameter.
1136  /// Returns null if the type is unknown or N is out of range.
1137  QualType getParamType(unsigned N) const;
1138 
1139  /// Get the declaration of the Nth parameter.
1140  /// Returns null if the decl is unknown or N is out of range.
1141  const NamedDecl *getParamDecl(unsigned N) const;
1142 
1143  /// Create a new code-completion string that describes the function
1144  /// signature of this overload candidate.
1146  CreateSignatureString(unsigned CurrentArg, Sema &S,
1147  CodeCompletionAllocator &Allocator,
1148  CodeCompletionTUInfo &CCTUInfo,
1149  bool IncludeBriefComments, bool Braced) const;
1150  };
1151 
1154 
1155  /// Whether the code-completion consumer wants to see macros.
1156  bool includeMacros() const {
1158  }
1159 
1160  /// Whether the code-completion consumer wants to see code patterns.
1161  bool includeCodePatterns() const {
1163  }
1164 
1165  /// Whether to include global (top-level) declaration results.
1167 
1168  /// Whether to include declarations in namespace contexts (including
1169  /// the global namespace). If this is false, `includeGlobals()` will be
1170  /// ignored.
1173  }
1174 
1175  /// Whether to include brief documentation comments within the set of
1176  /// code completions returned.
1177  bool includeBriefComments() const {
1179  }
1180 
1181  /// Whether to include completion items with small fix-its, e.g. change
1182  /// '.' to '->' on member access, etc.
1184 
1185  /// Hint whether to load data from the external AST in order to provide
1186  /// full results. If false, declarations from the preamble may be omitted.
1187  bool loadExternal() const {
1189  }
1190 
1191  /// Deregisters and destroys this code-completion consumer.
1192  virtual ~CodeCompleteConsumer();
1193 
1194  /// \name Code-completion filtering
1195  /// Check if the result should be filtered out.
1196  virtual bool isResultFilteredOut(StringRef Filter,
1197  CodeCompletionResult Results) {
1198  return false;
1199  }
1200 
1201  /// \name Code-completion callbacks
1202  //@{
1203  /// Process the finalized code-completion results.
1205  CodeCompletionContext Context,
1206  CodeCompletionResult *Results,
1207  unsigned NumResults) {}
1208 
1209  /// \param S the semantic-analyzer object for which code-completion is being
1210  /// done.
1211  ///
1212  /// \param CurrentArg the index of the current argument.
1213  ///
1214  /// \param Candidates an array of overload candidates.
1215  ///
1216  /// \param NumCandidates the number of overload candidates
1217  ///
1218  /// \param OpenParLoc location of the opening parenthesis of the argument
1219  /// list.
1220  virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg,
1221  OverloadCandidate *Candidates,
1222  unsigned NumCandidates,
1223  SourceLocation OpenParLoc,
1224  bool Braced) {}
1225  //@}
1226 
1227  /// Retrieve the allocator that will be used to allocate
1228  /// code completion strings.
1229  virtual CodeCompletionAllocator &getAllocator() = 0;
1230 
1232 };
1233 
1234 /// Get the documentation comment used to produce
1235 /// CodeCompletionString::BriefComment for RK_Declaration.
1236 const RawComment *getCompletionComment(const ASTContext &Ctx,
1237  const NamedDecl *Decl);
1238 
1239 /// Get the documentation comment used to produce
1240 /// CodeCompletionString::BriefComment for RK_Pattern.
1241 const RawComment *getPatternCompletionComment(const ASTContext &Ctx,
1242  const NamedDecl *Decl);
1243 
1244 /// Get the documentation comment used to produce
1245 /// CodeCompletionString::BriefComment for OverloadCandidate.
1246 const RawComment *
1247 getParameterComment(const ASTContext &Ctx,
1248  const CodeCompleteConsumer::OverloadCandidate &Result,
1249  unsigned ArgIndex);
1250 
1251 /// A simple code-completion consumer that prints the results it
1252 /// receives in a simple format.
1254  /// The raw output stream.
1255  raw_ostream &OS;
1256 
1257  CodeCompletionTUInfo CCTUInfo;
1258 
1259 public:
1260  /// Create a new printing code-completion consumer that prints its
1261  /// results to the given raw output stream.
1263  raw_ostream &OS)
1265  CCTUInfo(std::make_shared<GlobalCodeCompletionAllocator>()) {}
1266 
1267  /// Prints the finalized code-completion results.
1269  CodeCompletionResult *Results,
1270  unsigned NumResults) override;
1271 
1272  void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg,
1273  OverloadCandidate *Candidates,
1274  unsigned NumCandidates,
1275  SourceLocation OpenParLoc,
1276  bool Braced) override;
1277 
1278  bool isResultFilteredOut(StringRef Filter, CodeCompletionResult Results) override;
1279 
1281  return CCTUInfo.getAllocator();
1282  }
1283 
1284  CodeCompletionTUInfo &getCodeCompletionTUInfo() override { return CCTUInfo; }
1285 };
1286 
1287 } // namespace clang
1288 
1289 #endif // LLVM_CLANG_SEMA_CODECOMPLETECONSUMER_H
clang::CodeCompleteConsumer::OverloadCandidate::OverloadCandidate
OverloadCandidate(FunctionDecl *Function)
Definition: CodeCompleteConsumer.h:1071
clang::CodeCompletionContext::CCC_SymbolOrNewName
@ CCC_SymbolOrNewName
Code completion occurred where both a new name and an existing symbol is permissible.
Definition: CodeCompleteConsumer.h:278
clang::CCD_BlockPropertySetter
@ CCD_BlockPropertySetter
An Objective-C block property completed as a setter with a block placeholder.
Definition: CodeCompleteConsumer.h:131
clang::CodeCompleteConsumer::OverloadCandidate::CK_FunctionTemplate
@ CK_FunctionTemplate
The candidate is a function template, arguments are being completed.
Definition: CodeCompleteConsumer.h:1023
clang::CodeCompleteOptions::IncludeMacros
unsigned IncludeMacros
Show macros in code completion results.
Definition: CodeCompleteOptions.h:18
clang::CodeCompletionContext::CCC_Other
@ CCC_Other
An unspecified code-completion context.
Definition: CodeCompleteConsumer.h:191
clang::CodeCompleteConsumer::OverloadCandidate::CK_Function
@ CK_Function
The candidate is a function declaration.
Definition: CodeCompleteConsumer.h:1020
clang::CodeCompleteConsumer::includeCodePatterns
bool includeCodePatterns() const
Whether the code-completion consumer wants to see code patterns.
Definition: CodeCompleteConsumer.h:1161
clang::CodeCompletionBuilder::addParentContext
void addParentContext(const DeclContext *DC)
Add the parent context information to this code completion.
Definition: CodeCompleteConsumer.cpp:476
clang::CodeCompletionResult::Keyword
const char * Keyword
When Kind == RK_Keyword, the string representing the keyword or symbol's spelling.
Definition: CodeCompleteConsumer.h:776
clang::CCP_Unlikely
@ CCP_Unlikely
Priority for a result that isn't likely to be what the user wants, but is included for completeness.
Definition: CodeCompleteConsumer.h:97
clang::CCP_ObjC_cmd
@ CCP_ObjC_cmd
Priority for the Objective-C "_cmd" implicit parameter.
Definition: CodeCompleteConsumer.h:100
clang::CodeCompleteConsumer::OverloadCandidate::OverloadCandidate
OverloadCandidate(const RecordDecl *Aggregate)
Definition: CodeCompleteConsumer.h:1091
clang::CodeCompletionString::getAnnotationCount
unsigned getAnnotationCount() const
Retrieve the number of annotations for this code completion result.
Definition: CodeCompleteConsumer.cpp:303
clang::CodeCompletionString::getPriority
unsigned getPriority() const
Retrieve the priority of this code completion result.
Definition: CodeCompleteConsumer.h:616
clang::CodeCompletionContext::Kind
Kind
Definition: CodeCompleteConsumer.h:189
clang::CodeCompleteConsumer::loadExternal
bool loadExternal() const
Hint whether to load data from the external AST in order to provide full results.
Definition: CodeCompleteConsumer.h:1187
clang::CodeCompletionContext::CodeCompletionContext
CodeCompletionContext(Kind CCKind)
Construct a new code-completion context of the given kind.
Definition: CodeCompleteConsumer.h:370
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::DeclContext
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1389
clang::CodeCompleteConsumer::includeNamespaceLevelDecls
bool includeNamespaceLevelDecls() const
Whether to include declarations in namespace contexts (including the global namespace).
Definition: CodeCompleteConsumer.h:1171
clang::CodeCompletionBuilder::TakeString
CodeCompletionString * TakeString()
Take the resulting completion string.
Definition: CodeCompleteConsumer.cpp:430
clang::CodeCompletionContext::CCC_ObjCInstanceMessage
@ CCC_ObjCInstanceMessage
Code completion where an Objective-C instance message is expected.
Definition: CodeCompleteConsumer.h:317
clang::CodeCompletionContext::CCC_Expression
@ CCC_Expression
Code completion occurred where an expression is expected.
Definition: CodeCompleteConsumer.h:221
clang::CodeCompletionResult::CodeCompletionResult
CodeCompletionResult(const IdentifierInfo *Macro, const MacroInfo *MI=nullptr, unsigned Priority=CCP_Macro)
Build a result that refers to a macro.
Definition: CodeCompleteConsumer.h:899
clang::CodeCompletionBuilder::AddOptionalChunk
void AddOptionalChunk(CodeCompletionString *Optional)
Add a new optional chunk.
Definition: CodeCompleteConsumer.cpp:450
clang::CodeCompletionAllocator::CopyString
const char * CopyString(const Twine &String)
Copy the given string into this allocator.
Definition: CodeCompleteConsumer.cpp:358
clang::PrintingCodeCompleteConsumer::isResultFilteredOut
bool isResultFilteredOut(StringRef Filter, CodeCompletionResult Results) override
Definition: CodeCompleteConsumer.cpp:623
clang::CodeCompletionResult::FunctionCanBeCall
bool FunctionCanBeCall
When completing a function, whether it can be a call.
Definition: CodeCompleteConsumer.h:857
clang::PrintingCodeCompleteConsumer
A simple code-completion consumer that prints the results it receives in a simple format.
Definition: CodeCompleteConsumer.h:1253
llvm::SmallVector
Definition: LLVM.h:38
clang::STC_Pointer
@ STC_Pointer
Definition: CodeCompleteConsumer.h:156
clang::CodeCompleteConsumer::OverloadCandidate::OverloadCandidate
OverloadCandidate(FunctionTemplateDecl *FunctionTemplateDecl)
Definition: CodeCompleteConsumer.h:1076
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:86
clang::CodeCompleteConsumer::includeGlobals
bool includeGlobals() const
Whether to include global (top-level) declaration results.
Definition: CodeCompleteConsumer.h:1166
clang::CodeCompleteOptions::IncludeBriefComments
unsigned IncludeBriefComments
Show brief documentation comments in code completion results.
Definition: CodeCompleteOptions.h:35
clang::CodeCompletionContext::CCC_Type
@ CCC_Type
Code completion occurred where a type name is expected.
Definition: CodeCompleteConsumer.h:271
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:247
clang::CodeCompleteOptions::IncludeFixIts
unsigned IncludeFixIts
Include results after corrections (small fix-its), e.g.
Definition: CodeCompleteOptions.h:44
clang::CodeCompletionContext::CCC_ObjCImplementation
@ CCC_ObjCImplementation
Code completion occurred within an Objective-C implementation or category implementation.
Definition: CodeCompleteConsumer.h:207
clang::CodeCompletionResult::CreateCodeCompletionString
CodeCompletionString * CreateCodeCompletionString(Sema &S, const CodeCompletionContext &CCContext, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, bool IncludeBriefComments)
Create a new code-completion string that describes how to insert this result into a program.
Definition: SemaCodeComplete.cpp:3322
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:737
clang::CodeCompletionBuilder::AddChunk
void AddChunk(CodeCompletionString::ChunkKind CK, const char *Text="")
Add a new chunk.
Definition: CodeCompleteConsumer.cpp:471
clang::CodeCompletionString::CK_Text
@ CK_Text
A piece of text that should be placed in the buffer, e.g., parentheses or a comma in a function call.
Definition: CodeCompleteConsumer.h:454
AttributeLangSupport::C
@ C
Definition: SemaDeclAttr.cpp:56
clang::NestedNameSpecifier
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
Definition: NestedNameSpecifier.h:50
clang::tooling::Filter
llvm::cl::opt< std::string > Filter
clang::CodeCompletionResult::CreateCodeCompletionStringForMacro
CodeCompletionString * CreateCodeCompletionStringForMacro(Preprocessor &PP, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo)
Creates a new code-completion string for the macro result.
Definition: SemaCodeComplete.cpp:3330
clang::CodeCompleteConsumer::OverloadCandidate::getFunctionType
const FunctionType * getFunctionType() const
Retrieve the function type of the entity, regardless of how the function is stored.
Definition: CodeCompleteConsumer.cpp:506
clang::CodeCompleteConsumer::OverloadCandidate::getAggregate
const RecordDecl * getAggregate() const
Retrieve the aggregate type being initialized.
Definition: CodeCompleteConsumer.h:1127
clang::CodeCompletionBuilder::getCodeCompletionTUInfo
CodeCompletionTUInfo & getCodeCompletionTUInfo() const
Definition: CodeCompleteConsumer.h:709
clang::CodeCompleteConsumer::OverloadCandidate::getKind
CandidateKind getKind() const
Determine the kind of overload candidate.
Definition: CodeCompleteConsumer.h:1100
clang::CodeCompleteConsumer::OverloadCandidate::Template
const TemplateDecl * Template
The template overload candidate, available when Kind == CK_Template.
Definition: CodeCompleteConsumer.h:1063
Index.h
clang::CodeCompletionString::empty
bool empty() const
Definition: CodeCompleteConsumer.h:601
clang::CodeCompletionString::CK_RightParen
@ CK_RightParen
A right parenthesis (')').
Definition: CodeCompleteConsumer.h:481
clang::UsingShadowDecl
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition: DeclCXX.h:3222
clang::CodeCompleteConsumer::getCodeCompletionTUInfo
virtual CodeCompletionTUInfo & getCodeCompletionTUInfo()=0
clang::CCF_SimilarTypeMatch
@ CCF_SimilarTypeMatch
Divide by this factor when a code-completion result's type is similar to the type we expect (e....
Definition: CodeCompleteConsumer.h:144
clang::CodeCompletionBuilder::getBriefComment
const char * getBriefComment() const
Definition: CodeCompleteConsumer.h:745
clang::CodeCompletionString::CK_TypedText
@ CK_TypedText
The piece of text that the user is expected to type to match the code-completion string,...
Definition: CodeCompleteConsumer.h:450
llvm::Optional
Definition: LLVM.h:40
clang::CodeCompleteConsumer::OverloadCandidate::getParamDecl
const NamedDecl * getParamDecl(unsigned N) const
Get the declaration of the Nth parameter.
Definition: CodeCompleteConsumer.cpp:584
clang::CCP_NextInitializer
@ CCP_NextInitializer
Priority for the next initialization in a constructor initializer list.
Definition: CodeCompleteConsumer.h:57
clang::CodeCompletionContext::CCC_IncludedFile
@ CCC_IncludedFile
Code completion inside the filename part of a include directive.
Definition: CodeCompleteConsumer.h:330
clang::CodeCompletionResult::Pattern
CodeCompletionString * Pattern
When Kind == RK_Pattern, the code-completion string that describes the completion text to insert.
Definition: CodeCompleteConsumer.h:780
llvm::SmallPtrSet< DeclContext *, 8 >
clang::MacroInfo
Encapsulates the data about a macro definition (e.g.
Definition: MacroInfo.h:39
clang::CodeCompletionResult::RK_Keyword
@ RK_Keyword
Refers to a keyword or symbol.
Definition: CodeCompleteConsumer.h:760
clang::CodeCompletionString::Chunk::Chunk
Chunk()
Definition: CodeCompleteConsumer.h:540
DeclSpec.h
clang::CodeCompletionResult::Priority
unsigned Priority
The priority of this particular code-completion result.
Definition: CodeCompleteConsumer.h:787
clang::CodeCompletionString::CK_VerticalSpace
@ CK_VerticalSpace
Vertical whitespace ('\n' or '\r\n', depending on the platform).
Definition: CodeCompleteConsumer.h:518
clang::tooling::X
static ToolExecutorPluginRegistry::Add< AllTUsToolExecutorPlugin > X("all-TUs", "Runs FrontendActions on all TUs in the compilation database. " "Tool results are stored in memory.")
clang::CXXScopeSpec
Represents a C++ nested-name-specifier or a global scope specifier.
Definition: DeclSpec.h:65
clang::CodeCompleteConsumer::OverloadCandidate::CandidateKind
CandidateKind
Describes the type of overload candidate.
Definition: CodeCompleteConsumer.h:1018
clang::STC_Void
@ STC_Void
Definition: CodeCompleteConsumer.h:158
clang::PrintingPolicy
Describes how types, statements, expressions, and declarations should be printed.
Definition: PrettyPrinter.h:57
clang::CCP_LocalDeclaration
@ CCP_LocalDeclaration
Priority for a declaration that is in the local scope.
Definition: CodeCompleteConsumer.h:67
clang::CCP_Constant
@ CCP_Constant
Priority for a constant value (e.g., enumerator).
Definition: CodeCompleteConsumer.h:87
clang::CodeCompletionResult::StartsNestedNameSpecifier
bool StartsNestedNameSpecifier
Whether this declaration is the beginning of a nested-name-specifier and, therefore,...
Definition: CodeCompleteConsumer.h:843
clang::CodeCompleteConsumer::OverloadCandidate::ProtoTypeLoc
FunctionProtoTypeLoc ProtoTypeLoc
The location of the function prototype that describes the entity being called, when Kind == CK_Functi...
Definition: CodeCompleteConsumer.h:1059
clang::CCP_Macro
@ CCP_Macro
Priority for a preprocessor macro.
Definition: CodeCompleteConsumer.h:90
clang::CCP_NestedNameSpecifier
@ CCP_NestedNameSpecifier
Priority for a nested-name-specifier.
Definition: CodeCompleteConsumer.h:93
clang::CodeCompletionBuilder::AddTypedTextChunk
void AddTypedTextChunk(const char *Text)
Add a new typed-text chunk.
Definition: CodeCompleteConsumer.cpp:442
clang::FunctionType
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:3675
clang::getMacroUsagePriority
unsigned getMacroUsagePriority(StringRef MacroName, const LangOptions &LangOpts, bool PreferredTypeIsPointer=false)
Determine the priority to be given to a macro code completion result with the given name.
Definition: SemaCodeComplete.cpp:3965
clang::CodeCompletionString::CK_HorizontalSpace
@ CK_HorizontalSpace
Horizontal whitespace (' ').
Definition: CodeCompleteConsumer.h:514
clang::CodeCompletionContext::getBaseType
QualType getBaseType() const
Retrieve the type of the base object in a member-access expression.
Definition: CodeCompleteConsumer.h:399
clang::CodeCompleteConsumer::OverloadCandidate::FunctionTemplate
FunctionTemplateDecl * FunctionTemplate
The function template overload candidate, available when Kind == CK_FunctionTemplate.
Definition: CodeCompleteConsumer.h:1051
clang::getPatternCompletionComment
const RawComment * getPatternCompletionComment(const ASTContext &Ctx, const NamedDecl *Decl)
Get the documentation comment used to produce CodeCompletionString::BriefComment for RK_Pattern.
Definition: SemaCodeComplete.cpp:3701
clang::CCD_SelectorMatch
@ CCD_SelectorMatch
The selector of the given message exactly matches the selector of the current method,...
Definition: CodeCompleteConsumer.h:116
clang::CodeCompletionString::end
iterator end() const
Definition: CodeCompleteConsumer.h:600
clang::CodeCompletionString::CK_ResultType
@ CK_ResultType
A piece of text that describes the type of an entity or, for functions and methods,...
Definition: CodeCompleteConsumer.h:470
clang::STC_Block
@ STC_Block
Definition: CodeCompleteConsumer.h:152
clang::CodeCompleteConsumer::OverloadCandidate::CK_FunctionProtoTypeLoc
@ CK_FunctionProtoTypeLoc
The candidate is a variable or expression of function type for which we have the location of the prot...
Definition: CodeCompleteConsumer.h:1031
clang::CodeCompletionResult
Captures a result of code completion.
Definition: CodeCompleteConsumer.h:752
clang::CodeCompleteConsumer::OverloadCandidate::getFunctionProtoTypeLoc
const FunctionProtoTypeLoc getFunctionProtoTypeLoc() const
Retrieve the function ProtoTypeLoc candidate.
Definition: CodeCompleteConsumer.cpp:529
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1565
clang::CodeCompleteConsumer::OverloadCandidate::CK_Aggregate
@ CK_Aggregate
The candidate is aggregate initialization of a record type.
Definition: CodeCompleteConsumer.h:1037
clang::CodeCompletionString::ChunkKind
ChunkKind
The different kinds of "chunks" that can occur within a code completion string.
Definition: CodeCompleteConsumer.h:446
clang::CodeCompleteConsumer::OverloadCandidate::getFunctionTemplate
FunctionTemplateDecl * getFunctionTemplate() const
Retrieve the function template overload candidate.
Definition: CodeCompleteConsumer.h:1107
clang::CodeGen::AlignmentSource::Decl
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
clang::CodeCompletionContext::CCC_ObjCCategoryName
@ CCC_ObjCCategoryName
Code completion where an Objective-C category name is expected.
Definition: CodeCompleteConsumer.h:327
clang::STC_Array
@ STC_Array
Definition: CodeCompleteConsumer.h:151
clang::CodeCompletionBuilder::CodeCompletionBuilder
CodeCompletionBuilder(CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo)
Definition: CodeCompleteConsumer.h:695
clang::CodeCompletionContext::CCC_TopLevel
@ CCC_TopLevel
Code completion occurred within a "top-level" completion context, e.g., at namespace or global scope.
Definition: CodeCompleteConsumer.h:199
clang::FunctionTemplateDecl
Declaration of a template function.
Definition: DeclTemplate.h:1006
clang::CodeCompletionString::CK_LeftAngle
@ CK_LeftAngle
A left angle bracket ('<').
Definition: CodeCompleteConsumer.h:496
clang::CodeCompleteConsumer::OverloadCandidate::AggregateType
const RecordDecl * AggregateType
The class being aggregate-initialized, when Kind == CK_Aggregate.
Definition: CodeCompleteConsumer.h:1067
V
#define V(N, I)
Definition: ASTContext.h:3237
clang::CCD_ObjectQualifierMatch
@ CCD_ObjectQualifierMatch
The result is a C++ non-static member function whose qualifiers exactly match the object type on whic...
Definition: CodeCompleteConsumer.h:111
clang::CodeCompletionResult::ShadowDecl
const UsingShadowDecl * ShadowDecl
If this Decl was unshadowed by using declaration, this can store a pointer to the UsingShadowDecl whi...
Definition: CodeCompleteConsumer.h:868
clang::operator>
bool operator>(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
Definition: DeclarationName.h:555
clang::CodeCompletionBuilder::AddCurrentParameterChunk
void AddCurrentParameterChunk(const char *CurrentParameter)
Add a new current-parameter chunk.
Definition: CodeCompleteConsumer.cpp:466
clang::CodeCompletionResult::Availability
CXAvailabilityKind Availability
The availability of this result.
Definition: CodeCompleteConsumer.h:800
clang::CodeCompleteOptions::IncludeGlobals
unsigned IncludeGlobals
Show top-level decls in code completion results.
Definition: CodeCompleteOptions.h:24
clang::CodeCompletionContext::CCC_Recovery
@ CCC_Recovery
An unknown context, in which we are recovering from a parsing error and don't know which completions ...
Definition: CodeCompleteConsumer.h:337
clang::CodeCompletionString::CK_RightBracket
@ CK_RightBracket
A right bracket (']').
Definition: CodeCompleteConsumer.h:487
clang::CodeCompletionContext::CCC_ObjCProtocolName
@ CCC_ObjCProtocolName
Code completion occurred where a protocol name is expected.
Definition: CodeCompleteConsumer.h:264
clang::CCP_Keyword
@ CCP_Keyword
Priority for a language keyword (that isn't any of the other categories).
Definition: CodeCompleteConsumer.h:75
clang::CodeCompletionContext::CCC_EnumTag
@ CCC_EnumTag
Code completion occurred after the "enum" keyword, to indicate an enumeration name.
Definition: CodeCompleteConsumer.h:253
CodeCompleteOptions.h
clang::CodeCompletionString::Chunk::CreateOptional
static Chunk CreateOptional(CodeCompletionString *Optional)
Create a new optional chunk.
Definition: CodeCompleteConsumer.cpp:256
clang::CodeCompleteOptions::IncludeCodePatterns
unsigned IncludeCodePatterns
Show code patterns in code completion results.
Definition: CodeCompleteOptions.h:21
clang::CodeCompletionBuilder
A builder class used to construct new code-completion strings.
Definition: CodeCompleteConsumer.h:677
clang::CCP_EnumInCase
@ CCP_EnumInCase
Priority for an enumeration constant inside a switch whose condition is of the enumeration type.
Definition: CodeCompleteConsumer.h:61
CXCursor_NotImplemented
@ CXCursor_NotImplemented
Definition: Index.h:1236
clang::CodeCompletionResult::CodeCompletionResult
CodeCompletionResult(CodeCompletionString *Pattern, const NamedDecl *D, unsigned Priority)
Build a result that refers to a pattern with an associated declaration.
Definition: CodeCompleteConsumer.h:922
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:209
clang::CodeCompletionContext::CCC_ArrowMemberAccess
@ CCC_ArrowMemberAccess
Code completion occurred on the right-hand side of a member access expression using the arrow operato...
Definition: CodeCompleteConsumer.h:241
clang::CodeCompletionContext::CCC_Symbol
@ CCC_Symbol
Code completion occurred where an existing name(such as type, function or variable) is expected.
Definition: CodeCompleteConsumer.h:282
clang::CodeCompletionBuilder::AddTextChunk
void AddTextChunk(const char *Text)
Add a new text chunk.
Definition: CodeCompleteConsumer.cpp:446
clang::CodeCompletionString::Chunk::CreateResultType
static Chunk CreateResultType(const char *ResultType)
Create a new result type chunk.
Definition: CodeCompleteConsumer.cpp:274
clang::CodeCompletionString::getParentContextName
StringRef getParentContextName() const
Retrieve the name of the parent context.
Definition: CodeCompleteConsumer.h:628
clang::PrintingCodeCompleteConsumer::getCodeCompletionTUInfo
CodeCompletionTUInfo & getCodeCompletionTUInfo() override
Definition: CodeCompleteConsumer.h:1284
clang::CodeCompleteConsumer::OverloadCandidate::OverloadCandidate
OverloadCandidate(FunctionProtoTypeLoc Prototype)
Definition: CodeCompleteConsumer.h:1086
clang::CodeCompleteConsumer::isResultFilteredOut
virtual bool isResultFilteredOut(StringRef Filter, CodeCompletionResult Results)
Definition: CodeCompleteConsumer.h:1196
clang::CodeCompleteConsumer::OverloadCandidate::Function
FunctionDecl * Function
The function overload candidate, available when Kind == CK_Function.
Definition: CodeCompleteConsumer.h:1047
clang::CanQualType
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
Definition: CanonicalType.h:212
clang::RISCV::Policy
Policy
Definition: RISCVVIntrinsicUtils.h:96
clang::CodeCompletionContext::CCC_ObjCInterfaceName
@ CCC_ObjCInterfaceName
Code completion where the name of an Objective-C class is expected.
Definition: CodeCompleteConsumer.h:324
clang::CodeCompletionString::CK_Informative
@ CK_Informative
A piece of text that describes something about the result but should not be inserted into the buffer.
Definition: CodeCompleteConsumer.h:467
Type.h
clang::CodeCompletionContext::CCC_Attribute
@ CCC_Attribute
Code completion of an attribute name.
Definition: CodeCompleteConsumer.h:333
clang::CodeCompletionContext::setCXXScopeSpecifier
void setCXXScopeSpecifier(CXXScopeSpec SS)
Sets the scope specifier that comes before the completion token.
Definition: CodeCompleteConsumer.h:411
clang::CodeCompletionString::CK_LeftParen
@ CK_LeftParen
A left parenthesis ('(').
Definition: CodeCompleteConsumer.h:478
clang::CodeCompleteConsumer::OverloadCandidate::CK_FunctionType
@ CK_FunctionType
The "candidate" is actually a variable, expression, or block for which we only have a function protot...
Definition: CodeCompleteConsumer.h:1027
clang::CodeCompletionString::Chunk::Optional
CodeCompletionString * Optional
The code completion string associated with a CK_Optional chunk.
Definition: CodeCompleteConsumer.h:537
clang::CodeCompletionContext::CCC_ObjCMessageReceiver
@ CCC_ObjCMessageReceiver
Code completion occurred where an Objective-C message receiver is expected.
Definition: CodeCompleteConsumer.h:225
clang::CodeCompletionResult::MacroDefInfo
const MacroInfo * MacroDefInfo
If the result is RK_Macro, this can store the information about the macro definition.
Definition: CodeCompleteConsumer.h:873
clang::CodeCompletionResult::QualifierIsInformative
bool QualifierIsInformative
Whether this result was found via lookup into a base class.
Definition: CodeCompleteConsumer.h:839
clang::CodeCompletionContext::setPreferredType
void setPreferredType(QualType T)
Definition: CodeCompleteConsumer.h:395
clang::CCD_bool_in_ObjC
@ CCD_bool_in_ObjC
Adjustment to the "bool" type in Objective-C, where the typedef "BOOL" is preferred.
Definition: CodeCompleteConsumer.h:120
clang::CodeCompletionBuilder::getAllocator
CodeCompletionAllocator & getAllocator() const
Retrieve the allocator into which the code completion strings should be allocated.
Definition: CodeCompleteConsumer.h:707
clang::CodeCompletionString::operator=
CodeCompletionString & operator=(const CodeCompletionString &)=delete
clang::getParameterComment
const RawComment * getParameterComment(const ASTContext &Ctx, const CodeCompleteConsumer::OverloadCandidate &Result, unsigned ArgIndex)
Get the documentation comment used to produce CodeCompletionString::BriefComment for OverloadCandidat...
Definition: SemaCodeComplete.cpp:3724
clang::CodeCompleteConsumer::OverloadCandidate::OverloadCandidate
OverloadCandidate(const TemplateDecl *Template)
Definition: CodeCompleteConsumer.h:1096
clang::CodeCompletionResult::StartParameter
unsigned StartParameter
Specifies which parameter (of a function, Objective-C method, macro, etc.) we should start with when ...
Definition: CodeCompleteConsumer.h:791
clang::CCF_ExactTypeMatch
@ CCF_ExactTypeMatch
Divide by this factor when a code-completion result's type exactly matches the type we expect.
Definition: CodeCompleteConsumer.h:139
clang::CodeCompletionString::getAsString
std::string getAsString() const
Retrieve a string representation of the code completion string, which is mainly useful for debugging.
Definition: CodeCompleteConsumer.cpp:314
clang::CodeCompletionString::getAllTypedText
std::string getAllTypedText() const
Returns the combined text from all TypedText chunks.
Definition: CodeCompleteConsumer.cpp:349
clang::CodeCompletionString
A "string" used to describe how code completion can be performed for an entity.
Definition: CodeCompleteConsumer.h:442
clang::CodeCompletionString::Chunk::CreateCurrentParameter
static Chunk CreateCurrentParameter(const char *CurrentParameter)
Create a new current-parameter chunk.
Definition: CodeCompleteConsumer.cpp:278
clang::CodeCompleteConsumer::includeMacros
bool includeMacros() const
Whether the code-completion consumer wants to see macros.
Definition: CodeCompleteConsumer.h:1156
clang::CodeCompleteConsumer::ProcessCodeCompleteResults
virtual void ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context, CodeCompletionResult *Results, unsigned NumResults)
Process the finalized code-completion results.
Definition: CodeCompleteConsumer.h:1204
clang::CodeCompletionContext::CCC_OtherWithMacros
@ CCC_OtherWithMacros
An unspecified code-completion context where we should also add macro completions.
Definition: CodeCompleteConsumer.h:195
clang::CodeCompletionResult::createCodeCompletionStringForOverride
CodeCompletionString * createCodeCompletionStringForOverride(Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result, bool IncludeBriefComments, const CodeCompletionContext &CCContext, PrintingPolicy &Policy)
Definition: SemaCodeComplete.cpp:3438
clang::CodeCompletionBuilder::AddResultTypeChunk
void AddResultTypeChunk(const char *ResultType)
Add a new result-type chunk.
Definition: CodeCompleteConsumer.cpp:462
clang::CodeCompletionContext::CCC_Namespace
@ CCC_Namespace
Code completion occurred where a namespace or namespace alias is expected.
Definition: CodeCompleteConsumer.h:268
clang::CodeCompletionResult::RK_Macro
@ RK_Macro
Refers to a macro.
Definition: CodeCompleteConsumer.h:763
clang::CodeCompletionString::begin
iterator begin() const
Definition: CodeCompleteConsumer.h:599
clang::CodeCompleteOptions::IncludeNamespaceLevelDecls
unsigned IncludeNamespaceLevelDecls
Show decls in namespace (including the global namespace) in code completion results.
Definition: CodeCompleteOptions.h:32
clang::PrintingCodeCompleteConsumer::ProcessOverloadCandidates
void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg, OverloadCandidate *Candidates, unsigned NumCandidates, SourceLocation OpenParLoc, bool Braced) override
Definition: CodeCompleteConsumer.cpp:748
clang::CodeCompletionString::operator[]
const Chunk & operator[](unsigned I) const
Definition: CodeCompleteConsumer.h:604
clang::CodeCompleteConsumer::OverloadCandidate
Definition: CodeCompleteConsumer.h:1015
clang::getSimplifiedTypeClass
SimplifiedTypeClass getSimplifiedTypeClass(CanQualType T)
Determine the simplified type class of the given canonical type.
Definition: SemaCodeComplete.cpp:842
clang::CodeCompletionResult::Declaration
const NamedDecl * Declaration
When Kind == RK_Declaration or RK_Pattern, the declaration we are referring to.
Definition: CodeCompleteConsumer.h:771
clang::PrintingCodeCompleteConsumer::PrintingCodeCompleteConsumer
PrintingCodeCompleteConsumer(const CodeCompleteOptions &CodeCompleteOpts, raw_ostream &OS)
Create a new printing code-completion consumer that prints its results to the given raw output stream...
Definition: CodeCompleteConsumer.h:1262
clang::CCP_SuperCompletion
@ CCP_SuperCompletion
Priority for a send-to-super completion.
Definition: CodeCompleteConsumer.h:64
clang::CodeCompletionString::CK_RightBrace
@ CK_RightBrace
A right brace ('}').
Definition: CodeCompleteConsumer.h:493
clang::CodeCompletionTUInfo::getAllocatorRef
std::shared_ptr< GlobalCodeCompletionAllocator > getAllocatorRef() const
Definition: CodeCompleteConsumer.h:660
clang::CCP_CodePattern
@ CCP_CodePattern
Priority for a code pattern.
Definition: CodeCompleteConsumer.h:78
clang::CodeCompletionContext::CCC_ObjCPropertyAccess
@ CCC_ObjCPropertyAccess
Code completion occurred on the right-hand side of an Objective-C property access expression.
Definition: CodeCompleteConsumer.h:249
clang::CodeCompletionString::Chunk::Kind
ChunkKind Kind
The kind of data stored in this piece of the code completion string.
Definition: CodeCompleteConsumer.h:525
clang::CodeCompletionString::CK_SemiColon
@ CK_SemiColon
A semicolon (';').
Definition: CodeCompleteConsumer.h:508
clang::operator<=
bool operator<=(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
Definition: DeclarationName.h:561
clang::CodeCompletionContext::getCXXScopeSpecifier
llvm::Optional< const CXXScopeSpec * > getCXXScopeSpecifier()
Definition: CodeCompleteConsumer.h:425
false
#define false
Definition: stdbool.h:22
clang::CodeCompletionContext::CCC_PreprocessorExpression
@ CCC_PreprocessorExpression
Code completion occurred within a preprocessor expression.
Definition: CodeCompleteConsumer.h:292
clang::CodeCompletionBuilder::AddAnnotation
void AddAnnotation(const char *A)
Definition: CodeCompleteConsumer.h:740
clang::CodeCompletionContext::getKind
Kind getKind() const
Retrieve the kind of code-completion context.
Definition: CodeCompleteConsumer.h:389
CXCursor_MacroDefinition
@ CXCursor_MacroDefinition
Definition: Index.h:2048
CXAvailability_Available
@ CXAvailability_Available
The entity is available.
Definition: Index.h:130
CXAvailabilityKind
CXAvailabilityKind
Describes the availability of a particular entity, which indicates whether the use of this entity wil...
Definition: Index.h:126
clang::CodeCompletionResult::Qualifier
NestedNameSpecifier * Qualifier
If the result should have a nested-name-specifier, this is it.
Definition: CodeCompleteConsumer.h:862
clang::TemplateDecl
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:408
clang::CodeCompletionString::getTypedText
const char * getTypedText() const
Returns the text in the first TypedText chunk.
Definition: CodeCompleteConsumer.cpp:341
llvm::ArrayRef
Definition: LLVM.h:34
clang::CodeCompletionContext::CCC_PreprocessorDirective
@ CCC_PreprocessorDirective
Code completion occurred where a preprocessor directive is expected.
Definition: CodeCompleteConsumer.h:296
clang::CodeCompleteConsumer::includeFixIts
bool includeFixIts() const
Whether to include completion items with small fix-its, e.g.
Definition: CodeCompleteConsumer.h:1183
clang::CodeCompletionContext::isUsingDeclaration
bool isUsingDeclaration() const
Definition: CodeCompleteConsumer.h:385
CXCursorKind
CXCursorKind
Describes the kind of entity that a cursor refers to.
Definition: Index.h:1038
clang::OverloadCandidate
OverloadCandidate - A single candidate in an overload set (C++ 13.3).
Definition: Overload.h:821
clang::PrintingCodeCompleteConsumer::ProcessCodeCompleteResults
void ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context, CodeCompletionResult *Results, unsigned NumResults) override
Prints the finalized code-completion results.
Definition: CodeCompleteConsumer.cpp:640
clang::CodeCompletionString::CK_Equal
@ CK_Equal
An '=' sign.
Definition: CodeCompleteConsumer.h:511
clang::Sema
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:358
LLVM.h
clang::CodeCompletionResult::getKeyword
const char * getKeyword() const
Retrieve the keyword stored in this result.
Definition: CodeCompleteConsumer.h:940
clang::CodeCompletionContext::CCC_ClassStructUnion
@ CCC_ClassStructUnion
Code completion occurred within a class, struct, or union.
Definition: CodeCompleteConsumer.h:214
clang::CodeCompletionContext::CCC_Statement
@ CCC_Statement
Code completion occurred where a statement (or declaration) is expected in a function,...
Definition: CodeCompleteConsumer.h:218
clang::CodeCompleteConsumer
Abstract interface for a consumer of code-completion information.
Definition: CodeCompleteConsumer.h:1010
clang::CodeCompletionContext::CCC_DotMemberAccess
@ CCC_DotMemberAccess
Code completion occurred on the right-hand side of a member access expression using the dot operator.
Definition: CodeCompleteConsumer.h:233
clang::CodeCompletionResult::Hidden
bool Hidden
Whether this result is hidden by another name.
Definition: CodeCompleteConsumer.h:833
clang::CodeCompletionString::getAvailability
unsigned getAvailability() const
Retrieve the availability of this code completion result.
Definition: CodeCompleteConsumer.h:619
clang::CodeCompletionResult::CodeCompletionResult
CodeCompletionResult(CodeCompletionString *Pattern, unsigned Priority=CCP_CodePattern, CXCursorKind CursorKind=CXCursor_NotImplemented, CXAvailabilityKind Availability=CXAvailability_Available, const NamedDecl *D=nullptr)
Build a result that refers to a pattern.
Definition: CodeCompleteConsumer.h:909
clang::CodeCompleteConsumer::OverloadCandidate::CreateSignatureString
CodeCompletionString * CreateSignatureString(unsigned CurrentArg, Sema &S, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, bool IncludeBriefComments, bool Braced) const
Create a new code-completion string that describes the function signature of this overload candidate.
Definition: SemaCodeComplete.cpp:3908
clang::CodeCompletionResult::createCodeCompletionStringForDecl
CodeCompletionString * createCodeCompletionStringForDecl(Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result, bool IncludeBriefComments, const CodeCompletionContext &CCContext, PrintingPolicy &Policy)
Definition: SemaCodeComplete.cpp:3469
clang::CodeCompletionResult::Macro
const IdentifierInfo * Macro
When Kind == RK_Macro, the identifier that refers to a macro.
Definition: CodeCompleteConsumer.h:783
clang::CCP_Declaration
@ CCP_Declaration
Priority for a non-type declaration.
Definition: CodeCompleteConsumer.h:81
clang::CodeCompletionString::CK_CurrentParameter
@ CK_CurrentParameter
A piece of text that describes the parameter that corresponds to the code-completion location within ...
Definition: CodeCompleteConsumer.h:475
clang::CodeCompletionResult::getDeclaration
const NamedDecl * getDeclaration() const
Retrieve the declaration stored in this result.
Definition: CodeCompleteConsumer.h:933
clang::CodeCompletionString::getAnnotation
const char * getAnnotation(unsigned AnnotationNr) const
Retrieve the annotation string specified by AnnotationNr.
Definition: CodeCompleteConsumer.cpp:307
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:85
clang::DeclaratorContext::Prototype
@ Prototype
clang::SimplifiedTypeClass
SimplifiedTypeClass
A simplified classification of types used when determining "similar" types for code completion.
Definition: CodeCompleteConsumer.h:149
clang::STC_Function
@ STC_Function
Definition: CodeCompleteConsumer.h:153
Priority
int Priority
Definition: Format.cpp:2719
clang::CodeCompleteConsumer::CodeCompleteOpts
const CodeCompleteOptions CodeCompleteOpts
Definition: CodeCompleteConsumer.h:1012
clang::STC_Other
@ STC_Other
Definition: CodeCompleteConsumer.h:155
clang::CodeCompletionString::CK_LeftBracket
@ CK_LeftBracket
A left bracket ('[').
Definition: CodeCompleteConsumer.h:484
clang::CodeCompletionContext::CodeCompletionContext
CodeCompletionContext(Kind CCKind, QualType T, ArrayRef< IdentifierInfo * > SelIdents=None)
Construct a new code-completion context of the given kind.
Definition: CodeCompleteConsumer.h:374
clang::ObjCPropertyAttribute::Kind
Kind
Definition: DeclObjCCommon.h:22
clang::CodeCompleteConsumer::includeBriefComments
bool includeBriefComments() const
Whether to include brief documentation comments within the set of code completions returned.
Definition: CodeCompleteConsumer.h:1177
clang::CodeCompletionString::getBriefComment
const char * getBriefComment() const
Definition: CodeCompleteConsumer.h:632
clang::CodeCompletionResult::RK_Pattern
@ RK_Pattern
Refers to a precomputed pattern.
Definition: CodeCompleteConsumer.h:766
clang::CodeCompletionResult::ResultKind
ResultKind
Describes the kind of result generated.
Definition: CodeCompleteConsumer.h:755
clang::CodeCompletionBuilder::CodeCompletionBuilder
CodeCompletionBuilder(CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, unsigned Priority, CXAvailabilityKind Availability)
Definition: CodeCompleteConsumer.h:699
std
Definition: Format.h:4477
clang::CodeCompletionResult::AllParametersAreInformative
bool AllParametersAreInformative
Whether all parameters (of a function, Objective-C method, etc.) should be considered "informative".
Definition: CodeCompleteConsumer.h:847
clang::CodeCompletionString::Chunk::CreatePlaceholder
static Chunk CreatePlaceholder(const char *Placeholder)
Create a new placeholder chunk.
Definition: CodeCompleteConsumer.cpp:264
clang::CodeCompletionContext::CCC_NaturalLanguage
@ CCC_NaturalLanguage
Code completion occurred in a context where natural language is expected, e.g., a comment or string l...
Definition: CodeCompleteConsumer.h:303
clang::CodeCompletionString::CK_Placeholder
@ CK_Placeholder
A string that acts as a placeholder for, e.g., a function call argument.
Definition: CodeCompleteConsumer.h:463
clang::STC_Record
@ STC_Record
Definition: CodeCompleteConsumer.h:157
clang
Definition: CalledOnceCheck.h:17
Text
StringRef Text
Definition: Format.cpp:2716
clang::getCompletionComment
const RawComment * getCompletionComment(const ASTContext &Ctx, const NamedDecl *Decl)
Get the documentation comment used to produce CodeCompletionString::BriefComment for RK_Declaration.
Definition: SemaCodeComplete.cpp:3683
clang::CodeCompleteConsumer::getAllocator
virtual CodeCompletionAllocator & getAllocator()=0
Retrieve the allocator that will be used to allocate code completion strings.
clang::CodeCompleteConsumer::OverloadCandidate::OverloadCandidate
OverloadCandidate(const FunctionType *Type)
Definition: CodeCompleteConsumer.h:1081
clang::CodeCompletionResult::InBaseClass
bool InBaseClass
Whether this is a class member from base class.
Definition: CodeCompleteConsumer.h:836
clang::CodeCompleteConsumer::OverloadCandidate::getNumParams
unsigned getNumParams() const
Get the number of parameters in this signature.
Definition: CodeCompleteConsumer.cpp:535
clang::CCP_Type
@ CCP_Type
Priority for a type.
Definition: CodeCompleteConsumer.h:84
MacroInfo.h
clang::CodeCompletionContext::CCC_NewName
@ CCC_NewName
Code completion occurred where a new name is expected.
Definition: CodeCompleteConsumer.h:274
clang::CodeCompletionString::Chunk::CreateInformative
static Chunk CreateInformative(const char *Informative)
Create a new informative chunk.
Definition: CodeCompleteConsumer.cpp:269
clang::getDeclUsageType
QualType getDeclUsageType(ASTContext &C, const NamedDecl *ND)
Determine the type that this declaration will have if it is used as a type or in an expression.
Definition: SemaCodeComplete.cpp:911
clang::CCD_ProbablyNotObjCCollection
@ CCD_ProbablyNotObjCCollection
Adjustment for KVC code pattern priorities when it doesn't look like the.
Definition: CodeCompleteConsumer.h:124
clang::CodeCompleteConsumer::ProcessOverloadCandidates
virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg, OverloadCandidate *Candidates, unsigned NumCandidates, SourceLocation OpenParLoc, bool Braced)
Definition: CodeCompleteConsumer.h:1220
clang::CodeCompletionResult::getOrderedName
StringRef getOrderedName(std::string &Saved) const
Retrieve the name that should be used to order a result.
Definition: CodeCompleteConsumer.cpp:830
clang::operator<
bool operator<(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
Definition: DeclarationName.h:549
clang::CodeCompletionContext::setIsUsingDeclaration
void setIsUsingDeclaration(bool V)
Definition: CodeCompleteConsumer.h:386
clang::CodeCompletionBuilder::AddPlaceholderChunk
void AddPlaceholderChunk(const char *Placeholder)
Add a new placeholder chunk.
Definition: CodeCompleteConsumer.cpp:454
clang::CodeCompletionBuilder::addBriefComment
void addBriefComment(StringRef Comment)
Definition: CodeCompleteConsumer.cpp:489
clang::CodeCompletionTUInfo::CodeCompletionTUInfo
CodeCompletionTUInfo(std::shared_ptr< GlobalCodeCompletionAllocator > Allocator)
Definition: CodeCompleteConsumer.h:656
clang::CodeCompletionContext::CCC_ObjCIvarList
@ CCC_ObjCIvarList
Code completion occurred within the instance variable list of an Objective-C interface,...
Definition: CodeCompleteConsumer.h:211
clang::CodeCompletionString::CK_RightAngle
@ CK_RightAngle
A right angle bracket ('>').
Definition: CodeCompleteConsumer.h:499
clang::CodeCompletionResult::RK_Declaration
@ RK_Declaration
Refers to a declaration.
Definition: CodeCompleteConsumer.h:757
clang::CodeCompleteOptions
Options controlling the behavior of code completion.
Definition: CodeCompleteOptions.h:15
clang::CodeCompletionAllocator
An allocator used specifically for the purpose of code completion.
Definition: CodeCompleteConsumer.h:642
clang::CodeCompletionContext::CCC_ParenthesizedExpression
@ CCC_ParenthesizedExpression
Code completion in a parenthesized expression, which means that we may also have types here in C and ...
Definition: CodeCompleteConsumer.h:313
clang::CodeCompleteConsumer::OverloadCandidate::Type
const FunctionType * Type
The function type that describes the entity being called, when Kind == CK_FunctionType.
Definition: CodeCompleteConsumer.h:1055
clang::CodeCompletionResult::DeclaringEntity
bool DeclaringEntity
Whether we're completing a declaration of the given entity, rather than a use of that entity.
Definition: CodeCompleteConsumer.h:851
clang::CodeCompletionString::Chunk::CreateText
static Chunk CreateText(const char *Text)
Create a new text chunk.
Definition: CodeCompleteConsumer.cpp:251
clang::CodeCompletionContext::wantConstructorResults
bool wantConstructorResults() const
Determines whether we want C++ constructors as results within this context.
Definition: CodeCompleteConsumer.cpp:45
clang::CodeCompletionString::Chunk
One piece of the code completion string.
Definition: CodeCompleteConsumer.h:522
clang::CodeCompletionContext::CCC_SelectorName
@ CCC_SelectorName
Code completion for a selector, as in an @selector expression.
Definition: CodeCompleteConsumer.h:306
clang::CodeCompleteConsumer::~CodeCompleteConsumer
virtual ~CodeCompleteConsumer()
Deregisters and destroys this code-completion consumer.
clang::FunctionProtoTypeLoc
Definition: TypeLoc.h:1498
clang::CodeCompletionResult::Kind
ResultKind Kind
The kind of result stored here.
Definition: CodeCompleteConsumer.h:794
clang::CodeCompletionString::CK_Optional
@ CK_Optional
A code completion string that is entirely optional.
Definition: CodeCompleteConsumer.h:459
clang::GlobalCodeCompletionAllocator
Allocator for a cached set of global code completions.
Definition: CodeCompleteConsumer.h:649
clang::getCursorKindForDecl
CXCursorKind getCursorKindForDecl(const Decl *D)
Determine the libclang cursor kind associated with the given declaration.
Definition: SemaCodeComplete.cpp:3988
clang::CodeCompletionContext
The context in which code completion occurred, so that the code-completion consumer can process the r...
Definition: CodeCompleteConsumer.h:187
clang::CodeCompleteOptions::LoadExternal
unsigned LoadExternal
Hint whether to load data from the external AST to provide full results.
Definition: CodeCompleteOptions.h:40
true
#define true
Definition: stdbool.h:21
clang::getCompletionKindString
llvm::StringRef getCompletionKindString(CodeCompletionContext::Kind Kind)
Get string representation of Kind, useful for debugging.
Definition: CodeCompleteConsumer.cpp:92
clang::CodeCompletionBuilder::AddInformativeChunk
void AddInformativeChunk(const char *Text)
Add a new informative chunk.
Definition: CodeCompleteConsumer.cpp:458
clang::operator>=
bool operator>=(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
Definition: DeclarationName.h:567
clang::CodeCompletionString::CK_LeftBrace
@ CK_LeftBrace
A left brace ('{').
Definition: CodeCompleteConsumer.h:490
clang::CodeCompletionResult::FixIts
std::vector< FixItHint > FixIts
Fix-its that must be applied before inserting the text for the corresponding completion.
Definition: CodeCompleteConsumer.h:830
clang::CodeCompletionTUInfo::getParentName
StringRef getParentName(const DeclContext *DC)
Definition: CodeCompleteConsumer.cpp:370
clang::Preprocessor
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:129
clang::STC_ObjectiveC
@ STC_ObjectiveC
Definition: CodeCompleteConsumer.h:154
clang::CodeCompletionTUInfo::getAllocator
CodeCompletionAllocator & getAllocator() const
Definition: CodeCompleteConsumer.h:664
clang::CCD_InBaseClass
@ CCD_InBaseClass
The result is in a base class.
Definition: CodeCompleteConsumer.h:107
clang::CCP_MemberDeclaration
@ CCP_MemberDeclaration
Priority for a member declaration found from the current method or member function.
Definition: CodeCompleteConsumer.h:71
clang::CodeCompletionResult::CodeCompletionResult
CodeCompletionResult(const char *Keyword, unsigned Priority=CCP_Keyword)
Build a result that refers to a keyword or symbol.
Definition: CodeCompleteConsumer.h:891
clang::CodeCompleteConsumer::CodeCompleteConsumer
CodeCompleteConsumer(const CodeCompleteOptions &CodeCompleteOpts)
Definition: CodeCompleteConsumer.h:1152
clang::CodeCompletionString::CK_Colon
@ CK_Colon
A colon (':').
Definition: CodeCompleteConsumer.h:505
clang::CodeCompletionBuilder::getParentName
StringRef getParentName() const
Definition: CodeCompleteConsumer.h:748
clang::CodeCompletionResult::CursorKind
CXCursorKind CursorKind
The cursor kind that describes this result.
Definition: CodeCompleteConsumer.h:797
clang::CodeCompletionContext::getPreferredType
QualType getPreferredType() const
Retrieve the type that this expression would prefer to have, e.g., if the expression is a variable in...
Definition: CodeCompleteConsumer.h:394
clang::CCD_MethodAsProperty
@ CCD_MethodAsProperty
An Objective-C method being used as a property.
Definition: CodeCompleteConsumer.h:127
clang::CodeCompletionResult::CodeCompletionResult
CodeCompletionResult(const NamedDecl *Declaration, unsigned Priority, NestedNameSpecifier *Qualifier=nullptr, bool QualifierIsInformative=false, bool Accessible=true, std::vector< FixItHint > FixIts=std::vector< FixItHint >())
Build a result that refers to a declaration.
Definition: CodeCompleteConsumer.h:876
clang::CodeCompletionString::CK_Comma
@ CK_Comma
A comma separator (',').
Definition: CodeCompleteConsumer.h:502
clang::CodeCompletionString::Chunk::Text
const char * Text
The text string associated with a CK_Text, CK_Placeholder, CK_Informative, or CK_Comma chunk.
Definition: CodeCompleteConsumer.h:532
clang::FunctionDecl
Represents a function declaration or definition.
Definition: Decl.h:1904
clang::CodeCompleteConsumer::OverloadCandidate::CK_Template
@ CK_Template
The candidate is a template, template arguments are being completed.
Definition: CodeCompleteConsumer.h:1034
clang::RecordDecl
Represents a struct/union/class.
Definition: Decl.h:3983
clang::CodeCompletionContext::CCC_UnionTag
@ CCC_UnionTag
Code completion occurred after the "union" keyword, to indicate a union name.
Definition: CodeCompleteConsumer.h:257
clang::CodeCompletionString::size
unsigned size() const
Definition: CodeCompleteConsumer.h:602
clang::CodeCompleteConsumer::OverloadCandidate::getFunction
FunctionDecl * getFunction() const
Retrieve the function overload candidate or the templated function declaration for a function templat...
Definition: CodeCompleteConsumer.cpp:496
clang::CodeCompleteConsumer::OverloadCandidate::getTemplate
const TemplateDecl * getTemplate() const
Definition: CodeCompleteConsumer.h:1121
clang::CodeCompleteConsumer::OverloadCandidate::getParamType
QualType getParamType(unsigned N) const
Get the type of the Nth parameter.
Definition: CodeCompleteConsumer.cpp:555
clang::PrintingCodeCompleteConsumer::getAllocator
CodeCompletionAllocator & getAllocator() override
Retrieve the allocator that will be used to allocate code completion strings.
Definition: CodeCompleteConsumer.h:1280
clang::CodeCompletionContext::CCC_MacroName
@ CCC_MacroName
Code completion occurred where an macro is being defined.
Definition: CodeCompleteConsumer.h:285
clang::CodeCompletionContext::addVisitedContext
void addVisitedContext(DeclContext *Ctx)
Adds a visited context.
Definition: CodeCompleteConsumer.h:416
clang::CodeCompletionContext::getVisitedContexts
const VisitedContextSet & getVisitedContexts() const
Retrieves all visited contexts.
Definition: CodeCompleteConsumer.h:421
clang::CodeCompletionContext::CCC_ObjCClassMessage
@ CCC_ObjCClassMessage
Code completion where an Objective-C class message is expected.
Definition: CodeCompleteConsumer.h:320
clang::CodeCompletionTUInfo
Definition: CodeCompleteConsumer.h:651
clang::CodeCompletionContext::CCC_ObjCInterface
@ CCC_ObjCInterface
Code completion occurred within an Objective-C interface, protocol, or category interface.
Definition: CodeCompleteConsumer.h:203
clang::CodeCompletionContext::CCC_ClassOrStructTag
@ CCC_ClassOrStructTag
Code completion occurred after the "struct" or "class" keyword, to indicate a struct or class name.
Definition: CodeCompleteConsumer.h:261
clang::CodeCompletionContext::CCC_TypeQualifiers
@ CCC_TypeQualifiers
Code completion within a type-qualifier list.
Definition: CodeCompleteConsumer.h:309
clang::CodeCompletionContext::CCC_MacroNameUse
@ CCC_MacroNameUse
Code completion occurred where a macro name is expected (without any arguments, in the case of a func...
Definition: CodeCompleteConsumer.h:289
clang::STC_Arithmetic
@ STC_Arithmetic
Definition: CodeCompleteConsumer.h:150
clang::CodeCompletionContext::getSelIdents
ArrayRef< IdentifierInfo * > getSelIdents() const
Retrieve the Objective-C selector identifiers.
Definition: CodeCompleteConsumer.h:402