如何使用PCH或PTH提高clang解析性能
How to increase clang parsing performance using PCH or PTH?
我使用Clang C API进行解析和诊断。我注意到我一直在使用相同的头束,所以我决定尝试使用PCH或PTH来提高性能。
但我得到的诊断是,在clang_parseTranslationUnit
:时既没有使用PCH也没有使用PTH
- 编译过程中未使用的参数:'-emit pth'
- /tmp/system/include/libcxx/iostream.pth:"链接器"输入未使用
- 编译期间未使用的参数:'-emit pch'
- /tmp/system/include/libcxx/iostream.pch:"链接器"输入未使用
我很惊讶在解析时没有使用PCH和PTH,那么我如何使用PCH或PTH或任何其他方法来提高解析性能呢?
PS。
PTH是用clang++ -x c++-header iostream -emit-pth -o iostream.pth
、PCH以类似的方式生成的
更新1:
我发现PCH的使用示例:
// This will load all the symbols from 'IndexTest.c', excluding symbols
// from 'IndexTest.pch'.
char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args, 0, 0);
问题是,现在我得到了另一个诊断警告:
'-pch=/system/include/libcxx/iostream.pch' file not found
命令行参数的分析似乎不正确。。我做错了什么?
需要在每个参数之前包含-Xclang
:
char *args[] = { "-Xclang", "-include-pch", "-Xclang", "IndexTest.pch" };
请参阅https://reviews.llvm.org/diffusion/L/browse/cfe/trunk/test/Index/c-index-pch.c寻找灵感。
相关文章:
- 删除一个线程上有数百万个字符串的大型哈希映射会影响另一个线程的性能
- OpenMP阵列性能较差
- 递归列出所有目录中的C++与Python与Ruby的性能
- 奇怪的结构&GCC&clang(void*返回类型)
- 数据成员SFINAE的C++17测试:gcc vs clang
- 当我编译webrtc服务器时,Windows上只支持clang-cl
- 为什么在Windows上的VS 2019和Clang 9中"size_t"在没有标题的情况下工作
- 大小相等但成员数量不同的结构之间的性能差异
- 我可以将一个用clang c++11编译的对象与另一个用c++17编译的对象链接起来吗
- Clang bug?使用指针作为模板参数
- 为什么constexpr的性能比正常表达式差
- clang整洁10忽略了我的NOLINT命令
- 如何防止clang格式在流运算符调用之间添加换行符<<
- 在clang++预处理器中确定gcc工具链版本
- 为什么 Clang 不允许"and"作为函数名称?
- GCC 和 Clang 代码性能的巨大差异
- 使用双包装器类进行位操作(C++、clang)修复性能下降问题
- 为什么链接到librt会在g++和clang之间交换性能
- 如何使用PCH或PTH提高clang解析性能
- 特定C++随机数生成的Clang性能下降