Commit Graph

10858 Commits

Author SHA1 Message Date
Eli Friedman 4afe9a3518 Fix review comment; no visible change.
llvm-svn: 91797
2009-12-20 22:12:03 +00:00
Douglas Gregor 39c778b443 Switch default-initialization of variables of class type (or array thereof) over to InitializationSequence. I could swear that this fixes a PR somewhere, but I couldn't figure out which one
llvm-svn: 91796
2009-12-20 22:01:25 +00:00
Douglas Gregor 1b6d10555f Revert accidental commit
llvm-svn: 91795
2009-12-20 21:10:58 +00:00
Douglas Gregor b752f1e25c Fix CMake build on windows, from Cedric Venet
llvm-svn: 91794
2009-12-20 20:56:30 +00:00
John McCall 1c7e6ec27b Don't inject the class name until that magical lbrace.
Because of the rules of base-class lookup* and the restrictions on typedefs, it
was actually impossible for this to cause any problems more serious than the
spurious acceptance of
  template <class T> class A : B<A> { ... };
instead of
  template <class T> class A : B<A<T> > { ... };
but I'm sure we can all agree that that is a very important restriction which
is well worth making another Parser->Sema call for.

(*) n.b. clang++ does not implement these rules correctly;  we are not ignoring
    non-type names

llvm-svn: 91792
2009-12-20 07:58:13 +00:00
John McCall 2d814c305e Parse base specifiers within the scope of the class. This is possibly not
quite right;  I'll come back to it later.  It does fix PR 5741.

llvm-svn: 91789
2009-12-19 21:48:58 +00:00
Daniel Dunbar e017ecc9e2 Remove ';' after method definition. Noticed by clang++, which one would think
would have a higher respect for its own code. This is getting old, is this
warning really adding value?

llvm-svn: 91779
2009-12-19 17:50:07 +00:00
John McCall b878801046 Kill off PreDeclaratorDC.
llvm-svn: 91772
2009-12-19 10:53:49 +00:00
John McCall 6df5fef637 Refactor to remove more dependencies on PreDeclaratorDC. I seem to have made
the redeclaration problems in the [temp.explicit]p3 testcase worse, but I can
live with that;  they'll need to be fixed more holistically anyhow.

llvm-svn: 91771
2009-12-19 10:49:29 +00:00
John McCall 4d6d6137a0 Don't use EnterDeclaratorContext when rebuilding a type in the current
instantiation, since we're not using a Scope object for that anyway.

llvm-svn: 91770
2009-12-19 09:35:56 +00:00
John McCall 1f4ee7bd2f Just push a new scope when parsing an out-of-line variable definition.
Magically fixes all the terrible lookup problems associated with not pushing
a new scope.  Resolves an ancient xfail and an LLVM misparse.

llvm-svn: 91769
2009-12-19 09:28:58 +00:00
Eli Friedman 7827520ce8 Initialization improvements: addition of string initialization and a few
small bug fixes in SemaInit, switch over SemaDecl to use it more often, and
change a bunch of diagnostics which are different with the new initialization
code.

llvm-svn: 91767
2009-12-19 08:11:05 +00:00
Douglas Gregor 5103effb1d A CXXExprWithTemporaries expression is an lvalue if its subexpression
is an lvalue. Fixes PR5787.

llvm-svn: 91765
2009-12-19 07:07:47 +00:00
Daniel Dunbar 893d475ba8 ARM: Use front-end specific target features "soft-float" and "soft-float-abi" to communicate FP mode to target; __SOFTFP__ is set correctly now.
llvm-svn: 91755
2009-12-19 04:15:38 +00:00
Daniel Dunbar 7b245eda5e Targets: Allow CreateTargetInfo to mutate the target features.
- In particular, it can claim features for itself instead of always passing them on to LLVM.
 - This allows using the target features as a generic mechanism for passing target specific options to the TargetInfo instance, which may need them for initializing preprocessor defines, etc.

llvm-svn: 91753
2009-12-19 03:30:57 +00:00
Zhongxing Xu 4794801e27 Use the FunctionDecl's result type to know exactly if it returns a reference.
llvm-svn: 91751
2009-12-19 03:17:55 +00:00
Douglas Gregor a4b592a7d5 Switch more of Sema::CheckInitializerTypes over to
InitializationSequence. Specially, switch initialization of a C++
class type (either copy- or direct-initialization). 

