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 Decl;
18 class MacroDefinitionRecord;
19 class Module;
20 class SourceLocation;
21 class SourceManager;
22 
23 namespace index {
24 
25 static inline StringRef getUSRSpacePrefix() {
26  return "c:";
27 }
28 
29 /// Generate a USR for a Decl, including the USR prefix.
30 /// \returns true if the results should be ignored, false otherwise.
31 bool generateUSRForDecl(const Decl *D, SmallVectorImpl<char> &Buf);
32 
33 /// Generate a USR fragment for an Objective-C class.
34 void generateUSRForObjCClass(StringRef Cls, raw_ostream &OS,
35  StringRef ExtSymbolDefinedIn = "",
36  StringRef CategoryContextExtSymbolDefinedIn = "");
37 
38 /// Generate a USR fragment for an Objective-C class category.
39 void generateUSRForObjCCategory(StringRef Cls, StringRef Cat, raw_ostream &OS,
40  StringRef ClsExtSymbolDefinedIn = "",
41  StringRef CatExtSymbolDefinedIn = "");
42 
43 /// Generate a USR fragment for an Objective-C instance variable. The
44 /// complete USR can be created by concatenating the USR for the
45 /// encompassing class with this USR fragment.
46 void generateUSRForObjCIvar(StringRef Ivar, raw_ostream &OS);
47 
48 /// Generate a USR fragment for an Objective-C method.
49 void generateUSRForObjCMethod(StringRef Sel, bool IsInstanceMethod,
50  raw_ostream &OS);
51 
52 /// Generate a USR fragment for an Objective-C property.
53 void generateUSRForObjCProperty(StringRef Prop, bool isClassProp, raw_ostream &OS);
54 
55 /// Generate a USR fragment for an Objective-C protocol.
56 void generateUSRForObjCProtocol(StringRef Prot, raw_ostream &OS,
57  StringRef ExtSymbolDefinedIn = "");
58 
59 /// Generate USR fragment for a global (non-nested) enum.
60 void generateUSRForGlobalEnum(StringRef EnumName, raw_ostream &OS,
61  StringRef ExtSymbolDefinedIn = "");
62 
63 /// Generate a USR fragment for an enum constant.
64 void generateUSRForEnumConstant(StringRef EnumConstantName, raw_ostream &OS);
65 
66 /// Generate a USR for a macro, including the USR prefix.
67 ///
68 /// \returns true on error, false on success.
71 bool generateUSRForMacro(StringRef MacroName, SourceLocation Loc,
72  const SourceManager &SM, SmallVectorImpl<char> &Buf);
73 
74 /// Generate a USR for a module, including the USR prefix.
75 /// \returns true on error, false on success.
76 bool generateFullUSRForModule(const Module *Mod, raw_ostream &OS);
77 
78 /// Generate a USR for a top-level module name, including the USR prefix.
79 /// \returns true on error, false on success.
80 bool generateFullUSRForTopLevelModuleName(StringRef ModName, raw_ostream &OS);
81 
82 /// Generate a USR fragment for a module.
83 /// \returns true on error, false on success.
84 bool generateUSRFragmentForModule(const Module *Mod, raw_ostream &OS);
85 
86 /// Generate a USR fragment for a module name.
87 /// \returns true on error, false on success.
88 bool generateUSRFragmentForModuleName(StringRef ModName, raw_ostream &OS);
89 
90 } // namespace index
91 } // namespace clang
92 
93 #endif // LLVM_CLANG_INDEX_USRGENERATION_H
94 
bool generateUSRForMacro(const MacroDefinitionRecord *MD, const SourceManager &SM, SmallVectorImpl< char > &Buf)
Generate a USR for a macro, including the USR prefix.
void generateUSRForObjCCategory(StringRef Cls, StringRef Cat, raw_ostream &OS, StringRef ClsExtSymbolDefinedIn="", StringRef CatExtSymbolDefinedIn="")
Generate a USR fragment for an Objective-C class category.
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:25
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:1472
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.