Commit Graph

1894 Commits

Author SHA1 Message Date
Zhongxing Xu 9c15820ea6 Add notes for SCA.
llvm-svn: 58373
2008-10-29 07:05:10 +00:00
Eli Friedman 5adca5f02c Fix for PR2966: va_start/va_end use the *address* of the
va_list, not the value.  Patch fixes an assert on 
x86-64 and a wrong-code bug on x86.  I'm not completely sure, 
but I think it's a regression from r58306.

Does anyone run regression tests regularly on x86-64? The crash should 
have been picked up there.

llvm-svn: 58366
2008-10-29 04:39:20 +00:00
Ted Kremenek 3f04949b2a Patch by Nikita Zhuk:
The attached patch adds additional checks to -warn-objc-missing-dealloc. It checks that all ivars which are used in implementation of synthesized properties are either

a) released in dealloc if the property has retain" or "copy" attribute OR
b) not released in dealloc if the property has "assign" attribute

llvm-svn: 58363
2008-10-29 04:30:28 +00:00
Ted Kremenek 3700b762ff IOServiceGetMatchingServices is a release function.
llvm-svn: 58362
2008-10-29 04:07:07 +00:00
Daniel Dunbar dc4030454d Fix mmintrin.h to use proper definition of functions taking no
arguments.
 - More important than it looks, this inhibits trivial inlining
   otherwise.

llvm-svn: 58360
2008-10-29 03:37:55 +00:00
Zhongxing Xu 628ae879ea Rename: AddDecl => BindDecl
BindDecl better describes what the function does:
  - Bind the VarDecl to its memory region
  - Bind the memory region to some initial value.

llvm-svn: 58359
2008-10-29 02:34:02 +00:00
Douglas Gregor 786ab2119f Tweak Sema::CheckReferenceInit so that it (optionally) computes an
ImplicitConversionSequence and, when doing so, following the specific
rules of [over.best.ics]. 

The computation of the implicit conversion sequences implements C++
[over.ics.ref], but we do not (yet) have ranking for implicit
conversion sequences that use reference binding.

llvm-svn: 58357
2008-10-29 02:00:59 +00:00
Douglas Gregor 8e1cf608dc Implement initialization of a reference (C++ [dcl.init.ref]) as part
of copy initialization. Other pieces of the puzzle:

  - Try/Perform-ImplicitConversion now handles implicit conversions
    that don't involve references.
  - Try/Perform-CopyInitialization uses
    CheckSingleAssignmentConstraints for C. PerformCopyInitialization
    is now used for all argument passing and returning values from a
    function.
  - Diagnose errors with declaring references and const values without
    an initializer. (Uses a new Action callback, ActOnUninitializedDecl).
  
We do not yet have implicit conversion sequences for reference
binding, which means that we don't have any overloading support for
reference parameters yet.

llvm-svn: 58353
2008-10-29 00:13:59 +00:00
Douglas Gregor f19b2319c9 Rename ExplicitCCastExpr to CStyleCastExpr
llvm-svn: 58331
2008-10-28 15:36:24 +00:00
Douglas Gregor d984d30731 Replace a dyn_cast with a cast when we know the exact type
llvm-svn: 58330
2008-10-28 15:29:51 +00:00
Zhongxing Xu c3c104ec9c Add newline.
llvm-svn: 58322
2008-10-28 09:32:08 +00:00
Zhongxing Xu c94dce9f95 Update random notes.
llvm-svn: 58321
2008-10-28 09:09:48 +00:00
Daniel Dunbar 5b06d9f202 Don't run the verifier as part of IRgen, this is now down (per module)
in the driver (this means we no longer run the verifier per function, however).

llvm-svn: 58307
2008-10-28 00:36:04 +00:00
Douglas Gregor 6b75484ba6 Improve our handling of (C++) references within Clang. Specifically:
- Do not allow expressions to ever have reference type
  - Extend Expr::isLvalue to handle more cases where having written a
    reference into the source implies that the expression is an lvalue
    (e.g., function calls, C++ casts).
  - Make GRExprEngine::VisitCall treat the call arguments as lvalues when
    they are being bound to a reference parameter.

llvm-svn: 58306
2008-10-28 00:22:11 +00:00
Ted Kremenek 100f87d655 Initialize Suffix and Prefix to 0, even with a bad entry. Removes an uninitialized value warning from gcc.
llvm-svn: 58305
2008-10-28 00:18:42 +00:00
Daniel Dunbar 03a3844c66 Add attribute always_inline support.
llvm-svn: 58304
2008-10-28 00:17:57 +00:00
Daniel Dunbar 42c68f26cf Mark mmintrin functions static inline, this ensures they don't end up
being emitted unless needed and doesn't inhibit inlining.
  - Can be fixed once we implement C99 inline semantics.

