0.7.0
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
Functions
clanguml::common::index Namespace Reference

Functions

static StringRef getUSRSpacePrefix ()
 
bool generateUSRForDecl (const Decl *D, SmallVectorImpl< char > &Buf)
 
void generateUSRForObjCClass (StringRef Cls, raw_ostream &OS, StringRef ExtSymbolDefinedIn="", StringRef CategoryContextExtSymbolDefinedIn="")
 Generate a USR fragment for an Objective-C class.
 
void generateUSRForObjCCategory (StringRef Cls, StringRef Cat, raw_ostream &OS, StringRef ClsExtSymbolDefinedIn="", StringRef CatExtSymbolDefinedIn="")
 Generate a USR fragment for an Objective-C class category.
 
void generateUSRForObjCIvar (StringRef Ivar, raw_ostream &OS)
 
void generateUSRForObjCMethod (StringRef Sel, bool IsInstanceMethod, raw_ostream &OS)
 Generate a USR fragment for an Objective-C method.
 
void generateUSRForObjCProperty (StringRef Prop, bool isClassProp, raw_ostream &OS)
 Generate a USR fragment for an Objective-C property.
 
void generateUSRForObjCProtocol (StringRef Prot, raw_ostream &OS, StringRef ExtSymbolDefinedIn="")
 Generate a USR fragment for an Objective-C protocol.
 
void generateUSRForGlobalEnum (StringRef EnumName, raw_ostream &OS, StringRef ExtSymbolDefinedIn="")
 Generate USR fragment for a global (non-nested) enum.
 
void generateUSRForEnumConstant (StringRef EnumConstantName, raw_ostream &OS)
 Generate a USR fragment for an enum constant.
 
bool generateUSRForMacro (const MacroDefinitionRecord *MD, const SourceManager &SM, SmallVectorImpl< char > &Buf)
 
bool generateUSRForMacro (StringRef MacroName, SourceLocation Loc, const SourceManager &SM, SmallVectorImpl< char > &Buf)
 
bool generateUSRForType (QualType T, ASTContext &Ctx, SmallVectorImpl< char > &Buf)
 
bool generateFullUSRForModule (const Module *Mod, raw_ostream &OS)
 
bool generateFullUSRForTopLevelModuleName (StringRef ModName, raw_ostream &OS)
 
bool generateUSRFragmentForModule (const Module *Mod, raw_ostream &OS)
 
bool generateUSRFragmentForModuleName (StringRef ModName, raw_ostream &OS)
 
static StringRef getUSRSpacePrefix ()
 
static StringRef getUSRSpacePrefix ()
 
static StringRef getUSRSpacePrefix ()
 
static StringRef getUSRSpacePrefix ()
 
static StringRef getUSRSpacePrefix ()
 
static StringRef getUSRSpacePrefix ()
 
static StringRef getUSRSpacePrefix ()
 
static StringRef getUSRSpacePrefix ()
 
bool generateUSRForDecl (const Decl *D, SmallVectorImpl< char > &Buf, const LangOptions &LangOpts)
 
bool generateUSRForType (QualType T, ASTContext &Ctx, SmallVectorImpl< char > &Buf, const LangOptions &LangOpts)
 
static StringRef getUSRSpacePrefix ()
 
static StringRef getUSRSpacePrefix ()
 
static StringRef getUSRSpacePrefix ()
 

Function Documentation

◆ generateFullUSRForModule()

bool clanguml::common::index::generateFullUSRForModule ( const Module *  Mod,
raw_ostream &  OS 
)

Generate a USR for a module, including the USR prefix.

Returns
true on error, false on success.

Definition at line 1159 of file USRGeneration.cpp.

1160 {
1161 if (!Mod->Parent)
1162 return generateFullUSRForTopLevelModuleName(Mod->Name, OS);
1163 if (generateFullUSRForModule(Mod->Parent, OS))
1164 return true;
1165 return generateUSRFragmentForModule(Mod, OS);
1166}

◆ generateFullUSRForTopLevelModuleName()

bool clanguml::common::index::generateFullUSRForTopLevelModuleName ( StringRef  ModName,
raw_ostream &  OS 
)

