Commit Graph

3177 Commits

Author SHA1 Message Date
Fariborz Jahanian 2f85a6450a Detailed documentation for encoding of properties and a test
case.

llvm-svn: 62607
2009-01-20 20:04:12 +00:00
Steve Naroff 5faaef7692 Allocate expresssions through ASTContext (still more work to do).
Add debug hook to DeclContext.

llvm-svn: 62605
2009-01-20 19:53:53 +00:00
Fariborz Jahanian 218c630171 Improving on encoding of objective-c's property types. More to come.
llvm-svn: 62601
2009-01-20 19:14:18 +00:00
Chris Lattner 1ce41edd8d Optimize Declarator to avoid malloc/free traffic for the argument list of a
function DeclaratorChunk in common cases.  This uses a fixed array in 
Declarator when it is small enough for the first function declarator chunk
in a declarator.

This eliminates all malloc/free traffic from DeclaratorChunk::getFunction
when running on Cocoa.h except for five functions: signal/bsd_signal/sigset,
which have multiple Function DeclChunk's, and 
CFUUIDCreateWithBytes/CFUUIDGetConstantUUIDWithBytes, which take more than
16 arguments.

This patch was pair programmed with Steve.

llvm-svn: 62599
2009-01-20 19:11:22 +00:00
Eli Friedman ddea0ade30 Slight cleanup, and fix for va_arg on architectures where va_list is a
struct.

llvm-svn: 62585
2009-01-20 17:46:04 +00:00
Eli Friedman 8687a09fd0 Do codegen correctly for va_start/end/copy on architectures where
va_list is a struct, like x86-64.

If anyone has a better idea for how to do the check in the if 
statements, suggestions are welcome.

llvm-svn: 62582
2009-01-20 17:25:25 +00:00
Douglas Gregor 0da5ac8499 Rename DeclContext::insert to DeclContext::makeDeclVisibleInContext and document both it and DeclContext::addDecl properly
llvm-svn: 62581
2009-01-20 16:54:50 +00:00
Eli Friedman 08c5dabf1b Fix for PR3350: add special-casing for "references" to va_lists in
builtins.

Also, a minor tweak to va_copy for consistency.

llvm-svn: 62574
2009-01-20 07:46:22 +00:00
Douglas Gregor 00447933f6 Remove the TopLevelDecls from TranslationUnit, since all of those decls are owned by the ASTContext's TranslationUnitDecl. There are definitely some leaking Decls now that I'll tackle tomorrow
llvm-svn: 62568
2009-01-20 04:25:11 +00:00
Douglas Gregor 6e6ad602e5 Remove ScopedDecl, collapsing all of its functionality into Decl, so
that every declaration lives inside a DeclContext.

Moved several things that don't have names but were ScopedDecls (and,
therefore, NamedDecls) to inherit from Decl rather than NamedDecl,
including ObjCImplementationDecl and LinkageSpecDecl. Now, we don't
store empty DeclarationNames for these things, nor do we try to insert
them into DeclContext's lookup structure.

The serialization tests are temporarily disabled. We'll re-enable them
once we've sorted out the remaining ownership/serialiazation issues
between DeclContexts and TranslationUnion, DeclGroups, etc.

llvm-svn: 62562
2009-01-20 01:17:11 +00:00
Daniel Dunbar 9789e1ebcb Update for new SourceLocation API.
llvm-svn: 62556
2009-01-20 01:06:30 +00:00
Ted Kremenek e5fe617e2b Dead stores checker: Fix <rdar://problem/6506065> by being more selective when say that a store is dead even though the computed value is used in the enclosing expression.
llvm-svn: 62552
2009-01-20 00:47:45 +00:00
Ted Kremenek 8433f0b400 PTH: Emitted tokens now consist of 12 bytes that are loaded used 3 32-bit loads. This reduces user time but increases system time because of the slightly larger PTH file. Although there is no performance win on Cocoa.h and -Eonly, overall this seems like a good step.
llvm-svn: 62542
2009-01-19 23:13:15 +00:00
Steve Naroff d21d7226b1 Make sure all types are allocated with 8-byte alignment.
The QualType smart pointer assumes we have 3 flag bits available.

llvm-svn: 62540
2009-01-19 22:45:10 +00:00
Sebastian Redl b5d49356e6 Convert more expression actions to smart pointers.
llvm-svn: 62537
2009-01-19 22:31:54 +00:00
Ted Kremenek 721e239f2b Allocate Types using ASTContext's 'Allocator' object.
llvm-svn: 62530
2009-01-19 21:31:22 +00:00
Fariborz Jahanian 54fa418d03 Type of property and its ivar is more restrictive
that rules for assignment.

