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
29static inline StringRef getUSRSpacePrefix() {
30 return "c:";
31}
32
33/// Generate a USR for a Decl, including the USR prefix.
34/// \returns true if the results should be ignored, false otherwise.
35bool generateUSRForDecl(const Decl *D, SmallVectorImpl<char> &Buf);
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.
73bool generateUSRForMacro(const MacroDefinitionRecord *MD,
74 const SourceManager &SM, SmallVectorImpl<char> &Buf);
75bool generateUSRForMacro(StringRef MacroName, SourceLocation Loc,
76 const SourceManager &SM, SmallVectorImpl<char> &Buf);
77
78/// Generates a USR for a type.
79///
80/// \return true on error, false on success.
81bool generateUSRForType(QualType T, ASTContext &Ctx, SmallVectorImpl<char> &Buf);
82
83/// Generate a USR for a module, including the USR prefix.
84/// \returns true on error, false on success.
85bool generateFullUSRForModule(const Module *Mod, raw_ostream &OS);
86
87/// Generate a USR for a top-level module name, including the USR prefix.
88/// \returns true on error, false on success.
89bool generateFullUSRForTopLevelModuleName(StringRef ModName, raw_ostream &OS);
90
91/// Generate a USR fragment for a module.
92/// \returns true on error, false on success.
93bool generateUSRFragmentForModule(const Module *Mod, raw_ostream &OS);
94
95/// Generate a USR fragment for a module name.
96/// \returns true on error, false on success.
97bool generateUSRFragmentForModuleName(StringRef ModName, raw_ostream &OS);
98
99
100} // namespace index
101} // namespace clang
102
103} // namespace clanguml