使用 clang 从 stdin 自动补全
我已经在 Emacs 中设置了自动完成环境,使用 clang 2.8 作为解析器。它工作得很好,但依赖于在完成之前将当前编辑的缓冲区保存到文件中。这很慢,所以我试图让 clang 解析通过 stdin 提供给它的文件,但到目前为止还没有运气。
我在解析文件时输入 clang 的命令行如下:
clang -cc1 -fsyntax-only -Iinclude/ -code-completion-at foo.cpp:10:20 foo.cpp
这效果很好。但尝试从标准输入读取失败。我已经尝试过这个:
cat foo.cpp | clang -xc++ -cc1 -fsyntax-only -Iinclude/ -code-completion-at -:10:20 -
但这会使 clang 终止而不进行任何完成并打印警告:
clang: warning: argument unused during compilation: '-cc1'
clang: warning: argument unused during compilation: '-code-completion-at'
clang: warning: argument unused during compilation: '-:10:20'
有什么想法吗?
I have set up an environment for autocompletion in Emacs, using clang 2.8 as the parser. It works well, but relies on saving the currently edited buffer to file before completion. This is slow, so I am trying to get clang to parse a file given to it via stdin instead, without luck so far.
The command line I feed clang when parsing a file is as follows:
clang -cc1 -fsyntax-only -Iinclude/ -code-completion-at foo.cpp:10:20 foo.cpp
This works well. But attempts to read from stdin fail. I've tried this:
cat foo.cpp | clang -xc++ -cc1 -fsyntax-only -Iinclude/ -code-completion-at -:10:20 -
But that makes clang terminate without making any completions and prints the warnings:
clang: warning: argument unused during compilation: '-cc1'
clang: warning: argument unused during compilation: '-code-completion-at'
clang: warning: argument unused during compilation: '-:10:20'
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果在
-x c++
之前指定-cc1
是否有效?Does it work if you specify
-cc1
before-x c++
?