summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Frontend/ASTUnit.cpp6
-rw-r--r--clang/lib/Parse/ParseDecl.cpp2
-rw-r--r--clang/lib/Parse/ParseExpr.cpp8
-rw-r--r--clang/lib/Parse/ParseExprCXX.cpp4
-rw-r--r--clang/lib/Parse/ParseOpenMP.cpp13
-rw-r--r--clang/lib/Sema/CodeCompleteConsumer.cpp22
-rw-r--r--clang/lib/Sema/SemaCodeComplete.cpp24
7 files changed, 45 insertions, 34 deletions
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 701f07f22e3..b91870c291c 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -1911,8 +1911,10 @@ namespace {
void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg,
OverloadCandidate *Candidates,
- unsigned NumCandidates) override {
- Next.ProcessOverloadCandidates(S, CurrentArg, Candidates, NumCandidates);
+ unsigned NumCandidates,
+ SourceLocation OpenParLoc) override {
+ Next.ProcessOverloadCandidates(S, CurrentArg, Candidates, NumCandidates,
+ OpenParLoc);
}
CodeCompletionAllocator &getAllocator() override {
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 04c0286ec6d..5d780de8f55 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -2304,7 +2304,7 @@ Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes(
auto ConstructorCompleter = [&, ThisVarDecl] {
Actions.CodeCompleteConstructor(
getCurScope(), ThisVarDecl->getType()->getCanonicalTypeInternal(),
- ThisDecl->getLocation(), Exprs);
+ ThisDecl->getLocation(), Exprs, T.getOpenLocation());
};
if (ThisVarDecl) {
// ParseExpressionList can sometimes succeed even when ThisDecl is not
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index d1d8507af8c..39bf1c63981 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -1650,7 +1650,8 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
CommaLocsTy CommaLocs;
if (Tok.is(tok::code_completion)) {
- Actions.CodeCompleteCall(getCurScope(), LHS.get(), None);
+ Actions.CodeCompleteCall(getCurScope(), LHS.get(), None,
+ PT.getOpenLocation());
cutOffParsing();
return ExprError();
}
@@ -1658,8 +1659,9 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
if (OpKind == tok::l_paren || !LHS.isInvalid()) {
if (Tok.isNot(tok::r_paren)) {
if (ParseExpressionList(ArgExprs, CommaLocs, [&] {
- Actions.CodeCompleteCall(getCurScope(), LHS.get(), ArgExprs);
- })) {
+ Actions.CodeCompleteCall(getCurScope(), LHS.get(), ArgExprs,
+ PT.getOpenLocation());
+ })) {
(void)Actions.CorrectDelayedTyposInExpr(LHS);
LHS = ExprError();
} else if (LHS.isInvalid()) {
diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp
index 4e27ca0cea5..fef01a4030f 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -1687,7 +1687,7 @@ Parser::ParseCXXTypeConstructExpression(const DeclSpec &DS) {
if (ParseExpressionList(Exprs, CommaLocs, [&] {
Actions.CodeCompleteConstructor(
getCurScope(), TypeRep.get()->getCanonicalTypeInternal(),
- DS.getEndLoc(), Exprs);
+ DS.getEndLoc(), Exprs, T.getOpenLocation());
})) {
SkipUntil(tok::r_paren, StopAtSemi);
return ExprError();
@@ -2821,7 +2821,7 @@ Parser::ParseCXXNewExpression(bool UseGlobal, SourceLocation Start) {
DeclaratorInfo).get();
Actions.CodeCompleteConstructor(
getCurScope(), TypeRep.get()->getCanonicalTypeInternal(),
- DeclaratorInfo.getEndLoc(), ConstructorArgs);
+ DeclaratorInfo.getEndLoc(), ConstructorArgs, ConstructorLParen);
})) {
SkipUntil(tok::semi, StopAtSemi | StopBeforeMatch);
return ExprError();
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index a413e96a91e..c53eae3067e 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -415,11 +415,14 @@ void Parser::ParseOpenMPReductionInitializerForDecl(VarDecl *OmpPrivParm) {
ExprVector Exprs;
CommaLocsTy CommaLocs;
- if (ParseExpressionList(Exprs, CommaLocs, [this, OmpPrivParm, &Exprs] {
- Actions.CodeCompleteConstructor(
- getCurScope(), OmpPrivParm->getType()->getCanonicalTypeInternal(),
- OmpPrivParm->getLocation(), Exprs);
- })) {
+ SourceLocation LParLoc = T.getOpenLocation();
+ if (ParseExpressionList(
+ Exprs, CommaLocs, [this, OmpPrivParm, LParLoc, &Exprs] {
+ Actions.CodeCompleteConstructor(
+ getCurScope(),
+ OmpPrivParm->getType()->getCanonicalTypeInternal(),
+ OmpPrivParm->getLocation(), Exprs, LParLoc);
+ })) {
Actions.ActOnInitializerError(OmpPrivParm);
SkipUntil(tok::r_paren, tok::annot_pragma_openmp_end, StopBeforeMatch);
} else {
diff --git a/clang/lib/Sema/CodeCompleteConsumer.cpp b/clang/lib/Sema/CodeCompleteConsumer.cpp
index 8af54b99393..c7d4fc4efa8 100644
--- a/clang/lib/Sema/CodeCompleteConsumer.cpp
+++ b/clang/lib/Sema/CodeCompleteConsumer.cpp
@@ -20,8 +20,8 @@
#include "clang/AST/DeclarationName.h"
#include "clang/AST/Type.h"
#include "clang/Basic/IdentifierTable.h"
-#include "clang/Sema/Sema.h"
#include "clang/Lex/Preprocessor.h"
+#include "clang/Sema/Sema.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
@@ -29,6 +29,7 @@
#include "llvm/Support/Casting.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
@@ -624,16 +625,17 @@ static std::string getOverloadAsString(const CodeCompletionString &CCS) {
return OS.str();
}
-void
-PrintingCodeCompleteConsumer::ProcessOverloadCandidates(Sema &SemaRef,
- unsigned CurrentArg,
- OverloadCandidate *Candidates,
- unsigned NumCandidates) {
+void PrintingCodeCompleteConsumer::ProcessOverloadCandidates(
+ Sema &SemaRef, unsigned CurrentArg, OverloadCandidate *Candidates,
+ unsigned NumCandidates, SourceLocation OpenParLoc) {
+ OS << "OPENING_PAREN_LOC: ";
+ OpenParLoc.print(OS, SemaRef.getSourceManager());
+ OS << "\n";
+
for (unsigned I = 0; I != NumCandidates; ++I) {
- if (CodeCompletionString *CCS
- = Candidates[I].CreateSignatureString(CurrentArg, SemaRef,
- getAllocator(), CCTUInfo,
- includeBriefComments())) {
+ if (CodeCompletionString *CCS = Candidates[I].CreateSignatureString(
+ CurrentArg, SemaRef, getAllocator(), CCTUInfo,
+ includeBriefComments())) {
OS << "OVERLOAD: " << getOverloadAsString(*CCS) << "\n";
}
}
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp
index 30af826ef6c..e0adf38f93e 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -4435,10 +4435,11 @@ static QualType getParamType(Sema &SemaRef,
return ParamType;
}
-static void CodeCompleteOverloadResults(Sema &SemaRef, Scope *S,
- MutableArrayRef<ResultCandidate> Candidates,
- unsigned CurrentArg,
- bool CompleteExpressionWithCurrentArg = true) {
+static void
+CodeCompleteOverloadResults(Sema &SemaRef, Scope *S,
+ MutableArrayRef<ResultCandidate> Candidates,
+ unsigned CurrentArg, SourceLocation OpenParLoc,
+ bool CompleteExpressionWithCurrentArg = true) {
QualType ParamType;
if (CompleteExpressionWithCurrentArg)
ParamType = getParamType(SemaRef, Candidates, CurrentArg);
@@ -4449,12 +4450,12 @@ static void CodeCompleteOverloadResults(Sema &SemaRef, Scope *S,
SemaRef.CodeCompleteExpression(S, ParamType);
if (!Candidates.empty())
- SemaRef.CodeCompleter->ProcessOverloadCandidates(SemaRef, CurrentArg,
- Candidates.data(),
- Candidates.size());
+ SemaRef.CodeCompleter->ProcessOverloadCandidates(
+ SemaRef, CurrentArg, Candidates.data(), Candidates.size(), OpenParLoc);
}
-void Sema::CodeCompleteCall(Scope *S, Expr *Fn, ArrayRef<Expr *> Args) {
+void Sema::CodeCompleteCall(Scope *S, Expr *Fn, ArrayRef<Expr *> Args,
+ SourceLocation OpenParLoc) {
if (!CodeCompleter)
return;
@@ -4552,12 +4553,13 @@ void Sema::CodeCompleteCall(Scope *S, Expr *Fn, ArrayRef<Expr *> Args) {
}
mergeCandidatesWithResults(*this, Results, CandidateSet, Loc);
- CodeCompleteOverloadResults(*this, S, Results, Args.size(),
+ CodeCompleteOverloadResults(*this, S, Results, Args.size(), OpenParLoc,
!CandidateSet.empty());
}
void Sema::CodeCompleteConstructor(Scope *S, QualType Type, SourceLocation Loc,
- ArrayRef<Expr *> Args) {
+ ArrayRef<Expr *> Args,
+ SourceLocation OpenParLoc) {
if (!CodeCompleter)
return;
@@ -4592,7 +4594,7 @@ void Sema::CodeCompleteConstructor(Scope *S, QualType Type, SourceLocation Loc,
SmallVector<ResultCandidate, 8> Results;
mergeCandidatesWithResults(*this, Results, CandidateSet, Loc);
- CodeCompleteOverloadResults(*this, S, Results, Args.size());
+ CodeCompleteOverloadResults(*this, S, Results, Args.size(), OpenParLoc);
}
void Sema::CodeCompleteInitializer(Scope *S, Decl *D) {
OpenPOWER on IntegriCloud