summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-10-09 22:16:47 +0000
committerDouglas Gregor <dgregor@apple.com>2009-10-09 22:16:47 +0000
commit58acf32af26433e367384852e3431acd7ebd92bd (patch)
tree7298be6ab49008cc173bf107825c3b605080c277
parent82a108b4ed2c726bafcbd6059ee4f207bcd29ce3 (diff)
downloadbcm5719-llvm-58acf32af26433e367384852e3431acd7ebd92bd.tar.gz
bcm5719-llvm-58acf32af26433e367384852e3431acd7ebd92bd.zip
Minor tweaks for code-completion:
- Filter out unnamed declarations - Filter out declarations whose names are reserved for the implementation (e.g., __bar, _Foo) - Place OVERLOAD: or COMPLETION: at the beginning of each code-completion result, so we can easily separate them from other compilation results. llvm-svn: 83680
-rw-r--r--clang/lib/Sema/CodeCompleteConsumer.cpp3
-rw-r--r--clang/lib/Sema/SemaCodeComplete.cpp16
2 files changed, 15 insertions, 4 deletions
diff --git a/clang/lib/Sema/CodeCompleteConsumer.cpp b/clang/lib/Sema/CodeCompleteConsumer.cpp
index a8988a6ba83..c78ab5b3e95 100644
--- a/clang/lib/Sema/CodeCompleteConsumer.cpp
+++ b/clang/lib/Sema/CodeCompleteConsumer.cpp
@@ -137,6 +137,7 @@ PrintingCodeCompleteConsumer::ProcessCodeCompleteResults(Result *Results,
unsigned NumResults) {
// Print the results.
for (unsigned I = 0; I != NumResults; ++I) {
+ OS << "COMPLETION: ";
switch (Results[I].Kind) {
case Result::RK_Declaration:
OS << Results[I].Declaration->getNameAsString() << " : "
@@ -171,7 +172,7 @@ PrintingCodeCompleteConsumer::ProcessOverloadCandidates(unsigned CurrentArg,
for (unsigned I = 0; I != NumCandidates; ++I) {
if (CodeCompletionString *CCS
= Candidates[I].CreateSignatureString(CurrentArg, SemaRef)) {
- OS << CCS->getAsString() << "\n";
+ OS << "OVERLOAD: " << CCS->getAsString() << "\n";
delete CCS;
}
}
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp
index d7697a7333a..3981b8d22fa 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -198,7 +198,11 @@ void ResultBuilder::MaybeAddResult(Result R, DeclContext *CurContext) {
Results.push_back(R);
return;
}
-
+
+ // Skip unnamed entities.
+ if (!R.Declaration->getDeclName())
+ return;
+
// Look through using declarations.
if (UsingDecl *Using = dyn_cast<UsingDecl>(R.Declaration))
MaybeAddResult(Result(Using->getTargetDecl(), R.Rank, R.Qualifier),
@@ -229,8 +233,14 @@ void ResultBuilder::MaybeAddResult(Result R, DeclContext *CurContext) {
if (Id->isStr("__va_list_tag") || Id->isStr("__builtin_va_list"))
return;
- // FIXME: Should we filter out other names in the implementation's
- // namespace, e.g., those containing a __ or that start with _[A-Z]?
+ // Filter out names reserved for the implementation (C99 7.1.3,
+ // C++ [lib.global.names]). Users don't need to see those.
+ if (Id->getLength() >= 2) {
+ const char *Name = Id->getName();
+ if (Name[0] == '_' &&
+ (Name[1] == '_' || (Name[1] >= 'A' && Name[1] <= 'Z')))
+ return;
+ }
}
// C++ constructors are never found by name lookup.
OpenPOWER on IntegriCloud