[cfe-commits] r117414 - in /cfe/trunk: include/clang/Frontend/CommandLineSourceLoc.h lib/Frontend/CompilerInstance.cpp test/CodeCompletion/stdin.c
Dan Gohman
gohman at apple.com
Tue Oct 26 16:21:26 PDT 2010
Author: djg
Date: Tue Oct 26 18:21:25 2010
New Revision: 117414
URL: http://llvm.org/viewvc/llvm-project?rev=117414&view=rev
Log:
Add support for code completion on stdin.
Added:
cfe/trunk/test/CodeCompletion/stdin.c
Modified:
cfe/trunk/include/clang/Frontend/CommandLineSourceLoc.h
cfe/trunk/lib/Frontend/CompilerInstance.cpp
Modified: cfe/trunk/include/clang/Frontend/CommandLineSourceLoc.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CommandLineSourceLoc.h?rev=117414&r1=117413&r2=117414&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/CommandLineSourceLoc.h (original)
+++ cfe/trunk/include/clang/Frontend/CommandLineSourceLoc.h Tue Oct 26 18:21:25 2010
@@ -37,9 +37,15 @@
// If both tail splits were valid integers, return success.
if (!ColSplit.second.getAsInteger(10, PSL.Column) &&
- !LineSplit.second.getAsInteger(10, PSL.Line))
+ !LineSplit.second.getAsInteger(10, PSL.Line)) {
PSL.FileName = LineSplit.first;
+ // On the command-line, stdin may be specified via "-". Inside the
+ // compiler, stdin is called "<stdin>".
+ if (PSL.FileName == "-")
+ PSL.FileName = "<stdin>";
+ }
+
return PSL;
}
};
Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=117414&r1=117413&r2=117414&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Tue Oct 26 18:21:25 2010
@@ -479,7 +479,10 @@
Diags.Report(diag::err_fe_error_reading_stdin);
return false;
}
- SourceMgr.createMainFileIDForMemBuffer(SB);
+ const FileEntry *File = FileMgr.getVirtualFile(SB->getBufferIdentifier(),
+ SB->getBufferSize(), 0);
+ SourceMgr.createMainFileID(File);
+ SourceMgr.overrideFileContents(File, SB);
}
assert(!SourceMgr.getMainFileID().isInvalid() &&
Added: cfe/trunk/test/CodeCompletion/stdin.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/stdin.c?rev=117414&view=auto
==============================================================================
--- cfe/trunk/test/CodeCompletion/stdin.c (added)
+++ cfe/trunk/test/CodeCompletion/stdin.c Tue Oct 26 18:21:25 2010
@@ -0,0 +1,7 @@
+enum X { x };
+enum Y { y };
+
+enum
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=-:4:6 < %s -o - | FileCheck -check-prefix=CC1 %s
+ // CHECK-CC1: X
+ // CHECK-CC1: Y
More information about the cfe-commits
mailing list