Chris Lattner [Fri, 21 Nov 2008 01:18:36 +0000 (01:18 +0000)]
Change -verify mode to find the "expected-error" and "expected-warning" strings
with a raw lexer instead of a PP lexer. This means that -verify doesn't scan
#include'd headers for expected-error/warning strings, and it also means that it
doesn't ignore them in #if 0.
Ted Kremenek [Fri, 21 Nov 2008 00:58:35 +0000 (00:58 +0000)]
PTHLexer:
- Move out logic for handling the end-of-file to LexEndOfFile (to match the Lexer) class. The logic now mirrors the Lexer class more, which allows us to pass most of the Preprocessor test cases.
Ted Kremenek [Thu, 20 Nov 2008 16:32:22 +0000 (16:32 +0000)]
PTHLexer:
- Rename 'CurToken' and 'LastToken' to 'CurTokenIdx' and 'LastTokenIdx'
respectively.
- Add helper methods GetToken(), AdvanceToken(), AtLastToken() to abstract away
details of the token stream. This also allows us to easily replace their
implementation later.
Ted Kremenek [Thu, 20 Nov 2008 16:14:48 +0000 (16:14 +0000)]
Output 'ANALYZE' messages to standard error. This should address the intermixing of 'ANALYZE' and the other diagnostics the clang driver emits to standard error.
Daniel Dunbar [Thu, 20 Nov 2008 08:01:39 +0000 (08:01 +0000)]
De-unionize fields in Token class.
- This is fairly gross but although the code is conceptually the
same, introducting the union causes gcc 4.2 on x86 (darwin, if that
matters) to pessimize LexTokenInternal which is critical to our
preprocessor performance.
This speeds up -Eonly lexing of Cocoa.h by ~4.7% in my timings and
reduces the code size of LexTokenInternal by 8.6%.
Ted Kremenek [Thu, 20 Nov 2008 07:56:33 +0000 (07:56 +0000)]
Add ugly "test harness" for PTHLexer that is not enabled by default. The
(temporary hack) to test the PTHLexer is that whenever we would create a Lexer
object we instead raw lex a memory buffer first and then use the PTHLexer. This
logic exists only to driver the PTHLexer and will be removed/changed in the
future. Note that the regular path using normal Lexer objects is what is used by
default.
Chris Lattner [Thu, 20 Nov 2008 05:51:55 +0000 (05:51 +0000)]
remove the type_info identifier cache. Compared to the cost
of doing the lookup_decl, the hash lookup is cheap. Also,
typeid doesn't happen enough in real world code to worry about
it.
I'd like to eventually get rid of KnownFunctionIDs from Sema
also, but today is not that day.
Chris Lattner [Thu, 20 Nov 2008 05:45:14 +0000 (05:45 +0000)]
compared to the rest of the code in Sema::GetStdNamespace(),
looking up the "std" identifier is trivial. Just do it, particularly
since this is only done if the namespace hasn't already been looked up.
Chris Lattner [Thu, 20 Nov 2008 04:42:34 +0000 (04:42 +0000)]
Rename IdentifierInfo::isName to ::isStr. Use a nifty trick
from Sebastian to enforce that a literal string is passed in,
and use this to avoid having to call strlen on it.
Ted Kremenek [Thu, 20 Nov 2008 01:49:44 +0000 (01:49 +0000)]
Preprocessor::getCurrentFileLexer() now returns a PreprocessorLexer* instead of
a Lexer*. This means it will either return the current (normal) file Lexer or a
PTHLexer.
Ted Kremenek [Thu, 20 Nov 2008 01:45:11 +0000 (01:45 +0000)]
Just use the SourceLocation of SysHeaderTok when doing a callback to emit #line
information. A diff of the -E output for Cocoa.h shows that there is no change
in output.
More objc gc stuff. Read/Write barriers for local static/extern,
diagnostics on use of __weak attribute on fields,
Early support for read/write barriers for objc fields.
Douglas Gregor [Wed, 19 Nov 2008 22:57:39 +0000 (22:57 +0000)]
Implement the rest of C++ [over.call.object], which permits the object
being called to be converted to a reference-to-function,
pointer-to-function, or reference-to-pointer-to-function. This is done
through "surrogate" candidate functions that model the conversions
from the object to the function (reference/pointer) and the
conversions in the arguments.
Ted Kremenek [Wed, 19 Nov 2008 22:55:25 +0000 (22:55 +0000)]
Use PreprocessorLexer::getFileID() instead of Lexer::getFileLoc(). This is an intermediate step to having getCurrentLexer() return a PreprocessorLexer* instead of a Lexer*.
Ted Kremenek [Wed, 19 Nov 2008 21:57:25 +0000 (21:57 +0000)]
- Move static function IsNonPragmaNonMacroLexer into Preprocessor.h.
- Add variants of IsNonPragmaNonMacroLexer to accept an IncludeMacroStack entry
(simplifies some uses).
- Use IsNonPragmaNonMacroLexer in Preprocessor::LookupFile.
- Add 'FileID' to PreprocessorLexer, and have Preprocessor query this fileid
when looking up the FileEntry for a file
Performance testing of -Eonly on Cocoa.h shows no performance regression because
of this patch.
Douglas Gregor [Wed, 19 Nov 2008 21:05:33 +0000 (21:05 +0000)]
Support for calling overloaded function call operators (operator())
with function call syntax, e.g.,
Functor f;
f(x, y);
This is the easy part of handling calls to objects of class type
(C++ [over.call.object]). The hard part (coping with conversions from
f to function pointer or reference types) will come later. Nobody uses
that stuff anyway, right? :)
struct A::B {
void m() {} // Assertion failed: getContainingDC(DC) == CurContext && "The next DeclContext should be lexically contained in the current one."
};
Introduce DeclContext::getLexicalParent which may be different from DeclContext::getParent when nested-names are involved, e.g:
namespace A {
struct S;
}
struct A::S {}; // getParent() == namespace 'A'
// getLexicalParent() == translation unit
Steve Naroff [Wed, 19 Nov 2008 15:54:23 +0000 (15:54 +0000)]
Fix <rdar://problem/6150376> [sema] crash on invalid message send.
The core fix in Sema::ActOnClassMessage(). All the other changes have to do with passing down the SourceLocation for the receiver (to properly position the cursor when producing an error diagnostic).
Douglas Gregor [Wed, 19 Nov 2008 15:42:04 +0000 (15:42 +0000)]
Added operator overloading for unary operators, post-increment, and
post-decrement, including support for generating all of the built-in
operator candidates for these operators.
C++ and C have different rules for the arguments to the builtin unary
'+' and '-'. Implemented both variants in Sema::ActOnUnaryOp.
In C++, pre-increment and pre-decrement return lvalues. Update
Expr::isLvalue accordingly.
An assert is hit:
Assertion failed: CachedTokens[CachedLexPos-1].getLocation() == Tok.getAnnotationEndLoc() && "The annotation should be until the most recent cached token", file ..\..\lib\Lex\PPCaching.cpp, line 98
Introduce Preprocessor::RevertCachedTokens that reverts a specific number of tokens when backtracking is enabled.
Daniel Dunbar [Wed, 19 Nov 2008 09:36:46 +0000 (09:36 +0000)]
Fix redundant load of bit-fields on assignment (to get the updated
value).
- Use extra argument to EmitStoreThroughLValue to provide place to
write update bit-field value if caller requires it.
- This fixes several FIXMEs.
Chris Lattner [Wed, 19 Nov 2008 06:51:40 +0000 (06:51 +0000)]
rewrite FormatDiagnostic to be less gross and a lot more efficient.
This also makes it illegal to have bare '%'s in diagnostics. If you
want a % in a diagnostic, use %%.
Chris Lattner [Wed, 19 Nov 2008 06:04:55 +0000 (06:04 +0000)]
implement a transparent optimization with the diagnostics stuff:
const char*'s are now not converted to std::strings when the diagnostic
is formed, we just hold onto their pointer and format as needed.
This commit makes DiagnosticClient::FormatDiagnostic even more of a
mess, I'll fix it in the next commit.
Chris Lattner [Wed, 19 Nov 2008 05:08:23 +0000 (05:08 +0000)]
Switch several more Sema Diag methods over. This simplifies the
__builtin_prefetch code to only emit one diagnostic per builtin_prefetch.
While this has nothing to do with the rest of the patch, the code seemed
like overkill when I was updating it.