clang  8.0.0svn
USRGeneration.h
Go to the documentation of this file.
1 //===- USRGeneration.h - Routines for USR generation ------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_CLANG_INDEX_USRGENERATION_H
11 #define LLVM_CLANG_INDEX_USRGENERATION_H
12 
13 #include "clang/Basic/LLVM.h"
14 #include "llvm/ADT/StringRef.h"
15 
16 namespace clang {
17 class ASTContext;
18 class Decl;
19 class MacroDefinitionRecord;
20 class Module;
21 class SourceLocation;
22 class SourceManager;
23 class QualType;
24 
25 namespace index {
26 
27 static inline StringRef getUSRSpacePrefix() {
28  return "c:";
29 }
30 
31 /// Generate a USR for a Decl, including the USR prefix.
32 /// \returns true if the results should be ignored, false otherwise.
33 bool generateUSRForDecl(const Decl *D, SmallVectorImpl<char> &Buf);
34 
35 /// Generate a USR fragment for an Objective-C class.
36 void generateUSRForObjCClass(StringRef Cls, raw_ostream &OS,
37  StringRef ExtSymbolDefinedIn = "",
38  StringRef CategoryContextExtSymbolDefinedIn = "");
39 
40 /// Generate a USR fragment for an Objective-C class category.
41 void generateUSRForObjCCategory(StringRef Cls, StringRef Cat, raw_ostream &OS,
42  StringRef ClsExtSymbolDefinedIn = "",
43  StringRef CatExtSymbolDefinedIn = "");
44 
45 /// Generate a USR fragment for an Objective-C instance variable. The
46 /// complete USR can be created by concatenating the USR for the
47 /// encompassing class with this USR fragment.
48 void generateUSRForObjCIvar(StringRef Ivar, raw_ostream &OS);
49 
50 /// Generate a USR fragment for an Objective-C method.
51 void generateUSRForObjCMethod(StringRef Sel, bool IsInstanceMethod,
52  raw_ostream &OS);
53 
54 /// Generate a USR fragment for an Objective-C property.
55 void generateUSRForObjCProperty(StringRef Prop, bool isClassProp, raw_ostream &OS);
56 
57 /// Generate a USR fragment for an Objective-C protocol.
58 void generateUSRForObjCProtocol(StringRef Prot, raw_ostream &OS,
59  StringRef ExtSymbolDefinedIn = "");
60 
61 /// Generate USR fragment for a global (non-nested) enum.
62 void generateUSRForGlobalEnum(StringRef EnumName, raw_ostream &OS,
63  StringRef ExtSymbolDefinedIn = "");
64 
65 /// Generate a USR fragment for an enum constant.
66 void generateUSRForEnumConstant(StringRef EnumConstantName, raw_ostream &OS);
67 
68 /// Generate a USR for a macro, including the USR prefix.
69 ///
70 /// \returns true on error, false on success.
73 bool generateUSRForMacro(StringRef MacroName, SourceLocation Loc,
74  const SourceManager &SM, SmallVectorImpl<char> &Buf);
75 
76 /// Generates a USR for a type.
77 ///
78 /// \return true on error, false on success.
80 
81 /// Generate a USR for a module, including the USR prefix.
82 /// \returns true on error, false on success.
83 bool generateFullUSRForModule(const Module *Mod, raw_ostream &OS);
84 
85 /// Generate a USR for a top-level module name, including the USR prefix.
86 /// \returns true on error, false on success.
87 bool generateFullUSRForTopLevelModuleName(StringRef ModName, raw_ostream &OS);
88 
89 /// Generate a USR fragment for a module.
90 /// \returns true on error, false on success.
91 bool generateUSRFragmentForModule(const Module *Mod, raw_ostream &OS);
92 
93 /// Generate a USR fragment for a module name.
94 /// \returns true on error, false on success.
95 bool generateUSRFragmentForModuleName(StringRef ModName, raw_ostream &OS);
96 
97 
98 } // namespace index
99 } // namespace clang
100 
101 #endif // LLVM_CLANG_INDEX_USRGENERATION_H
102 
bool generateUSRForMacro(const MacroDefinitionRecord *MD, const SourceManager &SM, SmallVectorImpl< char > &Buf)
Generate a USR for a macro, including the USR prefix.
A (possibly-)qualified type.
Definition: Type.h:642
void generateUSRForObjCCategory(StringRef Cls, StringRef Cat, raw_ostream &OS, StringRef ClsExtSymbolDefinedIn="", StringRef CatExtSymbolDefinedIn="")
Generate a USR fragment for an Objective-C class category.
bool generateUSRForType(QualType T, ASTContext &Ctx, SmallVectorImpl< char > &Buf)
Generates a USR for a type.
bool generateFullUSRForTopLevelModuleName(StringRef ModName, raw_ostream &OS)
Generate a USR for a top-level module name, including the USR prefix.
bool generateUSRFragmentForModuleName(StringRef ModName, raw_ostream &OS)
Generate a USR fragment for a module name.
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:87
bool generateFullUSRForModule(const Module *Mod, raw_ostream &OS)
Generate a USR for a module, including the USR prefix.
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
void generateUSRForObjCClass(StringRef Cls, raw_ostream &OS, StringRef ExtSymbolDefinedIn="", StringRef CategoryContextExtSymbolDefinedIn="")
Generate a USR fragment for an Objective-C class.
static StringRef getUSRSpacePrefix()
Definition: USRGeneration.h:27
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:154
Record the location of a macro definition.
Describes a module or submodule.
Definition: Module.h:65
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
bool generateUSRFragmentForModule(const Module *Mod, raw_ostream &OS)
Generate a USR fragment for a module.
const SourceManager & SM
Definition: Format.cpp:1490
void generateUSRForObjCMethod(StringRef Sel, bool IsInstanceMethod, raw_ostream &OS)
Generate a USR fragment for an Objective-C method.
Encodes a location in the source.
Dataflow Directional Tag Classes.
void generateUSRForEnumConstant(StringRef EnumConstantName, raw_ostream &OS)
Generate a USR fragment for an enum constant.
void generateUSRForObjCProtocol(StringRef Prot, raw_ostream &OS, StringRef ExtSymbolDefinedIn="")
Generate a USR fragment for an Objective-C protocol.
void generateUSRForObjCIvar(StringRef Ivar, raw_ostream &OS)
Generate a USR fragment for an Objective-C instance variable.
void generateUSRForObjCProperty(StringRef Prop, bool isClassProp, raw_ostream &OS)
Generate a USR fragment for an Objective-C property.
void generateUSRForGlobalEnum(StringRef EnumName, raw_ostream &OS, StringRef ExtSymbolDefinedIn="")
Generate USR fragment for a global (non-nested) enum.
bool generateUSRForDecl(const Decl *D, SmallVectorImpl< char > &Buf)
Generate a USR for a Decl, including the USR prefix.
This class handles loading and caching of source files into memory.