Static Value-Flow Analysis
Loading...
Searching...
No Matches
Public Member Functions | List of all members
SVF::cppUtil::MSVCABI Class Reference

#include <CppUtil.h>

Inheritance diagram for SVF::cppUtil::MSVCABI:
SVF::cppUtil::CXXABI

Public Member Functions

bool isVtable (const std::string &name) override
 
bool isTypeInfo (const std::string &name) override
 
bool isConstructor (const std::string &name) override
 
bool isDestructor (const std::string &name) override
 
std::string extractClassName (const std::string &name) override
 
DemangledName demangle (const std::string &name) override
 
- Public Member Functions inherited from SVF::cppUtil::CXXABI
virtual ~CXXABI ()=default
 

Detailed Description

Definition at line 77 of file CppUtil.h.

Member Function Documentation

◆ demangle()

DemangledName SVF::cppUtil::MSVCABI::demangle ( const std::string &  name)
overridevirtual

Implements SVF::cppUtil::CXXABI.

Definition at line 1147 of file CppUtil.cpp.

1148{
1149 DemangledName dname;
1150 dname.isThunkFunc = false;
1151
1152 std::string realnameStr = llvm::demangle(name);
1153 if (realnameStr == name)
1154 {
1155 dname.className = "";
1156 dname.funcName = "";
1157 return dname;
1158 }
1159
1160 if (realnameStr.find("[thunk]") != std::string::npos ||
1161 realnameStr.find("`vcall'") != std::string::npos ||
1162 realnameStr.find("`adjustor'") != std::string::npos)
1163 {
1164 dname.isThunkFunc = true;
1165 }
1166
1168 if (beforeParenthesis.find("::") == std::string::npos ||
1170 {
1171 dname.className = "";
1172 dname.funcName = "";
1173 }
1174 else
1175 {
1177 size_t colon = beforeBracket.rfind("::");
1178 if (colon == std::string::npos)
1179 {
1180 dname.className = "";
1181 dname.funcName = "";
1182 }
1183 else
1184 {
1185 std::string classNamePart = beforeParenthesis.substr(0, colon);
1186 dname.funcName = beforeParenthesis.substr(colon + 2);
1187
1188 int i = classNamePart.size() - 1;
1189 int bracketDepth = 0;
1190 while (i >= 0)
1191 {
1192 char c = classNamePart[i];
1193 if (c == '>')
1194 {
1195 bracketDepth++;
1196 }
1197 else if (c == '<')
1198 {
1199 bracketDepth--;
1200 }
1201
1202 if (bracketDepth > 0)
1203 {
1204 i--;
1205 }
1206 else
1207 {
1208 if (std::isalnum(c) || c == '_' || c == ':' || c == '<' ||
1209 c == '>')
1210 {
1211 i--;
1212 }
1213 else
1214 {
1215 break;
1216 }
1217 }
1218 }
1219 dname.className = classNamePart.substr(i + 1);
1220 }
1221 }
1222
1223 return dname;
1224}
static bool isOperOverload(const std::string &name)
Definition CppUtil.cpp:84
static std::string getBeforeParenthesis(const std::string &name)
Definition CppUtil.cpp:107
const char *const name
Definition cJSON.h:264
std::string getBeforeBrackets(const std::string &name)
Definition CppUtil.cpp:127
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76

◆ extractClassName()

std::string SVF::cppUtil::MSVCABI::extractClassName ( const std::string &  name)
overridevirtual

Implements SVF::cppUtil::CXXABI.

Definition at line 1127 of file CppUtil.cpp.

1128{
1129 std::string className = "";
1130 std::string realnameStr = llvm::demangle(name);
1131 size_t pos = realnameStr.rfind("::`vftable'");
1132 if (pos == std::string::npos)
1133 {
1134 pos = realnameStr.rfind("::`vbtable'");
1135 }
1136 if (pos != std::string::npos)
1137 {
1138 className = realnameStr.substr(0, pos);
1139 if (className.compare(0, 6, "const ") == 0)
1140 {
1141 className = className.substr(6);
1142 }
1143 }
1144 return className;
1145}

◆ isConstructor()

bool SVF::cppUtil::MSVCABI::isConstructor ( const std::string &  name)
overridevirtual

Implements SVF::cppUtil::CXXABI.

Definition at line 1117 of file CppUtil.cpp.

1118{
1119 return name.compare(0, 3, "??0") == 0;
1120}

◆ isDestructor()

bool SVF::cppUtil::MSVCABI::isDestructor ( const std::string &  name)
overridevirtual

Implements SVF::cppUtil::CXXABI.

Definition at line 1122 of file CppUtil.cpp.

1123{
1124 return name.compare(0, 3, "??1") == 0;
1125}

◆ isTypeInfo()

bool SVF::cppUtil::MSVCABI::isTypeInfo ( const std::string &  name)
overridevirtual

Implements SVF::cppUtil::CXXABI.

Definition at line 1112 of file CppUtil.cpp.

1113{
1114 return name.compare(0, 4, "??_R") == 0;
1115}

◆ isVtable()

bool SVF::cppUtil::MSVCABI::isVtable ( const std::string &  name)
overridevirtual

Implements SVF::cppUtil::CXXABI.

Definition at line 1107 of file CppUtil.cpp.

1108{
1109 return name.compare(0, 4, "??_7") == 0 || name.compare(0, 4, "??_8") == 0;
1110}

The documentation for this class was generated from the following files: