[clang] [Sema] Add code completion for if constexpr and consteval (PR #124315)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 7 00:23:15 PST 2025
================
@@ -6749,6 +6749,55 @@ void SemaCodeCompletion::CodeCompleteInitializer(Scope *S, Decl *D) {
CodeCompleteExpression(S, Data);
}
+void SemaCodeCompletion::CodeCompleteIfConst(Scope *S,
+ bool AfterExclaim) const {
+ ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
+ CodeCompleter->getCodeCompletionTUInfo(),
+ CodeCompletionContext::CCC_Other);
+ CodeCompletionBuilder Builder(Results.getAllocator(),
+ Results.getCodeCompletionTUInfo());
+ Results.EnterNewScope();
+ if (getLangOpts().CPlusPlus17) {
+ if (!AfterExclaim) {
+ if (Results.includeCodePatterns()) {
+ Builder.AddTypedTextChunk("constexpr");
+ Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+ Builder.AddChunk(CodeCompletionString::CK_LeftParen);
+ Builder.AddPlaceholderChunk("condition");
+ Builder.AddChunk(CodeCompletionString::CK_RightParen);
+ Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+ Builder.AddChunk(CodeCompletionString::CK_LeftBrace);
+ Builder.AddChunk(CodeCompletionString::CK_VerticalSpace);
+ Builder.AddPlaceholderChunk("statements");
+ Builder.AddChunk(CodeCompletionString::CK_VerticalSpace);
+ Builder.AddChunk(CodeCompletionString::CK_RightBrace);
+ Results.AddResult({Builder.TakeString()});
+ } else {
+ Results.AddResult({"constexpr"});
+ }
+ }
+ }
----------------
zyn0217 wrote:
They should be tested
https://github.com/llvm/llvm-project/pull/124315
More information about the cfe-commits
mailing list