anderslanglands updated this revision to Diff 476261.
anderslanglands added a comment.

Added release note, incorporated other review notes


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137818/new/

https://reviews.llvm.org/D137818

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang-c/Index.h
  clang/test/Index/print-type.cpp
  clang/tools/libclang/CXType.cpp
  clang/tools/libclang/libclang.map

Index: clang/tools/libclang/libclang.map
===================================================================
--- clang/tools/libclang/libclang.map
+++ clang/tools/libclang/libclang.map
@@ -164,6 +164,7 @@
     clang_Type_getObjCProtocolDecl;
     clang_Type_getObjCTypeArg;
     clang_Type_getOffsetOf;
+    clang_Type_getReplacementType;
     clang_Type_getSizeOf;
     clang_Type_getTemplateArgumentAsType;
     clang_Type_getValueType;
Index: clang/tools/libclang/CXType.cpp
===================================================================
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -118,13 +118,13 @@
     TKCASE(Attributed);
     TKCASE(BTFTagAttributed);
     TKCASE(Atomic);
+    TKCASE(SubstTemplateTypeParm);
     default:
       return CXType_Unexposed;
   }
 #undef TKCASE
 }
 
-
 CXType cxtype::MakeCXType(QualType T, CXTranslationUnit TU) {
   CXTypeKind TK = CXType_Invalid;
 
@@ -635,6 +635,7 @@
     TKIND(OCLQueue);
     TKIND(OCLReserveID);
     TKIND(Atomic);
+    TKIND(SubstTemplateTypeParm);
   }
 #undef TKIND
   return cxstring::createRef(s);
@@ -1355,3 +1356,11 @@
   const auto *AT = T->castAs<AtomicType>();
   return MakeCXType(AT->getValueType(), GetTU(CT));
 }
+
+CXType clang_Type_getReplacementType(CXType CT) {
+  QualType T = GetQualType(CT);
+
+  const auto *ST =
+      !T.isNull() ? T->getAs<SubstTemplateTypeParmType>() : nullptr;
+  return MakeCXType(ST ? ST->getReplacementType() : QualType(), GetTU(CT));
+}
Index: clang/test/Index/print-type.cpp
===================================================================
--- clang/test/Index/print-type.cpp
+++ clang/test/Index/print-type.cpp
@@ -171,7 +171,7 @@
 // CHECK: VarDecl=autoI:54:6 (Definition) [type=int] [typekind=Auto] [canonicaltype=int] [canonicaltypekind=Int] [isPOD=1]
 // CHECK: IntegerLiteral= [type=int] [typekind=Int] [isPOD=1]
 // CHECK: VarDecl=autoTbar:55:6 (Definition) [type=int] [typekind=Auto] [canonicaltype=int] [canonicaltypekind=Int] [isPOD=1]
-// CHECK: CallExpr=tbar:36:3 [type=int] [typekind=Unexposed] [canonicaltype=int] [canonicaltypekind=Int] [args= [int] [Int]] [isPOD=1]
+// CHECK: CallExpr=tbar:36:3 [type=int] [typekind=SubstTemplateTypeParm] [canonicaltype=int] [canonicaltypekind=Int] [args= [int] [Int]] [isPOD=1]
 // CHECK: UnexposedExpr=tbar:36:3 [type=int (*)(int)] [typekind=Pointer] [canonicaltype=int (*)(int)] [canonicaltypekind=Pointer] [isPOD=1] [pointeetype=int (int)] [pointeekind=FunctionProto]
 // CHECK: DeclRefExpr=tbar:36:3 RefName=[55:17 - 55:21] RefName=[55:21 - 55:26] [type=int (int)] [typekind=FunctionProto] [canonicaltype=int (int)] [canonicaltypekind=FunctionProto] [isPOD=0]
 // CHECK: IntegerLiteral= [type=int] [typekind=Int] [isPOD=1]
Index: clang/include/clang-c/Index.h
===================================================================
--- clang/include/clang-c/Index.h
+++ clang/include/clang-c/Index.h
@@ -2789,7 +2789,9 @@
 
   CXType_ExtVector = 176,
   CXType_Atomic = 177,
-  CXType_BTFTagAttributed = 178
+  CXType_BTFTagAttributed = 178,
+  /* Represents a type that has been substituted for a template type parameter. */
+  CXType_SubstTemplateTypeParm = 179
 };
 
 /**
@@ -3447,6 +3449,13 @@
  */
 CINDEX_LINKAGE CXType clang_Type_getValueType(CXType CT);
 
+/**
+ * Gets the replacement type for a SubstTemplateTypeParm type.
+ *
+ * If any other type kind is passed in, an invalid type is returned.
+ */
+CINDEX_LINKAGE CXType clang_Type_getReplacementType(CXType CT);
+
 /**
  * Return the offset of the field represented by the Cursor.
  *
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -795,6 +795,10 @@
   ``clang_Cursor_getTemplateArgumentType``, ``clang_Cursor_getTemplateArgumentValue`` and 
   ``clang_Cursor_getTemplateArgumentUnsignedValue`` now work on struct, class,
   and partial template specialization cursors in addition to function cursors.
+- Added ``CXType_SubstTemplateTypeParm`` to ``CXTypeKind``, which identifies a type that 
+  is a replacement for a template type parameter (previously reported a ``CXType_Unexposed``).
+- Introduced the new function ``clang_Type_getReplacementType`` which gets the type replacing
+  the template type parameter when type kind is ``CXType_SubstTemplateTypeParm``.
 
 Static Analyzer
 ---------------
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to