Only filter out names reserved for the implementation (e.g., __blah or

_Foo) from code-completion results when they come from a system
header.

llvm-svn: 108338
This commit is contained in:
Douglas Gregor
2010-07-14 17:44:04 +00:00
parent 042523340b
commit 9f1570d993
3 changed files with 15 additions and 6 deletions

View File

@@ -407,13 +407,16 @@ bool ResultBuilder::isInterestingDecl(NamedDecl *ND,
return false;
// Filter out names reserved for the implementation (C99 7.1.3,
// C++ [lib.global.names]). Users don't need to see those.
// C++ [lib.global.names]) if they come from a system header.
//
// FIXME: Add predicate for this.
if (Id->getLength() >= 2) {
const char *Name = Id->getNameStart();
if (Name[0] == '_' &&
(Name[1] == '_' || (Name[1] >= 'A' && Name[1] <= 'Z')))
(Name[1] == '_' || (Name[1] >= 'A' && Name[1] <= 'Z')) &&
(ND->getLocation().isInvalid() ||
SemaRef.SourceMgr.isInSystemHeader(
SemaRef.SourceMgr.getSpellingLoc(ND->getLocation()))))
return false;
}
}