Commit Graph

12072 Commits

Author SHA1 Message Date
John McCall 340aafaac6 Emit global references with constant initializers as constants. Fixes PR5585.
The standard actually says that such references should have internal linkage,
but gcc doesn't do that, so we probably can't get away with it.

llvm-svn: 95577
2010-02-08 21:46:50 +00:00
Fariborz Jahanian 04477f3de9 Merge block/function pointer types with objc's __weak
attribute properly and avoid bogus warning. This is
an objective-c fix only. objective-c++ follows different code
pass and requires separate fix (which will come at a later time).
Fixes radar 7214820.

llvm-svn: 95571
2010-02-08 21:09:39 +00:00
Douglas Gregor 3aed6cdd5e Implement basic importing and merging of variable declarations within
the AST importer. This doesn't actually do anything (yet), because we
don't have driver logic for merging ASTs.

llvm-svn: 95570
2010-02-08 21:09:39 +00:00
Daniel Dunbar ddf1445134 Fix -Asserts warning.
llvm-svn: 95563
2010-02-08 20:24:21 +00:00
Benjamin Kramer 16fe0bcb26 Simplify another switch/strcmp construct. No functionality/performance change.
llvm-svn: 95561
2010-02-08 19:51:59 +00:00
Sebastian Redl b0e3e1bf67 When placing an annotation token over an existing annotation token, make sure that the new token's range extends to the end of the old token. Assert that in AnnotateCachedTokens. Fixes PR6248.
llvm-svn: 95555
2010-02-08 19:35:18 +00:00
John McCall 69f9dbc3e4 Fix the crash-on-invalid from PR6259.
llvm-svn: 95554
2010-02-08 19:26:07 +00:00
Chandler Carruth 75cc359fdc Ensure that a operator delete overload is rocognized regardless of cv-quals.
llvm-svn: 95553
2010-02-08 18:54:05 +00:00
Benjamin Kramer eaabbd8b46 Reapply r95546, no intended change in performance or functionality.
llvm-svn: 95552
2010-02-08 18:38:55 +00:00
Ted Kremenek ac5ab79555 Revert 95546 since it changed the algorithmic characteristics of the convention lookup.
llvm-svn: 95547
2010-02-08 16:45:01 +00:00
Benjamin Kramer 30949dd9f9 Simplify code with StringRef.
3 files changed, 76 insertions(+), 153 deletions(-)

llvm-svn: 95546
2010-02-08 16:39:00 +00:00
Ted Kremenek 57f0989c16 Revert 95541.
llvm-svn: 95545
2010-02-08 16:18:51 +00:00
Douglas Gregor f65bbb31e8 Cache imported types
llvm-svn: 95543
2010-02-08 15:18:58 +00:00
Zhongxing Xu 500f49fe25 Rename: GRState::getSVal(Stmt*) => getExprVal(),
GRState::getSVal(MemRegion*) => Load().

llvm-svn: 95541
2010-02-08 09:30:02 +00:00
Zhongxing Xu c5f825eacd BindInternal is redundant. Remove it.
llvm-svn: 95540
2010-02-08 08:48:05 +00:00
Zhongxing Xu 8ca2dc05a3 Like for symbolic region, automatically create a element zero region for
alloca region.

llvm-svn: 95539
2010-02-08 08:43:02 +00:00
Zhongxing Xu b02d4a0d11 Unify the implementation of getLValueElement of store managers.
It's more sophisticated than the original one of BasicStore. But it does
matter. 

llvm-svn: 95536
2010-02-08 08:17:02 +00:00
Zhongxing Xu f7f0cdc517 Unify the implementation of getLValueIvar and getLValueField of store managers.
llvm-svn: 95535
2010-02-08 07:58:06 +00:00
Zhongxing Xu 08515a5242 Move common methods to the base StoreManager class.
llvm-svn: 95534
2010-02-08 07:10:35 +00:00
Chandler Carruth 794da4c236 This doesn't seem to be used code as it didn't break any tests, but fix the
glaring logic bug anyways. =D

llvm-svn: 95533
2010-02-08 06:42:49 +00:00
Zhongxing Xu 8ffee4d5f8 ASTContext is now a reference member of StoreManager.
llvm-svn: 95531
2010-02-08 06:00:22 +00:00
Zhongxing Xu 000a859f05 Add support for binding and retrieving VarRegions in flat store.
llvm-svn: 95529
2010-02-08 05:40:07 +00:00
Chandler Carruth c126311d3e Require a complete type before examining base classes during template argument
deduction. This requires refactoring the deduction to have access to the Sema
object instead of merely the ASTContext. Still leaves something to be desired
due to poor source location.

Fixes PR6257 and half of PR6259.

llvm-svn: 95528
2010-02-07 21:33:28 +00:00
Anders Carlsson ff8cce4395 Make sure to set vtable pointers in the destructors as well.
llvm-svn: 95525
2010-02-07 19:45:40 +00:00
Anders Carlsson 6d0e5bd8f3 Use the right type when taking the address of a non-virtual member function pointer. Fixes PR6258.
llvm-svn: 95524
2010-02-07 17:37:13 +00:00
Douglas Gregor 0e027fb32b Workaround for friend template instantiation crash in PR5848, from Keir Mierle!
llvm-svn: 95517
2010-02-07 10:31:35 +00:00
Douglas Gregor b65a913c35 Fix assertion failure when parsing linkage specifications (PR5921),
from Keir Mierle!

llvm-svn: 95516
2010-02-07 08:38:28 +00:00
Sam Weinig e83b3aca0b Roll r95513 back in.
llvm-svn: 95515
2010-02-07 06:32:43 +00:00
Sam Weinig e911058bb5 Roll out r95513, it seems to have broken self hosting.
llvm-svn: 95514
2010-02-07 05:26:25 +00:00
Sam Weinig db3758c40d Add PCH support for CXXBoolLiteralExpr and CXXNullPtrLiteralExpr.
llvm-svn: 95513
2010-02-07 04:44:10 +00:00
Anders Carlsson cee2d2f016 Use the right linkage for static variables inside C++ inline functions.
llvm-svn: 95512
2010-02-07 02:03:08 +00:00
Anders Carlsson 10d369d1a2 Improved handling of the visibility attribute. Declarations now inherit their parent's visibility.
(This is kind of a risky change, but I did a self-host build and everything appears to work fine!)

llvm-svn: 95511
2010-02-07 01:44:36 +00:00
Anders Carlsson a7bcade229 Add attributes to namespace decls.
llvm-svn: 95510
2010-02-07 01:09:23 +00:00
Anders Carlsson 9878f9f73b Make EmitStartEHSpec and EmitEndEHSpec return early when exceptions are disabled.
llvm-svn: 95509
2010-02-06 23:59:05 +00:00
Anders Carlsson fcd764a168 Add support for threadsafe statics, and make them the default (matching gcc).
Daniel, I'd appreciate a review of the driver/cc1 parts.

llvm-svn: 95508
2010-02-06 23:23:06 +00:00
Anders Carlsson 5ade5d39b4 Call destructors for constructed bases as well.
llvm-svn: 95502
2010-02-06 20:00:21 +00:00
Anders Carlsson ba63167b64 If a constructor throws an exception we need to execute the destructors for all fully constructed members. Fixes ctor_dtor_count.cpp in the test suite.
llvm-svn: 95501
2010-02-06 19:50:17 +00:00
John McCall 15dda3701a Use a substituted type when determining how to substitute in non-type template
params.  Don't insert addrof operations when matching against a pointer;
array/function conversions should take care of this for us, assuming the
argument type-checked in the first place.  Add a fixme where we seem to be
using a less-restrictive reference type than we should.

Fixes PR 6249.

llvm-svn: 95495
2010-02-06 10:23:53 +00:00
Benjamin Kramer 4692faa7a4 Silence GCC warning and stay in 80 cols.
llvm-svn: 95494
2010-02-06 09:59:24 +00:00
John McCall 13481c56c3 Extract a function to instantiate references to value template parameters.
llvm-svn: 95491
2010-02-06 08:42:39 +00:00
Anders Carlsson 96c15b1816 Don't diagnose missing noreturns for uninstantiated templates. Fixes PR6247.
llvm-svn: 95487
2010-02-06 05:31:15 +00:00
Douglas Gregor 61f6db54e1 Switch CodeGen's "is this variable declaration a definition?" logic
over to VarDecl::isThisDeclarationADefinition(), which handles
variables declared with linkage specifications better (among other
things). CMake 2.9 (from CVS) now builds with clang++ and is somewhat
functional.

llvm-svn: 95486
2010-02-06 05:15:45 +00:00
Anders Carlsson 2c4de4c31e Only append 'L' for internal variable declarations, not all declarations. (Found by the mangle checker, yay)
llvm-svn: 95485
2010-02-06 04:52:27 +00:00
Ted Kremenek bdfcacbe8f Also teach RegionStore::RetrieveVar() to handle 'static' pointers that are implicitly initialized to NULL.
llvm-svn: 95479
2010-02-06 04:04:46 +00:00
Ted Kremenek 30fe9ecac2 Fix regression in RegionStore (from BasicStore) where static variables were not treated as being implicitly initialized to 0 (and instead were getting symbolicated).
llvm-svn: 95478
2010-02-06 03:57:59 +00:00
Ted Kremenek 9c193965ba Remove unused variable.
llvm-svn: 95476
2010-02-06 03:29:18 +00:00
Anders Carlsson 6710c5351e Use the correct function info for constructors when applying function attributes. Fixes PR6245.
llvm-svn: 95474
2010-02-06 02:44:09 +00:00
Anders Carlsson 0da714a3e2 Implement a warning diagnostic for weak vtables. Fixes PR6116.
llvm-svn: 95472
2010-02-06 02:27:10 +00:00
John McCall ce410662ce Teach Sema how to instantiate a local function declaration properly. Fixes
PR 5517.

llvm-svn: 95470
2010-02-06 01:50:47 +00:00
Douglas Gregor cae03b1e6d Assert when we try to mangle a dependent template name, rather than
crashing unceremoniously.

llvm-svn: 95464
2010-02-06 01:09:36 +00:00
John McCall 52cc0897f3 Per discussion, remove the explicit restriction on static const data members with
out-of-line initializers as integer constant expressions.  Fixes PR6206.

llvm-svn: 95463
2010-02-06 01:07:37 +00:00
Ted Kremenek 5abd69d946 Teach RegionStore::InvalidateRegions() to also invalidate static variables referenced by blocks.
llvm-svn: 95459
2010-02-06 00:30:00 +00:00
John McCall ca972cd1f1 Rearrange some checks to avoid call to isCopyConstructor() and clarify path
taken for non-trivial constructors.

llvm-svn: 95457
2010-02-06 00:25:16 +00:00
Douglas Gregor d320e03eed Fix a bogus assertion after adjusting the type of a substituted
non-type template argument for a non-type template parameter of
pointer type. Fixes PR6244.