Also, make sure that we create an elidable copy-construction when
performing copy initialization of a C++ class variable. Fixes PR5826.

llvm-svn: 91750
2009-12-19 03:01:41 +00:00
John McCall 7173903ea6 Unresolved implicit member accesses are dependent if the object type is dependent.
Avoids an assertion arising during object-argument initialization in overload
resolution.  In theory we can resolve this at definition time if the class
hierarchy for the member is fully known.

llvm-svn: 91747
2009-12-19 02:05:44 +00:00
Anton Korobeynikov d7e4a095c9 Add f80 entry for windows targets
llvm-svn: 91746
2009-12-19 02:05:07 +00:00
Anton Korobeynikov d94329a545 Use proper alignment for i16/i32 on msp430. This fixes PR5815.
llvm-svn: 91739
2009-12-19 01:32:37 +00:00
Chris Lattner 25d862bb17 eliminate a call to NextToken() when parsing ::foo
llvm-svn: 91738
2009-12-19 01:11:05 +00:00
Chris Lattner fc7055668b <string> already comes in from CharUnits.h
llvm-svn: 91737
2009-12-19 01:08:23 +00:00
John McCall e2ade289be Teach TryAnnotateTypeOrScopeToken to deal with already-annotated
scope specifiers.  Fix a tentative parsing bug that came up in LLVM.
Incidentally fixes some random FIXMEs in an existing testcase.

llvm-svn: 91734
2009-12-19 00:35:18 +00:00
Eli Friedman 357e8c94d6 Fix for PR5524: make reference binding in default argument work correctly.
llvm-svn: 91733
2009-12-19 00:20:10 +00:00
Eli Friedman 70724ad2ff Work in progress for setting the vtable pointers for all bases correctly in
the constructor.  This doesn't handle cases requiring the VTT at the moment,
and generates unnecessary stores, but I think it's essentially correct.

llvm-svn: 91731
2009-12-18 23:47:41 +00:00
Eli Friedman 2b677cd4ff Cleanup switch so it doesn't have a default case.
llvm-svn: 91725
2009-12-18 23:28:34 +00:00
Eli Friedman 303e45750e Fix for PR5830: fix the computation of the offset to a virtual base.
llvm-svn: 91724
2009-12-18 23:27:44 +00:00
Ken Dyck 690ff6a016 Add and tidy doxygen comments and move implementation of toString() to newly
created CharUnits.cpp.

llvm-svn: 91719
2009-12-18 21:51:03 +00:00
Daniel Dunbar 91b640abfc Fix a few MSVC warnings.
llvm-svn: 91714
2009-12-18 20:58:47 +00:00
Ted Kremenek af1bdd71af Enhance GRExprEngine::VisitCallExpr() to be used in an lvalue context. Uncovered a new failing test case along the way, but we're making progress on handling C++ references in the analyzer.
llvm-svn: 91710
2009-12-18 20:13:39 +00:00
Daniel Dunbar c454ecf9d0 ARM: Define __thumb2__ for V6T2 targets and only define
__USING_SJLJ_EXCEPTIONS__ on Darwin.

llvm-svn: 91705
2009-12-18 19:57:13 +00:00
Douglas Gregor b3fa919c2d Extend code-completion results with the type of each result
llvm-svn: 91702
2009-12-18 18:53:37 +00:00
Daniel Dunbar acde99ea52 ARM: Fix predefines (__ARM_ARCH_..., __REGISTER_PREFIX).
- This should be done leveraging the backend, but I'm a little refactored
   out. I'll fix it one day, I promise.

llvm-svn: 91700
2009-12-18 18:42:37 +00:00
John McCall b48971d63f When diagnosing that a decl ref expr is not a value, note the declaration
with "declared at" rather than "previous declaration is here".

