[clang] [clang] Fix PredefinedSugarType reported as CXType_Unexposed (PR #202209)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 7 08:18:18 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Yexuan Xiao (YexuanXiao)
<details>
<summary>Changes</summary>
Fix #<!-- -->192268.
---
Full diff: https://github.com/llvm/llvm-project/pull/202209.diff
4 Files Affected:
- (modified) clang/docs/ReleaseNotes.rst (+3)
- (modified) clang/include/clang-c/Index.h (+3-1)
- (added) clang/test/Index/print-type-predefined-sugar.cpp (+12)
- (modified) clang/tools/libclang/CXType.cpp (+2)
``````````diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f97e90634396a..d565f78f8d911 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -915,6 +915,9 @@ libclang
- Fix crash in clang_getBinaryOperatorKindSpelling and clang_getUnaryOperatorKindSpelling
- The clang_Module_getASTFile API is deprecated and now always returns nullptr
- The clang_Cursor_getCommentRange API will now return a comment range for macro definitions that have documentation comments.
+- Added CXType_PredefinedSugar for __ptrdiff_t, __size_t, and
+ __signed_size_t types, which are no longer exposed as
+ CXType_Unexposed.
Code Completion
---------------
diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index 119bd68ff9814..8427236e0b444 100644
--- a/clang/include/clang-c/Index.h
+++ b/clang/include/clang-c/Index.h
@@ -3043,7 +3043,9 @@ enum CXTypeKind {
/* HLSL Types */
CXType_HLSLResource = 179,
CXType_HLSLAttributedResource = 180,
- CXType_HLSLInlineSpirv = 181
+ CXType_HLSLInlineSpirv = 181,
+
+ CXType_PredefinedSugar = 182
};
/**
diff --git a/clang/test/Index/print-type-predefined-sugar.cpp b/clang/test/Index/print-type-predefined-sugar.cpp
new file mode 100644
index 0000000000000..6394186e14b9d
--- /dev/null
+++ b/clang/test/Index/print-type-predefined-sugar.cpp
@@ -0,0 +1,12 @@
+// RUN: c-index-test -test-print-type %s -target x86_64-pc-linux-gnu -std=c++23 | FileCheck %s
+
+typedef struct { void **unused; } S;
+void test(S *x, S *y) {
+ (void)(x - y);
+ (void)sizeof(*x);
+ (void)0z;
+}
+
+// CHECK: BinaryOperator=- [type=__ptrdiff_t] [typekind=PredefinedSugar] [canonicaltype=long] [canonicaltypekind=Long] [isPOD=1]
+// CHECK: UnaryExpr= [type=__size_t] [typekind=PredefinedSugar] [canonicaltype=unsigned long] [canonicaltypekind=ULong] [isPOD=1]
+// CHECK: IntegerLiteral= [type=__signed_size_t] [typekind=PredefinedSugar] [canonicaltype=long] [canonicaltypekind=Long] [isPOD=1]
diff --git a/clang/tools/libclang/CXType.cpp b/clang/tools/libclang/CXType.cpp
index 3feb56334d79c..0063939dec423 100644
--- a/clang/tools/libclang/CXType.cpp
+++ b/clang/tools/libclang/CXType.cpp
@@ -122,6 +122,7 @@ static CXTypeKind GetTypeKind(QualType T) {
TKCASE(Attributed);
TKCASE(BTFTagAttributed);
TKCASE(Atomic);
+ TKCASE(PredefinedSugar);
default:
return CXType_Unexposed;
}
@@ -651,6 +652,7 @@ CXString clang_getTypeKindSpelling(enum CXTypeKind K) {
TKIND(BTFTagAttributed);
TKIND(HLSLAttributedResource);
TKIND(HLSLInlineSpirv);
+ TKIND(PredefinedSugar);
TKIND(BFloat16);
#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) TKIND(Id);
#include "clang/Basic/OpenCLImageTypes.def"
``````````
</details>
https://github.com/llvm/llvm-project/pull/202209
More information about the cfe-commits
mailing list