[cfe-commits] r83680 - in /cfe/trunk/lib/Sema: CodeCompleteConsumer.cpp SemaCodeComplete.cpp
Douglas Gregor
dgregor at apple.com
Fri Oct 9 15:16:47 PDT 2009
Author: dgregor
Date: Fri Oct 9 17:16:47 2009
New Revision: 83680
URL: http://llvm.org/viewvc/llvm-project?rev=83680&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
Modified: cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp?rev=83680&r1=83679&r2=83680&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp (original)
+++ cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp Fri Oct 9 17:16:47 2009
@@ -137,6 +137,7 @@
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 @@
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;
}
}
Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=83680&r1=83679&r2=83680&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Fri Oct 9 17:16:47 2009
@@ -198,7 +198,11 @@
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 @@
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.
More information about the cfe-commits
mailing list