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

2018-11-26 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC347558: [Index] Expose USR generation for types (authored by 
ibiryukov, committed by ).
Herald added a subscriber: arphaman.

Changed prior to commit:
  https://reviews.llvm.org/D52275?vs=166167=175252#toc

Repository:
  rC Clang

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

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
@@ -1105,6 +1105,17 @@
   return false;
 }
 
+bool clang::index::generateUSRForType(QualType T, ASTContext ,
+  SmallVectorImpl ) {
+  if (T.isNull())
+return true;
+  T = T.getCanonicalType();
+
+  USRGenerator UG(, Buf);
+  UG.VisitType(T);
+  return UG.ignoreResults();
+}
+
 bool clang::index::generateFullUSRForModule(const Module *Mod,
 raw_ostream ) {
   if (!Mod->Parent)
Index: include/clang/Index/USRGeneration.h
===
--- include/clang/Index/USRGeneration.h
+++ include/clang/Index/USRGeneration.h
@@ -14,11 +14,13 @@
 #include "llvm/ADT/StringRef.h"
 
 namespace clang {
+class ASTContext;
 class Decl;
 class MacroDefinitionRecord;
 class Module;
 class SourceLocation;
 class SourceManager;
+class QualType;
 
 namespace index {
 
@@ -71,6 +73,11 @@
 bool generateUSRForMacro(StringRef MacroName, SourceLocation Loc,
  const SourceManager , SmallVectorImpl );
 
+/// Generates a USR for a type.
+///
+/// \return true on error, false on success.
+bool generateUSRForType(QualType T, ASTContext , SmallVectorImpl 
);
+
 /// Generate a USR for a module, including the USR prefix.
 /// \returns true on error, false on success.
 bool generateFullUSRForModule(const Module *Mod, raw_ostream );
@@ -87,6 +94,7 @@
 /// \returns true on error, false on success.
 bool generateUSRFragmentForModuleName(StringRef ModName, raw_ostream );
 
+
 } // namespace index
 } // namespace clang
 


Index: lib/Index/USRGeneration.cpp
===
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -1105,6 +1105,17 @@
   return false;
 }
 
+bool clang::index::generateUSRForType(QualType T, ASTContext ,
+  SmallVectorImpl ) {
+  if (T.isNull())
+return true;
+  T = T.getCanonicalType();
+
+  USRGenerator UG(, Buf);
+  UG.VisitType(T);
+  return UG.ignoreResults();
+}
+
 bool clang::index::generateFullUSRForModule(const Module *Mod,
 raw_ostream ) {
   if (!Mod->Parent)
Index: include/clang/Index/USRGeneration.h
===
--- include/clang/Index/USRGeneration.h
+++ include/clang/Index/USRGeneration.h
@@ -14,11 +14,13 @@
 #include "llvm/ADT/StringRef.h"
 
 namespace clang {
+class ASTContext;
 class Decl;
 class MacroDefinitionRecord;
 class Module;
 class SourceLocation;
 class SourceManager;
+class QualType;
 
 namespace index {
 
@@ -71,6 +73,11 @@
 bool generateUSRForMacro(StringRef MacroName, SourceLocation Loc,
  const SourceManager , SmallVectorImpl );
 
+/// Generates a USR for a type.
+///
+/// \return true on error, false on success.
+bool generateUSRForType(QualType T, ASTContext , SmallVectorImpl );
+
 /// Generate a USR for a module, including the USR prefix.
 /// \returns true on error, false on success.
 bool generateFullUSRForModule(const Module *Mod, raw_ostream );
@@ -87,6 +94,7 @@
 /// \returns true on error, false on success.
 bool generateUSRFragmentForModuleName(StringRef ModName, raw_ostream );
 
+
 } // namespace index
 } // namespace clang
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2018-09-19 Thread Ilya Biryukov via Phabricator via cfe-commits
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 , 
SmallVectorImpl ) {
+  if (T.isNull())
+return true;
+  T = T.getCanonicalType();
+
+  USRGenerator UG(, 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 , SmallVectorImpl );
 
+
+/// Generates a USR for a type.
+///
+/// \return true on error, false on success.
+bool generateUSRForType(QualType T, ASTContext , SmallVectorImpl 
);
+
 } // namespace index
 } // namespace clang
 


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 , SmallVectorImpl ) {
+  if (T.isNull())
+return true;
+  T = T.getCanonicalType();
+
+  USRGenerator UG(, 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 , SmallVectorImpl );
 
+
+/// Generates a USR for a type.
+///
+/// \return true on error, false on success.
+bool generateUSRForType(QualType T, ASTContext , SmallVectorImpl );
+
 } // namespace index
 } // namespace clang
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits