=?utf-8?b?5YWo5Y2T?= <[email protected]>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/[email protected]>


https://github.com/quanzhuo updated 
https://github.com/llvm/llvm-project/pull/165550

>From 90f7d02220640263a793b03d8ad01f18ecfc73b3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=85=A8=E5=8D=93?= <[email protected]>
Date: Wed, 29 Oct 2025 20:40:01 +0800
Subject: [PATCH 1/2] [clang] Add code completion for #embed directive in C23
 mode

---
 clang/lib/Sema/SemaCodeComplete.cpp | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/clang/lib/Sema/SemaCodeComplete.cpp 
b/clang/lib/Sema/SemaCodeComplete.cpp
index 0514d1033f74f..2feaaa4a9577e 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -10208,6 +10208,24 @@ void 
SemaCodeCompletion::CodeCompletePreprocessorDirective(bool InConditional) {
   Builder.AddPlaceholderChunk("message");
   Results.AddResult(Builder.TakeString());
 
+  if (getLangOpts().C23) {
+    // #embed "header"
+    Builder.AddTypedTextChunk("embed");
+    Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+    Builder.AddTextChunk("\"");
+    Builder.AddPlaceholderChunk("header");
+    Builder.AddTextChunk("\"");
+    Results.AddResult(Builder.TakeString());
+
+    // #embed <header>
+    Builder.AddTypedTextChunk("embed");
+    Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+    Builder.AddTextChunk("<");
+    Builder.AddPlaceholderChunk("header");
+    Builder.AddTextChunk(">");
+    Results.AddResult(Builder.TakeString());
+  }
+
   // Note: #ident and #sccs are such crazy anachronisms that we don't provide
   // completions for them. And __include_macros is a Clang-internal extension
   // that we don't want to encourage anyone to use.

>From 51d1802f66847c2b84868aed4d43b2ad3fe175d0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=85=A8=E5=8D=93?= <[email protected]>
Date: Fri, 31 Oct 2025 16:23:21 +0800
Subject: [PATCH 2/2] [clang] Update #embed directive completion placeholders
 and add test

---
 clang/lib/Sema/SemaCodeComplete.cpp      | 8 ++++----
 clang/test/Index/complete-preprocessor.m | 5 +++++
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Sema/SemaCodeComplete.cpp 
b/clang/lib/Sema/SemaCodeComplete.cpp
index 2feaaa4a9577e..aa93507ab5c30 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -10209,19 +10209,19 @@ void 
SemaCodeCompletion::CodeCompletePreprocessorDirective(bool InConditional) {
   Results.AddResult(Builder.TakeString());
 
   if (getLangOpts().C23) {
-    // #embed "header"
+    // #embed "file"
     Builder.AddTypedTextChunk("embed");
     Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
     Builder.AddTextChunk("\"");
-    Builder.AddPlaceholderChunk("header");
+    Builder.AddPlaceholderChunk("file");
     Builder.AddTextChunk("\"");
     Results.AddResult(Builder.TakeString());
 
-    // #embed <header>
+    // #embed <file>
     Builder.AddTypedTextChunk("embed");
     Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
     Builder.AddTextChunk("<");
-    Builder.AddPlaceholderChunk("header");
+    Builder.AddPlaceholderChunk("file");
     Builder.AddTextChunk(">");
     Results.AddResult(Builder.TakeString());
   }
diff --git a/clang/test/Index/complete-preprocessor.m 
b/clang/test/Index/complete-preprocessor.m
index 1cc2f32b7efa6..bd90a796240c4 100644
--- a/clang/test/Index/complete-preprocessor.m
+++ b/clang/test/Index/complete-preprocessor.m
@@ -80,3 +80,8 @@
 // RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test 
-code-completion-at=%s:9:8 %s | FileCheck -check-prefix=CHECK-CC3 %s
 // RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test 
-code-completion-at=%s:11:5 %s | FileCheck -check-prefix=CHECK-CC4 %s
 // RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test 
-code-completion-at=%s:14:5 %s | FileCheck -check-prefix=CHECK-CC5 %s
+
+// Test #embed completion in C23 mode
+// RUN: c-index-test -code-completion-at=%s:4:2 %s -std=c23 | FileCheck 
-check-prefix=CHECK-EMBED %s
+// CHECK-EMBED: NotImplemented:{TypedText embed}{HorizontalSpace  }{Text 
"}{Placeholder file}{Text "} (40)
+// CHECK-EMBED: NotImplemented:{TypedText embed}{HorizontalSpace  }{Text 
<}{Placeholder file}{Text >} (40)

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to