c++ - "Clang with Microsoft CodeGen"和 "LLVM-vs2014"有什么区别?

标签 c++ visual-studio debugging clang llvm

在 Visual Studio 2015 或更高版本下,我们可以通过两种方式使用 clang:

  1. Select Clang with Microsoft CodeGen as the Platform Toolset;

  2. Install LLVM-3.8-win64.exe, and select LLVM-vs2014 as the Platform Toolset;

我知道这两种方式都使用相同的编译器:clang 3.8。但是,我不知道它们之间有什么区别。

我的经验表明 Clang with Microsoft CodeGenLLVM-vs2014 更易于调试。换句话说:

  1. I can debug a program built by Clang with Microsoft CodeGen step by step as VC++ does;

  2. A program built by "LLVM-vs2014" cannot be debugged step by step at source-level, but the program can direct run as expected.

所以,我的问题是:

LLVM-vs2014不支持Visual Studio下的源码级调试吗?

微软提供的Clang with Microsoft CodeGen是否只是为了支持Visual Studio下的源码级调试?

最佳答案

I know both of the two ways use the same compiler: clang 3.8. However, I don't know what the difference is between them.

区别在于他们如何使用它。

Clang with Microsoft CodeGen 使用 Clang 将源代码解析为 AST。但随后 MSVC 的代码生成器开始运行,因此与 LLVM 相关的任何内容都不会被使用。

LLVM-vs2014 在每个编译阶段都完全使用 Clang。它使用 LLVM 生成代码。因此,难怪调试信息与 Visual Studio 的预期不兼容。

重要的是要注意,它们都使用相同的运行时。 Clang 具有 clang-cl 模式,使其能够解析 Microsoft header 并使用其语言扩展。

因此,主要区别在于中后端阶段。

关于c++ - "Clang with Microsoft CodeGen"和 "LLVM-vs2014"有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42593423/

相关文章:

c++ - 使用 Application Verifier 调试时应用程序挂起

c++ - 奇怪的语义错误

c# - 创建 asp.net web 表单时如何操作默认标题?

visual-studio - 在哪里可以获取 VS 的 Windows 6.0 Bootstrapper 文件?

c++ - 检测对已释放的未命名临时文件的访问

c++ - 访问超出 C 和 C++ 限制的数组

c# - "A project with an Output type of Class Library cannot be started directly"

c - 我的程序在调试时运行正确,但在调试结束时运行不正确

c# - StackTrace/StackFrame 不返回生产环境中的预期信息

java - 使用 Eclipse 调试不同的命令行参数