llvm-svn: 62524
2009-01-19 20:13:47 +00:00
Douglas Gregor dd430f7ec9 Centralize error reporting of improper uses of incomplete types in the
new DiagnoseIncompleteType. It provides additional information about
struct/class/union/enum types when possible, either by pointing to the
forward declaration of that type or by pointing to the definition (if
we're in the process of defining that type). 
Fixes <rdar://problem/6500531>.

llvm-svn: 62521
2009-01-19 19:26:10 +00:00
Fariborz Jahanian dab04840f0 Patch to allow @dynamic synthesis of property in a category,
with @synthesize being illegal.

llvm-svn: 62515
2009-01-19 18:16:19 +00:00
Chris Lattner 4fd8b958be do not use SourceManager::getFileCharacteristic(FileID), it is not
safe because a #line can change the file characteristic on a per-loc
basis.

llvm-svn: 62502
2009-01-19 08:01:53 +00:00
Chris Lattner c033416639 do not use SourceManager::getFileCharacteristic(FileID), it is not
safe because a #line can change the file characteristic on a per-loc
basis.

llvm-svn: 62501
2009-01-19 07:59:15 +00:00
Chris Lattner cbc35ecb04 Rename SourceManager::getCanonicalFileID -> getFileID. There is
no longer such thing as a non-canonical FileID.

llvm-svn: 62499
2009-01-19 07:46:45 +00:00
Ted Kremenek 8c3b812148 Run destructors of MacroInfo objects to free memory they allocate. This addresses <rdar://problem/6506035>.
llvm-svn: 62498
2009-01-19 07:45:44 +00:00
Chris Lattner 1e9e86f470 remove the public SourceManager::getContentCacheForLoc method.
llvm-svn: 62497
2009-01-19 07:40:40 +00:00
Chris Lattner f809bbdbb8 remove the SourceManager:: and FullSourceLoc::getFileEntryForLoc methods.
llvm-svn: 62496
2009-01-19 07:36:42 +00:00
Chris Lattner 7e343b2161 SourceManager::getBufferData(SourceLocation) is dead, delete it.
llvm-svn: 62495
2009-01-19 07:32:13 +00:00
Chris Lattner 91fda39454 some minor cleanups to SourceManager, and eliminate the
SourceManager::getBuffer(SourceLocation) method.

llvm-svn: 62494
2009-01-19 07:30:29 +00:00
Chris Lattner 02495d80ef Make some enums in SourceLocation private, remove a useless assertion from ScratchBuffer.
llvm-svn: 62492
2009-01-19 06:57:37 +00:00
Chris Lattner 29a2a191f2 Make SourceLocation::getFileLoc private to reduce the API exposure of
SourceLocation.  This requires making some cleanups to token pasting
and _Pragma expansion.

llvm-svn: 62490
2009-01-19 06:46:35 +00:00
Sebastian Redl c215cfc3e1 Convert more expression actions to smart pointers.
Fix type of logical negation for C++.

llvm-svn: 62475
2009-01-19 00:08:26 +00:00
Chris Lattner fc014f80e5 fix rdar://6505352 - Bogus warning with -WUndef, a case
Anders noticed.

llvm-svn: 62472
2009-01-18 21:18:58 +00:00
Nuno Lopes 9018ca711a fix deallocation of FunctionDecl::ParamInfo
llvm-svn: 62469
2009-01-18 19:57:27 +00:00
Sebastian Redl ffbcf96d1c Convert a few expression actions to smart pointers.
These actions are extremely widely used (identifier expressions and literals); still no performance regression.

llvm-svn: 62468
2009-01-18 18:53:16 +00:00
Sebastian Redl c2edafbdff Rename move_convert to move_arg and move_res. The new names are less misleading (and shorter).
llvm-svn: 62466
2009-01-18 18:03:53 +00:00
Sebastian Redl 481bf3f48b Convert ObjC statement actions to smart pointers.
llvm-svn: 62465
2009-01-18 17:43:11 +00:00
Sebastian Redl 24b8e15dfa Convert asm statement action to smart pointers.
llvm-svn: 62464
2009-01-18 16:53:17 +00:00
Sebastian Redl 573feed2a8 Convert more statement actions to smart pointers.
llvm-svn: 62463
2009-01-18 13:19:59 +00:00
Chris Lattner c671e061eb Switch MinimalAction from new/delete'ing its TypeNameInfo to
allocating them from a recycling bump pointer allocator.  This 
reduces malloc/free traffic of parse-noop (but no other mode),
which makes sharking -parse-noop more meaningful.

llvm-svn: 62460
2009-01-18 09:39:41 +00:00
Nate Begeman b699c9bf57 Vector codegen improvements
llvm-svn: 62458
2009-01-18 06:42:49 +00:00
Nate Begeman 2f2bdeb5df Support evaluation of vector constant expressions, and codegen of same.
llvm-svn: 62455
2009-01-18 03:20:47 +00:00
Chris Lattner 144aacd19e rearrange GetIdentifierInfo so that the fast path can be partially inlined into PTHLexer::Lex. This speeds up the user time of PTH -Eonly by another 2ms (4.4%)
llvm-svn: 62454
2009-01-18 02:57:21 +00:00
Chris Lattner 18fc6ceb56 rename some variables, only set a tokens identifierinfo if non-null.
llvm-svn: 62450
2009-01-18 02:34:01 +00:00
Chris Lattner 9cdd877436 On i386 and x86-64, just do unaligned loads
instead of assembling from bytes.  This speeds up -Eonly PTH reading 
of cocoa.h by about 2ms, which is 4.2%.

llvm-svn: 62447
2009-01-18 02:19:16 +00:00
Anders Carlsson e70cde134e Handle the 'X' constraint. Fixes <rdar://problem/6504897>.
llvm-svn: 62446
2009-01-18 02:12:04 +00:00
Chris Lattner 137d6492a8 switch PTHLexer to use Read32 and friends instead of lots of inlined
copies.  I verified that this causes no performance change in PTH.

llvm-svn: 62445
2009-01-18 02:10:31 +00:00
Anders Carlsson a92271d067 CG support for inline asm constraints with symbolic names. Fixes PR3345
llvm-svn: 62444
2009-01-18 02:06:20 +00:00
Nate Begeman 7e5185b264 A couple more vector component access fixes.
llvm-svn: 62443
2009-01-18 02:01:21 +00:00
Chris Lattner eb09754a9d switch PTH lexer from using "const char*"s to "const unsigned char*"s
internally.  This is just a cleanup that reduces the need to cast to
unsigned char before assembling a larger integer.

llvm-svn: 62442
2009-01-18 01:57:14 +00:00
Anders Carlsson a79203be85 Add sema support for symbolic names in inline asm statements.
llvm-svn: 62441
2009-01-18 01:56:57 +00:00
Nate Begeman bb70bf6dbb Update support for vector component access on ExtVectors.
llvm-svn: 62440
2009-01-18 01:47:54 +00:00
Nate Begeman 95439108e8 Fit in 80 cols
llvm-svn: 62439
2009-01-18 01:08:03 +00:00
Nate Begeman 1e31b168fa Add support for vectors to APValue. Vector constant evaluator and tests coming.
llvm-svn: 62438
2009-01-18 01:01:34 +00:00
Nate Begeman c1bf0612dd Remove outdated diagnostic. Tests are coming.
llvm-svn: 62437
2009-01-18 00:45:31 +00:00
Nate Begeman a45707c06a Allow targets to override IntMaxTWidth
llvm-svn: 62434
2009-01-17 23:56:13 +00:00
Anders Carlsson 19aa04d270 Change TargetInfo::validateInputConstraint to take begin/end name iterators instead of the number of outputs. No functionality change.
llvm-svn: 62433
2009-01-17 23:36:15 +00:00
Fariborz Jahanian 18789e1c21 Diagnose that property name cannot be a bitfield
llvm-svn: 62432
2009-01-17 23:21:10 +00:00
Fariborz Jahanian 091ae97786 Diagnose when method parameter is an object.
llvm-svn: 62431
2009-01-17 21:57:49 +00:00
Fariborz Jahanian 705c6d9cdd Patch to re-implement ivar-list meta-data generation to fix
cases of unnamed ivar bitfields.

llvm-svn: 62429
2009-01-17 19:36:33 +00:00
Chris Lattner 71dc14b9f0 Rename SourceLocation::getFileID to getChunkID, because it returns
the chunk ID not the file ID.  This exposes problems in 
TextDiagnosticPrinter where it should have been using the canonical
file ID but wasn't.  Fix these along the way.

llvm-svn: 62427
2009-01-17 08:45:21 +00:00
Chris Lattner 5509d533f6 simplify some lookups.
llvm-svn: 62426
2009-01-17 08:30:10 +00:00
Chris Lattner 757169b60f Change the Lexer ctor used to lex _Pragma directives into a static factory
method.  This lets us clean up the interface and make it more obvious that
this method is *really really* _Pragma specific.

Note that _Pragma handling uglifies the Lexer in the critical path.  It would
be very interesting to consider making _Pragma remapping be a new special
lexer class of its own.

llvm-svn: 62425
2009-01-17 08:27:52 +00:00
Chris Lattner ab1d4b8abd simplify PTHManager::CreateLexer
llvm-svn: 62424
2009-01-17 08:06:50 +00:00
Chris Lattner c809089b26 Change the Lexer ctor used in the non _Pragma case to take a FileID instead
of a SourceLocation.  This should speed it up and definitely simplifies it.

llvm-svn: 62422
2009-01-17 08:03:42 +00:00
Chris Lattner 8ddb5cf0cf in Preprocessor::AdvanceToTokenCharacter, don't actually bother
creating a whole lexer when we just want one static method.

llvm-svn: 62420
2009-01-17 07:57:25 +00:00
Chris Lattner 5965a28a4b More simplifications to the lexer ctors.
llvm-svn: 62419
2009-01-17 07:56:59 +00:00
Chris Lattner fcf6452eb4 make the verbose raw-lexer ctor fully explicit instead of having
embedded magic.

llvm-svn: 62417
2009-01-17 07:42:27 +00:00
Chris Lattner 08354fef13 add a simplified lexer ctor that sets up the lexer to raw-lex an
entire file.

llvm-svn: 62414
2009-01-17 07:35:14 +00:00
Chris Lattner f76b92092e refactor some common initialization code out of the two lexer ctors.
llvm-svn: 62411
2009-01-17 06:55:17 +00:00
Chris Lattner 3793bba26f suck the call to "getSpellingLoc" that all clients do into
the implementation of PTHManager::getSpelling.

llvm-svn: 62408
2009-01-17 06:29:33 +00:00
Chris Lattner d32480d3db this massive patch introduces a simple new abstraction: it makes
"FileID" a concept that is now enforced by the compiler's type checker
instead of yet-another-random-unsigned floating around.

This is an important distinction from the "FileID" currently tracked by
SourceLocation.  *That* FileID may refer to the start of a file or to a
chunk within it.  The new FileID *only* refers to the file (and its 
#include stack and eventually #line data), it cannot refer to a chunk.

FileID is a completely opaque datatype to all clients, only SourceManager
is allowed to poke and prod it.

llvm-svn: 62407
2009-01-17 06:22:33 +00:00
Chris Lattner 800979259e make "ContentCache::Buffer" mutable to avoid a const_cast.
llvm-svn: 62403
2009-01-17 03:54:16 +00:00
Chris Lattner 1abd20901b Instead of iterating over FileID's, have PTH generation iterate over the
content cache directly.  Content cache has a 1-1 mapping with fileentries,
whereas multiple FileIDs can be the same FileEntry.

llvm-svn: 62401
2009-01-17 03:48:08 +00:00
Douglas Gregor 051d8fd809 Warn about typedefs of enums without any declarator name. Fixes rdar://problem/6503878
llvm-svn: 62397
2009-01-17 02:55:50 +00:00
Ted Kremenek 1ab188f48a Fix analyzer crash found when scanning Wine sources where the analyzer used old logic to determine the value of a switch 'case' label.
llvm-svn: 62395
2009-01-17 01:54:16 +00:00
Douglas Gregor f23311d63b PODify LookupResult, for a measly 1% speedup on Cocoa.h.
llvm-svn: 62391
2009-01-17 01:13:24 +00:00
Nuno Lopes 4d78cf0fa7 add support for usage of cast to union thing with static vars
llvm-svn: 62387
2009-01-17 00:48:48 +00:00
Douglas Gregor dee1be8e95 Teach DeclContext how to find the primary declaration for any TagDecl
even when we are still defining the TagDecl. This is required so that
qualified name lookup of a class name within its definition works (see
the new bits in test/SemaCXX/qualified-id-lookup.cpp).

As part of this, move the nested redefinition checking code into
ActOnTag. This gives us diagnostics earlier (when we try to perform
the nested redefinition, rather than when we try to complete the 2nd
definition) and removes some code duplication.

llvm-svn: 62386
2009-01-17 00:42:38 +00:00
Fariborz Jahanian 94234ea63e Catch a foreach parse error.
llvm-svn: 62382
2009-01-17 00:00:40 +00:00
Sebastian Redl fbfaafc0a9 Convert some more statement actions to smart pointers.
Fix a type error; parser wanted to pass the third part of a for-statement as a statement; should be expression.

llvm-svn: 62380
2009-01-16 23:28:06 +00:00
Chris Lattner 48a8c57936 eliminate FullSourceLoc::getLocation() now that FullSourceLoc
*is* the location.  This eliminates some weird X.getLocation().getLocation()'s.

llvm-svn: 62376
2009-01-16 23:06:35 +00:00
Chris Lattner fb1fd911cb Make FullSourceLoc derive from SourceLocation instead of
containing one.  Containment is generally better than derivation,
but in this case FullSourceLoc really 'isa' SourceLocation.

llvm-svn: 62375
2009-01-16 23:03:56 +00:00
Chris Lattner fcc0a5a3f7 elimiante FullSourceLoc::getCanonicalFileID
llvm-svn: 62374
2009-01-16 22:59:51 +00:00
Chris Lattner 7067b4f49d remove FullSourceLoc::isFileID
llvm-svn: 62371
2009-01-16 22:53:56 +00:00
Chris Lattner 671689a440 an instantiation loc is always a file loc.
llvm-svn: 62370
2009-01-16 22:53:27 +00:00
Chris Lattner 5882771102 Fix PR2477 - clang misparses "//*" in C89 mode
llvm-svn: 62368
2009-01-16 22:39:25 +00:00
Fariborz Jahanian 10401ce2e0 Don't ICE (issue diagnostics) when receiver is a non-objc
type.

llvm-svn: 62355
2009-01-16 20:35:09 +00:00
Fariborz Jahanian 1778f4bf6d Don't ICE on user redeclaration of objc's built-in types.
Issue diagnostics instead if types do not match.

llvm-svn: 62349
2009-01-16 19:58:32 +00:00
Chris Lattner 5244f34e75 As a performance optimization, don't bother calling MacroInfo::isIdenticalTo
if warnings in system headers are disabled.  isIdenticalTo can end up 
calling the expensive getSpelling method, and other bad stuff and is 
completely unneeded if the warning will be discarded anyway. rdar://6502956

llvm-svn: 62347
2009-01-16 19:50:11 +00:00
Chris Lattner d3fb18fba2 silence release-assert warning.
llvm-svn: 62346
2009-01-16 19:44:00 +00:00
Douglas Gregor 225b321a85 Fix <rdar://problem/6502934>. We were creating an ImplicitCastExpr
with reference type (it should be an lvalue with non-reference type).

llvm-svn: 62345
2009-01-16 19:38:23 +00:00
Ted Kremenek 0755a34604 StringRegion::print: Remove copy/paste code and just call Stmt::printPretty() for the StringLiteral.
llvm-svn: 62340
2009-01-16 19:26:50 +00:00
Chris Lattner bb96cc45ae make ast-print handle random non-printable characters correctly with octal escapes.
llvm-svn: 62337
2009-01-16 19:25:18 +00:00
Fariborz Jahanian 55ca58ed61 Changed the API yet again.
llvm-svn: 62335
2009-01-16 19:02:53 +00:00
Chris Lattner f49775dc81 only notify callbacks if they exist.
llvm-svn: 62334
2009-01-16 19:01:46 +00:00
Chris Lattner 262d4e31b9 Improve #pragma comment support by building the string argument and
notifying PPCallbacks about it.

llvm-svn: 62333
2009-01-16 18:59:23 +00:00
Chris Lattner 8a24e588d7 minor cleanups to StringLiteralParser: no need to pass target info
into its ctor.  Also, make it handle validity checking of pascal
strings instead of making clients do it.

llvm-svn: 62332
2009-01-16 18:51:42 +00:00
Ted Kremenek 86afde337d Fix PR 3337 [retain/release checker]: Handle FunctionDecl's declared using typedefs.
llvm-svn: 62331
2009-01-16 18:40:33 +00:00
Douglas Gregor dd04d33e3a Part one of handling C++ functional casts. This handles semantic
analysis and AST-building for the cases where we have N != 1
arguments. For N == 1 arguments, we need to finish the C++
implementation of explicit type casts (C++ [expr.cast]).

llvm-svn: 62329
2009-01-16 18:33:17 +00:00
Fariborz Jahanian 195d36cb57 Used a more suitable api to get to the type of a record
in code gen.

llvm-svn: 62326
2009-01-16 17:41:13 +00:00
Anders Carlsson a7d069d63c Use a single function for doing vararg argument promotion. Also, make sure to do the promotion before checking the type - fixes PR3340.
llvm-svn: 62323
2009-01-16 16:48:51 +00:00
Chris Lattner 2ff698df60 Implement basic support for parsing #pragma comment, a microsoft extension
documented here:
http://msdn.microsoft.com/en-us/library/7f0aews7(VS.80).aspx

This is according to my understanding reading the docs, I don't know if it
really agrees fully with what VC++ allows.

llvm-svn: 62317
2009-01-16 08:21:25 +00:00
Chris Lattner 8a42586c54 more SourceLocation lexicon change: instead of referring to the
"logical" location, refer to the "instantiation" location.

llvm-svn: 62316
2009-01-16 07:36:28 +00:00
Chris Lattner 3c91971b33 rename "virtual location" of a macro to "instantiation location".
llvm-svn: 62315
2009-01-16 07:15:35 +00:00
Chris Lattner c4c181902e rename PP::getPhysicalCharacterAt -> PP::getSpelledCharacterAt.
Slightly speed up sema of numbers like '1' by going directly to 
TargetInfo instead of through ASTContext.

llvm-svn: 62314
2009-01-16 07:10:29 +00:00
Chris Lattner 7c8556e7bc remove obsolete comment which happened to go over 80 cols.
llvm-svn: 62313
2009-01-16 07:04:11 +00:00
Chris Lattner 15af77f679 remove an unneeded const_cast.
llvm-svn: 62311
2009-01-16 07:02:14 +00:00
Chris Lattner 53e384f633 Change some terminology in SourceLocation: instead of referring to
the "physical" location of tokens, refer to the "spelling" location.
This is more concrete and useful, tokens aren't really physical objects!

llvm-svn: 62309
2009-01-16 07:00:02 +00:00
Douglas Gregor 2b5d430096 Don't advance the statement iterator after we've deallocated the statement
llvm-svn: 62306
2009-01-16 06:50:08 +00:00
Zhongxing Xu ac8ef9ea4c Extract code dealing with typedef declarators into a separate function.
No functionality change.

llvm-svn: 62303
2009-01-16 03:34:13 +00:00
Zhongxing Xu 9b7714d909 Extract code dealing with variable declarator into a separate function.
No functionality change.

llvm-svn: 62300
2009-01-16 02:36:34 +00:00
Daniel Dunbar f557d831a7 Attempt to unbreak Windows build.
llvm-svn: 62295
2009-01-16 01:50:29 +00:00
Fariborz Jahanian dae9276090 postpone sizeof objc-class computatin to the clients.
llvm-svn: 62292
2009-01-16 01:42:12 +00:00
Zhongxing Xu bece5d61f6 Extract code dealing with declarators of function type into a separate function
Sema::ActOnFunctionDeclarator().  
No functionality change.  

llvm-svn: 62290
2009-01-16 01:13:29 +00:00
Fariborz Jahanian c5ece68d16 Implemented code gen for sizeof(objc class interface).
llvm-svn: 62289
2009-01-16 00:57:08 +00:00
Douglas Gregor 1c846b0e86 Improve diagnostics for ambiguous name lookup results
llvm-svn: 62287
2009-01-16 00:38:09 +00:00
Nuno Lopes 7ffcf93b24 add codegen support to union casts
init of static vars still not working. I'll get back to it tomorrow or so

llvm-svn: 62278
2009-01-15 20:14:33 +00:00
Ted Kremenek 4bbb79a642 PTH: Fix termination condition in binary search.
llvm-svn: 62277
2009-01-15 19:28:38 +00:00
Chris Lattner e53c036d85 PR3330: given an enum like this:
enum E {
 A = 1U,
 B
};

Don't make an implicit cast expr of null for B.

llvm-svn: 62274
2009-01-15 19:19:42 +00:00
Ted Kremenek a705b04d7f IdentifierInfo:
- IdentifierInfo can now (optionally) have its string data not be
  co-located with itself.  This is for use with PTH.  This aspect is a
  little gross, as getName() and getLength() now make assumptions
  about a possible alternate representation of IdentifierInfo.
  Perhaps we should make IdentifierInfo have virtual methods?

IdentifierTable:
- Added class "IdentifierInfoLookup" that can be used by
  IdentifierTable to perform "string -> IdentifierInfo" lookups using
  an auxilliary data structure.  This is used by PTH.
- Perform tests show that IdentifierTable::get() does not slow down
  because of the extra check for the IdentiferInfoLookup object (the
  regular StringMap lookup does enough work to mitigate the impact of
  an extra null pointer check).
- The upshot is that now that some IdentifierInfo objects might be
  owned by the IdentiferInfoLookup object.  This should be reviewed.

PTH:
- Modified PTHManager::GetIdentifierInfo to *not* insert entries in
  IdentifierTable's string map, and instead create IdentifierInfo
  objects on the fly when mapping from persistent IDs to
  IdentifierInfos.  This saves a ton of work with string copies,
  hashing, and StringMap lookup and resizing.  This change was
  motivated because when processing source files in the PTH cache we
  don't need to do any string -> IdentifierInfo lookups.
- PTHManager now subclasses IdentifierInfoLookup, allowing clients of
  IdentifierTable to transparently use IdentifierInfo objects managed
  by the PTH file.  PTHManager resolves "string -> IdentifierInfo"
  queries by doing a binary search over a sorted table of identifier
  strings in the PTH file (the exact algorithm we use can be changed
  as needed).

These changes lead to the following performance changes when using PTH on Cocoa.h:
- fsyntax-only: 10% performance improvement
- Eonly: 30% performance improvement

llvm-svn: 62273
2009-01-15 18:47:46 +00:00
Daniel Dunbar 435bbe0254 Fix some unused variable, control reaches end of non-void function,
and uninitialized use options.

llvm-svn: 62270
2009-01-15 18:32:35 +00:00
Daniel Dunbar 707f6436e0 Add dummy X86_64 ABIInfo implementation.
llvm-svn: 62268
2009-01-15 18:18:40 +00:00
Nuno Lopes 6be2939d5d add support for initializing static vars with a cast to union (gcc extension)
llvm-svn: 62261
2009-01-15 16:44:45 +00:00
Seo Sanghyeon 39a3ebf8f0 PR2746: Implement GCC cast to union extension
llvm-svn: 62255
2009-01-15 04:51:39 +00:00
Douglas Gregor 41c8ba80de Deallocate the BasePaths structure that we allocate for LookupResult.
llvm-svn: 62250
2009-01-15 02:19:31 +00:00
Ted Kremenek bef9fc2240 PTH: Embed a persistentID side-table in the PTH file that is sorted in the
lexical order of the corresponding identifier strings. This will be used for a
forthcoming optimization. This slows down PTH generation time by 7%. We can
revert this change if the optimization proves to not be valuable.

llvm-svn: 62248
2009-01-15 01:26:25 +00:00
Douglas Gregor 960b5bc7c1 Initial implementation of member name lookup
llvm-svn: 62247
2009-01-15 00:26:24 +00:00
Douglas Gregor 3407432644 Refactor name lookup.
This change refactors and cleans up our handling of name lookup with
LookupDecl. There are several aspects to this refactoring:

  - The criteria for name lookup is now encapsulated into the class
  LookupCriteria, which replaces the hideous set of boolean values
  that LookupDecl currently has.

  - The results of name lookup are returned in a new class
  LookupResult, which can lazily build OverloadedFunctionDecls for
  overloaded function sets (and, eventually, eliminate the need to
  allocate member for OverloadedFunctionDecls) and contains a
  placeholder for handling ambiguous name lookup (for C++).

  - The primary entry points for name lookup are now LookupName (for
    unqualified name lookup) and LookupQualifiedName (for qualified
    name lookup). There is also a convenience function
    LookupParsedName that handles qualified/unqualified name lookup
    when given a scope specifier. Together, these routines are meant
    to gradually replace the kludgy LookupDecl, but this won't happen
    until after we have base class lookup (which forces us to cope
    with ambiguities).

  - Documented the heck out of name lookup. Experimenting a little
    with using Doxygen's member groups to make some sense of the Sema
    class. Feedback welcome!

  - Fixes some lingering issues with name lookup for
  nested-name-specifiers, which now goes through
  LookupName/LookupQualifiedName. 

llvm-svn: 62245
2009-01-14 22:20:51 +00:00
Fariborz Jahanian f2a3120b77 Patch to keep clang honest that it does not yet support
explicit return type on block literals.

llvm-svn: 62240
2009-01-14 19:39:53 +00:00
Douglas Gregor 5fb5397238 Introduce support for C++0x explicit conversion operators (N2437)
Small cleanup in the handling of user-defined conversions. 

Also, implement an optimization when constructing a call. We avoid
recomputing implicit conversion sequences and instead use those
conversion sequences that we computed as part of overload resolution.

llvm-svn: 62231
2009-01-14 15:45:31 +00:00
Steve Naroff 5de9b58bd2 Fix a subtle bug in DeclContext::DestroyDecls().
llvm-svn: 62205
2009-01-14 01:27:31 +00:00
Ted Kremenek 4ba36fcc3f FunctionDecl::setParams() now uses the allocator associated with ASTContext to allocate the array of ParmVarDecl*'s.
llvm-svn: 62203
2009-01-14 00:42:25 +00:00
Fariborz Jahanian 255c0958dd Implemenent objective-c's NSObject attribute as a way of ddeclaraing c-type
objects as an objective-c object.

llvm-svn: 62197
2009-01-13 23:34:40 +00:00
Ted Kremenek e9814186ac PTH:
- Use canonical FileID when using getSpelling() caching.  This
  addresses some cache misses we were seeing with -fsyntax-only on
  Cocoa.h
- Added Preprocessor::getPhysicalCharacterAt() utility method for
  clients to grab the first character at a specified sourcelocation.
  This uses the PTH spelling cache.
- Modified Sema::ActOnNumericConstant() to use
  Preprocessor::getPhysicalCharacterAt() instead of
  SourceManager::getCharacterData() (to get PTH hits).

These changes cause -fsyntax-only to not page in any sources from
Cocoa.h.  We see a speedup of 27%.

llvm-svn: 62193
2009-01-13 23:19:12 +00:00
Douglas Gregor 2b136fe2a5 Permitting typedefs without a name is a Microsoft/GNU extension
llvm-svn: 62192
2009-01-13 23:10:51 +00:00
Ted Kremenek 7cbdcc25d4 Fix corner cases in PTH getSpelling() binary search.
llvm-svn: 62187
2009-01-13 22:16:45 +00:00
Ted Kremenek b0b4f74b6b PTH: Fix remaining cases where the spelling cache in the PTH file was being missed when it shouldn't. This shaves another 7% off PTH time for -Eonly on Cocoa.h
llvm-svn: 62186
2009-01-13 22:05:50 +00:00
Douglas Gregor 89100920d6 Turn off some Destroy calls that are currenly causing double-destruction of ScopedDecls. We will re-enable this later, when we have time to fully solve the ownership issue.
llvm-svn: 62175
2009-01-13 19:47:12 +00:00
Anders Carlsson bc12e92068 Use the unqualified type for GCCs struct/union cast extension
llvm-svn: 62170
2009-01-13 17:00:51 +00:00
Anders Carlsson 6393773c4b Warn when someone tries to pass a variable with a non-POD type to a varargs function/method/block.
llvm-svn: 62148
2009-01-13 05:48:52 +00:00
Douglas Gregor 02a0acd0bc Fix argument-passing bugs in a call to object
llvm-svn: 62147
2009-01-13 05:10:00 +00:00
Zhongxing Xu 2436f86024 add a fixme.
llvm-svn: 62142
2009-01-13 03:07:41 +00:00
Daniel Dunbar dec798bf37 Bug fix, __private_extern__ globals were always introducing a definition.
llvm-svn: 62139
2009-01-13 02:25:00 +00:00
Zhongxing Xu cff637a568 Add KillStruct to region store.
- put the killed region in the kill set.
 - set its default value to unknown.
 - removes all bindings for its subregions.  

llvm-svn: 62138
2009-01-13 01:49:57 +00:00
Fariborz Jahanian 5c76772f49 Patch to fix encoding of Enum bitfields in ObjC.
llvm-svn: 62135
2009-01-13 01:18:13 +00:00
Ted Kremenek eb68db238f static analyzer: Handle casts from arrays to integers. This fixes PR 3297.
llvm-svn: 62130
2009-01-13 01:04:21 +00:00
Ted Kremenek 167f2fa5f4 Invert condition on branch (was causing RegionStore::ArrayToPointer to return 'unknown' on most cases.
llvm-svn: 62129
2009-01-13 01:03:27 +00:00
Douglas Gregor c5e61070f6 Add the proper restrictions on the left-hand argument of a built-in
assignment operator candidate (C++ [over.match.oper]p4).

llvm-svn: 62128
2009-01-13 00:52:54 +00:00
Douglas Gregor f399ef43c7 Make sure we don't name a constructor or destructor with a qualified
type. It leads to very weird errors.

llvm-svn: 62124
2009-01-13 00:11:19 +00:00
Fariborz Jahanian 30e7864661 Patch to implement code gen for aggrgate-valued property used
to access a field of its type.

llvm-svn: 62123
2009-01-12 23:27:26 +00:00
Douglas Gregor b3730b50c7 Cleanup DeclContext::addDecl and DeclContext::insert interface, from Piotr Rak
llvm-svn: 62122
2009-01-12 23:27:07 +00:00
Ted Kremenek 6dfeb55897 Patch by Roman Divacky:
Extend string-literal checking for printf() format string to handle conditional
ternary operators where both sides are literals.

This fixes PR 3319: http://llvm.org/bugs/show_bug.cgi?id=3319

llvm-svn: 62117
2009-01-12 23:09:09 +00:00
Ted Kremenek 6ae6513ce2 Fix crasher due to use-after-release: DeclContext now owns all ObjCMethodDecls, and shouldn't be released elsewhere.
llvm-svn: 62113
2009-01-12 22:49:54 +00:00
Douglas Gregor c6f58fe266 Implement support for anonymous structs and unions in C. Both C and
C++ handle anonymous structs/unions in the same way. Addresses several
bugs:

  <rdar://problem/6259534>
  <rdar://problem/6481130>
  <rdar://problem/6483159>

The test case in PR clang/1750 now passes with -fsyntax-only, but
CodeGen for inline assembler still fails.

llvm-svn: 62112
2009-01-12 22:49:06 +00:00
Ted Kremenek 7e90422e95 retain/release checker:
- Refactor a bunch of logic in the retain/release checker, making it more
  condense and easier to read.
- Add support for "Create" methods in the DiskArbitration framework

retain/release tests:
- Rename CFDate.m to retain-release.m, and move test from CFString.c to
  retain-release.m
- Add DiskArbitration framework tests cases.
- Add/refine and few more retain/release GC test cases.

llvm-svn: 62106
2009-01-12 21:45:02 +00:00
Daniel Dunbar 62db95e891 (LLVM up) Match TargetData API change in LLVM TOT.
llvm-svn: 62101
2009-01-12 21:08:18 +00:00
Fariborz Jahanian 8e1555c7c3 Patch to supprt case of readonly property being
assigned to when it has user declared setter method
defined in the class implementation (but no declaration in
the class itself).

llvm-svn: 62098
2009-01-12 19:55:42 +00:00
Douglas Gregor 45a33ecce1 Properly set the scope of non-fields declared within a struct, union,
or enum to be outside that struct, union, or enum. Fixes several
regressions: 

  <rdar://problem/6487662>
  <rdar://problem/6487669>
  <rdar://problem/6487684>
  <rdar://problem/6487702>
  PR clang/3305
  PR clang/3312

There is still some work to do in Objective-C++, but this requires
that each of the Objective-C entities (interfaces, implementations,
etc.) to be introduced into the context stack with
PushDeclContext/PopDeclContext. This will be a separate fix, later.

llvm-svn: 62091
2009-01-12 18:45:55 +00:00
Anders Carlsson 00057e4e09 Handle multi-value inputs
llvm-svn: 62069
2009-01-12 02:22:13 +00:00
Anders Carlsson 30c235d182 Make sure to initialize the ConstraintInfo to 0
llvm-svn: 62068
2009-01-12 02:15:29 +00:00
Chris Lattner 5562d19ebe some more minor asqualtype bugs.
llvm-svn: 62064
2009-01-12 00:21:19 +00:00
Chris Lattner d1f748dabc improve some more is*Type predicates to look through asqualtypes.
llvm-svn: 62063
2009-01-12 00:10:42 +00:00
Chris Lattner ebcbce5ec8 simplify these predicates a bit.
llvm-svn: 62061
2009-01-11 23:59:49 +00:00
Nuno Lopes a0abe62904 make ScalarExprEmitter::EmitCompare() emit the expression with the correct type instead of always zext it to an int
this fixes codegen of simple exprs in C++ like 'if (x != 0)'

llvm-svn: 62060
2009-01-11 23:22:37 +00:00
Anders Carlsson 431acd1129 More inline asm fixes
llvm-svn: 62049
2009-01-11 21:23:27 +00:00
Anders Carlsson a948c34b0b Handle readwrite constraints correctly
llvm-svn: 62043
2009-01-11 19:46:50 +00:00
Anders Carlsson 03aaf11502 Forgot to commit this
llvm-svn: 62042
2009-01-11 19:40:10 +00:00
Anders Carlsson da5f56939b Use a common function for emitting asm inputs and remove a FIXME
llvm-svn: 62041
2009-01-11 19:32:54 +00:00
Sebastian Redl f70b683e89 Fix operator precedence.
llvm-svn: 62038
2009-01-11 13:39:06 +00:00
Steve Naroff ba3dc38840 Convert property implementation to DeclContext::addDecl().
This completes the ObjCContainerDecl AST cleanup (for now).

llvm-svn: 62037
2009-01-11 12:47:58 +00:00
Steve Naroff 0c0f5bae80 A few property related cleanups to ObjCContainerDecl AST.
llvm-svn: 62034
2009-01-11 01:06:09 +00:00
Sebastian Redl 6a8002eac7 Convert some more actions to smart pointers.
No performance regression in my basic test.
Also fixed a type error in ActOnFinishSwitchStmt's arguments (body is a stmt).

llvm-svn: 62032
2009-01-11 00:38:46 +00:00
Steve Naroff 5a7dd78ba2 Fix a misleading comment.
llvm-svn: 62031
2009-01-10 22:55:25 +00:00
Fariborz Jahanian 0196a1cd2b This patch fixes the code gen failures which was a fallout from
not merging protocol properties into the classes which
use those protocols. With this patch, all my exceutable
test pass again.

llvm-svn: 62030
2009-01-10 21:06:09 +00:00
Fariborz Jahanian 8630b2d992 Explicit declaration of property setters over-ride
prohibition of 'readonly' properties in an assignment.

llvm-svn: 62028
2009-01-10 18:43:55 +00:00
Douglas Gregor b37080a969 Allow multiple Microsoft calling-convention keywords. Fixes rdar://problem/6486133
llvm-svn: 62018
2009-01-10 00:48:18 +00:00
Fariborz Jahanian d9c238dc9f assert if attempting to code gen. a property setter/getter
coming from a protocol.

llvm-svn: 62017
2009-01-10 00:13:01 +00:00
Douglas Gregor 498b58ceb1 Don't bother setting NextDeclarator for EnumConstantDecls. It isn't used
llvm-svn: 62016
2009-01-09 23:23:35 +00:00
Douglas Gregor 658b9550bb When we see a reference to a struct, class, or union like "struct X"
that is neither a definition nor a forward declaration and where X has
not yet been declared as a tag, introduce a declaration
into the appropriate scope (which is likely *not* to be the current
scope). The rules for the placement of the declaration differ slightly
in C and C++, so we implement both and test the various corner
cases. This implementation isn't 100% correct due to some lingering
issues with the function prototype scope (for a function parameter
list) not being the same scope as the scope of the function
definition. Testcase is FIXME'd; this probably isn't an important issue.

Addresses <rdar://problem/6484805>.

llvm-svn: 62014
2009-01-09 22:42:13 +00:00
Sebastian Redl 6138f2b4d8 Add some comments to the virtual work. Thanks to Doug Gregor for the review.
llvm-svn: 62012
2009-01-09 22:29:03 +00:00
Ted Kremenek 890d44eb7f Dead stores checker: Don't flag dead stores for self-assignments (common escape hatch for 'unused variable' warnings).
llvm-svn: 62010
2009-01-09 22:15:01 +00:00
Ted Kremenek 47b8cf6deb Enhance PTH 'getSpelling' caching:
- Refactor caching logic into a helper class PTHSpellingSearch
- Allow "random accesses" in the spelling cache, thus catching the remaining
  cases where 'getSpelling' wasn't hitting the PTH cache
  
For -Eonly, PTH, Cocoa.h:
- This reduces wall time by 3% (user time unchanged, sys time reduced)
- This reduces the amount of paged source by 1112K.
  The remaining 1112K still being paged in is from somewhere else
  (investigating).

llvm-svn: 62009
2009-01-09 22:05:30 +00:00
Sebastian Redl 020cddcfee Prevent a segfault for vaarg expressions on unsupported architectures.
llvm-svn: 62008
2009-01-09 21:09:38 +00:00
Fariborz Jahanian 519976c4e9 This patch removes mergeProperties and does the property lookup
in designated protocols lazily.

llvm-svn: 62007
2009-01-09 21:04:52 +00:00
Daniel Dunbar 8429dbc753 Implement EmitUnsupportedRValue to generate an appropriately typed RValue.
llvm-svn: 62004
2009-01-09 20:09:28 +00:00
Sebastian Redl 6079525591 Very basic support for pure virtual functions.
llvm-svn: 62003
2009-01-09 19:57:06 +00:00
Douglas Gregor 020713e308 Replace DeclContext's vector of ScopedDecl pointers with a linked list
of ScopedDecls (using the new ScopedDecl::NextDeclInScope
pointer). Performance-wise:

  - It's a net win in memory utilization, since DeclContext is now one
    pointer smaller than it used to be (std::vectors are typically 3
    pointers; we now use 2 pointers) and 
  - Parsing Cocoa.h with -fsyntax-only (with a Release-Asserts Clang)
    is about 1.9% faster than before, most likely because we no longer
    have the memory allocations and copying associated with the
    std::vector.

I'll re-enable serialization of DeclContexts once I've sorted out the
NextDeclarator/NextDeclInScope question.

llvm-svn: 62001
2009-01-09 19:42:16 +00:00
Douglas Gregor c72e645fd6 Make sure that ScopedDecls passed to DeclContext::addDecl are added into their lexical context
llvm-svn: 61998
2009-01-09 18:51:29 +00:00
Douglas Gregor ffca3a21f1 Provide a new kind of iterator, the specific_decl_iterator, that
filters the decls seen by decl_iterator with two criteria: the dynamic
type of the declaration and a run-time predicate described by a member
function. This simplifies EnumDecl, RecordDecl, and ObjCContainerDecl
considerably. It has no measurable performance impact.

llvm-svn: 61994
2009-01-09 17:18:27 +00:00
Daniel Dunbar 93215eca9b Emit more refined "unsupported" error for block expressions.
llvm-svn: 61993
2009-01-09 17:04:29 +00:00
Daniel Dunbar bb197e439d Give "unsupported" error on calls through block pointers instead of
crashes.

llvm-svn: 61992
2009-01-09 16:50:52 +00:00
Steve Naroff b3a8798253 Move property API's up to ObjCContainerDecl (removing a lot of duplicate code).
Add isa/cast/dyncast support for ObjCContainerDecl.
Renamed classprop_iterator/begin/end to prop_iterator/begin/end (the class prefix was confusing).
More simplifications to Sema::ActOnAtEnd()...
Added/changed some FIXME's as a result of the above work.

llvm-svn: 61988
2009-01-09 15:36:25 +00:00
Chris Lattner c7c9ab7947 Fix rdar://6480479 - [parser] infinite loop on invalid input
llvm-svn: 61975
2009-01-09 04:34:13 +00:00
Daniel Dunbar cc1b6e8fce Convert block types in IRgen. This is not the correct type, but
matches llvm-gcc (?).

llvm-svn: 61974
2009-01-09 02:48:46 +00:00
Daniel Dunbar 9b21e63251 Block pointer types are not aggregate types.
llvm-svn: 61973
2009-01-09 02:44:18 +00:00
Daniel Dunbar f4c6616d9d Fix crash on null deference when searching for readwrite properties in
categories.
 - Also, simplify nesting via early return.

llvm-svn: 61968
2009-01-09 01:04:21 +00:00
Douglas Gregor c25d7a7fe0 Addressed the issue in <rdar://problem/6479085>, where we failed to
rewrite @class declarations that showed up within linkage
specifications because those @class declarations never made it any
place where the rewriter could find them.

Moved all of the ObjC*Decl nodes over to ScopedDecls, so that they can
live in the appropriate top-level or transparent DeclContext near the
top level, e.g., TranslationUnitDecl or LinkageSpecDecl. Objective-C
declarations now show up in a traversal of the declarations in a
DeclContext (they didn't before!). This way, the rewriter finds all
Objective-C declarations within linkage specifications.

llvm-svn: 61966
2009-01-09 00:49:46 +00:00
Fariborz Jahanian e84858ccf9 Adding support for ObjC methods which have c-style
parameter list. This is work in progress.

llvm-svn: 61964
2009-01-09 00:38:19 +00:00
Ted Kremenek 8ae06625b5 Invert assertion condition.
llvm-svn: 61961
2009-01-09 00:36:11 +00:00
Anders Carlsson bfd47a3c00 Add mm_malloc.h, patch by Sam Weinig.
llvm-svn: 61954
2009-01-08 23:30:09 +00:00
Douglas Gregor e4b414c781 Revert my previous, failed attempt to pretty-print anonymous struct/union accesses well. Added a FIXME so we know to revisit this later
llvm-svn: 61951
2009-01-08 22:45:41 +00:00