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