llvm-svn: 91699
2009-12-18 18:35:10 +00:00
Torok Edwin d0139fd3e5 Debian has x86_64-linux-gnu, not x86_64-pc-linux-gnu, so add it.
llvm-svn: 91698
2009-12-18 17:43:54 +00:00
Douglas Gregor 4a2ce65dbf Try to de-bork DISABLE_SMART_POINTERS build
llvm-svn: 91696
2009-12-18 17:31:58 +00:00
Anders Carlsson 28a133d602 CK_UserDefinedConversion is a valid kind when doing copy ctor elision.
llvm-svn: 91695
2009-12-18 17:29:21 +00:00
Torok Edwin 029707885c Move the 4.4.2 c++ include search to the top, otherwise it was picking the 4.1.3
dirs on my system. Which is wrong, since it was missing the x86_64-pc-linux-gnu
suffix.

llvm-svn: 91694
2009-12-18 17:29:14 +00:00
Ken Dyck 01e620efaa Change the return type of ASTContext::getTypeSizeInChars() from uint64_t to the
new opaque value type, CharUnits. This will help us avoid accidentally mixing 
quantities that are in bit and character units.

llvm-svn: 91689
2009-12-18 15:55:54 +00:00
Ken Dyck acfe6aa83a Rename getByteSize() and getTypeSizeInBytes() in ASTContext to getCharWidth()
and getTypeSizeInChars() to reflect their basis in character type units, not
that of a possibly independent architecture-specific byte.

llvm-svn: 91688
2009-12-18 15:24:05 +00:00
Anders Carlsson 0087bc851c Fix regression I introduced when dynamic_cast-ing to a reference type.
llvm-svn: 91687
2009-12-18 14:55:04 +00:00
Anders Carlsson b396f43520 It's perfectly fine to see UserDefinedConversion casts when emitting scalar expressions.
llvm-svn: 91686
2009-12-18 14:42:03 +00:00
John Thompson 6f8dba7f9e Tweaks for PS3 target.
llvm-svn: 91685
2009-12-18 14:21:08 +00:00
John Thompson 551446b31b Removing trailing directory separator, to make stat work
llvm-svn: 91684
2009-12-18 14:18:21 +00:00
John McCall d43784feae Set up the semantic context correctly when declaring a friend class template.
llvm-svn: 91678
2009-12-18 11:25:59 +00:00
John McCall c3f09ad253 Look through using decls when checking whether a name is an acceptable
nested-name specifier name.

I accidentally checked in the test case for this in the last commit ---
fortunately, that refactor was inspired by having debugged this problem already,
so I can fix the bug quick (though probably not fast enough for the buildbots).

llvm-svn: 91677
2009-12-18 10:48:10 +00:00
John McCall ea305edd63 Pull Sema::isAcceptableLookupResult into SemaLookup. Extract the criteria into
different functions and pick the function at lookup initialization time.
In theory we could actually divide the criteria functions into N different
functions for the N cases, but it's so not worth it.

Among other things, lets us invoke LookupQualifiedName without recomputing
IDNS info every time.

Do some refactoring in SemaDecl to avoid an awkward special case in LQN
that was only necessary for redeclaration testing for anonymous structs/unions ---
which could be done more efficiently with a scoped lookup anyway.

llvm-svn: 91676
2009-12-18 10:40:03 +00:00
Daniel Dunbar a7d0231b66 clang -cc1: Rename -mcpu to -target-cpu to match other target options and not alias driver/backend option.
llvm-svn: 91671
2009-12-18 06:30:12 +00:00
Douglas Gregor 357b6fd3e5 Address some of Anders comments
llvm-svn: 91670
2009-12-18 05:19:44 +00:00
Douglas Gregor e1314a64b8 Switch the initialization required by return statements over to the
new InitializationSequence. This fixes some bugs (e.g., PR5808),
changed some diagnostics, and caused more churn than expected. What's
new:

  - InitializationSequence now has a "C conversion sequence" category
    and step kind, which falls back to
  - Changed the diagnostics for returns to always have the result type
    of the function first and the type of the expression second.
    CheckSingleAssignmentConstraints to peform checking in C. 
  - Improved ASTs for initialization of return values. The ASTs now
    capture all of the temporaries we need to create, but
    intentionally do not bind the tempoary that is actually returned,
    so that it won't get destroyed twice.
  - Make sure to perform an (elidable!) copy of the class object that
    is returned from a class.
  - Fix copy elision in CodeGen to properly see through the
    subexpressions that occur with elidable copies.
  - Give "new" its own entity kind; as with return values and thrown
    objects, we don't bind the expression so we don't call a
    destructor for it.

