[PATCH] D139178: [libclang] Have clang_getCursorSpelling() return the string for a CXCursor_IntegerLiteral cursor

William Hsu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 2 01:50:39 PST 2022


GrislyMe created this revision.
GrislyMe added reviewers: abdulras, gribozavr.
GrislyMe added a project: clang.
Herald added a subscriber: arphaman.
Herald added a project: All.
GrislyMe requested review of this revision.
Herald added a subscriber: cfe-commits.

Return the IntegerLiteral cursor value in a string.
The value will be represented in base-10 and unsigned.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139178

Files:
  clang/tools/libclang/CIndex.cpp


Index: clang/tools/libclang/CIndex.cpp
===================================================================
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -4937,6 +4937,13 @@
       SLit->outputString(OS);
       return cxstring::createDup(OS.str());
     }
+    if (C.kind == CXCursor_IntegerLiteral) {
+      SmallString<64> Buf;
+      if (const IntegerLiteral *ILit = dyn_cast<IntegerLiteral>(E)) {
+        ILit->getValue().toString(Buf, 10, true);
+        return cxstring::createDup(Buf);
+      }
+    }
 
     const Decl *D = getDeclFromExpr(getCursorExpr(C));
     if (D)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139178.479529.patch
Type: text/x-patch
Size: 609 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221202/9e99f344/attachment.bin>


More information about the cfe-commits mailing list