llvm-svn: 95447
2010-02-05 22:49:09 +00:00
Douglas Gregor d225fa05bd Cope with finding the "instantiated" declaration when we are
type-checking within a template definition. In this case, the
"instantiated" declaration is just the declaration itself, found
within the current instantiation. Fixes PR6239.

llvm-svn: 95442
2010-02-05 22:40:03 +00:00
John McCall ab26cfa58d Standardize the parsing of function type attributes in a way that
follows (as conservatively as possible) gcc's current behavior:  attributes
written on return types that don't apply there are applied to the function
instead, etc.  Only parse CC attributes as type attributes, not as decl attributes;
don't accepet noreturn as a decl attribute on ValueDecls, either (it still
needs to apply to other decls, like blocks).  Consistently consume CC/noreturn
information throughout codegen;  enforce this by removing their default values
in CodeGenTypes::getFunctionInfo().

llvm-svn: 95436
2010-02-05 21:31:56 +00:00
Ted Kremenek 31e7f0f293 Add guard in RewriteObjC::HandleTopLevelSingleDecl() to not do
anything when Sema has issued an error.  This matches the behavior in
RewriteObjC::HandleTranslationUnit().

llvm-svn: 95434
2010-02-05 21:28:51 +00:00
Douglas Gregor a643780483 Revert r95393, which broke Clang's self-host.
llvm-svn: 95430
2010-02-05 21:10:36 +00:00
Douglas Gregor a16b0cae9a Implement name mangling for template template parameters
llvm-svn: 95427
2010-02-05 20:45:00 +00:00
Daniel Dunbar 9c4e4651d5 IRgen: A few more ConvertType cleanups.
llvm-svn: 95423
2010-02-05 20:02:42 +00:00
Douglas Gregor b9397108c5 Fix two issues with the substitution of template template parameters
when instantiating the declaration of a member template:
  - Only check if the have a template template argument at a specific position
  when we already know that we have template arguments at that level;
  otherwise, we're substituting for a level-reduced template template
  parameter. 
  - When trying to find an instantiated declaration for a template
  template parameter, look into the instantiated scope. This was a
  typo, where we had two checks for TemplateTypeParmDecl, one of
  which should have been a TemplateTemplateParmDecl.

With these changes, tramp3d-v4 passes -fsyntax-only.

llvm-svn: 95421
2010-02-05 19:54:12 +00:00
Daniel Dunbar d0bc7b9d13 IRgen: Factor out EmitAggExprToLValue.
llvm-svn: 95416
2010-02-05 19:38:31 +00:00
Fariborz Jahanian df506b934e Fix a code gen bug accessing 'isa' field via a message call
(Fixes radar 7609722).

llvm-svn: 95406
2010-02-05 19:18:30 +00:00
Douglas Gregor 7df89f5d18 When we're parsing an expression that may have looked like a
declaration, we can end up with template-id annotation tokens for
types that have not been converted into type annotation tokens. When
this is the case, translate the template-id into a type and parse as
an expression.

llvm-svn: 95404
2010-02-05 19:11:37 +00:00
Daniel Dunbar 8848175547 IRgen: Fix some CreateTempAlloca calls to use ConvertTypeForMem when that is
conceptually correct. Review appreciated (Chris, Eli, Anders).

llvm-svn: 95401
2010-02-05 18:56:49 +00:00
Anders Carlsson cb86e1088a Fix the bug that was breaking self-host, and re-land the static ctor fixes.
llvm-svn: 95400
2010-02-05 18:38:45 +00:00
Charles Davis 5a5473f0f8 Now that we store calling conventions in the types, use them instead of
getting the calling convention from the target function, which may or may not
exist. Fixes PR5280.

llvm-svn: 95399
2010-02-05 18:13:10 +00:00
Douglas Gregor 96e578d29d Initial skeleton of an AST "importer", which will take AST elements from
one context and import them into another context, merging them
according to language-specific rules. This is a skeleton. It doesn't
work, it isn't testable, but I want it in version control.

llvm-svn: 95395
2010-02-05 17:54:41 +00:00
Charles Davis e4e604b5d6 Testing, 1, 2, 3...
Also make the comments I added in r95291 consistent.

llvm-svn: 95394
2010-02-05 17:53:51 +00:00
Daniel Dunbar 363589bded IRgen: Use hasAggregateLLVMType instead of isSingleValueType() for cases that
need to deal with aggregates specially; this is consistent with the rest of IRgen.

Also, simplify EmitParmDecl and don't worry about using Decl::getNameAsString.

llvm-svn: 95393
2010-02-05 17:51:33 +00:00
Fariborz Jahanian 314333847e Fixes a minor rewriter bug messaging inside a function call.
Fixes radar 7617047.

llvm-svn: 95392
2010-02-05 17:48:10 +00:00
Fariborz Jahanian a7e1dcdc0e Some clean up of replacement text API no longer needed by
my recent changes.

llvm-svn: 95391
2010-02-05 16:43:40 +00:00
Douglas Gregor af77cd220a Revert r95363 and r95375, which broke self-host.
llvm-svn: 95389
2010-02-05 16:18:08 +00:00
Douglas Gregor 0ab7af6c28 A dependent initializer with zero arguments should return a NULL
initializer (for no initialization) rather than a ParenListExpr with
zero arguments in it.

llvm-svn: 95382
2010-02-05 07:56:11 +00:00
Chandler Carruth bc50da6360 Revert the unused TST_pixel entry from r95335 as it is not listed in the Sema
switch, triggering warnings.

llvm-svn: 95381
2010-02-05 07:38:55 +00:00
Douglas Gregor 8c702534cb Default function arguments for function template specializations
always come from the primary template, so gather the instantiation
template arguments from the primary template.

llvm-svn: 95380
2010-02-05 07:33:43 +00:00
Daniel Dunbar 4e9083260b Tweak inliner thresholds to match llvm-gcc, see r95321.
llvm-svn: 95379
2010-02-05 07:32:37 +00:00
Anders Carlsson c6eec40189 Check in a mangle checker that's turned off by default.
llvm-svn: 95377
2010-02-05 07:31:37 +00:00
Douglas Gregor 3ce7493c35 Teach C++ name lookup that it's okay to look in a scope without a
context. This happens fairly rarely (which is why we got away with
this bug). Fixes PR6184, where we skipped over the template parameter
scope while tentatively parsing.

llvm-svn: 95376
2010-02-05 07:07:10 +00:00
Anders Carlsson 893555ce66 Fix array initialization test.
llvm-svn: 95375
2010-02-05 07:00:11 +00:00
Douglas Gregor 1aa3edbb99 A function declarator with a non-identifier name in an anonymous class
is a constructor for that class, right? Fixes PR6238. 

llvm-svn: 95367
2010-02-05 06:12:42 +00:00
Zhongxing Xu ad0ef84040 More GRState* -> Store changes.
llvm-svn: 95365
2010-02-05 05:34:29 +00:00
Zhongxing Xu 0d081f373a Remove unused parameter.
llvm-svn: 95364
2010-02-05 05:24:20 +00:00
Anders Carlsson ecac409cb0 If a global initializer has a non-trivial destructor it can't be emitted as a constant (even if it has a trivial constructor).
llvm-svn: 95363
2010-02-05 05:19:42 +00:00
Zhongxing Xu f668204a6a More GRState* -> Store changes.
llvm-svn: 95362
2010-02-05 05:18:47 +00:00
Douglas Gregor 6ec89d4953 When adding ADL candidates for overloaded
post-increment/post-decrement operators, be sure to consider both
arguments. Fixes PR6237.

llvm-svn: 95361
2010-02-05 05:15:43 +00:00
Zhongxing Xu 7fcd8acbf8 More GRState* -> Store changes.
llvm-svn: 95360
2010-02-05 05:06:13 +00:00
Douglas Gregor 8a6d15d5ed When determining whether a scope specifier is complete, consider a
dependent DeclContext to be "complete". Fixes PR6236.

llvm-svn: 95359
2010-02-05 04:39:02 +00:00
Zhongxing Xu c7b9f950d7 More GRState* -> Store changes.
llvm-svn: 95357
2010-02-05 03:01:53 +00:00
Zhongxing Xu bd96bf1e78 Change LazyCompoundVal to a <Store, MemRegion*> pair. We really don't need to
spread GRState* everywhere.

llvm-svn: 95354
2010-02-05 02:26:30 +00:00
Ted Kremenek 2f2692f8ca Rename -cc1 option '-checker-cfref' to '-analyzer-check-objc-mem'.
llvm-svn: 95348
2010-02-05 02:06:54 +00:00
Ted Kremenek b6e400c87c Rename -cc1 option '-warn-objc-missing-dealloc' to '-analyzer-check-objc-missing-dealloc'.
llvm-svn: 95347
2010-02-05 01:59:21 +00:00
Ted Kremenek 61b506aa8f Rename -cc1 option '-warn-objc-methodsigs' to '-analyzer-check-objc-methodsigs'.
llvm-svn: 95346
2010-02-05 01:57:44 +00:00
Ted Kremenek 2d8ef71ae6 Rename -cc1 option '-warn-objc-unused-ivars' to '-analyzer-check-objc-unused-ivars'.
llvm-svn: 95345
2010-02-05 01:55:01 +00:00
Ted Kremenek d519b83757 Rename -cc1 option '-warn-dead-stores' to '-analyzer-check-dead-stores'.
llvm-svn: 95343
2010-02-05 01:52:40 +00:00
Ted Kremenek ec5b3d45c1 Rename -cc1 option '-warn-security-syntactic' to '-analyzer-check-security-syntactic'.
llvm-svn: 95342
2010-02-05 01:50:36 +00:00
Fariborz Jahanian 80fadb5069 Fix a nested ivar reference rewriting bug.
(Fixes radar 7607605).

llvm-svn: 95341
2010-02-05 01:35:00 +00:00
John McCall ae580fede3 Always start tag definitions before completing them. Assert same.
Fixes latent and not-so-latent objc++ and blocks++ bugs.

llvm-svn: 95340
2010-02-05 01:33:36 +00:00
John Thompson 2233460de6 First stage of adding AltiVec support
llvm-svn: 95335
2010-02-05 00:12:22 +00:00
Douglas Gregor 0c8a172911 Fix a crash with ill-formed code within a method in an ill-formed
category implementation, which showed up during (attempted) typo
correction. Fixes <rdar://problem/7605289>.

llvm-svn: 95334
2010-02-04 23:42:48 +00:00
John McCall 67da35c832 Extract a common structure for holding information about the definition
of a C++ record.  Exposed a lot of problems where various routines were
silently doing The Wrong Thing (or The Acceptable Thing in The Wrong Order)
when presented with a non-definition.  Also cuts down on memory usage.

