[cfe-commits] [PATCH] Support auto-completion on stdin
Douglas Gregor
dgregor at apple.com
Tue Oct 26 10:09:23 PDT 2010
On Oct 21, 2010, at 3:22 PM, Dan Gohman wrote:
> Hello,
>
> Attached is a patch which adds support for using "-", meaning stdin,
> as the filename in the -code-completion-at option.
>
> I used this to implement an experimental code-completion mode for
> vim, in llvm/utils/vim/vimrc.
Nifty. The patch seems to thread PremadeBuffer through a lot of routines, e.g.,
Index: include/clang/Basic/SourceManager.h
===================================================================
--- include/clang/Basic/SourceManager.h (revision 117040)
+++ include/clang/Basic/SourceManager.h (working copy)
@@ -446,9 +446,13 @@
FileID getMainFileID() const { return MainFileID; }
/// createMainFileID - Create the FileID for the main source file.
- FileID createMainFileID(const FileEntry *SourceFile) {
+ /// If PremadeBuffer is non-null, install it as the contents for the
+ /// main source file.
+ FileID createMainFileID(const FileEntry *SourceFile,
+ const llvm::MemoryBuffer *PremadeBuffer = 0) {
assert(MainFileID.isInvalid() && "MainFileID already set!");
- MainFileID = createFileID(SourceFile, SourceLocation(), SrcMgr::C_User);
+ MainFileID = createFileID(SourceFile, SourceLocation(), SrcMgr::C_User,
+ 0, 0, PremadeBuffer);
return MainFileID;
}
but there is already an existing mechanism for overridding the contents of a file in SourceManager::overrideFileContents(). Can we get more re-use out of that code?
- Doug
More information about the cfe-commits
mailing list