Commit Graph

7770 Commits

Author SHA1 Message Date
Daniel Dunbar bc47ed8e74 Ignore Output directories when searching for tests.
llvm-svn: 59660
2008-11-19 19:06:57 +00:00
Oscar Fuentes 77543d9af0 CMake: Added some source files.
Patch contributed by Jay Foad!

llvm-svn: 59656
2008-11-19 18:46:39 +00:00
Fariborz Jahanian a598b5286e More of objective-c's gc code-gen. Treat objective-c
objects as __strong when attribute unspecified.

llvm-svn: 59654
2008-11-19 18:38:10 +00:00
Argyrios Kyrtzidis 554689a3aa Make DeclContext::getLexicalParent reuse DeclContext::getParent.
llvm-svn: 59651
2008-11-19 18:07:24 +00:00
Argyrios Kyrtzidis 0d09c4944e Take care another assert:
struct A {
  struct B;
};

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

llvm-svn: 59650
2008-11-19 18:01:13 +00:00
Nuno Lopes 0e33c688d5 fix folding of '*doubleArray'
llvm-svn: 59647
2008-11-19 17:44:31 +00:00
Argyrios Kyrtzidis 7768a30c37 Make the non-const DeclContext::getParent call the const version, instead of the other way around.
llvm-svn: 59646
2008-11-19 17:36:39 +00:00
Fariborz Jahanian 50a1270d87 Few more changes due to Daniel's feedback.
llvm-svn: 59645
2008-11-19 17:34:06 +00:00
Douglas Gregor 40412acc02 Support overloading of the subscript operator[], including support for
built-in operator candidates. Test overloading of '&' and ','.

In C++, a comma expression is an lvalue if its right-hand
subexpression is an lvalue. Update Expr::isLvalue accordingly.

llvm-svn: 59643
2008-11-19 17:17:41 +00:00
Steve Naroff 9e4ac111f0 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).

llvm-svn: 59639
2008-11-19 15:54:23 +00:00
Douglas Gregor d08452f60a 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.

llvm-svn: 59638
2008-11-19 15:42:04 +00:00
Argyrios Kyrtzidis 89709ac2cc Fix this:
With this snippet:
  void f(a::b);

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.

llvm-svn: 59636
2008-11-19 15:22:16 +00:00
Argyrios Kyrtzidis f5e2812e69 Remove Preprocessor::CacheTokens boolean data member. The same functionality can be provided by using Preprocessor::isBacktrackEnabled().
llvm-svn: 59631
2008-11-19 14:23:14 +00:00
Daniel Dunbar 7689f6be47 Add spec ref to comment.
llvm-svn: 59622
2008-11-19 11:54:05 +00:00
Zhongxing Xu 16a92afc4b Add test for path-sensitive uninit-val detection involving struct field.
llvm-svn: 59620
2008-11-19 11:10:42 +00:00
Zhongxing Xu e5816f213d Add support for symbolicating global structs and arrays in RegionStoreManager::getInitialStore().
llvm-svn: 59619
2008-11-19 11:06:24 +00:00
Zhongxing Xu b8e54884c8 Add SymbolData for array elements and struct fields.
llvm-svn: 59618
2008-11-19 11:03:17 +00:00
Daniel Dunbar af7efa695c Fix silly code, use IdentifierInfo* instead of std::string in
PragmaPackStack. Thanks Chris!

llvm-svn: 59616
2008-11-19 10:32:38 +00:00
Daniel Dunbar 9b1335eca8 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.

llvm-svn: 59615
2008-11-19 09:36:46 +00:00
Sanjiv Gupta f99d54498a Pointer width for PIC16 is 16 bits. Modify getMemCpy, getMemMove and getMemSet accordingly.
llvm-svn: 59613
2008-11-19 09:02:07 +00:00
Chris Lattner e503373e67 fix save-o
llvm-svn: 59611
2008-11-19 08:26:36 +00:00
Chris Lattner d9c7bcf4bc simplify
llvm-svn: 59610
2008-11-19 08:24:49 +00:00
Chris Lattner 4bd8dd8568 stop calling II::getName() unnecesarily in sema
llvm-svn: 59609
2008-11-19 08:23:25 +00:00
Chris Lattner 6ef2bc4b42 simplify some code.
llvm-svn: 59608
2008-11-19 07:55:04 +00:00
Chris Lattner 760d19ade1 remove uses of IdentifierInfo::getName()
llvm-svn: 59607
2008-11-19 07:51:13 +00:00
Chris Lattner 406c096993 remove some uses of IdentifierInfo::getName()
llvm-svn: 59606
2008-11-19 07:49:38 +00:00
Chris Lattner 49c017f4ea add a new helper method. It is unclear to me why this doesn't work, but GCC
won't match it:

  template<std::size_t StrLen>
  bool isName(const char Str[StrLen]) const {
    return getLength() == StrLen-1 && !memcmp(getName(), Str, StrLen-1);
  }

llvm-svn: 59605
2008-11-19 07:49:14 +00:00
Chris Lattner 66e3877b42 Use smallstring instead of new[]'ing a string. This simplifies
the code and speeds it up.

llvm-svn: 59604
2008-11-19 07:41:27 +00:00
Chris Lattner ebad6a220f remove uses of IdentifierInfo::getName()
llvm-svn: 59603
2008-11-19 07:37:42 +00:00
Chris Lattner c5cdade2df don't turn identifierinfo's into strings in diagnostics.
llvm-svn: 59602
2008-11-19 07:33:58 +00:00
Chris Lattner b91fd17b7d Allow sending IdentifierInfo*'s into Diagnostics without turning them into strings
first.  This should allow removal of a bunch of II->getName() calls.

llvm-svn: 59601
2008-11-19 07:32:16 +00:00
Chris Lattner f76c09dcaa convert some diags to use numbers instead of strings.
llvm-svn: 59600
2008-11-19 07:25:44 +00:00
Chris Lattner 230fc3d17d formatting
llvm-svn: 59599
2008-11-19 07:24:05 +00:00
Chris Lattner 91aea716c6 add direct support for signed and unsigned integer arguments to diagnostics.
llvm-svn: 59598
2008-11-19 07:22:31 +00:00
Chris Lattner 327984f4c4 switch TextDiagnosticPrinter to raw_ostream.
llvm-svn: 59597
2008-11-19 06:56:25 +00:00
Chris Lattner 23be067407 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 %%.

llvm-svn: 59596
2008-11-19 06:51:40 +00:00
Daniel Dunbar 1b9ad472a4 Discard unused runtime function declarations (for readability).
llvm-svn: 59594
2008-11-19 06:15:35 +00:00
Chris Lattner 8d5bec4c7d 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.

llvm-svn: 59593
2008-11-19 06:04:55 +00:00
Ted Kremenek 29704928b7 Updated checker build.
llvm-svn: 59591
2008-11-19 05:46:43 +00:00
Chris Lattner 5d78c9ab5d Address Sebastian and Doug's objections with taking pointers to temporaries.
Instead of doing that, copy the strings into the diagnostic info.

llvm-svn: 59590
2008-11-19 05:34:22 +00:00
Chris Lattner f490e15729 remove one more old-style Diag method.
llvm-svn: 59589
2008-11-19 05:27:50 +00:00
Chris Lattner 3b05413e9d 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.

