[clang] 8d8c898 - [clang][ExtractAPI] Add support for C++ variable templates
Erick Velez via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 18 13:57:57 PDT 2023
Author: Erick Velez
Date: 2023-08-18T13:57:02-07:00
New Revision: 8d8c8981cac0e548f0fca1268d6e501431564f66
URL: https://github.com/llvm/llvm-project/commit/8d8c8981cac0e548f0fca1268d6e501431564f66
DIFF: https://github.com/llvm/llvm-project/commit/8d8c8981cac0e548f0fca1268d6e501431564f66.diff
LOG: [clang][ExtractAPI] Add support for C++ variable templates
Serialize global C++ variable templates and specializations.
Depends on D157076
Reviewed By: dang
Differential Revision: https://reviews.llvm.org/D157350
Added:
clang/test/ExtractAPI/global_var_template.cpp
clang/test/ExtractAPI/global_var_template_partial_spec.cpp
clang/test/ExtractAPI/global_var_template_spec.cpp
Modified:
clang/include/clang/ExtractAPI/API.h
clang/include/clang/ExtractAPI/DeclarationFragments.h
clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
clang/include/clang/ExtractAPI/Serialization/SerializerBase.h
clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
clang/lib/ExtractAPI/API.cpp
clang/lib/ExtractAPI/DeclarationFragments.cpp
clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/ExtractAPI/API.h b/clang/include/clang/ExtractAPI/API.h
index 83ff982be559b9..7846ad14127fe4 100644
--- a/clang/include/clang/ExtractAPI/API.h
+++ b/clang/include/clang/ExtractAPI/API.h
@@ -99,6 +99,24 @@ class Template {
}
}
+ Template(const VarTemplatePartialSpecializationDecl *Decl) {
+ for (auto *const Parameter : *Decl->getTemplateParameters()) {
+ const auto *Param = dyn_cast<TemplateTypeParmDecl>(Parameter);
+ if (!Param) // some params are null
+ continue;
+ std::string Type;
+ if (Param->hasTypeConstraint())
+ Type = Param->getTypeConstraint()->getNamedConcept()->getName().str();
+ else if (Param->wasDeclaredWithTypename())
+ Type = "typename";
+ else
+ Type = "class";
+
+ addTemplateParameter(Type, Param->getName().str(), Param->getIndex(),
+ Param->getDepth(), Param->isParameterPack());
+ }
+ }
+
const llvm::SmallVector<TemplateParameter> &getParameters() const {
return Parameters;
}
@@ -141,6 +159,9 @@ struct APIRecord {
RK_Unknown,
RK_GlobalFunction,
RK_GlobalVariable,
+ RK_GlobalVariableTemplate,
+ RK_GlobalVariableTemplateSpecialization,
+ RK_GlobalVariableTemplatePartialSpecialization,
RK_EnumConstant,
RK_Enum,
RK_StructField,
@@ -279,6 +300,14 @@ struct GlobalVariableRecord : APIRecord {
Linkage, Comment, Declaration, SubHeading,
IsFromSystemHeader) {}
+ GlobalVariableRecord(RecordKind Kind, StringRef USR, StringRef Name,
+ PresumedLoc Loc, AvailabilitySet Availabilities,
+ LinkageInfo Linkage, const DocComment &Comment,
+ DeclarationFragments Declaration,
+ DeclarationFragments SubHeading, bool IsFromSystemHeader)
+ : APIRecord(Kind, USR, Name, Loc, std::move(Availabilities), Linkage,
+ Comment, Declaration, SubHeading, IsFromSystemHeader) {}
+
static bool classof(const APIRecord *Record) {
return Record->getKind() == RK_GlobalVariable;
}
@@ -287,6 +316,61 @@ struct GlobalVariableRecord : APIRecord {
virtual void anchor();
};
+struct GlobalVariableTemplateRecord : GlobalVariableRecord {
+ Template Templ;
+
+ GlobalVariableTemplateRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
+ AvailabilitySet Availabilities,
+ LinkageInfo Linkage, const DocComment &Comment,
+ DeclarationFragments Declaration,
+ DeclarationFragments SubHeading,
+ class Template Template, bool IsFromSystemHeader)
+ : GlobalVariableRecord(RK_GlobalVariableTemplate, USR, Name, Loc,
+ std::move(Availabilities), Linkage, Comment,
+ Declaration, SubHeading, IsFromSystemHeader),
+ Templ(Template) {}
+
+ static bool classof(const APIRecord *Record) {
+ return Record->getKind() == RK_GlobalVariableTemplate;
+ }
+};
+
+struct GlobalVariableTemplateSpecializationRecord : GlobalVariableRecord {
+ GlobalVariableTemplateSpecializationRecord(
+ StringRef USR, StringRef Name, PresumedLoc Loc,
+ AvailabilitySet Availabilities, LinkageInfo Linkage,
+ const DocComment &Comment, DeclarationFragments Declaration,
+ DeclarationFragments SubHeading, bool IsFromSystemHeader)
+ : GlobalVariableRecord(RK_GlobalVariableTemplateSpecialization, USR, Name,
+ Loc, std::move(Availabilities), Linkage, Comment,
+ Declaration, SubHeading, IsFromSystemHeader) {}
+
+ static bool classof(const APIRecord *Record) {
+ return Record->getKind() == RK_GlobalVariableTemplateSpecialization;
+ }
+};
+
+struct GlobalVariableTemplatePartialSpecializationRecord
+ : GlobalVariableRecord {
+ Template Templ;
+
+ GlobalVariableTemplatePartialSpecializationRecord(
+ StringRef USR, StringRef Name, PresumedLoc Loc,
+ AvailabilitySet Availabilities, LinkageInfo Linkage,
+ const DocComment &Comment, DeclarationFragments Declaration,
+ DeclarationFragments SubHeading, class Template Template,
+ bool IsFromSystemHeader)
+ : GlobalVariableRecord(RK_GlobalVariableTemplatePartialSpecialization,
+ USR, Name, Loc, std::move(Availabilities), Linkage,
+ Comment, Declaration, SubHeading,
+ IsFromSystemHeader),
+ Templ(Template) {}
+
+ static bool classof(const APIRecord *Record) {
+ return Record->getKind() == RK_GlobalVariableTemplatePartialSpecialization;
+ }
+};
+
/// This holds information associated with enum constants.
struct EnumConstantRecord : APIRecord {
EnumConstantRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
@@ -782,6 +866,7 @@ struct ClassTemplatePartialSpecializationRecord : CXXClassRecord {
struct ConceptRecord : APIRecord {
Template Templ;
+
ConceptRecord(StringRef USR, StringRef Name, PresumedLoc Loc,
AvailabilitySet Availabilities, const DocComment &Comment,
DeclarationFragments Declaration,
@@ -791,10 +876,6 @@ struct ConceptRecord : APIRecord {
LinkageInfo::none(), Comment, Declaration, SubHeading,
IsFromSystemHeader),
Templ(Template) {}
-
- static bool classof(const APIRecord *Record) {
- return Record->getKind() == RK_Concept;
- }
};
/// This holds information associated with Objective-C categories.
@@ -938,6 +1019,11 @@ template <>
struct has_template<ClassTemplatePartialSpecializationRecord>
: public std::true_type {};
template <> struct has_template<ConceptRecord> : public std::true_type {};
+template <>
+struct has_template<GlobalVariableTemplateRecord> : public std::true_type {};
+template <>
+struct has_template<GlobalVariableTemplatePartialSpecializationRecord>
+ : public std::true_type {};
/// APISet holds the set of API records collected from given inputs.
class APISet {
@@ -954,6 +1040,14 @@ class APISet {
const DocComment &Comment, DeclarationFragments Declaration,
DeclarationFragments SubHeadin, bool IsFromSystemHeaderg);
+ GlobalVariableTemplateRecord *
+ addGlobalVariableTemplate(StringRef Name, StringRef USR, PresumedLoc Loc,
+ AvailabilitySet Availability, LinkageInfo Linkage,
+ const DocComment &Comment,
+ DeclarationFragments Declaration,
+ DeclarationFragments SubHeading, Template Template,
+ bool IsFromSystemHeader);
+
/// Create and add a function record into the API set.
///
/// Note: the caller is responsible for keeping the StringRef \p Name and
@@ -1056,6 +1150,21 @@ class APISet {
DeclarationFragments Declaration, DeclarationFragments SubHeading,
Template Template, bool IsFromSystemHeader);
+ GlobalVariableTemplateSpecializationRecord *
+ addGlobalVariableTemplateSpecialization(
+ StringRef Name, StringRef USR, PresumedLoc Loc,
+ AvailabilitySet Availability, LinkageInfo Linkage,
+ const DocComment &Comment, DeclarationFragments Declaration,
+ DeclarationFragments SubHeading, bool IsFromSystemHeader);
+
+ GlobalVariableTemplatePartialSpecializationRecord *
+ addGlobalVariableTemplatePartialSpecialization(
+ StringRef Name, StringRef USR, PresumedLoc Loc,
+ AvailabilitySet Availability, LinkageInfo Linkage,
+ const DocComment &Comment, DeclarationFragments Declaration,
+ DeclarationFragments SubHeading, Template Template,
+ bool IsFromSystemHeader);
+
CXXMethodRecord *
addCXXMethod(CXXClassRecord *CXXClassRecord, StringRef Name, StringRef USR,
PresumedLoc Loc, AvailabilitySet Availability,
@@ -1199,9 +1308,21 @@ class APISet {
const RecordMap<GlobalVariableRecord> &getGlobalVariables() const {
return GlobalVariables;
}
+ const RecordMap<GlobalVariableTemplateRecord> &
+ getGlobalVariableTemplates() const {
+ return GlobalVariableTemplates;
+ }
const RecordMap<StaticFieldRecord> &getStaticFields() const {
return StaticFields;
}
+ const RecordMap<GlobalVariableTemplateSpecializationRecord> &
+ getGlobalVariableTemplateSpecializations() const {
+ return GlobalVariableTemplateSpecializations;
+ }
+ const RecordMap<GlobalVariableTemplatePartialSpecializationRecord> &
+ getGlobalVariableTemplatePartialSpecializations() const {
+ return GlobalVariableTemplatePartialSpecializations;
+ }
const RecordMap<EnumRecord> &getEnums() const { return Enums; }
const RecordMap<StructRecord> &getStructs() const { return Structs; }
const RecordMap<CXXClassRecord> &getCXXClasses() const { return CXXClasses; }
@@ -1271,6 +1392,11 @@ class APISet {
llvm::DenseMap<StringRef, APIRecord *> USRBasedLookupTable;
RecordMap<GlobalFunctionRecord> GlobalFunctions;
RecordMap<GlobalVariableRecord> GlobalVariables;
+ RecordMap<GlobalVariableTemplateRecord> GlobalVariableTemplates;
+ RecordMap<GlobalVariableTemplateSpecializationRecord>
+ GlobalVariableTemplateSpecializations;
+ RecordMap<GlobalVariableTemplatePartialSpecializationRecord>
+ GlobalVariableTemplatePartialSpecializations;
RecordMap<ConceptRecord> Concepts;
RecordMap<StaticFieldRecord> StaticFields;
RecordMap<EnumRecord> Enums;
diff --git a/clang/include/clang/ExtractAPI/DeclarationFragments.h b/clang/include/clang/ExtractAPI/DeclarationFragments.h
index c0271de91acfb2..c2260a209ee5e1 100644
--- a/clang/include/clang/ExtractAPI/DeclarationFragments.h
+++ b/clang/include/clang/ExtractAPI/DeclarationFragments.h
@@ -23,7 +23,10 @@
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/DeclTemplate.h"
+#include "clang/AST/ExprCXX.h"
+#include "clang/Basic/Specifiers.h"
#include "clang/Lex/MacroInfo.h"
+#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include <vector>
@@ -268,6 +271,8 @@ class DeclarationFragmentsBuilder {
/// Build DeclarationFragments for a variable declaration VarDecl.
static DeclarationFragments getFragmentsForVar(const VarDecl *);
+ static DeclarationFragments getFragmentsForVarTemplate(const VarDecl *);
+
/// Build DeclarationFragments for a function declaration FunctionDecl.
static DeclarationFragments getFragmentsForFunction(const FunctionDecl *);
@@ -320,6 +325,12 @@ class DeclarationFragmentsBuilder {
static DeclarationFragments getFragmentsForClassTemplatePartialSpecialization(
const ClassTemplatePartialSpecializationDecl *);
+ static DeclarationFragments getFragmentsForVarTemplateSpecialization(
+ const VarTemplateSpecializationDecl *);
+
+ static DeclarationFragments getFragmentsForVarTemplatePartialSpecialization(
+ const VarTemplatePartialSpecializationDecl *);
+
/// Build DeclarationFragments for an Objective-C category declaration
/// ObjCCategoryDecl.
static DeclarationFragments
diff --git a/clang/include/clang/ExtractAPI/ExtractAPIVisitor.h b/clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
index 0392b6db2da0ad..e7746f4abc8d57 100644
--- a/clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
+++ b/clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
@@ -59,6 +59,14 @@ class ExtractAPIVisitorBase : public RecursiveASTVisitor<Derived> {
bool WalkUpFromClassTemplatePartialSpecializationDecl(
const ClassTemplatePartialSpecializationDecl *Decl);
+ bool WalkUpFromVarTemplateDecl(const VarTemplateDecl *Decl);
+
+ bool WalkUpFromVarTemplateSpecializationDecl(
+ const VarTemplateSpecializationDecl *Decl);
+
+ bool WalkUpFromVarTemplatePartialSpecializationDecl(
+ const VarTemplatePartialSpecializationDecl *Decl);
+
bool VisitRecordDecl(const RecordDecl *Decl);
bool VisitCXXRecordDecl(const CXXRecordDecl *Decl);
@@ -71,6 +79,14 @@ class ExtractAPIVisitorBase : public RecursiveASTVisitor<Derived> {
bool VisitClassTemplatePartialSpecializationDecl(
const ClassTemplatePartialSpecializationDecl *Decl);
+ bool VisitVarTemplateDecl(const VarTemplateDecl *Decl);
+
+ bool
+ VisitVarTemplateSpecializationDecl(const VarTemplateSpecializationDecl *Decl);
+
+ bool VisitVarTemplatePartialSpecializationDecl(
+ const VarTemplatePartialSpecializationDecl *Decl);
+
bool VisitObjCInterfaceDecl(const ObjCInterfaceDecl *Decl);
bool VisitObjCProtocolDecl(const ObjCProtocolDecl *Decl);
@@ -382,6 +398,28 @@ bool ExtractAPIVisitorBase<Derived>::
return true;
}
+template <typename Derived>
+bool ExtractAPIVisitorBase<Derived>::WalkUpFromVarTemplateDecl(
+ const VarTemplateDecl *Decl) {
+ getDerivedExtractAPIVisitor().VisitVarTemplateDecl(Decl);
+ return true;
+}
+
+template <typename Derived>
+bool ExtractAPIVisitorBase<Derived>::WalkUpFromVarTemplateSpecializationDecl(
+ const VarTemplateSpecializationDecl *Decl) {
+ getDerivedExtractAPIVisitor().VisitVarTemplateSpecializationDecl(Decl);
+ return true;
+}
+
+template <typename Derived>
+bool ExtractAPIVisitorBase<Derived>::
+ WalkUpFromVarTemplatePartialSpecializationDecl(
+ const VarTemplatePartialSpecializationDecl *Decl) {
+ getDerivedExtractAPIVisitor().VisitVarTemplatePartialSpecializationDecl(Decl);
+ return true;
+}
+
template <typename Derived>
bool ExtractAPIVisitorBase<Derived>::VisitRecordDecl(const RecordDecl *Decl) {
if (!getDerivedExtractAPIVisitor().shouldDeclBeIncluded(Decl))
@@ -562,6 +600,103 @@ bool ExtractAPIVisitorBase<Derived>::
return true;
}
+template <typename Derived>
+bool ExtractAPIVisitorBase<Derived>::VisitVarTemplateDecl(
+ const VarTemplateDecl *Decl) {
+ if (!getDerivedExtractAPIVisitor().shouldDeclBeIncluded(Decl))
+ return true;
+
+ // Collect symbol information.
+ StringRef Name = Decl->getName();
+ StringRef USR = API.recordUSR(Decl);
+ PresumedLoc Loc =
+ Context.getSourceManager().getPresumedLoc(Decl->getLocation());
+ LinkageInfo Linkage = Decl->getLinkageAndVisibility();
+ DocComment Comment;
+ if (auto *RawComment =
+ getDerivedExtractAPIVisitor().fetchRawCommentForDecl(Decl))
+ Comment = RawComment->getFormattedLines(Context.getSourceManager(),
+ Context.getDiagnostics());
+
+ // Build declaration fragments and sub-heading for the variable.
+ DeclarationFragments Declaration =
+ DeclarationFragmentsBuilder::getFragmentsForVarTemplate(
+ Decl->getTemplatedDecl());
+ DeclarationFragments SubHeading =
+ DeclarationFragmentsBuilder::getSubHeading(Decl);
+
+ // Inject template fragments before var fragments.
+ Declaration.insert(
+ Declaration.begin(),
+ DeclarationFragmentsBuilder::getFragmentsForRedeclarableTemplate(Decl));
+
+ API.addGlobalVariableTemplate(Name, USR, Loc, AvailabilitySet(Decl), Linkage,
+ Comment, Declaration, SubHeading,
+ Template(Decl), isInSystemHeader(Decl));
+ return true;
+}
+
+template <typename Derived>
+bool ExtractAPIVisitorBase<Derived>::VisitVarTemplateSpecializationDecl(
+ const VarTemplateSpecializationDecl *Decl) {
+ if (!getDerivedExtractAPIVisitor().shouldDeclBeIncluded(Decl))
+ return true;
+
+ // Collect symbol information.
+ StringRef Name = Decl->getName();
+ StringRef USR = API.recordUSR(Decl);
+ PresumedLoc Loc =
+ Context.getSourceManager().getPresumedLoc(Decl->getLocation());
+ LinkageInfo Linkage = Decl->getLinkageAndVisibility();
+ DocComment Comment;
+ if (auto *RawComment =
+ getDerivedExtractAPIVisitor().fetchRawCommentForDecl(Decl))
+ Comment = RawComment->getFormattedLines(Context.getSourceManager(),
+ Context.getDiagnostics());
+
+ // Build declaration fragments and sub-heading for the variable.
+ DeclarationFragments Declaration =
+ DeclarationFragmentsBuilder::getFragmentsForVarTemplateSpecialization(
+ Decl);
+ DeclarationFragments SubHeading =
+ DeclarationFragmentsBuilder::getSubHeading(Decl);
+
+ API.addGlobalVariableTemplateSpecialization(
+ Name, USR, Loc, AvailabilitySet(Decl), Linkage, Comment, Declaration,
+ SubHeading, isInSystemHeader(Decl));
+ return true;
+}
+
+template <typename Derived>
+bool ExtractAPIVisitorBase<Derived>::VisitVarTemplatePartialSpecializationDecl(
+ const VarTemplatePartialSpecializationDecl *Decl) {
+ if (!getDerivedExtractAPIVisitor().shouldDeclBeIncluded(Decl))
+ return true;
+
+ // Collect symbol information.
+ StringRef Name = Decl->getName();
+ StringRef USR = API.recordUSR(Decl);
+ PresumedLoc Loc =
+ Context.getSourceManager().getPresumedLoc(Decl->getLocation());
+ LinkageInfo Linkage = Decl->getLinkageAndVisibility();
+ DocComment Comment;
+ if (auto *RawComment =
+ getDerivedExtractAPIVisitor().fetchRawCommentForDecl(Decl))
+ Comment = RawComment->getFormattedLines(Context.getSourceManager(),
+ Context.getDiagnostics());
+
+ // Build declaration fragments and sub-heading for the variable.
+ DeclarationFragments Declaration = DeclarationFragmentsBuilder::
+ getFragmentsForVarTemplatePartialSpecialization(Decl);
+ DeclarationFragments SubHeading =
+ DeclarationFragmentsBuilder::getSubHeading(Decl);
+
+ API.addGlobalVariableTemplatePartialSpecialization(
+ Name, USR, Loc, AvailabilitySet(Decl), Linkage, Comment, Declaration,
+ SubHeading, Template(Decl), isInSystemHeader(Decl));
+ return true;
+}
+
template <typename Derived>
bool ExtractAPIVisitorBase<Derived>::VisitObjCInterfaceDecl(
const ObjCInterfaceDecl *Decl) {
diff --git a/clang/include/clang/ExtractAPI/Serialization/SerializerBase.h b/clang/include/clang/ExtractAPI/Serialization/SerializerBase.h
index 2bcd480b60e1c9..d5d23edc449788 100644
--- a/clang/include/clang/ExtractAPI/Serialization/SerializerBase.h
+++ b/clang/include/clang/ExtractAPI/Serialization/SerializerBase.h
@@ -41,6 +41,12 @@ template <typename Derived> class APISetVisitor {
getDerived()->traverseConcepts();
+ getDerived()->traverseGlobalVariableTemplateRecords();
+
+ getDerived()->traverseGlobalVariableTemplateSpecializationRecords();
+
+ getDerived()->traverseGlobalVariableTemplatePartialSpecializationRecords();
+
getDerived()->traverseStructRecords();
getDerived()->traverseObjCInterfaces();
@@ -103,6 +109,26 @@ template <typename Derived> class APISetVisitor {
*ClassTemplatePartialSpecialization.second);
}
+ void traverseGlobalVariableTemplateRecords() {
+ for (const auto &GlobalVariableTemplate : API.getGlobalVariableTemplates())
+ getDerived()->visitGlobalVariableTemplateRecord(
+ *GlobalVariableTemplate.second);
+ }
+
+ void traverseGlobalVariableTemplateSpecializationRecords() {
+ for (const auto &GlobalVariableTemplateSpecialization :
+ API.getGlobalVariableTemplateSpecializations())
+ getDerived()->visitGlobalVariableTemplateSpecializationRecord(
+ *GlobalVariableTemplateSpecialization.second);
+ }
+
+ void traverseGlobalVariableTemplatePartialSpecializationRecords() {
+ for (const auto &GlobalVariableTemplatePartialSpecialization :
+ API.getGlobalVariableTemplatePartialSpecializations())
+ getDerived()->visitGlobalVariableTemplatePartialSpecializationRecord(
+ *GlobalVariableTemplatePartialSpecialization.second);
+ }
+
void traverseConcepts() {
for (const auto &Concept : API.getConcepts())
getDerived()->visitConceptRecord(*Concept.second);
@@ -157,6 +183,15 @@ template <typename Derived> class APISetVisitor {
void visitClassTemplatePartialSpecializationRecord(
const ClassTemplatePartialSpecializationRecord &Record){};
+ void visitGlobalVariableTemplateRecord(
+ const GlobalVariableTemplateRecord &Record) {}
+
+ void visitGlobalVariableTemplateSpecializationRecord(
+ const GlobalVariableTemplateSpecializationRecord &Record){};
+
+ void visitGlobalVariableTemplatePartialSpecializationRecord(
+ const GlobalVariableTemplatePartialSpecializationRecord &Record){};
+
/// Visit an Objective-C container record.
void visitObjCContainerRecord(const ObjCContainerRecord &Record){};
diff --git a/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h b/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
index 7b315c9f6d410e..102436af9bc1a3 100644
--- a/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
+++ b/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
@@ -185,6 +185,15 @@ class SymbolGraphSerializer : public APISetVisitor<SymbolGraphSerializer> {
void visitConceptRecord(const ConceptRecord &Record);
+ void
+ visitGlobalVariableTemplateRecord(const GlobalVariableTemplateRecord &Record);
+
+ void visitGlobalVariableTemplateSpecializationRecord(
+ const GlobalVariableTemplateSpecializationRecord &Record);
+
+ void visitGlobalVariableTemplatePartialSpecializationRecord(
+ const GlobalVariableTemplatePartialSpecializationRecord &Record);
+
/// Visit an Objective-C container record.
void visitObjCContainerRecord(const ObjCContainerRecord &Record);
diff --git a/clang/lib/ExtractAPI/API.cpp b/clang/lib/ExtractAPI/API.cpp
index c1c4bc7a0b4cf7..4d2ab172656533 100644
--- a/clang/lib/ExtractAPI/API.cpp
+++ b/clang/lib/ExtractAPI/API.cpp
@@ -54,6 +54,18 @@ APISet::addGlobalVar(StringRef Name, StringRef USR, PresumedLoc Loc,
Fragments, SubHeading, IsFromSystemHeader);
}
+GlobalVariableTemplateRecord *APISet::addGlobalVariableTemplate(
+ StringRef Name, StringRef USR, PresumedLoc Loc,
+ AvailabilitySet Availability, LinkageInfo Linkage,
+ const DocComment &Comment, DeclarationFragments Declaration,
+ DeclarationFragments SubHeading, Template Template,
+ bool IsFromSystemHeader) {
+ return addTopLevelRecord(USRBasedLookupTable, GlobalVariableTemplates, USR,
+ Name, Loc, std::move(Availability), Linkage, Comment,
+ Declaration, SubHeading, Template,
+ IsFromSystemHeader);
+}
+
GlobalFunctionRecord *APISet::addGlobalFunction(
StringRef Name, StringRef USR, PresumedLoc Loc,
AvailabilitySet Availabilities, LinkageInfo Linkage,
@@ -192,6 +204,31 @@ APISet::addClassTemplatePartialSpecialization(
SubHeading, Template, IsFromSystemHeader);
}
+GlobalVariableTemplateSpecializationRecord *
+APISet::addGlobalVariableTemplateSpecialization(
+ StringRef Name, StringRef USR, PresumedLoc Loc,
+ AvailabilitySet Availability, LinkageInfo Linkage,
+ const DocComment &Comment, DeclarationFragments Declaration,
+ DeclarationFragments SubHeading, bool IsFromSystemHeader) {
+ return addTopLevelRecord(USRBasedLookupTable,
+ GlobalVariableTemplateSpecializations, USR, Name,
+ Loc, std::move(Availability), Linkage, Comment,
+ Declaration, SubHeading, IsFromSystemHeader);
+}
+
+GlobalVariableTemplatePartialSpecializationRecord *
+APISet::addGlobalVariableTemplatePartialSpecialization(
+ StringRef Name, StringRef USR, PresumedLoc Loc,
+ AvailabilitySet Availability, LinkageInfo Linkage,
+ const DocComment &Comment, DeclarationFragments Declaration,
+ DeclarationFragments SubHeading, Template Template,
+ bool IsFromSystemHeader) {
+ return addTopLevelRecord(
+ USRBasedLookupTable, GlobalVariableTemplatePartialSpecializations, USR,
+ Name, Loc, std::move(Availability), Linkage, Comment, Declaration,
+ SubHeading, Template, IsFromSystemHeader);
+}
+
ConceptRecord *APISet::addConcept(StringRef Name, StringRef USR,
PresumedLoc Loc, AvailabilitySet Availability,
const DocComment &Comment,
diff --git a/clang/lib/ExtractAPI/DeclarationFragments.cpp b/clang/lib/ExtractAPI/DeclarationFragments.cpp
index ec8ae56f71e161..271355d4de169b 100644
--- a/clang/lib/ExtractAPI/DeclarationFragments.cpp
+++ b/clang/lib/ExtractAPI/DeclarationFragments.cpp
@@ -14,10 +14,12 @@
#include "clang/ExtractAPI/DeclarationFragments.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
+#include "clang/AST/QualTypeNames.h"
#include "clang/Basic/OperatorKinds.h"
#include "clang/ExtractAPI/TypedefUnderlyingTypeResolver.h"
#include "clang/Index/USRGeneration.h"
#include "llvm/ADT/StringSwitch.h"
+#include <typeinfo>
using namespace clang::extractapi;
using namespace llvm;
@@ -452,6 +454,34 @@ DeclarationFragmentsBuilder::getFragmentsForVar(const VarDecl *Var) {
.append(";", DeclarationFragments::FragmentKind::Text);
}
+DeclarationFragments
+DeclarationFragmentsBuilder::getFragmentsForVarTemplate(const VarDecl *Var) {
+ DeclarationFragments Fragments;
+ if (Var->isConstexpr())
+ Fragments.append("constexpr", DeclarationFragments::FragmentKind::Keyword)
+ .appendSpace();
+ QualType T =
+ Var->getTypeSourceInfo()
+ ? Var->getTypeSourceInfo()->getType()
+ : Var->getASTContext().getUnqualifiedObjCPointerType(Var->getType());
+
+ DeclarationFragments After;
+ DeclarationFragments ArgumentFragment =
+ getFragmentsForType(T, Var->getASTContext(), After);
+ if (ArgumentFragment.begin()->Spelling.substr(0, 14).compare(
+ "type-parameter") == 0) {
+ std::string ProperArgName = getNameForTemplateArgument(
+ Var->getDescribedVarTemplate()->getTemplateParameters()->asArray(),
+ ArgumentFragment.begin()->Spelling);
+ ArgumentFragment.begin()->Spelling.swap(ProperArgName);
+ }
+ Fragments.append(std::move(ArgumentFragment))
+ .appendSpace()
+ .append(Var->getName(), DeclarationFragments::FragmentKind::Identifier)
+ .append(";", DeclarationFragments::FragmentKind::Text);
+ return Fragments;
+}
+
DeclarationFragments
DeclarationFragmentsBuilder::getFragmentsForParam(const ParmVarDecl *Param) {
DeclarationFragments Fragments, After;
@@ -903,6 +933,47 @@ DeclarationFragmentsBuilder::getFragmentsForClassTemplatePartialSpecialization(
.append(";", DeclarationFragments::FragmentKind::Text);
}
+DeclarationFragments
+DeclarationFragmentsBuilder::getFragmentsForVarTemplateSpecialization(
+ const VarTemplateSpecializationDecl *Decl) {
+ DeclarationFragments Fragments;
+ return Fragments
+ .append("template", DeclarationFragments::FragmentKind::Keyword)
+ .append("<", DeclarationFragments::FragmentKind::Text)
+ .append(">", DeclarationFragments::FragmentKind::Text)
+ .appendSpace()
+ .append(DeclarationFragmentsBuilder::getFragmentsForVarTemplate(Decl))
+ .pop_back() // there is an extra semicolon now
+ .append("<", DeclarationFragments::FragmentKind::Text)
+ .append(
+ getFragmentsForTemplateArguments(Decl->getTemplateArgs().asArray(),
+ Decl->getASTContext(), std::nullopt))
+ .append(">", DeclarationFragments::FragmentKind::Text)
+ .append(";", DeclarationFragments::FragmentKind::Text);
+}
+
+DeclarationFragments
+DeclarationFragmentsBuilder::getFragmentsForVarTemplatePartialSpecialization(
+ const VarTemplatePartialSpecializationDecl *Decl) {
+ DeclarationFragments Fragments;
+ return Fragments
+ .append("template", DeclarationFragments::FragmentKind::Keyword)
+ .append("<", DeclarationFragments::FragmentKind::Text)
+ // Partial specs may have new params.
+ .append(getFragmentsForTemplateParameters(
+ Decl->getTemplateParameters()->asArray()))
+ .append(">", DeclarationFragments::FragmentKind::Text)
+ .appendSpace()
+ .append(DeclarationFragmentsBuilder::getFragmentsForVarTemplate(Decl))
+ .pop_back() // there is an extra semicolon now
+ .append("<", DeclarationFragments::FragmentKind::Text)
+ .append(getFragmentsForTemplateArguments(
+ Decl->getTemplateArgs().asArray(), Decl->getASTContext(),
+ Decl->getTemplateParameters()->asArray()))
+ .append(">", DeclarationFragments::FragmentKind::Text)
+ .append(";", DeclarationFragments::FragmentKind::Text);
+}
+
DeclarationFragments
DeclarationFragmentsBuilder::getFragmentsForMacro(StringRef Name,
const MacroDirective *MD) {
diff --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
index 6c7a037f76e348..ae8b1a67a50e9b 100644
--- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -361,6 +361,18 @@ Object serializeSymbolKind(APIRecord::RecordKind RK, Language Lang) {
Kind["identifier"] = AddLangPrefix("func");
Kind["displayName"] = "Function";
break;
+ case APIRecord::RK_GlobalVariableTemplate:
+ Kind["identifier"] = AddLangPrefix("var");
+ Kind["displayName"] = "Global Variable Template";
+ break;
+ case APIRecord::RK_GlobalVariableTemplateSpecialization:
+ Kind["identifier"] = AddLangPrefix("var");
+ Kind["displayName"] = "Global Variable Template Specialization";
+ break;
+ case APIRecord::RK_GlobalVariableTemplatePartialSpecialization:
+ Kind["identifier"] = AddLangPrefix("var");
+ Kind["displayName"] = "Global Variable Template Partial Specialization";
+ break;
case APIRecord::RK_GlobalVariable:
Kind["identifier"] = AddLangPrefix("var");
Kind["displayName"] = "Global Variable";
@@ -910,6 +922,31 @@ void SymbolGraphSerializer::visitConceptRecord(const ConceptRecord &Record) {
Symbols.emplace_back(std::move(*Concept));
}
+void SymbolGraphSerializer::visitGlobalVariableTemplateRecord(
+ const GlobalVariableTemplateRecord &Record) {
+ auto GlobalVariableTemplate = serializeAPIRecord(Record);
+ if (!GlobalVariableTemplate)
+ return;
+ Symbols.emplace_back(std::move(*GlobalVariableTemplate));
+}
+
+void SymbolGraphSerializer::visitGlobalVariableTemplateSpecializationRecord(
+ const GlobalVariableTemplateSpecializationRecord &Record) {
+ auto GlobalVariableTemplateSpecialization = serializeAPIRecord(Record);
+ if (!GlobalVariableTemplateSpecialization)
+ return;
+ Symbols.emplace_back(std::move(*GlobalVariableTemplateSpecialization));
+}
+
+void SymbolGraphSerializer::
+ visitGlobalVariableTemplatePartialSpecializationRecord(
+ const GlobalVariableTemplatePartialSpecializationRecord &Record) {
+ auto GlobalVariableTemplatePartialSpecialization = serializeAPIRecord(Record);
+ if (!GlobalVariableTemplatePartialSpecialization)
+ return;
+ Symbols.emplace_back(std::move(*GlobalVariableTemplatePartialSpecialization));
+}
+
void SymbolGraphSerializer::visitObjCContainerRecord(
const ObjCContainerRecord &Record) {
auto ObjCContainer = serializeAPIRecord(Record);
diff --git a/clang/test/ExtractAPI/global_var_template.cpp b/clang/test/ExtractAPI/global_var_template.cpp
new file mode 100644
index 00000000000000..a3b71cc17cc412
--- /dev/null
+++ b/clang/test/ExtractAPI/global_var_template.cpp
@@ -0,0 +1,133 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s at INPUT_DIR@%{/t:regex_replacement}@g" \
+// RUN: %t/reference.output.json.in >> %t/reference.output.json
+// RUN: %clang_cc1 -extract-api -triple arm64-apple-macosx \
+// RUN: -x c++-header %t/input.h -o %t/output.json -verify
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/output.json >> %t/output-normalized.json
+// RUN:
diff %t/reference.output.json %t/output-normalized.json
+
+//--- input.h
+template<typename T> T Foo = T(3.14);
+/// expected-no-diagnostics
+
+//--- reference.output.json.in
+{
+ "metadata": {
+ "formatVersion": {
+ "major": 0,
+ "minor": 5,
+ "patch": 3
+ },
+ "generator": "?"
+ },
+ "module": {
+ "name": "",
+ "platform": {
+ "architecture": "arm64",
+ "operatingSystem": {
+ "minimumVersion": {
+ "major": 11,
+ "minor": 0,
+ "patch": 0
+ },
+ "name": "macosx"
+ },
+ "vendor": "apple"
+ }
+ },
+ "relationships": [],
+ "symbols": [
+ {
+ "accessLevel": "public",
+ "declarationFragments": [
+ {
+ "kind": "keyword",
+ "spelling": "template"
+ },
+ {
+ "kind": "text",
+ "spelling": "<"
+ },
+ {
+ "kind": "keyword",
+ "spelling": "typename"
+ },
+ {
+ "kind": "text",
+ "spelling": " "
+ },
+ {
+ "kind": "genericParameter",
+ "spelling": "T"
+ },
+ {
+ "kind": "text",
+ "spelling": "> "
+ },
+ {
+ "kind": "typeIdentifier",
+ "preciseIdentifier": "c:t0.0",
+ "spelling": "T"
+ },
+ {
+ "kind": "text",
+ "spelling": " "
+ },
+ {
+ "kind": "identifier",
+ "spelling": "Foo"
+ },
+ {
+ "kind": "text",
+ "spelling": ";"
+ }
+ ],
+ "identifier": {
+ "interfaceLanguage": "c++",
+ "precise": "c:@Foo"
+ },
+ "kind": {
+ "displayName": "Global Variable Template",
+ "identifier": "c++.var"
+ },
+ "location": {
+ "position": {
+ "character": 24,
+ "line": 1
+ },
+ "uri": "file://INPUT_DIR/input.h"
+ },
+ "names": {
+ "navigator": [
+ {
+ "kind": "identifier",
+ "spelling": "Foo"
+ }
+ ],
+ "subHeading": [
+ {
+ "kind": "identifier",
+ "spelling": "Foo"
+ }
+ ],
+ "title": "Foo"
+ },
+ "pathComponents": [
+ "Foo"
+ ],
+ "swiftGenerics": {
+ "parameters": [
+ {
+ "depth": 0,
+ "index": 0,
+ "name": "T"
+ }
+ ]
+ }
+ }
+ ]
+}
diff --git a/clang/test/ExtractAPI/global_var_template_partial_spec.cpp b/clang/test/ExtractAPI/global_var_template_partial_spec.cpp
new file mode 100644
index 00000000000000..e7c92786331e8e
--- /dev/null
+++ b/clang/test/ExtractAPI/global_var_template_partial_spec.cpp
@@ -0,0 +1,262 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s at INPUT_DIR@%{/t:regex_replacement}@g" \
+// RUN: %t/reference.output.json.in >> %t/reference.output.json
+// RUN: %clang_cc1 -extract-api -triple arm64-apple-macosx \
+// RUN: -x c++-header %t/input.h -o %t/output.json -verify
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/output.json >> %t/output-normalized.json
+// RUN:
diff %t/reference.output.json %t/output-normalized.json
+
+//--- input.h
+template<typename X, typename Y> int Foo = 0;
+
+template<typename Z> int Foo<int, Z> = 0;
+/// expected-no-diagnostics
+
+//--- reference.output.json.in
+{
+ "metadata": {
+ "formatVersion": {
+ "major": 0,
+ "minor": 5,
+ "patch": 3
+ },
+ "generator": "?"
+ },
+ "module": {
+ "name": "",
+ "platform": {
+ "architecture": "arm64",
+ "operatingSystem": {
+ "minimumVersion": {
+ "major": 11,
+ "minor": 0,
+ "patch": 0
+ },
+ "name": "macosx"
+ },
+ "vendor": "apple"
+ }
+ },
+ "relationships": [],
+ "symbols": [
+ {
+ "accessLevel": "public",
+ "declarationFragments": [
+ {
+ "kind": "keyword",
+ "spelling": "template"
+ },
+ {
+ "kind": "text",
+ "spelling": "<"
+ },
+ {
+ "kind": "keyword",
+ "spelling": "typename"
+ },
+ {
+ "kind": "text",
+ "spelling": " "
+ },
+ {
+ "kind": "genericParameter",
+ "spelling": "X"
+ },
+ {
+ "kind": "text",
+ "spelling": ", "
+ },
+ {
+ "kind": "keyword",
+ "spelling": "typename"
+ },
+ {
+ "kind": "text",
+ "spelling": " "
+ },
+ {
+ "kind": "genericParameter",
+ "spelling": "Y"
+ },
+ {
+ "kind": "text",
+ "spelling": "> "
+ },
+ {
+ "kind": "typeIdentifier",
+ "preciseIdentifier": "c:I",
+ "spelling": "int"
+ },
+ {
+ "kind": "text",
+ "spelling": " "
+ },
+ {
+ "kind": "identifier",
+ "spelling": "Foo"
+ },
+ {
+ "kind": "text",
+ "spelling": ";"
+ }
+ ],
+ "identifier": {
+ "interfaceLanguage": "c++",
+ "precise": "c:@Foo"
+ },
+ "kind": {
+ "displayName": "Global Variable Template",
+ "identifier": "c++.var"
+ },
+ "location": {
+ "position": {
+ "character": 38,
+ "line": 1
+ },
+ "uri": "file://INPUT_DIR/input.h"
+ },
+ "names": {
+ "navigator": [
+ {
+ "kind": "identifier",
+ "spelling": "Foo"
+ }
+ ],
+ "subHeading": [
+ {
+ "kind": "identifier",
+ "spelling": "Foo"
+ }
+ ],
+ "title": "Foo"
+ },
+ "pathComponents": [
+ "Foo"
+ ],
+ "swiftGenerics": {
+ "parameters": [
+ {
+ "depth": 0,
+ "index": 0,
+ "name": "X"
+ },
+ {
+ "depth": 0,
+ "index": 1,
+ "name": "Y"
+ }
+ ]
+ }
+ },
+ {
+ "accessLevel": "public",
+ "declarationFragments": [
+ {
+ "kind": "keyword",
+ "spelling": "template"
+ },
+ {
+ "kind": "text",
+ "spelling": "<"
+ },
+ {
+ "kind": "keyword",
+ "spelling": "typename"
+ },
+ {
+ "kind": "text",
+ "spelling": " "
+ },
+ {
+ "kind": "genericParameter",
+ "spelling": "Z"
+ },
+ {
+ "kind": "text",
+ "spelling": "> "
+ },
+ {
+ "kind": "typeIdentifier",
+ "preciseIdentifier": "c:I",
+ "spelling": "int"
+ },
+ {
+ "kind": "text",
+ "spelling": " "
+ },
+ {
+ "kind": "identifier",
+ "spelling": "Foo"
+ },
+ {
+ "kind": "text",
+ "spelling": "<"
+ },
+ {
+ "kind": "typeIdentifier",
+ "preciseIdentifier": "c:I",
+ "spelling": "int"
+ },
+ {
+ "kind": "text",
+ "spelling": ", "
+ },
+ {
+ "kind": "typeIdentifier",
+ "preciseIdentifier": "c:t0.0",
+ "spelling": "Z"
+ },
+ {
+ "kind": "text",
+ "spelling": ">;"
+ }
+ ],
+ "identifier": {
+ "interfaceLanguage": "c++",
+ "precise": "c:@VP>1#T at Foo>#I#t0.0"
+ },
+ "kind": {
+ "displayName": "Global Variable Template Partial Specialization",
+ "identifier": "c++.var"
+ },
+ "location": {
+ "position": {
+ "character": 26,
+ "line": 3
+ },
+ "uri": "file://INPUT_DIR/input.h"
+ },
+ "names": {
+ "navigator": [
+ {
+ "kind": "identifier",
+ "spelling": "Foo"
+ }
+ ],
+ "subHeading": [
+ {
+ "kind": "identifier",
+ "spelling": "Foo"
+ }
+ ],
+ "title": "Foo"
+ },
+ "pathComponents": [
+ "Foo"
+ ],
+ "swiftGenerics": {
+ "parameters": [
+ {
+ "depth": 0,
+ "index": 0,
+ "name": "Z"
+ }
+ ]
+ }
+ }
+ ]
+}
diff --git a/clang/test/ExtractAPI/global_var_template_spec.cpp b/clang/test/ExtractAPI/global_var_template_spec.cpp
new file mode 100644
index 00000000000000..16268b2c58d3e4
--- /dev/null
+++ b/clang/test/ExtractAPI/global_var_template_spec.cpp
@@ -0,0 +1,207 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s at INPUT_DIR@%{/t:regex_replacement}@g" \
+// RUN: %t/reference.output.json.in >> %t/reference.output.json
+// RUN: %clang_cc1 -extract-api -triple arm64-apple-macosx \
+// RUN: -x c++-header %t/input.h -o %t/output.json -verify
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/output.json >> %t/output-normalized.json
+// RUN:
diff %t/reference.output.json %t/output-normalized.json
+
+//--- input.h
+template<typename T> T Foo = T(3.14);
+
+template<> int Foo<int>;
+/// expected-no-diagnostics
+
+//--- reference.output.json.in
+{
+ "metadata": {
+ "formatVersion": {
+ "major": 0,
+ "minor": 5,
+ "patch": 3
+ },
+ "generator": "?"
+ },
+ "module": {
+ "name": "",
+ "platform": {
+ "architecture": "arm64",
+ "operatingSystem": {
+ "minimumVersion": {
+ "major": 11,
+ "minor": 0,
+ "patch": 0
+ },
+ "name": "macosx"
+ },
+ "vendor": "apple"
+ }
+ },
+ "relationships": [],
+ "symbols": [
+ {
+ "accessLevel": "public",
+ "declarationFragments": [
+ {
+ "kind": "keyword",
+ "spelling": "template"
+ },
+ {
+ "kind": "text",
+ "spelling": "<"
+ },
+ {
+ "kind": "keyword",
+ "spelling": "typename"
+ },
+ {
+ "kind": "text",
+ "spelling": " "
+ },
+ {
+ "kind": "genericParameter",
+ "spelling": "T"
+ },
+ {
+ "kind": "text",
+ "spelling": "> "
+ },
+ {
+ "kind": "typeIdentifier",
+ "preciseIdentifier": "c:t0.0",
+ "spelling": "T"
+ },
+ {
+ "kind": "text",
+ "spelling": " "
+ },
+ {
+ "kind": "identifier",
+ "spelling": "Foo"
+ },
+ {
+ "kind": "text",
+ "spelling": ";"
+ }
+ ],
+ "identifier": {
+ "interfaceLanguage": "c++",
+ "precise": "c:@Foo"
+ },
+ "kind": {
+ "displayName": "Global Variable Template",
+ "identifier": "c++.var"
+ },
+ "location": {
+ "position": {
+ "character": 24,
+ "line": 1
+ },
+ "uri": "file://INPUT_DIR/input.h"
+ },
+ "names": {
+ "navigator": [
+ {
+ "kind": "identifier",
+ "spelling": "Foo"
+ }
+ ],
+ "subHeading": [
+ {
+ "kind": "identifier",
+ "spelling": "Foo"
+ }
+ ],
+ "title": "Foo"
+ },
+ "pathComponents": [
+ "Foo"
+ ],
+ "swiftGenerics": {
+ "parameters": [
+ {
+ "depth": 0,
+ "index": 0,
+ "name": "T"
+ }
+ ]
+ }
+ },
+ {
+ "accessLevel": "public",
+ "declarationFragments": [
+ {
+ "kind": "keyword",
+ "spelling": "template"
+ },
+ {
+ "kind": "text",
+ "spelling": "<> "
+ },
+ {
+ "kind": "typeIdentifier",
+ "preciseIdentifier": "c:I",
+ "spelling": "int"
+ },
+ {
+ "kind": "text",
+ "spelling": " "
+ },
+ {
+ "kind": "identifier",
+ "spelling": "Foo"
+ },
+ {
+ "kind": "text",
+ "spelling": "<"
+ },
+ {
+ "kind": "typeIdentifier",
+ "preciseIdentifier": "c:I",
+ "spelling": "int"
+ },
+ {
+ "kind": "text",
+ "spelling": ">;"
+ }
+ ],
+ "identifier": {
+ "interfaceLanguage": "c++",
+ "precise": "c:@Foo>#I"
+ },
+ "kind": {
+ "displayName": "Global Variable Template Specialization",
+ "identifier": "c++.var"
+ },
+ "location": {
+ "position": {
+ "character": 16,
+ "line": 3
+ },
+ "uri": "file://INPUT_DIR/input.h"
+ },
+ "names": {
+ "navigator": [
+ {
+ "kind": "identifier",
+ "spelling": "Foo"
+ }
+ ],
+ "subHeading": [
+ {
+ "kind": "identifier",
+ "spelling": "Foo"
+ }
+ ],
+ "title": "Foo"
+ },
+ "pathComponents": [
+ "Foo"
+ ]
+ }
+ ]
+}
More information about the cfe-commits
mailing list