llvm-svn: 58303
2008-10-28 00:06:25 +00:00
Ted Kremenek 1a658a991e - Fix type-punning warning in SVals.cpp by using a real iterator class for symbol_iterator.
- Add symbol_iterator support for SymbolicRegions.

llvm-svn: 58300
2008-10-27 23:39:39 +00:00
Ted Kremenek 54d399ac5d Remove type-punning warning in GRExprEngine. No functionality change.
llvm-svn: 58292
2008-10-27 23:02:39 +00:00
Daniel Dunbar 6f4eafe14b Comment fix, ParseAST does not take ownership of the consumer.
llvm-svn: 58281
2008-10-27 22:01:05 +00:00
Ted Kremenek bf26368255 Added preliminary support for CompoundLiterals in the static analyzer:
- GRExprEngine::VisitCompoundLiteral...
   (1) visits the initializer list (generating ExplodedNodes)
   (2) creates a CompoundMemRegion for the literal
   (3) creates a new state with the bound literal values using
       GRStateManager::BindCompoundLiteral

- GRStateManager::BindCompoundLiteral simply calls 
  StoreManager::BindCompoundLiteral to get a new store and returns a persistent
  GRState with that store.

- BasicStore::BindCompoundLiteral simply returns the same store, as it
  doesn't handle field sensitivity
  
- RegionStore::BindCompoundLiteral currently fires an assert (pending discussion
  of how to best implement mappings for CompoundLiteralRegion).

llvm-svn: 58277
2008-10-27 21:54:31 +00:00
Ted Kremenek eaf5e24cbb Pull determination of the super region for a VarRegion into a single getVarRegion() method. This provides a common clean API for clients.
llvm-svn: 58272
2008-10-27 21:01:26 +00:00
Ted Kremenek bc48caf383 Added CompoundLiteralRegion to represent the (temporary) memory allocated for a compound literal.
llvm-svn: 58270
2008-10-27 20:57:58 +00:00
Douglas Gregor e200adc503 Refactor the expression class hierarchy for casts. Most importantly:
- CastExpr is the root of all casts
  - ImplicitCastExpr is (still) used for all explicit casts
  - ExplicitCastExpr is now the root of all *explicit* casts
  - ExplicitCCastExpr (new name needed!?) is a C-style cast in C or C++
  - CXXFunctionalCastExpr inherits from ExplicitCastExpr
  - CXXNamedCastExpr inherits from ExplicitCastExpr and is the root of all
    of the C++ named cast expression types (static_cast, dynamic_cast, etc.)
  - Added classes CXXStaticCastExpr, CXXDynamicCastExpr, 
    CXXReinterpretCastExpr, and CXXConstCastExpr to 

Also, fixed returned-stack-addr.cpp, which broke once when we fixed
reinterpret_cast to diagnose double->int* conversions and again when
we eliminated implicit conversions to reference types. The fix is in
both testcase and SemaChecking.cpp.

Most of this patch is simply support for the renaming. There's very
little actual change in semantics.

llvm-svn: 58264
2008-10-27 19:41:14 +00:00
Ted Kremenek 5778acf5e8 - Move ExprIterator to Stmt.h so that it can be used by classes defined in Stmt.h
- Implement child_begin() and child_end() for AsmStmt.  Previously these had stub implementations that did not iterate over the input/output operands of an inline assembly statement.
- Use ExprIterator for performing iteration over input/output operands.

llvm-svn: 58261
2008-10-27 18:40:21 +00:00
Zhongxing Xu 144d7554c4 Use ASTContext::getCanonicalType() to get TypedRegion's type.
llvm-svn: 58247
2008-10-27 13:35:03 +00:00
Zhongxing Xu 7b700575dd An ElementRegion is really a typed region. Its super region's type has to be ArrayType.
llvm-svn: 58245
2008-10-27 13:17:02 +00:00
Douglas Gregor 89ebcb9d8d When destroying a translation unit, deallocate its owned declarations in reverse order, because there may be dependencies among the declarations.
llvm-svn: 58244
2008-10-27 12:50:38 +00:00
Zhongxing Xu 36d4ade4be We cannot get precise lvalue for symbolic base array region.
llvm-svn: 58243
2008-10-27 12:23:17 +00:00
Steve Naroff c6db58a6bd Replace common diagnostic with a convenience function.
This simplifies debug of this particular diagnostic (and removes some code clutter).

llvm-svn: 58242
2008-10-27 11:34:16 +00:00
Steve Naroff 1d4a9a31b6 Fix <rdar://problem/6315646> clang on xcode: error: invalid operands to binary expression ('id<NSTableViewDelegate>' and 'XCExtendedArrayController *').
There is still a bug here (as the FIXME in the test case indicates). Prior to this patch, the bug would generate an error. Now, we simply do nothing (which is less harmful until we can get it right). The complete bug fix will require changing ASTContext::mergeTypes(), which I'd like to defer for now.

