Static Value-Flow Analysis
Loading...
Searching...
No Matches
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 1168 of file CppUtil.cpp.

1169{
1170 DemangledName dname;
1171 dname.isThunkFunc = false;
1172
1173 std::string realnameStr = llvm::demangle(name);
1174 if (realnameStr == name)
1175 {
1176 dname.className = "";
1177 dname.funcName = "";
1178 return dname;
1179 }
1180
1181 if (realnameStr.find("[thunk]") != std::string::npos ||
1182 realnameStr.find("`vcall'") != std::string::npos ||
1183 realnameStr.find("`adjustor'") != std::string::npos)
1184 {
1185 dname.isThunkFunc = true;
1186 }
1187
1188 std::string beforeParenthesis = getBeforeParenthesis(realnameStr);
1189 if (beforeParenthesis.find("::") == std::string::npos ||
1190 isOperOverload(beforeParenthesis))
1191 {
1192 dname.className = "";
1193 dname.funcName = "";
1194 }
1195 else
1196 {
1197 std::string beforeBracket = getBeforeBrackets(beforeParenthesis);
1198 size_t colon = beforeBracket.rfind("::");
1199 if (colon == std::string::npos)
1200 {
1201 dname.className = "";
1202 dname.funcName = "";
1203 }
1204 else
1205 {
1206 std::string classNamePart = beforeParenthesis.substr(0, colon);
1207 dname.funcName = beforeParenthesis.substr(colon + 2);
1208
1209 int i = classNamePart.size() - 1;
1210 int bracketDepth = 0;
1211 while (i >= 0)
1212 {
1213 char c = classNamePart[i];
1214 if (c == '>')
1215 {
1216 bracketDepth++;
1217 }
1218 else if (c == '<')
1219 {
1220 bracketDepth--;
1221 }
1222
1223 if (bracketDepth > 0)
1224 {
1225 i--;
1226 }
1227 else
1228 {
1229 if (std::isalnum(c) || c == '_' || c == ':' || c == '<' ||
1230 c == '>')
1231 {
1232 i--;
1233 }
1234 else
1235 {
1236 break;
1237 }
1238 }
1239 }
1240 dname.className = classNamePart.substr(i + 1);
1241 }
1242 }
1243
1244 return dname;
1245}
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

◆ extractClassName()

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

Implements SVF::cppUtil::CXXABI.

Definition at line 1148 of file CppUtil.cpp.

1149{
1150 std::string className = "";
1151 std::string realnameStr = llvm::demangle(name);
1152 size_t pos = realnameStr.rfind("::`vftable'");
1153 if (pos == std::string::npos)
1154 {
1155 pos = realnameStr.rfind("::`vbtable'");
1156 }
1157 if (pos != std::string::npos)
1158 {
1159 className = realnameStr.substr(0, pos);
1160 if (className.compare(0, 6, "const ") == 0)
1161 {
1162 className = className.substr(6);
1163 }
1164 }
1165 return className;
1166}

◆ isConstructor()

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

Implements SVF::cppUtil::CXXABI.

Definition at line 1138 of file CppUtil.cpp.

1139{
1140 return name.compare(0, 3, "??0") == 0;
1141}

◆ isDestructor()

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

Implements SVF::cppUtil::CXXABI.

Definition at line 1143 of file CppUtil.cpp.

1144{
1145 return name.compare(0, 3, "??1") == 0;
1146}

◆ isTypeInfo()

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

Implements SVF::cppUtil::CXXABI.

Definition at line 1133 of file CppUtil.cpp.

1134{
1135 return name.compare(0, 4, "??_R") == 0;
1136}

◆ isVtable()

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

Implements SVF::cppUtil::CXXABI.

Definition at line 1128 of file CppUtil.cpp.

1129{
1130 return name.compare(0, 4, "??_7") == 0 || name.compare(0, 4, "??_8") == 0;
1131}

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