summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-02-01 05:02:47 +0000
committerDouglas Gregor <dgregor@apple.com>2012-02-01 05:02:47 +0000
commitd3cebdba411bb55d08d687fdc181b21403beb629 (patch)
tree3b2611cb8a5f750aae3e5b113e5c0090ae14064c
parent17c981a45b605af8d71041cd4435fbafa17aadad (diff)
downloadbcm5719-llvm-d3cebdba411bb55d08d687fdc181b21403beb629.tar.gz
bcm5719-llvm-d3cebdba411bb55d08d687fdc181b21403beb629.zip
When providing code completions for a switch over a scoped enumeration
type, be sure to add the qualifier for the enumeration type. llvm-svn: 149471
-rw-r--r--clang/lib/Sema/SemaCodeComplete.cpp5
-rw-r--r--clang/test/Index/complete-enums.cpp25
2 files changed, 26 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp
index f20558c201f..0d5413a936b 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -3637,10 +3637,7 @@ void Sema::CodeCompleteCase(Scope *S) {
// 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.
diff --git a/clang/test/Index/complete-enums.cpp b/clang/test/Index/complete-enums.cpp
new file mode 100644
index 00000000000..49a89325877
--- /dev/null
+++ b/clang/test/Index/complete-enums.cpp
@@ -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)
OpenPOWER on IntegriCloud