clang 23.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_UNIFIEDSYMBOLRESOLUTION_USRGENERATION_H
10#define LLVM_CLANG_UNIFIEDSYMBOLRESOLUTION_USRGENERATION_H
11
12#include "clang/Basic/LLVM.h"
13#include "llvm/ADT/StringRef.h"
14
15namespace clang {
16class ASTContext;
17class Decl;
18class LangOptions;
20class Module;
21class SourceLocation;
22class SourceManager;
23class QualType;
24
25namespace index {
26
27static inline StringRef getUSRSpacePrefix() { return "c:"; }
28
29/// Generate a USR for a Decl, including the USR prefix.
30/// \returns true if the results should be ignored, false otherwise.
33 const LangOptions &LangOpts);
34
35/// Generate a USR fragment for an Objective-C class.
36void generateUSRForObjCClass(StringRef Cls, raw_ostream &OS,
37 StringRef ExtSymbolDefinedIn = "",
38 StringRef CategoryContextExtSymbolDefinedIn = "");
39
40/// Generate a USR fragment for an Objective-C class category.
41void 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.
48void generateUSRForObjCIvar(StringRef Ivar, raw_ostream &OS);
49
50/// Generate a USR fragment for an Objective-C method.
51void generateUSRForObjCMethod(StringRef Sel, bool IsInstanceMethod,
52 raw_ostream &OS);
53
54/// Generate a USR fragment for an Objective-C property.
55void generateUSRForObjCProperty(StringRef Prop, bool isClassProp,
56 raw_ostream &OS);
57
58/// Generate a USR fragment for an Objective-C protocol.
59void generateUSRForObjCProtocol(StringRef Prot, raw_ostream &OS,
60 StringRef ExtSymbolDefinedIn = "");
61
62/// Generate USR fragment for a global (non-nested) enum.
63void generateUSRForGlobalEnum(StringRef EnumName, raw_ostream &OS,
64 StringRef ExtSymbolDefinedIn = "");
65
66/// Generate a USR fragment for an enum constant.
67void generateUSRForEnumConstant(StringRef EnumConstantName, raw_ostream &OS);
68
69/// Generate a USR for a macro, including the USR prefix.
70///
71/// \returns true on error, false on success.
74bool generateUSRForMacro(StringRef MacroName, SourceLocation Loc,
76
77/// Generates a USR for a type.
78///
79/// \return true on error, false on success.
83 const LangOptions &LangOpts);
84
85/// Generate a USR for a module, including the USR prefix.
86/// \returns true on error, false on success.
87bool generateFullUSRForModule(const Module *Mod, raw_ostream &OS);
88
89/// Generate a USR for a top-level module name, including the USR prefix.
90/// \returns true on error, false on success.
91bool generateFullUSRForTopLevelModuleName(StringRef ModName, raw_ostream &OS);
92
93/// Generate a USR fragment for a module.
94/// \returns true on error, false on success.
95bool generateUSRFragmentForModule(const Module *Mod, raw_ostream &OS);
96
97/// Generate a USR fragment for a module name.
98/// \returns true on error, false on success.
99bool generateUSRFragmentForModuleName(StringRef ModName, raw_ostream &OS);
100
101} // namespace index
102} // namespace clang
103
104#endif // LLVM_CLANG_UNIFIEDSYMBOLRESOLUTION_USRGENERATION_H
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
#define SM(sm)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:226
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...
Record the location of a macro definition.
Describes a module or submodule.
Definition Module.h:246
A (possibly-)qualified type.
Definition TypeBase.h:937
Encodes a location in the source.
This class handles loading and caching of source files into memory.
bool generateFullUSRForTopLevelModuleName(StringRef ModName, raw_ostream &OS)
Generate a USR for a top-level module name, including the USR prefix.
static StringRef getUSRSpacePrefix()
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.