clang  15.0.0git
CodeCompleteConsumer.cpp
Go to the documentation of this file.
1 //===- CodeCompleteConsumer.cpp - Code Completion Interface ---------------===//
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 implements the CodeCompleteConsumer class.
10 //
11 //===----------------------------------------------------------------------===//
12 
14 #include "clang-c/Index.h"
15 #include "clang/AST/Decl.h"
16 #include "clang/AST/DeclBase.h"
17 #include "clang/AST/DeclObjC.h"
18 #include "clang/AST/DeclTemplate.h"
20 #include "clang/AST/Type.h"
22 #include "clang/Lex/Preprocessor.h"
23 #include "clang/Sema/Sema.h"
24 #include "llvm/ADT/SmallString.h"
25 #include "llvm/ADT/SmallVector.h"
26 #include "llvm/ADT/StringExtras.h"
27 #include "llvm/ADT/StringRef.h"
28 #include "llvm/ADT/Twine.h"
29 #include "llvm/Support/Casting.h"
30 #include "llvm/Support/Compiler.h"
31 #include "llvm/Support/ErrorHandling.h"
32 #include "llvm/Support/FormatVariadic.h"
33 #include "llvm/Support/raw_ostream.h"
34 #include <algorithm>
35 #include <cassert>
36 #include <cstdint>
37 #include <string>
38 
39 using namespace clang;
40 
41 //===----------------------------------------------------------------------===//
42 // Code completion context implementation
43 //===----------------------------------------------------------------------===//
44 
46  switch (CCKind) {
47  case CCC_Recovery:
48  case CCC_Statement:
49  case CCC_Expression:
52  case CCC_Symbol:
54  return true;
55 
56  case CCC_TopLevel:
57  case CCC_ObjCInterface:
59  case CCC_ObjCIvarList:
64  case CCC_EnumTag:
65  case CCC_UnionTag:
68  case CCC_Namespace:
69  case CCC_Type:
70  case CCC_NewName:
71  case CCC_MacroName:
72  case CCC_MacroNameUse:
76  case CCC_SelectorName:
77  case CCC_TypeQualifiers:
78  case CCC_Other:
84  case CCC_IncludedFile:
85  case CCC_Attribute:
86  return false;
87  }
88 
89  llvm_unreachable("Invalid CodeCompletionContext::Kind!");
90 }
91 
93  using CCKind = CodeCompletionContext::Kind;
94  switch (Kind) {
95  case CCKind::CCC_Other:
96  return "Other";
97  case CCKind::CCC_OtherWithMacros:
98  return "OtherWithMacros";
99  case CCKind::CCC_TopLevel:
100  return "TopLevel";
101  case CCKind::CCC_ObjCInterface:
102  return "ObjCInterface";
103  case CCKind::CCC_ObjCImplementation:
104  return "ObjCImplementation";
105  case CCKind::CCC_ObjCIvarList:
106  return "ObjCIvarList";
107  case CCKind::CCC_ClassStructUnion:
108  return "ClassStructUnion";
109  case CCKind::CCC_Statement:
110  return "Statement";
111  case CCKind::CCC_Expression:
112  return "Expression";
113  case CCKind::CCC_ObjCMessageReceiver:
114  return "ObjCMessageReceiver";
115  case CCKind::CCC_DotMemberAccess:
116  return "DotMemberAccess";
117  case CCKind::CCC_ArrowMemberAccess:
118  return "ArrowMemberAccess";
119  case CCKind::CCC_ObjCPropertyAccess:
120  return "ObjCPropertyAccess";
121  case CCKind::CCC_EnumTag:
122  return "EnumTag";
123  case CCKind::CCC_UnionTag:
124  return "UnionTag";
125  case CCKind::CCC_ClassOrStructTag:
126  return "ClassOrStructTag";
127  case CCKind::CCC_ObjCProtocolName:
128  return "ObjCProtocolName";
129  case CCKind::CCC_Namespace:
130  return "Namespace";
131  case CCKind::CCC_Type:
132  return "Type";
133  case CCKind::CCC_NewName:
134  return "NewName";
135  case CCKind::CCC_Symbol:
136  return "Symbol";
137  case CCKind::CCC_SymbolOrNewName:
138  return "SymbolOrNewName";
139  case CCKind::CCC_MacroName:
140  return "MacroName";
141  case CCKind::CCC_MacroNameUse:
142  return "MacroNameUse";
143  case CCKind::CCC_PreprocessorExpression:
144  return "PreprocessorExpression";
145  case CCKind::CCC_PreprocessorDirective:
146  return "PreprocessorDirective";
147  case CCKind::CCC_NaturalLanguage:
148  return "NaturalLanguage";
149  case CCKind::CCC_SelectorName:
150  return "SelectorName";
151  case CCKind::CCC_TypeQualifiers:
152  return "TypeQualifiers";
153  case CCKind::CCC_ParenthesizedExpression:
154  return "ParenthesizedExpression";
155  case CCKind::CCC_ObjCInstanceMessage:
156  return "ObjCInstanceMessage";
157  case CCKind::CCC_ObjCClassMessage:
158  return "ObjCClassMessage";
159  case CCKind::CCC_ObjCInterfaceName:
160  return "ObjCInterfaceName";
161  case CCKind::CCC_ObjCCategoryName:
162  return "ObjCCategoryName";
163  case CCKind::CCC_IncludedFile:
164  return "IncludedFile";
165  case CCKind::CCC_Attribute:
166  return "Attribute";
167  case CCKind::CCC_Recovery:
168  return "Recovery";
169  }
170  llvm_unreachable("Invalid CodeCompletionContext::Kind!");
171 }
172 
173 //===----------------------------------------------------------------------===//
174 // Code completion string implementation
175 //===----------------------------------------------------------------------===//
176 
178  : Kind(Kind), Text("") {
179  switch (Kind) {
180  case CK_TypedText:
181  case CK_Text:
182  case CK_Placeholder:
183  case CK_Informative:
184  case CK_ResultType:
185  case CK_CurrentParameter:
186  this->Text = Text;
187  break;
188 
189  case CK_Optional:
190  llvm_unreachable("Optional strings cannot be created from text");
191 
192  case CK_LeftParen:
193  this->Text = "(";
194  break;
195 
196  case CK_RightParen:
197  this->Text = ")";
198  break;
199 
200  case CK_LeftBracket:
201  this->Text = "[";
202  break;
203 
204  case CK_RightBracket:
205  this->Text = "]";
206  break;
207 
208  case CK_LeftBrace:
209  this->Text = "{";
210  break;
211 
212  case CK_RightBrace:
213  this->Text = "}";
214  break;
215 
216  case CK_LeftAngle:
217  this->Text = "<";
218  break;
219 
220  case CK_RightAngle:
221  this->Text = ">";
222  break;
223 
224  case CK_Comma:
225  this->Text = ", ";
226  break;
227 
228  case CK_Colon:
229  this->Text = ":";
230  break;
231 
232  case CK_SemiColon:
233  this->Text = ";";
234  break;
235 
236  case CK_Equal:
237  this->Text = " = ";
238  break;
239 
240  case CK_HorizontalSpace:
241  this->Text = " ";
242  break;
243 
244  case CK_VerticalSpace:
245  this->Text = "\n";
246  break;
247  }
248 }
249 
252  return Chunk(CK_Text, Text);
253 }
254 
257  Chunk Result;
258  Result.Kind = CK_Optional;
259  Result.Optional = Optional;
260  return Result;
261 }
262 
265  return Chunk(CK_Placeholder, Placeholder);
266 }
267 
270  return Chunk(CK_Informative, Informative);
271 }
272 
275  return Chunk(CK_ResultType, ResultType);
276 }
277 
279  const char *CurrentParameter) {
280  return Chunk(CK_CurrentParameter, CurrentParameter);
281 }
282 
283 CodeCompletionString::CodeCompletionString(
284  const Chunk *Chunks, unsigned NumChunks, unsigned Priority,
285  CXAvailabilityKind Availability, const char **Annotations,
286  unsigned NumAnnotations, StringRef ParentName, const char *BriefComment)
287  : NumChunks(NumChunks), NumAnnotations(NumAnnotations), Priority(Priority),
288  Availability(Availability), ParentName(ParentName),
289  BriefComment(BriefComment) {
290  assert(NumChunks <= 0xffff);
291  assert(NumAnnotations <= 0xffff);
292 
293  Chunk *StoredChunks = reinterpret_cast<Chunk *>(this + 1);
294  for (unsigned I = 0; I != NumChunks; ++I)
295  StoredChunks[I] = Chunks[I];
296 
297  const char **StoredAnnotations =
298  reinterpret_cast<const char **>(StoredChunks + NumChunks);
299  for (unsigned I = 0; I != NumAnnotations; ++I)
300  StoredAnnotations[I] = Annotations[I];
301 }
302 
304  return NumAnnotations;
305 }
306 
307 const char *CodeCompletionString::getAnnotation(unsigned AnnotationNr) const {
308  if (AnnotationNr < NumAnnotations)
309  return reinterpret_cast<const char *const *>(end())[AnnotationNr];
310  else
311  return nullptr;
312 }
313 
315  std::string Result;
316  llvm::raw_string_ostream OS(Result);
317 
318  for (const Chunk &C : *this) {
319  switch (C.Kind) {
320  case CK_Optional:
321  OS << "{#" << C.Optional->getAsString() << "#}";
322  break;
323  case CK_Placeholder:
324  OS << "<#" << C.Text << "#>";
325  break;
326  case CK_Informative:
327  case CK_ResultType:
328  OS << "[#" << C.Text << "#]";
329  break;
330  case CK_CurrentParameter:
331  OS << "<#" << C.Text << "#>";
332  break;
333  default:
334  OS << C.Text;
335  break;
336  }
337  }
338  return Result;
339 }
340 
342  for (const Chunk &C : *this)
343  if (C.Kind == CK_TypedText)
344  return C.Text;
345 
346  return nullptr;
347 }
348 
349 const char *CodeCompletionAllocator::CopyString(const Twine &String) {
350  SmallString<128> Data;
351  StringRef Ref = String.toStringRef(Data);
352  // FIXME: It would be more efficient to teach Twine to tell us its size and
353  // then add a routine there to fill in an allocated char* with the contents
354  // of the string.
355  char *Mem = (char *)Allocate(Ref.size() + 1, 1);
356  std::copy(Ref.begin(), Ref.end(), Mem);
357  Mem[Ref.size()] = 0;
358  return Mem;
359 }
360 
362  if (!isa<NamedDecl>(DC))
363  return {};
364 
365  // Check whether we've already cached the parent name.
366  StringRef &CachedParentName = ParentNames[DC];
367  if (!CachedParentName.empty())
368  return CachedParentName;
369 
370  // If we already processed this DeclContext and assigned empty to it, the
371  // data pointer will be non-null.
372  if (CachedParentName.data() != nullptr)
373  return {};
374 
375  // Find the interesting names.
377  while (DC && !DC->isFunctionOrMethod()) {
378  if (const auto *ND = dyn_cast<NamedDecl>(DC)) {
379  if (ND->getIdentifier())
380  Contexts.push_back(DC);
381  }
382 
383  DC = DC->getParent();
384  }
385 
386  {
388  llvm::raw_svector_ostream OS(S);
389  bool First = true;
390  for (const DeclContext *CurDC : llvm::reverse(Contexts)) {
391  if (First)
392  First = false;
393  else {
394  OS << "::";
395  }
396 
397  if (const auto *CatImpl = dyn_cast<ObjCCategoryImplDecl>(CurDC))
398  CurDC = CatImpl->getCategoryDecl();
399 
400  if (const auto *Cat = dyn_cast<ObjCCategoryDecl>(CurDC)) {
401  const ObjCInterfaceDecl *Interface = Cat->getClassInterface();
402  if (!Interface) {
403  // Assign an empty StringRef but with non-null data to distinguish
404  // between empty because we didn't process the DeclContext yet.
405  CachedParentName = StringRef((const char *)(uintptr_t)~0U, 0);
406  return {};
407  }
408 
409  OS << Interface->getName() << '(' << Cat->getName() << ')';
410  } else {
411  OS << cast<NamedDecl>(CurDC)->getName();
412  }
413  }
414 
415  CachedParentName = AllocatorRef->CopyString(OS.str());
416  }
417 
418  return CachedParentName;
419 }
420 
422  void *Mem = getAllocator().Allocate(
423  sizeof(CodeCompletionString) + sizeof(Chunk) * Chunks.size() +
424  sizeof(const char *) * Annotations.size(),
425  alignof(CodeCompletionString));
426  CodeCompletionString *Result = new (Mem) CodeCompletionString(
427  Chunks.data(), Chunks.size(), Priority, Availability, Annotations.data(),
428  Annotations.size(), ParentName, BriefComment);
429  Chunks.clear();
430  return Result;
431 }
432 
434  Chunks.push_back(Chunk(CodeCompletionString::CK_TypedText, Text));
435 }
436 
438  Chunks.push_back(Chunk::CreateText(Text));
439 }
440 
442  Chunks.push_back(Chunk::CreateOptional(Optional));
443 }
444 
445 void CodeCompletionBuilder::AddPlaceholderChunk(const char *Placeholder) {
446  Chunks.push_back(Chunk::CreatePlaceholder(Placeholder));
447 }
448 
450  Chunks.push_back(Chunk::CreateInformative(Text));
451 }
452 
453 void CodeCompletionBuilder::AddResultTypeChunk(const char *ResultType) {
454  Chunks.push_back(Chunk::CreateResultType(ResultType));
455 }
456 
458  const char *CurrentParameter) {
459  Chunks.push_back(Chunk::CreateCurrentParameter(CurrentParameter));
460 }
461 
463  const char *Text) {
464  Chunks.push_back(Chunk(CK, Text));
465 }
466 
468  if (DC->isTranslationUnit())
469  return;
470 
471  if (DC->isFunctionOrMethod())
472  return;
473 
474  if (!isa<NamedDecl>(DC))
475  return;
476 
477  ParentName = getCodeCompletionTUInfo().getParentName(DC);
478 }
479 
480 void CodeCompletionBuilder::addBriefComment(StringRef Comment) {
481  BriefComment = Allocator.CopyString(Comment);
482 }
483 
484 //===----------------------------------------------------------------------===//
485 // Code completion overload candidate implementation
486 //===----------------------------------------------------------------------===//
488  if (getKind() == CK_Function)
489  return Function;
490  else if (getKind() == CK_FunctionTemplate)
491  return FunctionTemplate->getTemplatedDecl();
492  else
493  return nullptr;
494 }
495 
496 const FunctionType *
498  switch (Kind) {
499  case CK_Function:
500  return Function->getType()->getAs<FunctionType>();
501 
502  case CK_FunctionTemplate:
503  return FunctionTemplate->getTemplatedDecl()
504  ->getType()
505  ->getAs<FunctionType>();
506 
507  case CK_FunctionType:
508  return Type;
509 
510  case CK_Template:
511  case CK_Aggregate:
512  return nullptr;
513  }
514 
515  llvm_unreachable("Invalid CandidateKind!");
516 }
517 
519  if (Kind == CK_Template)
520  return Template->getTemplateParameters()->size();
521 
522  if (Kind == CK_Aggregate) {
523  unsigned Count =
524  std::distance(AggregateType->field_begin(), AggregateType->field_end());
525  if (const auto *CRD = dyn_cast<CXXRecordDecl>(AggregateType))
526  Count += CRD->getNumBases();
527  return Count;
528  }
529 
530  if (const auto *FT = getFunctionType())
531  if (const auto *FPT = dyn_cast<FunctionProtoType>(FT))
532  return FPT->getNumParams();
533 
534  return 0;
535 }
536 
537 QualType
539  if (Kind == CK_Aggregate) {
540  if (const auto *CRD = dyn_cast<CXXRecordDecl>(AggregateType)) {
541  if (N < CRD->getNumBases())
542  return std::next(CRD->bases_begin(), N)->getType();
543  N -= CRD->getNumBases();
544  }
545  for (const auto *Field : AggregateType->fields())
546  if (N-- == 0)
547  return Field->getType();
548  return QualType();
549  }
550 
551  if (Kind == CK_Template) {
552  TemplateParameterList *TPL = getTemplate()->getTemplateParameters();
553  if (N < TPL->size())
554  if (const auto *D = dyn_cast<NonTypeTemplateParmDecl>(TPL->getParam(N)))
555  return D->getType();
556  return QualType();
557  }
558 
559  if (const auto *FT = getFunctionType())
560  if (const auto *FPT = dyn_cast<FunctionProtoType>(FT))
561  if (N < FPT->getNumParams())
562  return FPT->getParamType(N);
563  return QualType();
564 }
565 
566 const NamedDecl *
568  if (Kind == CK_Aggregate) {
569  if (const auto *CRD = dyn_cast<CXXRecordDecl>(AggregateType)) {
570  if (N < CRD->getNumBases())
571  return std::next(CRD->bases_begin(), N)->getType()->getAsTagDecl();
572  N -= CRD->getNumBases();
573  }
574  for (const auto *Field : AggregateType->fields())
575  if (N-- == 0)
576  return Field;
577  return nullptr;
578  }
579 
580  if (Kind == CK_Template) {
581  TemplateParameterList *TPL = getTemplate()->getTemplateParameters();
582  if (N < TPL->size())
583  return TPL->getParam(N);
584  return nullptr;
585  }
586 
587  // Note that if we only have a FunctionProtoType, we don't have param decls.
588  if (const auto *FD = getFunction()) {
589  if (N < FD->param_size())
590  return FD->getParamDecl(N);
591  }
592  return nullptr;
593 }
594 
595 //===----------------------------------------------------------------------===//
596 // Code completion consumer implementation
597 //===----------------------------------------------------------------------===//
598 
600 
602  StringRef Filter, CodeCompletionResult Result) {
603  switch (Result.Kind) {
605  return !(Result.Declaration->getIdentifier() &&
606  Result.Declaration->getIdentifier()->getName().startswith(Filter));
608  return !StringRef(Result.Keyword).startswith(Filter);
610  return !Result.Macro->getName().startswith(Filter);
612  return !(Result.Pattern->getTypedText() &&
613  StringRef(Result.Pattern->getTypedText()).startswith(Filter));
614  }
615  llvm_unreachable("Unknown code completion result Kind.");
616 }
617 
619  Sema &SemaRef, CodeCompletionContext Context, CodeCompletionResult *Results,
620  unsigned NumResults) {
621  std::stable_sort(Results, Results + NumResults);
622 
623  if (!Context.getPreferredType().isNull())
624  OS << "PREFERRED-TYPE: " << Context.getPreferredType() << '\n';
625 
626  StringRef Filter = SemaRef.getPreprocessor().getCodeCompletionFilter();
627  // Print the completions.
628  for (unsigned I = 0; I != NumResults; ++I) {
629  if (!Filter.empty() && isResultFilteredOut(Filter, Results[I]))
630  continue;
631  OS << "COMPLETION: ";
632  switch (Results[I].Kind) {
634  OS << *Results[I].Declaration;
635  {
636  std::vector<std::string> Tags;
637  if (Results[I].Hidden)
638  Tags.push_back("Hidden");
639  if (Results[I].InBaseClass)
640  Tags.push_back("InBase");
641  if (Results[I].Availability ==
643  Tags.push_back("Inaccessible");
644  if (!Tags.empty())
645  OS << " (" << llvm::join(Tags, ",") << ")";
646  }
647  if (CodeCompletionString *CCS = Results[I].CreateCodeCompletionString(
648  SemaRef, Context, getAllocator(), CCTUInfo,
649  includeBriefComments())) {
650  OS << " : " << CCS->getAsString();
651  if (const char *BriefComment = CCS->getBriefComment())
652  OS << " : " << BriefComment;
653  }
654  break;
655 
657  OS << Results[I].Keyword;
658  break;
659 
661  OS << Results[I].Macro->getName();
662  if (CodeCompletionString *CCS = Results[I].CreateCodeCompletionString(
663  SemaRef, Context, getAllocator(), CCTUInfo,
664  includeBriefComments())) {
665  OS << " : " << CCS->getAsString();
666  }
667  break;
668 
670  OS << "Pattern : " << Results[I].Pattern->getAsString();
671  break;
672  }
673  for (const FixItHint &FixIt : Results[I].FixIts) {
674  const SourceLocation BLoc = FixIt.RemoveRange.getBegin();
675  const SourceLocation ELoc = FixIt.RemoveRange.getEnd();
676 
677  SourceManager &SM = SemaRef.SourceMgr;
678  std::pair<FileID, unsigned> BInfo = SM.getDecomposedLoc(BLoc);
679  std::pair<FileID, unsigned> EInfo = SM.getDecomposedLoc(ELoc);
680  // Adjust for token ranges.
681  if (FixIt.RemoveRange.isTokenRange())
682  EInfo.second += Lexer::MeasureTokenLength(ELoc, SM, SemaRef.LangOpts);
683 
684  OS << " (requires fix-it:"
685  << " {" << SM.getLineNumber(BInfo.first, BInfo.second) << ':'
686  << SM.getColumnNumber(BInfo.first, BInfo.second) << '-'
687  << SM.getLineNumber(EInfo.first, EInfo.second) << ':'
688  << SM.getColumnNumber(EInfo.first, EInfo.second) << "}"
689  << " to \"" << FixIt.CodeToInsert << "\")";
690  }
691  OS << '\n';
692  }
693 }
694 
695 // This function is used solely to preserve the former presentation of overloads
696 // by "clang -cc1 -code-completion-at", since CodeCompletionString::getAsString
697 // needs to be improved for printing the newer and more detailed overload
698 // chunks.
700  std::string Result;
701  llvm::raw_string_ostream OS(Result);
702 
703  for (auto &C : CCS) {
704  switch (C.Kind) {
707  OS << "[#" << C.Text << "#]";
708  break;
709 
711  OS << "<#" << C.Text << "#>";
712  break;
713 
714  // FIXME: We can also print optional parameters of an overload.
716  break;
717 
718  default:
719  OS << C.Text;
720  break;
721  }
722  }
723  return Result;
724 }
725 
727  Sema &SemaRef, unsigned CurrentArg, OverloadCandidate *Candidates,
728  unsigned NumCandidates, SourceLocation OpenParLoc, bool Braced) {
729  OS << "OPENING_PAREN_LOC: ";
730  OpenParLoc.print(OS, SemaRef.getSourceManager());
731  OS << "\n";
732 
733  for (unsigned I = 0; I != NumCandidates; ++I) {
734  if (CodeCompletionString *CCS = Candidates[I].CreateSignatureString(
735  CurrentArg, SemaRef, getAllocator(), CCTUInfo,
736  includeBriefComments(), Braced)) {
737  OS << "OVERLOAD: " << getOverloadAsString(*CCS) << "\n";
738  }
739  }
740 }
741 
742 /// Retrieve the effective availability of the given declaration.
745  if (isa<EnumConstantDecl>(D))
746  AR = std::max(AR, cast<Decl>(D->getDeclContext())->getAvailability());
747  return AR;
748 }
749 
750 void CodeCompletionResult::computeCursorKindAndAvailability(bool Accessible) {
751  switch (Kind) {
752  case RK_Pattern:
753  if (!Declaration) {
754  // Do nothing: Patterns can come with cursor kinds!
755  break;
756  }
757  LLVM_FALLTHROUGH;
758 
759  case RK_Declaration: {
760  // Set the availability based on attributes.
761  switch (getDeclAvailability(Declaration)) {
762  case AR_Available:
763  case AR_NotYetIntroduced:
764  Availability = CXAvailability_Available;
765  break;
766 
767  case AR_Deprecated:
768  Availability = CXAvailability_Deprecated;
769  break;
770 
771  case AR_Unavailable:
772  Availability = CXAvailability_NotAvailable;
773  break;
774  }
775 
776  if (const auto *Function = dyn_cast<FunctionDecl>(Declaration))
777  if (Function->isDeleted())
778  Availability = CXAvailability_NotAvailable;
779 
780  CursorKind = getCursorKindForDecl(Declaration);
781  if (CursorKind == CXCursor_UnexposedDecl) {
782  // FIXME: Forward declarations of Objective-C classes and protocols
783  // are not directly exposed, but we want code completion to treat them
784  // like a definition.
785  if (isa<ObjCInterfaceDecl>(Declaration))
786  CursorKind = CXCursor_ObjCInterfaceDecl;
787  else if (isa<ObjCProtocolDecl>(Declaration))
788  CursorKind = CXCursor_ObjCProtocolDecl;
789  else
790  CursorKind = CXCursor_NotImplemented;
791  }
792  break;
793  }
794 
795  case RK_Macro:
796  case RK_Keyword:
797  llvm_unreachable("Macro and keyword kinds are handled by the constructors");
798  }
799 
800  if (!Accessible)
801  Availability = CXAvailability_NotAccessible;
802 }
803 
804 /// Retrieve the name that should be used to order a result.
805 ///
806 /// If the name needs to be constructed as a string, that string will be
807 /// saved into Saved and the returned StringRef will refer to it.
809  switch (Kind) {
810  case RK_Keyword:
811  return Keyword;
812  case RK_Pattern:
813  return Pattern->getTypedText();
814  case RK_Macro:
815  return Macro->getName();
816  case RK_Declaration:
817  // Handle declarations below.
818  break;
819  }
820 
821  DeclarationName Name = Declaration->getDeclName();
822 
823  // If the name is a simple identifier (by far the common case), or a
824  // zero-argument selector, just return a reference to that identifier.
825  if (IdentifierInfo *Id = Name.getAsIdentifierInfo())
826  return Id->getName();
827  if (Name.isObjCZeroArgSelector())
828  if (IdentifierInfo *Id = Name.getObjCSelector().getIdentifierInfoForSlot(0))
829  return Id->getName();
830 
831  Saved = Name.getAsString();
832  return Saved;
833 }
834 
836  const CodeCompletionResult &Y) {
837  std::string XSaved, YSaved;
838  StringRef XStr = X.getOrderedName(XSaved);
839  StringRef YStr = Y.getOrderedName(YSaved);
840  int cmp = XStr.compare_insensitive(YStr);
841  if (cmp)
842  return cmp < 0;
843 
844  // If case-insensitive comparison fails, try case-sensitive comparison.
845  return XStr.compare(YStr) < 0;
846 }
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::ObjCInterfaceDecl
Represents an ObjC class declaration.
Definition: DeclObjC.h:1150
clang::CodeCompletionContext::CCC_Other
@ CCC_Other
An unspecified code-completion context.
Definition: CodeCompleteConsumer.h:191
max
__DEVICE__ int max(int __a, int __b)
Definition: __clang_cuda_math.h:196
clang::CodeCompletionBuilder::addParentContext
void addParentContext(const DeclContext *DC)
Add the parent context information to this code completion.
Definition: CodeCompleteConsumer.cpp:467
clang::CodeCompletionString::getAnnotationCount
unsigned getAnnotationCount() const
Retrieve the number of annotations for this code completion result.
Definition: CodeCompleteConsumer.cpp:303
clang::CodeCompletionContext::Kind
Kind
Definition: CodeCompleteConsumer.h:189
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:1356
clang::CodeCompletionBuilder::TakeString
CodeCompletionString * TakeString()
Take the resulting completion string.
Definition: CodeCompleteConsumer.cpp:421
clang::CodeCompletionContext::CCC_ObjCInstanceMessage
@ CCC_ObjCInstanceMessage
Code completion where an Objective-C instance message is expected.
Definition: CodeCompleteConsumer.h:317
Optional
llvm::Optional< T > Optional
Definition: ByteCodeExprGen.cpp:23
clang::CodeCompletionContext::CCC_Expression
@ CCC_Expression
Code completion occurred where an expression is expected.
Definition: CodeCompleteConsumer.h:221
clang::CodeCompletionBuilder::AddOptionalChunk
void AddOptionalChunk(CodeCompletionString *Optional)
Add a new optional chunk.
Definition: CodeCompleteConsumer.cpp:441
clang::Sema::SourceMgr
SourceManager & SourceMgr
Definition: Sema.h:413
clang::CodeCompletionAllocator::CopyString
const char * CopyString(const Twine &String)
Copy the given string into this allocator.
Definition: CodeCompleteConsumer.cpp:349
clang::PrintingCodeCompleteConsumer::isResultFilteredOut
bool isResultFilteredOut(StringRef Filter, CodeCompletionResult Results) override
Definition: CodeCompleteConsumer.cpp:601
llvm::SmallVector
Definition: LLVM.h:38
clang::AR_Deprecated
@ AR_Deprecated
Definition: DeclBase.h:72
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:86
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::CodeCompletionContext::CCC_ObjCImplementation
@ CCC_ObjCImplementation
Code completion occurred within an Objective-C implementation or category implementation.
Definition: CodeCompleteConsumer.h:207
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:675
clang::CodeCompletionBuilder::AddChunk
void AddChunk(CodeCompletionString::ChunkKind CK, const char *Text="")
Add a new chunk.
Definition: CodeCompleteConsumer.cpp:462
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
clang::tooling::Filter
llvm::cl::opt< std::string > Filter
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:497
Index.h
clang::CodeCompletionString::CK_RightParen
@ CK_RightParen
A right parenthesis (')').
Definition: CodeCompleteConsumer.h:481
clang::Sema::getSourceManager
SourceManager & getSourceManager() const
Definition: Sema.h:1612
CodeCompleteConsumer.h
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:567
clang::ComparisonCategoryType::First
@ First
clang::CodeCompletionContext::CCC_IncludedFile
@ CCC_IncludedFile
Code completion inside the filename part of a include directive.
Definition: CodeCompleteConsumer.h:330
clang::CodeCompletionResult::RK_Keyword
@ RK_Keyword
Refers to a keyword or symbol.
Definition: CodeCompleteConsumer.h:757
clang::CodeCompletionString::Chunk::Chunk
Chunk()
Definition: CodeCompleteConsumer.h:540
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::Lexer::MeasureTokenLength
static unsigned MeasureTokenLength(SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts)
MeasureTokenLength - Relex the token at the specified location and return its length in bytes in the ...
Definition: Lexer.cpp:452
clang::CodeCompletionBuilder::AddTypedTextChunk
void AddTypedTextChunk(const char *Text)
Add a new typed-text chunk.
Definition: CodeCompleteConsumer.cpp:433
clang::FunctionType
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:3559
clang::CodeCompletionString::CK_HorizontalSpace
@ CK_HorizontalSpace
Horizontal whitespace (' ').
Definition: CodeCompleteConsumer.h:514
clang::DeclarationName
The name of a declaration.
Definition: DeclarationName.h:144
clang::CodeCompletionString::end
iterator end() const
Definition: CodeCompleteConsumer.h:600
CXAvailability_NotAvailable
@ CXAvailability_NotAvailable
The entity is not available; any use of it will be an error.
Definition: Index.h:138
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::SourceManager
This class handles loading and caching of source files into memory.
Definition: SourceManager.h:627
clang::CodeCompletionResult
Captures a result of code completion.
Definition: CodeCompleteConsumer.h:749
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1500
Preprocessor.h
clang::Decl::getAvailability
AvailabilityResult getAvailability(std::string *Message=nullptr, VersionTuple EnclosingVersion=VersionTuple(), StringRef *RealizedPlatform=nullptr) const
Determine the availability of the given declaration.
Definition: DeclBase.cpp:622
Decl.h
DeclObjC.h
clang::CodeCompletionString::ChunkKind
ChunkKind
The different kinds of "chunks" that can occur within a code completion string.
Definition: CodeCompleteConsumer.h:446
clang::FixItHint
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
Definition: Diagnostic.h:71
clang::CodeCompletionContext::CCC_ObjCCategoryName
@ CCC_ObjCCategoryName
Code completion where an Objective-C category name is expected.
Definition: CodeCompleteConsumer.h:327
U
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::CodeCompletionString::CK_LeftAngle
@ CK_LeftAngle
A left angle bracket ('<').
Definition: CodeCompleteConsumer.h:496
clang::SourceLocation::print
void print(raw_ostream &OS, const SourceManager &SM) const
Definition: SourceLocation.cpp:62
clang::Decl::Kind
Kind
Lists the kind of concrete classes of Decl.
Definition: DeclBase.h:86
clang::CodeCompletionBuilder::AddCurrentParameterChunk
void AddCurrentParameterChunk(const char *CurrentParameter)
Add a new current-parameter chunk.
Definition: CodeCompleteConsumer.cpp:457
clang::AR_Available
@ AR_Available
Definition: DeclBase.h:70
clang::TemplateParameterList::getParam
NamedDecl * getParam(unsigned Idx)
Definition: DeclTemplate.h:138
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
DeclTemplate.h
clang::CodeCompletionContext::CCC_ObjCProtocolName
@ CCC_ObjCProtocolName
Code completion occurred where a protocol name is expected.
Definition: CodeCompleteConsumer.h:264
clang::CodeCompletionContext::CCC_EnumTag
@ CCC_EnumTag
Code completion occurred after the "enum" keyword, to indicate an enumeration name.
Definition: CodeCompleteConsumer.h:253
Id
int Id
Definition: ASTDiff.cpp:191
clang::CodeCompletionString::Chunk::CreateOptional
static Chunk CreateOptional(CodeCompletionString *Optional)
Create a new optional chunk.
Definition: CodeCompleteConsumer.cpp:256
DeclBase.h
CXCursor_NotImplemented
@ CXCursor_NotImplemented
Definition: Index.h:1904
getOverloadAsString
static std::string getOverloadAsString(const CodeCompletionString &CCS)
Definition: CodeCompleteConsumer.cpp:699
CXCursor_ObjCProtocolDecl
@ CXCursor_ObjCProtocolDecl
An Objective-C @protocol declaration.
Definition: Index.h:1744
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:437
clang::CodeCompletionString::Chunk::CreateResultType
static Chunk CreateResultType(const char *ResultType)
Create a new result type chunk.
Definition: CodeCompleteConsumer.cpp:274
CXAvailability_NotAccessible
@ CXAvailability_NotAccessible
The entity is available, but not accessible; any use of it will be an error.
Definition: Index.h:143
clang::Type::getAs
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:7243
clang::CodeCompletionContext::CCC_ObjCInterfaceName
@ CCC_ObjCInterfaceName
Code completion where the name of an Objective-C class is expected.
Definition: CodeCompleteConsumer.h:324
uintptr_t
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
Definition: opencl-c-base.h:139
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
IdentifierTable.h
clang::DeclContext::isTranslationUnit
bool isTranslationUnit() const
Definition: DeclBase.h:1951
Type.h
clang::CodeCompletionContext::CCC_Attribute
@ CCC_Attribute
Code completion of an attribute name.
Definition: CodeCompleteConsumer.h:333
llvm::SmallString< 128 >
clang::CodeCompletionString::CK_LeftParen
@ CK_LeftParen
A left parenthesis ('(').
Definition: CodeCompleteConsumer.h:478
clang::CodeCompletionContext::CCC_ObjCMessageReceiver
@ CCC_ObjCMessageReceiver
Code completion occurred where an Objective-C message receiver is expected.
Definition: CodeCompleteConsumer.h:225
clang::TemplateParameterList
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:69
clang::Preprocessor::getCodeCompletionFilter
StringRef getCodeCompletionFilter()
Get the code completion token for filtering purposes.
Definition: Preprocessor.h:1368
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
getKind
static Decl::Kind getKind(const Decl *D)
Definition: DeclBase.cpp:1008
Sema.h
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::Sema::LangOpts
const LangOptions & LangOpts
Definition: Sema.h:408
clang::CodeCompletionContext::CCC_OtherWithMacros
@ CCC_OtherWithMacros
An unspecified code-completion context where we should also add macro completions.
Definition: CodeCompleteConsumer.h:195
clang::CodeCompletionBuilder::AddResultTypeChunk
void AddResultTypeChunk(const char *ResultType)
Add a new result-type chunk.
Definition: CodeCompleteConsumer.cpp:453
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:760
clang::PrintingCodeCompleteConsumer::ProcessOverloadCandidates
void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg, OverloadCandidate *Candidates, unsigned NumCandidates, SourceLocation OpenParLoc, bool Braced) override
Definition: CodeCompleteConsumer.cpp:726
clang::CodeCompleteConsumer::OverloadCandidate
Definition: CodeCompleteConsumer.h:1005
clang::CodeCompletionString::CK_RightBrace
@ CK_RightBrace
A right brace ('}').
Definition: CodeCompleteConsumer.h:493
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::CodeCompletionContext::CCC_PreprocessorExpression
@ CCC_PreprocessorExpression
Code completion occurred within a preprocessor expression.
Definition: CodeCompleteConsumer.h:292
clang::NamedDecl::getIdentifier
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition: Decl.h:268
CXAvailability_Available
@ CXAvailability_Available
The entity is available.
Definition: Index.h:129
clang::DeclContext::getParent
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition: DeclBase.h:1876
CXAvailabilityKind
CXAvailabilityKind
Describes the availability of a particular entity, which indicates whether the use of this entity wil...
Definition: Index.h:125
clang::CodeCompletionString::getTypedText
const char * getTypedText() const
Returns the text in the TypedText chunk.
Definition: CodeCompleteConsumer.cpp:341
clang::frontend::FixIt
@ FixIt
Parse and apply any fixits to the source.
Definition: FrontendOptions.h:82
clang::CodeCompletionContext::CCC_PreprocessorDirective
@ CCC_PreprocessorDirective
Code completion occurred where a preprocessor directive is expected.
Definition: CodeCompleteConsumer.h:296
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:83
clang::PrintingCodeCompleteConsumer::ProcessCodeCompleteResults
void ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context, CodeCompletionResult *Results, unsigned NumResults) override
Prints the finalized code-completion results.
Definition: CodeCompleteConsumer.cpp:618
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:354
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::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::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::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:84
Priority
int Priority
Definition: Format.cpp:2555
clang::CodeCompletionString::CK_LeftBracket
@ CK_LeftBracket
A left bracket ('[').
Definition: CodeCompleteConsumer.h:484
clang::ObjCPropertyAttribute::Kind
Kind
Definition: DeclObjCCommon.h:22
clang::CodeCompletionResult::RK_Pattern
@ RK_Pattern
Refers to a precomputed pattern.
Definition: CodeCompleteConsumer.h:763
clang::Sema::getPreprocessor
Preprocessor & getPreprocessor() const
Definition: Sema.h:1613
DeclarationName.h
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::AR_NotYetIntroduced
@ AR_NotYetIntroduced
Definition: DeclBase.h:71
clang::IdentifierInfo::getName
StringRef getName() const
Return the actual identifier string.
Definition: IdentifierTable.h:195
clang::AR_Unavailable
@ AR_Unavailable
Definition: DeclBase.h:73
clang
Definition: CalledOnceCheck.h:17
Text
StringRef Text
Definition: Format.cpp:2552
distance
float __ovld __cnfn distance(float, float)
Returns the distance between p0 and p1.
clang::CodeCompleteConsumer::OverloadCandidate::getNumParams
unsigned getNumParams() const
Get the number of parameters in this signature.
Definition: CodeCompleteConsumer.cpp:518
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::AvailabilityResult
AvailabilityResult
Captures the result of checking the availability of a declaration.
Definition: DeclBase.h:69
clang::CodeCompletionResult::getOrderedName
StringRef getOrderedName(std::string &Saved) const
Retrieve the name that should be used to order a result.
Definition: CodeCompleteConsumer.cpp:808
clang::operator<
bool operator<(DeclarationName LHS, DeclarationName RHS)
Ordering on two declaration names.
Definition: DeclarationName.h:549
clang::CodeCompletionBuilder::AddPlaceholderChunk
void AddPlaceholderChunk(const char *Placeholder)
Add a new placeholder chunk.
Definition: CodeCompleteConsumer.cpp:445
clang::CodeCompletionBuilder::addBriefComment
void addBriefComment(StringRef Comment)
Definition: CodeCompleteConsumer.cpp:480
CXCursor_UnexposedDecl
@ CXCursor_UnexposedDecl
A declaration whose specific kind is not exposed via this interface.
Definition: Index.h:1717
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:754
CXAvailability_Deprecated
@ CXAvailability_Deprecated
The entity is available, but has been deprecated (and its use is not recommended).
Definition: Index.h:134
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::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::index::SymbolKind::Function
@ Function
clang::CodeCompletionString::CK_Optional
@ CK_Optional
A code completion string that is entirely optional.
Definition: CodeCompleteConsumer.h:459
clang::getCursorKindForDecl
CXCursorKind getCursorKindForDecl(const Decl *D)
Determine the libclang cursor kind associated with the given declaration.
Definition: SemaCodeComplete.cpp:3946
clang::CodeCompletionContext
The context in which code completion occurred, so that the code-completion consumer can process the r...
Definition: CodeCompleteConsumer.h:187
clang::getCompletionKindString
llvm::StringRef getCompletionKindString(CodeCompletionContext::Kind Kind)
Get string representation of Kind, useful for for debugging.
Definition: CodeCompleteConsumer.cpp:92
clang::CodeCompletionBuilder::AddInformativeChunk
void AddInformativeChunk(const char *Text)
Add a new informative chunk.
Definition: CodeCompleteConsumer.cpp:449
clang::CodeCompletionString::CK_LeftBrace
@ CK_LeftBrace
A left brace ('{').
Definition: CodeCompleteConsumer.h:490
clang::CodeCompletionTUInfo::getParentName
StringRef getParentName(const DeclContext *DC)
Definition: CodeCompleteConsumer.cpp:361
SM
#define SM(sm)
Definition: Cuda.cpp:81
CXCursor_ObjCInterfaceDecl
@ CXCursor_ObjCInterfaceDecl
An Objective-C @interface.
Definition: Index.h:1740
clang::DeclContext::isFunctionOrMethod
bool isFunctionOrMethod() const
Definition: DeclBase.h:1928
clang::CodeCompletionString::CK_Colon
@ CK_Colon
A colon (':').
Definition: CodeCompleteConsumer.h:505
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:1872
getDeclAvailability
static AvailabilityResult getDeclAvailability(const Decl *D)
Retrieve the effective availability of the given declaration.
Definition: CodeCompleteConsumer.cpp:743
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:487
clang::CodeCompleteConsumer::OverloadCandidate::getParamType
QualType getParamType(unsigned N) const
Get the type of the Nth parameter.
Definition: CodeCompleteConsumer.cpp:538
clang::CodeCompletionContext::CCC_MacroName
@ CCC_MacroName
Code completion occurred where an macro is being defined.
Definition: CodeCompleteConsumer.h:285
clang::CodeCompletionContext::CCC_ObjCClassMessage
@ CCC_ObjCClassMessage
Code completion where an Objective-C class message is expected.
Definition: CodeCompleteConsumer.h:320
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::Decl::getDeclContext
DeclContext * getDeclContext()
Definition: DeclBase.h:434
clang::NamedDecl::getName
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Definition: Decl.h:274