clang  6.0.0svn
USRGeneration.h
Go to the documentation of this file.
1 //===- USRGeneration.h - Routines for USR generation ----------------------===//
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 SourceLocation;
20 class SourceManager;
21 
22 namespace index {
23 
24 static inline StringRef getUSRSpacePrefix() {
25  return "c:";
26 }
27 
28 /// \brief Generate a USR for a Decl, including the USR prefix.
29 /// \returns true if the results should be ignored, false otherwise.
30 bool generateUSRForDecl(const Decl *D, SmallVectorImpl<char> &Buf);
31 
32 /// \brief Generate a USR fragment for an Objective-C class.
33 void generateUSRForObjCClass(StringRef Cls, raw_ostream &OS,
34  StringRef ExtSymbolDefinedIn = "",
35  StringRef CategoryContextExtSymbolDefinedIn = "");
36 
37 /// \brief Generate a USR fragment for an Objective-C class category.
38 void generateUSRForObjCCategory(StringRef Cls, StringRef Cat, raw_ostream &OS,
39  StringRef ClsExtSymbolDefinedIn = "",
40  StringRef CatExtSymbolDefinedIn = "");
41 
42 /// \brief Generate a USR fragment for an Objective-C instance variable. The
43 /// complete USR can be created by concatenating the USR for the
44 /// encompassing class with this USR fragment.
45 void generateUSRForObjCIvar(StringRef Ivar, raw_ostream &OS);
46 
47 /// \brief Generate a USR fragment for an Objective-C method.
48 void generateUSRForObjCMethod(StringRef Sel, bool IsInstanceMethod,
49  raw_ostream &OS);
50 
51 /// \brief Generate a USR fragment for an Objective-C property.
52 void generateUSRForObjCProperty(StringRef Prop, bool isClassProp, raw_ostream &OS);
53 
54 /// \brief Generate a USR fragment for an Objective-C protocol.
55 void generateUSRForObjCProtocol(StringRef Prot, raw_ostream &OS,
56  StringRef ExtSymbolDefinedIn = "");
57 
58 /// Generate USR fragment for a global (non-nested) enum.
59 void generateUSRForGlobalEnum(StringRef EnumName, raw_ostream &OS,
60  StringRef ExtSymbolDefinedIn = "");
61 
62 /// Generate a USR fragment for an enum constant.
63 void generateUSRForEnumConstant(StringRef EnumConstantName, raw_ostream &OS);
64 
65 /// \brief Generate a USR for a macro, including the USR prefix.
66 ///
67 /// \returns true on error, false on success.
70 bool generateUSRForMacro(StringRef MacroName, SourceLocation Loc,
71  const SourceManager &SM, SmallVectorImpl<char> &Buf);
72 
73 } // namespace index
74 } // namespace clang
75 
76 #endif // LLVM_CLANG_IDE_USRGENERATION_H
77 
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.
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:81
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:24
Record the location of a macro definition.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
const SourceManager & SM
Definition: Format.cpp:1308
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.