llvm-svn: 59588
2008-11-19 05:08:23 +00:00
Douglas Gregor ca63811b39 Built-in equality and relational operators have return type "bool" in C++,
not "int".

Fix a typo in the promotion of enumeration types that was causing some
integral promotions to look like integral conversions (leading to
extra ambiguities in overload resolution).

Check for "acceptable" overloaded operators based on the types of the
arguments. This is a somewhat odd check that is specified by the
standard, but I can't see why it actually matters: the overload
candidates it suppresses don't seem like they would ever be picked as
the best candidates.

llvm-svn: 59583
2008-11-19 03:25:36 +00:00
Ted Kremenek a7c279ba40 Revert 59574 (caused tests to fail).
llvm-svn: 59579
2008-11-19 01:54:47 +00:00
Ted Kremenek 5a205a57d8 scan-build now recognizes when the user is directly invoking gcc for:
(a) different versions of gcc (e.g., a suffix '-4.2')
(b) different paths for gcc

llvm-svn: 59578
2008-11-19 01:46:21 +00:00
Fariborz Jahanian d7db964495 Generate strong write barriers for __strong objects.
Also, took care of Daniel's commments.

llvm-svn: 59575
2008-11-19 00:59:10 +00:00
Ted Kremenek 1b167108bb - Move static function IsNonPragmaNonMacroLexer into Preprocessor.h.
- Add variants of IsNonPragmaNonMacroLexer to accept an IncludeMacroStack entry
  (simplifies some uses).
- Use IsNonPragmaNonMacroLexer in Preprocessor::LookupFile.

Performance testing of -Eonly on Cocoa.h shows no performance regression because
of this patch.

llvm-svn: 59574
2008-11-19 00:46:18 +00:00
Ted Kremenek c7a366309d Initialize CurPPLexer in Preprocessor's constructor.
llvm-svn: 59573
2008-11-19 00:44:06 +00:00
Ted Kremenek c0145fd0bf Fix warning about RegionStoreManager::Retrieve() not always returning a value.
llvm-svn: 59571
2008-11-19 00:27:37 +00:00
Douglas Gregor 436424cfa5 Partial expansion of C++ operator overloading (for binary operators)
to support operators defined as member functions, e.g.,

  struct X { 
    bool operator==(X&);
  };

Overloading with non-member operators is supported, and the special
rules for the implicit object parameter (e.g., the ability for a
non-const *this to bind to an rvalue) are implemented.

This change also refactors and generalizes the code for adding
overload candidates for overloaded operator calls (C++ [over.match.expr]),
both to match the rules more exactly (name lookup of non-member
operators actually ignores member operators) and to make this routine
more reusable for the other overloaded operators.

Testing for the initialization of the implicit object parameter is
very light. More tests will come when we get support for calling
member functions directly (e.g., o.m(a1, a2)).

llvm-svn: 59564
2008-11-18 23:14:02 +00:00
Chris Lattner 377d1f8eae start converting Sema over to using its canonical Diag method.
llvm-svn: 59561
2008-11-18 22:52:51 +00:00
Fariborz Jahanian 83f45b55f8 Patch for generation of weak write barriers for objc
__weak objects.

llvm-svn: 59560
2008-11-18 22:37:34 +00:00
Chris Lattner 84f1ee3001 introduce the one true Diag method for Sema. Next up: kill all the others off.
llvm-svn: 59556
2008-11-18 21:53:24 +00:00
Chris Lattner a7fc74fdc1 Allow diagnostics to be used in bool context, like:
return Diag(...);

when the function returns bool.  This always evaluates to true.

llvm-svn: 59555
2008-11-18 21:53:02 +00:00
Chris Lattner e05c4dfc42 Remove the last of the old-style Preprocessor::Diag methods.
llvm-svn: 59554
2008-11-18 21:48:13 +00:00
Fariborz Jahanian f5125d19e7 Generate objc_read_weak for __weak objc loads.
llvm-svn: 59553
2008-11-18 21:45:40 +00:00
Fariborz Jahanian 406b117eea Some basic support toward objective-c's GC code gen.
llvm-svn: 59543
2008-11-18 20:18:11 +00:00
Steve Naroff 119f60e12a Fix <rdar://problem/6329769> [sema] crash on duplication definition of interface with protocols.
As soon as we detect duplicate interfaces, discontinue further semantic checks (returning the original interface).

This is now consistent with how we handle protocols (and less error prone in general).

llvm-svn: 59541
2008-11-18 19:15:30 +00:00
Torok Edwin c63831dd6a remove this testcase, it fails with -verify still
llvm-svn: 59539
2008-11-18 18:48:14 +00:00
Nuno Lopes b4e7e859e2 fix test. it now crashes, but thats another problem..
llvm-svn: 59537
2008-11-18 17:57:01 +00:00
Daniel Dunbar bf45c9a4e4 Add some quick notes on the clang tests and running the LLVM test
suite with clang.

llvm-svn: 59536
2008-11-18 17:56:21 +00:00
Daniel Dunbar ad90855730 Input files should be before link options.
- PR3094.
 - No test case, ccc is not really a supported product (llvmc2 already
   got this right).

llvm-svn: 59535
2008-11-18 17:38:30 +00:00
Torok Edwin 1403f404da add testcase for PR3093
llvm-svn: 59534
2008-11-18 17:31:32 +00:00
Chris Lattner 2b387c487e don't dereference a null pointer
llvm-svn: 59533
2008-11-18 17:18:16 +00:00
Douglas Gregor 4ea8043d6f As threatened previously: consolidate name lookup and the creation of
DeclRefExprs and BlockDeclRefExprs into a single function
Sema::ActOnDeclarationNameExpr, eliminating a bunch of duplicate
lookup-name-and-check-the-result code.

Note that we still have the three parser entry points for identifiers,
operator-function-ids, and conversion-function-ids, since the parser
doesn't (and shouldn't) know about DeclarationNames. This is a Good
Thing (TM), and there will be more entrypoints coming (e.g., for C++
pseudo-destructor expressions).

llvm-svn: 59527
2008-11-18 15:03:34 +00:00
Douglas Gregor 163c58502a Extend DeclarationName to support C++ overloaded operators, e.g.,
operator+, directly, using the same mechanism as all other special
names.

Removed the "special" identifiers for the overloaded operators from
the identifier table and IdentifierInfo data structure. IdentifierInfo
is back to representing only real identifiers.

