Commit Graph

886 Commits

Author SHA1 Message Date
Ted Kremenek
292b3842a0 Use DeclStmt::getSolitaryDecl() instead of DeclStmt::getDecl() when rewriting Objective-c foreach statements.
llvm-svn: 57212
2008-10-06 22:16:13 +00:00
Ted Kremenek
53532c1fda In RewriteFunctionBody, using DeclStmt::decl_iterator to rewrite the Decls in a DeclStmt instead of using getDecl() to fetch the first Decl.
Steve: Please review this patch.  'make test' passes, and my cursory scan of the rewriter leads me to believe this doesn't break anything, but I'm not sure.
llvm-svn: 57195
2008-10-06 18:47:09 +00:00
Daniel Dunbar
374b8b4269 Allow -verify to be used with -rewrite-macros.
llvm-svn: 57093
2008-10-05 01:38:39 +00:00
Daniel Dunbar
6b57b45b4d Add dummy -ast-dump support for ObjC category implementations.
llvm-svn: 57087
2008-10-05 00:31:15 +00:00
Steve Naroff
8f9be42072 Remove old diag that alerted the user to a limitation we no longer have:-)
llvm-svn: 57086
2008-10-05 00:12:46 +00:00
Steve Naroff
02da7667d2 Create a function, eliminating some redundancy between SynthesizeBlockInitExpr() and SynthesizeBlockLiterals().
llvm-svn: 57083
2008-10-05 00:06:12 +00:00
Steve Naroff
c7a80a5533 Finish implementing copy/dispose helpers for imported block decls.
llvm-svn: 57082
2008-10-04 23:47:37 +00:00
Daniel Dunbar
e773d5ff16 Set exit code properly on "Unexpected program action".
llvm-svn: 57080
2008-10-04 23:42:49 +00:00
Steve Naroff
4017d15fed Add indirection required for byref BlockDeclRefExpr's.
llvm-svn: 57063
2008-10-04 18:52:47 +00:00
Steve Naroff
564e97a2de Handle bookkeeping for imported blocks (in SynthesizeBlockImpl).
This code was "lost" with my recent changes to SynthesizeBlockFunc.

llvm-svn: 57056
2008-10-04 18:00:11 +00:00
Steve Naroff
87b9d298b8 Cut/paste error...need to use the expression "name" for member references (or other complex expressions that can embed a block pointer type)
llvm-svn: 57054
2008-10-04 17:45:51 +00:00
Steve Naroff
756efbc7f7 Clear the map that associated the rewritten block with it's corresponding BlockExpr.
llvm-svn: 57053
2008-10-04 17:10:02 +00:00
Steve Naroff
5f96e4dffc Moved main control flow functions to bottom of file.
Reworked control flow to:
- rewrite the block expr body "in place".
- used Chris's new rewriter hook "getRewritenText" to "lift" the text for later use.
- finally, we do the block expr text replacement.

llvm-svn: 57052
2008-10-04 17:06:23 +00:00
Steve Naroff
3d5a11c622 Remove an old/vacuous if clause.
llvm-svn: 57036
2008-10-03 23:00:50 +00:00
Steve Naroff
e3e45a8c43 More fun & games with the block rewriter.
llvm-svn: 57028
2008-10-03 20:28:15 +00:00
Steve Naroff
a2d71df5b9 Rewrite global block expressions.
llvm-svn: 57004
2008-10-03 15:38:09 +00:00
Steve Naroff
239f6f9b24 - Add a convenience constructor to Type.
- Many rewriter modifications.

llvm-svn: 57003
2008-10-03 15:04:50 +00:00
Steve Naroff
7bf080c9cc Rework SynthesizeBlockImpl() to include a constructor.
llvm-svn: 57001
2008-10-03 12:09:49 +00:00
Daniel Dunbar
15619c7e4b Pass postfix attributes to ActOnFields.
llvm-svn: 56992
2008-10-03 02:03:53 +00:00
Steve Naroff
49428dbdd5 Get the right location to insert the synthesized block literals/functions.
llvm-svn: 56987
2008-10-03 00:12:09 +00:00
Steve Naroff
ddb1492288 Name changes and some cleanup of preamble.
llvm-svn: 56984
2008-10-02 23:30:43 +00:00
Steve Naroff
d40a39626c Changed Sema::CheckForConstantInitializer to allow global block literals.
This commit also includes some name changes in the blocks rewriter (no functionality change).

llvm-svn: 56955
2008-10-02 17:12:56 +00:00
Daniel Dunbar
d03c02873a (llvm up) If the target triple is unspecified, automatically set the
OS version part to that of the host on darwin.