Note that, with this patch, I've broken returning move-only types in
C++0x. We'll fix it later, when we tackle NRVO.

llvm-svn: 91669
2009-12-18 05:02:21 +00:00
Daniel Dunbar 24c7f5efc5 Add -dwarf-debug-flags, which provides a way to embed the cc1 level options used
to compile a translation unit into the debug info for that file.
 - Used by parts of Darwin build process to check compiler flags, etc.
 - <rdar://problem/7256886> clang does not emit AT_APPLE_flags

llvm-svn: 91661
2009-12-18 02:43:17 +00:00
Mike Stump 0da53228e6 Handle case when DestPtr is 0.
llvm-svn: 91658
2009-12-18 02:14:27 +00:00
Fariborz Jahanian 6ab7ed40c7 Implemented rewriting of invocation of a block ivar.
(radar 7482224).
 

llvm-svn: 91652
2009-12-18 01:15:21 +00:00
John McCall 90d3bb943e Patch over yet more problems with friend declarations which were provoking
problems on LLVM-Code-Syntax.  This proved remarkably easy to "fix" once
I settled on how I was going to approach it.

llvm-svn: 91633
2009-12-17 23:21:11 +00:00
Mike Stump 6dc04f4067 Revert r91073.
llvm-svn: 91629
2009-12-17 22:14:41 +00:00
Ted Kremenek 48af0e0a71 Tweak formatting and comments.
llvm-svn: 91615
2009-12-17 20:10:17 +00:00
Ted Kremenek 94cc33f33e Convert GRExprEngine::VisitCallExpr() to use a worklist instead of recursion to evaluate the arguments of a CallExpr. This simplifies the logic and makes it easier to read. (it also avoids any issues with blowing out the stack if the CallExpr had a ridiculous number of arguments)
llvm-svn: 91613
2009-12-17 20:06:29 +00:00
Ted Kremenek da7d55a4a8 Reduce nesting by using early exits. No functionality change.
llvm-svn: 91610
2009-12-17 19:17:27 +00:00
Nuno Lopes e9823fab83 implement PR3962: diagnose more faulty cases of usage of the restrict qualifier. this also removes a FIXME
llvm-svn: 91601
2009-12-17 11:35:26 +00:00
Nuno Lopes 641fdce235 revert part of my last patch, and mark only the c++ global new operator as noalias. the rest will be infered by llvm optz
llvm-svn: 91600
2009-12-17 10:15:49 +00:00
Ted Kremenek f907cee544 Sort switch statement. No functionality change.
llvm-svn: 91591
2009-12-17 07:38:34 +00:00
Anders Carlsson 3f4336cb1f Rename GetAddrOfRTTI to GetAddrOfRTTIDescriptor. Remove the overload that takes a CXXRecordDecl since we were just creating a QualType from it anyway.
llvm-svn: 91590
2009-12-17 07:09:17 +00:00
Mike Stump cd8faeb0b1 Ensure we run cleanups for CXXTemporaries on the exceptional edge. WIP.
llvm-svn: 91588
2009-12-17 06:08:47 +00:00
Chris Lattner 3dfff974ec reimplement r90860, fixing a couple of problems:
1. Don't make a copy of LangOptions every time a lexer is created.
2. Don't make CharInfo global mutable state.
3. Fix the implementation to properly treat ^Z as EOF instead of as
   horizontal whitespace, which matches the semantic implemented by VC++.

llvm-svn: 91586
2009-12-17 05:29:40 +00:00
Anders Carlsson 1fd734276d Simplify RTTIBuilder::finish.
llvm-svn: 91585
2009-12-17 05:10:59 +00:00
Anders Carlsson e5a94105eb Move the Info vector into the RTTIBuilder struct. No functionality change.
llvm-svn: 91583
2009-12-17 05:06:03 +00:00
Ted Kremenek 2e2b258158 Fix check in GRExprEngine for the 'main' function to handle NULL IdentifierInfo*'s.
llvm-svn: 91577
2009-12-17 01:20:43 +00:00
Fariborz Jahanian 057a17e4c5 Diagnose duplicate declaration of a property. Fixes
PR5809