Added a new Action, ActOnOperatorFunctionIdExpr, that builds an
expression from an parsed operator-function-id (e.g., "operator
+"). ActOnIdentifierExpr used to do this job, but
operator-function-ids are no longer represented by IdentifierInfo's.

Extended Declarator to store overloaded operator names. 
Sema::GetNameForDeclarator now knows how to turn the operator
name into a DeclarationName for the overloaded operator. 

Except for (perhaps) consolidating the functionality of
ActOnIdentifier, ActOnOperatorFunctionIdExpr, and
ActOnConversionFunctionExpr into a common routine that builds an
appropriate DeclRefExpr by looking up a DeclarationName, all of the
work on normalizing declaration names should be complete with this
commit.

llvm-svn: 59526
2008-11-18 14:39:36 +00:00
Zhongxing Xu 383ccc1e75 Fix 80-col violation.
llvm-svn: 59523
2008-11-18 13:35:51 +00:00
Zhongxing Xu 19cad71552 Add test cast for struct array.
llvm-svn: 59522
2008-11-18 13:30:46 +00:00
Zhongxing Xu f87a7abcd4 handle the case that the array element is of structure type when bind the whole array to a single value (for example, UnknownVal, UndefinedVal).
llvm-svn: 59521
2008-11-18 13:11:04 +00:00
Chris Lattner 97b8e84bd7 remove one more Preprocessor::Diag method.
llvm-svn: 59512
2008-11-18 08:02:48 +00:00
Chris Lattner 907dfe94e1 Convert the lexer and start converting the PP over to using canonical Diag methods.
llvm-svn: 59511
2008-11-18 07:59:24 +00:00
Chris Lattner 3d31c6c823 remove the last couple obsolete forms of Parser::Diag.
llvm-svn: 59510
2008-11-18 07:50:21 +00:00
Chris Lattner 6d29c10564 Change a couple of the Parser::Diag methods to return DiagnosticInfo
and let the clients push whatever they want into the DiagnosticInfo
instead of hard coding a few forms.  Also switch various clients to
use Diag(Tok, ...) instead of Diag(Tok.getLocation(), ...) as the
canonical form to simplify the code a bit.

llvm-svn: 59509
2008-11-18 07:48:38 +00:00
Chris Lattner d55748ec47 The 'return Diag(...)' idiom should be treated as returning an
invalid expr/stmt, etc.

llvm-svn: 59508
2008-11-18 07:47:11 +00:00
Chris Lattner 5d4562ca20 Give DiagnosticInfo a real copy constructor, even though it
is destructive.

llvm-svn: 59507
2008-11-18 07:46:42 +00:00
Chris Lattner ab73bb1494 alphabeticalize.
llvm-svn: 59506
2008-11-18 07:46:14 +00:00
Ted Kremenek ee4fa9cfbb Updated checker build.
llvm-svn: 59503
2008-11-18 07:27:02 +00:00
Chris Lattner 8488c8297c This reworks some of the Diagnostic interfaces a bit to change how diagnostics
are formed.  In particular, a diagnostic with all its strings and ranges is now
packaged up and sent to DiagnosticClients as a DiagnosticInfo instead of as a 
ton of random stuff.  This has the benefit of simplifying the interface, making
it more extensible, and allowing us to do more checking for things like access
past the end of the various arrays passed in.

In addition to introducing DiagnosticInfo, this also substantially changes how 
Diagnostic::Report works.  Instead of being passed in all of the info required
to issue a diagnostic, Report now takes only the required info (a location and 
ID) and returns a fresh DiagnosticInfo *by value*.  The caller is then free to
stuff strings and ranges into the DiagnosticInfo with the << operator.  When
the dtor runs on the DiagnosticInfo object (which should happen at the end of
the statement), the diagnostic is actually emitted with all of the accumulated
information.  This is a somewhat tricky dance, but it means that the 
accumulated DiagnosticInfo is allowed to keep pointers to other expression 
temporaries without those pointers getting invalidated.

This is just the minimal change to get this stuff working, but this will allow
us to eliminate the zillions of variant "Diag" methods scattered throughout
(e.g.) sema.  For example, instead of calling:

  Diag(BuiltinLoc, diag::err_overload_no_match, typeNames,
       SourceRange(BuiltinLoc, RParenLoc));

We will soon be able to just do:

  Diag(BuiltinLoc, diag::err_overload_no_match)
      << typeNames << SourceRange(BuiltinLoc, RParenLoc));

This scales better to support arbitrary types being passed in (not just 
strings) in a type-safe way.  Go operator overloading?!

llvm-svn: 59502
2008-11-18 07:04:44 +00:00
Ted Kremenek 5fa5052d50 Attribute nonnull can be applied to block pointers.
llvm-svn: 59499
2008-11-18 06:52:58 +00:00
Chris Lattner 746d474b28 SourceManager::getLineNumber is logically const except for caching.
Use mutable to make it so.

llvm-svn: 59498
2008-11-18 06:51:15 +00:00
Chris Lattner 3de58149bd eliminate dependence of strange "Diagnostic::Report" method,
delete huge trailing whitespace to fit in 80 cols.

llvm-svn: 59497
2008-11-18 06:07:40 +00:00
Chris Lattner 7b9f769ea9 remove a helper method with only one call site.
llvm-svn: 59495
2008-11-18 05:05:28 +00:00
Chris Lattner 16ba91396a Change the diagnostics interface to take an array of pointers to
strings instead of array of strings.  This reduces string copying
in some not-very-important cases, but paves the way for future 
improvements.

llvm-svn: 59494
2008-11-18 04:56:44 +00:00
Chris Lattner 95d3d1094f cleanups.
llvm-svn: 59493
2008-11-18 04:53:45 +00:00
Chris Lattner 17c6fa4efe sort files.
llvm-svn: 59492
2008-11-18 04:48:28 +00:00
Chris Lattner 53f5d4c1b5 cleanups and simplifications.
llvm-svn: 59491
2008-11-18 04:44:58 +00:00
Ted Kremenek 4c5888c67a Preprocessor::PushIncludeMacroStack() should always zero out CurPPLexer.
llvm-svn: 59490
2008-11-18 03:28:24 +00:00
Ted Kremenek 3d9740da29 - Add Lexer::isPragma() accessor for clients of Lexer that aren't friends.
- Add static method to test if the current lexer is a non-macro/non-pragma
  lexer.
- Refactor some code in PPLexerChange to use this static method.
- No performance change.

llvm-svn: 59486
2008-11-18 01:33:13 +00:00
Chris Lattner 326f757698 minor cleanups and tidying, no functionality change.
llvm-svn: 59485
2008-11-18 01:30:42 +00:00
Chris Lattner 74112917b2 implement a fixme by making warnings for ++/-- on non-modifiable-lvalues better.
llvm-svn: 59484
2008-11-18 01:26:17 +00:00
Chris Lattner 30bd327746 factor some code out into a helper function
llvm-svn: 59483
2008-11-18 01:22:49 +00:00
Ted Kremenek 551c82aa7b Replace more uses of 'CurLexer->' with 'CurPPLexer->'. No performance change.
llvm-svn: 59482
2008-11-18 01:12:54 +00:00
Ted Kremenek 6b73291462 Add hooks to use PTHLexer::Lex instead of Lexer::Lex when CurLexer is null.
Performance tests on Cocoa.h (using the regular Lexer) shows no performance
difference.

llvm-svn: 59479
2008-11-18 01:04:47 +00:00
Ted Kremenek e2c23daa14 Update Xcode project.
llvm-svn: 59478
2008-11-18 00:57:33 +00:00
Ted Kremenek 59e003e538 Added conditional guard 'if (CurLexer)' when using SetCommentRetentionState().
This is because the PTHLexer will not support this method. Performance testing
on preprocessing Cocoa.h shows that this results in a negligible performance
difference (less than 1%).

I tried making Lexer::SetCommentRetentionState() an out-of-line function (a
precursor to making it a virtual function in PreprocessorLexer) and noticed a 1%
decrease in speed (it is called in a hot part of the Preprocessor).

