[cfe-commits] r108338 - in /cfe/trunk: lib/Sema/SemaCodeComplete.cpp test/CodeCompletion/Inputs/reserved.h test/CodeCompletion/ordinary-name.c
Douglas Gregor
dgregor at apple.com
Wed Jul 14 10:44:05 PDT 2010
Author: dgregor
Date: Wed Jul 14 12:44:04 2010
New Revision: 108338
URL: http://llvm.org/viewvc/llvm-project?rev=108338&view=rev
Log:
Only filter out names reserved for the implementation (e.g., __blah or
_Foo) from code-completion results when they come from a system
header.
Added:
cfe/trunk/test/CodeCompletion/Inputs/reserved.h
Modified:
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/test/CodeCompletion/ordinary-name.c
Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=108338&r1=108337&r2=108338&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Wed Jul 14 12:44:04 2010
@@ -407,13 +407,16 @@
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;
}
}
Added: cfe/trunk/test/CodeCompletion/Inputs/reserved.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/Inputs/reserved.h?rev=108338&view=auto
==============================================================================
--- cfe/trunk/test/CodeCompletion/Inputs/reserved.h (added)
+++ cfe/trunk/test/CodeCompletion/Inputs/reserved.h Wed Jul 14 12:44:04 2010
@@ -0,0 +1,2 @@
+typedef int _INTEGER_TYPE;
+typedef float FLOATING_TYPE;
Modified: cfe/trunk/test/CodeCompletion/ordinary-name.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/ordinary-name.c?rev=108338&r1=108337&r2=108338&view=diff
==============================================================================
--- cfe/trunk/test/CodeCompletion/ordinary-name.c (original)
+++ cfe/trunk/test/CodeCompletion/ordinary-name.c Wed Jul 14 12:44:04 2010
@@ -1,10 +1,14 @@
+#include <reserved.h>
struct X { int x; };
-
typedef struct t TYPEDEF;
-
+typedef struct t _TYPEDEF;
void foo() {
int y;
- // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:6:9 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+ // RUN: %clang_cc1 -isystem %S/Inputs -fsyntax-only -code-completion-at=%s:6:9 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+ // CHECK-CC1: _Imaginary
+ // CHECK-CC1-NOT: _INTEGER_TYPE;
+ // CHECK-CC1: _TYPEDEF
+ // CHECK-CC1: FLOATING_TYPE
// CHECK-CC1: foo
- // CHECK-CC1: y
// CHECK-CC1: TYPEDEF
+ // CHECK-CC1: y
More information about the cfe-commits
mailing list