[cfe-commits] r90701 - in /cfe/trunk: include/clang/Basic/SourceManager.h lib/Lex/PPLexerChange.cpp test/Preprocessor/open-failure.c
Daniel Dunbar
daniel at zuster.org
Sun Dec 6 01:19:25 PST 2009
Author: ddunbar
Date: Sun Dec 6 03:19:25 2009
New Revision: 90701
URL: http://llvm.org/viewvc/llvm-project?rev=90701&view=rev
Log:
Unbreak and add test case for r90276, a situation in which getBuffer is expected to fail.
Also, update SourceManager.h doxyments for getBuffer() to reflect reality.
Added:
cfe/trunk/test/Preprocessor/open-failure.c
Modified:
cfe/trunk/include/clang/Basic/SourceManager.h
cfe/trunk/lib/Lex/PPLexerChange.cpp
Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=90701&r1=90700&r2=90701&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Sun Dec 6 03:19:25 2009
@@ -70,8 +70,8 @@
unsigned NumLines;
/// getBuffer - Returns the memory buffer for the associated content. If
- /// there is an error opening this buffer the first time, this returns null
- /// and fills in the ErrorStr with a reason.
+ /// there is an error opening this buffer the first time, this manufactures
+ /// a temporary buffer and returns a non-empty error string.
const llvm::MemoryBuffer *getBuffer(std::string *ErrorStr = 0) const;
/// getSize - Returns the size of the content encapsulated by this
@@ -426,10 +426,9 @@
// FileID manipulation methods.
//===--------------------------------------------------------------------===//
- /// getBuffer - Return the buffer for the specified FileID. If there is an
- /// error opening this buffer the first time, this returns null and fills in
- /// the ErrorStr with a reason.
- ///
+ /// getBuffer - Return the buffer for the specified FileID. If there is an
+ /// error opening this buffer the first time, this manufactures a temporary
+ /// buffer and returns a non-empty error string.
const llvm::MemoryBuffer *getBuffer(FileID FID, std::string *Error = 0) const{
return getSLocEntry(FID).getFile().getContentCache()->getBuffer(Error);
}
Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=90701&r1=90700&r2=90701&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPLexerChange.cpp (original)
+++ cfe/trunk/lib/Lex/PPLexerChange.cpp Sun Dec 6 03:19:25 2009
@@ -81,8 +81,8 @@
// Get the MemoryBuffer for this FID, if it fails, we fail.
const llvm::MemoryBuffer *InputFile =
- if (InputFile == 0)
getSourceManager().getBuffer(FID, &ErrorStr);
+ if (!ErrorStr.empty())
return true;
EnterSourceFileWithLexer(new Lexer(FID, InputFile, *this), CurDir);
Added: cfe/trunk/test/Preprocessor/open-failure.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/open-failure.c?rev=90701&view=auto
==============================================================================
--- cfe/trunk/test/Preprocessor/open-failure.c (added)
+++ cfe/trunk/test/Preprocessor/open-failure.c Sun Dec 6 03:19:25 2009
@@ -0,0 +1,11 @@
+// RUN: rm -rf %t.dir
+// RUN: mkdir %t.dir
+// RUN: echo 'void f0();' > %t.dir/t.h
+// RUN: chmod 000 %t.dir/t.h
+// RUN: clang-cc -verify -I %t.dir %s
+
+// FIXME: Is there a way to test this on Windows?
+// XFAIL: win32
+
+#include "t.h" // expected-error {{Permission denied}}
+int f0(void);
More information about the cfe-commits
mailing list