llvm-svn: 59477
2008-11-18 00:43:07 +00:00
Ted Kremenek 30cd88caab Change a bunch of uses of 'CurLexer->' to 'CurPPLexer->', which should be the
alias for the current PreprocessorLexer. No functionality change. Performance
testing shows this results in no performance degradation when preprocessing
Cocoa.h.

llvm-svn: 59474
2008-11-18 00:34:22 +00:00
Ted Kremenek 68ef9fc6ae - Add 'CurPPLexer' to Preprocessor to keep track of the current
PreprocessorLexer, which will either be a 'Lexer' or 'PTHLexer'.
- Added stub field 'CurPTHLexer' to keep track of the current PTHLexer.
- Modified IncludeStackInfo to track both the current PTHLexer and
  current PreprocessorLexer.

llvm-svn: 59472
2008-11-18 00:12:49 +00:00
Sebastian Redl 8071edb297 Implement effects of 'mutable', and a few comments from Chris on its parsing.
llvm-svn: 59470
2008-11-17 23:24:37 +00:00
Douglas Gregor 92751d41a0 Eliminate all of the placeholder identifiers used for constructors,
destructors, and conversion functions. The placeholders were used to
work around the fact that the parser and some of Sema really wanted
declarators to have simple identifiers; now, the code that deals with
declarators will use DeclarationNames.

llvm-svn: 59469
2008-11-17 22:58:34 +00:00
Ted Kremenek c775712192 Fold assertion into second valid else branch. This removes a compiler warning
where the control reaches the end of a non-void function and also allows the
compiler to generate better code.  When this assertion is false we can easily
add more else cases.

llvm-svn: 59468
2008-11-17 22:55:12 +00:00
Steve Naroff 773cdc7c0d Fix <rdar://problem/6333904> [sema] message lookup on super is incorrect
Missing special lookup rule in Sema::ActOnInstanceMessage().

llvm-svn: 59467
2008-11-17 22:29:32 +00:00
Douglas Gregor 0f492d1a11 Only test test/CodeGenObjC/synchronized.m as a i686-apple-darwin8 target
llvm-svn: 59463
2008-11-17 20:45:14 +00:00
Douglas Gregor ae2fbad373 Updated IdentifierResolver to deal with DeclarationNames. The names of
C++ constructors, destructors, and conversion functions now have a
FETokenInfo field that IdentifierResolver can access, so that these
special names are handled just like ordinary identifiers. A few other
Sema routines now use DeclarationNames instead of IdentifierInfo*'s.

To validate this design, this code also implements parsing and
semantic analysis for id-expressions that name conversion functions,
e.g.,

  return operator bool();

The new parser action ActOnConversionFunctionExpr takes the result of
parsing "operator type-id" and turning it into an expression, using
the IdentifierResolver with the DeclarationName of the conversion
function. ActOnDeclarator pushes those conversion function names into
scope so that the IdentifierResolver can find them, of course.

llvm-svn: 59462
2008-11-17 20:34:05 +00:00
Chris Lattner 9b3bbe9db7 Implement rdar://6319320: give a good diagnostic for cases where people
are trying to use the old GCC "casts as lvalue" extension.  We don't and
will hopefully never support this.

llvm-svn: 59460
2008-11-17 19:51:54 +00:00
Steve Naroff 753567f2c1 Fix <rdar://problem/6316324> [sema] spurious warning on comparison of qualified id.
llvm-svn: 59459
2008-11-17 19:49:16 +00:00
Ted Kremenek f9f58f085d Updated checker build.
llvm-svn: 59457
2008-11-17 19:26:13 +00:00
Fariborz Jahanian e3126a24e3 Test case for objective-c's @synchronized statement.
llvm-svn: 59451
2008-11-17 18:03:28 +00:00
Douglas Gregor accde4343c Add TODO item for adding more source-range information to declarators
llvm-svn: 59446
2008-11-17 17:14:10 +00:00
Steve Naroff ecf2bb8724 Fix <rdar://problem/6320086> parser rejects block capturing ivar.
llvm-svn: 59444
2008-11-17 16:28:52 +00:00
Douglas Gregor d69246bd5b Some cleanups for C++ operator overloading
llvm-svn: 59443
2008-11-17 16:14:12 +00:00
Douglas Gregor 9edcc802c3 Simplify error messages for two-parameter overloaded increment/decrement operators
llvm-svn: 59442
2008-11-17 15:03:30 +00:00
Douglas Gregor 77324f3854 Introduction the DeclarationName class, as a single, general method of
representing the names of declarations in the C family of
languages. DeclarationName is used in NamedDecl to store the name of
the declaration (naturally), and ObjCMethodDecl is now a NamedDecl.

llvm-svn: 59441
2008-11-17 14:58:09 +00:00
Chris Lattner d1f5e5d304 pad header out to 80 cols
llvm-svn: 59438
2008-11-17 04:06:37 +00:00
Chris Lattner 8ae89ca65e add OperatorKinds.* to the project.
llvm-svn: 59437
2008-11-17 04:05:52 +00:00
Chris Lattner bcca40b264 line up some columns, no functionality change.
llvm-svn: 59436
2008-11-17 04:03:07 +00:00
Eli Friedman dcbcbb827d A few corrections to the expr constant work. Not enabled at the
moment.