llvm-svn: 58241
2008-10-27 10:33:19 +00:00
Zhongxing Xu bb18b57f53 Get the canonical type for struct initialization. The original code would crash on TypedefType.
llvm-svn: 58236
2008-10-27 09:24:07 +00:00
Zhongxing Xu d7c44059d4 Only loc::MemRegionVal can be modified. This avoids crashing in RegionStore when a function pointer is used as an argument.
llvm-svn: 58233
2008-10-27 09:00:08 +00:00
Chris Lattner 66a740e66e Rename Characteristic_t to CharacteristicKind
llvm-svn: 58224
2008-10-27 01:19:25 +00:00
Chris Lattner 69f9bc24f4 Fix the definition of __builtin_va_list on PPC, which was set to the V4 ABI, not the
darwin or AIX abis.  This fixes PR2904.

llvm-svn: 58222
2008-10-27 01:11:29 +00:00
Chris Lattner 084bc32e0d make codegen reject initializes with designators, like this:
t.c:1:13: error: cannot codegen this designators yet
int a[10] = {2, 4, [8]=9, 10};
            ^~~~~~~~~~~~~~~~~

llvm-svn: 58220
2008-10-26 23:53:12 +00:00
Chris Lattner 07d754acf1 Remember whether an initlist had a designator in the AST.
llvm-svn: 58218
2008-10-26 23:43:26 +00:00
Chris Lattner 248388e313 pass designators into sema. This completes parser-level designator
support as far as I know.

llvm-svn: 58217
2008-10-26 23:35:51 +00:00
Chris Lattner 9a53fdc23e implement some more FIXMEs, by rejecting more bogus stuff in
objc mode.

llvm-svn: 58216
2008-10-26 23:29:41 +00:00
Chris Lattner 46dcba6d2d add some simple designator testcases. Reject things like this:
struct foo Y[10] = {
  [4] .arr [2] 4  // expected-error {{expected '=' or another designator}}
};

because the "missing equals" extension only is valid if there 
is exactly one array designator.

llvm-svn: 58215
2008-10-26 23:22:23 +00:00
Chris Lattner 8aafd35c79 improve comments, build array and array range designator nodes,
fix an obscure memory leak.

llvm-svn: 58213
2008-10-26 23:06:54 +00:00
Chris Lattner 7243245a58 improve comments, build a Designation for field designators and
improve diagnostic for a malformed field designator.

llvm-svn: 58212
2008-10-26 22:59:19 +00:00
Chris Lattner e2b5e87f58 restructure ParseInitializerWithPotentialDesignator to make it
easier to understand and hack on, no functionality change.

llvm-svn: 58210
2008-10-26 22:49:49 +00:00
Chris Lattner dde6543731 improve MayBeDesignationStart to do the entire determination
about whether a leading identifier is a designator.

llvm-svn: 58207
2008-10-26 22:41:58 +00:00
Chris Lattner 3fa9239f41 inline the decision logic that chooses between an assign expr and brace
initializer, avoiding an extra level of calls for silly things like
'int x = 4'.

llvm-svn: 58206
2008-10-26 22:38:55 +00:00
Chris Lattner f3e58e2ebc This patch continues parser-level implementation of designators:
1. It introduces new parser level abstractions for designators
   that are used to communicate between parser and sema.
2. This fixes a FIXME where "identifier ':'" was considered to be
   a designator even if it wasn't the first in a designator list.
3. In the "identifier ':'" case, it actually builds the designator
   representation.

llvm-svn: 58205
2008-10-26 22:36:07 +00:00
Chris Lattner 0c02460038 minor cleanups
llvm-svn: 58203
2008-10-26 21:46:13 +00:00
Argyrios Kyrtzidis 22a3735398 Don't give a default argument to ASTContext::getFunctionType for the TypeQuals parameter, it causes subtle bugs where TypeQuals, while necessary, are omitted from the call.
-Remove the default argument.
-Update all call sites of ASTContext::getFunctionType.

llvm-svn: 58187
2008-10-26 16:43:14 +00:00
Zhongxing Xu 60de6c6c63 Remove loc::StringLiteralVal. Now we allocate regions for string literals in the Store.
llvm-svn: 58182
2008-10-26 02:27:21 +00:00
Zhongxing Xu bf47dc85fe Simplify ArrayToPointer conversion. Actually the only thing we need to do is to get the first element region. It is not necessary to care about the kind of the base array region.
llvm-svn: 58181
2008-10-26 02:23:57 +00:00