llvm-svn: 56943
2008-10-02 01:21:33 +00:00
Daniel Dunbar
4dd154663e Drop code to validate OS part of target triple on darwin, too fragile.
llvm-svn: 56941
2008-10-02 00:26:24 +00:00
Daniel Dunbar
106ab3bb42 Fix help for --suppress-system-warnings
llvm-svn: 56878
2008-09-30 20:49:53 +00:00
Chris Lattner
97d749464d Handle minor version numbers in __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
like "10.3.9"

llvm-svn: 56873
2008-09-30 20:30:12 +00:00
Chris Lattner
b5c15e8228 Finish handling of -mmacosx-version-min. If you now do something like:
clang -mmacosx-version-min=10.4.9 ...

you'll end up with a target triple like "i686-apple-darwin8.9".

llvm-svn: 56871
2008-09-30 20:16:56 +00:00
Chris Lattner
29c54dd6b9 start handling 'mmacosx-version-min', this is not complete yet.
llvm-svn: 56828
2008-09-30 01:13:12 +00:00
Chris Lattner
b03dc76499 clean up a bunch of fixme's I added, by moving
DirectoryLookup::DirType into SourceManager.h

llvm-svn: 56692
2008-09-26 21:18:42 +00:00
Chris Lattner
71efd8159e fit in 80 cols.
llvm-svn: 56687
2008-09-26 20:05:14 +00:00
Daniel Dunbar
e778131386 Make clang preprocessed output a bit more like gcc output.
llvm-svn: 56636
2008-09-26 01:13:35 +00:00
Steve Naroff
4efed31acf Fix a couple harmless warnings when compiling optimized with gcc (reported by mrs@apple.com).
llvm-svn: 56591
2008-09-24 22:46:45 +00:00
Steve Naroff
c792570eb1 Fix some const-ness to keep the VisualStudio C++ compiler happy.
llvm-svn: 56560
2008-09-24 17:22:34 +00:00
Steve Naroff
92559af851 RewriteBlocks::RewriteBlockPointerDecl(): Handle TypedefDecl's and VarDecl's uniformly.
llvm-svn: 56500
2008-09-23 21:15:53 +00:00
Steve Naroff
87930ca38f Teach block rewriter to replace '^' with '*' in VarDecls.
Since we don't have DeclGroup's and location information for types, there is some fancy footwork to do this fairly reliably.

O.K...it's a kludge. One day, we can use this as motivation to do this more gracefully:-)

llvm-svn: 56499
2008-09-23 19:24:41 +00:00
Ted Kremenek
f0673e4eb6 Change implementation of NSError** coding-style check to be invoked at the end of the retain/release analysis.
llvm-svn: 56312
2008-09-18 21:25:13 +00:00
Steve Naroff
9779e92fa4 Add driver support for invoking block rewriter.
Also tweaked the create function to take an explicit output file.

llvm-svn: 56305
2008-09-18 14:10:13 +00:00
Ted Kremenek
fc3abeb1e5 Implemented one of the checks requested in PR 2600:
"Method accepting NSError** argument should have non-void return value to indicate that an error occurred."

Test case written, but the header needs to be delta-debugged reduced.  Will commit shortly.

llvm-svn: 56297
2008-09-18 06:33:41 +00:00
Steve Naroff
43bafa78b3 Remove BlockStmtExpr.
Block literals are now represented by the concrete BlockExpr class.
This is cleanup (removes a FIXME).
No functionality change.

llvm-svn: 56288
2008-09-17 18:37:59 +00:00
Steve Naroff
2da868e9c2 Add support for rewriting blocks...
llvm-svn: 56266
2008-09-17 00:13:27 +00:00
Ted Kremenek
2d470fc0ba Patch by Csaba Hruska!
"Here is a patch what replaces std::ostream with llvm::raw_ostream. This patch
covers the AST library, but ignores Analysis lib."

llvm-svn: 56185
2008-09-13 05:16:45 +00:00
Daniel Dunbar
84b70f7f0f Add --suppress-system-warnings (on by default, use =0 to disable)
- For investigating warnings in system headers / builtins.
 - Currently also enables the behavior that allows silent redefinition
   of types in system headers. Conceptually these are separate but I
   didn't feel it was worth two options (or changing LangOptions).

llvm-svn: 56163
2008-09-12 18:10:20 +00:00
Steve Naroff
4adbe3116e Fix <rdar://problem/6210791> clang ObjC rewriter: @try / @catch block with no @finally does not call objc_exception_try_exit.
Need a couple tweaks to RewriteObjCTryStmt(). Need to deal with implicit finally clauses (to make sure objc_exception_try_exit is called). Also fixed a related bug where we need to generate an implicit @catch else clause (to again make sure objc_exception_try_exit is called).

