[PATCH] D52275: [Index] Expose USR generation for types

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 19 12:16:54 PDT 2018


ilya-biryukov created this revision.
ilya-biryukov added reviewers: sammccall, ioeric.
Herald added a subscriber: kadircet.

Used in clangd.


Repository:
  rC Clang

https://reviews.llvm.org/D52275

Files:
  include/clang/Index/USRGeneration.h
  lib/Index/USRGeneration.cpp


Index: lib/Index/USRGeneration.cpp
===================================================================
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -1094,3 +1094,13 @@
   Out << MacroName;
   return false;
 }
+
+bool clang::index::generateUSRForType(QualType T, ASTContext &Ctx, SmallVectorImpl<char> &Buf) {
+  if (T.isNull())
+    return true;
+  T = T.getCanonicalType();
+
+  USRGenerator UG(&Ctx, Buf);
+  UG.VisitType(T);
+  return UG.ignoreResults();
+}
Index: include/clang/Index/USRGeneration.h
===================================================================
--- include/clang/Index/USRGeneration.h
+++ include/clang/Index/USRGeneration.h
@@ -14,10 +14,12 @@
 #include "llvm/ADT/StringRef.h"
 
 namespace clang {
+class ASTContext;
 class Decl;
 class MacroDefinitionRecord;
 class SourceLocation;
 class SourceManager;
+class QualType;
 
 namespace index {
 
@@ -70,6 +72,12 @@
 bool generateUSRForMacro(StringRef MacroName, SourceLocation Loc,
                          const SourceManager &SM, SmallVectorImpl<char> &Buf);
 
+
+/// Generates a USR for a type.
+///
+/// \return true on error, false on success.
+bool generateUSRForType(QualType T, ASTContext &Ctx, SmallVectorImpl<char> &Buf);
+
 } // namespace index
 } // namespace clang
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52275.166167.patch
Type: text/x-patch
Size: 1280 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180919/1cf7bae7/attachment-0001.bin>


More information about the cfe-commits mailing list