[clang] Fix PredefinedSugarType reported as CXType_Unexposed#202209
Open
YexuanXiao wants to merge 2 commits into
Open
[clang] Fix PredefinedSugarType reported as CXType_Unexposed#202209YexuanXiao wants to merge 2 commits into
YexuanXiao wants to merge 2 commits into
Conversation
|
@llvm/pr-subscribers-clang Author: Yexuan Xiao (YexuanXiao) ChangesFix #192268. Full diff: https://github.com/llvm/llvm-project/pull/202209.diff 4 Files Affected:
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"
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #192268.