llvm-svn: 95330
2010-02-04 22:26:26 +00:00
Ted Kremenek 1de1707bfc Move ParseFormatString() and FormatStringHandler back into the analyze_printf namespace.
llvm-svn: 95324
2010-02-04 20:46:58 +00:00
Douglas Gregor c42075a164 Fix an obscure crash found in the Boost.MPL test suite, along with a
ton of potential crashes of the same kind. The fundamental problem is
that type creation was following a dangerous pattern when using its
FoldingSets:
  1) Use FindNodeOrInsertPos to see if the type is available
  2) If not, and we aren't looking at a canonical type, build the
  canonical type
  3) Build and insert the new node into the FoldingSet

The problem here is that building the canonical type can, in very rare
circumstances, force the hash table inside the FoldingSet to
reallocate. That invalidates the insertion position we computed in
step 1, and in step 3 we end up inserting the new node into the wrong
place. BOOM!

I've audited all of ASTContext, fixing this problem everywhere I found
it. The vast majority of wrong code was C++-specific (and *ahem*
written by me), so I also audited other major folding sets in the C++
code (e.g., template specializations), but found no other instances of
this problem.

llvm-svn: 95315
2010-02-04 18:10:26 +00:00
Anders Carlsson 824e0613de When binding an lvalue to a reference, we always need to pop temporaries.
With this fix, and the other fixes committed today a make check-all with a clang-built LLVM now gives:

Expected Passes    : 6933
Expected Failures  : 46
Unsupported Tests  : 40
Unexpected Failures: 27

which means that we pass 99.96% of all tests :) The resulting 27 tests are all LLVMC tests and seem to be because of differences in the clang and gcc drivers.

llvm-svn: 95313
2010-02-04 17:32:58 +00:00
Anders Carlsson 9b942c65a5 Fix a bug where we would not mark temporaries as conditional when emitting a conditional operator as an lvalue.
llvm-svn: 95311
2010-02-04 17:26:01 +00:00
Douglas Gregor eca8f5a49c When substituting the template argument for a pointer non-type
template parameter, perform array/function decay (if needed), take the
address of the argument (if needed), perform qualification conversions
(if needed), and remove any top-level cv-qualifiers from the resulting
expression. Fixes PR6226.

llvm-svn: 95309
2010-02-04 17:21:48 +00:00
Anders Carlsson ae612d22ac Rename StartConditionalBranch/FinishConditionalBranch to BeginConditionalBranch/EndConditionalBranch.
llvm-svn: 95308
2010-02-04 17:18:07 +00:00
Anders Carlsson c4325486b9 Fix another pointer-to-member function miscompile, this time when trying to call a virtual member function.
llvm-svn: 95307
2010-02-04 17:08:48 +00:00
Anders Carlsson 7914dad72d Calculate offset correctly when taking the address of a virtual member function.
llvm-svn: 95305
2010-02-04 16:38:05 +00:00
John McCall cddbad000d Allow calling convention attributes to apply to types. Patch by Chip Davis!
llvm-svn: 95291
2010-02-04 05:44:44 +00:00
Zhongxing Xu 319deb83d2 Cast evaluation no longer touch GRState.
llvm-svn: 95290
2010-02-04 04:56:43 +00:00
Ted Kremenek 49f878524c Specially handle casts to 'void' in AdjustedReturnValueChecker.
llvm-svn: 95287
2010-02-04 04:18:55 +00:00
Ted Kremenek 33617e055a Remove stray typo.
llvm-svn: 95286
2010-02-04 04:14:49 +00:00
John McCall d061b4429e Mangle member expressions. Also invented.
llvm-svn: 95284
2010-02-04 02:56:29 +00:00
Zhongxing Xu 4f8b9899bb Now that CastRetrievedVal returns SVal, there is no need to use CastResult.
llvm-svn: 95279
2010-02-04 02:39:47 +00:00
John McCall 11ef09f8b5 Add a cautionary note about the mangling I just invented.
llvm-svn: 95275
2010-02-04 01:48:38 +00:00
John McCall 09de8ecd88 Add mangling support for calls, sizeof/alignof, constructor calls,
float literals, and unresolved lookups (which required hand-wavey extensions).

llvm-svn: 95273
2010-02-04 01:42:13 +00:00
Ted Kremenek 1e3b95580c static analyzer: handle casts of a function to a function pointer with
a different return type.  While we don't emit any errors (yet), at
least we avoid cases where we might crash because of an assertion
failure later on (when the return type differs from what is expected).

llvm-svn: 95268
2010-02-04 00:47:48 +00:00
Fariborz Jahanian b8355e3b9f Fix rewriting of 'const' __block variables in
the rewriter. (Fixes radar 7607781).

llvm-svn: 95267
2010-02-04 00:07:58 +00:00
Anders Carlsson b0695ef011 Don't try to fold DeclRefExprs that point to ParmVarDecls. This had the side-effect of always folding the expression to the default argument of the parameter. For example:
void f(int a = 10) {
  return a;
}

would always return 10, regardless of the passed in argument.

This fixes another 600 test failures. We're now down to only 137 failures!

llvm-svn: 95262
2010-02-03 21:58:41 +00:00
Fariborz Jahanian 80c54b05a0 Fix more rewriting of protocol-quialified 'id' type.
(Fixes radar 7607413).

llvm-svn: 95257
2010-02-03 21:29:28 +00:00
Sebastian Redl 2b37272c11 In some contexts, type declarations cannot occur. Pass this information down to ParseClassSpecifier, to make its decision easier. Fixes PR6200.
llvm-svn: 95255
2010-02-03 21:21:43 +00:00
Chris Lattner 93ddf80eb7 don't inform comment handlers about comments in #if 0 blocks,
doing so invalidates the file guard optimization and is not
in the spirit of "#if 0" because it is supposed to completely
skip everything, even if it isn't lexically valid. Patch by
Abramo Bagnara!

llvm-svn: 95253
2010-02-03 21:06:21 +00:00
Douglas Gregor 21e771e96e Define two types to be "compatible" in C++ if they are the same, and
remove some age-old FIXMEs and C++ workarounds within the
type-compatibility logic.

llvm-svn: 95249
2010-02-03 21:02:30 +00:00
Chris Lattner 5e854b95f3 Declarators can have grouping parens. This fixes rdar://7608537.
llvm-svn: 95246
2010-02-03 20:41:24 +00:00
Fariborz Jahanian 8c3f06d09c Patch to allow reinterpret_cast on objective-c pointers.
(partial fix for radar 7591784).

llvm-svn: 95245
2010-02-03 20:32:31 +00:00
Daniel Dunbar 45858d2d59 Revert "Numerous changes to selector handling:", this breaks a whole bunch of
working code, for no apparent reason.

llvm-svn: 95244
2010-02-03 20:11:42 +00:00
Sebastian Redl cbdffb1585 Top-level const changes do not make a qualification conversion. Fixes PR6089.
llvm-svn: 95239
2010-02-03 19:36:07 +00:00
Douglas Gregor 2973d406ba When determining whether a function without a prototype is compatible
with a function with a prototype, treat parameters of enumeration type
based on the enumeration type's promotion type.

llvm-svn: 95238
2010-02-03 19:27:29 +00:00
Anders Carlsson 66498388a7 Handle reference binding in aggregate initializers. Fixes another 47 tests.
llvm-svn: 95235
2010-02-03 19:13:55 +00:00
Anders Carlsson 9b92ef90f0 Add a band-aid fix for clang self-hosting. A better fix will follow shortly.
llvm-svn: 95232
2010-02-03 18:54:13 +00:00
Eli Friedman eb1df70bdc Fix for PR6220: compute the correct type for multicharacter literals.
llvm-svn: 95228
2010-02-03 18:21:45 +00:00
Anders Carlsson b247350ef7 More cleanup.
llvm-svn: 95226
2010-02-03 17:33:16 +00:00
Anders Carlsson 3b227bd629 Revert the new reference binding code; I came up with a way simpler solution for the reference binding bug that is preventing self-hosting.
llvm-svn: 95223
2010-02-03 16:38:03 +00:00
David Chisnall 5bb4efdf3c First pass at adding GC support for GNU runtime. GC ivar maps not yet constructed, GC flag not set.
Please don't try using this yet - the runtime support is still very immature and your code will almost certainly crash if you do.  

llvm-svn: 95222
2010-02-03 15:59:02 +00:00
Chandler Carruth 935384217d Teach the allocation function overload handling to deal with templates, and
prevent a crash on templates when looking for an existing declaration of the
predefined global operators. This fixes PR5918.

Added an easy test case for the overload handling, but testing the crash is
a bit trickier. Created a new test that can use multiple runs with a define to
trigger which test case is used so we can test this type of issue.

llvm-svn: 95220
2010-02-03 11:02:14 +00:00
Chandler Carruth 7ceffab64d Fix PR6149 by looking at the qualifiers on the referred to type for non-type
reference template arguments. Adds test cases for the cv-quals of reference
arguments.

llvm-svn: 95217
2010-02-03 09:37:33 +00:00
Douglas Gregor 7dc5c17d92 When a function or variable somehow depends on a type or declaration
that is in an anonymous namespace, give that function or variable
internal linkage.

This change models an oddity of the C++ standard, where names declared
in an anonymous namespace have external linkage but, because anonymous
namespace are really "uniquely-named" namespaces, the names cannot be
referenced from other translation units. That means that they have
external linkage for semantic analysis, but the only sensible
implementation for code generation is to give them internal
linkage. We now model this notion via the UniqueExternalLinkage
linkage type. There are several changes here:

  - Extended NamedDecl::getLinkage() to produce UniqueExternalLinkage
    when the declaration is in an anonymous namespace.
  - Added Type::getLinkage() to determine the linkage of a type, which
    is defined as the minimum linkage of the types (when we're dealing
    with a compound type that is not a struct/class/union).
  - Extended NamedDecl::getLinkage() to consider the linkage of the
    template arguments and template parameters of function template
    specializations and class template specializations.
  - Taught code generation to rely on NamedDecl::getLinkage() when
    determining the linkage of variables and functions, also
    considering the linkage of the types of those variables and
    functions (C++ only). Map UniqueExternalLinkage to internal
    linkage, taking out the explicit checks for
    isInAnonymousNamespace().

This fixes much of PR5792, which, as discovered by Anders Carlsson, is
actually the reason behind the pass-manager assertion that causes the
majority of clang-on-clang regression test failures. With this fix,
Clang-built-Clang+LLVM passes 88% of its regression tests (up from
67%). The specific numbers are:

LLVM:
  Expected Passes    : 4006
  Expected Failures  : 32
  Unsupported Tests  : 40
  Unexpected Failures: 736

Clang:
  Expected Passes    : 1903
  Expected Failures  : 14
  Unexpected Failures: 75

Overall:
  Expected Passes    : 5909
  Expected Failures  : 46
  Unsupported Tests  : 40
  Unexpected Failures: 811

Still to do:
  - Improve testing
  - Check whether we should allow the presence of types with
  InternalLinkage (in addition to UniqueExternalLinkage) given
  variables/functions internal linkage in C++, as mentioned in
  PR5792. 
  - Determine how expensive the getLinkage() calls are in practice;
  consider caching the result in NamedDecl.
  - Assess the feasibility of Chris's idea in comment #1 of PR5792.