Generate a USR for a top-level module name, including the USR prefix.

Returns
true on error, false on success.

Definition at line 1168 of file USRGeneration.cpp.

1169 {
1170 OS << getUSRSpacePrefix();
1171 return generateUSRFragmentForModuleName(ModName, OS);
1172}

◆ generateUSRForDecl() [1/2]

bool clanguml::common::index::generateUSRForDecl ( const Decl *  D,
SmallVectorImpl< char > &  Buf 
)

Generate a USR for a Decl, including the USR prefix.

Returns
true if the results should be ignored, false otherwise.

Definition at line 1104 of file USRGeneration.cpp.

1105 {
1106 if (!D)
1107 return true;
1108 // We don't ignore decls with invalid source locations. Implicit decls, like
1109 // C++'s operator new function, can have invalid locations but it is fine to
1110 // create USRs that can identify them.
1111
1112 USRGenerator UG(&D->getASTContext(), Buf);
1113 UG.Visit(D);
1114 return UG.ignoreResults();
1115}

◆ generateUSRForDecl() [2/2]

bool clanguml::common::index::generateUSRForDecl ( const Decl *  D,
SmallVectorImpl< char > &  Buf,
const LangOptions &  LangOpts 
)

Definition at line 1364 of file USRGeneration.cpp.

1366{
1367 if (!D)
1368 return true;
1369 // We don't ignore decls with invalid source locations. Implicit decls, like
1370 // C++'s operator new function, can have invalid locations but it is fine to
1371 // create USRs that can identify them.
1372
1373#if !defined(_MSC_VER)
1374 // Check if the declaration has explicit external USR specified.
1375 auto *CD = D->getCanonicalDecl();
1376 if (auto *ExternalSymAttr = CD->getAttr<ExternalSourceSymbolAttr>()) {
1377 if (!ExternalSymAttr->getUSR().empty()) {
1378 llvm::raw_svector_ostream Out(Buf);
1379 Out << ExternalSymAttr->getUSR();
1380 return false;
1381 }
1382 }
1383#endif
1384
1385 USRGenerator UG(&D->getASTContext(), Buf, LangOpts);
1386 UG.Visit(D);
1387 return UG.ignoreResults();
1388}

◆ generateUSRForEnumConstant()

void clanguml::common::index::generateUSRForEnumConstant ( StringRef  EnumConstantName,
raw_ostream &  OS 
)

Generate a USR fragment for an enum constant.

Definition at line 1099 of file USRGeneration.cpp.

1100 {
1101 OS << '@' << EnumConstantName;
1102}

◆ generateUSRForGlobalEnum()

void clanguml::common::index::generateUSRForGlobalEnum ( StringRef  EnumName,
raw_ostream &  OS,
StringRef  ExtSymbolDefinedIn = "" 
)

Generate USR fragment for a global (non-nested) enum.

Definition at line 1092 of file USRGeneration.cpp.

1093 {
1094 if (!ExtSymDefinedIn.empty())
1095 OS << "@M@" << ExtSymDefinedIn;
1096 OS << "@E@" << EnumName;
1097}

◆ generateUSRForMacro() [1/2]

bool clanguml::common::index::generateUSRForMacro ( const MacroDefinitionRecord *  MD,
const SourceManager &  SM,
SmallVectorImpl< char > &  Buf 
)

Generate a USR for a macro, including the USR prefix.

Returns
true on error, false on success.

Definition at line 1117 of file USRGeneration.cpp.

1119 {
1120 if (!MD)
1121 return true;
1122 return generateUSRForMacro(MD->getName()->getName(), MD->getLocation(),
1123 SM, Buf);
1124
1125}

◆ generateUSRForMacro() [2/2]

bool clanguml::common::index::generateUSRForMacro ( StringRef  MacroName,
SourceLocation  Loc,
const SourceManager &  SM,
SmallVectorImpl< char > &  Buf 
)

Definition at line 1127 of file USRGeneration.cpp.

