mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[CusorInfo] Fix ASAN heap-use-after-free failure when reporting parent contexts.
Resolves rdar://problem/74289832
This commit is contained in:
@@ -1,5 +1,3 @@
|
|||||||
// REQUIRES: rdar74150023
|
|
||||||
|
|
||||||
/// Something about variable global
|
/// Something about variable global
|
||||||
let global = 1
|
let global = 1
|
||||||
|
|
||||||
|
|||||||
@@ -836,9 +836,7 @@ static bool passCursorInfoForDecl(SourceFile* SF,
|
|||||||
|
|
||||||
|
|
||||||
SmallVector<symbolgraphgen::PathComponent, 4> PathComponents;
|
SmallVector<symbolgraphgen::PathComponent, 4> PathComponents;
|
||||||
SmallVector<ParentInfo, 4> Parents;
|
|
||||||
unsigned SymbolGraphBegin = SS.size();
|
unsigned SymbolGraphBegin = SS.size();
|
||||||
unsigned SymbolGraphEnd = SymbolGraphBegin;
|
|
||||||
if (SymbolGraph) {
|
if (SymbolGraph) {
|
||||||
symbolgraphgen::SymbolGraphOptions Options {
|
symbolgraphgen::SymbolGraphOptions Options {
|
||||||
"",
|
"",
|
||||||
@@ -851,16 +849,16 @@ static bool passCursorInfoForDecl(SourceFile* SF,
|
|||||||
symbolgraphgen::printSymbolGraphForDecl(VD, BaseType,
|
symbolgraphgen::printSymbolGraphForDecl(VD, BaseType,
|
||||||
InSynthesizedExtension, Options, OS,
|
InSynthesizedExtension, Options, OS,
|
||||||
PathComponents);
|
PathComponents);
|
||||||
SymbolGraphEnd = SS.size();
|
|
||||||
|
|
||||||
for (auto &Component: PathComponents) {
|
|
||||||
unsigned USRStart = SS.size();
|
|
||||||
if (SwiftLangSupport::printUSR(Component.VD, OS))
|
|
||||||
continue;
|
|
||||||
StringRef USR{SS.begin()+USRStart, SS.size() - USRStart};
|
|
||||||
Parents.push_back({Component.Title, Component.Kind, USR});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
unsigned SymbolGraphEnd = SS.size();
|
||||||
|
|
||||||
|
DelayedStringRetriever ParentUSRsOS(SS);
|
||||||
|
for (auto &Component: PathComponents) {
|
||||||
|
ParentUSRsOS.startPiece();
|
||||||
|
if (SwiftLangSupport::printUSR(Component.VD, OS))
|
||||||
|
ParentUSRsOS.startPiece(); // ignore any output if invalid
|
||||||
|
ParentUSRsOS.endPiece();
|
||||||
|
};
|
||||||
|
|
||||||
unsigned FullDeclBegin = SS.size();
|
unsigned FullDeclBegin = SS.size();
|
||||||
{
|
{
|
||||||
@@ -995,6 +993,15 @@ static bool passCursorInfoForDecl(SourceFile* SF,
|
|||||||
StringRef SymbolGraphJSON = StringRef(SS.begin()+SymbolGraphBegin,
|
StringRef SymbolGraphJSON = StringRef(SS.begin()+SymbolGraphBegin,
|
||||||
SymbolGraphEnd-SymbolGraphBegin);
|
SymbolGraphEnd-SymbolGraphBegin);
|
||||||
|
|
||||||
|
SmallVector<ParentInfo, 4> Parents;
|
||||||
|
auto ParentIt = PathComponents.begin();
|
||||||
|
ParentUSRsOS.retrieve([&](StringRef ParentUSR) {
|
||||||
|
assert(ParentIt != PathComponents.end());
|
||||||
|
if (!ParentUSR.empty())
|
||||||
|
Parents.push_back({ParentIt->Title, ParentIt->Kind, ParentUSR});
|
||||||
|
++ParentIt;
|
||||||
|
});
|
||||||
|
|
||||||
// If VD is the syntehsized property wrapper backing storage (_foo) or
|
// If VD is the syntehsized property wrapper backing storage (_foo) or
|
||||||
// projected value ($foo) of a property (foo), base the location on that
|
// projected value ($foo) of a property (foo), base the location on that
|
||||||
// property instead.
|
// property instead.
|
||||||
|
|||||||
Reference in New Issue
Block a user