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

source code of clang/include/clang/Index/USRGeneration.h