1129 {
1130 // Don't generate USRs for things with invalid locations.
1131 if (MacroName.empty() || Loc.isInvalid())
1132 return true;
1133
1134 llvm::raw_svector_ostream Out(Buf);
1135
1136 // Assume that system headers are sane. Don't put source location
1137 // information into the USR if the macro comes from a system header.
1138 bool ShouldGenerateLocation = !SM.isInSystemHeader(Loc);
1139
1140 Out << getUSRSpacePrefix();
1141 if (ShouldGenerateLocation)
1142 printLoc(Out, Loc, SM, /*IncludeOffset=*/true);
1143 Out << "@macro@";
1144 Out << MacroName;
1145 return false;
1146}

◆ generateUSRForObjCCategory()

void clanguml::common::index::generateUSRForObjCCategory ( StringRef  Cls,
StringRef  Cat,
raw_ostream &  OS,
StringRef  ClsExtSymbolDefinedIn = "",
StringRef  CatExtSymbolDefinedIn = "" 
)

Generate a USR fragment for an Objective-C class category.

Definition at line 1062 of file USRGeneration.cpp.

1065 {
1066 combineClassAndCategoryExtContainers(ClsSymDefinedIn, CatSymDefinedIn, OS);
1067 OS << "objc(cy)" << Cls << '@' << Cat;
1068}

◆ generateUSRForObjCClass()

void clanguml::common::index::generateUSRForObjCClass ( StringRef  Cls,
raw_ostream &  OS,
StringRef  ExtSymbolDefinedIn = "",
StringRef  CategoryContextExtSymbolDefinedIn = "" 
)

Generate a USR fragment for an Objective-C class.

Definition at line 1054 of file USRGeneration.cpp.

1056 {
1058 CategoryContextExtSymbolDefinedIn, OS);
1059 OS << "objc(cs)" << Cls;
1060}

◆ generateUSRForObjCIvar()

void clanguml::common::index::generateUSRForObjCIvar ( StringRef  Ivar,
raw_ostream &  OS 
)

Generate a USR fragment for an Objective-C instance variable. The complete USR can be created by concatenating the USR for the encompassing class with this USR fragment.

Definition at line 1070 of file USRGeneration.cpp.

1070 {
1071 OS << '@' << Ivar;
1072}

◆ generateUSRForObjCMethod()

void clanguml::common::index::generateUSRForObjCMethod ( StringRef  Sel,
bool  IsInstanceMethod,
raw_ostream &  OS 
)

Generate a USR fragment for an Objective-C method.

Definition at line 1074 of file USRGeneration.cpp.

1076 {
1077 OS << (IsInstanceMethod ? "(im)" : "(cm)") << Sel;
1078}

◆ generateUSRForObjCProperty()

void clanguml::common::index::generateUSRForObjCProperty ( StringRef  Prop,
bool  isClassProp,
raw_ostream &  OS 
)

Generate a USR fragment for an Objective-C property.

Definition at line 1080 of file USRGeneration.cpp.

1081 {
1082 OS << (isClassProp ? "(cpy)" : "(py)") << Prop;
1083}

◆ generateUSRForObjCProtocol()

void clanguml::common::index::generateUSRForObjCProtocol ( StringRef  Prot,
raw_ostream &  OS,
StringRef  ExtSymbolDefinedIn = "" 
)

Generate a USR fragment for an Objective-C protocol.

Definition at line 1085 of file USRGeneration.cpp.

1086 {
1087 if (!ExtSymDefinedIn.empty())
1088 OS << "@M@" << ExtSymDefinedIn << '@';
1089 OS << "objc(pl)" << Prot;
1090}

◆ generateUSRForType() [1/2]

bool clanguml::common::index::generateUSRForType ( QualType  T,
ASTContext &  Ctx,
SmallVectorImpl< char > &  Buf 
)

Generates a USR for a type.

Returns
true on error, false on success.

Definition at line 1148 of file USRGeneration.cpp.

1149 {
1150 if (T.isNull())
1151 return true;
1152 T = T.getCanonicalType();
1153
1154 USRGenerator UG(&Ctx, Buf);
1155 UG.VisitType(T);
1156 return UG.ignoreResults();
1157}

