Skip to content

Commit 2626cd4

Browse files
committed
Add consteval
1 parent 69856ad commit 2626cd4

File tree

5 files changed

+17
-12
lines changed

5 files changed

+17
-12
lines changed

clang/include/clang/Sema/SemaCodeCompletion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class SemaCodeCompletion : public SemaBase {
152152
void CodeCompleteDesignator(const QualType BaseType,
153153
llvm::ArrayRef<Expr *> InitExprs,
154154
const Designation &D);
155-
void CodeCompleteIfConstexpr(Scope *S) const;
155+
void CodeCompleteIfConst(Scope *S) const;
156156
void CodeCompleteAfterIf(Scope *S, bool IsBracedThen);
157157

158158
void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS, bool EnteringContext,

clang/lib/Parse/ParseStmt.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,11 +1555,9 @@ StmtResult Parser::ParseIfStatement(SourceLocation *TrailingElseLoc) {
15551555
}
15561556

15571557
if (Tok.is(tok::code_completion)) {
1558-
if (getLangOpts().CPlusPlus17) {
1559-
cutOffParsing();
1560-
Actions.CodeCompletion().CodeCompleteIfConstexpr(getCurScope());
1561-
return StmtError();
1562-
}
1558+
cutOffParsing();
1559+
Actions.CodeCompletion().CodeCompleteIfConst(getCurScope());
1560+
return StmtError();
15631561
}
15641562
}
15651563
if (!IsConsteval && (NotLocation.isValid() || Tok.isNot(tok::l_paren))) {

clang/lib/Sema/SemaCodeComplete.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6749,12 +6749,17 @@ void SemaCodeCompletion::CodeCompleteInitializer(Scope *S, Decl *D) {
67496749
CodeCompleteExpression(S, Data);
67506750
}
67516751

6752-
void SemaCodeCompletion::CodeCompleteIfConstexpr(Scope *S) const {
6752+
void SemaCodeCompletion::CodeCompleteIfConst(Scope *S) const {
67536753
ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
67546754
CodeCompleter->getCodeCompletionTUInfo(),
67556755
CodeCompletionContext::CCC_Other);
67566756
Results.EnterNewScope();
6757-
Results.AddResult(CodeCompletionResult("constexpr"));
6757+
if (getLangOpts().CPlusPlus17) {
6758+
Results.AddResult(CodeCompletionResult("constexpr"));
6759+
}
6760+
if (getLangOpts().CPlusPlus23) {
6761+
Results.AddResult(CodeCompletionResult("consteval"));
6762+
}
67586763
Results.ExitScope();
67596764

67606765
HandleCodeCompleteResults(&SemaRef, CodeCompleter,
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
void test() {
2+
if c
3+
// RUN: %clang_cc1 -fsyntax-only -std=c++17 -code-completion-at=%s:2:7 %s -o - | FileCheck -check-prefix=CHECK-CXX17 %s
4+
// RUN: %clang_cc1 -fsyntax-only -std=c++23 -code-completion-at=%s:2:7 %s -o - | FileCheck -check-prefix=CHECK-CXX23 %s
5+
// CHECK-CXX17: constexpr
6+
// CHECK-CXX23: consteval

clang/test/CodeCompletion/if-constexpr.cpp

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)