Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:36:56

0001 //===- USRGeneration.h - Routines for USR generation ------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLVM_CLANG_INDEX_USRGENERATION_H
0010 #define LLVM_CLANG_INDEX_USRGENERATION_H
0011 
0012 #include "clang/Basic/LLVM.h"
0013 #include "llvm/ADT/StringRef.h"
0014 
0015 namespace clang {
0016 class ASTContext;
0017 class Decl;
0018 class LangOptions;
0019 class MacroDefinitionRecord;
0020 class Module;
0021 class SourceLocation;
0022 class SourceManager;
0023 class QualType;
0024 
0025 namespace index {
0026 
0027 static inline StringRef getUSRSpacePrefix() {
0028   return "c:";
0029 }
0030 
0031 /// Generate a USR for a Decl, including the USR prefix.
0032 /// \returns true if the results should be ignored, false otherwise.
0033 bool generateUSRForDecl(const Decl *D, SmallVectorImpl<char> &Buf);
0034 bool generateUSRForDecl(const Decl *D, SmallVectorImpl<char> &Buf,
0035                         const LangOptions &LangOpts);
0036 
0037 /// Generate a USR fragment for an Objective-C class.
0038 void generateUSRForObjCClass(StringRef Cls, raw_ostream &OS,
0039                              StringRef ExtSymbolDefinedIn = "",
0040                              StringRef CategoryContextExtSymbolDefinedIn = "");
0041 
0042 /// Generate a USR fragment for an Objective-C class category.
0043 void generateUSRForObjCCategory(StringRef Cls, StringRef Cat, raw_ostream &OS,
0044                                 StringRef ClsExtSymbolDefinedIn = "",
0045                                 StringRef CatExtSymbolDefinedIn = "");
0046 
0047 /// Generate a USR fragment for an Objective-C instance variable.  The
0048 /// complete USR can be created by concatenating the USR for the
0049 /// encompassing class with this USR fragment.
0050 void generateUSRForObjCIvar(StringRef Ivar, raw_ostream &OS);
0051 
0052 /// Generate a USR fragment for an Objective-C method.
0053 void generateUSRForObjCMethod(StringRef Sel, bool IsInstanceMethod,
0054                               raw_ostream &OS);
0055 
0056 /// Generate a USR fragment for an Objective-C property.
0057 void generateUSRForObjCProperty(StringRef Prop, bool isClassProp, raw_ostream &OS);
0058 
0059 /// Generate a USR fragment for an Objective-C protocol.
0060 void generateUSRForObjCProtocol(StringRef Prot, raw_ostream &OS,
0061                                 StringRef ExtSymbolDefinedIn = "");
0062 
0063 /// Generate USR fragment for a global (non-nested) enum.
0064 void generateUSRForGlobalEnum(StringRef EnumName, raw_ostream &OS,
0065                               StringRef ExtSymbolDefinedIn = "");
0066 
0067 /// Generate a USR fragment for an enum constant.
0068 void generateUSRForEnumConstant(StringRef EnumConstantName, raw_ostream &OS);
0069 
0070 /// Generate a USR for a macro, including the USR prefix.
0071 ///
0072 /// \returns true on error, false on success.
0073 bool generateUSRForMacro(const MacroDefinitionRecord *MD,
0074                          const SourceManager &SM, SmallVectorImpl<char> &Buf);
0075 bool generateUSRForMacro(StringRef MacroName, SourceLocation Loc,
0076                          const SourceManager &SM, SmallVectorImpl<char> &Buf);
0077 
0078 /// Generates a USR for a type.
0079 ///
0080 /// \return true on error, false on success.
0081 bool generateUSRForType(QualType T, ASTContext &Ctx,
0082                         SmallVectorImpl<char> &Buf);
0083 bool generateUSRForType(QualType T, ASTContext &Ctx, SmallVectorImpl<char> &Buf,
0084                         const LangOptions &LangOpts);
0085 
0086 /// Generate a USR for a module, including the USR prefix.
0087 /// \returns true on error, false on success.
0088 bool generateFullUSRForModule(const Module *Mod, raw_ostream &OS);
0089 
0090 /// Generate a USR for a top-level module name, including the USR prefix.
0091 /// \returns true on error, false on success.
0092 bool generateFullUSRForTopLevelModuleName(StringRef ModName, raw_ostream &OS);
0093 
0094 /// Generate a USR fragment for a module.
0095 /// \returns true on error, false on success.
0096 bool generateUSRFragmentForModule(const Module *Mod, raw_ostream &OS);
0097 
0098 /// Generate a USR fragment for a module name.
0099 /// \returns true on error, false on success.
0100 bool generateUSRFragmentForModuleName(StringRef ModName, raw_ostream &OS);
0101 
0102 
0103 } // namespace index
0104 } // namespace clang
0105 
0106 #endif // LLVM_CLANG_INDEX_USRGENERATION_H
0107