SourceKit: use explicit struct constructor for C++14

Explicitly instantiate the `CursorInfoData` instances when using it with
the default constructor rather than using the inline initializer list.
This is needed to build with C++14 mode.  Provide a default value for
the `Optional` type in the structure which prevents a non-copy default
constructor from being synthesized.  NFC.
This commit is contained in:
Saleem Abdulrasool
2017-12-18 12:31:08 -08:00
parent 40e9499c45
commit aaeac4cb34
2 changed files with 14 additions and 14 deletions

View File

@@ -286,7 +286,7 @@ struct CursorInfoData {
StringRef ModuleInterfaceName; StringRef ModuleInterfaceName;
/// This is an (offset,length) pair. /// This is an (offset,length) pair.
/// It is set only if the declaration has a source location. /// It is set only if the declaration has a source location.
llvm::Optional<std::pair<unsigned, unsigned>> DeclarationLoc; llvm::Optional<std::pair<unsigned, unsigned>> DeclarationLoc = None;
/// Set only if the declaration has a source location. /// Set only if the declaration has a source location.
StringRef Filename; StringRef Filename;
/// For methods this lists the USRs of the overrides in the class hierarchy. /// For methods this lists the USRs of the overrides in the class hierarchy.

View File

@@ -1218,7 +1218,7 @@ static void resolveCursor(SwiftLangSupport &Lang,
SourceLoc Loc = SourceLoc Loc =
Lexer::getLocForStartOfToken(SM, BufferID, Offset); Lexer::getLocForStartOfToken(SM, BufferID, Offset);
if (Loc.isInvalid()) { if (Loc.isInvalid()) {
Receiver({}); Receiver(CursorInfoData());
return; return;
} }
@@ -1281,7 +1281,7 @@ static void resolveCursor(SwiftLangSupport &Lang,
CursorInfoResolver Resolver(AstUnit->getPrimarySourceFile()); CursorInfoResolver Resolver(AstUnit->getPrimarySourceFile());
ResolvedCursorInfo CursorInfo = Resolver.resolve(Loc); ResolvedCursorInfo CursorInfo = Resolver.resolve(Loc);
if (CursorInfo.isInvalid()) { if (CursorInfo.isInvalid()) {
Receiver({}); Receiver(CursorInfoData());
return; return;
} }
CompilerInvocation CompInvok; CompilerInvocation CompInvok;
@@ -1313,7 +1313,7 @@ static void resolveCursor(SwiftLangSupport &Lang,
/*TryExistingAST=*/false, CancelOnSubsequentRequest, /*TryExistingAST=*/false, CancelOnSubsequentRequest,
Receiver); Receiver);
} else { } else {
Receiver({}); Receiver(CursorInfoData());
} }
} }
return; return;
@@ -1343,7 +1343,7 @@ static void resolveCursor(SwiftLangSupport &Lang,
} }
} }
Receiver({}); Receiver(CursorInfoData());
return; return;
} }
case CursorInfoKind::Invalid: { case CursorInfoKind::Invalid: {
@@ -1360,7 +1360,7 @@ static void resolveCursor(SwiftLangSupport &Lang,
void failed(StringRef Error) override { void failed(StringRef Error) override {
LOG_WARN_FUNC("cursor info failed: " << Error); LOG_WARN_FUNC("cursor info failed: " << Error);
Receiver({}); Receiver(CursorInfoData());
} }
}; };
@@ -1595,7 +1595,7 @@ void SwiftLangSupport::getCursorInfo(
{}, *this, Invok, {}, Receiver); {}, *this, Invok, {}, Receiver);
} }
} else { } else {
Receiver({}); Receiver(CursorInfoData());
} }
}); });
return; return;
@@ -1606,7 +1606,7 @@ void SwiftLangSupport::getCursorInfo(
if (!Invok) { if (!Invok) {
// FIXME: Report it as failed request. // FIXME: Report it as failed request.
LOG_WARN_FUNC("failed to create an ASTInvocation: " << Error); LOG_WARN_FUNC("failed to create an ASTInvocation: " << Error);
Receiver({}); Receiver(CursorInfoData());
return; return;
} }
@@ -1752,7 +1752,7 @@ resolveCursorFromUSR(SwiftLangSupport &Lang, StringRef InputFile, StringRef USR,
if (USR.startswith("c:")) { if (USR.startswith("c:")) {
LOG_WARN_FUNC("lookup for C/C++/ObjC USRs not implemented"); LOG_WARN_FUNC("lookup for C/C++/ObjC USRs not implemented");
Receiver({}); Receiver(CursorInfoData());
return; return;
} }
@@ -1761,7 +1761,7 @@ resolveCursorFromUSR(SwiftLangSupport &Lang, StringRef InputFile, StringRef USR,
Decl *D = ide::getDeclFromUSR(context, USR, error); Decl *D = ide::getDeclFromUSR(context, USR, error);
if (!D) { if (!D) {
Receiver({}); Receiver(CursorInfoData());
return; return;
} }
@@ -1790,7 +1790,7 @@ resolveCursorFromUSR(SwiftLangSupport &Lang, StringRef InputFile, StringRef USR,
/*TryExistingAST=*/false, /*TryExistingAST=*/false,
CancelOnSubsequentRequest, Receiver); CancelOnSubsequentRequest, Receiver);
} else { } else {
Receiver({}); Receiver(CursorInfoData());
} }
} }
} }
@@ -1804,7 +1804,7 @@ resolveCursorFromUSR(SwiftLangSupport &Lang, StringRef InputFile, StringRef USR,
void failed(StringRef Error) override { void failed(StringRef Error) override {
LOG_WARN_FUNC("cursor info failed: " << Error); LOG_WARN_FUNC("cursor info failed: " << Error);
Receiver({}); Receiver(CursorInfoData());
} }
}; };
@@ -1824,7 +1824,7 @@ void SwiftLangSupport::getCursorInfoFromUSR(
std::function<void(const CursorInfoData &)> receiver) { std::function<void(const CursorInfoData &)> receiver) {
if (auto IFaceGenRef = IFaceGenContexts.get(filename)) { if (auto IFaceGenRef = IFaceGenContexts.get(filename)) {
LOG_WARN_FUNC("info from usr for generated interface not implemented yet"); LOG_WARN_FUNC("info from usr for generated interface not implemented yet");
receiver({}); receiver(CursorInfoData());
return; return;
} }
@@ -1833,7 +1833,7 @@ void SwiftLangSupport::getCursorInfoFromUSR(
if (!invok) { if (!invok) {
// FIXME: Report it as failed request. // FIXME: Report it as failed request.
LOG_WARN_FUNC("failed to create an ASTInvocation: " << error); LOG_WARN_FUNC("failed to create an ASTInvocation: " << error);
receiver({}); receiver(CursorInfoData());
return; return;
} }