llvm-svn: 91575
2009-12-17 00:49:09 +00:00
Eli Friedman 7f4933f6c7 Fix for PR5801: codegen memcpy, memmove, memset directly to LLVM intrinsics.
llvm-svn: 91573
2009-12-17 00:14:28 +00:00
Ted Kremenek d970acb60f Completely remove ObjCObjectRegion (tests pass this time).
llvm-svn: 91572
2009-12-16 23:53:37 +00:00
Fariborz Jahanian 01cbe441b3 Allow pointer convesion of an objective-c pointer to
'void *' to mimic gcc's behavior. (fixes radar 7477351).

llvm-svn: 91570
2009-12-16 23:13:33 +00:00
Eli Friedman 6a8dc922b3 Make sure C-specific enum warning doesn't trigger in C++.
llvm-svn: 91563
2009-12-16 20:30:08 +00:00
Daniel Dunbar 15cef0ed42 Fix -fdollars-in-identifiers Clang translation.
llvm-svn: 91562
2009-12-16 20:10:18 +00:00
Eli Friedman 5dd02a0f65 Correctly calcluate abstract-ness in the case where an implicitly declared
method overrides a pure virtual method.

llvm-svn: 91558
2009-12-16 20:00:27 +00:00
Ted Kremenek 3ab9e4cf87 Temporarily revert 91553.
llvm-svn: 91557
2009-12-16 19:46:44 +00:00
Ted Kremenek 023bceaf1b Remove use of ObjCObjectRegion from BasicStoreManager.
llvm-svn: 91553
2009-12-16 19:42:23 +00:00
Douglas Gregor 4f4b186215 When value-initializing a class with no user-defined constructors but
with a non-trivial default constructor, zero-initialize the storage
and then call the default constructor. Fixes PR5800.

llvm-svn: 91548
2009-12-16 18:50:27 +00:00
Fariborz Jahanian 00857fc376 Diagnose property of reference type as unsupported
instead of crashing for now. 

llvm-svn: 91546
2009-12-16 18:03:30 +00:00
Anders Carlsson d681a29ac0 Baby steps towards fixing PR5589. If a class needs a vtable pointer, add one.
llvm-svn: 91545
2009-12-16 17:27:20 +00:00
Nuno Lopes 13c88c7269 implement PR5654: add -fassume-sane-operator-new, which is enabled by default, and adds the malloc attribute to the global function new() and to the overloaded new operators.
feel free to chage the name to this lengthy argument

llvm-svn: 91543
2009-12-16 16:59:22 +00:00
Douglas Gregor 59ae3c8542 In Sema::CheckInitializerTypes, replace a use of CheckReferenceInit with an InitializationSequence
llvm-svn: 91542
2009-12-16 16:54:16 +00:00
Nuno Lopes 2af2af219f fix PR5689: add support for 'o' and 'V' asm input operands
llvm-svn: 91540
2009-12-16 14:28:21 +00:00
Nuno Lopes fdb8137a3e fix build
llvm-svn: 91539
2009-12-16 14:20:08 +00:00
John McCall 5750077300 Shift things around so that it's easier to recover from a missing
function in a C++ call using an arbitrary call-expression type.
Actually exploit this to fix the recovery implemented earlier.

The diagnostic is still iffy, though.

llvm-svn: 91538
2009-12-16 12:17:52 +00:00
Zhongxing Xu 6df9f54d6d Add a new kind of region: CXXObjectRegion. Currently it has only one
attribute: the object type. 
Add initial support for visiting CXXThisExpr.
Fix a bunch of 80-col violations.

llvm-svn: 91535
2009-12-16 11:27:52 +00:00
John McCall d681c3959f Introduce a centralized routine in Sema for diagnosing failed lookups (when
used as expressions).  In dependent contexts, try to recover by doing a lookup
in previously-dependent base classes.  We get better diagnostics out, but    
unfortunately the recovery fails:  we need to turn it into a method call  
expression, not a bare call expression.  Thus this is still a WIP.

llvm-svn: 91525
2009-12-16 08:11:27 +00:00
Anders Carlsson 07863b8b6e Use GetAddrOfRTTI everywhere and remove GenerateRTTI and GenerateRTTIRef. With this change, we can now compile and link TableGen.
llvm-svn: 91520
2009-12-16 07:05:41 +00:00
Anders Carlsson 18ada9856f Handle ImplicitValueInitExpr in AggExprEmitter.
llvm-svn: 91519
2009-12-16 06:57:54 +00:00
Douglas Gregor 723796af7a Eliminate Sema::CheckValueInitialization; its callers now use
InitializationSequence to perform the actual initialization.

