Граф коммитов

337 Коммитов

Автор SHA1 Сообщение Дата
Chris Lattner 9e62171a25 Move handling of __builtin_nan("") out of CGBuiltin.cpp into ExprConstant.cpp
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57157 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 06:31:58 +00:00
Chris Lattner 34a74ab816 Teach FloatExprEvaluator to evaluate __builtin_huge_val and inf.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57154 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 05:53:16 +00:00
Chris Lattner 019f4e858e Add a comment that describes tryEvaluate. Make tryEvaluate fold
__builtin_constant_p properly, and add some scaffolding for
FloatExprEvaluator to eventually handle huge_val and inf.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57152 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 05:28:25 +00:00
Chris Lattner cb88896740 add a new CallExpr::isBuiltinCall() method, and use it to simplify some existing
code.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57151 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 05:00:53 +00:00
Chris Lattner a62a03b282 a more efficient test for __builtin_classify_type
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57149 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06 04:48:17 +00:00
Chris Lattner 61710854be Wrap long lines and other minor cleanups, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57119 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 17:34:18 +00:00
Daniel Dunbar 5620b50f8f Make VectorType printing less broken.
- Print size as number of elements times "sizeof(elt type)", not
   perfect but better than just printing the completely wrong type.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57100 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 05:43:11 +00:00
Zhongxing Xu 924d9a8cb9 Reverse the RHSBlock of LogicalOp && and ||
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57041 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-04 05:48:38 +00:00
Daniel Dunbar f7bb8b91bb Pass postfix attributes to ActOnFields (mismarked a file).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56993 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-03 02:05:12 +00:00
Daniel Dunbar 1bfe1c2129 Pass postfix attributes to ActOnFields.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56992 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-03 02:03:53 +00:00
Steve Naroff 0eb07bfde0 Add getTypeSpecStartLoc() to VarDecls and FunctionDecls.
This is a temporary solution to help with the block rewriter (though it certainly has general utility).
Once DeclGroup's are implemented, this SourceLocation should be stored with it (since it applies to all the decls).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56985 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-03 00:02:03 +00:00
Daniel Dunbar ae3f4919e4 Add Builtins.def attribute for "can be a constant expression".
- Enabled for builtins which are always constant expressions
   (__builtin_huge_val*, __builtin_inf*, __builtin_constant_p,
   __builtin_classify_type, __builtin___CFStringMakeConstantString).

Added Builtin::Context::isConstantExpr.
 - Currently overly simply interface which only works for builtins
   whose constantexprness does not depend on their arguments.

CallExpr::isBuiltinConstantExpr now takes an ASTContext argument.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56983 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-02 23:30:31 +00:00
Chris Lattner f77d545fe9 Fix va_arg handling to do argument decaying at the correct place. This
fixes problems handling references of va_list, which happens on x86_64.
This fixes PR2841 and rdar://6252231


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56809 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-29 22:28:25 +00:00
Chris Lattner 891ed9aa87 Fix rdar://6252231 - cannot call vsnprintf with va_list on x86_64,
by decaying __builtin_va_list's type when forming builtins.  On
x86-64 (and other targets) __builtin_va_list is a typedef for
an array.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56768 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-28 06:05:35 +00:00
Zhongxing Xu c61255f630 Delete trailing white space. It's over 80 columns.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56749 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-27 03:27:29 +00:00
Ted Kremenek 9da13f9ddb Internally store the body of a BlockExpr using a Stmt* instead of a CompoundStmt*, and use the getBody() method to do the appropriate checking. This both removes the type-punning warnings in Expr.cpp and also makes BlockExpr have more consistency checks against modifications to its body (via StmtIterator).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56710 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-26 23:24:14 +00:00
Ted Kremenek 1377e541ea Use a union instead of a bunch of magic casts to implement a variant. This removes the type-punning errors for DeclGroup.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56708 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-26 23:19:04 +00:00
Ted Kremenek 610a09e409 Add CFG support for implicit-control flow for VLA size expressions within an SizeOfAlignOfTypeExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56706 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-26 22:58:57 +00:00
Ted Kremenek 00c0a30acd Do not create CFGs for functions/methods using blocks (need to add control-flow).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56672 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-26 18:17:07 +00:00
Ted Kremenek fcd06f77be Move VLA processing logic from LiveVariables to CFG construction. This way all dataflow analyses "see" the VLA size expressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56655 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-26 16:26:36 +00:00
Steve Naroff 4f6a7d7ead Tweak Expr::isModifiableLvalue() and Expr::isLvalue() to better deal with BlockDeclRef exprs.
This fixes <rdar://problem/6248392> clang: Error when using address of stack variable inside block.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56652 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-26 14:41:28 +00:00
Daniel Dunbar 248e1c01d3 Add # of block pointer types to -print-stats.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56638 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-26 03:23:00 +00:00
Ted Kremenek d17062cc23 Added prototype implementation of the DeclGroup, DeclGroupRef, and DeclGroupOwningRef classes.
Documentation and testing are pending.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56611 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-25 17:13:40 +00:00
Steve Naroff 485eeff9ba Extend ASTContext::getTypeInfo() and ASTContext::getObjCEncodingForType() for BlockTypes.
This fixes <rdar://problem/6240616> clang: Assertion failed when using typedef and Blocks.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56554 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-24 15:05:44 +00:00
Daniel Dunbar e1226d24d2 Bug fix, result of isIntegerConstantExpr could be of incorrect width
for type.
  - PR2817


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56482 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-22 23:53:24 +00:00
Ted Kremenek 7360fda1ef Implement second part of PR 2600: NSError** parameter may be null, and should be checked before being dereferenced.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56318 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-18 23:09:54 +00:00
Steve Naroff 9c3c902835 Remove BlockStmtExpr.
Block literals are now represented by the concrete BlockExpr class.
This is cleanup (removes a FIXME).
No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56288 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-17 18:37:59 +00:00
Steve Naroff 17dab4f616 Remove support for BlockExprExpr. For example...
^(expression) or ^(int arg1, float arg2)(expression)
...is no longer supported. 
All block literals now require a compound statement.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56257 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-16 23:11:46 +00:00
Ted Kremenek d452758bb6 ProgramPoint now takes the space of two pointers instead of one. This change was
motivated because it became clear that the number of subclasses of ProgramPoint
would expand and we ran out of bits to represent a pointer variant. As a plus of
this change, BlockEdge program points can now be represented explicitly without
using a cache of CFGBlock* pairs in CFG.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56245 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-16 18:44:52 +00:00
Ted Kremenek a95d375044 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."


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56185 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-13 05:16:45 +00:00
Douglas Gregor 77a52233f7 Give string literals const element typesin C++, and cope with the deprecated C++ conversion from a string literal to a pointer-to-non-const-character
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56137 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-12 00:47:35 +00:00
Argyrios Kyrtzidis 24b41fa823 CXXConditionDeclExpr expression node is an lvalue.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56093 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-11 04:22:26 +00:00
Argyrios Kyrtzidis 4189a76f55 Change line endings: CRLF -> LF
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56043 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-10 02:14:49 +00:00
Argyrios Kyrtzidis 9e922b1663 Add new 'CXXConditionDeclExpr' expression node used for a 'condition' declaration, e.g: "if (int x=0) {...}".
It is a subclass of DeclRefExpr and the main difference is that CXXConditionDeclExpr owns the declaration that it references.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56033 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-09 23:47:53 +00:00
Steve Naroff 2b255c4dab Tweak implementation for allowing ObjC builtin type redefinitions.
- Replace string comparisons with pre-defined idents.
- Avoid calling isBuiltinObjCType() to avoid two checks. 
- Remove isBuiltinObjCType(), since it was only used in Sema::MergeTypeDefDecl().
- Have Sema::MergeTypeDefDecl() set the new type.

