clang 20.0.0git
USRGeneration.h
Go to the documentation of this file.
1//===- USRGeneration.h - Routines for USR generation ------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_CLANG_INDEX_USRGENERATION_H
10#define LLVM_CLANG_INDEX_USRGENERATION_H
11
12#include "clang/Basic/LLVM.h"
13#include "llvm/ADT/StringRef.h"
14
15namespace clang {
16class ASTContext;
17class Decl;
18class LangOptions;
19class MacroDefinitionRecord;
20class Module;
21class SourceLocation;
22class SourceManager;
23class QualType;
24
25namespace index {
26
27static 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.
35 const LangOptions &LangOpts);
36
37/// Generate a USR fragment for an Objective-C class.
38void generateUSRForObjCClass(StringRef Cls, raw_ostream &OS,
39 StringRef ExtSymbolDefinedIn = "",
40 StringRef CategoryContextExtSymbolDefinedIn = "");
41
42/// Generate a USR fragment for an Objective-C class category.
43void generateUSRForObjCCategory(StringRef Cls, StringRef Cat, raw_ostream &OS,
44 StringRef ClsExtSymbolDefinedIn = "",
45 StringRef CatExtSymbolDefinedIn = "");
46
47/// Generate a USR fragment for an Objective-C instance variable. The
48/// complete USR can be created by concatenating the USR for the
49/// encompassing class with this USR fragment.
50void generateUSRForObjCIvar(StringRef Ivar, raw_ostream &OS);
51
52/// Generate a USR fragment for an Objective-C method.
53void generateUSRForObjCMethod(StringRef Sel, bool IsInstanceMethod,
54 raw_ostream &OS);
55
56/// Generate a USR fragment for an Objective-C property.
57void generateUSRForObjCProperty(StringRef Prop, bool isClassProp, raw_ostream &OS);
58
59/// Generate a USR fragment for an Objective-C protocol.
60void generateUSRForObjCProtocol(StringRef Prot, raw_ostream &OS,
61 StringRef ExtSymbolDefinedIn = "");
62
63/// Generate USR fragment for a global (non-nested) enum.
64void generateUSRForGlobalEnum(StringRef EnumName, raw_ostream &OS,
65 StringRef ExtSymbolDefinedIn = "");
66
67/// Generate a USR fragment for an enum constant.
68void generateUSRForEnumConstant(StringRef EnumConstantName, raw_ostream &OS);
69
70/// Generate a USR for a macro, including the USR prefix.
71///
72/// \returns true on error, false on success.
75bool generateUSRForMacro(StringRef MacroName, SourceLocation Loc,
77
78/// Generates a USR for a type.
79///
80/// \return true on error, false on success.
84 const LangOptions &LangOpts);
85
86/// Generate a USR for a module, including the USR prefix.
87/// \returns true on error, false on success.
88bool generateFullUSRForModule(const Module *Mod, raw_ostream &OS);
89
90/// Generate a USR for a top-level module name, including the USR prefix.
91/// \returns true on error, false on success.
92bool generateFullUSRForTopLevelModuleName(StringRef ModName, raw_ostream &OS);
93
94/// Generate a USR fragment for a module.
95/// \returns true on error, false on success.
96bool generateUSRFragmentForModule(const Module *Mod, raw_ostream &OS);
97
98/// Generate a USR fragment for a module name.
99/// \returns true on error, false on success.
100bool generateUSRFragmentForModuleName(StringRef ModName, raw_ostream &OS);
101
102
103} // namespace index
104} // namespace clang
105
106#endif // LLVM_CLANG_INDEX_USRGENERATION_H
107
#define SM(sm)
Definition: Cuda.cpp:84
const Decl * D
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
SourceLocation Loc
Definition: SemaObjC.cpp:759
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:188
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:499
Record the location of a macro definition.
Describes a module or submodule.
Definition: Module.h:115
A (possibly-)qualified type.
Definition: Type.h:929
Encodes a location in the source.
This class handles loading and caching of source files into memory.
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
bool generateFullUSRForTopLevelModuleName(StringRef ModName, raw_ostream &OS)
Generate a USR for a top-level module name, including the USR prefix.
static StringRef getUSRSpacePrefix()
Definition: USRGeneration.h:27
void generateUSRForObjCCategory(StringRef Cls, StringRef Cat, raw_ostream &OS, StringRef ClsExtSymbolDefinedIn="", StringRef CatExtSymbolDefinedIn="")
Generate a USR fragment for an Objective-C class category.
bool generateFullUSRForModule(const Module *Mod, raw_ostream &OS)
Generate a USR for a module, including the USR prefix.
bool generateUSRFragmentForModuleName(StringRef ModName, raw_ostream &OS)
Generate a USR fragment for a module name.
bool generateUSRForMacro(const MacroDefinitionRecord *MD, const SourceManager &SM, SmallVectorImpl< char > &Buf)
Generate a USR for a macro, including the USR prefix.
void generateUSRForObjCProperty(StringRef Prop, bool isClassProp, raw_ostream &OS)
Generate a USR fragment for an Objective-C property.
void generateUSRForEnumConstant(StringRef EnumConstantName, raw_ostream &OS)
Generate a USR fragment for an enum constant.
void generateUSRForObjCIvar(StringRef Ivar, raw_ostream &OS)
Generate a USR fragment for an Objective-C instance variable.
void generateUSRForObjCMethod(StringRef Sel, bool IsInstanceMethod, raw_ostream &OS)
Generate a USR fragment for an Objective-C method.
bool generateUSRForType(QualType T, ASTContext &Ctx, SmallVectorImpl< char > &Buf)
Generates a USR for a type.
void generateUSRForObjCClass(StringRef Cls, raw_ostream &OS, StringRef ExtSymbolDefinedIn="", StringRef CategoryContextExtSymbolDefinedIn="")
Generate a USR fragment for an Objective-C class.
void generateUSRForGlobalEnum(StringRef EnumName, raw_ostream &OS, StringRef ExtSymbolDefinedIn="")
Generate USR fragment for a global (non-nested) enum.
void generateUSRForObjCProtocol(StringRef Prot, raw_ostream &OS, StringRef ExtSymbolDefinedIn="")
Generate a USR fragment for an Objective-C protocol.
bool generateUSRFragmentForModule(const Module *Mod, raw_ostream &OS)
Generate a USR fragment for a module.
bool generateUSRForDecl(const Decl *D, SmallVectorImpl< char > &Buf)
Generate a USR for a Decl, including the USR prefix.
The JSON file list parser is used to communicate input to InstallAPI.
@ Module
Module linkage, which indicates that the entity can be referred to from other translation units withi...
const FunctionProtoType * T