From 39dbfa72aaebe64e913d65f1eeab48c5f33b8010 Mon Sep 17 00:00:00 2001 From: Daniel Grumberg Date: Mon, 7 Nov 2022 13:33:59 +0000 Subject: [PATCH] Revert "Only add targetFallback if target is not in defined in current product" This was an accidental addition of a non-reviewed change. This reverts commit f63db9159bbbb0db98e13cb4440fdaa5c40e219b. --- clang/include/clang/ExtractAPI/API.h | 6 ---- clang/lib/ExtractAPI/API.cpp | 33 ---------------------- .../Serialization/SymbolGraphSerializer.cpp | 5 +--- .../test/ExtractAPI/anonymous_record_no_typedef.c | 12 +++++--- clang/test/ExtractAPI/enum.c | 33 ++++++++++++++-------- clang/test/ExtractAPI/objc_category.m | 9 ++++-- clang/test/ExtractAPI/objc_interface.m | 18 ++++++++---- clang/test/ExtractAPI/objc_property.m | 21 +++++++++----- clang/test/ExtractAPI/objc_protocol.m | 3 +- clang/test/ExtractAPI/struct.c | 12 +++++--- clang/test/ExtractAPI/underscored.c | 3 +- 11 files changed, 75 insertions(+), 80 deletions(-) diff --git a/clang/include/clang/ExtractAPI/API.h b/clang/include/clang/ExtractAPI/API.h index ffb700e..b77d76d 100644 --- a/clang/include/clang/ExtractAPI/API.h +++ b/clang/include/clang/ExtractAPI/API.h @@ -675,12 +675,6 @@ public: const RecordMap &getMacros() const { return Macros; } const RecordMap &getTypedefs() const { return Typedefs; } - /// Get the APIRecord associated with the USR if it's defined in the - /// current product. - /// - /// \returns a APIRecord pointer to the stored symbol record if it exists. - APIRecord *getSymbolForUSR(StringRef USR) const; - /// Generate and store the USR of declaration \p D. /// /// Note: The USR string is stored in and owned by Allocator. diff --git a/clang/lib/ExtractAPI/API.cpp b/clang/lib/ExtractAPI/API.cpp index 4832202..8ab03a8 100644 --- a/clang/lib/ExtractAPI/API.cpp +++ b/clang/lib/ExtractAPI/API.cpp @@ -197,39 +197,6 @@ TypedefRecord *APISet::addTypedef(StringRef Name, StringRef USR, Comment, Declaration, SubHeading, UnderlyingType); } -template -static APIRecord *getSymbolInRecordMapForUSR(StringRef USR, - const RecordMap &Records) { - auto It = Records.find(USR); - return (It != Records.end() ? It->second.get() : nullptr); -} - -APIRecord *APISet::getSymbolForUSR(StringRef USR) const { - if (USR.empty()) - return nullptr; - if (auto *Record = getSymbolInRecordMapForUSR(USR, ObjCProtocols)) - return Record; - if (auto *Record = getSymbolInRecordMapForUSR(USR, ObjCInterfaces)) - return Record; - if (auto *Record = getSymbolInRecordMapForUSR(USR, ObjCCategories)) - return Record; - if (auto *Record = getSymbolInRecordMapForUSR(USR, ObjCCategories)) - return Record; - if (auto *Record = getSymbolInRecordMapForUSR(USR, Structs)) - return Record; - if (auto *Record = getSymbolInRecordMapForUSR(USR, Enums)) - return Record; - if (auto *Record = getSymbolInRecordMapForUSR(USR, Typedefs)) - return Record; - if (auto *Record = getSymbolInRecordMapForUSR(USR, GlobalFunctions)) - return Record; - if (auto *Record = getSymbolInRecordMapForUSR(USR, GlobalVariables)) - return Record; - if (auto *Record = getSymbolInRecordMapForUSR(USR, Macros)) - return Record; - return nullptr; -} - StringRef APISet::recordUSR(const Decl *D) { SmallString<128> USR; index::generateUSRForDecl(D, USR); diff --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp index 807c618..641f1ae 100644 --- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp +++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp @@ -559,10 +559,7 @@ void SymbolGraphSerializer::serializeRelationship(RelationshipKind Kind, Object Relationship; Relationship["source"] = Source.USR; Relationship["target"] = Target.USR; - // Emit a fallback if the target is not a symbol that will be part of this - // symbol graph. - if (API.getSymbolForUSR(Target.USR) == nullptr) - Relationship["targetFallback"] = Target.Name; + Relationship["targetFallback"] = Target.Name; Relationship["kind"] = getRelationshipString(Kind); Relationships.emplace_back(std::move(Relationship)); diff --git a/clang/test/ExtractAPI/anonymous_record_no_typedef.c b/clang/test/ExtractAPI/anonymous_record_no_typedef.c index e20abfd..abb96db 100644 --- a/clang/test/ExtractAPI/anonymous_record_no_typedef.c +++ b/clang/test/ExtractAPI/anonymous_record_no_typedef.c @@ -56,22 +56,26 @@ struct Vehicle { { "kind": "memberOf", "source": "c:@S@Vehicle@E@input.h@64@Bicycle", - "target": "c:@S@Vehicle@E@input.h@64" + "target": "c:@S@Vehicle@E@input.h@64", + "targetFallback": "Vehicle::enum (unnamed)" }, { "kind": "memberOf", "source": "c:@S@Vehicle@E@input.h@64@Car", - "target": "c:@S@Vehicle@E@input.h@64" + "target": "c:@S@Vehicle@E@input.h@64", + "targetFallback": "Vehicle::enum (unnamed)" }, { "kind": "memberOf", "source": "c:@S@Vehicle@FI@type", - "target": "c:@S@Vehicle" + "target": "c:@S@Vehicle", + "targetFallback": "Vehicle" }, { "kind": "memberOf", "source": "c:@S@Vehicle@FI@information", - "target": "c:@S@Vehicle" + "target": "c:@S@Vehicle", + "targetFallback": "Vehicle" } ], "symbols": [ diff --git a/clang/test/ExtractAPI/enum.c b/clang/test/ExtractAPI/enum.c index 07d8480..7b34546 100644 --- a/clang/test/ExtractAPI/enum.c +++ b/clang/test/ExtractAPI/enum.c @@ -65,57 +65,68 @@ enum { { "kind": "memberOf", "source": "c:@E@Vehicle@Bicycle", - "target": "c:@E@Vehicle" + "target": "c:@E@Vehicle", + "targetFallback": "Vehicle" }, { "kind": "memberOf", "source": "c:@E@Vehicle@Car", - "target": "c:@E@Vehicle" + "target": "c:@E@Vehicle", + "targetFallback": "Vehicle" }, { "kind": "memberOf", "source": "c:@E@Vehicle@Train", - "target": "c:@E@Vehicle" + "target": "c:@E@Vehicle", + "targetFallback": "Vehicle" }, { "kind": "memberOf", "source": "c:@E@Vehicle@Ship", - "target": "c:@E@Vehicle" + "target": "c:@E@Vehicle", + "targetFallback": "Vehicle" }, { "kind": "memberOf", "source": "c:@E@Vehicle@Airplane", - "target": "c:@E@Vehicle" + "target": "c:@E@Vehicle", + "targetFallback": "Vehicle" }, { "kind": "memberOf", "source": "c:@E@Direction@North", - "target": "c:@E@Direction" + "target": "c:@E@Direction", + "targetFallback": "Direction" }, { "kind": "memberOf", "source": "c:@E@Direction@East", - "target": "c:@E@Direction" + "target": "c:@E@Direction", + "targetFallback": "Direction" }, { "kind": "memberOf", "source": "c:@E@Direction@South", - "target": "c:@E@Direction" + "target": "c:@E@Direction", + "targetFallback": "Direction" }, { "kind": "memberOf", "source": "c:@E@Direction@West", - "target": "c:@E@Direction" + "target": "c:@E@Direction", + "targetFallback": "Direction" }, { "kind": "memberOf", "source": "c:@Ea@Constant@Constant", - "target": "c:@Ea@Constant" + "target": "c:@Ea@Constant", + "targetFallback": "enum (unnamed)" }, { "kind": "memberOf", "source": "c:@Ea@OtherConstant@OtherConstant", - "target": "c:@Ea@OtherConstant" + "target": "c:@Ea@OtherConstant", + "targetFallback": "enum (unnamed)" } ], "symbols": [ diff --git a/clang/test/ExtractAPI/objc_category.m b/clang/test/ExtractAPI/objc_category.m index b0bdaad..185016d 100644 --- a/clang/test/ExtractAPI/objc_category.m +++ b/clang/test/ExtractAPI/objc_category.m @@ -54,17 +54,20 @@ { "kind": "memberOf", "source": "c:objc(cs)Interface(im)InstanceMethod", - "target": "c:objc(cs)Interface" + "target": "c:objc(cs)Interface", + "targetFallback": "Interface" }, { "kind": "memberOf", "source": "c:objc(cs)Interface(cm)ClassMethod", - "target": "c:objc(cs)Interface" + "target": "c:objc(cs)Interface", + "targetFallback": "Interface" }, { "kind": "memberOf", "source": "c:objc(cs)Interface(py)Property", - "target": "c:objc(cs)Interface" + "target": "c:objc(cs)Interface", + "targetFallback": "Interface" }, { "kind": "conformsTo", diff --git a/clang/test/ExtractAPI/objc_interface.m b/clang/test/ExtractAPI/objc_interface.m index 908ee37..159e97a 100644 --- a/clang/test/ExtractAPI/objc_interface.m +++ b/clang/test/ExtractAPI/objc_interface.m @@ -57,17 +57,20 @@ { "kind": "memberOf", "source": "c:objc(cs)Super(cm)getWithProperty:", - "target": "c:objc(cs)Super" + "target": "c:objc(cs)Super", + "targetFallback": "Super" }, { "kind": "memberOf", "source": "c:objc(cs)Super(im)setProperty:andOtherThing:", - "target": "c:objc(cs)Super" + "target": "c:objc(cs)Super", + "targetFallback": "Super" }, { "kind": "memberOf", "source": "c:objc(cs)Super(py)Property", - "target": "c:objc(cs)Super" + "target": "c:objc(cs)Super", + "targetFallback": "Super" }, { "kind": "conformsTo", @@ -78,17 +81,20 @@ { "kind": "memberOf", "source": "c:objc(cs)Derived@Ivar", - "target": "c:objc(cs)Derived" + "target": "c:objc(cs)Derived", + "targetFallback": "Derived" }, { "kind": "memberOf", "source": "c:objc(cs)Derived(im)getIvar", - "target": "c:objc(cs)Derived" + "target": "c:objc(cs)Derived", + "targetFallback": "Derived" }, { "kind": "inheritsFrom", "source": "c:objc(cs)Derived", - "target": "c:objc(cs)Super" + "target": "c:objc(cs)Super", + "targetFallback": "Super" } ], "symbols": [ diff --git a/clang/test/ExtractAPI/objc_property.m b/clang/test/ExtractAPI/objc_property.m index 1b50950..f09a5ad 100644 --- a/clang/test/ExtractAPI/objc_property.m +++ b/clang/test/ExtractAPI/objc_property.m @@ -55,37 +55,44 @@ { "kind": "memberOf", "source": "c:objc(cs)Interface(cpy)myInterfaceTypeProp", - "target": "c:objc(cs)Interface" + "target": "c:objc(cs)Interface", + "targetFallback": "Interface" }, { "kind": "memberOf", "source": "c:objc(cs)Interface(py)myInterfaceInstanceProp", - "target": "c:objc(cs)Interface" + "target": "c:objc(cs)Interface", + "targetFallback": "Interface" }, { "kind": "memberOf", "source": "c:objc(cs)Interface(cpy)myCategoryTypeProp", - "target": "c:objc(cs)Interface" + "target": "c:objc(cs)Interface", + "targetFallback": "Interface" }, { "kind": "memberOf", "source": "c:objc(cs)Interface(py)myCategoryInstanceProp", - "target": "c:objc(cs)Interface" + "target": "c:objc(cs)Interface", + "targetFallback": "Interface" }, { "kind": "conformsTo", "source": "c:objc(cs)Interface", - "target": "c:objc(pl)Protocol" + "target": "c:objc(pl)Protocol", + "targetFallback": "Protocol" }, { "kind": "memberOf", "source": "c:objc(pl)Protocol(cpy)myProtocolTypeProp", - "target": "c:objc(pl)Protocol" + "target": "c:objc(pl)Protocol", + "targetFallback": "Protocol" }, { "kind": "memberOf", "source": "c:objc(pl)Protocol(py)myProtocolInstanceProp", - "target": "c:objc(pl)Protocol" + "target": "c:objc(pl)Protocol", + "targetFallback": "Protocol" } ], "symbols": [ diff --git a/clang/test/ExtractAPI/objc_protocol.m b/clang/test/ExtractAPI/objc_protocol.m index 0368509..d9a65f4 100644 --- a/clang/test/ExtractAPI/objc_protocol.m +++ b/clang/test/ExtractAPI/objc_protocol.m @@ -49,7 +49,8 @@ { "kind": "conformsTo", "source": "c:objc(pl)AnotherProtocol", - "target": "c:objc(pl)Protocol" + "target": "c:objc(pl)Protocol", + "targetFallback": "Protocol" } ], "symbols": [ diff --git a/clang/test/ExtractAPI/struct.c b/clang/test/ExtractAPI/struct.c index 51605576..7e93f0d 100644 --- a/clang/test/ExtractAPI/struct.c +++ b/clang/test/ExtractAPI/struct.c @@ -52,22 +52,26 @@ struct Color { { "kind": "memberOf", "source": "c:@S@Color@FI@Red", - "target": "c:@S@Color" + "target": "c:@S@Color", + "targetFallback": "Color" }, { "kind": "memberOf", "source": "c:@S@Color@FI@Green", - "target": "c:@S@Color" + "target": "c:@S@Color", + "targetFallback": "Color" }, { "kind": "memberOf", "source": "c:@S@Color@FI@Blue", - "target": "c:@S@Color" + "target": "c:@S@Color", + "targetFallback": "Color" }, { "kind": "memberOf", "source": "c:@S@Color@FI@Alpha", - "target": "c:@S@Color" + "target": "c:@S@Color", + "targetFallback": "Color" } ], "symbols": [ diff --git a/clang/test/ExtractAPI/underscored.c b/clang/test/ExtractAPI/underscored.c index 47f1893..6eeaf1c 100644 --- a/clang/test/ExtractAPI/underscored.c +++ b/clang/test/ExtractAPI/underscored.c @@ -65,7 +65,8 @@ typedef _HiddenTypedef ExposedTypedefToHidden; { "kind": "memberOf", "source": "c:@S@ExposedRecord@FI@a", - "target": "c:@S@ExposedRecord" + "target": "c:@S@ExposedRecord", + "targetFallback": "ExposedRecord" } ], "symbols": [ -- 2.7.4