Author: Daniel Grumberg Date: 2022-04-06T18:42:55+01:00 New Revision: 28d793144f2a5c92b83df3cc3d2772ec4cab0ad3
URL: https://github.com/llvm/llvm-project/commit/28d793144f2a5c92b83df3cc3d2772ec4cab0ad3 DIFF: https://github.com/llvm/llvm-project/commit/28d793144f2a5c92b83df3cc3d2772ec4cab0ad3.diff LOG: [clang][extract-api] Fix small issues with SymbolGraphSerializer This includes: - replacing "relationhips" with "relationships" - emitting the "pathComponents" property on symbols - emitting the "accessLevel" property on symbols Differential Revision: https://reviews.llvm.org/D123045 Added: Modified: clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp clang/test/ExtractAPI/enum.c clang/test/ExtractAPI/global_record.c clang/test/ExtractAPI/global_record_multifile.c clang/test/ExtractAPI/language.c clang/test/ExtractAPI/macro_undefined.c clang/test/ExtractAPI/macros.c clang/test/ExtractAPI/objc_interface.m clang/test/ExtractAPI/objc_protocol.m clang/test/ExtractAPI/struct.c Removed: ################################################################################ diff --git a/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h b/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h index 02ea9c2e92c83..7b55fd788f6d0 100644 --- a/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h +++ b/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h @@ -19,6 +19,7 @@ #include "clang/ExtractAPI/API.h" #include "clang/ExtractAPI/Serialization/SerializerBase.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/Support/JSON.h" #include "llvm/Support/VersionTuple.h" #include "llvm/Support/raw_ostream.h" @@ -45,6 +46,25 @@ class SymbolGraphSerializer : public APISerializer { /// The Symbol Graph format version used by this serializer. static const VersionTuple FormatVersion; + using PathComponentStack = llvm::SmallVector<llvm::StringRef, 4>; + /// The current path component stack. + /// + /// Note: this is used to serialize the ``pathComponents`` field of symbols in + /// the Symbol Graph. + PathComponentStack PathComponents; + + /// A helper type to manage PathComponents correctly using RAII. + struct PathComponentGuard { + PathComponentGuard(PathComponentStack &PC, StringRef Component) : PC(PC) { + PC.emplace_back(Component); + } + + ~PathComponentGuard() { PC.pop_back(); } + + private: + PathComponentStack &PC; + }; + public: /// Serialize the APIs in \c APISet in the Symbol Graph format. /// @@ -126,6 +146,13 @@ class SymbolGraphSerializer : public APISerializer { /// Serialize a macro defintion record. void serializeMacroDefinitionRecord(const MacroDefinitionRecord &Record); + /// Push a component to the current path components stack. + /// + /// \param Component The component to push onto the path components stack. + /// \return A PathComponentGuard responsible for removing the latest + /// component from the stack on scope exit. + LLVM_NODISCARD PathComponentGuard makePathComponentGuard(StringRef Component); + public: SymbolGraphSerializer(const APISet &API, StringRef ProductName, APISerializerOption Options = {}) diff --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp index bfd2c207c0918..1440ca358d4b5 100644 --- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp +++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp @@ -90,27 +90,35 @@ Object serializePlatform(const Triple &T) { return Platform; } +/// Serialize a source position. +Object serializeSourcePosition(const PresumedLoc &Loc) { + assert(Loc.isValid() && "invalid source position"); + + Object SourcePosition; + SourcePosition["line"] = Loc.getLine(); + SourcePosition["character"] = Loc.getColumn(); + + return SourcePosition; +} + /// Serialize a source location in file. /// /// \param Loc The presumed location to serialize. /// \param IncludeFileURI If true, include the file path of \p Loc as a URI. /// Defaults to false. -Object serializeSourcePosition(const PresumedLoc &Loc, +Object serializeSourceLocation(const PresumedLoc &Loc, bool IncludeFileURI = false) { - assert(Loc.isValid() && "invalid source position"); - - Object SourcePosition; - SourcePosition["line"] = Loc.getLine(); - SourcePosition["character"] = Loc.getColumn(); + Object SourceLocation; + serializeObject(SourceLocation, "position", serializeSourcePosition(Loc)); if (IncludeFileURI) { std::string FileURI = "file://"; // Normalize file path to use forward slashes for the URI. FileURI += sys::path::convert_to_slash(Loc.getFilename()); - SourcePosition["uri"] = FileURI; + SourceLocation["uri"] = FileURI; } - return SourcePosition; + return SourceLocation; } /// Serialize a source range with begin and end locations. @@ -449,12 +457,16 @@ SymbolGraphSerializer::serializeAPIRecord(const APIRecord &Record) const { serializeObject(Obj, "names", serializeNames(Record)); serializeObject( Obj, "location", - serializeSourcePosition(Record.Location, /*IncludeFileURI=*/true)); + serializeSourceLocation(Record.Location, /*IncludeFileURI=*/true)); serializeObject(Obj, "availbility", serializeAvailability(Record.Availability)); serializeObject(Obj, "docComment", serializeDocComment(Record.Comment)); serializeArray(Obj, "declarationFragments", serializeDeclarationFragments(Record.Declaration)); + // TODO: Once we keep track of symbol access information serialize it + // correctly here. + Obj["accessLevel"] = "public"; + serializeArray(Obj, "pathComponents", Array(PathComponents)); return Obj; } @@ -483,18 +495,21 @@ void SymbolGraphSerializer::serializeRelationship(RelationshipKind Kind, } void SymbolGraphSerializer::serializeGlobalRecord(const GlobalRecord &Record) { + auto GlobalPathComponentGuard = makePathComponentGuard(Record.Name); + auto Obj = serializeAPIRecord(Record); if (!Obj) return; if (Record.GlobalKind == GVKind::Function) - serializeObject(*Obj, "parameters", + serializeObject(*Obj, "functionSignature", serializeFunctionSignature(Record.Signature)); Symbols.emplace_back(std::move(*Obj)); } void SymbolGraphSerializer::serializeEnumRecord(const EnumRecord &Record) { + auto EnumPathComponentGuard = makePathComponentGuard(Record.Name); auto Enum = serializeAPIRecord(Record); if (!Enum) return; @@ -502,7 +517,10 @@ void SymbolGraphSerializer::serializeEnumRecord(const EnumRecord &Record) { Symbols.emplace_back(std::move(*Enum)); for (const auto &Constant : Record.Constants) { + auto EnumConstantPathComponentGuard = + makePathComponentGuard(Constant->Name); auto EnumConstant = serializeAPIRecord(*Constant); + if (!EnumConstant) continue; @@ -512,6 +530,7 @@ void SymbolGraphSerializer::serializeEnumRecord(const EnumRecord &Record) { } void SymbolGraphSerializer::serializeStructRecord(const StructRecord &Record) { + auto StructPathComponentGuard = makePathComponentGuard(Record.Name); auto Struct = serializeAPIRecord(Record); if (!Struct) return; @@ -519,7 +538,9 @@ void SymbolGraphSerializer::serializeStructRecord(const StructRecord &Record) { Symbols.emplace_back(std::move(*Struct)); for (const auto &Field : Record.Fields) { + auto StructFieldPathComponentGuard = makePathComponentGuard(Field->Name); auto StructField = serializeAPIRecord(*Field); + if (!StructField) continue; @@ -530,6 +551,7 @@ void SymbolGraphSerializer::serializeStructRecord(const StructRecord &Record) { void SymbolGraphSerializer::serializeObjCContainerRecord( const ObjCContainerRecord &Record) { + auto ObjCContainerPathComponentGuard = makePathComponentGuard(Record.Name); auto ObjCContainer = serializeAPIRecord(Record); if (!ObjCContainer) return; @@ -539,7 +561,9 @@ void SymbolGraphSerializer::serializeObjCContainerRecord( // Record instance variables and that the instance variables are members of // the container. for (const auto &Ivar : Record.Ivars) { + auto IvarPathComponentGuard = makePathComponentGuard(Ivar->Name); auto ObjCIvar = serializeAPIRecord(*Ivar); + if (!ObjCIvar) continue; @@ -549,7 +573,9 @@ void SymbolGraphSerializer::serializeObjCContainerRecord( // Record methods and that the methods are members of the container. for (const auto &Method : Record.Methods) { + auto MethodPathComponentGuard = makePathComponentGuard(Method->Name); auto ObjCMethod = serializeAPIRecord(*Method); + if (!ObjCMethod) continue; @@ -559,7 +585,9 @@ void SymbolGraphSerializer::serializeObjCContainerRecord( // Record properties and that the properties are members of the container. for (const auto &Property : Record.Properties) { + auto PropertyPathComponentGuard = makePathComponentGuard(Property->Name); auto ObjCProperty = serializeAPIRecord(*Property); + if (!ObjCProperty) continue; @@ -581,13 +609,20 @@ void SymbolGraphSerializer::serializeObjCContainerRecord( void SymbolGraphSerializer::serializeMacroDefinitionRecord( const MacroDefinitionRecord &Record) { + auto MacroPathComponentGuard = makePathComponentGuard(Record.Name); auto Macro = serializeAPIRecord(Record); + if (!Macro) return; Symbols.emplace_back(std::move(*Macro)); } +SymbolGraphSerializer::PathComponentGuard +SymbolGraphSerializer::makePathComponentGuard(StringRef Component) { + return PathComponentGuard(PathComponents, Component); +} + Object SymbolGraphSerializer::serialize() { Object Root; serializeObject(Root, "metadata", serializeMetadata()); @@ -617,7 +652,7 @@ Object SymbolGraphSerializer::serialize() { serializeMacroDefinitionRecord(*Macro.second); Root["symbols"] = std::move(Symbols); - Root["relationhips"] = std::move(Relationships); + Root["relationships"] = std::move(Relationships); return Root; } diff --git a/clang/test/ExtractAPI/enum.c b/clang/test/ExtractAPI/enum.c index f3b5cc8e08c74..a9646e21cc8f1 100644 --- a/clang/test/ExtractAPI/enum.c +++ b/clang/test/ExtractAPI/enum.c @@ -55,7 +55,7 @@ enum Direction : unsigned char { "vendor": "apple" } }, - "relationhips": [ + "relationships": [ { "kind": "memberOf", "source": "c:@E@Vehicle@Bicycle", @@ -104,6 +104,7 @@ enum Direction : unsigned char { ], "symbols": [ { + "accessLevel": "public", "declarationFragments": [ { "kind": "keyword", @@ -153,8 +154,10 @@ enum Direction : unsigned char { "identifier": "c.enum" }, "location": { - "character": 6, - "line": 2, + "position": { + "character": 6, + "line": 2 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -165,9 +168,13 @@ enum Direction : unsigned char { } ], "title": "Vehicle" - } + }, + "pathComponents": [ + "Vehicle" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "identifier", @@ -183,8 +190,10 @@ enum Direction : unsigned char { "identifier": "c.enum.case" }, "location": { - "character": 3, - "line": 3, + "position": { + "character": 3, + "line": 3 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -195,9 +204,14 @@ enum Direction : unsigned char { } ], "title": "Bicycle" - } + }, + "pathComponents": [ + "Vehicle", + "Bicycle" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "identifier", @@ -213,8 +227,10 @@ enum Direction : unsigned char { "identifier": "c.enum.case" }, "location": { - "character": 3, - "line": 4, + "position": { + "character": 3, + "line": 4 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -225,9 +241,14 @@ enum Direction : unsigned char { } ], "title": "Car" - } + }, + "pathComponents": [ + "Vehicle", + "Car" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "identifier", @@ -260,8 +281,10 @@ enum Direction : unsigned char { "identifier": "c.enum.case" }, "location": { - "character": 3, - "line": 5, + "position": { + "character": 3, + "line": 5 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -272,9 +295,14 @@ enum Direction : unsigned char { } ], "title": "Train" - } + }, + "pathComponents": [ + "Vehicle", + "Train" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "identifier", @@ -290,8 +318,10 @@ enum Direction : unsigned char { "identifier": "c.enum.case" }, "location": { - "character": 3, - "line": 6, + "position": { + "character": 3, + "line": 6 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -302,9 +332,14 @@ enum Direction : unsigned char { } ], "title": "Ship" - } + }, + "pathComponents": [ + "Vehicle", + "Ship" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "identifier", @@ -320,8 +355,10 @@ enum Direction : unsigned char { "identifier": "c.enum.case" }, "location": { - "character": 3, - "line": 7, + "position": { + "character": 3, + "line": 7 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -332,9 +369,14 @@ enum Direction : unsigned char { } ], "title": "Airplane" - } + }, + "pathComponents": [ + "Vehicle", + "Airplane" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "keyword", @@ -367,8 +409,10 @@ enum Direction : unsigned char { "identifier": "c.enum" }, "location": { - "character": 6, - "line": 10, + "position": { + "character": 6, + "line": 10 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -379,9 +423,13 @@ enum Direction : unsigned char { } ], "title": "Direction" - } + }, + "pathComponents": [ + "Direction" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "identifier", @@ -397,8 +445,10 @@ enum Direction : unsigned char { "identifier": "c.enum.case" }, "location": { - "character": 3, - "line": 11, + "position": { + "character": 3, + "line": 11 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -409,9 +459,14 @@ enum Direction : unsigned char { } ], "title": "North" - } + }, + "pathComponents": [ + "Direction", + "North" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "identifier", @@ -427,8 +482,10 @@ enum Direction : unsigned char { "identifier": "c.enum.case" }, "location": { - "character": 3, - "line": 12, + "position": { + "character": 3, + "line": 12 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -439,9 +496,14 @@ enum Direction : unsigned char { } ], "title": "East" - } + }, + "pathComponents": [ + "Direction", + "East" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "identifier", @@ -457,8 +519,10 @@ enum Direction : unsigned char { "identifier": "c.enum.case" }, "location": { - "character": 3, - "line": 13, + "position": { + "character": 3, + "line": 13 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -469,9 +533,14 @@ enum Direction : unsigned char { } ], "title": "South" - } + }, + "pathComponents": [ + "Direction", + "South" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "identifier", @@ -487,8 +556,10 @@ enum Direction : unsigned char { "identifier": "c.enum.case" }, "location": { - "character": 3, - "line": 14, + "position": { + "character": 3, + "line": 14 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -499,7 +570,11 @@ enum Direction : unsigned char { } ], "title": "West" - } + }, + "pathComponents": [ + "Direction", + "West" + ] } ] } diff --git a/clang/test/ExtractAPI/global_record.c b/clang/test/ExtractAPI/global_record.c index 7193ba11b4be1..4c14cae2de877 100644 --- a/clang/test/ExtractAPI/global_record.c +++ b/clang/test/ExtractAPI/global_record.c @@ -51,9 +51,10 @@ char unavailable __attribute__((unavailable)); "vendor": "apple" } }, - "relationhips": [], + "relationships": [], "symbols": [ { + "accessLevel": "public", "declarationFragments": [ { "kind": "typeIdentifier", @@ -78,8 +79,10 @@ char unavailable __attribute__((unavailable)); "identifier": "c.var" }, "location": { - "character": 5, - "line": 1, + "position": { + "character": 5, + "line": 1 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -90,9 +93,13 @@ char unavailable __attribute__((unavailable)); } ], "title": "num" - } + }, + "pathComponents": [ + "num" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "typeIdentifier", @@ -261,29 +268,7 @@ char unavailable __attribute__((unavailable)); } ] }, - "identifier": { - "interfaceLanguage": "c", - "precise": "c:@F@add" - }, - "kind": { - "displayName": "Function", - "identifier": "c.func" - }, - "location": { - "character": 6, - "line": 9, - "uri": "file://INPUT_DIR/input.h" - }, - "names": { - "subHeading": [ - { - "kind": "identifier", - "spelling": "add" - } - ], - "title": "add" - }, - "parameters": { + "functionSignature": { "parameters": [ { "declarationFragments": [ @@ -363,7 +348,34 @@ char unavailable __attribute__((unavailable)); "spelling": "void" } ] - } + }, + "identifier": { + "interfaceLanguage": "c", + "precise": "c:@F@add" + }, + "kind": { + "displayName": "Function", + "identifier": "c.func" + }, + "location": { + "position": { + "character": 6, + "line": 9 + }, + "uri": "file://INPUT_DIR/input.h" + }, + "names": { + "subHeading": [ + { + "kind": "identifier", + "spelling": "add" + } + ], + "title": "add" + }, + "pathComponents": [ + "add" + ] } ] } diff --git a/clang/test/ExtractAPI/global_record_multifile.c b/clang/test/ExtractAPI/global_record_multifile.c index cc5448e838298..76e18811a53b4 100644 --- a/clang/test/ExtractAPI/global_record_multifile.c +++ b/clang/test/ExtractAPI/global_record_multifile.c @@ -53,9 +53,10 @@ char unavailable __attribute__((unavailable)); "vendor": "apple" } }, - "relationhips": [], + "relationships": [], "symbols": [ { + "accessLevel": "public", "declarationFragments": [ { "kind": "typeIdentifier", @@ -80,8 +81,10 @@ char unavailable __attribute__((unavailable)); "identifier": "c.var" }, "location": { - "character": 5, - "line": 1, + "position": { + "character": 5, + "line": 1 + }, "uri": "file://INPUT_DIR/input1.h" }, "names": { @@ -92,9 +95,13 @@ char unavailable __attribute__((unavailable)); } ], "title": "num" - } + }, + "pathComponents": [ + "num" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "typeIdentifier", @@ -263,29 +270,7 @@ char unavailable __attribute__((unavailable)); } ] }, - "identifier": { - "interfaceLanguage": "c", - "precise": "c:@F@add" - }, - "kind": { - "displayName": "Function", - "identifier": "c.func" - }, - "location": { - "character": 6, - "line": 7, - "uri": "file://INPUT_DIR/input2.h" - }, - "names": { - "subHeading": [ - { - "kind": "identifier", - "spelling": "add" - } - ], - "title": "add" - }, - "parameters": { + "functionSignature": { "parameters": [ { "declarationFragments": [ @@ -365,7 +350,34 @@ char unavailable __attribute__((unavailable)); "spelling": "void" } ] - } + }, + "identifier": { + "interfaceLanguage": "c", + "precise": "c:@F@add" + }, + "kind": { + "displayName": "Function", + "identifier": "c.func" + }, + "location": { + "position": { + "character": 6, + "line": 7 + }, + "uri": "file://INPUT_DIR/input2.h" + }, + "names": { + "subHeading": [ + { + "kind": "identifier", + "spelling": "add" + } + ], + "title": "add" + }, + "pathComponents": [ + "add" + ] } ] } diff --git a/clang/test/ExtractAPI/language.c b/clang/test/ExtractAPI/language.c index 274e6b930340d..df182cf07819e 100644 --- a/clang/test/ExtractAPI/language.c +++ b/clang/test/ExtractAPI/language.c @@ -53,9 +53,10 @@ char objc; "vendor": "apple" } }, - "relationhips": [], + "relationships": [], "symbols": [ { + "accessLevel": "public", "declarationFragments": [ { "kind": "typeIdentifier", @@ -80,8 +81,10 @@ char objc; "identifier": "c.var" }, "location": { - "character": 6, - "line": 1, + "position": { + "character": 6, + "line": 1 + }, "uri": "file://INPUT_DIR/c.h" }, "names": { @@ -92,7 +95,10 @@ char objc; } ], "title": "c" - } + }, + "pathComponents": [ + "c" + ] } ] } @@ -121,9 +127,10 @@ char objc; "vendor": "apple" } }, - "relationhips": [], + "relationships": [], "symbols": [ { + "accessLevel": "public", "declarationFragments": [ { "kind": "typeIdentifier", @@ -148,8 +155,10 @@ char objc; "identifier": "objective-c.var" }, "location": { - "character": 6, - "line": 1, + "position": { + "character": 6, + "line": 1 + }, "uri": "file://INPUT_DIR/objc.h" }, "names": { @@ -160,7 +169,10 @@ char objc; } ], "title": "objc" - } + }, + "pathComponents": [ + "objc" + ] } ] } diff --git a/clang/test/ExtractAPI/macro_undefined.c b/clang/test/ExtractAPI/macro_undefined.c index f128a446b6588..feb4b3f43637e 100644 --- a/clang/test/ExtractAPI/macro_undefined.c +++ b/clang/test/ExtractAPI/macro_undefined.c @@ -47,9 +47,10 @@ FUNC_GEN(bar, const int *, unsigned); "vendor": "apple" } }, - "relationhips": [], + "relationships": [], "symbols": [ { + "accessLevel": "public", "declarationFragments": [ { "kind": "typeIdentifier", @@ -69,6 +70,15 @@ FUNC_GEN(bar, const int *, unsigned); "spelling": "()" } ], + "functionSignature": { + "returns": [ + { + "kind": "typeIdentifier", + "preciseIdentifier": "c:v", + "spelling": "void" + } + ] + }, "identifier": { "interfaceLanguage": "objective-c", "precise": "c:@F@foo" @@ -78,8 +88,10 @@ FUNC_GEN(bar, const int *, unsigned); "identifier": "objective-c.func" }, "location": { - "character": 1, - "line": 3, + "position": { + "character": 1, + "line": 3 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -91,17 +103,12 @@ FUNC_GEN(bar, const int *, unsigned); ], "title": "foo" }, - "parameters": { - "returns": [ - { - "kind": "typeIdentifier", - "preciseIdentifier": "c:v", - "spelling": "void" - } - ] - } + "pathComponents": [ + "foo" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "typeIdentifier", @@ -163,29 +170,7 @@ FUNC_GEN(bar, const int *, unsigned); "spelling": ")" } ], - "identifier": { - "interfaceLanguage": "objective-c", - "precise": "c:@F@bar" - }, - "kind": { - "displayName": "Function", - "identifier": "objective-c.func" - }, - "location": { - "character": 1, - "line": 4, - "uri": "file://INPUT_DIR/input.h" - }, - "names": { - "subHeading": [ - { - "kind": "identifier", - "spelling": "bar" - } - ], - "title": "bar" - }, - "parameters": { + "functionSignature": { "parameters": [ { "declarationFragments": [ @@ -239,9 +224,37 @@ FUNC_GEN(bar, const int *, unsigned); "spelling": "void" } ] - } + }, + "identifier": { + "interfaceLanguage": "objective-c", + "precise": "c:@F@bar" + }, + "kind": { + "displayName": "Function", + "identifier": "objective-c.func" + }, + "location": { + "position": { + "character": 1, + "line": 4 + }, + "uri": "file://INPUT_DIR/input.h" + }, + "names": { + "subHeading": [ + { + "kind": "identifier", + "spelling": "bar" + } + ], + "title": "bar" + }, + "pathComponents": [ + "bar" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "keyword", @@ -265,8 +278,10 @@ FUNC_GEN(bar, const int *, unsigned); "identifier": "objective-c.macro" }, "location": { - "character": 9, - "line": 1, + "position": { + "character": 9, + "line": 1 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -277,7 +292,10 @@ FUNC_GEN(bar, const int *, unsigned); } ], "title": "HELLO" - } + }, + "pathComponents": [ + "HELLO" + ] } ] } diff --git a/clang/test/ExtractAPI/macros.c b/clang/test/ExtractAPI/macros.c index 1e1e5e60906a6..867b0aed00619 100644 --- a/clang/test/ExtractAPI/macros.c +++ b/clang/test/ExtractAPI/macros.c @@ -46,9 +46,10 @@ "vendor": "apple" } }, - "relationhips": [], + "relationships": [], "symbols": [ { + "accessLevel": "public", "declarationFragments": [ { "kind": "keyword", @@ -72,8 +73,10 @@ "identifier": "objective-c.macro" }, "location": { - "character": 9, - "line": 1, + "position": { + "character": 9, + "line": 1 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -84,9 +87,13 @@ } ], "title": "HELLO" - } + }, + "pathComponents": [ + "HELLO" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "keyword", @@ -110,8 +117,10 @@ "identifier": "objective-c.macro" }, "location": { - "character": 9, - "line": 2, + "position": { + "character": 9, + "line": 2 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -122,9 +131,13 @@ } ], "title": "WORLD" - } + }, + "pathComponents": [ + "WORLD" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "keyword", @@ -160,8 +173,10 @@ "identifier": "objective-c.macro" }, "location": { - "character": 9, - "line": 3, + "position": { + "character": 9, + "line": 3 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -172,9 +187,13 @@ } ], "title": "MACRO_FUN" - } + }, + "pathComponents": [ + "MACRO_FUN" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "keyword", @@ -226,8 +245,10 @@ "identifier": "objective-c.macro" }, "location": { - "character": 9, - "line": 4, + "position": { + "character": 9, + "line": 4 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -238,9 +259,13 @@ } ], "title": "FUN" - } + }, + "pathComponents": [ + "FUN" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "keyword", @@ -276,8 +301,10 @@ "identifier": "objective-c.macro" }, "location": { - "character": 9, - "line": 5, + "position": { + "character": 9, + "line": 5 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -288,9 +315,13 @@ } ], "title": "FUNC99" - } + }, + "pathComponents": [ + "FUNC99" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "keyword", @@ -326,8 +357,10 @@ "identifier": "objective-c.macro" }, "location": { - "character": 9, - "line": 6, + "position": { + "character": 9, + "line": 6 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -338,7 +371,10 @@ } ], "title": "FUNGNU" - } + }, + "pathComponents": [ + "FUNGNU" + ] } ] } diff --git a/clang/test/ExtractAPI/objc_interface.m b/clang/test/ExtractAPI/objc_interface.m index 1e903cfc359e0..a105a58281fba 100644 --- a/clang/test/ExtractAPI/objc_interface.m +++ b/clang/test/ExtractAPI/objc_interface.m @@ -52,7 +52,7 @@ - (char)getIvar; "vendor": "apple" } }, - "relationhips": [ + "relationships": [ { "kind": "memberOf", "source": "c:objc(cs)Super(cm)getWithProperty:", @@ -86,6 +86,7 @@ - (char)getIvar; ], "symbols": [ { + "accessLevel": "public", "declarationFragments": [ { "kind": "keyword", @@ -109,8 +110,10 @@ - (char)getIvar; "identifier": "objective-c.class" }, "location": { - "character": 12, - "line": 3, + "position": { + "character": 12, + "line": 3 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -121,9 +124,13 @@ - (char)getIvar; } ], "title": "Super" - } + }, + "pathComponents": [ + "Super" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "text", @@ -172,8 +179,10 @@ - (char)getIvar; "identifier": "objective-c.type.method" }, "location": { - "character": 1, - "line": 5, + "position": { + "character": 1, + "line": 5 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -188,9 +197,14 @@ - (char)getIvar; } ], "title": "getWithProperty:" - } + }, + "pathComponents": [ + "Super", + "getWithProperty:" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "keyword", @@ -251,8 +265,10 @@ - (char)getIvar; "identifier": "objective-c.property" }, "location": { - "character": 50, - "line": 4, + "position": { + "character": 50, + "line": 4 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -263,9 +279,14 @@ - (char)getIvar; } ], "title": "Property" - } + }, + "pathComponents": [ + "Super", + "Property" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "keyword", @@ -298,8 +319,10 @@ - (char)getIvar; "identifier": "objective-c.class" }, "location": { - "character": 12, - "line": 8, + "position": { + "character": 12, + "line": 8 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -310,9 +333,13 @@ - (char)getIvar; } ], "title": "Derived" - } + }, + "pathComponents": [ + "Derived" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "typeIdentifier", @@ -337,8 +364,10 @@ - (char)getIvar; "identifier": "objective-c.ivar" }, "location": { - "character": 8, - "line": 9, + "position": { + "character": 8, + "line": 9 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -349,9 +378,14 @@ - (char)getIvar; } ], "title": "Ivar" - } + }, + "pathComponents": [ + "Derived", + "Ivar" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "text", @@ -380,8 +414,10 @@ - (char)getIvar; "identifier": "objective-c.method" }, "location": { - "character": 1, - "line": 11, + "position": { + "character": 1, + "line": 11 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -396,7 +432,11 @@ - (char)getIvar; } ], "title": "getIvar" - } + }, + "pathComponents": [ + "Derived", + "getIvar" + ] } ] } diff --git a/clang/test/ExtractAPI/objc_protocol.m b/clang/test/ExtractAPI/objc_protocol.m index 1b6c55ec474d8..cffb0ed55d54e 100644 --- a/clang/test/ExtractAPI/objc_protocol.m +++ b/clang/test/ExtractAPI/objc_protocol.m @@ -45,7 +45,7 @@ @protocol AnotherProtocol <Protocol> "vendor": "apple" } }, - "relationhips": [ + "relationships": [ { "kind": "conformsTo", "source": "c:objc(pl)AnotherProtocol", @@ -54,6 +54,7 @@ @protocol AnotherProtocol <Protocol> ], "symbols": [ { + "accessLevel": "public", "declarationFragments": [ { "kind": "keyword", @@ -77,8 +78,10 @@ @protocol AnotherProtocol <Protocol> "identifier": "objective-c.protocol" }, "location": { - "character": 11, - "line": 1, + "position": { + "character": 11, + "line": 1 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -89,9 +92,13 @@ @protocol AnotherProtocol <Protocol> } ], "title": "Protocol" - } + }, + "pathComponents": [ + "Protocol" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "keyword", @@ -128,8 +135,10 @@ @protocol AnotherProtocol <Protocol> "identifier": "objective-c.protocol" }, "location": { - "character": 11, - "line": 4, + "position": { + "character": 11, + "line": 4 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -140,7 +149,10 @@ @protocol AnotherProtocol <Protocol> } ], "title": "AnotherProtocol" - } + }, + "pathComponents": [ + "AnotherProtocol" + ] } ] } diff --git a/clang/test/ExtractAPI/struct.c b/clang/test/ExtractAPI/struct.c index 9be2ff4a4ffed..ec03d84493b05 100644 --- a/clang/test/ExtractAPI/struct.c +++ b/clang/test/ExtractAPI/struct.c @@ -48,7 +48,7 @@ struct Color { "vendor": "apple" } }, - "relationhips": [ + "relationships": [ { "kind": "memberOf", "source": "c:@S@Color@FI@Red", @@ -72,6 +72,7 @@ struct Color { ], "symbols": [ { + "accessLevel": "public", "declarationFragments": [ { "kind": "keyword", @@ -112,8 +113,10 @@ struct Color { "identifier": "c.struct" }, "location": { - "character": 8, - "line": 2, + "position": { + "character": 8, + "line": 2 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -124,9 +127,13 @@ struct Color { } ], "title": "Color" - } + }, + "pathComponents": [ + "Color" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "typeIdentifier", @@ -151,8 +158,10 @@ struct Color { "identifier": "c.property" }, "location": { - "character": 12, - "line": 3, + "position": { + "character": 12, + "line": 3 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -163,9 +172,14 @@ struct Color { } ], "title": "Red" - } + }, + "pathComponents": [ + "Color", + "Red" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "typeIdentifier", @@ -190,8 +204,10 @@ struct Color { "identifier": "c.property" }, "location": { - "character": 12, - "line": 4, + "position": { + "character": 12, + "line": 4 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -202,9 +218,14 @@ struct Color { } ], "title": "Green" - } + }, + "pathComponents": [ + "Color", + "Green" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "typeIdentifier", @@ -229,8 +250,10 @@ struct Color { "identifier": "c.property" }, "location": { - "character": 12, - "line": 5, + "position": { + "character": 12, + "line": 5 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -241,9 +264,14 @@ struct Color { } ], "title": "Blue" - } + }, + "pathComponents": [ + "Color", + "Blue" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "typeIdentifier", @@ -285,8 +313,10 @@ struct Color { "identifier": "c.property" }, "location": { - "character": 12, - "line": 7, + "position": { + "character": 12, + "line": 7 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -297,7 +327,11 @@ struct Color { } ], "title": "Alpha" - } + }, + "pathComponents": [ + "Color", + "Alpha" + ] } ] } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits