[Sema] ArrayRef-ize ParseObjCStringLiteral and CodeCompleteObjCProtocolReferences. NFC
llvm-svn: 256397
This commit is contained in:
parent
8b27746bde
commit
883dd33294
|
@ -5087,8 +5087,7 @@ public:
|
||||||
|
|
||||||
// ParseObjCStringLiteral - Parse Objective-C string literals.
|
// ParseObjCStringLiteral - Parse Objective-C string literals.
|
||||||
ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs,
|
ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs,
|
||||||
Expr **Strings,
|
ArrayRef<Expr *> Strings);
|
||||||
unsigned NumStrings);
|
|
||||||
|
|
||||||
ExprResult BuildObjCStringLiteral(SourceLocation AtLoc, StringLiteral *S);
|
ExprResult BuildObjCStringLiteral(SourceLocation AtLoc, StringLiteral *S);
|
||||||
|
|
||||||
|
@ -8900,8 +8899,8 @@ public:
|
||||||
DeclGroupPtrTy IterationVar);
|
DeclGroupPtrTy IterationVar);
|
||||||
void CodeCompleteObjCSelector(Scope *S,
|
void CodeCompleteObjCSelector(Scope *S,
|
||||||
ArrayRef<IdentifierInfo *> SelIdents);
|
ArrayRef<IdentifierInfo *> SelIdents);
|
||||||
void CodeCompleteObjCProtocolReferences(IdentifierLocPair *Protocols,
|
void CodeCompleteObjCProtocolReferences(
|
||||||
unsigned NumProtocols);
|
ArrayRef<IdentifierLocPair> Protocols);
|
||||||
void CodeCompleteObjCProtocolDecl(Scope *S);
|
void CodeCompleteObjCProtocolDecl(Scope *S);
|
||||||
void CodeCompleteObjCInterfaceDecl(Scope *S);
|
void CodeCompleteObjCInterfaceDecl(Scope *S);
|
||||||
void CodeCompleteObjCSuperclass(Scope *S,
|
void CodeCompleteObjCSuperclass(Scope *S,
|
||||||
|
|
|
@ -503,8 +503,7 @@ ObjCTypeParamList *Parser::parseObjCTypeParamListOrProtocolRefs(
|
||||||
if (Tok.is(tok::code_completion)) {
|
if (Tok.is(tok::code_completion)) {
|
||||||
// FIXME: If these aren't protocol references, we'll need different
|
// FIXME: If these aren't protocol references, we'll need different
|
||||||
// completions.
|
// completions.
|
||||||
Actions.CodeCompleteObjCProtocolReferences(protocolIdents.data(),
|
Actions.CodeCompleteObjCProtocolReferences(protocolIdents);
|
||||||
protocolIdents.size());
|
|
||||||
cutOffParsing();
|
cutOffParsing();
|
||||||
|
|
||||||
// FIXME: Better recovery here?.
|
// FIXME: Better recovery here?.
|
||||||
|
@ -1566,8 +1565,7 @@ ParseObjCProtocolReferences(SmallVectorImpl<Decl *> &Protocols,
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (Tok.is(tok::code_completion)) {
|
if (Tok.is(tok::code_completion)) {
|
||||||
Actions.CodeCompleteObjCProtocolReferences(ProtocolIdents.data(),
|
Actions.CodeCompleteObjCProtocolReferences(ProtocolIdents);
|
||||||
ProtocolIdents.size());
|
|
||||||
cutOffParsing();
|
cutOffParsing();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1670,8 +1668,7 @@ void Parser::parseObjCTypeArgsOrProtocolQualifiers(
|
||||||
if (!BaseT.isNull() && BaseT->acceptsObjCTypeParams()) {
|
if (!BaseT.isNull() && BaseT->acceptsObjCTypeParams()) {
|
||||||
Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Type);
|
Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Type);
|
||||||
} else {
|
} else {
|
||||||
Actions.CodeCompleteObjCProtocolReferences(identifierLocPairs.data(),
|
Actions.CodeCompleteObjCProtocolReferences(identifierLocPairs);
|
||||||
identifierLocPairs.size());
|
|
||||||
}
|
}
|
||||||
cutOffParsing();
|
cutOffParsing();
|
||||||
return;
|
return;
|
||||||
|
@ -3287,8 +3284,7 @@ ExprResult Parser::ParseObjCStringLiteral(SourceLocation AtLoc) {
|
||||||
AtStrings.push_back(Lit.get());
|
AtStrings.push_back(Lit.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Actions.ParseObjCStringLiteral(&AtLocs[0], AtStrings.data(),
|
return Actions.ParseObjCStringLiteral(AtLocs.data(), AtStrings);
|
||||||
AtStrings.size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ParseObjCBooleanLiteral -
|
/// ParseObjCBooleanLiteral -
|
||||||
|
|
|
@ -5926,8 +5926,8 @@ static void AddProtocolResults(DeclContext *Ctx, DeclContext *CurContext,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sema::CodeCompleteObjCProtocolReferences(IdentifierLocPair *Protocols,
|
void Sema::CodeCompleteObjCProtocolReferences(
|
||||||
unsigned NumProtocols) {
|
ArrayRef<IdentifierLocPair> Protocols) {
|
||||||
ResultBuilder Results(*this, CodeCompleter->getAllocator(),
|
ResultBuilder Results(*this, CodeCompleter->getAllocator(),
|
||||||
CodeCompleter->getCodeCompletionTUInfo(),
|
CodeCompleter->getCodeCompletionTUInfo(),
|
||||||
CodeCompletionContext::CCC_ObjCProtocolName);
|
CodeCompletionContext::CCC_ObjCProtocolName);
|
||||||
|
@ -5938,9 +5938,9 @@ void Sema::CodeCompleteObjCProtocolReferences(IdentifierLocPair *Protocols,
|
||||||
// Tell the result set to ignore all of the protocols we have
|
// Tell the result set to ignore all of the protocols we have
|
||||||
// already seen.
|
// already seen.
|
||||||
// FIXME: This doesn't work when caching code-completion results.
|
// FIXME: This doesn't work when caching code-completion results.
|
||||||
for (unsigned I = 0; I != NumProtocols; ++I)
|
for (const IdentifierLocPair &Pair : Protocols)
|
||||||
if (ObjCProtocolDecl *Protocol = LookupProtocol(Protocols[I].first,
|
if (ObjCProtocolDecl *Protocol = LookupProtocol(Pair.first,
|
||||||
Protocols[I].second))
|
Pair.second))
|
||||||
Results.Ignore(Protocol);
|
Results.Ignore(Protocol);
|
||||||
|
|
||||||
// Add all protocols.
|
// Add all protocols.
|
||||||
|
|
|
@ -32,24 +32,21 @@ using namespace sema;
|
||||||
using llvm::makeArrayRef;
|
using llvm::makeArrayRef;
|
||||||
|
|
||||||
ExprResult Sema::ParseObjCStringLiteral(SourceLocation *AtLocs,
|
ExprResult Sema::ParseObjCStringLiteral(SourceLocation *AtLocs,
|
||||||
Expr **strings,
|
ArrayRef<Expr *> Strings) {
|
||||||
unsigned NumStrings) {
|
|
||||||
StringLiteral **Strings = reinterpret_cast<StringLiteral**>(strings);
|
|
||||||
|
|
||||||
// Most ObjC strings are formed out of a single piece. However, we *can*
|
// Most ObjC strings are formed out of a single piece. However, we *can*
|
||||||
// have strings formed out of multiple @ strings with multiple pptokens in
|
// have strings formed out of multiple @ strings with multiple pptokens in
|
||||||
// each one, e.g. @"foo" "bar" @"baz" "qux" which need to be turned into one
|
// each one, e.g. @"foo" "bar" @"baz" "qux" which need to be turned into one
|
||||||
// StringLiteral for ObjCStringLiteral to hold onto.
|
// StringLiteral for ObjCStringLiteral to hold onto.
|
||||||
StringLiteral *S = Strings[0];
|
StringLiteral *S = cast<StringLiteral>(Strings[0]);
|
||||||
|
|
||||||
// If we have a multi-part string, merge it all together.
|
// If we have a multi-part string, merge it all together.
|
||||||
if (NumStrings != 1) {
|
if (Strings.size() != 1) {
|
||||||
// Concatenate objc strings.
|
// Concatenate objc strings.
|
||||||
SmallString<128> StrBuf;
|
SmallString<128> StrBuf;
|
||||||
SmallVector<SourceLocation, 8> StrLocs;
|
SmallVector<SourceLocation, 8> StrLocs;
|
||||||
|
|
||||||
for (unsigned i = 0; i != NumStrings; ++i) {
|
for (Expr *E : Strings) {
|
||||||
S = Strings[i];
|
S = cast<StringLiteral>(E);
|
||||||
|
|
||||||
// ObjC strings can't be wide or UTF.
|
// ObjC strings can't be wide or UTF.
|
||||||
if (!S->isAscii()) {
|
if (!S->isAscii()) {
|
||||||
|
|
Loading…
Reference in New Issue