clang

作者: 咚咚董dyh | 来源:发表于2023-05-30 20:52 被阅读0次

参考资料:

ubuntu安装llvm,含clang:https://apt.llvm.org/

clang ast-dump cli:

clang -Xclang -ast-dump -fsyntax-only -Xclang -ast-dump-filter -Xclang FaceDetector::FaceDetector -I/path/to/opencv-4.5.5/include/opencv4/ xxx.hpp

clang重命名类的Cursor:

  • CursorKind.NAMESPACE_ALIAS
  • CursorKind.TYPE_ALIAS_DECL
  • CursorKind.TYPE_ALIAS_TEMPLATE_DECL

clang ElaboratedType

  • Represents a type that was referred to using an elaborated type keyword, e.g., struct S, or via a qualified name, e.g., N::M::type, or both.
  • This type is used to keep track of a type name as written in the source code, including tag keywords and any nested-name-specifiers. The type itself is always "sugar", used to express what was written in the source code but containing no additional semantic information.

CMake file API:用于获取JSON格式的语义信息

mkdir build
cd build/
mkdir -p .cmake/api/v1/query
touch .cmake/api/v1/query/codemodel-v2  # 支持cache-v2、cmakeFiles-v1、toolchains-v1
cmake .. -DCMAKE_BUILD_TYPE=Release -G "CodeBlocks - Unix Makefiles"
ls .cmake/api/v1/reply

clang get_usr

get_usr中各种符号含义:

  • @N@: Namespace
  • @E@: Enum
  • @F@: Function
  • @S@: Struct

例如:

"c:@N@cv@ST>1#T@Ptr":cv::Ptr<T>
"c:@N@cv@E@WindowFlags@WINDOW_OPENGL":cv::WindowFlags.WINDOW_OPENGL
"c:@N@cv@N@cuda@S@GpuMat@F@GpuMat#*$@N@cv@N@cuda@S@GpuMat@S@Allocator#":cv::cuda::CpuMat::GptMat
"c:@N@cv@S@Ptr>#$@N@cv@N@cudacodec@S@VideoReader@F@operator->#1":cv::Ptr<cv::cudacodec::VideoReader>

usr字符串解析:

nsc = re.findall(r'(?:@[NSE]@\w+){1,1000}', usr[:index])
# nss = ['::'.join(x[3:].split('@N@')) for x in nsc]
nss = [x[3:].replace('@N@', '::').replace('@S@', '::').replace('@E@', '::') for x in nsc]

相关文章

网友评论

      本文标题:clang

      本文链接:https://www.haomeiwen.com/subject/weyeedtx.html