llvm-svn: 59435
2008-11-17 03:57:28 +00:00
Anders Carlsson 4425d8e37b More expr constant work. (Off by default).
llvm-svn: 59433
2008-11-17 01:58:55 +00:00
Anders Carlsson 899c7050b6 Address some comments Eli had.
llvm-svn: 59430
2008-11-16 22:46:56 +00:00
Nuno Lopes 527b5a6858 use HandleConversionToBool() to check if a given cond is foldable (per Eli's comment)
llvm-svn: 59429
2008-11-16 22:06:39 +00:00
Anders Carlsson 9ddf7bedf9 More complex float evaluator support.
llvm-svn: 59428
2008-11-16 21:51:21 +00:00
Chris Lattner 807e8c5d63 Describe how constant folding and i-c-e diagnosing should work.
Unfortunately, we're not here yet, but eventually Expr::isConstantExpr
and friends should go away.

llvm-svn: 59427
2008-11-16 21:48:07 +00:00
Chris Lattner 67d7b9204c rename Expr::tryEvaluate to Expr::Evaluate.
llvm-svn: 59426
2008-11-16 21:24:15 +00:00
Anders Carlsson 537969c237 Add very limited support for evaluating complex floats.
llvm-svn: 59425
2008-11-16 20:27:53 +00:00
Chris Lattner 1b03f76113 Trivial tidying
llvm-svn: 59424
2008-11-16 20:22:05 +00:00
Chris Lattner e0a828ee41 add PTHLexer.h to project
llvm-svn: 59423
2008-11-16 20:18:49 +00:00
Nuno Lopes e236a48210 fix folding of comma if given a non-constant operand.
Eli please take a look, as I'm not sure if this gets the extension warning in the right place

llvm-svn: 59422
2008-11-16 20:09:07 +00:00
Nuno Lopes 420426100c make IntExprEvaluator fold the ?: operator
llvm-svn: 59421
2008-11-16 19:28:31 +00:00
Anders Carlsson 9f9e4249cc More work on the constant evaluator. Eli, it would be great if you could have a look at this.
llvm-svn: 59420
2008-11-16 19:01:22 +00:00
Chris Lattner 962b4eed9d Fix PR3075, __builtin_stdarg_start being misprototyped. This affects netbsd headers.
llvm-svn: 59419
2008-11-16 18:43:46 +00:00
Chris Lattner e6de6252c2 Fix PR3077: tokens that come from macro expansions whose macro was
defined in a system header should be treated as system header tokens
even if they are instantiated in a different place.

llvm-svn: 59418
2008-11-16 18:36:34 +00:00
Zhongxing Xu e76577a97d add targe triple commandline option to fix test failure on Linux.
llvm-svn: 59412
2008-11-16 09:17:52 +00:00
Chris Lattner 981f33b0b6 add dump and print methods, add operator<< for APValue.
llvm-svn: 59411
2008-11-16 07:46:48 +00:00
Chris Lattner 85d1908caf move some APValue methods out of line.
llvm-svn: 59410
2008-11-16 07:35:53 +00:00
Anders Carlsson acc7981883 Add the ability to evaluate comparison operators with floating point numbers as operands.
llvm-svn: 59408
2008-11-16 07:17:21 +00:00
Zhongxing Xu 99a96d6ef3 Enhance modularization: return a <state,loc> pair to let GRExprEngine modify the
environment.

llvm-svn: 59407
2008-11-16 07:06:26 +00:00
Anders Carlsson 430887742e More constant expr work.
llvm-svn: 59405
2008-11-16 06:23:45 +00:00
Chris Lattner 9ce8a533cd daniel prefers completed thoughts.
llvm-svn: 59404
2008-11-16 06:16:27 +00:00
Zhongxing Xu a3b2ef6fa9 Re-enable array-struct test.
llvm-svn: 59396
2008-11-16 04:47:39 +00:00
Zhongxing Xu ceca80619f Enhances SCA to process untyped region to typed region conversion.
- RegionView and RegionViewMap is introduced to assist back-mapping from
   super region to subregions.
 - GDM is used to carry RegionView information.
 - AnonTypedRegion is added to represent a typed region introduced by pointer
   casting. Later AnonTypedRegion can be used in other similar cases, e.g.,
   malloc()'ed region.
 - The specific conversion is delegated to store manager.

llvm-svn: 59382
2008-11-16 04:07:26 +00:00
Chris Lattner e132e2432a Start implementing support for @synchonized with the darwin ObjC API.
Patch by Fariborz!

llvm-svn: 59377
2008-11-15 21:26:17 +00:00
Anders Carlsson ee0d90fe30 Check in code that uses tryEvaluate for emitting constant exprs (not used yet).
llvm-svn: 59375
2008-11-15 20:45:50 +00:00
Anders Carlsson c2480a5589 Handle padding in the constant CFString struct. Fixes PR3046.
llvm-svn: 59372
2008-11-15 18:54:24 +00:00
Anders Carlsson c9dacf4fdd Use IgnoreParenCasts. No functionality change.
llvm-svn: 59371
2008-11-15 18:52:06 +00:00
Zhongxing Xu 461b4f4276 Use the allocator of ExplodedGraph. The whole static analysis module uses it.
llvm-svn: 59359
2008-11-15 08:19:58 +00:00
Anders Carlsson 312045115e Fix silly bug spotted by Daniel Dunbar
llvm-svn: 59358
2008-11-15 06:35:36 +00:00
Zhongxing Xu 6a276cf5b7 Improve zero value generation.
llvm-svn: 59356
2008-11-15 05:18:50 +00:00
Zhongxing Xu fe354a200a Add isUnsigned option.
llvm-svn: 59355
2008-11-15 05:17:04 +00:00
Ted Kremenek 1b2dace792 Reduce permissiveness of assertion.
llvm-svn: 59354
2008-11-15 05:00:27 +00:00
Ted Kremenek 9f748e23e3 Updated checker build.
llvm-svn: 59353
2008-11-15 04:57:19 +00:00
Ted Kremenek 3ebd7dea7e Add a test case for compound assignments that lazily symbolicate the value of the LHS when the computation type is an integer of more bits.
llvm-svn: 59352
2008-11-15 04:44:13 +00:00
Ted Kremenek 4413714946 Reverted part of r59335: http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20081110/009243.html
In that patch I added a bogus type promotion for unary '!'.

The real bug was more fallout from edges cases with compound assignments and conjured symbolic values.  Now the conjured value has the type of the LHS expression, and we do a promotion to the computation type.  We also now correctly do a conversion from the computation type back to the LHS type.

llvm-svn: 59349
2008-11-15 04:01:56 +00:00
Ted Kremenek ac172fc574 Re-enable an assertion that I mistakenly removed.
llvm-svn: 59348
2008-11-15 02:35:08 +00:00
Anders Carlsson d0e4f2b106 Handle complex return values.
llvm-svn: 59345
2008-11-15 01:29:05 +00:00
Ted Kremenek 519a223056 Use the correct QualType when creating the '0' constant.
llvm-svn: 59343
2008-11-15 00:40:08 +00:00
Ted Kremenek 1ca3346b19 Implement FIXME in GRExprEngine::VisitUnaryOperator() to handle implicit conversions caused by the '!' operator. This required adding some logic to GRSimpleVals to reason about nonloc::LocAsInteger SVals. This code appears to work fine, but it should eventually be cleaned up.
llvm-svn: 59335
2008-11-15 00:20:05 +00:00
Ted Kremenek 7eee049eea Flush llvm::errs() when printing out SVals.
llvm-svn: 59334
2008-11-15 00:16:53 +00:00
Zhongxing Xu c381841e99 Add handy method.
llvm-svn: 59332
2008-11-14 23:49:15 +00:00
Sebastian Redl ccdfabab35 Implement parsing and semantic checking of the 'mutable' keyword.
Thanks to Doug for the review. Actual effects of mutable to follow.

llvm-svn: 59331
2008-11-14 23:42:31 +00:00
Argyrios Kyrtzidis 494d410b32 Use ReadPtr, not ReadUIntPtr through a reinterpret_cast.
Thanks to Sebastian for the suggestion.

llvm-svn: 59330
2008-11-14 23:32:45 +00:00
Argyrios Kyrtzidis d800fd96af Remove Parser::isTokenUnqualifiedId, it's not getting used anywhere.
llvm-svn: 59323
2008-11-14 21:41:24 +00:00
Steve Naroff a610ab3283 Fix <rdar://problem/6372970> clang ObjC rewriter: incorrect cast when passing block argument
SynthBlockInitExpr() was not adding by-ref arguments to the init expr.

llvm-svn: 59322
2008-11-14 21:36:12 +00:00
Ted Kremenek fc419a035f Minor tweaks to liveness analysis:
- Block-expression for 'ObjCForCollectionStmt' is not alive before it occurs
- Recursively visit 'element' expression for ObjCForCollectionStmt to get liveness for referenced block-level expressions and variables.

llvm-svn: 59316
2008-11-14 21:07:14 +00:00
Ted Kremenek 537f6387a2 Second attempt at implementation transfer function support for ObjCForCollectionStmt. We now assume that the 'element' expression can be any lvalue.
llvm-svn: 59313
2008-11-14 19:47:18 +00:00
Ted Kremenek 8959a1a69a Flow-sensitive uninitialized values analysis: properly handle the 'element' expression of ObjCForCollectionStmt (can be anything).
llvm-svn: 59312
2008-11-14 18:21:25 +00:00
Douglas Gregor 993603d80d Add a new expression node, CXXOperatorCallExpr, which expresses a
function call created in response to the use of operator syntax that
resolves to an overloaded operator in C++, e.g., "str1 +
str2" that resolves to std::operator+(str1, str2)". We now build a
CXXOperatorCallExpr in C++ when we pick an overloaded operator. (But
only for binary operators, where we actually implement overloading)

I decided *not* to refactor the current CallExpr to make it abstract
(with FunctionCallExpr and CXXOperatorCallExpr as derived
classes). Doing so would allow us to make CXXOperatorCallExpr a little
bit smaller, at the cost of making the argument and callee accessors
virtual. We won't know if this is going to be a win until we can parse
lots of C++ code to determine how much memory we'll save by making
this change vs. the performance penalty due to the extra virtual
calls.

llvm-svn: 59306
2008-11-14 16:09:21 +00:00
Steve Naroff 2a2a41fa11 Fix <rdar://problem/6370288> clang ObjC rewriter: Too many _objc_symtab, _OBJC_SYMBOLS
llvm-svn: 59301
2008-11-14 14:10:01 +00:00
Douglas Gregor be35ce953e Don't require us to manually number the statements and expressions in StmtNodes.def. We don't need stable numbers yet, renumbering is a pain, and LAST_STMT had the wrong value anyway.
llvm-svn: 59300
2008-11-14 12:46:07 +00:00
Zhongxing Xu c967d03528 Improve comments.
llvm-svn: 59294
2008-11-14 09:23:38 +00:00
Ted Kremenek 99d4ff3c7a Handle the case where 'element' in ObjCforCollectionstmt is not a DeclStmt or DeclRefExpr.
llvm-svn: 59290
2008-11-14 01:58:12 +00:00
Ted Kremenek 5cf87ff564 Fix CFG construction for ObjCForCollectionStmt: 'element' expression can be anything that evaluates to an lvalue
llvm-svn: 59289
2008-11-14 01:57:41 +00:00
Ted Kremenek 33d2dae0d4 Update Xcode project.
llvm-svn: 59285
2008-11-14 01:16:15 +00:00
Ted Kremenek a9d3e6c087 Rename header file.
Update include files.

llvm-svn: 59284
2008-11-14 01:14:18 +00:00
Ted Kremenek 63f4398e0b Rename ExprDeclBitVector to BlkExprDeclBitVector, and store mappings from Stmt* to bit indices instead using Expr*.
llvm-svn: 59283
2008-11-14 01:13:07 +00:00
Daniel Dunbar 62efa23518 Fix some validation errors.
llvm-svn: 59272
2008-11-13 23:01:34 +00:00
Daniel Dunbar ed40bc19c9 Start a "hacking" page with some simple notes on getting started
developing clang.

llvm-svn: 59270
2008-11-13 22:49:41 +00:00
Steve Naroff c9337928c1 Add file to VC++ project.
llvm-svn: 59261
2008-11-13 21:16:53 +00:00
Douglas Gregor 58e008d2a6 Some cleanup for the implementation of built-in operator
candidates. Thanks to Chris for the review!

llvm-svn: 59260
2008-11-13 20:12:29 +00:00
Steve Naroff f8cfd1647e Fix an obscure rewriter bug when rewriting implementations that don't have a corresponding interface (found while doing random testing on another bug).
llvm-svn: 59259
2008-11-13 20:07:04 +00:00
Chris Lattner 0046de17e5 Fix a couple of suboptimalities in error recovery.
1. In the top level of ParseStatementOrDeclaration, don't eat a } if we
   just parsed a statement if it list there.  Also, don't even bother
   emitting an error about a missing semicolon if the statement had a 
   bug (an rbrace is fine).
2. In do/while parsing, don't require a 'while' to be present if the do
   body didn't parse.

This allows us to generate a clean diagnostic for this code:

t.c:1:22: error: expected expression
void foo (void) { do . while (0); }
                     ^

Thanks to Neil for pointing this out.

llvm-svn: 59256
2008-11-13 18:52:53 +00:00
Chris Lattner f3e388d1bf don't highlight field name, just put a caret on it.
llvm-svn: 59255
2008-11-13 18:49:38 +00:00
Chris Lattner 7464fc784e disable these two tests, they crash and take a long time to run crashreporter etc.
llvm-svn: 59254
2008-11-13 18:45:47 +00:00
Chris Lattner 9226b92563 implement a fixme :), switch to -verify mode.
llvm-svn: 59253
2008-11-13 18:42:17 +00:00
Steve Naroff 832d89012f Fix <rdar://problem/6343942> clang ObjC rewriter: crash rewriting blocks
and <rdar://problem/6344601> clang ObjC rewriter: crash passing Block parameter?