llvm-svn: 56104
2008-09-11 15:29:03 +00:00
Argyrios Kyrtzidis
e7092bafc2 LangOptions.C99 should be false in C++.
llvm-svn: 56092
2008-09-11 04:21:06 +00:00
Douglas Gregor
e972aa471d Add support for expected-note to Clang's -verify option
llvm-svn: 56089
2008-09-11 02:46:36 +00:00
Steve Naroff
fac18fe2ee Fix <rdar://problem/6197841> try, finally with no catch stops the exception from being propagated
llvm-svn: 56004
2008-09-09 19:59:12 +00:00
Nico Weber
b0920374ca rename libclangSEMA to libclangSema
llvm-svn: 55887
2008-09-07 17:09:06 +00:00
Ted Kremenek
2147570258 Change struct forward declarations and definitions to use unique RecordDecls, as opposed to creating a single RecordDecl and reusing it.
This change effects both RecordDecls and CXXRecordDecls, but does not effect EnumDecls (yet).

The motivation of this patch is as follows:
- Capture more source information, necessary for refactoring/rewriting clients.

- Pave the way to resolve ownership issues with RecordDecls with the forthcoming
  addition of DeclGroups.

Current caveats:
- Until DeclGroups are in place, we will leak RecordDecls not explicitly
  referenced by the AST.  For example:

    typedef struct { ... } x;  

  The RecordDecl for the struct will be leaked because the TypedefDecl doesn't
  refer to it.  This will be solved with DeclGroups.
  
- This patch also (temporarily) breaks CodeGen.  More below.

High-level changes:
- As before, TagType still refers to a TagDecl, but it doesn't own it.  When
  a struct/union/class is first referenced, a RecordType and RecordDecl are
  created for it, and the RecordType refers to that RecordDecl.  Later, if
  a new RecordDecl is created, the pointer to a RecordDecl in RecordType is
  updated to point to the RecordDecl that defines the struct/union/class.

- TagDecl and RecordDecl now how a method 'getDefinition()' to return the
  TagDecl*/RecordDecl* that refers to the TagDecl* that defines a particular
  enum/struct/class/union. This is useful from going from a RecordDecl* that
  defines a forward declaration to the RecordDecl* that provides the actual
  definition. Note that this also works for EnumDecls, except that in this case
  there is no distinction between forward declarations and definitions (yet).

- Clients should no longer assume that 'isDefinition()' returns true from a
  RecordDecl if the corresponding struct/union/class has been defined.
  isDefinition() only returns true if a particular RecordDecl is the defining
  Decl. Use 'getDefinition()' instead to determine if a struct has been defined.

- The main changes to Sema happen in ActOnTag. To make the changes more
  incremental, I split off the processing of enums and structs et al into two
  code paths. Enums use the original code path (which is in ActOnTag) and
  structs use the ActOnTagStruct. Eventually the two code paths will be merged,
  but the idea was to preserve the original logic both for comparison and not to
  change the logic for both enums and structs all at once.

- There is NO CHAINING of RecordDecls for the same RecordType. All RecordDecls
  that correspond to the same type simply have a pointer to that type. If we
  need to figure out what are all the RecordDecls for a given type we can build
  a backmap.

- The diff in CXXRecordDecl.[cpp,h] is actually very small; it just mimics the
  changes to RecordDecl. For some reason 'svn' marks the entire file as changed.

Why is CodeGen broken:
- Codegen assumes that there is an equivalence between RecordDecl* and
  RecordType*. This was true before because we only created one RecordDecl* for
  a given RecordType*, but it is no longer true. I believe this shouldn't be too
  hard to change, but the patch was big enough as it is.
  
I have tested this patch on both the clang test suite, and by running the static analyzer over Postgresql and a large Apple-internal project (mix of Objective-C and C).  

llvm-svn: 55839
2008-09-05 17:16:31 +00:00
Daniel Dunbar
98e0e535bd Workaround gcc bug causing crash on our preprocessed outputs.
- gcc is not happy if we start a preprocessed file with
#line 1 "XXX" 1
 - Workaround by making sure file starts with a simple #line change.

Also, factored WriteLineInfo out.

Also, fixed bug where FileType was not being correctly updated.

llvm-svn: 55825
2008-09-05 03:22:57 +00:00
Ted Kremenek
47923c7e59 Remove "NextDecl" from RecordDecl. This change touches many files that where RecordDecl or CXXRecordDecl was constructed, always with an argument of 'NULL' for the previous declaration.
The motivation behind this change is that chaining the RecordDecls is simply unnecessary.  Once we create multiple RecordDecls for the same struct/union/class, clients that care about all the declarations of the same struct can build a back map by seeing which Decls refer to the same RecordType.

llvm-svn: 55821
2008-09-05 01:34:33 +00:00