New AST node to access "implicit" setter/getter using property dor syntax.
Issuing diagnostics when assigning to read-only properties.
This is work in progress.
Chris Lattner [Sat, 22 Nov 2008 08:28:49 +0000 (08:28 +0000)]
move the Diag method for Sema to be inline. This shrinks the release-asserts
clang executable (when built with gcc 4.2 on the mac) from 14519740 to 14495028 bytes. This shrinks individual object files as well: SemaChecking
from 23580->22248, SemaDeclObjc from 61368->57376, SemaExpr from
115628->110516, as well as several others.
Chris Lattner [Sat, 22 Nov 2008 07:39:03 +0000 (07:39 +0000)]
Fix a weird inconsistency with hex floats. Previously the lexer
would not eat the "-1" in "0x0p-1", but LiteralSupport would accept
it when extensions are on. This caused strangeness and failures
when hexfloats were properly treated as an extension (not error)
in LiteralSupport.
Chris Lattner [Sat, 22 Nov 2008 07:23:31 +0000 (07:23 +0000)]
remove the NumericLiteralParser::Diag helper method, inlining it into
its call sites. This makes it more explicit when the hasError flag is
getting set and removes a confusing difference in behavior between
PP.Diag and Diag in this code.
Chris Lattner [Sat, 22 Nov 2008 07:03:46 +0000 (07:03 +0000)]
Move the Preprocessor::Diag methods inline. This has the interesting
(and carefully calculated) effect of allowing the compiler to reason
about the aliasing properties of DiagnosticBuilder object better,
allowing the whole thing to be promoted to registers instead of
resulting in a ton of stack traffic.
While I'm not very concerned about the performance of the Diag() method
invocations, I *am* more concerned about their code size and impact on the
non-diagnostic code. This patch shrinks the clang executable (in
release-asserts mode with gcc-4.2) from 14523980 to 14519816 bytes. This
isn't much, but it shrinks the lexer from 38192 to 37776, PPDirectives.o
from 31116 to 28868 bytes, etc.
Chris Lattner [Sat, 22 Nov 2008 02:02:22 +0000 (02:02 +0000)]
Change the Lexer::Diag method to not magically silence warnings,
force the caller to check instead. This eliminates the need (and the
risk!) of weird null DiagnosticBuilder's floating around.
Chris Lattner [Sat, 22 Nov 2008 00:59:29 +0000 (00:59 +0000)]
Split the DiagnosticInfo class into two disjoint classes:
one for building up the diagnostic that is in flight (DiagnosticBuilder)
and one for pulling structured information out of the diagnostic when
formatting and presenting it.
Sebastian Redl [Fri, 21 Nov 2008 19:14:01 +0000 (19:14 +0000)]
Implementation of new and delete parsing and sema.
This version uses VLAs to represent arrays. I'll try an alternative way next, but I want this safe first.
Chris Lattner [Fri, 21 Nov 2008 07:50:02 +0000 (07:50 +0000)]
Add the concept of "modifiers" to the clang diagnostic format
strings. This allows us to have considerable flexibility in how
these things are displayed and provides extra information that
allows us to merge away diagnostics that are very similar.
Diagnostic modifiers are a string of characters with the regex
[-a-z]+ that occur between the % and digit. They may
optionally have an argument that can parameterize them.
For now, I've added two example modifiers. One is a very useful
tool that allows you to factor commonality across diagnostics
that need single words or phrases combined. Basically you can
use %select{a|b|c}4 with with an integer argument that selects
either a/b/c based on an integer value in the range [0..3).
The second modifier is also an integer modifier, aimed to help
English diagnostics handle plurality. "%s3" prints to 's' if
integer argument #3 is not 1, otherwise it prints to nothing.
I'm fully aware that 's' is an English concept and doesn't
apply to all situations (mouse vs mice). However, this is very
useful and we can add other crazy modifiers once we add support
for polish! ;-)
I converted a couple C++ diagnostics over to use this as an
example, I'd appreciate it if others could merge the other
likely candiates. If you have other modifiers that you want,
lets talk on cfe-dev.
Chris Lattner [Fri, 21 Nov 2008 06:59:12 +0000 (06:59 +0000)]
move the diagnostic location and ID out of DiagnosticInfo and store it in
the Diagnostic class. Since we can already only have one diagnostic in
flight at a time, this shrinks DiagnosticInfo.
This reduces DiagnosticInfo to being basically a rather crazy smart pointer
to a DiagnosticInfo :)
Chris Lattner [Fri, 21 Nov 2008 06:54:20 +0000 (06:54 +0000)]
move diagnostic insertion methods to be free methods instead of
in the DiagnosticInfo class. This requires marking them as taking
a const DiagnosticInfo, which is bogus (they logically mutate DI),
but works with the C++ type system.
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*.