llvm-svn: 59251
2008-11-13 17:40:07 +00:00
Ted Kremenek a0d2a1661a Using llvm::OwningPtr<> for CurLexer and CurTokenLexer. This makes both the ownership semantics of these objects explicit within the Preprocessor and also tightens up the code (explicit deletes not needed).
llvm-svn: 59249
2008-11-13 17:11:24 +00:00
Ted Kremenek 7c1e61d78b Use PushIncludeMacroStack/PopMacroStack instead of manually pushing/popping from IncludeMacroStack. This is both cleaner and makes the include stack transparently extensible.
llvm-svn: 59248
2008-11-13 16:51:03 +00:00
Ted Kremenek 9df654fa95 Update Xcode project.
llvm-svn: 59247
2008-11-13 16:36:43 +00:00
Ted Kremenek 7d5389e4b3 - Revert r59229 and r59232: AllocRegion should be immutable.
- Temporarily disabled test Analysis/array-struct.c for region store.

llvm-svn: 59245
2008-11-13 15:42:31 +00:00
Zhongxing Xu d4e72fca45 Process array base expression of any type.
llvm-svn: 59240
2008-11-13 09:48:44 +00:00
Zhongxing Xu e9857ddcc0 Add test for unsigned array index.
llvm-svn: 59239
2008-11-13 09:20:05 +00:00
Zhongxing Xu 189a30796a Array index might be unsigned. We have to generate a temporary signed value for
it to be evaluated by APSInt::operators.

llvm-svn: 59238
2008-11-13 09:15:14 +00:00
Zhongxing Xu b9ec8f555f Add test for incomplete struct pointer.
llvm-svn: 59236
2008-11-13 08:44:52 +00:00
Zhongxing Xu 29188c2948 Incomplete struct pointer can be used as a function argument.
llvm-svn: 59235
2008-11-13 08:41:36 +00:00
Zhongxing Xu 06a04bd1ae Add a test case for alloca().
llvm-svn: 59233
2008-11-13 07:59:15 +00:00
Zhongxing Xu 0dbeeaa886 Lift the pointer to alloca'ed region to the pointer to its first element.
This is required by some operations, e.g., *p = 1; p[0] = 1;.
Also set the AllocaRegion's type during the cast.