Also, introduced the notion of a tree of initialized entities, so that
we can know where an initialization began when dealing with nested
initializations (as occur when performing list initialization). This
will, eventually, be useful for producing better diagnostics when list
initialization fails, because we can show the path from the top-level
object being initialized down to the actual subobject where
initialization failed.

llvm-svn: 91516
2009-12-16 06:35:08 +00:00
Anders Carlsson a5ca598ce6 More work on the FullExpr class.
llvm-svn: 91513
2009-12-16 06:10:22 +00:00
Ted Kremenek 9bcc264494 Teach RetainSummaryManager::getSummary(FunctionDecl* FD) that 'FD->getIdentifier()' will not always return a non-null IdentifierInfo*.
llvm-svn: 91512
2009-12-16 06:06:43 +00:00
Ted Kremenek 2d251557ef Teach OSAtomicChecker that a FunctionDecl's name isn't always a simple IdentifierInfo*.
llvm-svn: 91511
2009-12-16 06:03:24 +00:00
Ted Kremenek 85763180e7 Teach NoReturnFunctionChecker that FunctionDecl::getIdentifier() is not guaranteed to return a non-null IdentifierInfo*.
llvm-svn: 91510
2009-12-16 05:58:28 +00:00
Anders Carlsson b7e93e268f Mangle CXXOperatorCallExprs, fixes PR5796.
llvm-svn: 91507
2009-12-16 05:48:46 +00:00
Zhongxing Xu 686b8458f4 Expose C++ methods to GRExprEngine.
llvm-svn: 91506
2009-12-16 05:29:59 +00:00
Douglas Gregor 7c3bbdfd28 Fix semantic diagnostics that embed English works, from Nicola Gigante!
llvm-svn: 91503
2009-12-16 03:45:30 +00:00
Ted Kremenek 4cad5fc035 Add (initial?) static analyzer support for handling C++ references.
This change was a lot bigger than I originally anticipated; among
other things it requires us storing more information in the CFG to
record what block-level expressions need to be evaluated as lvalues.

The big change is that CFGBlocks no longer contain Stmt*'s by
CFGElements.  Currently CFGElements just wrap Stmt*, but they also
store a bit indicating whether the block-level expression should be
evalauted as an lvalue.  DeclStmts involving the initialization of a
reference require us treating the initialization expression as an
lvalue, even though that information isn't recorded in the AST.
Conceptually this change isn't that complicated, but it required
bubbling up the data through the CFGBuilder, to GRCoreEngine, and
eventually to GRExprEngine.

The addition of CFGElement is also useful for when we want to handle
more control-flow constructs or other data we want to keep in the CFG
that isn't represented well with just a block of statements.

In GRExprEngine, this patch introduces logic for evaluating the
lvalues of references, which currently retrieves the internal "pointer
value" that the reference represents.  EvalLoad does a two stage load
to catch null dereferences involving an invalid reference (although
this could possibly be caught earlier during the initialization of a
reference).

Symbols are currently symbolicated using the reference type, instead
of a pointer type, and special handling is required creating
ElementRegions that layer on SymbolicRegions (see the changes to
RegionStoreManager).

Along the way, the DeadStoresChecker also silences warnings involving
dead stores to references.  This was the original change I introduced
(which I wrote test cases for) that I realized caused GRExprEngine to
crash.

llvm-svn: 91501
2009-12-16 03:18:58 +00:00
Mike Stump b85ffb689e Add an addition check for undefined behavior for when we hit a
__builtin_unreachable.  WIP.

llvm-svn: 91499
2009-12-16 03:07:12 +00:00
Mike Stump 3f6f9febad Implement additional undefined checks for additional loads and stores. WIP.
llvm-svn: 91498
2009-12-16 02:57:00 +00:00
Anders Carlsson afb2dade0c Check in a rudimentary FullExpr class that isn't used anywhere yet. Rename Action::FullExpr to Action::MakeFullExpr to avoid name clashes.
llvm-svn: 91494
2009-12-16 02:09:40 +00:00