1 Star 1 Fork 0

Rong Tao/autofdo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
source_info.cc 1.46 KB
一键复制 编辑 原始数据 按行查看 历史
Wei Mi 提交于 2021-09-15 22:55 . Update to the latest internal version.
// Class to represent the source info.
#include "source_info.h"
#include "base/logging.h"
#include "llvm/ADT/StringRef.h"
namespace {
int StrcmpMaybeNull(const char *a, const char *b) {
if (a == nullptr) {
a = "";
}
if (b == nullptr) {
b = "";
}
return strcmp(a, b);
}
} // namespace
namespace devtools_crosstool_autofdo {
#if defined(HAVE_LLVM)
bool SourceInfo::use_fs_discriminator = false;
#endif
bool SourceInfo::operator<(const SourceInfo &p) const {
if (line != p.line) {
return line < p.line;
}
if (start_line != p.start_line) {
return start_line < p.start_line;
}
if (discriminator != p.discriminator) {
return discriminator < p.discriminator;
}
int ret = StrcmpMaybeNull(func_name, p.func_name);
if (ret != 0) {
return ret < 0;
}
// The comparison below relies on the lexicographical behavior of
// llvm::StringRef::compare. C++ string compare should return the same result,
// but since converting to llvm::StringRef is very cheap, and both functions
// may not stay in sync, preferring to retain the prior functionality.
auto p_file_name_ref = llvm::StringRef(p.file_name);
auto file_name_ref = llvm::StringRef(file_name);
ret = file_name_ref.compare(p_file_name_ref);
if (ret != 0) {
return ret < 0;
}
auto p_dir_name_ref = llvm::StringRef(p.dir_name);
auto dir_name_ref = llvm::StringRef(dir_name);
return dir_name_ref.compare(p_dir_name_ref) < 0;
}
} // namespace devtools_crosstool_autofdo
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/rtoax/autofdo.git
git@gitee.com:rtoax/autofdo.git
rtoax
autofdo
autofdo
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385