llvm-svn: 59232
2008-11-13 07:58:20 +00:00
Zhongxing Xu a70987eb82 Change AllocaRegion to subclass TypedRegion. We need to know ElementRegion's
type when assigning to it.

llvm-svn: 59229
2008-11-13 07:30:58 +00:00
Ted Kremenek 9f164c96bf Hook up "BodyBlock", not "Block".
llvm-svn: 59227
2008-11-13 07:01:10 +00:00
Ted Kremenek 1516dc075a Correctly connect 'continue' and 'break' statements in Objective-C fast enumeration for blocks to the appropriate basic blocks.
llvm-svn: 59226
2008-11-13 06:36:45 +00:00
Ted Kremenek 16866d6fd8 GRExprEngine/CFRefCount/GRSimpleVals: We don't do any special handling (yet) of vector types. Add explicit checks that when we process integers that they really are scalars.
llvm-svn: 59225
2008-11-13 06:10:40 +00:00
Eli Friedman 5a332ea01f Fix for crash issues with comma operators with a void first operand, and
some more bullet-proofing/enhancements for tryEvaluate.  This shouldn't 
cause any behavior changes except for handling cases where we were 
crashing before and being able to evaluate a few more cases in tryEvaluate.
 
This should settle the minor mess surrounding r59196.

llvm-svn: 59224
2008-11-13 06:09:17 +00:00
Daniel Dunbar 4b27eb4d26 Obey the FIXMES!
- Resume running the always inliner pass always now that LLVM has
   been improved and functions with debug info can be inlined.
 - Remove unused header.

llvm-svn: 59223
2008-11-13 05:29:02 +00:00
Ted Kremenek 75db6d7529 Fix uninitialized variable.
llvm-svn: 59222
2008-11-13 05:26:15 +00:00
Daniel Dunbar f3502dbc14 [LLVM up] Update for raw_fd_ostream change. This fixes a FIXME that
the Backend output should be done in binary mode.
 - I'd appreciate it if someone who has a Windows build could verify
   this.

llvm-svn: 59221
2008-11-13 05:09:21 +00:00
Ted Kremenek 45698bf05f GRExprEngine::VisitInitListExpr:
- Don't crash on vector types.
- Handle typedefs.

llvm-svn: 59220
2008-11-13 05:05:34 +00:00
Daniel Dunbar f7fb75044f Easy IRgen improvement for bitfields, don't emit x >> 0.
- Logic such as this quite possibly should be optional builder
   behavior.

llvm-svn: 59213
2008-11-13 02:20:34 +00:00
Eli Friedman 8553a98b8e Backout of r59196, plus a new ICE test. Sorry if this is a
little rude; I figure it's cleaner to just back this out now so 
it doesn't get forgotten or mixed up with other checkins.

The modification to isICE is simply wrong; I've added a test that the 
change to isICE breaks.

I'm pretty sure the modification to tryEvaluate is also wrong.  
At the very least, there's some serious miscommunication going on here, 
as this is going in exactly the opposite direction of r59105.  My 
understanding is that tryEvaluate is not supposed to care about side 
effects.  That said, a lot of the clients to tryEvaluate are 
expecting it to enforce a no-side-effects policy, so we probably need 
another method that provides that guarantee.

llvm-svn: 59212
2008-11-13 02:13:11 +00:00
Daniel Dunbar df21c6e203 Supply finished flag to EmitBlock for common statements which use
landing pads.
 - Primarily a cleanliness issue instead of a performance issue (this
   eliminates all blocks w/o predecessors on 176.gcc/expr.c), but this
   also allows subsequent code to recognize it is unreachable and
   potentially avoid IRgen.

llvm-svn: 59211
2008-11-13 01:54:24 +00:00
Daniel Dunbar a612e79be4 Normalize many BasicBlock names.
- Use dotted notation for blocks related to a particular statement
   type.
 - Use .end for landing pads.

No functionality change in NDEBUG mode. :)

llvm-svn: 59210
2008-11-13 01:38:36 +00:00
Ted Kremenek 83844100fb Revert to older checker build.
llvm-svn: 59209
2008-11-13 01:30:19 +00:00
Daniel Dunbar fcac22eac1 Add IsFinished arg to EmitBlock.
- Indicates that caller is done with the block and it can be dropped
   if it has no predecessors. Useful for callers who need to make
   landing pads but which may not be reached.

No functionality change.

llvm-svn: 59207
2008-11-13 01:24:05 +00:00
Ted Kremenek d0e32791d5 Update checker build.
llvm-svn: 59206
2008-11-13 01:23:50 +00:00
Daniel Dunbar f75c823e5c For if blocks with no else, name the join block ifend instead of the
more confusing ifelse.

Use dotted names for if blocks (if.then vs ifthen).

llvm-svn: 59201
2008-11-13 00:47:57 +00:00
Ted Kremenek ce9082ad5c Fix bug where the body block of an ObjCForCollectionStmt would not properly get expanded as a series of basic blocks.
llvm-svn: 59197
2008-11-13 00:06:59 +00:00
Daniel Dunbar c7ec5fcf24 Fix bug in constant evaluation exposed by 176.gcc.
- Evaluation of , operator used bogus assumption that LHS could be
   evaluated as an integral expression even though its type is
   unspecified.

This change is making isICE very permissive of the LHS in non-evaluated 
contexts because it is not clear what predicate we would use to reject 
code here. The standard didn't offer me any guidance; opinions?

llvm-svn: 59196
2008-11-13 00:03:19 +00:00
Ted Kremenek e9c16a6a79 Updated checker build.
llvm-svn: 59195
2008-11-12 23:26:57 +00:00
Douglas Gregor b6acda0f36 Don't build identifiers for C++ constructors, destructors, or
conversion functions. Instead, we just use a placeholder identifier
for these (e.g., "<constructor>") and override NamedDecl::getName() to
provide a human-readable name.

This is one potential solution to the problem; another solution would
be to replace the use of IdentifierInfo* in NamedDecl with a different
class that deals with identifiers better. I'm also prototyping that to
see how it compares, but this commit is better than what we had
previously.

llvm-svn: 59193
2008-11-12 23:21:09 +00:00
Douglas Gregor c208f4617c Fix compilation on 64-bit targets
llvm-svn: 59192
2008-11-12 23:17:06 +00:00
Ted Kremenek 66312a3ff4 Move some diagnostic handling to PreprocessorLexer.
llvm-svn: 59191
2008-11-12 23:13:54 +00:00
Ted Kremenek 3060634fba Add virtual dtor to PreprocessorLexer.
llvm-svn: 59188
2008-11-12 22:48:57 +00:00
Ted Kremenek 9d39e377df Add LexIncludeFilename.
llvm-svn: 59187
2008-11-12 22:46:33 +00:00
Ted Kremenek 2f4f2dea82 Remove Lexer::LexIncludeFilename.
llvm-svn: 59186
2008-11-12 22:44:15 +00:00
Ted Kremenek 6c90efb923 Move LexIncludeFilename from Lexer to PreprocessorLexer.
PreprocessorLexer now has a virtual method "IndirectLex" which allows it to call the lex method of its subclasses.  This is not for performance intensive operations.