llvm-svn: 95216
2010-02-03 09:33:45 +00:00
Chandler Carruth 54a0f48e0b Add FlatStore.cpp (from r95214) to CMake build. Don't forget about it! =D
llvm-svn: 95215
2010-02-03 09:31:39 +00:00
Zhongxing Xu 5df3f53616 Add skeleton of flat store manager.
llvm-svn: 95214
2010-02-03 09:10:32 +00:00
Douglas Gregor 4a2f5464a7 Look through CXXExprWithTemporaries when digging out the original
initializer. Grrr....

llvm-svn: 95211
2010-02-03 09:01:59 +00:00
Chris Lattner 78c8eaa4cb update for llvm api change.
llvm-svn: 95203
2010-02-03 05:55:22 +00:00
Chris Lattner eb1e610d00 remove a big chunk of #if 0 code.
llvm-svn: 95201
2010-02-03 05:28:17 +00:00
Ted Kremenek d960564b76 Fix regression in RegionStore due to recent changes in
RegionStoreManager::InvalidateRegions() by adjusting the worklist to
iterate over BindingKeys instead of MemRegions.  We also only need to
do the actual invalidation work on base regions, and for non-base
regions just blow away their bindings.

llvm-svn: 95200
2010-02-03 04:16:00 +00:00
Sam Weinig a16b0dd1ae Implement Doug's suggestion. Eliminate the Stmts pointer from CXXTryStmt and instead allocate the statements after the object.
llvm-svn: 95199
2010-02-03 03:56:39 +00:00
Daniel Dunbar c434394d18 Driver: Add -[no-]integrated-as for clang.
- Requires backend support, which only exists for i386--darwin currently.

No 'as' required:
--
ddunbar@ozzy:tmp$ cat t.c
int main() { return 42; }
ddunbar@ozzy:tmp$ clang -m32 -integrated-as t.c


ddunbar@ozzy:tmp$ ./a.out; echo $?
42
ddunbar@ozzy:tmp$
--

The random extra whitespace is how you know its working! :)

llvm-svn: 95194
2010-02-03 03:07:56 +00:00
Ted Kremenek 64efd0d213 Rework RegionStoreManager's implementation of InvalidateRegions() to
not build a subregion map and instead do a single scan of the store.
This is done by building "region clusters" that represent the
collection of regions that have the same base region.  Invalidating
any region in a cluster means that they all should get invalidated.

This change brought out a point that Zhongxing mentioned to me
offline: the flattened memory binding has issues distinguishing
between direct and default bindings.  For example, setting the default
value for an entire struct is the same as binding to the first
element.  To address this problem, I moved the binding "tag" (Direct
or Default) from BindingVal to BdingKey (and removed BindingVal
entirely).  This requires us to do double lookups in some cases; and
there is still much more cleanup that can be done.

This change produced a noticeable speedup when analyzing sqlite3 (a
reduction of 4% in running time).

llvm-svn: 95193
2010-02-03 03:06:46 +00:00
Douglas Gregor db56b919e5 Provide a real fix for PR6199, reverting the old workaround. Here, we
realize that CXXConstructExpr is always implicit, so we should just
return its argument (if there is only one) rather than directly
invoking the constructor.

llvm-svn: 95192
2010-02-03 03:01:57 +00:00
Sam Weinig ebcea988c2 Remove the SmallVector from CXXTryStmt.
llvm-svn: 95190
2010-02-03 02:09:59 +00:00
David Chisnall 92b762e256 Numerous changes to selector handling:
- Don't use GlobalAliases with non-0 GEPs (GNU runtime) - this was unsupported and LLVM will be generating errors if you do it soon.  This also simplifies the code generated by the GNU runtime a bit.  

- Make GetSelector() return a constant (GNU runtime), not a load of a store of a constant.

- Recognise @selector() expressions as valid static initialisers (as GCC does).