◆ generateUSRForType() [2/2]

bool clanguml::common::index::generateUSRForType ( QualType  T,
ASTContext &  Ctx,
SmallVectorImpl< char > &  Buf,
const LangOptions &  LangOpts 
)

Definition at line 1425 of file USRGeneration.cpp.

1427{
1428 if (T.isNull())
1429 return true;
1430 T = T.getCanonicalType();
1431
1432 USRGenerator UG(&Ctx, Buf, LangOpts);
1433 UG.VisitType(T);
1434 return UG.ignoreResults();
1435}

◆ generateUSRFragmentForModule()

bool clanguml::common::index::generateUSRFragmentForModule ( const Module *  Mod,
raw_ostream &  OS 
)

Generate a USR fragment for a module.

Returns
true on error, false on success.

Definition at line 1174 of file USRGeneration.cpp.

1175 {
1176 return generateUSRFragmentForModuleName(Mod->Name, OS);
1177}

◆ generateUSRFragmentForModuleName()

bool clanguml::common::index::generateUSRFragmentForModuleName ( StringRef  ModName,
raw_ostream &  OS 
)

Generate a USR fragment for a module name.

Returns
true on error, false on success.

Definition at line 1179 of file USRGeneration.cpp.

1180 {
1181 OS << "@M@" << ModName;
1182 return false;
1183}

◆ getUSRSpacePrefix() [1/12]

static StringRef clanguml::common::index::getUSRSpacePrefix ( )
inlinestatic

Definition at line 29 of file USRGeneration.h.

29 {
30 return "c:";
31}

◆ getUSRSpacePrefix() [2/12]

static StringRef clanguml::common::index::getUSRSpacePrefix ( )
inlinestatic

Definition at line 29 of file USRGeneration.h.

29 {
30 return "c:";
31}

◆ getUSRSpacePrefix() [3/12]

static StringRef clanguml::common::index::getUSRSpacePrefix ( )
inlinestatic

Definition at line 29 of file USRGeneration.h.

29 {
30 return "c:";
31}

◆ getUSRSpacePrefix() [4/12]

static StringRef clanguml::common::index::getUSRSpacePrefix ( )
inlinestatic

Definition at line 29 of file USRGeneration.h.

29 {
30 return "c:";
31}

◆ getUSRSpacePrefix() [5/12]

static StringRef clanguml::common::index::getUSRSpacePrefix ( )
inlinestatic

Definition at line 29 of file USRGeneration.h.

29 {
30 return "c:";
31}

◆ getUSRSpacePrefix() [6/12]

static StringRef clanguml::common::index::getUSRSpacePrefix ( )
inlinestatic

Definition at line 30 of file USRGeneration.h.

30 {
31 return "c:";
32}

◆ getUSRSpacePrefix() [7/12]

static StringRef clanguml::common::index::getUSRSpacePrefix ( )
inlinestatic

Definition at line 30 of file USRGeneration.h.

30 {
31 return "c:";
32}

◆ getUSRSpacePrefix() [8/12]

static StringRef clanguml::common::index::getUSRSpacePrefix ( )
inlinestatic

Definition at line 29 of file USRGeneration.h.

29 {
30 return "c:";
31}

◆ getUSRSpacePrefix() [9/12]

static StringRef clanguml::common::index::getUSRSpacePrefix ( )
inlinestatic

Definition at line 29 of file USRGeneration.h.

29 {
30 return "c:";
31}

◆ getUSRSpacePrefix() [10/12]

static StringRef clanguml::common::index::getUSRSpacePrefix ( )
inlinestatic

Definition at line 30 of file USRGeneration.h.

30 {
31 return "c:";
32}

◆ getUSRSpacePrefix() [11/12]

static StringRef clanguml::common::index::getUSRSpacePrefix ( )
inlinestatic

Definition at line 30 of file USRGeneration.h.

30 {
31 return "c:";
32}

◆ getUSRSpacePrefix() [12/12]

static StringRef clanguml::common::index::getUSRSpacePrefix ( )
inlinestatic

Definition at line 30 of file USRGeneration.h.

30 {
31 return "c:";
32}