llvm-svn: 59185
2008-11-12 22:43:05 +00:00
Daniel Dunbar f32443cdcd Quick fix for crash in IRgen when we can tryEvaluate a condition to
something that is not an int.

 - Ignore these cases for now, added FIXME that we should also boolize
   them.

llvm-svn: 59184
2008-11-12 22:37:10 +00:00
Ted Kremenek 50b4f48225 Use PushIncludeMacroStack() instead of manually manipulating the include stack.
llvm-svn: 59181
2008-11-12 22:21:57 +00:00
Ted Kremenek 50b84bb5f6 Unbreak last commit.
llvm-svn: 59180
2008-11-12 22:19:18 +00:00
Ted Kremenek f5518cc95b Add Preprocessor::PushIncludeMacroStack() and Preprocessor::PopIncludeMacroStack(), two utility methods for manipulating the Preprocessor stack. These will be used to remove manually manipulation of IncludeMacroStack from the rest of the Preprocessor implementation.
llvm-svn: 59179
2008-11-12 22:10:22 +00:00
Ted Kremenek 65dd30fdea Update CFGStmtVisitor to recognize that ObjCForCollectionStmts are special block-level "expressions".
llvm-svn: 59176
2008-11-12 21:58:46 +00:00
Daniel Dunbar a461e6d124 Disable some debug prints.
llvm-svn: 59174
2008-11-12 21:52:46 +00:00
Douglas Gregor 63eb9386b7 Slightly improve type hash
llvm-svn: 59173
2008-11-12 21:52:20 +00:00
Ted Kremenek 7cd62457c4 Add skeleton for PTH lexer.
llvm-svn: 59169
2008-11-12 21:37:15 +00:00
Ted Kremenek 3a460b1106 Move pieces of Lexer that the Preprocessor mutates to a new base class 'PreprocessorLexer'. This will also be the base class of the new Preprocessed-Token-Header (PTH) lexer. No functionality change.
llvm-svn: 59168
2008-11-12 21:33:59 +00:00
Chris Lattner 6515bcc3c6 Fix a FIXME by improving a diagnostic, add a testcase for PR3048
llvm-svn: 59167
2008-11-12 21:25:45 +00:00
Sebastian Redl 15b7160a17 64-bit test fixes.
llvm-svn: 59165
2008-11-12 21:19:11 +00:00
Chris Lattner ffb31a23a5 make TryFixInvalidVariablyModifiedType a static function.
llvm-svn: 59163
2008-11-12 21:17:48 +00:00
Ted Kremenek df31792a66 Shore up transfer function for ObjCForCollectionStmt.
llvm-svn: 59162
2008-11-12 21:12:46 +00:00
Ted Kremenek 97450fe0a1 Use Stmt* instead of Expr* for block-level expression.
llvm-svn: 59161
2008-11-12 21:12:18 +00:00
Ted Kremenek 6d8b46e71d ObjCForCollectionStmts are block-level expressions.
llvm-svn: 59160
2008-11-12 21:11:49 +00:00
Chris Lattner b5da7a342c Restructure code to encourage fallthrough, no functionality change.
llvm-svn: 59157
2008-11-12 19:48:13 +00:00
Chris Lattner e7d1cdb6fd fix PR3048. I'm going to do some more work before closing it off and
adding a testcase.

llvm-svn: 59156
2008-11-12 19:45:49 +00:00
Ted Kremenek 1781080c34 Add (preliminary) transfer function support for ObjCForCollectionStmt. Still need to flesh out some logic.
When processing DeclStmt, use the new interface to StateManager::BindDecl.  Conjuring of symbols is now done in VisitDeclStmt.

llvm-svn: 59155
2008-11-12 19:24:17 +00:00
Ted Kremenek 9999d72fe2 Conjured symbols now bind to Stmt* instead of Expr*.
llvm-svn: 59154
2008-11-12 19:22:47 +00:00
Ted Kremenek 60d46414f4 Update method names involving GRStateRef. No functionality change.
llvm-svn: 59153
2008-11-12 19:22:09 +00:00
Ted Kremenek b94d72a0e3 GRStateRef:
- Rename SetSVal to BindLoc
- Add BindDecl
- Add BindExpr

GRState:
- Environment now binds to Stmt* instead of Expr*.  This is needed for processing ObjCForCollectionStmt (essentially the declaration of the the 'element' variable can have an SVal attached to it).
- BindDecl no longer accepts Expr* for the initialization value; use SVal* instead.

llvm-svn: 59152
2008-11-12 19:21:30 +00:00
Ted Kremenek cd639218e4 StoreManager::BindDecl now takes an SVal* for the initialization value instead of an Expr* (which can be null). Lazy symbolication of conjured symbols is now the sole responsibility of GRExprEngine.
llvm-svn: 59151
2008-11-12 19:18:35 +00:00
Douglas Gregor a11693bc37 Implement support for operator overloading using candidate operator
functions for built-in operators, e.g., the builtin

  bool operator==(int const*, int const*)

can be used for the expression "x1 == x2" given:

  struct X {
    operator int const*();
  } x1, x2;

The scheme for handling these built-in operators is relatively simple:
for each candidate required by the standard, create a special kind of
candidate function for the built-in. If overload resolution picks the
built-in operator, we perform the appropriate conversions on the
arguments and then let the normal built-in operator take care of it. 

There may be some optimization opportunity left: if we can reduce the
number of built-in operator overloads we generate, overload resolution
for these cases will go faster. However, one must be careful when
doing this: GCC generates too few operator overloads in our little
test program, and fails to compile it because none of the overloads it
generates match.

Note that we only support operator overload for non-member binary
operators at the moment. The other operators will follow.

As part of this change, ImplicitCastExpr can now be an lvalue.

llvm-svn: 59148
2008-11-12 17:17:38 +00:00
Daniel Dunbar 2889780436 Start a README.txt of possible optimizations to do in IRgen.
llvm-svn: 59130
2008-11-12 12:31:28 +00:00
Daniel Dunbar bf3c22e51d Handle ?: in EmitBranchOnBoolExpr.
llvm-svn: 59129
2008-11-12 10:30:32 +00:00
Daniel Dunbar d2a53a7b77 Rename ?: operator blocks to cond.true and cond.false (I don't know
what "cond.?" means, and this avoids quoting).

llvm-svn: 59128
2008-11-12 10:13:37 +00:00
Daniel Dunbar 682712cda0 Comment/indentation fix.
llvm-svn: 59127
2008-11-12 10:12:14 +00:00
Eli Friedman 9a156e5c1e Some additions to tryEvaluate I've had sitting around for a while.
This pushes it a lot closer to being able to deal with most of the stuff 
CodeGen's constant expression evaluator knows how to deal with.  This 
also fixes PR3003.

The test could possibly use some improvement, but this'll work for now.  
Test 6 is inspired by PR3003; the other tests are mostly just designed
to exercise the new code.  The reason for the funny structure of the 
tests is that type fixing for arrays inside of structs is the only place 
in Sema that calls tryEvaluate, at least for the moment.

llvm-svn: 59125
2008-11-12 09:44:48 +00:00
Chris Lattner 3fd91f83fd Lower ?: into select when the selected values are cheap and side-effect-free.
This cuts another 200 lines off expr.ll, forming 23 selects.

llvm-svn: 59124
2008-11-12 08:55:54 +00:00