Skip to content

Commit d4c727c

Browse files
committed
temp
1 parent e983093 commit d4c727c

File tree

6 files changed

+94
-21
lines changed

6 files changed

+94
-21
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include "multiple_classes.h"
2+
3+
int first_class::get1() {
4+
return 1;
5+
}
6+
7+
int second_class::get2() {
8+
return 2;
9+
}
10+
11+
int second_class::third_class::get3() {
12+
return 3;
13+
}
14+
15+
first_class::first_class() {}
16+
17+
second_class::second_class() {}
18+
19+
second_class::third_class::third_class() {}
20+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#ifndef UNITTESTBOT_MULTIPLE_CLASSES_H
2+
#define UNITTESTBOT_MULTIPLE_CLASSES_H
3+
4+
5+
class first_class {
6+
public:
7+
first_class();
8+
9+
int get1();
10+
};
11+
12+
struct second_class {
13+
public:
14+
second_class();
15+
16+
struct third_class {
17+
third_class();
18+
19+
public:
20+
int get3();
21+
};
22+
23+
int get2();
24+
};
25+
26+
27+
#endif //UNITTESTBOT_MULTIPLE_CLASSES_H

server/src/BordersFinder.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,16 @@ void BordersFinder::run(const MatchFinder::MatchResult &Result) {
8383
} else {
8484
lineInfo.scopeName = path.stem().string();
8585
}
86-
lineInfo.methodName = FS->getNameAsString();
86+
87+
std::string QualName = "";
88+
89+
llvm::raw_string_ostream OS(QualName);
90+
auto qua = FS->getQualifier();
91+
if (qua) {
92+
qua->print(OS, FS->getASTContext().getPrintingPolicy());
93+
}
94+
95+
lineInfo.methodName = QualName + FS->getNameAsString();
8796
clang::QualType realReturnType = ClangUtils::getReturnType(FS, Result);
8897
lineInfo.functionReturnType = ParamsHandler::getType(realReturnType, realReturnType, sourceManager);
8998
lineInfo.initialized = true;

server/src/clang-utils/ClangUtils.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,27 @@ namespace ClangUtils {
3636
return FS;
3737
}
3838

39-
40-
clang::QualType getReturnType(const clang::FunctionDecl *FS, const clang::ast_matchers::MatchFinder::MatchResult &Result) {
39+
clang::QualType
40+
getReturnType(const clang::FunctionDecl *FS, const clang::ast_matchers::MatchFinder::MatchResult &Result) {
4141
clang::QualType realReturnType = FS->getReturnType().getCanonicalType();
4242
if (const auto *CS = getConstructor(Result)) {
4343
realReturnType = CS->getThisObjectType();
4444
}
4545
return realReturnType;
4646
}
47+
48+
std::string getQualName(const clang::FunctionDecl *FS) {
49+
std::string QualName = "";
50+
llvm::raw_string_ostream OS(QualName);
51+
auto qualifier = FS->getQualifier();
52+
if (qualifier) {
53+
switch (FS->getCanonicalDecl()) {
54+
55+
}
56+
qualifier->print(OS, FS->getASTContext().getPrintingPolicy());
57+
OS.flush();
58+
59+
LOG_S(ERROR) << "qualname: '" << QualName << "' '" << FS->getQualifiedNameAsString() << "'";
60+
}
61+
}
4762
}

server/src/fetchers/FunctionDeclsMatchCallback.cpp

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ FunctionDeclsMatchCallback::FunctionDeclsMatchCallback(const Fetcher *parent,
1616
bool onlyNames,
1717
bool toResolveReturnTypes,
1818
bool onlyReturnTypes)
19-
: parent(parent), typesResolver(parent), onlyNames(onlyNames),
20-
toResolveReturnTypes(toResolveReturnTypes), onlyReturnTypes(onlyReturnTypes) {
19+
: parent(parent), typesResolver(parent), onlyNames(onlyNames),
20+
toResolveReturnTypes(toResolveReturnTypes), onlyReturnTypes(onlyReturnTypes) {
2121
}
2222

2323
void FunctionDeclsMatchCallback::run(const MatchFinder::MatchResult &Result) {
@@ -29,15 +29,14 @@ void FunctionDeclsMatchCallback::run(const MatchFinder::MatchResult &Result) {
2929
->tryGetRealPathName()
3030
.str();
3131

32-
std::string methodName = FS->getNameAsString();
3332
Tests::MethodDescription methodDescription;
34-
methodDescription.name = methodName;
3533
if (const CXXConstructorDecl *CS = ClangUtils::getConstructor(Result)) {
36-
methodDescription.constructorInfo = Tests::ConstructorInfo::CONSTRUCTOR;
37-
if (CS->isMoveConstructor()) {
38-
methodDescription.constructorInfo = Tests::ConstructorInfo::MOVE_CONSTRUCTOR;
39-
}
34+
methodDescription.constructorInfo = CS->isMoveConstructor() ? Tests::ConstructorInfo::MOVE_CONSTRUCTOR
35+
: Tests::ConstructorInfo::CONSTRUCTOR;
4036
}
37+
38+
std::string methodName = QualName + FS->getNameAsString();
39+
methodDescription.name = methodName;
4140
methodDescription.sourceFilePath = sourceFilePath;
4241
if (onlyNames) {
4342
addMethod(sourceFilePath, methodDescription);
@@ -156,18 +155,18 @@ void FunctionDeclsMatchCallback::logFunction(const Tests::MethodDescription &des
156155
}
157156

158157
void FunctionDeclsMatchCallback::addFunctionPointer(
159-
tests::Tests::MethodDescription::FPointerMap &functionPointers,
160-
const clang::FunctionType *functionType,
161-
const clang::QualType &qualType,
162-
const std::string &name,
163-
const clang::SourceManager &sourceManager,
164-
const types::Type &type) {
158+
tests::Tests::MethodDescription::FPointerMap &functionPointers,
159+
const clang::FunctionType *functionType,
160+
const clang::QualType &qualType,
161+
const std::string &name,
162+
const clang::SourceManager &sourceManager,
163+
const types::Type &type) {
165164
if (type.isPointerToFunction()) {
166165
functionPointers[name] = ParamsHandler::getFunctionPointerDeclaration(functionType, name, sourceManager,
167-
false);
166+
false);
168167
} else if (type.isArrayOfPointersToFunction()) {
169168
functionPointers[name] = ParamsHandler::getFunctionPointerDeclaration(
170-
qualType->getPointeeType()->getPointeeType()->getAs<clang::FunctionType>(), name,
171-
sourceManager, true);
169+
qualType->getPointeeType()->getPointeeType()->getAs<clang::FunctionType>(), name,
170+
sourceManager, true);
172171
}
173172
}

server/src/utils/KleeUtils.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ namespace KleeUtils {
8383
const std::string &methodName,
8484
bool needToMangle,
8585
bool isWrapped) {
86-
std::string methodNewName = getRenamedOperator(methodName);
86+
87+
std::string methodNewName = methodName;
88+
StringUtils::replaceAll(methodNewName, ':', '_');
89+
methodNewName = getRenamedOperator(methodNewName);
8790
if (isWrapped) {
8891
methodNewName += PrinterUtils::WRAPPED_SUFFIX;
8992
}

0 commit comments

Comments
 (0)