12 #include "clang/AST/ASTTypeTraits.h" 13 #include "clang/AST/Decl.h" 14 #include "clang/AST/DeclCXX.h" 15 #include "clang/AST/DeclTemplate.h" 16 #include "clang/AST/DeclVisitor.h" 17 #include "clang/AST/DeclarationName.h" 18 #include "clang/AST/Expr.h" 19 #include "clang/AST/ExprCXX.h" 20 #include "clang/AST/ExprObjC.h" 21 #include "clang/AST/NestedNameSpecifier.h" 22 #include "clang/AST/PrettyPrinter.h" 23 #include "clang/AST/RecursiveASTVisitor.h" 24 #include "clang/AST/StmtVisitor.h" 25 #include "clang/AST/TemplateBase.h" 26 #include "clang/AST/Type.h" 27 #include "clang/AST/TypeLoc.h" 28 #include "clang/AST/TypeLocVisitor.h" 29 #include "clang/Basic/LangOptions.h" 30 #include "clang/Basic/OperatorKinds.h" 31 #include "clang/Basic/SourceLocation.h" 32 #include "llvm/ADT/STLExtras.h" 33 #include "llvm/ADT/SmallVector.h" 34 #include "llvm/Support/Casting.h" 35 #include "llvm/Support/Compiler.h" 36 #include "llvm/Support/raw_ostream.h" 43 using ast_type_traits::DynTypedNode;
45 LLVM_ATTRIBUTE_UNUSED std::string
46 nodeToString(
const ast_type_traits::DynTypedNode &N) {
47 std::string S = N.getNodeKind().asStringRef();
49 llvm::raw_string_ostream OS(S);
51 N.print(OS, PrintingPolicy(LangOptions()));
70 std::vector<const NamedDecl *> getMembersReferencedViaDependentName(
72 llvm::function_ref<DeclarationName(ASTContext &)> NameFactory,
73 bool IsNonstaticMember) {
76 if (
auto *ICNT = T->getAs<InjectedClassNameType>()) {
77 T = ICNT->getInjectedSpecializationType().getTypePtrOrNull();
79 auto *TST = T->getAs<TemplateSpecializationType>();
82 const ClassTemplateDecl *TD = dyn_cast_or_null<ClassTemplateDecl>(
83 TST->getTemplateName().getAsTemplateDecl());
86 CXXRecordDecl *RD = TD->getTemplatedDecl();
87 if (!RD->hasDefinition())
89 RD = RD->getDefinition();
90 DeclarationName
Name = NameFactory(RD->getASTContext());
91 return RD->lookupDependentName(Name, [=](
const NamedDecl *D) {
92 return IsNonstaticMember ? D->isCXXInstanceMember()
93 : !D->isCXXInstanceMember();
100 const Type *getPointeeType(
const Type *T) {
104 if (T->isPointerType()) {
105 return T->getAs<PointerType>()->getPointeeType().getTypePtrOrNull();
112 auto ArrowOps = getMembersReferencedViaDependentName(
114 [](ASTContext &
Ctx) {
115 return Ctx.DeclarationNames.getCXXOperatorName(OO_Arrow);
118 if (ArrowOps.empty())
127 auto *TST = T->getAs<TemplateSpecializationType>();
130 if (TST->getNumArgs() == 0)
132 const TemplateArgument &FirstArg = TST->getArg(0);
135 return FirstArg.getAsType().getTypePtrOrNull();
138 const NamedDecl *getTemplatePattern(
const NamedDecl *D) {
139 if (
const CXXRecordDecl *CRD = dyn_cast<CXXRecordDecl>(D)) {
140 return CRD->getTemplateInstantiationPattern();
141 }
else if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
142 return FD->getTemplateInstantiationPattern();
143 }
else if (
auto *VD = dyn_cast<VarDecl>(D)) {
145 VarDecl *T = VD->getTemplateInstantiationPattern();
146 return (T == D) ? nullptr : T;
147 }
else if (
const auto *ED = dyn_cast<EnumDecl>(D)) {
148 return ED->getInstantiatedFromMemberEnum();
149 }
else if (isa<FieldDecl>(D) || isa<TypedefNameDecl>(D)) {
150 if (
const auto *
Parent = llvm::dyn_cast<NamedDecl>(D->getDeclContext()))
151 if (
const DeclContext *ParentPat =
152 dyn_cast_or_null<DeclContext>(getTemplatePattern(
Parent)))
153 for (
const NamedDecl *BaseND : ParentPat->lookup(D->getDeclName()))
154 if (!BaseND->isImplicit() && BaseND->getKind() == D->getKind())
156 }
else if (
const auto *ECD = dyn_cast<EnumConstantDecl>(D)) {
157 if (
const auto *ED = dyn_cast<EnumDecl>(ECD->getDeclContext())) {
158 if (
const EnumDecl *Pattern = ED->getInstantiatedFromMemberEnum()) {
159 for (
const NamedDecl *BaseECD : Pattern->lookup(ECD->getDeclName()))
197 struct TargetFinder {
198 using RelSet = DeclRelationSet;
202 llvm::SmallDenseMap<
const NamedDecl *,
203 std::pair<RelSet,
size_t>>
207 template <
typename T>
void debug(T &Node, RelSet Flags) {
208 dlog(
"visit [{0}] {1}", Flags,
209 nodeToString(ast_type_traits::DynTypedNode::create(Node)));
212 void report(
const NamedDecl *D, RelSet Flags) {
213 dlog(
"--> [{0}] {1}", Flags,
214 nodeToString(ast_type_traits::DynTypedNode::create(*D)));
215 auto It = Decls.try_emplace(D, std::make_pair(Flags, Decls.size()));
218 It.first->second.first |=
Flags;
222 llvm::SmallVector<std::pair<const NamedDecl *, RelSet>, 1> takeDecls()
const {
223 using ValTy = std::pair<const NamedDecl *, RelSet>;
224 llvm::SmallVector<ValTy, 1> Result;
225 Result.resize(Decls.size());
226 for (
const auto &Elem : Decls)
227 Result[Elem.second.second] = {Elem.first, Elem.second.first};
231 void add(
const Decl *Dcl, RelSet Flags) {
232 const NamedDecl *D = llvm::dyn_cast<NamedDecl>(Dcl);
236 if (
const UsingDirectiveDecl *UDD = llvm::dyn_cast<UsingDirectiveDecl>(D))
237 D = UDD->getNominatedNamespaceAsWritten();
239 if (
const TypedefNameDecl *TND = dyn_cast<TypedefNameDecl>(D)) {
242 }
else if (
const UsingDecl *UD = dyn_cast<UsingDecl>(D)) {
243 for (
const UsingShadowDecl *S : UD->shadows())
246 }
else if (
const auto *NAD = dyn_cast<NamespaceAliasDecl>(D)) {
249 }
else if (
const UsingShadowDecl *USD = dyn_cast<UsingShadowDecl>(D)) {
252 report(USD->getUsingDecl(), Flags |
Rel::Alias);
255 D = USD->getTargetDecl();
259 if (
const Decl *Pat = getTemplatePattern(D)) {
269 void add(
const Stmt *S, RelSet Flags) {
273 struct Visitor :
public ConstStmtVisitor<Visitor> {
276 Visitor(TargetFinder &Outer, RelSet Flags) : Outer(Outer), Flags(Flags) {}
278 void VisitCallExpr(
const CallExpr *CE) {
279 Outer.add(CE->getCalleeDecl(),
Flags);
281 void VisitDeclRefExpr(
const DeclRefExpr *DRE) {
282 const Decl *D = DRE->getDecl();
285 if (
auto *USD = llvm::dyn_cast<UsingShadowDecl>(DRE->getFoundDecl()))
289 void VisitMemberExpr(
const MemberExpr *ME) {
290 const Decl *D = ME->getMemberDecl();
292 llvm::dyn_cast<UsingShadowDecl>(ME->getFoundDecl().getDecl()))
296 void VisitOverloadExpr(
const OverloadExpr *OE) {
297 for (
auto *D : OE->decls())
300 void VisitSizeOfPackExpr(
const SizeOfPackExpr *SE) {
301 Outer.add(SE->getPack(),
Flags);
303 void VisitCXXConstructExpr(
const CXXConstructExpr *CCE) {
304 Outer.add(CCE->getConstructor(),
Flags);
306 void VisitDesignatedInitExpr(
const DesignatedInitExpr *DIE) {
307 for (
const DesignatedInitExpr::Designator &D :
308 llvm::reverse(DIE->designators()))
309 if (D.isFieldDesignator()) {
310 Outer.add(D.getField(),
Flags);
316 VisitCXXDependentScopeMemberExpr(
const CXXDependentScopeMemberExpr *
E) {
317 const Type *BaseType = E->getBaseType().getTypePtrOrNull();
319 BaseType = getPointeeType(BaseType);
321 for (
const NamedDecl *D : getMembersReferencedViaDependentName(
322 BaseType, [E](ASTContext &) {
return E->getMember(); },
327 void VisitDependentScopeDeclRefExpr(
const DependentScopeDeclRefExpr *E) {
328 for (
const NamedDecl *D : getMembersReferencedViaDependentName(
329 E->getQualifier()->getAsType(),
330 [
E](ASTContext &) {
return E->getDeclName(); },
335 void VisitObjCIvarRefExpr(
const ObjCIvarRefExpr *OIRE) {
336 Outer.add(OIRE->getDecl(),
Flags);
338 void VisitObjCMessageExpr(
const ObjCMessageExpr *OME) {
339 Outer.add(OME->getMethodDecl(),
Flags);
341 void VisitObjCPropertyRefExpr(
const ObjCPropertyRefExpr *OPRE) {
342 if (OPRE->isExplicitProperty())
343 Outer.add(OPRE->getExplicitProperty(),
Flags);
345 if (OPRE->isMessagingGetter())
346 Outer.add(OPRE->getImplicitPropertyGetter(),
Flags);
347 if (OPRE->isMessagingSetter())
348 Outer.add(OPRE->getImplicitPropertySetter(),
Flags);
351 void VisitObjCProtocolExpr(
const ObjCProtocolExpr *OPE) {
352 Outer.add(OPE->getProtocol(),
Flags);
354 void VisitOpaqueValueExpr(
const OpaqueValueExpr *OVE) {
355 Outer.add(OVE->getSourceExpr(),
Flags);
357 void VisitPseudoObjectExpr(
const PseudoObjectExpr *POE) {
358 Outer.add(POE->getSyntacticForm(),
Flags);
361 Visitor(*
this, Flags).Visit(S);
364 void add(QualType T, RelSet Flags) {
368 struct Visitor :
public TypeVisitor<Visitor> {
371 Visitor(TargetFinder &Outer, RelSet Flags) : Outer(Outer), Flags(Flags) {}
373 void VisitTagType(
const TagType *TT) {
374 Outer.add(TT->getAsTagDecl(),
Flags);
376 void VisitDecltypeType(
const DecltypeType *DTT) {
384 void VisitDeducedTemplateSpecializationType(
385 const DeducedTemplateSpecializationType *DTST) {
392 if (
auto *TD = DTST->getTemplateName().getAsTemplateDecl())
395 void VisitTypedefType(
const TypedefType *TT) {
396 Outer.add(TT->getDecl(),
Flags);
399 VisitTemplateSpecializationType(
const TemplateSpecializationType *TST) {
406 if (TST->isTypeAlias()) {
411 TST->getTemplateName().getAsTemplateDecl()->getTemplatedDecl(),
416 else if (
const auto *Parm =
417 llvm::dyn_cast_or_null<TemplateTemplateParmDecl>(
418 TST->getTemplateName().getAsTemplateDecl()))
419 Outer.add(Parm, Flags);
421 else if (
const CXXRecordDecl *RD = TST->getAsCXXRecordDecl())
422 Outer.add(RD, Flags);
425 if (
auto *TD = TST->getTemplateName().getAsTemplateDecl())
429 void VisitTemplateTypeParmType(
const TemplateTypeParmType *TTPT) {
430 Outer.add(TTPT->getDecl(),
Flags);
432 void VisitObjCInterfaceType(
const ObjCInterfaceType *OIT) {
433 Outer.add(OIT->getDecl(),
Flags);
435 void VisitObjCObjectType(
const ObjCObjectType *OOT) {
438 if (OOT->isObjCQualifiedId() && OOT->getNumProtocols() == 1)
439 Outer.add(OOT->getProtocol(0),
Flags);
442 Visitor(*
this, Flags).Visit(T.getTypePtr());
445 void add(
const NestedNameSpecifier *NNS, RelSet Flags) {
449 switch (NNS->getKind()) {
453 add(NNS->getAsNamespace(),
Flags);
455 case NestedNameSpecifier::NamespaceAlias:
456 add(NNS->getAsNamespaceAlias(),
Flags);
458 case NestedNameSpecifier::TypeSpec:
459 case NestedNameSpecifier::TypeSpecWithTemplate:
460 add(QualType(NNS->getAsType(), 0), Flags);
462 case NestedNameSpecifier::Global:
465 case NestedNameSpecifier::Super:
466 add(NNS->getAsRecordDecl(),
Flags);
469 llvm_unreachable(
"unhandled NestedNameSpecifier::SpecifierKind");
472 void add(
const CXXCtorInitializer *CCI, RelSet Flags) {
477 if (CCI->isAnyMemberInitializer())
478 add(CCI->getAnyMember(),
Flags);
485 llvm::SmallVector<std::pair<const NamedDecl *, DeclRelationSet>, 1>
487 dlog(
"allTargetDecls({0})", nodeToString(N));
491 Finder.add(D, Flags);
492 else if (
const Stmt *S = N.get<Stmt>())
493 Finder.add(S, Flags);
494 else if (
const NestedNameSpecifierLoc *NNSL = N.get<NestedNameSpecifierLoc>())
495 Finder.add(NNSL->getNestedNameSpecifier(),
Flags);
496 else if (
const NestedNameSpecifier *NNS = N.get<NestedNameSpecifier>())
497 Finder.add(NNS, Flags);
498 else if (
const TypeLoc *TL = N.get<TypeLoc>())
499 Finder.add(TL->getType(),
Flags);
500 else if (
const QualType *QT = N.get<QualType>())
501 Finder.add(*QT, Flags);
502 else if (
const CXXCtorInitializer *CCI = N.get<CXXCtorInitializer>())
503 Finder.add(CCI, Flags);
505 return Finder.takeDecls();
508 llvm::SmallVector<const NamedDecl *, 1>
510 llvm::SmallVector<const NamedDecl *, 1> Result;
512 if (!(
Entry.second & ~Mask))
513 Result.push_back(
Entry.first);
518 llvm::SmallVector<const NamedDecl *, 1>
522 "explicitRefenceTargets handles templates on its own");
529 llvm::SmallVector<const NamedDecl *, 1> TemplatePatterns;
530 llvm::SmallVector<const NamedDecl *, 1> Targets;
531 bool SeenTemplateInstantiations =
false;
532 for (
auto &D : Decls) {
533 if (D.second & ~Mask)
536 TemplatePatterns.push_back(D.first);
540 SeenTemplateInstantiations =
true;
541 Targets.push_back(D.first);
543 if (!SeenTemplateInstantiations)
544 Targets.insert(Targets.end(), TemplatePatterns.begin(),
545 TemplatePatterns.end());
550 llvm::SmallVector<ReferenceLoc, 2> refInDecl(
const Decl *D) {
551 struct Visitor : ConstDeclVisitor<Visitor> {
552 llvm::SmallVector<ReferenceLoc, 2>
Refs;
554 void VisitUsingDirectiveDecl(
const UsingDirectiveDecl *D) {
558 D->getIdentLocation(),
560 {D->getNominatedNamespaceAsWritten()}});
563 void VisitUsingDecl(
const UsingDecl *D) {
566 ReferenceLoc{D->getQualifierLoc(), D->getLocation(),
false,
571 void VisitNamespaceAliasDecl(
const NamespaceAliasDecl *D) {
577 D->getTargetNameLoc(),
579 {D->getAliasedNamespace()}});
582 void VisitNamedDecl(
const NamedDecl *ND) {
584 if (llvm::isa<CXXDestructorDecl>(ND))
588 if (ND->getDeclName().isIdentifier() &&
589 !ND->getDeclName().getAsIdentifierInfo())
603 llvm::SmallVector<ReferenceLoc, 2> refInExpr(
const Expr *E) {
604 struct Visitor : ConstStmtVisitor<Visitor> {
606 llvm::SmallVector<ReferenceLoc, 2>
Refs;
608 void VisitDeclRefExpr(
const DeclRefExpr *E) {
610 E->getNameInfo().getLoc(),
612 {E->getFoundDecl()}});
615 void VisitMemberExpr(
const MemberExpr *E) {
617 E->getMemberNameInfo().getLoc(),
619 {E->getFoundDecl()}});
622 void VisitOverloadExpr(
const OverloadExpr *E) {
624 E->getNameInfo().getLoc(),
626 llvm::SmallVector<const NamedDecl *, 1>(
627 E->decls().begin(), E->decls().end())});
630 void VisitSizeOfPackExpr(
const SizeOfPackExpr *E) {
643 llvm::SmallVector<ReferenceLoc, 2> refInTypeLoc(TypeLoc L) {
644 struct Visitor : TypeLocVisitor<Visitor> {
645 llvm::Optional<ReferenceLoc>
Ref;
647 void VisitElaboratedTypeLoc(ElaboratedTypeLoc L) {
649 Visit(L.getNamedTypeLoc().getUnqualifiedLoc());
653 assert(!Ref->Qualifier.hasQualifier() &&
"qualifier already set");
654 Ref->Qualifier = L.getQualifierLoc();
657 void VisitTagTypeLoc(TagTypeLoc L) {
664 void VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc L) {
671 void VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc L) {
681 NestedNameSpecifierLoc(), L.getTemplateNameLoc(),
false,
685 void VisitDeducedTemplateSpecializationTypeLoc(
686 DeducedTemplateSpecializationTypeLoc L) {
688 NestedNameSpecifierLoc(), L.getNameLoc(),
false,
693 void VisitDependentTemplateSpecializationTypeLoc(
694 DependentTemplateSpecializationTypeLoc L) {
696 L.getQualifierLoc(), L.getTemplateNameLoc(),
false,
700 void VisitDependentNameTypeLoc(DependentNameTypeLoc L) {
702 L.getQualifierLoc(), L.getNameLoc(),
false,
706 void VisitTypedefTypeLoc(TypedefTypeLoc L) {
710 {L.getTypedefNameDecl()}};
715 V.Visit(L.getUnqualifiedLoc());
721 class ExplicitReferenceCollector
722 :
public RecursiveASTVisitor<ExplicitReferenceCollector> {
724 ExplicitReferenceCollector(llvm::function_ref<
void(
ReferenceLoc)> Out)
729 bool VisitTypeLoc(TypeLoc TTL) {
730 if (TypeLocsToSkip.count(TTL.getBeginLoc().getRawEncoding()))
732 visitNode(DynTypedNode::create(TTL));
736 bool TraverseElaboratedTypeLoc(ElaboratedTypeLoc L) {
739 TypeLoc Inner = L.getNamedTypeLoc().getUnqualifiedLoc();
740 TypeLocsToSkip.insert(Inner.getBeginLoc().getRawEncoding());
741 return RecursiveASTVisitor::TraverseElaboratedTypeLoc(L);
744 bool VisitExpr(Expr *E) {
745 visitNode(DynTypedNode::create(*E));
752 bool TraverseTemplateArgumentLoc(TemplateArgumentLoc A) {
753 switch (A.getArgument().getKind()) {
754 case TemplateArgument::Template:
755 case TemplateArgument::TemplateExpansion:
756 reportReference(
ReferenceLoc{A.getTemplateQualifierLoc(),
757 A.getTemplateNameLoc(),
760 .getAsTemplateOrTemplatePattern()
761 .getAsTemplateDecl()}},
762 DynTypedNode::create(A.getArgument()));
766 case TemplateArgument::Integral:
768 case TemplateArgument::NullPtr:
770 case TemplateArgument::Pack:
772 case TemplateArgument::Expression:
775 return RecursiveASTVisitor::TraverseTemplateArgumentLoc(A);
778 bool VisitDecl(
Decl *D) {
779 visitNode(DynTypedNode::create(*D));
784 bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc L) {
785 if (!L.getNestedNameSpecifier())
787 visitNode(DynTypedNode::create(L));
789 if (
auto TL = L.getTypeLoc())
790 TypeLocsToSkip.insert(TL.getBeginLoc().getRawEncoding());
791 return RecursiveASTVisitor::TraverseNestedNameSpecifierLoc(L);
794 bool TraverseConstructorInitializer(CXXCtorInitializer *Init) {
795 visitNode(DynTypedNode::create(*Init));
796 return RecursiveASTVisitor::TraverseConstructorInitializer(Init);
814 llvm::SmallVector<ReferenceLoc, 2> explicitReference(DynTypedNode N) {
815 if (
auto *D = N.get<
Decl>())
817 if (
auto *E = N.get<Expr>())
819 if (
auto *NNSL = N.get<NestedNameSpecifierLoc>()) {
822 NNSL->getPrefix(), NNSL->getLocalBeginLoc(),
false,
824 DynTypedNode::create(*NNSL->getNestedNameSpecifier()),
827 if (
const TypeLoc *TL = N.get<TypeLoc>())
828 return refInTypeLoc(*TL);
829 if (
const CXXCtorInitializer *CCI = N.get<CXXCtorInitializer>()) {
832 if (CCI->isAnyMemberInitializer()) {
834 CCI->getMemberLocation(),
836 {CCI->getAnyMember()}}};
843 void visitNode(DynTypedNode N) {
844 for (
const auto &R : explicitReference(N))
845 reportReference(R, N);
854 dlog(
"invalid location at node {0}", nodeToString(N));
860 llvm::function_ref<void(ReferenceLoc)> Out;
863 llvm::DenseSet<
unsigned> TypeLocsToSkip;
870 ExplicitReferenceCollector(Out).TraverseStmt(const_cast<Stmt *>(S));
875 ExplicitReferenceCollector(Out).TraverseDecl(const_cast<Decl *>(D));
879 ExplicitReferenceCollector(Out).TraverseAST(const_cast<ASTContext &>(AST));
884 #define REL_CASE(X) \ 885 case DeclRelation::X: \ 893 llvm_unreachable(
"Unhandled DeclRelation enum");
896 const char *Sep =
"";
897 for (
unsigned I = 0; I < RS.S.size(); ++I) {
899 OS << Sep << static_cast<DeclRelation>(I);
910 for (
const NamedDecl *T : R.
Targets) {
919 OS <<
", qualifier = '";
920 R.
Qualifier.getNestedNameSpecifier()->print(OS,
921 PrintingPolicy(LangOptions()));
const FunctionDecl * Decl
std::string printQualifiedName(const NamedDecl &ND)
Returns the qualified name of ND.
Information about a reference written in the source code, independent of the actual AST node that thi...
llvm::SmallVector< std::pair< const NamedDecl *, DeclRelationSet >, 1 > allTargetDecls(const ast_type_traits::DynTypedNode &N)
Similar to targetDecl(), however instead of applying a filter, all possible decls are returned along ...
This is the pattern the template specialization was instantiated from.
Represents a symbol occurrence in the source file.
std::vector< const char * > Flags
NestedNameSpecifierLoc getQualifierLoc(const NamedDecl &ND)
Returns a nested name specifier loc of ND if it was present in the source, e.g.
std::string printTemplateSpecializationArgs(const NamedDecl &ND)
Prints template arguments of a decl as written in the source code, including enclosing '<' and '>'...
static std::string replace(llvm::StringRef Haystack, llvm::StringRef Needle, llvm::StringRef Repl)
This declaration is an alias that was referred to.
bool IsDecl
True if the reference is a declaration or definition;.
SourceLocation NameLoc
Start location of the last name part, i.e. 'foo' in 'ns::foo<int>'.
llvm::SmallVector< const NamedDecl *, 1 > explicitReferenceTargets(DynTypedNode N, DeclRelationSet Mask)
This is the template instantiation that was referred to.
static constexpr llvm::StringLiteral Name
llvm::SmallVector< const NamedDecl *, 1 > Targets
A list of targets referenced by this name.
llvm::SmallVector< const NamedDecl *, 1 > targetDecl(const ast_type_traits::DynTypedNode &N, DeclRelationSet Mask)
targetDecl() finds the declaration referred to by an AST node.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
void findExplicitReferences(const Stmt *S, llvm::function_ref< void(ReferenceLoc)> Out)
Recursively traverse S and report all references explicitly written in the code.
This is the underlying declaration for an alias, decltype etc.
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const CodeCompletion &C)
NestedNameSpecifierLoc Qualifier
Contains qualifier written in the code, if any, e.g. 'ns::' for 'ns::foo'.