clang  7.0.0svn
CodeCompleteConsumer.h
Go to the documentation of this file.
1 //===- CodeCompleteConsumer.h - Code Completion Interface -------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the CodeCompleteConsumer class.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_SEMA_CODECOMPLETECONSUMER_H
15 #define LLVM_CLANG_SEMA_CODECOMPLETECONSUMER_H
16 
17 #include "clang-c/Index.h"
18 #include "clang/AST/Type.h"
19 #include "clang/Basic/LLVM.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 Sema;
49 
50 /// \brief Default priority values for code-completion results based
51 /// on their kind.
52 enum {
53  /// \brief Priority for the next initialization in a constructor initializer
54  /// list.
56 
57  /// \brief Priority for an enumeration constant inside a switch whose
58  /// condition is of the enumeration type.
60 
61  /// \brief Priority for a send-to-super completion.
63 
64  /// \brief Priority for a declaration that is in the local scope.
66 
67  /// \brief Priority for a member declaration found from the current
68  /// method or member function.
70 
71  /// \brief Priority for a language keyword (that isn't any of the other
72  /// categories).
74 
75  /// \brief Priority for a code pattern.
77 
78  /// \brief Priority for a non-type declaration.
80 
81  /// \brief Priority for a type.
83 
84  /// \brief Priority for a constant value (e.g., enumerator).
86 
87  /// \brief Priority for a preprocessor macro.
88  CCP_Macro = 70,
89 
90  /// \brief Priority for a nested-name-specifier.
92 
93  /// \brief Priority for a result that isn't likely to be what the user wants,
94  /// but is included for completeness.
96 
97  /// \brief Priority for the Objective-C "_cmd" implicit parameter.
99 };
100 
101 /// \brief Priority value deltas that are added to code-completion results
102 /// based on the context of the result.
103 enum {
104  /// \brief The result is in a base class.
106 
107  /// \brief The result is a C++ non-static member function whose qualifiers
108  /// exactly match the object type on which the member function can be called.
110 
111  /// \brief The selector of the given message exactly matches the selector
112  /// of the current method, which might imply that some kind of delegation
113  /// is occurring.
115 
116  /// \brief Adjustment to the "bool" type in Objective-C, where the typedef
117  /// "BOOL" is preferred.
119 
120  /// \brief Adjustment for KVC code pattern priorities when it doesn't look
121  /// like the
123 
124  /// \brief An Objective-C method being used as a property.
126 
127  /// \brief An Objective-C block property completed as a setter with a
128  /// block placeholder.
130 };
131 
132 /// \brief Priority value factors by which we will divide or multiply the
133 /// priority of a code-completion result.
134 enum {
135  /// \brief Divide by this factor when a code-completion result's type exactly
136  /// matches the type we expect.
138 
139  /// \brief Divide by this factor when a code-completion result's type is
140  /// similar to the type we expect (e.g., both arithmetic types, both
141  /// Objective-C object pointer types).
143 };
144 
145 /// \brief A simplified classification of types used when determining
146 /// "similar" types for code completion.
157 };
158 
159 /// \brief Determine the simplified type class of the given canonical type.
161 
162 /// \brief Determine the type that this declaration will have if it is used
163 /// as a type or in an expression.
165 
166 /// \brief Determine the priority to be given to a macro code completion result
167 /// with the given name.
168 ///
169 /// \param MacroName The name of the macro.
170 ///
171 /// \param LangOpts Options describing the current language dialect.
172 ///
173 /// \param PreferredTypeIsPointer Whether the preferred type for the context
174 /// of this macro is a pointer type.
175 unsigned getMacroUsagePriority(StringRef MacroName,
176  const LangOptions &LangOpts,
177  bool PreferredTypeIsPointer = false);
178 
179 /// \brief Determine the libclang cursor kind associated with the given
180 /// declaration.
182 
183 /// \brief The context in which code completion occurred, so that the
184 /// code-completion consumer can process the results accordingly.
186 public:
187  enum Kind {
188  /// \brief An unspecified code-completion context.
190 
191  /// \brief An unspecified code-completion context where we should also add
192  /// macro completions.
194 
195  /// \brief Code completion occurred within a "top-level" completion context,
196  /// e.g., at namespace or global scope.
198 
199  /// \brief Code completion occurred within an Objective-C interface,
200  /// protocol, or category interface.
202 
203  /// \brief Code completion occurred within an Objective-C implementation
204  /// or category implementation.
206 
207  /// \brief Code completion occurred within the instance variable list of
208  /// an Objective-C interface, implementation, or category implementation.
210 
211  /// \brief Code completion occurred within a class, struct, or union.
213 
214  /// \brief Code completion occurred where a statement (or declaration) is
215  /// expected in a function, method, or block.
217 
218  /// \brief Code completion occurred where an expression is expected.
220 
221  /// \brief Code completion occurred where an Objective-C message receiver
222  /// is expected.
224 
225  /// \brief Code completion occurred on the right-hand side of a member
226  /// access expression using the dot operator.
227  ///
228  /// The results of this completion are the members of the type being
229  /// accessed. The type itself is available via
230  /// \c CodeCompletionContext::getType().
232 
233  /// \brief Code completion occurred on the right-hand side of a member
234  /// access expression using the arrow operator.
235  ///
236  /// The results of this completion are the members of the type being
237  /// accessed. The type itself is available via
238  /// \c CodeCompletionContext::getType().
240 
241  /// \brief Code completion occurred on the right-hand side of an Objective-C
242  /// property access expression.
243  ///
244  /// The results of this completion are the members of the type being
245  /// accessed. The type itself is available via
246  /// \c CodeCompletionContext::getType().
248 
249  /// \brief Code completion occurred after the "enum" keyword, to indicate
250  /// an enumeration name.
252 
253  /// \brief Code completion occurred after the "union" keyword, to indicate
254  /// a union name.
256 
257  /// \brief Code completion occurred after the "struct" or "class" keyword,
258  /// to indicate a struct or class name.
260 
261  /// \brief Code completion occurred where a protocol name is expected.
263 
264  /// \brief Code completion occurred where a namespace or namespace alias
265  /// is expected.
267 
268  /// \brief Code completion occurred where a type name is expected.
270 
271  /// \brief Code completion occurred where a new name is expected.
273 
274  /// \brief Code completion occurred where a new name is expected and a
275  /// qualified name is permissible.
277 
278  /// \brief Code completion occurred where an macro is being defined.
280 
281  /// \brief Code completion occurred where a macro name is expected
282  /// (without any arguments, in the case of a function-like macro).
284 
285  /// \brief Code completion occurred within a preprocessor expression.
287 
288  /// \brief Code completion occurred where a preprocessor directive is
289  /// expected.
291 
292  /// \brief Code completion occurred in a context where natural language is
293  /// expected, e.g., a comment or string literal.
294  ///
295  /// This context usually implies that no completions should be added,
296  /// unless they come from an appropriate natural-language dictionary.
298 
299  /// \brief Code completion for a selector, as in an \@selector expression.
301 
302  /// \brief Code completion within a type-qualifier list.
304 
305  /// \brief Code completion in a parenthesized expression, which means that
306  /// we may also have types here in C and Objective-C (as well as in C++).
308 
309  /// \brief Code completion where an Objective-C instance message is
310  /// expected.
312 
313  /// \brief Code completion where an Objective-C class message is expected.
315 
316  /// \brief Code completion where the name of an Objective-C class is
317  /// expected.
319 
320  /// \brief Code completion where an Objective-C category name is expected.
322 
323  /// \brief An unknown context, in which we are recovering from a parsing
324  /// error and don't know which completions we should give.
326  };
327 
328  using VisitedContextSet = llvm::SmallPtrSet<DeclContext *, 8>;
329 
330 private:
331  Kind CCKind;
332 
333  /// \brief The type that would prefer to see at this point (e.g., the type
334  /// of an initializer or function parameter).
335  QualType PreferredType;
336 
337  /// \brief The type of the base object in a member access expression.
338  QualType BaseType;
339 
340  /// \brief The identifiers for Objective-C selector parts.
341  ArrayRef<IdentifierInfo *> SelIdents;
342 
343  /// \brief The scope specifier that comes before the completion token e.g.
344  /// "a::b::"
345  llvm::Optional<CXXScopeSpec> ScopeSpecifier;
346 
347  /// \brief A set of declaration contexts visited by Sema when doing lookup for
348  /// code completion.
349  VisitedContextSet VisitedContexts;
350 
351 public:
352  /// \brief Construct a new code-completion context of the given kind.
353  CodeCompletionContext(Kind CCKind) : CCKind(CCKind), SelIdents(None) {}
354 
355  /// \brief Construct a new code-completion context of the given kind.
357  ArrayRef<IdentifierInfo *> SelIdents = None)
358  : CCKind(CCKind), SelIdents(SelIdents) {
359  if (CCKind == CCC_DotMemberAccess || CCKind == CCC_ArrowMemberAccess ||
360  CCKind == CCC_ObjCPropertyAccess || CCKind == CCC_ObjCClassMessage ||
361  CCKind == CCC_ObjCInstanceMessage)
362  BaseType = T;
363  else
364  PreferredType = T;
365  }
366 
367  /// \brief Retrieve the kind of code-completion context.
368  Kind getKind() const { return CCKind; }
369 
370  /// \brief Retrieve the type that this expression would prefer to have, e.g.,
371  /// if the expression is a variable initializer or a function argument, the
372  /// type of the corresponding variable or function parameter.
373  QualType getPreferredType() const { return PreferredType; }
374 
375  /// \brief Retrieve the type of the base object in a member-access
376  /// expression.
377  QualType getBaseType() const { return BaseType; }
378 
379  /// \brief Retrieve the Objective-C selector identifiers.
380  ArrayRef<IdentifierInfo *> getSelIdents() const { return SelIdents; }
381 
382  /// \brief Determines whether we want C++ constructors as results within this
383  /// context.
384  bool wantConstructorResults() const;
385 
386  /// \brief Sets the scope specifier that comes before the completion token.
387  /// This is expected to be set in code completions on qualfied specifiers
388  /// (e.g. "a::b::").
390  this->ScopeSpecifier = std::move(SS);
391  }
392 
393  /// \brief Adds a visited context.
395  VisitedContexts.insert(Ctx);
396  }
397 
398  /// \brief Retrieves all visited contexts.
400  return VisitedContexts;
401  }
402 
404  if (ScopeSpecifier)
405  return ScopeSpecifier.getPointer();
406  return llvm::None;
407  }
408 };
409 
410 /// \brief Get string representation of \p Kind, useful for for debugging.
412 
413 /// \brief A "string" used to describe how code completion can
414 /// be performed for an entity.
415 ///
416 /// A code completion string typically shows how a particular entity can be
417 /// used. For example, the code completion string for a function would show
418 /// the syntax to call it, including the parentheses, placeholders for the
419 /// arguments, etc.
421 public:
422  /// \brief The different kinds of "chunks" that can occur within a code
423  /// completion string.
424  enum ChunkKind {
425  /// \brief The piece of text that the user is expected to type to
426  /// match the code-completion string, typically a keyword or the name of a
427  /// declarator or macro.
429 
430  /// \brief A piece of text that should be placed in the buffer, e.g.,
431  /// parentheses or a comma in a function call.
433 
434  /// \brief A code completion string that is entirely optional. For example,
435  /// an optional code completion string that describes the default arguments
436  /// in a function call.
438 
439  /// \brief A string that acts as a placeholder for, e.g., a function
440  /// call argument.
442 
443  /// \brief A piece of text that describes something about the result but
444  /// should not be inserted into the buffer.
446  /// \brief A piece of text that describes the type of an entity or, for
447  /// functions and methods, the return type.
449 
450  /// \brief A piece of text that describes the parameter that corresponds
451  /// to the code-completion location within a function call, message send,
452  /// macro invocation, etc.
454 
455  /// \brief A left parenthesis ('(').
457 
458  /// \brief A right parenthesis (')').
460 
461  /// \brief A left bracket ('[').
463 
464  /// \brief A right bracket (']').
466 
467  /// \brief A left brace ('{').
469 
470  /// \brief A right brace ('}').
472 
473  /// \brief A left angle bracket ('<').
475 
476  /// \brief A right angle bracket ('>').
478 
479  /// \brief A comma separator (',').
481 
482  /// \brief A colon (':').
484 
485  /// \brief A semicolon (';').
487 
488  /// \brief An '=' sign.
490 
491  /// \brief Horizontal whitespace (' ').
493 
494  /// \brief Vertical whitespace ('\\n' or '\\r\\n', depending on the
495  /// platform).
496  CK_VerticalSpace
497  };
498 
499  /// \brief One piece of the code completion string.
500  struct Chunk {
501  /// \brief The kind of data stored in this piece of the code completion
502  /// string.
503  ChunkKind Kind = CK_Text;
504 
505  union {
506  /// \brief The text string associated with a CK_Text, CK_Placeholder,
507  /// CK_Informative, or CK_Comma chunk.
508  /// The string is owned by the chunk and will be deallocated
509  /// (with delete[]) when the chunk is destroyed.
510  const char *Text;
511 
512  /// \brief The code completion string associated with a CK_Optional chunk.
513  /// The optional code completion string is owned by the chunk, and will
514  /// be deallocated (with delete) when the chunk is destroyed.
516  };
517 
518  Chunk() : Text(nullptr) {}
519 
520  explicit Chunk(ChunkKind Kind, const char *Text = "");
521 
522  /// \brief Create a new text chunk.
523  static Chunk CreateText(const char *Text);
524 
525  /// \brief Create a new optional chunk.
526  static Chunk CreateOptional(CodeCompletionString *Optional);
527 
528  /// \brief Create a new placeholder chunk.
529  static Chunk CreatePlaceholder(const char *Placeholder);
530 
531  /// \brief Create a new informative chunk.
532  static Chunk CreateInformative(const char *Informative);
533 
534  /// \brief Create a new result type chunk.
535  static Chunk CreateResultType(const char *ResultType);
536 
537  /// \brief Create a new current-parameter chunk.
538  static Chunk CreateCurrentParameter(const char *CurrentParameter);
539  };
540 
541 private:
542  friend class CodeCompletionBuilder;
543  friend class CodeCompletionResult;
544 
545  /// \brief The number of chunks stored in this string.
546  unsigned NumChunks : 16;
547 
548  /// \brief The number of annotations for this code-completion result.
549  unsigned NumAnnotations : 16;
550 
551  /// \brief The priority of this code-completion string.
552  unsigned Priority : 16;
553 
554  /// \brief The availability of this code-completion result.
555  unsigned Availability : 2;
556 
557  /// \brief The name of the parent context.
558  StringRef ParentName;
559 
560  /// \brief A brief documentation comment attached to the declaration of
561  /// entity being completed by this result.
562  const char *BriefComment;
563 
564  CodeCompletionString(const Chunk *Chunks, unsigned NumChunks,
565  unsigned Priority, CXAvailabilityKind Availability,
566  const char **Annotations, unsigned NumAnnotations,
567  StringRef ParentName,
568  const char *BriefComment);
569  ~CodeCompletionString() = default;
570 
571 public:
572  CodeCompletionString(const CodeCompletionString &) = delete;
573  CodeCompletionString &operator=(const CodeCompletionString &) = delete;
574 
575  using iterator = const Chunk *;
576 
577  iterator begin() const { return reinterpret_cast<const Chunk *>(this + 1); }
578  iterator end() const { return begin() + NumChunks; }
579  bool empty() const { return NumChunks == 0; }
580  unsigned size() const { return NumChunks; }
581 
582  const Chunk &operator[](unsigned I) const {
583  assert(I < size() && "Chunk index out-of-range");
584  return begin()[I];
585  }
586 
587  /// \brief Returns the text in the TypedText chunk.
588  const char *getTypedText() const;
589 
590  /// \brief Retrieve the priority of this code completion result.
591  unsigned getPriority() const { return Priority; }
592 
593  /// \brief Retrieve the availability of this code completion result.
594  unsigned getAvailability() const { return Availability; }
595 
596  /// \brief Retrieve the number of annotations for this code completion result.
597  unsigned getAnnotationCount() const;
598 
599  /// \brief Retrieve the annotation string specified by \c AnnotationNr.
600  const char *getAnnotation(unsigned AnnotationNr) const;
601 
602  /// \brief Retrieve the name of the parent context.
603  StringRef getParentContextName() const {
604  return ParentName;
605  }
606 
607  const char *getBriefComment() const {
608  return BriefComment;
609  }
610 
611  /// \brief Retrieve a string representation of the code completion string,
612  /// which is mainly useful for debugging.
613  std::string getAsString() const;
614 };
615 
616 /// \brief An allocator used specifically for the purpose of code completion.
617 class CodeCompletionAllocator : public llvm::BumpPtrAllocator {
618 public:
619  /// \brief Copy the given string into this allocator.
620  const char *CopyString(const Twine &String);
621 };
622 
623 /// \brief Allocator for a cached set of global code completions.
625 
627  llvm::DenseMap<const DeclContext *, StringRef> ParentNames;
628  std::shared_ptr<GlobalCodeCompletionAllocator> AllocatorRef;
629 
630 public:
632  std::shared_ptr<GlobalCodeCompletionAllocator> Allocator)
633  : AllocatorRef(std::move(Allocator)) {}
634 
635  std::shared_ptr<GlobalCodeCompletionAllocator> getAllocatorRef() const {
636  return AllocatorRef;
637  }
638 
640  assert(AllocatorRef);
641  return *AllocatorRef;
642  }
643 
644  StringRef getParentName(const DeclContext *DC);
645 };
646 
647 } // namespace clang
648 
649 namespace llvm {
650 
651 template <> struct isPodLike<clang::CodeCompletionString::Chunk> {
652  static const bool value = true;
653 };
654 
655 } // namespace llvm
656 
657 namespace clang {
658 
659 /// \brief A builder class used to construct new code-completion strings.
661 public:
663 
664 private:
665  CodeCompletionAllocator &Allocator;
666  CodeCompletionTUInfo &CCTUInfo;
667  unsigned Priority = 0;
669  StringRef ParentName;
670  const char *BriefComment = nullptr;
671 
672  /// \brief The chunks stored in this string.
673  SmallVector<Chunk, 4> Chunks;
674 
675  SmallVector<const char *, 2> Annotations;
676 
677 public:
679  CodeCompletionTUInfo &CCTUInfo)
680  : Allocator(Allocator), CCTUInfo(CCTUInfo) {}
681 
683  CodeCompletionTUInfo &CCTUInfo,
684  unsigned Priority, CXAvailabilityKind Availability)
685  : Allocator(Allocator), CCTUInfo(CCTUInfo), Priority(Priority),
686  Availability(Availability) {}
687 
688  /// \brief Retrieve the allocator into which the code completion
689  /// strings should be allocated.
690  CodeCompletionAllocator &getAllocator() const { return Allocator; }
691 
692  CodeCompletionTUInfo &getCodeCompletionTUInfo() const { return CCTUInfo; }
693 
694  /// \brief Take the resulting completion string.
695  ///
696  /// This operation can only be performed once.
697  CodeCompletionString *TakeString();
698 
699  /// \brief Add a new typed-text chunk.
700  void AddTypedTextChunk(const char *Text);
701 
702  /// \brief Add a new text chunk.
703  void AddTextChunk(const char *Text);
704 
705  /// \brief Add a new optional chunk.
706  void AddOptionalChunk(CodeCompletionString *Optional);
707 
708  /// \brief Add a new placeholder chunk.
709  void AddPlaceholderChunk(const char *Placeholder);
710 
711  /// \brief Add a new informative chunk.
712  void AddInformativeChunk(const char *Text);
713 
714  /// \brief Add a new result-type chunk.
715  void AddResultTypeChunk(const char *ResultType);
716 
717  /// \brief Add a new current-parameter chunk.
718  void AddCurrentParameterChunk(const char *CurrentParameter);
719 
720  /// \brief Add a new chunk.
721  void AddChunk(CodeCompletionString::ChunkKind CK, const char *Text = "");
722 
723  void AddAnnotation(const char *A) { Annotations.push_back(A); }
724 
725  /// \brief Add the parent context information to this code completion.
726  void addParentContext(const DeclContext *DC);
727 
728  const char *getBriefComment() const { return BriefComment; }
729  void addBriefComment(StringRef Comment);
730 
731  StringRef getParentName() const { return ParentName; }
732 };
733 
734 /// \brief Captures a result of code completion.
736 public:
737  /// \brief Describes the kind of result generated.
738  enum ResultKind {
739  /// Refers to a declaration.
740  RK_Declaration = 0,
741 
742  /// Refers to a keyword or symbol.
744 
745  /// Refers to a macro.
747 
748  /// Refers to a precomputed pattern.
749  RK_Pattern
750  };
751 
752  /// \brief When Kind == RK_Declaration or RK_Pattern, the declaration we are
753  /// referring to. In the latter case, the declaration might be NULL.
754  const NamedDecl *Declaration = nullptr;
755 
756  union {
757  /// \brief When Kind == RK_Keyword, the string representing the keyword
758  /// or symbol's spelling.
759  const char *Keyword;
760 
761  /// \brief When Kind == RK_Pattern, the code-completion string that
762  /// describes the completion text to insert.
764 
765  /// \brief When Kind == RK_Macro, the identifier that refers to a macro.
767  };
768 
769  /// \brief The priority of this particular code-completion result.
770  unsigned Priority;
771 
772  /// \brief Specifies which parameter (of a function, Objective-C method,
773  /// macro, etc.) we should start with when formatting the result.
774  unsigned StartParameter = 0;
775 
776  /// \brief The kind of result stored here.
778 
779  /// \brief The cursor kind that describes this result.
781 
782  /// \brief The availability of this result.
784 
785  /// \brief Whether this result is hidden by another name.
786  bool Hidden : 1;
787 
788  /// \brief Whether this result was found via lookup into a base class.
790 
791  /// \brief Whether this declaration is the beginning of a
792  /// nested-name-specifier and, therefore, should be followed by '::'.
794 
795  /// \brief Whether all parameters (of a function, Objective-C
796  /// method, etc.) should be considered "informative".
798 
799  /// \brief Whether we're completing a declaration of the given entity,
800  /// rather than a use of that entity.
801  bool DeclaringEntity : 1;
802 
803  /// \brief If the result should have a nested-name-specifier, this is it.
804  /// When \c QualifierIsInformative, the nested-name-specifier is
805  /// informative rather than required.
806  NestedNameSpecifier *Qualifier = nullptr;
807 
808  /// \brief Build a result that refers to a declaration.
809  CodeCompletionResult(const NamedDecl *Declaration,
810  unsigned Priority,
811  NestedNameSpecifier *Qualifier = nullptr,
812  bool QualifierIsInformative = false,
813  bool Accessible = true)
814  : Declaration(Declaration), Priority(Priority), Kind(RK_Declaration),
815  Hidden(false), QualifierIsInformative(QualifierIsInformative),
816  StartsNestedNameSpecifier(false), AllParametersAreInformative(false),
817  DeclaringEntity(false), Qualifier(Qualifier) {
818  computeCursorKindAndAvailability(Accessible);
819  }
820 
821  /// \brief Build a result that refers to a keyword or symbol.
822  CodeCompletionResult(const char *Keyword, unsigned Priority = CCP_Keyword)
823  : Keyword(Keyword), Priority(Priority), Kind(RK_Keyword),
824  CursorKind(CXCursor_NotImplemented), Hidden(false),
825  QualifierIsInformative(false), StartsNestedNameSpecifier(false),
826  AllParametersAreInformative(false), DeclaringEntity(false) {}
827 
828  /// \brief Build a result that refers to a macro.
830  unsigned Priority = CCP_Macro)
831  : Macro(Macro), Priority(Priority), Kind(RK_Macro),
832  CursorKind(CXCursor_MacroDefinition), Hidden(false),
833  QualifierIsInformative(false), StartsNestedNameSpecifier(false),
834  AllParametersAreInformative(false), DeclaringEntity(false) {}
835 
836  /// \brief Build a result that refers to a pattern.
838  unsigned Priority = CCP_CodePattern,
841  const NamedDecl *D = nullptr)
842  : Declaration(D), Pattern(Pattern), Priority(Priority), Kind(RK_Pattern),
843  CursorKind(CursorKind), Availability(Availability), Hidden(false),
844  QualifierIsInformative(false), StartsNestedNameSpecifier(false),
845  AllParametersAreInformative(false), DeclaringEntity(false) {}
846 
847  /// \brief Build a result that refers to a pattern with an associated
848  /// declaration.
850  unsigned Priority)
851  : Declaration(D), Pattern(Pattern), Priority(Priority), Kind(RK_Pattern),
852  Hidden(false), QualifierIsInformative(false),
853  StartsNestedNameSpecifier(false), AllParametersAreInformative(false),
854  DeclaringEntity(false) {
855  computeCursorKindAndAvailability();
856  }
857 
858  /// \brief Retrieve the declaration stored in this result.
859  const NamedDecl *getDeclaration() const {
860  assert(Kind == RK_Declaration && "Not a declaration result");
861  return Declaration;
862  }
863 
864  /// \brief Retrieve the keyword stored in this result.
865  const char *getKeyword() const {
866  assert(Kind == RK_Keyword && "Not a keyword result");
867  return Keyword;
868  }
869 
870  /// \brief Create a new code-completion string that describes how to insert
871  /// this result into a program.
872  ///
873  /// \param S The semantic analysis that created the result.
874  ///
875  /// \param Allocator The allocator that will be used to allocate the
876  /// string itself.
877  CodeCompletionString *CreateCodeCompletionString(Sema &S,
878  const CodeCompletionContext &CCContext,
879  CodeCompletionAllocator &Allocator,
880  CodeCompletionTUInfo &CCTUInfo,
881  bool IncludeBriefComments);
882  CodeCompletionString *CreateCodeCompletionString(ASTContext &Ctx,
883  Preprocessor &PP,
884  const CodeCompletionContext &CCContext,
885  CodeCompletionAllocator &Allocator,
886  CodeCompletionTUInfo &CCTUInfo,
887  bool IncludeBriefComments);
888 
889  /// \brief Retrieve the name that should be used to order a result.
890  ///
891  /// If the name needs to be constructed as a string, that string will be
892  /// saved into Saved and the returned StringRef will refer to it.
893  StringRef getOrderedName(std::string &Saved) const;
894 
895 private:
896  void computeCursorKindAndAvailability(bool Accessible = true);
897 };
898 
900 
901 inline bool operator>(const CodeCompletionResult &X,
902  const CodeCompletionResult &Y) {
903  return Y < X;
904 }
905 
906 inline bool operator<=(const CodeCompletionResult &X,
907  const CodeCompletionResult &Y) {
908  return !(Y < X);
909 }
910 
911 inline bool operator>=(const CodeCompletionResult &X,
912  const CodeCompletionResult &Y) {
913  return !(X < Y);
914 }
915 
916 raw_ostream &operator<<(raw_ostream &OS,
917  const CodeCompletionString &CCS);
918 
919 /// \brief Abstract interface for a consumer of code-completion
920 /// information.
922 protected:
924 
925  /// \brief Whether the output format for the code-completion consumer is
926  /// binary.
928 
929 public:
931  public:
932  /// \brief Describes the type of overload candidate.
934  /// \brief The candidate is a function declaration.
936 
937  /// \brief The candidate is a function template.
939 
940  /// \brief The "candidate" is actually a variable, expression, or block
941  /// for which we only have a function prototype.
942  CK_FunctionType
943  };
944 
945  private:
946  /// \brief The kind of overload candidate.
948 
949  union {
950  /// \brief The function overload candidate, available when
951  /// Kind == CK_Function.
953 
954  /// \brief The function template overload candidate, available when
955  /// Kind == CK_FunctionTemplate.
957 
958  /// \brief The function type that describes the entity being called,
959  /// when Kind == CK_FunctionType.
961  };
962 
963  public:
965  : Kind(CK_Function), Function(Function) {}
966 
968  : Kind(CK_FunctionTemplate), FunctionTemplate(FunctionTemplateDecl) {}
969 
971  : Kind(CK_FunctionType), Type(Type) {}
972 
973  /// \brief Determine the kind of overload candidate.
974  CandidateKind getKind() const { return Kind; }
975 
976  /// \brief Retrieve the function overload candidate or the templated
977  /// function declaration for a function template.
978  FunctionDecl *getFunction() const;
979 
980  /// \brief Retrieve the function template overload candidate.
982  assert(getKind() == CK_FunctionTemplate && "Not a function template");
983  return FunctionTemplate;
984  }
985 
986  /// \brief Retrieve the function type of the entity, regardless of how the
987  /// function is stored.
988  const FunctionType *getFunctionType() const;
989 
990  /// \brief Create a new code-completion string that describes the function
991  /// signature of this overload candidate.
992  CodeCompletionString *CreateSignatureString(unsigned CurrentArg,
993  Sema &S,
994  CodeCompletionAllocator &Allocator,
995  CodeCompletionTUInfo &CCTUInfo,
996  bool IncludeBriefComments) const;
997  };
998 
999  CodeCompleteConsumer(const CodeCompleteOptions &CodeCompleteOpts,
1000  bool OutputIsBinary)
1001  : CodeCompleteOpts(CodeCompleteOpts), OutputIsBinary(OutputIsBinary) {}
1002 
1003  /// \brief Whether the code-completion consumer wants to see macros.
1004  bool includeMacros() const {
1005  return CodeCompleteOpts.IncludeMacros;
1006  }
1007 
1008  /// \brief Whether the code-completion consumer wants to see code patterns.
1009  bool includeCodePatterns() const {
1010  return CodeCompleteOpts.IncludeCodePatterns;
1011  }
1012 
1013  /// \brief Whether to include global (top-level) declaration results.
1014  bool includeGlobals() const { return CodeCompleteOpts.IncludeGlobals; }
1015 
1016  /// \brief Whether to include declarations in namespace contexts (including
1017  /// the global namespace). If this is false, `includeGlobals()` will be
1018  /// ignored.
1020  return CodeCompleteOpts.IncludeNamespaceLevelDecls;
1021  }
1022 
1023  /// \brief Whether to include brief documentation comments within the set of
1024  /// code completions returned.
1025  bool includeBriefComments() const {
1026  return CodeCompleteOpts.IncludeBriefComments;
1027  }
1028 
1029  /// \brief Hint whether to load data from the external AST in order to provide
1030  /// full results. If false, declarations from the preamble may be omitted.
1031  bool loadExternal() const {
1032  return CodeCompleteOpts.LoadExternal;
1033  }
1034 
1035  /// \brief Determine whether the output of this consumer is binary.
1036  bool isOutputBinary() const { return OutputIsBinary; }
1037 
1038  /// \brief Deregisters and destroys this code-completion consumer.
1039  virtual ~CodeCompleteConsumer();
1040 
1041  /// \name Code-completion filtering
1042  /// \brief Check if the result should be filtered out.
1043  virtual bool isResultFilteredOut(StringRef Filter,
1044  CodeCompletionResult Results) {
1045  return false;
1046  }
1047 
1048  /// \name Code-completion callbacks
1049  //@{
1050  /// \brief Process the finalized code-completion results.
1052  CodeCompletionContext Context,
1053  CodeCompletionResult *Results,
1054  unsigned NumResults) {}
1055 
1056  /// \param S the semantic-analyzer object for which code-completion is being
1057  /// done.
1058  ///
1059  /// \param CurrentArg the index of the current argument.
1060  ///
1061  /// \param Candidates an array of overload candidates.
1062  ///
1063  /// \param NumCandidates the number of overload candidates
1064  virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg,
1065  OverloadCandidate *Candidates,
1066  unsigned NumCandidates) {}
1067  //@}
1068 
1069  /// \brief Retrieve the allocator that will be used to allocate
1070  /// code completion strings.
1071  virtual CodeCompletionAllocator &getAllocator() = 0;
1072 
1073  virtual CodeCompletionTUInfo &getCodeCompletionTUInfo() = 0;
1074 };
1075 
1076 /// \brief A simple code-completion consumer that prints the results it
1077 /// receives in a simple format.
1079  /// \brief The raw output stream.
1080  raw_ostream &OS;
1081 
1082  CodeCompletionTUInfo CCTUInfo;
1083 
1084 public:
1085  /// \brief Create a new printing code-completion consumer that prints its
1086  /// results to the given raw output stream.
1088  raw_ostream &OS)
1089  : CodeCompleteConsumer(CodeCompleteOpts, false), OS(OS),
1090  CCTUInfo(std::make_shared<GlobalCodeCompletionAllocator>()) {}
1091 
1092  /// \brief Prints the finalized code-completion results.
1093  void ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context,
1094  CodeCompletionResult *Results,
1095  unsigned NumResults) override;
1096 
1097  void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg,
1098  OverloadCandidate *Candidates,
1099  unsigned NumCandidates) override;
1100 
1101  bool isResultFilteredOut(StringRef Filter, CodeCompletionResult Results) override;
1102 
1104  return CCTUInfo.getAllocator();
1105  }
1106 
1107  CodeCompletionTUInfo &getCodeCompletionTUInfo() override { return CCTUInfo; }
1108 };
1109 
1110 } // namespace clang
1111 
1112 #endif // LLVM_CLANG_SEMA_CODECOMPLETECONSUMER_H
One piece of the code completion string.
An unknown context, in which we are recovering from a parsing error and don&#39;t know which completions ...
A code completion string that is entirely optional.
CXAvailabilityKind
Describes the availability of a particular entity, which indicates whether the use of this entity wil...
Definition: Index.h:131
Priority for a declaration that is in the local scope.
CodeCompletionAllocator & getAllocator() const
Represents a function declaration or definition.
Definition: Decl.h:1696
llvm::SmallPtrSet< DeclContext *, 8 > VisitedContextSet
ResultKind Kind
The kind of result stored here.
An Objective-C method being used as a property.
CodeCompletionResult(const IdentifierInfo *Macro, unsigned Priority=CCP_Macro)
Build a result that refers to a macro.
const FunctionType * Type
The function type that describes the entity being called, when Kind == CK_FunctionType.
CXCursorKind CursorKind
The cursor kind that describes this result.
A (possibly-)qualified type.
Definition: Type.h:653
unsigned IncludeBriefComments
Show brief documentation comments in code completion results.
llvm::Optional< const CXXScopeSpec * > getCXXScopeSpecifier()
Code completion for a selector, as in an @selector expression.
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
Definition: Dominators.h:26
unsigned IncludeGlobals
Show top-level decls in code completion results.
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...
Code completion where an Objective-C class message is expected.
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:3062
C Language Family Type Representation.
Code completion within a type-qualifier list.
static void AddResultTypeChunk(ASTContext &Context, const PrintingPolicy &Policy, const NamedDecl *ND, QualType BaseType, CodeCompletionBuilder &Result)
If the given declaration has an associated type, add it as a result type chunk.
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
CandidateKind
Describes the type of overload candidate.
Adjustment for KVC code pattern priorities when it doesn&#39;t look like the.
const DiagnosticBuilder & operator<<(const DiagnosticBuilder &DB, const Attr *At)
Definition: Attr.h:200
The base class of the type hierarchy.
Definition: Type.h:1356
An unspecified code-completion context.
Allocator for a cached set of global code completions.
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
An Objective-C block property completed as a setter with a block placeholder.
bool loadExternal() const
Hint whether to load data from the external AST in order to provide full results. ...
Code completion occurred where an Objective-C message receiver is expected.
unsigned Priority
The priority of this particular code-completion result.
Code completion occurred on the right-hand side of a member access expression using the arrow operato...
ChunkKind
The different kinds of "chunks" that can occur within a code completion string.
Code completion occurred after the "enum" keyword, to indicate an enumeration name.
bool isOutputBinary() const
Determine whether the output of this consumer is binary.
A piece of text that describes the type of an entity or, for functions and methods, the return type.
bool StartsNestedNameSpecifier
Whether this declaration is the beginning of a nested-name-specifier and, therefore, should be followed by &#39;::&#39;.
const char * Keyword
When Kind == RK_Keyword, the string representing the keyword or symbol&#39;s spelling.
Priority for an enumeration constant inside a switch whose condition is of the enumeration type...
Code completion occurred within the instance variable list of an Objective-C interface, implementation, or category implementation.
bool operator<=(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
CodeCompletionBuilder(CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, unsigned Priority, CXAvailabilityKind Availability)
One of these records is kept for each identifier that is lexed.
OverloadCandidate(FunctionTemplateDecl *FunctionTemplateDecl)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:149
A "string" used to describe how code completion can be performed for an entity.
Adjustment to the "bool" type in Objective-C, where the typedef "BOOL" is preferred.
Definition: Format.h:2011
Kind getKind() const
Retrieve the kind of code-completion context.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:50
bool operator>(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
Priority for a language keyword (that isn&#39;t any of the other categories).
unsigned IncludeCodePatterns
Show code patterns in code completion results.
An allocator used specifically for the purpose of code completion.
CodeCompletionString * Pattern
When Kind == RK_Pattern, the code-completion string that describes the completion text to insert...
Priority for a nested-name-specifier.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
Code completion occurred where a preprocessor directive is expected.
Code completion occurred within an Objective-C implementation or category implementation.
bool QualifierIsInformative
Whether this result was found via lookup into a base class.
Priority for the Objective-C "_cmd" implicit parameter.
FunctionTemplateDecl * FunctionTemplate
The function template overload candidate, available when Kind == CK_FunctionTemplate.
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...
Code completion occurred where a namespace or namespace alias is expected.
Represents a C++ nested-name-specifier or a global scope specifier.
Definition: DeclSpec.h:63
The piece of text that the user is expected to type to match the code-completion string, typically a keyword or the name of a declarator or macro.
A comma separator (&#39;,&#39;).
bool wantConstructorResults() const
Determines whether we want C++ constructors as results within this context.
CXCursorKind
Describes the kind of entity that a cursor refers to.
Definition: Index.h:1690
FunctionTemplateDecl * getFunctionTemplate() const
Retrieve the function template overload candidate.
CodeCompletionAllocator & getAllocator() const
Retrieve the allocator into which the code completion strings should be allocated.
A right parenthesis (&#39;)&#39;).
Code completion where an Objective-C category name is expected.
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:275
Code completion occurred within a "top-level" completion context, e.g., at namespace or global scope...
CodeCompletionTUInfo & getCodeCompletionTUInfo() override
Code completion occurred where a protocol name is expected.
CXCursorKind getCursorKindForDecl(const Decl *D)
Determine the libclang cursor kind associated with the given declaration.
A simple code-completion consumer that prints the results it receives in a simple format...
QualType getPreferredType() const
Retrieve the type that this expression would prefer to have, e.g., if the expression is a variable in...
llvm::StringRef getCompletionKindString(CodeCompletionContext::Kind Kind)
Get string representation of Kind, useful for for debugging.
Code completion occurred where a new name is expected.
Divide by this factor when a code-completion result&#39;s type is similar to the type we expect (e...
llvm::StringRef getAsString(SyncScope S)
Definition: SyncScope.h:51
const FunctionProtoType * T
CodeCompletionResult(CodeCompletionString *Pattern, const NamedDecl *D, unsigned Priority)
Build a result that refers to a pattern with an associated declaration.
const char * Text
The text string associated with a CK_Text, CK_Placeholder, CK_Informative, or CK_Comma chunk...
This file defines the classes used to store parsed information about declaration-specifiers and decla...
virtual void ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context, CodeCompletionResult *Results, unsigned NumResults)
Process the finalized code-completion results.
void addVisitedContext(DeclContext *Ctx)
Adds a visited context.
unsigned IncludeNamespaceLevelDecls
Show decls in namespace (including the global namespace) in code completion results.
Captures a result of code completion.
ArrayRef< IdentifierInfo * > getSelIdents() const
Retrieve the Objective-C selector identifiers.
Code completion occurred where a new name is expected and a qualified name is permissible.
CodeCompletionContext(Kind CCKind)
Construct a new code-completion context of the given kind.
std::shared_ptr< GlobalCodeCompletionAllocator > getAllocatorRef() const
Priority for a member declaration found from the current method or member function.
Code completion in a parenthesized expression, which means that we may also have types here in C and ...
Code completion occurred in a context where natural language is expected, e.g., a comment or string l...
Divide by this factor when a code-completion result&#39;s type exactly matches the type we expect...
virtual bool isResultFilteredOut(StringRef Filter, CodeCompletionResult Results)
FunctionDecl * Function
The function overload candidate, available when Kind == CK_Function.
Priority for a result that isn&#39;t likely to be what the user wants, but is included for completeness...
A piece of text that should be placed in the buffer, e.g., parentheses or a comma in a function call...
StringRef getParentContextName() const
Retrieve the name of the parent context.
CandidateKind getKind() const
Determine the kind of overload candidate.
CodeCompletionString * Optional
The code completion string associated with a CK_Optional chunk.
The context in which code completion occurred, so that the code-completion consumer can process the r...
const IdentifierInfo * Macro
When Kind == RK_Macro, the identifier that refers to a macro.
The result is in a base class.
PrintingCodeCompleteConsumer(const CodeCompleteOptions &CodeCompleteOpts, raw_ostream &OS)
Create a new printing code-completion consumer that prints its results to the given raw output stream...
Code completion occurred within a class, struct, or union.
const VisitedContextSet & getVisitedContexts() const
Retrieves all visited contexts.
#define false
Definition: stdbool.h:33
const char * getBriefComment() const
Code completion where the name of an Objective-C class is expected.
const Chunk & operator[](unsigned I) const
Code completion occurred within an Objective-C interface, protocol, or category interface.
CodeCompleteConsumer(const CodeCompleteOptions &CodeCompleteOpts, bool OutputIsBinary)
virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg, OverloadCandidate *Candidates, unsigned NumCandidates)
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
The entity is available.
Definition: Index.h:135
SimplifiedTypeClass getSimplifiedTypeClass(CanQualType T)
Determine the simplified type class of the given canonical type.
bool operator>=(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
bool operator<(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
const char * getBriefComment() const
bool includeMacros() const
Whether the code-completion consumer wants to see macros.
CodeCompletionTUInfo & getCodeCompletionTUInfo() const
Abstract interface for a consumer of code-completion information.
Options controlling the behavior of code completion.
Dataflow Directional Tag Classes.
Priority for a type.
Code completion occurred where an macro is being defined.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1256
A piece of text that describes something about the result but should not be inserted into the buffer...
Priority for a send-to-super completion.
Code completion occurred after the "struct" or "class" keyword, to indicate a struct or class name...
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.
CodeCompletionResult(const NamedDecl *Declaration, unsigned Priority, NestedNameSpecifier *Qualifier=nullptr, bool QualifierIsInformative=false, bool Accessible=true)
Build a result that refers to a declaration.
Code completion occurred after the "union" keyword, to indicate a union name.
Code completion occurred where a macro name is expected (without any arguments, in the case of a func...
A builder class used to construct new code-completion strings.
Code completion where an Objective-C instance message is expected.
The result is a C++ non-static member function whose qualifiers exactly match the object type on whic...
const char * getKeyword() const
Retrieve the keyword stored in this result.
Priority for a constant value (e.g., enumerator).
Code completion occurred where a statement (or declaration) is expected in a function, method, or block.
Code completion occurred on the right-hand side of an Objective-C property access expression...
const CodeCompleteOptions CodeCompleteOpts
CodeCompletionResult(const char *Keyword, unsigned Priority=CCP_Keyword)
Build a result that refers to a keyword or symbol.
const NamedDecl * getDeclaration() const
Retrieve the declaration stored in this result.
Priority for a preprocessor macro.
QualType getBaseType() const
Retrieve the type of the base object in a member-access expression.
bool includeBriefComments() const
Whether to include brief documentation comments within the set of code completions returned...
A piece of text that describes the parameter that corresponds to the code-completion location within ...
A string that acts as a placeholder for, e.g., a function call argument.
CodeCompletionContext(Kind CCKind, QualType T, ArrayRef< IdentifierInfo *> SelIdents=None)
Construct a new code-completion context of the given kind.
bool Hidden
Whether this result is hidden by another name.
unsigned getAvailability() const
Retrieve the availability of this code completion result.
A left parenthesis (&#39;(&#39;).
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
Definition: SemaDecl.cpp:13401
Code completion occurred within a preprocessor expression.
Code completion occurred where an expression is expected.
Priority for a code pattern.
bool AllParametersAreInformative
Whether all parameters (of a function, Objective-C method, etc.) should be considered "informative"...
An unspecified code-completion context where we should also add macro completions.
CodeCompletionAllocator & getAllocator() override
Retrieve the allocator that will be used to allocate code completion strings.
A left angle bracket (&#39;<&#39;).
void setCXXScopeSpecifier(CXXScopeSpec SS)
Sets the scope specifier that comes before the completion token.
A right angle bracket (&#39;>&#39;).
bool OutputIsBinary
Whether the output format for the code-completion consumer is binary.
ResultKind
Describes the kind of result generated.
The selector of the given message exactly matches the selector of the current method, which might imply that some kind of delegation is occurring.
CodeCompletionTUInfo(std::shared_ptr< GlobalCodeCompletionAllocator > Allocator)
unsigned LoadExternal
Hint whether to load data from the external AST to provide full results.
Code completion occurred on the right-hand side of a member access expression using the dot operator...
SimplifiedTypeClass
A simplified classification of types used when determining "similar" types for code completion...
Code completion occurred where a type name is expected.
Horizontal whitespace (&#39; &#39;).
bool includeCodePatterns() const
Whether the code-completion consumer wants to see code patterns.
StringRef Text
Definition: Format.cpp:1523
bool DeclaringEntity
Whether we&#39;re completing a declaration of the given entity, rather than a use of that entity...
unsigned getPriority() const
Retrieve the priority of this code completion result.
unsigned IncludeMacros
Show macros in code completion results.
CodeCompletionBuilder(CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo)
This represents a decl that may have a name.
Definition: Decl.h:248
bool includeNamespaceLevelDecls() const
Whether to include declarations in namespace contexts (including the global namespace).
Declaration of a template function.
Definition: DeclTemplate.h:967
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:127
bool includeGlobals() const
Whether to include global (top-level) declaration results.
Priority for a non-type declaration.
Priority for the next initialization in a constructor initializer list.