- Add methods to GCObjCRuntime to emit selectors as constants (needed for using @selector() expressions as constants.  These need implementing for the Mac runtimes - I couldn't figure out how to do this, they seem to require a load.

- Store an ObjCMethodDecl in an ObjCSelectorExpr so that we can get at the type information for the selector.  This is needed for generating typed selectors from @selector() expressions (as GCC does).  Ideally, this information should be stored in the Selector, but that would be an invasive change.  We should eventually add checks for common uses of @selector() expressions.  Possibly adding an attribute that can be applied to method args providing the types of a selector so, for example, you'd do something like this:

- (id)performSelector: __attribute__((selector_types(id, SEL, id)))(SEL)
           withObject: (id)object;

Then, any @selector() expressions passed to the method will be check to ensure that it conforms to this signature.  We do this at run time on the GNU runtime already, but it would be nice to do it at compile time on all runtimes.

- Made @selector() expressions emit type info if available and the runtime supports it.

Someone more familiar with the Mac runtime needs to implement the GetConstantSelector() function in CGObjCMac.  This currently just assert()s.

llvm-svn: 95189
2010-02-03 02:09:30 +00:00
Sebastian Redl d85be0cc60 Don't do an expensive definition check where a cheap 'is this C?' check suffices.
llvm-svn: 95188
2010-02-03 02:08:48 +00:00
Chris Lattner 35af0ab3eb fix PR6216
llvm-svn: 95185
2010-02-03 01:45:03 +00:00
Daniel Dunbar 92db0fbe5a clang -cc1: Wire up -emit-obj, for emitting object files.
llvm-svn: 95182
2010-02-03 01:18:43 +00:00
John McCall 2adddcae7e Remove abstract expression kinds from the StmtClass enum. Update a few users
appropriately.  Call out a few missing cases in the expression mangler.

llvm-svn: 95176
2010-02-03 00:55:45 +00:00
Fariborz Jahanian e165191990 Simplify setting of DeclContext for @catch variable
(per Doug's comment).

llvm-svn: 95169
2010-02-03 00:32:51 +00:00
Douglas Gregor b92a1565c3 Implement the lvalue-to-rvalue conversion where needed. The
lvalue-to-rvalue conversion adjusts lvalues of qualified, non-class
type to rvalue expressions of the unqualified variant of that
type. For example, given:

  const int i;
  (void)(i + 17);

the lvalue-to-rvalue conversion for the subexpression "i" will turn it
from an lvalue expression (a DeclRefExpr) with type 'const int' into
an rvalue expression with type 'int'. Both C and C++ mandate this
conversion, and somehow we've slid through without implementing it. 

We now have both DefaultFunctionArrayConversion and
DefaultFunctionArrayLvalueConversion, and which gets used depends on
whether we do the lvalue-to-rvalue conversion or not. Generally, we do
the lvalue-to-rvalue conversion, but there are a few notable
exceptions:
  - the left-hand side of a '.' operator
  - the left-hand side of an assignment
  - a C++ throw expression
  - a subscript expression that's subscripting a vector

Making this change exposed two issues with blocks:
  - we were deducing const-qualified return types of non-class type
  from a block return, which doesn't fit well
  - we weren't always setting the known return type of a block when it
  was provided with the ^return-type syntax

Fixes the current Clang-on-Clang compile failure and PR6076.

llvm-svn: 95167
2010-02-03 00:27:59 +00:00
Fariborz Jahanian 08d614d92e Fix DeclContext of an objective-c @catch variable
declaration. Fixes radar 7590273.

llvm-svn: 95164
2010-02-03 00:01:43 +00:00
Ted Kremenek b251eb6901 Remove RegionStoreSubRegionMap::iterator and RegionStoreSubRegionMap::begin_end(). This is a precursor to using DenseSet to represent region sets instead of ImmutableSet.
llvm-svn: 95151
2010-02-02 22:38:47 +00:00
Ted Kremenek 416b923786 Explicitly check for casts to double or complex types instead of possibly asserting in SValuator.
llvm-svn: 95128
2010-02-02 21:11:40 +00:00
Chris Lattner 60272554aa update for llvm api changes.
llvm-svn: 95125
2010-02-02 21:06:50 +00:00
Douglas Gregor a71cc15361 Implement promotion for enumeration types.
WHAT!?!

It turns out that Type::isPromotableIntegerType() was not considering
enumeration types to be promotable, so we would never do the
promotion despite having properly computed the promotion type when the
enum was defined. Various operations on values of enum type just
"worked" because we could still compute the integer rank of an enum
type; the oddity, however, is that operations such as "add an enum and
an unsigned" would often have an enum result type (!). The bug
actually showed up as a spurious -Wformat diagnostic
(<rdar://problem/7595366>), but in theory it could cause miscompiles.

In this commit:
  - Enum types with a promotion type of "int" or "unsigned int" are
  promotable.
  - Tweaked the computation of promotable types for enums
  - For all of the ABIs, treat enum types the same way as their
  underlying types (*not* their promotion types) for argument passing
  and return values
  - Extend the ABI tester with support for enumeration types

llvm-svn: 95117
2010-02-02 20:10:50 +00:00
Anders Carlsson 5dc86337fb Set the correct vtable pointers _before_ generating code for any member initializers. Fixes about ~2000 clang/LLVM tests in the clang-on-clang build.
llvm-svn: 95116
2010-02-02 19:58:43 +00:00
Chris Lattner f3c1b08508 update for llvm api change.
llvm-svn: 95110
2010-02-02 19:14:34 +00:00
John McCall eba90cd682 Dump the constructor type for a CXXConstructExpr.
llvm-svn: 95106
2010-02-02 19:03:45 +00:00
John McCall c17ae44b09 Fix this comment.
llvm-svn: 95104
2010-02-02 19:02:38 +00:00
Sebastian Redl f184291fec Check for redefinitions in MergeVarDecl. This finds redefinitions of globals without an initializer in C++ and thus fixes PR5451.
llvm-svn: 95098
2010-02-02 18:35:11 +00:00
Fariborz Jahanian 06769f9197 Fix up rewriting of protocol qualified types in objc rewriter.
Fixes radar 7589414.

llvm-svn: 95097
2010-02-02 18:35:07 +00:00
Sebastian Redl ccdb5ff17d Fix a C++ regression where redefinitions weren't diagnosed.
llvm-svn: 95096
2010-02-02 17:55:12 +00:00
Chris Lattner afe6a840d4 the declspec of a declaration can have storage-class specifiers,
type qualifiers and type specifiers in any order.   For example,
this is valid: struct x {...} typedef y;

This fixes PR6208.

llvm-svn: 95094
2010-02-02 17:32:27 +00:00
Daniel Dunbar ffa70e8b27 Driver/Darwin: Don't error/warn on conflicting deployment targets. Apparently
this is still a popular thing to do.

llvm-svn: 95093
2010-02-02 17:31:12 +00:00
Chandler Carruth 173bfe477b Use the Arg variable rather than re-computing it. This also silences GCC's
unused variable warning.

llvm-svn: 95085
2010-02-02 12:15:55 +00:00
John McCall 03c4848bf4 Mark dtors for parameter variables and eliminate some redundant type munging.
llvm-svn: 95079
2010-02-02 09:10:11 +00:00
John McCall 6781b05a92 Access control for implicit destructor calls. Diagnostic could be orders of
magnitude clearer.

llvm-svn: 95078
2010-02-02 08:45:54 +00:00
John McCall 49786a6c31 Codegen CXXConstructExprs with trivial constructors as constants.
Eliminates a lot of spurious global initializers, fixing PR6205.

llvm-svn: 95077
2010-02-02 08:02:49 +00:00
Anders Carlsson 75b1f959da Check in a test case and a nasty workaround for PR6199.
llvm-svn: 95076
2010-02-02 07:10:35 +00:00
John McCall 1acbbb5a4c Extract a common base class between UnresolvedLookupExpr and
UnresolvedMemberExpr and employ it in a few places where it's useful.

llvm-svn: 95072
2010-02-02 06:20:04 +00:00
Anders Carlsson e8bfe412ec Improve handling of emitting 'null' pointers to data members.
llvm-svn: 95066
2010-02-02 05:17:25 +00:00
Anders Carlsson 259688ce29 Move pointer to data member emission to CodeGenModule and use it in CGExprConstant. Fixes PR5674.
llvm-svn: 95063
2010-02-02 03:37:46 +00:00
John McCall fb7ad0f57a Improve the diagnostic used when an incompatible overload set is passed
as an argument during overload resolution.

llvm-svn: 95057
2010-02-02 02:42:52 +00:00
John McCall c1f69989b1 Implement C++ [temp.deduct.call]p6, template argument deduction for overloaded
arguments.  Fix a bug where incomplete explicit specializations were being
passed through as legitimate.  Fix a bug where the absence of an explicit
specialization in an overload set was causing overall deduction to fail.

Fixes PR6191.

llvm-svn: 95052
2010-02-02 02:21:27 +00:00
Ted Kremenek 545168268b Add a stop gap to Sema::CorrectTypo() to correct only up to 20 typos.
This is to address a serious performance problem observed when running
'clang -fsyntax-only' on really broken source files.  In one case,
repeatedly calling CorrectTypo() caused one source file to be rejected
after 2 minutes instead of 1 second.

This patch causes typo correction to take neglible time on that file
while still providing correction results for the first 20 cases.  I
felt this was a reasonable number for moderately broken source files.

I don't claim this is the best solution.  Comments welcome.  It is
necessary for us to address this issue because it is a serious
performance problem.

llvm-svn: 95049
2010-02-02 02:07:01 +00:00
Ted Kremenek fab459fc95 Fix bug in GRExprEngine::VisitSizeOfAlignOfExpr() where we do not add
'Pred' to 'Dst' for cases we currently don't handle.  This fixes
<rdar://problem/7593875>.

llvm-svn: 95048
2010-02-02 02:01:51 +00:00
Chris Lattner cf25141d14 Implement PR6180, substantially improving the diagnostics we get from
forgetting a ';' at the end of a struct.  For something like:

class c {
}
void foo() {}

we now produce:

t.cc:3:2: error: expected ';' after class
}
 ^
 ;

instead of:

t.cc:4:1: error: cannot combine with previous 'class' declaration specifier
void foo() {}
^
t.cc:2:7: error: 'class c' can not be defined in the result type of a function
class c {
      ^

GCC produces:

t.cc:4: error: new types may not be defined in a return type
t.cc:4: note: (perhaps a semicolon is missing after the definition of ‘c’)
t.cc:4: error: two or more data types in declaration of ‘foo’

I *think* I got the follow set right, but if I forgot anything, we'll start 
getting spurious "expected ';' after class" errors, let me know if you see
any.

llvm-svn: 95042
2010-02-02 01:23:29 +00:00
Chris Lattner 916dbf114a improve diagnostics for C++ struct ; issues. Before:
t.cc:4:3: error: expected ';' at end of declaration list
  int y;
  ^
t.cc:6:1: error: expected ';' at end of declaration list
};
^

After:

t.cc:3:8: error: expected ';' at end of declaration list
  int x
       ^
       ;
t.cc:5:8: error: expected ';' at end of declaration list
  int z
       ^
       ;

llvm-svn: 95039
2010-02-02 00:43:15 +00:00
Chris Lattner 245c5335b5 improve diagnostics on missing ; in a struct. Before:
t.c:4:3: error: expected ';' at end of declaration list
  int y;
  ^
t.c:4:8: warning: extra ';' inside a struct or union
  int y;
       ^
t.c:6:1: warning: expected ';' at end of declaration list
};
^

After:

t.c:3:8: error: expected ';' at end of declaration list
  int x  // expected-error {{expected ';' at end of declaration list}}
       ^
       ;
t.c:5:8: warning: expected ';' at end of declaration list
  int z
       ^
       ;

llvm-svn: 95038
2010-02-02 00:37:27 +00:00
Ted Kremenek 0059c491c1 Hoist diagnostic generation in ReturnStackAddressChecker into a separate method. No functionality change.
llvm-svn: 95037
2010-02-02 00:13:41 +00:00
Douglas Gregor 6791a0d43b Improve handling of enumerator values for C and C++, including:
- In C++, prior to the closing '}', set the type of enumerators
    based on the type of their initializer. Don't perform unary
    conversions on the enumerator values.
  - In C++, handle overflow when an enumerator has no initializer and
    its value cannot be represented in the type of the previous
    enumerator.
  - In C, handle overflow more gracefully, by complaining and then
    falling back to the C++ rules.
  - In C, if the enumerator value is representable in an int, convert the
    expression to the type 'int'.

Fixes PR5854 and PR4515.

llvm-svn: 95031
2010-02-01 23:36:03 +00:00
Daniel Dunbar 96ebba5770 ARM/APCS: Fix classification of small complex integer types as "integer like".
llvm-svn: 95030
2010-02-01 23:31:26 +00:00
Daniel Dunbar eedf151cb1 ARM/APCS: Pass Complex types following llvm-gcc.
llvm-svn: 95029
2010-02-01 23:31:19 +00:00
Ted Kremenek 016b605266 Add format string type checking support for 'long double'.
llvm-svn: 95026
2010-02-01 23:23:50 +00:00
Devang Patel ab793231c1 Fix FIXME and surrounding comment.
llvm-svn: 95023
2010-02-01 22:51:29 +00:00
Devang Patel e8fb4b7fd6 Use appropriate context descriptor in RecordDecl's debug info.
llvm-svn: 95016
2010-02-01 22:40:08 +00:00
Devang Patel 3efd1470c9 Do not use clang type name to name a local variable, e.g. Decl.
llvm-svn: 95010
2010-02-01 21:52:22 +00:00
Devang Patel 1c0954cca7 Do not use clang type name to name a local variable, e.g. Decl.
llvm-svn: 95009
2010-02-01 21:39:52 +00:00
Devang Patel 7b7f46f5a6 Use DeclContext as getContextDescriptor() argument.
llvm-svn: 95008
2010-02-01 21:34:11 +00:00
Daniel Dunbar 98188414ef Driver/Darwin: Darwin uses -fobjc-legacy-dispatch on ARM.
llvm-svn: 95006
2010-02-01 21:07:43 +00:00
Daniel Dunbar ca5e3eb7f7 NeXT: Add support for -fobjc-legacy-dispatch.
llvm-svn: 95005
2010-02-01 21:07:33 +00:00
Daniel Dunbar 2e3f2c805e Driver/Frontend: Add support for -fobjc-legacy-dispatch, not yet used.
llvm-svn: 95004
2010-02-01 21:07:25 +00:00
Chris Lattner 5b5d2db3f6 Don't explicitly force utf strings into the __TEXT,__ustring
by setting the section of the generated global.  This is an
optimization done by the code generator, and the code being
removed didn't handle the case when the string contained an
embedded nul (which the code generator does correctly 
handle).  This is rdar://7589850

llvm-svn: 95003
2010-02-01 20:59:08 +00:00
Sebastian Redl 5ca7984bb4 In C++, an initializer on a variable doesn't necessarily mean it's the definition. With that in mind, rename getDefinition to getAnyInitializer (to distinguish it from getInit) and reimplement it in terms of isThisDeclarationADefinition. Update all code to use this new function.
llvm-svn: 94999
2010-02-01 20:16:42 +00:00
Chris Lattner b18093e467 fix PR6187: various load functions in xmmintrin.h were missing 'const'.
emmintrin looks ok.

llvm-svn: 94998
2010-02-01 20:14:14 +00:00
Ted Kremenek fb20c4121e Use early return as suggested by Cristian Draghici.
llvm-svn: 94994
2010-02-01 19:38:10 +00:00
Ted Kremenek cd83106151 Format string checking: selectively ignore implicit casts to 'int'
when checking if the format specifier matches the type of the data
argument and the length modifier indicates the data type is 'char' or
'short'.

llvm-svn: 94992
2010-02-01 19:28:15 +00:00
Devang Patel 973f2eb0cd Emit debug info for namespaces.
llvm-svn: 94991
2010-02-01 19:16:32 +00:00
John McCall 8b9ed55bfb Note that an overload candidate was non-viable because template argument
deduction failed.  Right now there's a very vague diagnostic for most cases
and a good diagnostic for incomplete deduction.

llvm-svn: 94988
2010-02-01 18:53:26 +00:00
Sam Weinig deb55d5123 Fix for PR5185. C99 [*] VLA notation should be disallowed in function definitions.
llvm-svn: 94972
2010-02-01 05:02:49 +00:00
John McCall 760af170ff Access checking for implicit user-defined conversions.
llvm-svn: 94971
2010-02-01 03:16:54 +00:00
Sebastian Redl 35351a9554 Add VarDecl::isThisDeclarationADefinition(), which properly encapsulates the logic for when a variable declaration is a (possibly tentativ) definition. Add a few functions building on this, and shift C tentative definition handling over to this new functionality. This shift also kills the Sema::TentativeDefinitions map and instead simply stores all declarations in the renamed list. The correct handling for multiple tentative definitions is instead shifted to the final walk of the list.
llvm-svn: 94968
2010-01-31 22:27:38 +00:00
Eli Friedman a682427e42 Switch expressions like T() and T(1,2) over to new-style initialization. I'm
not quite sure what we want to do about the AST representation; comments
welcome.

llvm-svn: 94967
2010-01-31 20:58:15 +00:00
Eli Friedman 604179775a Simplify EmitMemberInitializer; no intended functionality change.
llvm-svn: 94965
2010-01-31 19:07:50 +00:00
Anders Carlsson ab0ddb57b1 Start creating CXXBindReferenceExpr nodes when binding complex types to references.
llvm-svn: 94964
2010-01-31 18:34:51 +00:00
Anders Carlsson 8abde4b447 Diagnose binding a non-const reference to a vector element.
llvm-svn: 94963
2010-01-31 17:18:49 +00:00
Chandler Carruth 3a693b7428 Return early, reduce indentation, and simplify line breaks. No functionality
change.

PS: I'm under the impression formatting-only patches don't need pre-commit
review, but feel free to yell at me if I should post these first! =D

llvm-svn: 94956
2010-01-31 11:44:02 +00:00
Chandler Carruth 00216980fb Really trivial patch to accept pointer to const void in indirect goto. Despite
the lack of documentation, this matches the behavior of GCC.

llvm-svn: 94954
2010-01-31 10:26:25 +00:00
Chandler Carruth 724a8a1fef Fix PR6159 and several other problems with value-dependent non-type template
arguments. This both prevents meaningless checks on these arguments and ensures
that they are represented as an expression by the instantiation.

Cleaned up and added standard text to the relevant test case. Also started
adding tests for *rejected* cases. At least one FIXME here where (I think) we
allow something we shouldn't. More to come in the area of rejecting crazy
arguments with decent diagnostics. Suggestions welcome for still better
diagnostics on these errors!

llvm-svn: 94953
2010-01-31 10:01:20 +00:00
Douglas Gregor 7ae2d7758f Rework base and member initialization in constructors, with several
(necessarily simultaneous) changes:

  - CXXBaseOrMemberInitializer now contains only a single initializer
    rather than a set of initialiation arguments + a constructor. The
    single initializer covers all aspects of initialization, including
    constructor calls as necessary but also cleanup of temporaries
    created by the initializer (which we never handled
    before!).

  - Rework + simplify code generation for CXXBaseOrMemberInitializers,
    since we can now just emit the initializer as an initializer.

  - Switched base and member initialization over to the new
    initialization code (InitializationSequence), so that it

  - Improved diagnostics for the new initialization code when
    initializing bases and members, to match the diagnostics produced
    by the previous (special-purpose) code.

  - Simplify the representation of type-checked constructor initializers in
    templates; instead of keeping the fully-type-checked AST, which is
    rather hard to undo at template instantiation time, throw away the
    type-checked AST and store the raw expressions in the AST. This
    simplifies instantiation, but loses a little but of information in
    the AST.

  - When type-checking implicit base or member initializers within a
    dependent context, don't add the generated initializers into the
    AST, because they'll look like they were explicit.

  - Record in CXXConstructExpr when the constructor call is to
  initialize a base class, so that CodeGen does not have to infer it
  from context. This ensures that we call the right kind of
  constructor.

There are also a few "opportunity" fixes here that were needed to not
regress, for example:

  - Diagnose default-initialization of a const-qualified class that
    does not have a user-declared default constructor. We had this
    diagnostic specifically for bases and members, but missed it for
    variables. That's fixed now.

  - When defining the implicit constructors, destructor, and
    copy-assignment operator, set the CurContext to that constructor
    when we're defining the body.

llvm-svn: 94952
2010-01-31 09:12:51 +00:00
Benjamin Kramer 43a645cd93 Try to unbreak MSVC build.
llvm-svn: 94951
2010-01-31 09:01:55 +00:00
Chandler Carruth 234c129fba Fix PR6156 and test several of the basic aspects of non-type template arguments
when implicitly supplied to the injected class name.

llvm-svn: 94948
2010-01-31 07:24:03 +00:00
Chandler Carruth 9b1fa25432 Handle instantiation of templates with non-type arguments expressed with an
explicit '&' by introducing an address-of operator prior to checking the
argument's type.

llvm-svn: 94947
2010-01-31 07:09:11 +00:00
Anders Carlsson 6276b2506d When performing a derived-to-base cast that we know will not change the offset, we don't need to null check the input pointer. Fixes PR5965.
llvm-svn: 94942
2010-01-31 02:39:02 +00:00
Anders Carlsson 600f737b95 When doing a base-to-derived cast we don't need to null check the derived value if the class offset is 0.
llvm-svn: 94939
2010-01-31 01:43:37 +00:00
Anders Carlsson 84673e200f Some class related cleanup.
llvm-svn: 94938
2010-01-31 01:36:53 +00:00
Daniel Dunbar 8fa74aa21d Simplify.
llvm-svn: 94929
2010-01-30 23:31:57 +00:00
Anders Carlsson 98323d29b6 Remove the SmallVectors from AsmStmt. Fixes PR6105.
llvm-svn: 94926
2010-01-30 23:19:41 +00:00
Anders Carlsson 9a020f9a3a Use IdentifierInfo * instead of std::string for the AsmStmt names.
llvm-svn: 94925
2010-01-30 22:25:16 +00:00
Daniel Dunbar 6b03ecef0d ASTUnit: Ensure the CompilerInvocation object used in LoadFromCommandLine is
live as long as the ASTUnit. This is useful for clients which want to maintain
pointers to the LangOptions object which ultimately lives in the
CompilerInvocation, although it would be nice to make all of this ownership
stuff more explicit and obvious.

llvm-svn: 94924
2010-01-30 21:47:16 +00:00
Daniel Dunbar 6824225465 CompilerInstance: Change to not contain the CompilerInvocation object.
This allows clients to install their own CompilerInvocation object, which is
important for clients that may wish to create references to things like
LangOptions whose lifetime will extend past that of the CompilerInstance.

llvm-svn: 94923
2010-01-30 21:47:07 +00:00
Anders Carlsson 0c5d7448d8 Fix thinko.
llvm-svn: 94922
2010-01-30 20:48:08 +00:00
Anders Carlsson 66de081f39 Even more AsmStmt cleanup.
llvm-svn: 94921
2010-01-30 20:38:10 +00:00
Anders Carlsson 087bc13d96 More asm cleanup.
llvm-svn: 94920
2010-01-30 20:05:21 +00:00
Benjamin Kramer 31a68e70a5 Simplify FreeBSD version parsing.
llvm-svn: 94919
2010-01-30 19:55:01 +00:00
Anders Carlsson 96fe0b5b96 Combine AsmStmt::setOutputsAndInputs and AsmStmt::setClobbers.
llvm-svn: 94918
2010-01-30 19:34:25 +00:00
Anders Carlsson c7c5baa482 Yay for more StringRefs.
llvm-svn: 94917
2010-01-30 19:12:25 +00:00
Anders Carlsson 0b0a122fde StringRef-ize the TargetInfo::ConstraintInfo constructor.
llvm-svn: 94916
2010-01-30 18:33:31 +00:00
Anders Carlsson bd32c434ae Add an assert to make sure that we don't try to mess with overridden methods for class templates.
llvm-svn: 94907
2010-01-30 17:42:34 +00:00
Benjamin Kramer 2ecf8eb2dc PCHReader doesn't implement classof so dyn_casting it will do really weird stuff. Use a static_cast instead.
I don't know if this hack is the right fix. Doug, please take a look.

llvm-svn: 94895
2010-01-30 16:23:25 +00:00
Daniel Dunbar 19b70bd46c Recognize 'q' as a format length modifier (from BSD).
llvm-svn: 94894
2010-01-30 15:49:20 +00:00
Benjamin Kramer 842bf17366 Use StringRef instead of returning a temporary std::string.
This fixes a really nasty bug in Darwin::getDarwinArchName where we were going
StringRef -> temporary std::string -> StringRef (and return the dead StringRef).
The StringRefs from Triple live as long as the Triple itself, that should be
long enough.

Hopefully 2 of 4 MSVC buildbot failures are gone now.

llvm-svn: 94892
2010-01-30 15:01:47 +00:00
Benjamin Kramer a87bdb793e We don't need to place 0 in the URL string now that we return a StringRef.
- URL can go into read only memory now.
- Compilers will fold away all the strstr calls.

llvm-svn: 94887
2010-01-30 14:01:39 +00:00
Anton Korobeynikov cbc4e98381 Fix alignment for msp430 integer types.
llvm-svn: 94879
2010-01-30 12:55:11 +00:00
Anders Carlsson a18f0fbca2 Eliminate yet another old-school PerformCopyInitialization.
llvm-svn: 94874
2010-01-30 01:56:32 +00:00
Ted Kremenek 9ff02052dd Add format string checking of 'double' arguments. Fixes <rdar://problem/6931734>.
llvm-svn: 94867
2010-01-30 01:02:18 +00:00
Ted Kremenek c3bdff7c8c Add basic type checking of format string conversion specifiers and their arguments. Thanks to Cristian Draghici for his help with this patch!
llvm-svn: 94864
2010-01-30 00:49:51 +00:00
Ted Kremenek 605b0113f3 Be a little more permissive than C99: allow 'unsigned' to be used for
the field width and precision of a format specifier instead of just
'int'.  This matches GCC, and fixes <rdar://problem/6079850>.

llvm-svn: 94856
2010-01-29 23:32:22 +00:00
Ted Kremenek ba775fe5c7 Fix spacing.
llvm-svn: 94852
2010-01-29 23:00:35 +00:00
Ted Kremenek 79db7b7b17 Per a suggestion from Cristian Draghici, add a method to FormatSpecifier that returns the expected type of the matching data argument. It isn't complete, but should handle several of the important cases.
llvm-svn: 94851
2010-01-29 22:59:32 +00:00
Devang Patel bb4820dc8e Use appropriate context for typedefs.
llvm-svn: 94849
2010-01-29 22:29:31 +00:00
Daniel Dunbar 1299819f71 Driver: Don't honor -std-default for C++, this makes it hard to run the gdb test
suite with clang++ enabled.

The right fix here is PR6175, although we would still have to find a different
work around for the gdb test suite.

llvm-svn: 94838
2010-01-29 21:03:02 +00:00
Ted Kremenek 8d9842d43f Switch Sema over to using the new implementation of format string
checking.  It passes all existing tests, and the diagnostics have been
refined to provide better range information (we now highlight
individual format specifiers) and more precise wording in the
diagnostics.

llvm-svn: 94837
2010-01-29 20:55:36 +00:00
Ted Kremenek 23a71a1cdf Enhancements to the alternate (WIP) format string checking:
- Add ConversionSpecifier::consumesDataArgument() as a helper method
  to determine if a conversion specifier requires a matching argument.
- Add support for glibc-specific '%m' conversion
- Add an extra callback to HandleNull() for locations within the
  format specifier that have a null character

llvm-svn: 94834
2010-01-29 20:29:53 +00:00
Douglas Gregor d1e08648c6 Fix reference-binding when we have a reference to const volatile type;
previously, we were allowing this to bind to a temporary. Now, we
don't; add test-cases and improve diagnostics.

llvm-svn: 94831
2010-01-29 19:39:15 +00:00
Ted Kremenek db4b7710f7 Fix subtle bug in Preprocessor::AdvanceToTokenCharacter(): use '+=' instead of '='.
llvm-svn: 94830
2010-01-29 19:38:24 +00:00
Douglas Gregor 65eb86e912 Fix reference binding of const lvalue references to bit-fields, which
requires a temporary. Previously, we were building an initialization
sequence that bound to the bit-field as if it were a real lvalue. Note
that we previously (and still) diagnose binding of non-const
references to bit-fields, as we should.

There's no real way to test that this code is correct, since reference
binding does not *currently* have any representation in the AST. This
fix should make it easier for that to happen, so I've verified this
fix with...

Added InitializationSequence::dump(), to print an initialization
sequence for debugging purposes.

llvm-svn: 94826
2010-01-29 19:14:02 +00:00
Anders Carlsson 7c5fe48060 And yet another call.
llvm-svn: 94824
2010-01-29 18:43:53 +00:00
Anders Carlsson a68e51e3a1 Another PerformCopyInitialization call bites the dust.
llvm-svn: 94823
2010-01-29 18:37:50 +00:00
Anders Carlsson 6f923f89c3 Get rid of another old PerformCopyInitialization call.
llvm-svn: 94819
2010-01-29 18:30:20 +00:00
Devang Patel 92e2541599 Maintain a map of regions (lexical scopes) and use it to find context for a global variable.
llvm-svn: 94817
2010-01-29 18:11:03 +00:00
Douglas Gregor 4b4844f88d When naming a function template via a qualified-id (or any other way
that ADL is suppressed), we need to build an
UnresolvedLookupExpr. Fixes PR6063, which was hitting Boost headers
pretty hard.

llvm-svn: 94814
2010-01-29 17:15:43 +00:00
Daniel Dunbar 6596984f3c Driver/Darwin: Fix a crash when diagnosing conflicting deployment targets.
llvm-svn: 94812
2010-01-29 17:02:25 +00:00
Douglas Gregor 16810ca647 Name mangling for cast expressions, from Matthias Schiffer! Fixes PR5876.
llvm-svn: 94811
2010-01-29 16:37:09 +00:00
Anders Carlsson 42c876dff2 Use EmitLValueForFieldInitialization when synthesizing the copy ctor as well.
llvm-svn: 94800
2010-01-29 05:41:25 +00:00
Anders Carlsson db78f0ad04 Add a new EmitLValueForFieldInitialization that will be used for initializing fields (and reference type fields in particular).
llvm-svn: 94799
2010-01-29 05:24:29 +00:00
Anders Carlsson 5d8645b150 Simplify EmitLValueForField - we can get whether the field is part of a union or not from the FieldDecl (through its DeclContext).
llvm-svn: 94798
2010-01-29 05:05:36 +00:00
Daniel Dunbar 45c7ff1d79 ARM/APCS ABI: Fix some problems with bit-fields in structures. After rereading
the ABI spec, this turns out to simplify the code. We still have some annoying
code which mismatches the spec with regard to empty structures.

llvm-svn: 94796
2010-01-29 03:22:29 +00:00
Ted Kremenek c22f78ddfd Alternate format string checking: issue warnings for incomplete format specifiers.
In addition, move ParseFormatString() and FormatStringHandler() from
the clang::analyze_printf to the clang namespace.  Hopefully this will
resolve some link errors on Linux.

llvm-svn: 94794
2010-01-29 03:16:21 +00:00
Anders Carlsson a91be641a7 Simplify InitListChecker::CheckReferenceType
llvm-svn: 94793
2010-01-29 02:47:33 +00:00
Ted Kremenek 94af575e9c Alternate format string checking: issue a warning for invalid conversion specifiers.
llvm-svn: 94792
2010-01-29 02:40:24 +00:00
Anders Carlsson ba6c437d52 Add an CXXBindReferenceExpr (not used just yet).
llvm-svn: 94791
2010-01-29 02:39:32 +00:00
Ted Kremenek 176f7d6ef0 Yet another attempt to make the Linux buildbots happy. Apparently there are differences on how nested namespaces are handled...
llvm-svn: 94790
2010-01-29 02:13:53 +00:00
Fariborz Jahanian b5f99c3f4f Fixes rewriter bug rewriting byref related API where a struct
definition comes after where it is needed. Fixes radar 7589385.

llvm-svn: 94788
2010-01-29 01:55:49 +00:00
Ted Kremenek 019d224d91 Alternate format string checking: check for excess data arguments.
llvm-svn: 94787
2010-01-29 01:50:07 +00:00
Ted Kremenek 9fcd8305c0 Alternate format string checking: check if the number of format specifiers exceeds the number of arguments.
llvm-svn: 94785
2010-01-29 01:43:31 +00:00
Ted Kremenek 559d89a02a Move definition of FormatStringHandler::~FormatStringHandler() within namespace directives. Hopefully this will make the Linux buildbots happy.
llvm-svn: 94784
2010-01-29 01:37:52 +00:00
Ted Kremenek d5fd0fac38 Alternate format string checking: warn of '%n' as being potentially insecure.
llvm-svn: 94782
2010-01-29 01:35:25 +00:00
Ted Kremenek 5739de77fa Add precision/field width checking to AlternateCheckPrintfString().
llvm-svn: 94774
2010-01-29 01:06:55 +00:00
Ted Kremenek b5c98ef61e Fix off-by-one error in ParseFormatSpecifier() when reporting the location of a null character.
llvm-svn: 94762
2010-01-28 23:56:52 +00:00
Ted Kremenek ab278de2d1 Start fleshing out Sema::AlternateCheckPrintfString():
- Add an anonymous class 'CheckPrintfHandler' which will do the
  checking of specific format specifiers
- Add checking for using the '@' conversion specifier outside
  an ObjC string literal
- Add checking for null characters within the string

llvm-svn: 94761
2010-01-28 23:39:18 +00:00
Devang Patel 7bfc596fcf s/CGDebugInfo::getContext/CGDebugInfo::getContextDescriptor/g to avoid confusion.
llvm-svn: 94760
2010-01-28 23:15:27 +00:00
Devang Patel 128aa9d176 Fix indentation.
llvm-svn: 94758
2010-01-28 21:54:15 +00:00
Devang Patel 4c3e7e99ca Static methods do not need "this" pointer argument.
llvm-svn: 94756
2010-01-28 21:43:50 +00:00
Devang Patel 946edc1aa6 Emit base classes info first, as expected by the debugger.
llvm-svn: 94755
2010-01-28 21:41:35 +00:00
Anders Carlsson b1ef991097 Fix an incorrect union layout assert. Fixes PR6164.
llvm-svn: 94754
2010-01-28 18:22:03 +00:00
Devang Patel 0d61eebd81 s/FunctionNames/DebugInfoNames/g
llvm-svn: 94753
2010-01-28 18:21:00 +00:00
Devang Patel 84033fb240 Emit vtable info.
llvm-svn: 94751
2010-01-28 18:11:52 +00:00
John McCall 2cb941642e Access control for surrogate function calls. Required a moderately gross hack
to get the access bits set properly in conversion sets.

llvm-svn: 94744
2010-01-28 07:38:46 +00:00
Douglas Gregor ac0605e927 Introduce serialization and deserialization of diagnostic information
so that CIndex can report diagnostics through the normal mechanisms
even when executing Clang in a separate process. This applies both
when performing code completion and when using ASTs as an intermediary
for clang_createTranslationUnitFromSourceFile().

The serialized format is not perfect at the moment, because it does
not encapsulate macro-instantiation information. Instead, it maps all
source locations back to the instantiation location. However, it does
maintain source-range and fix-it information. To get perfect fidelity
from the serialized format would require serializing a large chunk of
the source manager; at present, it isn't clear if this code will live
long enough for that to matter.

llvm-svn: 94740
2010-01-28 06:00:51 +00:00
Ted Kremenek fee0e96c82 Add position of conversion specifier character to 'ConversionSpecifier'.
llvm-svn: 94739
2010-01-28 02:46:17 +00:00
Ted Kremenek 08ad1cceb3 Rename namespace clang::printf to clang::analyze_printf to avoid problems where the reference to 'printf' is ambiguous.
llvm-svn: 94733
2010-01-28 02:02:59 +00:00
John McCall 49ec2e694c Access control for overloaded call operators. Not for surrogates yet,
mostly because we're going to want a better diagnostic for conversions.

Also this API needs to go back to sanity.

llvm-svn: 94730
2010-01-28 01:54:34 +00:00
John McCall b3a4400554 Access checking for overloaded operators.
llvm-svn: 94725
2010-01-28 01:42:12 +00:00
Fariborz Jahanian 81310810bd Fixes a rewrite bug rewriting nested ivars reference.
(Radar 7583971).

llvm-svn: 94724
2010-01-28 01:41:20 +00:00
Ted Kremenek c70ee8610d Add placeholder function in Sema for new format string checking logic.
This function will use the format string parsing logic in libAnalysis,
and once it is shown to be better than the current implementation it
will replace AlternateCheckPrintfString() entirely.

llvm-svn: 94721
2010-01-28 01:18:22 +00:00
Ted Kremenek e4fd3300c9 Fix 80 col violation.
llvm-svn: 94717
2010-01-28 01:04:48 +00:00
Ted Kremenek bcbdaea703 Allow HandleFormatSpecifier() to indicate that no more processing of the format string is desired.
llvm-svn: 94715
2010-01-28 01:00:59 +00:00
Ted Kremenek c06ead62f0 Add '@' conversion specifier.
llvm-svn: 94713
2010-01-28 00:55:28 +00:00
Devang Patel abb4413728 While emitting debugging infor for a C++ class, identify the holder of class's vtable, if any.
llvm-svn: 94712
2010-01-28 00:54:21 +00:00
Devang Patel 3d4e6d9dd0 Include "this" pointer argument while emitting debug info for a C++ method.
llvm-svn: 94710
2010-01-28 00:28:01 +00:00
Ted Kremenek fa784e88e8 Remove invalid conversion specifiers from format string checking.
llvm-svn: 94707
2010-01-28 00:17:51 +00:00
Ted Kremenek c8d9c01f04 Add a few more conversion specifiers to ParseFormatSpecifier (these appear in SemaChecking).
llvm-svn: 94704
2010-01-28 00:02:05 +00:00
Ted Kremenek a2e77b41f3 Add skeleton for a more structured way to analyzing pring format
strings than what we currently have in Sema.  This is both an
experiment and a WIP.

The idea is simple: parse the format string incrementally,
constructing a well-structure representation of each format specifier.
Each format specifier is then handed back one-by-one to a client via a
callback.  Malformed format strings are also handled with callbacks.
The idea is to separate the parsing of the format string from the
emission of diagnostics.  Currently what we have in Sema for handling
format strings is a mongrel of both that is hard to follow and
difficult to modify (I can apply this label since I'm the original
author of that code).

This is in libAnalysis as it is reasonable generic and can potentially
be used both by libSema and libChecker.

Comments welcome.

llvm-svn: 94702
2010-01-27 23:43:25 +00:00
Jeffrey Yasskin 3f565ae2dd Remove ModuleProviders from clang after r94686 removed them from LLVM.
llvm-svn: 94688
2010-01-27 21:12:04 +00:00
Daniel Dunbar 377dc2f91f ARM/APCS: Fix alignment of long double.
llvm-svn: 94685
2010-01-27 20:23:08 +00:00
Ted Kremenek e9918356b2 Move more naming conventions logic out of the retain/release checker to CocoaConventions.h.
llvm-svn: 94682
2010-01-27 18:00:17 +00:00
Ken Dyck 160146eba2 Change the return type of ASTContext::getDeclAlignInBytes() to CharUnits and,
now that the "InBytes" part of the name is implied by the return type, rename
it to getDeclAlign().

llvm-svn: 94681
2010-01-27 17:10:57 +00:00
Benjamin Kramer b925f7707e Use raw_ostreams in Preprocessor::ExpandBuiltinMacro. Still not nice but less fragile than the old code.
llvm-svn: 94679
2010-01-27 16:38:22 +00:00
Ted Kremenek 968999b5f6 Add missing call to Optional<...>.getValue() that was pointed out by Chandler.
llvm-svn: 94678
2010-01-27 16:31:37 +00:00
Ken Dyck 2c229a7c17 Use getTypeAlignInChars() for alignment in VisitSizeOfAlignOfExpr().
llvm-svn: 94677
2010-01-27 12:54:25 +00:00
David Chisnall 358e751a7b Unique ObjC strings (GNU Runtime); fix for PR6142. Note: Doing this in the runtime-specific code is a bit ugly. It would be a good idea to hoist all of the string / protocol uniqueing code up into CGObjCRuntime or CodeGenModule and only handle emitting the original versions in the runtime-specific code.
llvm-svn: 94676
2010-01-27 12:49:23 +00:00
Chris Lattner 0afd3a23cd fix a bug in the _MM_TRANSPOSE4_PS definition, patch by Brian Sumner from
PR6138

llvm-svn: 94669
2010-01-27 07:54:50 +00:00
Ted Kremenek d5e27af60a Remove unnecessary ASTContext* argument from isRefType().
llvm-svn: 94665
2010-01-27 06:45:10 +00:00
Ted Kremenek 49c0d89a10 Update CMake build.
llvm-svn: 94663
2010-01-27 06:14:12 +00:00
Ted Kremenek db1832d928 Start pulling out pieces of the monolithic retain/release checker into
reusable and modular API pieces.

Start by pulling the logic for deriving the Cocoa naming convention
into a separate API, header, and source file.

llvm-svn: 94662
2010-01-27 06:13:48 +00:00
Douglas Gregor 3edc4d5ec3 Fix a major oversight in the comparison of standard conversion
sequences, where we would occasionally determine (incorrectly) that
one standard conversion sequence was a proper subset of another when,
in fact, they contained completely incomparable conversions. 

This change records the types in each step within a standard
conversion sequence, so that we can check the specific comparison
types to determine when one sequence is a proper subset of the
other. Fixes this testcase (thanks, Anders!), which was distilled from
PR6095 (also thanks to Anders).

llvm-svn: 94660
2010-01-27 03:51:04 +00:00
John McCall 86121519ca Implement access-check delays for out-of-line member definitions
using the same framework we use for deprecation warnings.

llvm-svn: 94659
2010-01-27 03:50:35 +00:00
Anders Carlsson e437c6870a Add support for 3dnow and 3dnowa, and define the target macros accordingly. (This is needed in order to build Qt).
llvm-svn: 94658
2010-01-27 03:47:49 +00:00
Anders Carlsson 40446e8a0a Structs and classes with non-trivial destructors or copy constructors should be passed indirectly in the 32-bit ABI. Fixes PR6094.
llvm-svn: 94656
2010-01-27 03:25:19 +00:00
John McCall 58cc69d4c1 Implement access control for overloaded functions. Suppress access control
diagnostics in "early" lookups, such as during typename checks and when building
unresolved lookup expressions.

llvm-svn: 94647
2010-01-27 01:50:18 +00:00
Daniel Dunbar f48d51d693 Driver/Darwin: Eliminate invalid uses of DarwinVersion -- this fixes a number of
defaults when targetting iPhoneOS (blocks, non-fragile ABI, stack protector).

llvm-svn: 94642
2010-01-27 00:57:11 +00:00
Daniel Dunbar 6d23b2f503 Driver/Darwin: Simplify target version checks.
llvm-svn: 94641
2010-01-27 00:57:03 +00:00
Daniel Dunbar 8360803a8a Driver/Darwin: Fix a few link arguments when targetting different iPhoneOS
versions to match gcc (which is matching linker changes).

llvm-svn: 94640
2010-01-27 00:56:56 +00:00
Daniel Dunbar b73bb5d085 Driver/Darwin: Switch clang -triple synthesis to use computed target information.
llvm-svn: 94639
2010-01-27 00:56:49 +00:00
Daniel Dunbar 7c870175eb Driver/Darwin: Eliminate confusing IsIPhoneOS parameter -- this was actually
just indicating whether the default target should be iPhoneOS.

llvm-svn: 94638
2010-01-27 00:56:44 +00:00
Daniel Dunbar 15c8942baf Driver/Darwin: Switch to using isTargetIPhoneOS where appropriate.
llvm-svn: 94637
2010-01-27 00:56:37 +00:00
Daniel Dunbar 3b8e50d0ed Driver/Darwin: Track target platform more explicitly in tool chain, eventually
this should just be part of the tool chain itself once we have eliminated
argument translation.

llvm-svn: 94635
2010-01-27 00:56:25 +00:00
Ted Kremenek e36bceb97d Teach RegionStore to handle initialization of incomplete arrays in structures using a compound value. Fixes <rdar://problem/7515938>.
llvm-svn: 94622
2010-01-26 23:51:00 +00:00
Ted Kremenek 6296e0990b Move 'LocalCheckers.h' to the 'Checkers' subdirectory.
llvm-svn: 94609
2010-01-26 22:59:55 +00:00
Ted Kremenek b29faead69 Move 'include/Checkers/PathSensitive/Checkers' directory to 'include/Checkers'.
llvm-svn: 94608
2010-01-26 22:56:15 +00:00
Fariborz Jahanian d59baba9fd Patch to add 'volatile' to first argument of all
sync compare_and_swap to match them with gcc.
It also fixes a few incorrect argument defitions.
(fixes radar 7540291).

llvm-svn: 94607
2010-01-26 22:48:42 +00:00
Mike Stump ded0a406b4 Refine the non-virtual this adjustments for thunks by using the offset
to the declaring class from the nearest virtual base class.  WIP.

llvm-svn: 94606
2010-01-26 22:44:01 +00:00
Sebastian Redl 833ef45b1d Bring some semblance of order into Decl.h and Decl.cpp. While at it, fix some typo comments and remove an unused and unimplemented function prototype. No functionality change.
llvm-svn: 94599
2010-01-26 22:01:41 +00:00
Mike Stump a04ecfb701 Refine the non-virtual this adjustments for thunks by using the offset
to the declaring class from the nearest virtual base class.  WIP.

This fixes 40% of all the problems remaining in one of my testcases.

llvm-svn: 94592
2010-01-26 21:35:27 +00:00
Fariborz Jahanian f0ed69cb5b Added assert to the rewrite.
llvm-svn: 94584
2010-01-26 20:37:44 +00:00
Ken Dyck 7df3cbeb01 Convert one last size variable to CharUnits (follow-on to 94577).
llvm-svn: 94579
2010-01-26 19:59:28 +00:00
Ken Dyck 3eb55cfe8a Use CharUnits for sizes, offsets, alignments, and padding amounts for values
that are in character units.

llvm-svn: 94577
2010-01-26 19:44:24 +00:00
Douglas Gregor 64213261b4 Fix typo in comment
llvm-svn: 94576
2010-01-26 19:43:43 +00:00
Ken Dyck 5262b11962 Use CharUnits for alignments in character units.
llvm-svn: 94571
2010-01-26 19:13:33 +00:00
Ken Dyck a0f99ff230 Use CharUnits for alignment of UTF16 string in GetAddrOfConstantCFString().
llvm-svn: 94564
2010-01-26 18:46:23 +00:00
Ken Dyck e5402e4749 Use CharUnits for alignment in EmitNullInitializationLValue().
llvm-svn: 94563
2010-01-26 18:35:11 +00:00
Fariborz Jahanian f9e8c2b759 Refix rewriting of an ivar access when it is
type-cast to its sub-class (radar 7575882).

llvm-svn: 94559
2010-01-26 18:28:51 +00:00
Anders Carlsson ca4a5459d8 Use the right definition when emitting a global variable. Fixes PR5564.
llvm-svn: 94555
2010-01-26 17:43:42 +00:00
Anders Carlsson 7228117108 Change getUnique to return a GlobalDecl. Fixes PR6147.
llvm-svn: 94554
2010-01-26 17:36:47 +00:00
Ken Dyck a6046ab82b Correct cut-and-paste error in doxygen comment for newly introduced
getTypeAlignInChars().  

llvm-svn: 94553
2010-01-26 17:25:18 +00:00
Ken Dyck 24d28d6cde Add getTypeAlignInChars() for use in code that works in alignments in character
units.

llvm-svn: 94552
2010-01-26 17:22:55 +00:00
Ken Dyck 98ca79435a Introduce CodeGenModule::GetTargetTypeStoreSize() to calculate the store size
of LLVM types in character units.

llvm-svn: 94542
2010-01-26 13:48:07 +00:00
John McCall 1f6386b79b Avoid some unnecessary copying of unresolved lookup results.
llvm-svn: 94531
2010-01-26 07:37:41 +00:00
John McCall 8fe6808de0 Handle redeclarations found by ADL deterministically and reasonably.
This solution relies on an O(n) scan of redeclarations, which means it might
scale poorly in crazy cases with tons of redeclarations brought in by a ton
of distinct associated namespaces.  I believe that avoiding this
is not worth the common-case cost.

llvm-svn: 94530
2010-01-26 07:16:45 +00:00
Chandler Carruth 72343706c1 Correctly treat 64 bit integers specified via the mode attribute as the 'long'
type when that type is 64 bits wide, and the 'long long' type when 'long' is
only 32 bits wide. This fixes PR6108.

Also adds a bunch of test cases to ensure proper conversion between equally
sized standard types and mode-specified types on both 32 and 64 bit targets.

llvm-svn: 94527
2010-01-26 06:39:24 +00:00
Anders Carlsson d6b21e4842 If a global variable has an initializer with side effects, it can never be deferred (even if it's in an anonymous namespace).
llvm-svn: 94525
2010-01-26 06:15:16 +00:00
John McCall 91f61fc921 Allow ADL to find functions imported by using decls. Leave wordy comment
about interaction between ADL and default arguments.  Shrug shoulders, commit.

llvm-svn: 94524
2010-01-26 06:04:06 +00:00
Anders Carlsson 0b5f1ddf0a Fix another debug info crash with virtual bases.
llvm-svn: 94520
2010-01-26 05:26:39 +00:00