diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-02-01 05:02:47 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-02-01 05:02:47 +0000 |
commit | b223d8c4266655fe7a9491a0aff0263597672823 (patch) | |
tree | bdc4e3242b73289bad16770ac851421bfcc643a6 | |
parent | 8398cbfc73f7ff0a676232db9ea9160bb9dafd8d (diff) |
When providing code completions for a switch over a scoped enumeration
type, be sure to add the qualifier for the enumeration type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149471 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaCodeComplete.cpp | 5 | ||||
-rw-r--r-- | test/Index/complete-enums.cpp | 25 |
2 files changed, 26 insertions, 4 deletions
diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp index f20558c201..0d5413a936 100644 --- a/lib/Sema/SemaCodeComplete.cpp +++ b/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/test/Index/complete-enums.cpp b/test/Index/complete-enums.cpp new file mode 100644 index 0000000000..49a8932587 --- /dev/null +++ b/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) |