Skip to content

Commit

Permalink
Revert "Only add targetFallback if target is not in defined in curren…
Browse files Browse the repository at this point in the history
…t product"

This was an accidental addition of a non-reviewed change.

This reverts commit f63db91.
  • Loading branch information
daniel-grumberg committed Nov 7, 2022
1 parent f63db91 commit 39dbfa7
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 80 deletions.
6 changes: 0 additions & 6 deletions clang/include/clang/ExtractAPI/API.h
Expand Up @@ -675,12 +675,6 @@ class APISet {
const RecordMap<MacroDefinitionRecord> &getMacros() const { return Macros; }
const RecordMap<TypedefRecord> &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.
Expand Down
33 changes: 0 additions & 33 deletions clang/lib/ExtractAPI/API.cpp
Expand Up @@ -197,39 +197,6 @@ TypedefRecord *APISet::addTypedef(StringRef Name, StringRef USR,
Comment, Declaration, SubHeading, UnderlyingType);
}

template <class RecordMap>
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);
Expand Down
5 changes: 1 addition & 4 deletions clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
Expand Up @@ -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));
Expand Down
12 changes: 8 additions & 4 deletions clang/test/ExtractAPI/anonymous_record_no_typedef.c
Expand Up @@ -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": [
Expand Down
33 changes: 22 additions & 11 deletions clang/test/ExtractAPI/enum.c
Expand Up @@ -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": [
Expand Down
9 changes: 6 additions & 3 deletions clang/test/ExtractAPI/objc_category.m
Expand Up @@ -54,17 +54,20 @@ + (void)ClassMethod;
{
"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",
Expand Down
18 changes: 12 additions & 6 deletions clang/test/ExtractAPI/objc_interface.m
Expand Up @@ -57,17 +57,20 @@ - (char)getIvar;
{
"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",
Expand All @@ -78,17 +81,20 @@ - (char)getIvar;
{
"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": [
Expand Down
21 changes: 14 additions & 7 deletions clang/test/ExtractAPI/objc_property.m
Expand Up @@ -55,37 +55,44 @@ @interface Interface (Category) <Protocol>
{
"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": [
Expand Down
3 changes: 2 additions & 1 deletion clang/test/ExtractAPI/objc_protocol.m
Expand Up @@ -49,7 +49,8 @@ @protocol AnotherProtocol <Protocol>
{
"kind": "conformsTo",
"source": "c:objc(pl)AnotherProtocol",
"target": "c:objc(pl)Protocol"
"target": "c:objc(pl)Protocol",
"targetFallback": "Protocol"
}
],
"symbols": [
Expand Down
12 changes: 8 additions & 4 deletions clang/test/ExtractAPI/struct.c
Expand Up @@ -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": [
Expand Down
3 changes: 2 additions & 1 deletion clang/test/ExtractAPI/underscored.c
Expand Up @@ -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": [
Expand Down

0 comments on commit 39dbfa7

Please sign in to comment.