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