[clang] 39dbfa7 - Revert "Only add targetFallback if target is not in defined in current product"
Daniel Grumberg via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 7 05:34:46 PST 2022
Author: Daniel Grumberg
Date: 2022-11-07T13:33:59Z
New Revision: 39dbfa72aaebe64e913d65f1eeab48c5f33b8010
URL: https://github.com/llvm/llvm-project/commit/39dbfa72aaebe64e913d65f1eeab48c5f33b8010
DIFF: https://github.com/llvm/llvm-project/commit/39dbfa72aaebe64e913d65f1eeab48c5f33b8010.diff
LOG: 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.
Added:
Modified:
clang/include/clang/ExtractAPI/API.h
clang/lib/ExtractAPI/API.cpp
clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
clang/test/ExtractAPI/anonymous_record_no_typedef.c
clang/test/ExtractAPI/enum.c
clang/test/ExtractAPI/objc_category.m
clang/test/ExtractAPI/objc_interface.m
clang/test/ExtractAPI/objc_property.m
clang/test/ExtractAPI/objc_protocol.m
clang/test/ExtractAPI/struct.c
clang/test/ExtractAPI/underscored.c
Removed:
################################################################################
diff --git a/clang/include/clang/ExtractAPI/API.h b/clang/include/clang/ExtractAPI/API.h
index ffb700eb923f..b77d76d500df 100644
--- a/clang/include/clang/ExtractAPI/API.h
+++ b/clang/include/clang/ExtractAPI/API.h
@@ -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.
diff --git a/clang/lib/ExtractAPI/API.cpp b/clang/lib/ExtractAPI/API.cpp
index 48322023d504..8ab03a833e3c 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 <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);
diff --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
index 807c618e3198..641f1ae812a5 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 e20abfdd86ab..abb96db058db 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 at Vehicle@E at input.h@64 at Bicycle",
- "target": "c:@S at Vehicle@E at input.h@64"
+ "target": "c:@S at Vehicle@E at input.h@64",
+ "targetFallback": "Vehicle::enum (unnamed)"
},
{
"kind": "memberOf",
"source": "c:@S at Vehicle@E at input.h@64 at Car",
- "target": "c:@S at Vehicle@E at input.h@64"
+ "target": "c:@S at Vehicle@E at input.h@64",
+ "targetFallback": "Vehicle::enum (unnamed)"
},
{
"kind": "memberOf",
"source": "c:@S at Vehicle@FI at type",
- "target": "c:@S at Vehicle"
+ "target": "c:@S at Vehicle",
+ "targetFallback": "Vehicle"
},
{
"kind": "memberOf",
"source": "c:@S at Vehicle@FI at information",
- "target": "c:@S at Vehicle"
+ "target": "c:@S at Vehicle",
+ "targetFallback": "Vehicle"
}
],
"symbols": [
diff --git a/clang/test/ExtractAPI/enum.c b/clang/test/ExtractAPI/enum.c
index 07d848082981..7b345464cb98 100644
--- a/clang/test/ExtractAPI/enum.c
+++ b/clang/test/ExtractAPI/enum.c
@@ -65,57 +65,68 @@ enum {
{
"kind": "memberOf",
"source": "c:@E at Vehicle@Bicycle",
- "target": "c:@E at Vehicle"
+ "target": "c:@E at Vehicle",
+ "targetFallback": "Vehicle"
},
{
"kind": "memberOf",
"source": "c:@E at Vehicle@Car",
- "target": "c:@E at Vehicle"
+ "target": "c:@E at Vehicle",
+ "targetFallback": "Vehicle"
},
{
"kind": "memberOf",
"source": "c:@E at Vehicle@Train",
- "target": "c:@E at Vehicle"
+ "target": "c:@E at Vehicle",
+ "targetFallback": "Vehicle"
},
{
"kind": "memberOf",
"source": "c:@E at Vehicle@Ship",
- "target": "c:@E at Vehicle"
+ "target": "c:@E at Vehicle",
+ "targetFallback": "Vehicle"
},
{
"kind": "memberOf",
"source": "c:@E at Vehicle@Airplane",
- "target": "c:@E at Vehicle"
+ "target": "c:@E at Vehicle",
+ "targetFallback": "Vehicle"
},
{
"kind": "memberOf",
"source": "c:@E at Direction@North",
- "target": "c:@E at Direction"
+ "target": "c:@E at Direction",
+ "targetFallback": "Direction"
},
{
"kind": "memberOf",
"source": "c:@E at Direction@East",
- "target": "c:@E at Direction"
+ "target": "c:@E at Direction",
+ "targetFallback": "Direction"
},
{
"kind": "memberOf",
"source": "c:@E at Direction@South",
- "target": "c:@E at Direction"
+ "target": "c:@E at Direction",
+ "targetFallback": "Direction"
},
{
"kind": "memberOf",
"source": "c:@E at Direction@West",
- "target": "c:@E at Direction"
+ "target": "c:@E at Direction",
+ "targetFallback": "Direction"
},
{
"kind": "memberOf",
"source": "c:@Ea at Constant@Constant",
- "target": "c:@Ea at Constant"
+ "target": "c:@Ea at Constant",
+ "targetFallback": "enum (unnamed)"
},
{
"kind": "memberOf",
"source": "c:@Ea at OtherConstant@OtherConstant",
- "target": "c:@Ea at OtherConstant"
+ "target": "c:@Ea at OtherConstant",
+ "targetFallback": "enum (unnamed)"
}
],
"symbols": [
diff --git a/clang/test/ExtractAPI/objc_category.m b/clang/test/ExtractAPI/objc_category.m
index b0bdaaddbdad..185016dfe848 100644
--- a/clang/test/ExtractAPI/objc_category.m
+++ b/clang/test/ExtractAPI/objc_category.m
@@ -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",
diff --git a/clang/test/ExtractAPI/objc_interface.m b/clang/test/ExtractAPI/objc_interface.m
index 908ee37f85bb..159e97a193a1 100644
--- a/clang/test/ExtractAPI/objc_interface.m
+++ b/clang/test/ExtractAPI/objc_interface.m
@@ -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",
@@ -78,17 +81,20 @@ - (char)getIvar;
{
"kind": "memberOf",
"source": "c:objc(cs)Derived at 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 1b50950d4424..f09a5ad72423 100644
--- a/clang/test/ExtractAPI/objc_property.m
+++ b/clang/test/ExtractAPI/objc_property.m
@@ -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": [
diff --git a/clang/test/ExtractAPI/objc_protocol.m b/clang/test/ExtractAPI/objc_protocol.m
index 036850924587..d9a65f419df8 100644
--- a/clang/test/ExtractAPI/objc_protocol.m
+++ b/clang/test/ExtractAPI/objc_protocol.m
@@ -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": [
diff --git a/clang/test/ExtractAPI/struct.c b/clang/test/ExtractAPI/struct.c
index 516055768749..7e93f0d7e7bf 100644
--- a/clang/test/ExtractAPI/struct.c
+++ b/clang/test/ExtractAPI/struct.c
@@ -52,22 +52,26 @@ struct Color {
{
"kind": "memberOf",
"source": "c:@S at Color@FI at Red",
- "target": "c:@S at Color"
+ "target": "c:@S at Color",
+ "targetFallback": "Color"
},
{
"kind": "memberOf",
"source": "c:@S at Color@FI at Green",
- "target": "c:@S at Color"
+ "target": "c:@S at Color",
+ "targetFallback": "Color"
},
{
"kind": "memberOf",
"source": "c:@S at Color@FI at Blue",
- "target": "c:@S at Color"
+ "target": "c:@S at Color",
+ "targetFallback": "Color"
},
{
"kind": "memberOf",
"source": "c:@S at Color@FI at Alpha",
- "target": "c:@S at Color"
+ "target": "c:@S at Color",
+ "targetFallback": "Color"
}
],
"symbols": [
diff --git a/clang/test/ExtractAPI/underscored.c b/clang/test/ExtractAPI/underscored.c
index 47f1893cdb02..6eeaf1ce412c 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 at ExposedRecord@FI at a",
- "target": "c:@S at ExposedRecord"
+ "target": "c:@S at ExposedRecord",
+ "targetFallback": "ExposedRecord"
}
],
"symbols": [
More information about the cfe-commits
mailing list