This is a moidified version of an patch by David Chisnall.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55990 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-09 14:32:20 +00:00
Steve Naroff 3c1b912239 Simplify typesAreBlockCompatible().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55989 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-09 13:47:19 +00:00
Steve Naroff dd972f20dc More type checking for blocks. Still incomplete (will hopefully finish up this weekend).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55862 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-05 22:11:13 +00:00
Ted Kremenek 4b7c98378a 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).  


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55839 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-05 17:16:31 +00:00
Ted Kremenek df042e6c2b 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55821 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-05 01:34:33 +00:00
Ted Kremenek e933450535 Fix CFG construction bug:
- Within for loops, 'continue' should jump to a basic block containing the
  increment code


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55800 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-04 21:48:47 +00:00
Steve Naroff bfdcae678d Fix a handful of typos (closure->block) to avoid confusion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55768 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-04 15:31:07 +00:00
Steve Naroff 1c7d067550 Add type checking for blocks.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55767 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-04 15:10:53 +00:00
Steve Naroff 4eb206bebc Add semantic analysis for "blocks".
Highlights...

- 4 new AST nodes, BlockExpr, BlockStmtExpr, BlockExprExpr, BlockDeclRefExpr.
- Sema::ActOnBlockStart(), ActOnBlockError(), ActOnBlockStmtExpr(), ActOnBlockExprExpr(), ActOnBlockReturnStmt().

Next steps...

- hack Sema::ActOnIdentifierExpr() to deal with block decl refs.
- add attribute handler for byref decls.
- add test cases.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55710 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-03 18:15:37 +00:00
Daniel Dunbar e66f4e3e3a Fix ObjCPropertRefExpr to be able to encode all the information for
uses which refer to methods not properties.
 - Not yet wired in Sema.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55681 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-03 00:27:26 +00:00
Ted Kremenek 6359792ca9 RecordDecl:
- Remove method 'isForwardDecl'; this functionality is already provided by
  'isDefinition()'
- Move method definitions to be co-located with other RecordDecl methods.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55649 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-02 21:12:32 +00:00
Ted Kremenek 6812a7308d RecordDecl serialization:
- Don't serialize out the NextDeclarator field.  It is unused and deprecated.
- Serialize out the NextDecl pointer.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55644 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-02 20:42:52 +00:00
Ted Kremenek a39da06576 RecordDecl:
- Added method 'isForwardDeclaration', a predicate method that returns true
  if a RecordDecl represents a forward declaration.
- Added method 'getDefinitionDecl', a query method that returns a pointer to
  the RecordDecl that provides the actual definition of a struct/union.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55642 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-02 20:25:22 +00:00
Ted Kremenek df91eca19b CXXRecordDecl and RecordDecl:
- Change constructor and create methods to accept a CXXRecordDecl* (RecordDecl*)
  instead of a ScopedDecl* for PrevDecl.  This causes the type checking
  to be more tight and doesn't break any code.
  
RecordDecl:

- Don't use the NextDeclarator field in ScopedDecl to represent the previous
  declaration. This is a conflated use of the NextDeclarator field, which will
  be removed anyway when DeclGroups are fully implemented.

- Instead, represent (a soon to be implemented) chain of RecordDecls using a
  NextDecl field.  The last RecordDecl in the chain is always the 'defining'
  RecordDecl that owns the FieldDecls.  The other RecordDecls in the chain
  are forward declarations.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55640 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-02 20:13:32 +00:00
Nuno Lopes b381aac9ba codegen constant data as such. add QualType::isConstant()
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55603 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-01 11:33:04 +00:00
Anders Carlsson bd4c1ada2e Add code to create the fast enumeration state type
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55572 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-30 19:34:46 +00:00