[cfe-commits] r149471 - in /cfe/trunk: lib/Sema/SemaCodeComplete.cpp test/Index/complete-enums.cpp
Douglas Gregor
dgregor at apple.com
Tue Jan 31 21:02:47 PST 2012
Author: dgregor
Date: Tue Jan 31 23:02:47 2012
New Revision: 149471
URL: http://llvm.org/viewvc/llvm-project?rev=149471&view=rev
Log:
When providing code completions for a switch over a scoped enumeration
type, be sure to add the qualifier for the enumeration type.
Added:
cfe/trunk/test/Index/complete-enums.cpp (with props)
Modified:
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=149471&r1=149470&r2=149471&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Tue Jan 31 23:02:47 2012
@@ -3637,10 +3637,7 @@
// If there are no prior enumerators in C++, check whether we have to
// qualify the names of the enumerators that we suggest, because they
// may not be visible in this scope.
- Qualifier = getRequiredQualification(Context, CurContext,
- Enum->getDeclContext());
-
- // FIXME: Scoped enums need to start with "EnumDecl" as the context!
+ Qualifier = getRequiredQualification(Context, CurContext, Enum);
}
// Add any enumerators that have not yet been mentioned.
Added: cfe/trunk/test/Index/complete-enums.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-enums.cpp?rev=149471&view=auto
==============================================================================
--- cfe/trunk/test/Index/complete-enums.cpp (added)
+++ cfe/trunk/test/Index/complete-enums.cpp Tue Jan 31 23:02:47 2012
@@ -0,0 +1,25 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+enum class Color {
+ Red = 17,
+ Green,
+ Blue
+};
+int Greeby();
+void f(Color color) {
+ switch (color) {
+ case Color::Green:
+ case Color::Red;
+ }
+}
+
+// RUN: c-index-test -code-completion-at=%s:12:8 -std=c++11 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: EnumConstantDecl:{ResultType Color}{Text Color::}{TypedText Blue} (7)
+// CHECK-CC1: EnumConstantDecl:{ResultType Color}{Text Color::}{TypedText Green} (7)
+// CHECK-CC1: EnumConstantDecl:{ResultType Color}{Text Color::}{TypedText Red} (7)
+
+// RUN: c-index-test -code-completion-at=%s:13:8 -std=c++11 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: EnumConstantDecl:{ResultType Color}{Text Color::}{TypedText Blue} (7)
+// CHECK-CC2-NOT: Green
+// CHECK-CC2: EnumConstantDecl:{ResultType Color}{Text Color::}{TypedText Red} (7)
Propchange: cfe/trunk/test/Index/complete-enums.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cfe/trunk/test/Index/complete-enums.cpp
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cfe/trunk/test/Index/complete-enums.cpp
------------------------------------------------------------------------------
svn:mime-type = text/plain
More information about the cfe-commits
mailing list