Commit Graph

11367 Commits

Author SHA1 Message Date
Eli Friedman 8b7b1b1aee Change compound assignment operators to keep track of both the promoted
LHS type and the computation result type; this encodes information into 
the AST which is otherwise non-obvious.  Fix Sema to always come up with the 
right answer for both of these types.  Fix IRGen and the analyzer to 
account for these changes.  This fixes PR2601.  The approach is inspired 
by PR2601 comment 2.

Note that this changes real *= complex in CodeGen from a silent 
miscompilation to an explicit error.

I'm not really sure that the analyzer changes are correct, or how to 
test them... someone more familiar with the analyzer should check those 
changes.

llvm-svn: 67889
2009-03-28 01:22:36 +00:00
Anders Carlsson 0cb4cc106c Implement access checking for protected base classes.
llvm-svn: 67887
2009-03-28 01:09:05 +00:00
Chris Lattner 2b9e7efccd move StatListener out to top level.
llvm-svn: 67886
2009-03-28 00:55:35 +00:00
Douglas Gregor 5c7c9cb678 Make our diagnostics about the obsolete GNU designated-initializer
syntax into extension warnings, and provide code-modification hints
showing how to fix the problem.

llvm-svn: 67885
2009-03-28 00:41:23 +00:00
Chris Lattner a94d139a1f various cleanups, no functionality change
llvm-svn: 67883
2009-03-28 00:16:20 +00:00
Douglas Gregor c741fb15a5 Better way to free NestedNameSpecifiers. Thanks, Chris
llvm-svn: 67880
2009-03-27 23:54:10 +00:00
Douglas Gregor 8aa6bf5b8e Fix <rdar://problem/6724396>, where we were silently dropping
GNU-style array designators, causing us to emit broken initializers.

llvm-svn: 67878
2009-03-27 23:40:29 +00:00
Douglas Gregor 6fcec66525 Perform a very, very ugly song-and-dance number to free the
NestedNameSpecifiers without causing problems for the FoldingSet that
contains them.

llvm-svn: 67877
2009-03-27 23:25:45 +00:00
Devang Patel afc1c1d405 Do not emit debug information for variables while generating optimized code. The llvm optimizer and code generator are not yet ready to support optimized code debugging.
llvm-svn: 67876
2009-03-27 23:16:32 +00:00
Douglas Gregor 333489bba3 Initial implementation of parsing, semantic analysis, and template
instantiation for C++ typename-specifiers such as

  typename T::type

The parsing of typename-specifiers is relatively easy thanks to
annotation tokens. When we see the "typename", we parse the
typename-specifier and produce a typename annotation token. There are
only a few places where we need to handle this. We currently parse the
typename-specifier form that terminates in an identifier, but not the
simple-template-id form, e.g.,

  typename T::template apply<U, V>

Parsing of nested-name-specifiers has a similar problem, since at this
point we don't have any representation of a class template
specialization whose template-name is unknown.

Semantic analysis is only partially complete, with some support for
template instantiation that works for simple examples. 

llvm-svn: 67875
2009-03-27 23:10:48 +00:00
Ted Kremenek 8f5ec29b91 Add missing header file change.
llvm-svn: 67871
2009-03-27 22:00:38 +00:00
Sebastian Redl ec74096050 Better overload resolution for rvalue references.
llvm-svn: 67870
2009-03-27 21:36:42 +00:00
Ted Kremenek 7a621b9747 BugReporter: For control-flow edges from 'if', 'for', 'do', 'while' to
successor, using 'getEnclosingStmt()' to have the end location be the top-level
Stmt* enclosing the target Expr*.

llvm-svn: 67869
2009-03-27 21:16:25 +00:00
Eli Friedman 7044b76707 Finish off semantic analysis for regparm, and remove the warning. Also
remove a redundant error in CodeGen.

llvm-svn: 67868
2009-03-27 21:06:47 +00:00
Eli Friedman 6ecb5afcd6 Fix test failures caused by reading memory after freeing it. My fix is
rather nasty, but I can't think of a better fix off the top of my head.

llvm-svn: 67867
2009-03-27 20:56:17 +00:00
Ted Kremenek 41d865cbaa BugReporter: PathDiagnosticBuilder::ExecutionContinues now returns a
PathDiagnosticLocation.

llvm-svn: 67866
2009-03-27 20:55:39 +00:00
Chris Lattner 8e097198fc minor cleanups: make getIdentifierNamespace() be a single load
instead of a load + large inlined switch.

llvm-svn: 67864
2009-03-27 20:18:19 +00:00
Mike Stump e5fdfd5930 Fixup -fcommon and -fno-common to be more gcc compatible.
llvm-svn: 67863
2009-03-27 20:15:22 +00:00
Chris Lattner 17a1bfa9d8 reduce # const_casts, no functionality change.
llvm-svn: 67861
2009-03-27 19:19:59 +00:00
Anders Carlsson af06b977f9 It is OK to cast to a private base class if the current member belongs to the class that the private base class is a base of:
class A {};
class B : private A {
  void f(B *b) { A* a = b; }
};

llvm-svn: 67860
2009-03-27 19:01:12 +00:00
Anders Carlsson 93d35acb28 Add a Class field to the base path element structure. This holds the record decl of the class taht the base is a base of.
llvm-svn: 67859
2009-03-27 18:54:29 +00:00
Chris Lattner 586c66d5ba change Decl::DeclCtx to use a PointerIntPair instead of hand bitmangling.
llvm-svn: 67858
2009-03-27 18:46:15 +00:00
Fariborz Jahanian a2d609e2f1 Besides the warning, issue unsupported diagnostics in
ir gen. No intended change in functionality.

llvm-svn: 67857
2009-03-27 18:38:55 +00:00
Chris Lattner 839150e0d2 push line markers through -E mode.
llvm-svn: 67854
2009-03-27 17:13:49 +00:00
Ted Kremenek b3e8f6531d Update "Getting Started" with more current information about 'clang-cc' and 'clang'.
llvm-svn: 67850
2009-03-27 16:32:57 +00:00
Ted Kremenek 15b3753858 analyzer plist: For PathDiagnosticControlFlowPieces, now output an array of
start-end points, where start and end are source ranges.

llvm-svn: 67847
2009-03-27 15:53:20 +00:00
Ted Kremenek 073da05fa4 Emit aggregate "location" for PathDiagnostic to plist. This fixes <rdar://problem/6729558>.
llvm-svn: 67845
2009-03-27 15:31:11 +00:00
Ted Kremenek d10307debb Move declaration of 'PathDiagnostic' to the end of PathDiagnostic.h and add PathDiagnostic::getLocation().
llvm-svn: 67842
2009-03-27 15:24:36 +00:00
Daniel Dunbar a21c833d74 Driver: Pass -f[no-]pascal-strings on to clang, even if it has been
turned into -m[no-]pascal-strings by the tool chain.
 - This still has issue that derived arguments don't propogate "used"
   information correctly so spurious "argument unused" warnings will
   still show up.

llvm-svn: 67841
2009-03-27 15:22:28 +00:00
Ted Kremenek 33e6f91ec3 PathDiagnostic: replace 'std::list' with 'std::deque'
llvm-svn: 67840
2009-03-27 14:59:04 +00:00
Ted Kremenek b630d5b2c9 Add iterators to PathDiagnosticControlFlowDiagnostic for iterating over the
multiple location vectors.

llvm-svn: 67838
2009-03-27 14:54:49 +00:00
Daniel Dunbar 565eefd4ab Driver: -print-libgcc-file-name was searching wrong path list.
llvm-svn: 67837
2009-03-27 14:26:33 +00:00
Anders Carlsson 733d77f1b4 Implement checking for base class access. Right now it's overly conservative but that will change. (Also, protected isn't implemented right now).
llvm-svn: 67827
2009-03-27 06:03:27 +00:00
Douglas Gregor 0b08ba44a1 If the user is trying to apply the -> or . member reference operator
to a function or function pointer, it's probably because the user
forgot to put in parentheses () to call the function.

llvm-svn: 67826
2009-03-27 06:00:30 +00:00
Zhongxing Xu 17e28b7a54 remove dead code.
llvm-svn: 67825
2009-03-27 05:31:12 +00:00
Douglas Gregor 43f1bdbdc3 Update CMake
llvm-svn: 67824
2009-03-27 05:18:33 +00:00
Douglas Gregor ae0fb56aaa Remove the code insertion hint for implicit int. Too often, we're wrong about this hint, so it loses its usefulness. Maybe some day we can make the hint smart enough to be useful.
llvm-svn: 67823
2009-03-27 05:10:56 +00:00
Ted Kremenek a7ec0ded63 BugReporter:
- Added an internal helper class 'PathDiagnosticBuilder' which now bundles the
  'ExecutionContinues' methods.
- Added preliminary diagnostics for short-circuit '&&' and '||'

llvm-svn: 67822
2009-03-27 05:06:10 +00:00
Anders Carlsson 4742a9c19a Add a stubbed out CheckBaseClassAccess method.
llvm-svn: 67821
2009-03-27 05:05:05 +00:00
Anders Carlsson 17941120d6 Move Sema::SetMemberAccessSpecifier to SemaAccess.cpp
llvm-svn: 67820
2009-03-27 04:54:36 +00:00
Anders Carlsson 8ed6f3645b Add SemaAccess.cpp
llvm-svn: 67819
2009-03-27 04:43:36 +00:00
Douglas Gregor f4d17c4f22 Improve recovery when a constructor fails to type-check. Test case from Anders
llvm-svn: 67818
2009-03-27 04:38:56 +00:00
Douglas Gregor fdca4a7967 Tests and fixes for templates declared within (non-template)
classes. Test case from Anders Carlsson, fix from Piotr Rak!

llvm-svn: 67817
2009-03-27 04:21:56 +00:00
Chris Lattner 9eac931b5f Fix rdar://6719156 - clang should emit a better error when blocks are disabled but are used anyway
by changing blocks from being disabled in the parser to being disabled
in Sema.

llvm-svn: 67816
2009-03-27 04:18:06 +00:00
Zhongxing Xu c1c09b1f35 remove the updated notes.
llvm-svn: 67813
2009-03-27 02:22:41 +00:00
Ted Kremenek 0e34da42c5 - Fix thinko in implementation of PathDiagnosticLocation::asStmt(). Thanks to
Anders Johnsen for pointing this out.
- Have PathDiagnosticControlFlowPiece take PathDiagnosticLocation for the
  arguments to its constructors.

llvm-svn: 67812
2009-03-27 02:22:03 +00:00
Mike Stump db65737b1c Fix searching for gcc, we only want executable files.
llvm-svn: 67806
2009-03-27 00:40:20 +00:00
Douglas Gregor f53c47ecc2 Clarify that QualifiedNameType is sugar-only. This will matter once we can parse typename-specifiers
llvm-svn: 67803
2009-03-27 00:03:43 +00:00
Fariborz Jahanian c35c9d87a9 Put back __OBJC2__ definition.
llvm-svn: 67802
2009-03-26 23:57:56 +00:00
Douglas Gregor c23500ebb3 Simplify CXXScopeSpec a lot. No more weird SmallVector-like hacks here
llvm-svn: 67800
2009-03-26 23:56:24 +00:00
Douglas Gregor f21eb49a04 Revamp our representation of C++ nested-name-specifiers. We now have a
uniqued representation that should both save some memory and make it
far easier to properly build canonical types for types involving
dependent nested-name-specifiers, e.g., "typename T::Nested::type".

This approach will greatly simplify the representation of
CXXScopeSpec. That'll be next.

llvm-svn: 67799
2009-03-26 23:50:42 +00:00
Anders Carlsson e6224e7913 I said _fix_ the build, don't break it.
llvm-svn: 67797
2009-03-26 23:48:49 +00:00
Anders Carlsson e3f92270e6 Fix build.
llvm-svn: 67796
2009-03-26 23:47:48 +00:00
Anders Carlsson 6750d16002 Add
const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
                                    AccessSpecifier AS);
   
so we can easily add access specifiers to diagnostics.

llvm-svn: 67795
2009-03-26 23:46:50 +00:00
Ted Kremenek 46dee7b0f6 - Add class PathDiagosticLocationPair.
- Have PathDiagnosticControlFlowPiece use a vector of PathDiagnosticLocationPairs to represent transitions.

llvm-svn: 67786
2009-03-26 23:12:02 +00:00
Ted Kremenek 96110d5920 Implement PathDiagnosticLocation::asRange() and PathDiagnosticLocation::asStmt().
llvm-svn: 67777
2009-03-26 21:48:17 +00:00
Ted Kremenek c25116576f Add comment.
llvm-svn: 67776
2009-03-26 21:42:51 +00:00
Ted Kremenek 7c36d902d0 Restructure code to silence bogus GCC warning.
llvm-svn: 67775
2009-03-26 21:42:00 +00:00
Ted Kremenek bade06e7d7 - Implement PathDiagnosticLocation::asLocation.
- Switch PathDiagnosticEventPiece and PathDiagnosticMacroPiece to use
  PathDiagnosticLocation.

llvm-svn: 67774
2009-03-26 21:39:39 +00:00
Ted Kremenek 2d6a1dec5d Because of the use of 'cast<TagDecl>', ASTContext.h now depends on Decl.h.
llvm-svn: 67773
2009-03-26 21:36:37 +00:00
Mike Stump ffea82e2f4 Remove dead code.
llvm-svn: 67769
2009-03-26 21:25:00 +00:00
Ted Kremenek 3d46b1cfb4 PathDiagnostics (analyzer):
- Added a new class, 'PathDiagnosticLocation', that is a variant for
  SourceLocation, SourceRange, or Stmt*. This will be used soon by
  PathDiagnosticPieces to describe locations for targets of branches, locations
  of events, etc.
- Did some prep. refactoring of PathDiagnosticPieces to prepare them for
  adopting the new PathDiagnosticLocation

llvm-svn: 67767
2009-03-26 21:21:35 +00:00
Fariborz Jahanian dac14a7159 - Minor change to dump of ivar layout map.
- Temporarily undef'ed __OBJC2__ in nonfragile objc abi mode
  as it was forcing ivar synthesis in a certain project which clang
  does not yet support.

llvm-svn: 67766
2009-03-26 19:10:36 +00:00
Daniel Dunbar adf511c056 Driver: Forward -fno-common to clang.
- <rdar://problem/6710978> ccc/clang-driver ignore -fno-common

llvm-svn: 67762
2009-03-26 16:37:00 +00:00
Daniel Dunbar 42b91a86f3 Driver: Test case for darwin::Link
llvm-svn: 67761
2009-03-26 16:29:05 +00:00
Daniel Dunbar c196421fbc Driver: Add darwin::Link tool.
- <rdar://problem/6717381> [driver] implement ld argument translation
   in new driver

llvm-svn: 67760
2009-03-26 16:23:12 +00:00
Ted Kremenek 2f41ffe825 Add a high-level intro to the memory regions design document.
llvm-svn: 67759
2009-03-26 16:19:54 +00:00
Daniel Dunbar dd76524d76 Driver: Fix a number of option definition mismatches (flags instead of
separate, or vice versa).

Also, fix initialization of LinkingOutput variable.

llvm-svn: 67757
2009-03-26 16:12:09 +00:00
Daniel Dunbar b1024880f1 Driver: Print the correct target when printing the version.
llvm-svn: 67756
2009-03-26 16:09:13 +00:00
Steve Naroff 389925dc87 Fix <rdar://problem/6697053> instance variable is protected.
Treat @package the same as @public. The documentation for @package says it is analogous to private_extern for variables/functions. Fully implementing this requires some kind of linker support (so access is denied to code outside the classes executable image). I don't believe GCC fully implements this semantic. Will discuss with Fariborz offline.

llvm-svn: 67755
2009-03-26 16:01:08 +00:00
Daniel Dunbar c7fd57a2f3 Driver: Move GetReleaseVersion to static Driver::GetReleaseVersion method.
llvm-svn: 67754
2009-03-26 15:58:36 +00:00
Daniel Dunbar 4e5696b984 Driver: Add ArgList::AddAllArgsTranslated; for forwarding options to
tools with the name of the option replace, and arguments rendered
separately.

llvm-svn: 67753
2009-03-26 15:39:22 +00:00
Ted Kremenek a32f7a124a Move "regions" analyzer design document to 'docs'.
llvm-svn: 67752
2009-03-26 15:29:38 +00:00
Zhongxing Xu 8346601e0b Simplify some code. No functionality change.
llvm-svn: 67748
2009-03-26 08:40:37 +00:00
Zhongxing Xu 2d44866316 Check in some design documents to centralize ideas around region store and the
analysis engine.

llvm-svn: 67747
2009-03-26 08:23:58 +00:00
Eli Friedman 6568eef9f9 Sanity-check argument to indirect goto.
llvm-svn: 67746
2009-03-26 07:32:37 +00:00
Chris Lattner ada1c91537 hopefully fix VC++ build error.
llvm-svn: 67741
2009-03-26 05:56:24 +00:00
Chris Lattner 984fac5f5f most of this is plumbing to get CompileOptions down into
CodeGenModule.  Once there, add a new NoCommon option to
it and implement -fno-common.

llvm-svn: 67735
2009-03-26 05:00:52 +00:00
Chris Lattner 897b41dd77 make this self contained, declare everything as 'class'.
llvm-svn: 67734
2009-03-26 05:00:03 +00:00
Chris Lattner 5e31037164 sort items.
llvm-svn: 67733
2009-03-26 04:59:37 +00:00
Chris Lattner cea1efaa61 add driver and clang-cc to project.
llvm-svn: 67732
2009-03-26 04:27:05 +00:00
Ted Kremenek 3e31c26f81 analyzer infrastructure: make a bunch of changes to symbolic expressions that
Zhongxing and I discussed by email.

Main changes:
- Removed SymIntConstraintVal and SymIntConstraint
- Added SymExpr as a parent class to SymbolData, SymSymExpr, SymIntExpr
- Added nonloc::SymExprVal to wrap SymExpr
- SymbolRef is now just a typedef of 'const SymbolData*'
- Bunch of minor code cleanups in how some methods were invoked (no functionality change)

This changes are part of a long-term plan to have full symbolic expression
trees. This will be useful for lazily evaluating complicated expressions.

llvm-svn: 67731
2009-03-26 03:35:11 +00:00
Anders Carlsson 137108da15 Set the access specifier for templates inside classes.
llvm-svn: 67726
2009-03-26 01:24:28 +00:00
Anders Carlsson 5558ca1d4f Factor the member access specifier setting code into its own function. No intended functionality change.
llvm-svn: 67725
2009-03-26 01:19:02 +00:00
Anders Carlsson dfbbdf6fd5 Handle parsing of templates in member declarations. Pass the AccessSpecifier all the way down to ActOnClassTemplate.
Doug, Sebastian: Plz review! :)

llvm-svn: 67723
2009-03-26 00:52:18 +00:00
Anders Carlsson 2ed6ceba1d Check that the access specifier of a member redeclaration is the same as the original declaration.
llvm-svn: 67722
2009-03-26 00:24:17 +00:00
Eli Friedman 8d7ff4098c Fix for PR3869: actually enforce that the argument of an indirect goto
is of type void*.  I'll try to add the appropriate checking later.

llvm-svn: 67721
2009-03-26 00:18:06 +00:00
Douglas Gregor 97f1f1c46e The injected-class-name of class templates and class template
specializations can be treated as a template. Finally, we can parse
and process the first implementation of Fibonacci I wrote!

Note that this code does not handle all of the cases where
injected-class-names can be treated as templates. In particular,
there's an ambiguity case that we should be able to handle (but
can't), e.g.,

  template <class T> struct Base { }; 
  template <class T> struct Derived : Base<int>, Base<char> {
    typename Derived::Base b;       // error: ambiguous
    typename Derived::Base<double> d;  // OK 
  };

llvm-svn: 67720
2009-03-26 00:10:35 +00:00
Anders Carlsson a28908d575 Tighten the setAccess assert. We now allow AS_none if the decl contex is not a C++ record decl.
Also, fix fallout from the change.

llvm-svn: 67717
2009-03-25 23:38:06 +00:00
Douglas Gregor ef1a09a336 Implement template instantiation for static data members of class
templates, including in-class initializers. For example:

  template<typename T, T Divisor>
  class X {
  public:
    static const T value = 10 / Divisor;
  };

instantiated with, e.g.,

  X<int, 5>::value

to get the value '2'.

llvm-svn: 67715
2009-03-25 23:32:15 +00:00
Fariborz Jahanian f909f92799 More for for objc2's ivar layout map (currently
is not in use).

llvm-svn: 67713
2009-03-25 22:36:49 +00:00
Douglas Gregor 6c2adff380 Pass access specifiers through to member classes and member enums.
llvm-svn: 67710
2009-03-25 22:00:53 +00:00
Douglas Gregor f3430ae300 Fix notes regarding the instantiation of member classes (and test 'em).
llvm-svn: 67708
2009-03-25 21:23:52 +00:00
Douglas Gregor 8ea8fd48f2 Instantiation for member classes of class templates. Note that only
the declarations of member classes are instantiated when the owning
class template is instantiated. The definitions of such member classes
are instantiated when a complete type is required.

This change also introduces the injected-class-name into a class
template specialization.

llvm-svn: 67707
2009-03-25 21:17:03 +00:00
Chris Lattner 51a53f92a5 fix PR3880, fixing a comma swallowing bug handling macros that only take
... arguments.

llvm-svn: 67706
2009-03-25 21:08:24 +00:00
Chris Lattner beb9055000 remove some dead code. ArgTokens can never be empty, because it is always
terminated with an EOF token.  The condition it is trying to check for is
handled by this code above.

    // Empty arguments are standard in C99 and supported as an extension in
    // other modes.
    if (ArgTokens.empty() && !Features.C99)
      Diag(Tok, diag::ext_empty_fnmacro_arg);

llvm-svn: 67705
2009-03-25 21:01:40 +00:00
Ted Kremenek a87b8a9a72 CMake: Also include header files in target when the generator is 'XCode'.
llvm-svn: 67703
2009-03-25 20:34:07 +00:00
Anders Carlsson 612f8a4842 It doesn't make sense to set the access specifier to AS_none (I think)
llvm-svn: 67700
2009-03-25 20:19:57 +00:00
Mike Stump 871c1f6f88 Remove -f__block as codegen for __block variables should be solid.
llvm-svn: 67697
2009-03-25 18:05:39 +00:00
Mike Stump d2142cffbf Fixup codegen for block literals that bleed copy/dispose information
from previous block literals.

llvm-svn: 67696
2009-03-25 17:58:24 +00:00
Mike Stump 12ef15f8b2 Update to account for the great driver renaming.
llvm-svn: 67695
2009-03-25 17:56:16 +00:00
Douglas Gregor dfcad11842 Predicate to detect when a RecordDecl is really the injected-class-name
llvm-svn: 67687
2009-03-25 15:59:44 +00:00
Douglas Gregor 8a6555332f Stub out some declaration kinds that cannot ever be instantiated
llvm-svn: 67686
2009-03-25 15:45:12 +00:00
Douglas Gregor 167fa625f3 Fix parsing of template classes prefixed by nested-name-specifiers
llvm-svn: 67685
2009-03-25 15:40:00 +00:00
Douglas Gregor 9106b82ceb Minor refactoring to eliminate an extra switch during template instantiation
llvm-svn: 67684
2009-03-25 15:04:13 +00:00
Daniel Dunbar 0af75a19a4 Driver: Implement Darwin_X86 tool chain level argument translation.
- This is really gross, but its the easiest way to match gcc. Once we
   are confident in the driver, we can try and push these translations
   down into tools.

 - No test cases for this yet, it's hard to see the effects of these
   translations before the gcc tool argument translation is pulled
   over.

 - Interaction with "unused argument" warning hasn't been worked out
   yet.

 - <rdar://problem/6717359> [driver] implement toolchain specific
   argument translation.

"It's horrible in here."

llvm-svn: 67683
2009-03-25 06:58:31 +00:00
Daniel Dunbar aabb0b11a3 Driver: Handle -Xarch_, including warning for nasty -Xarch_ use cases
we aren't going to support. For example:
  clang -Xarch_i386 -S -Xarch_i386 -o -Xarch_i386 myi386asm.s ...

llvm-svn: 67680
2009-03-25 06:12:34 +00:00
Daniel Dunbar 0e378b1e26 Driver: Replace Option::ForwardToGCC by Option::DriverOption (which
matches the flag in Options.def).

llvm-svn: 67679
2009-03-25 06:08:46 +00:00
Zhongxing Xu 24e7eade19 This patch adds two more SymbolData subclasses: SymIntExpr and SymSymExpr, for
representing symbolic expressions like 'x'+3 and 'x'+'y'. The design is
subjected to change later when we fix the class hierarchy of symbolic
expressions.

llvm-svn: 67678
2009-03-25 05:58:37 +00:00
Daniel Dunbar b2304ee0d1 Driver: Fix typo in JoinedAndSeparateArg::render.
llvm-svn: 67677
2009-03-25 05:23:40 +00:00
Daniel Dunbar dac54a81df Driver: Prep for tool chain specific argument translation.
- Lift ArgList to a base class for InputArgList and DerivedArgList.
 
 - This is not a great decomposition, but it does embed the
   translation into the type system, and keep things efficient for
   tool chains that don't want to do any translation.

 - No intended functionality change.

Eventually I hope to get rid of tool chain specific translation and
have each tool do the right thing, but for now this is the easiest way
to match gcc precisely (which is good for testing).

llvm-svn: 67676
2009-03-25 04:13:45 +00:00
Chris Lattner 8c37df4f91 simplify some conditionals, don't copy LangOptions.
llvm-svn: 67674
2009-03-25 03:28:08 +00:00
Daniel Dunbar 0e0cf39a9e gcc 4.3 finds my use of ^ suspicious.
llvm-svn: 67673
2009-03-25 03:06:26 +00:00
Anders Carlsson 75fdaa465f Improve handling of base initializers. We now parse initializers in out of line decls, such as:
class C {
    C() { }
    
    int a;
};

C::C() : a(10) { }

We also diagnose when initializers are used on declarations that aren't constructors:

t.cpp:1:10: error: only constructors take base initializers
void f() : a(10) { }
         ^

Doug and/or Sebastian: I'd appreciate a review, especially the nested-name-spec test results (from the looks of it we now match gcc in that test.)

llvm-svn: 67672
2009-03-25 02:58:17 +00:00
Anders Carlsson 3cfc2e214a Add the .td files and remove the .def files from the Xcode project.
llvm-svn: 67671
2009-03-25 02:54:43 +00:00
Ted Kremenek 759d5d3fa7 Turn on -analyzer-eagerly-assume by default when using 'clang-cc' to perform
static analysis.

llvm-svn: 67665
2009-03-25 00:38:14 +00:00
Douglas Gregor 1880ba59f3 Template instantiation for conversion functions
llvm-svn: 67664
2009-03-25 00:34:44 +00:00
Ted Kremenek 7b7b3f0817 Turn on '-analyzer-eagerly-assume' by default in ccc for the static analyzer.
llvm-svn: 67663
2009-03-25 00:32:30 +00:00
Douglas Gregor 3d0d4b833a Move template instantiation for expressions into a separate file
llvm-svn: 67660
2009-03-25 00:27:28 +00:00
Douglas Gregor c08f489d38 In Parser::ParseClassSpecifier, don't conflate a NULL declaration with
failure to perform a declaration. Instead, explicitly note semantic
failures that occur during template parsing with a DeclResult. Fixes
PR3872.

llvm-svn: 67659
2009-03-25 00:13:59 +00:00
Sebastian Redl f769df5ef9 Parse deleted function definitions and hook them up to Doug's machinery.
llvm-svn: 67653
2009-03-24 22:27:57 +00:00
Devang Patel 94406c954f Encode language.
llvm-svn: 67650
2009-03-24 20:35:51 +00:00
Douglas Gregor 64259f5143 Type::isObjectType now implements the (more sensible) C++ definition
of "object type" rather than the C definition of "object type". The
difference is that C's "object type" excludes incomplete types such as

  struct X;

However, C's definition also makes it far too easy to use isObjectType
as a means to detect incomplete types when in fact we should use other
means (e.g., Sema::RequireCompleteType) that cope with C++ semantics,
including template instantiation.

I've already audited every use of isObjectType and isIncompleteType to
ensure that they are doing the right thing for both C and C++, so this
is patch does not change any functionality.

llvm-svn: 67648
2009-03-24 20:32:41 +00:00
Daniel Dunbar 1386495406 Driver: Handle -flto, -O4, and tweak -emit-llvm to match llvm-gcc.
- -emit-llvm no longer changes what compilation steps are done.

 - -emit-llvm and -emit-llvm -S write output files with .o and .s
    suffixes, respectively.

 - <rdar://problem/6714125> clang-driver should support -O4 and -flto,
   like llvm-gcc

llvm-svn: 67645
2009-03-24 20:17:30 +00:00
Douglas Gregor c9a1a3b9d9 Fix a few isObjectTypes that really need to be isIncompleteOrObject
types; add another use of RequireCompleteType.

llvm-svn: 67644
2009-03-24 20:13:58 +00:00
Douglas Gregor ac1fb65d0c Make sure to use RequireCompleteType rather than testing for
incomplete types. RequireCompleteType is needed when the type may be
completed by instantiating a template.

llvm-svn: 67643
2009-03-24 19:52:54 +00:00
Daniel Dunbar 6b5244d600 Driver: Warn when 'clang' is used to compile a source file we could
conceivably handle, but are defaulting to not using clang for.

llvm-svn: 67641
2009-03-24 19:14:56 +00:00
Daniel Dunbar 88f356e16b Driver: Change default use of "clang" compiler.
- Don't default to using clang for C++ (use -ccc-clang-cxx to
   override).

 - Default to only using clang on i386 and x86_64 (use
   -ccc-clang-archs "" to override).

 - <rdar://problem/6712350> [driver] clang should not be used on
   powerpc by default
 - <rdar://problem/6705767> driver should default to -ccc-no-clang-cxx

I plan to add a warning that we are not using the clang compiler for
the given compilation so that users do not think clang is being used
in situations it isn't.

This change is motivated by the desire to be able to drop clang into a
build and have things "just work", even if it happens to get used to
compile C++ code or code for an architecture we don't support yet.

llvm-svn: 67640
2009-03-24 19:02:31 +00:00
Daniel Dunbar 8fa879d39f Move ToolChain::ShouldUseClangCompiler to
Driver::ShouldUseClangCompiler.
 - No functionality change.

llvm-svn: 67639
2009-03-24 18:57:02 +00:00
Daniel Dunbar 038f5d6ef0 Driver: Translate -fverbose-asm for LLVM backend.
- <rdar://problem/6715707> driver should translate -fverbose-asm into
   -asm-verbose

llvm-svn: 67634
2009-03-24 17:59:06 +00:00
Mike Stump 90a3707225 Really fix cmake style builds.
llvm-svn: 67633
2009-03-24 17:52:34 +00:00
Daniel Dunbar 827faf8f2b Driver: Result files shouldn't be removed on failure when -save-temps
is specified.
 - No easy way to make a safe test case for this (given where the
   driver is supposed to put temp files).

llvm-svn: 67632
2009-03-24 17:49:01 +00:00
Daniel Dunbar 9ea0e77572 Driver: ArgList::getLastArg was in fact returning the first matching arg.
- <rdar://problem/6715818> clang doesn't honor gcc semantic that last
    -O optimization option wins.

llvm-svn: 67628
2009-03-24 17:31:30 +00:00
Anders Carlsson b57738b09c Fix the bug that Eli noticed where we wouldn't look at function decls outside the class declaration.
llvm-svn: 67627
2009-03-24 17:23:42 +00:00
Chris Lattner f37e09e0fc improve error recovery for when type parsing fails.
llvm-svn: 67626
2009-03-24 17:21:43 +00:00
Chris Lattner deab7250fb fix "Comment#1" from PR3872
llvm-svn: 67625
2009-03-24 17:05:27 +00:00
Chris Lattner 803802d4d6 random cleanups.
llvm-svn: 67624
2009-03-24 17:04:48 +00:00
Douglas Gregor 4044d995c9 Template instantiation for constructors
llvm-svn: 67623
2009-03-24 16:43:20 +00:00
Chris Lattner 02428f6aa6 -arch ppc should change the triple to powerpc-foo not to ppc-foo.
Similarly for ppc64.  This should probably move into the driver, along
with all the other target selection stuff other than -triple.

llvm-svn: 67621
2009-03-24 16:18:41 +00:00
Douglas Gregor 0caea8cca7 Add another C++ open project
llvm-svn: 67620
2009-03-24 16:16:53 +00:00
Chris Lattner 73a7cab9e1 change the __VERSION__ string to be more sensible. It would be useful to include the clang version # too.
llvm-svn: 67619
2009-03-24 16:09:18 +00:00
Daniel Dunbar d7a1860eba Driver: Forward -MMD (not -MM) to clang-cc; this got lost in
translation, the former we support, the later we don't (yet).

llvm-svn: 67611
2009-03-24 07:20:59 +00:00
Daniel Dunbar 2afa8abdfb Update TestRunner.sh for renaming.
- Substitutes both clang and clang-cc.

 - Incorporates patch from Jon Simons to diagnose if clang or clang-cc
   isn't found.

 - Uses full path when running scripts, for more precision in the
   output.

llvm-svn: 67610
2009-03-24 06:17:45 +00:00
Ted Kremenek 97eaaddc22 More path updates with clang-cc...
llvm-svn: 67609
2009-03-24 05:30:14 +00:00
Ted Kremenek c13a6bc593 Update scan-build/ccc-analyzer to use 'clang-cc' instead of 'clang'.
llvm-svn: 67608
2009-03-24 04:29:13 +00:00
Daniel Dunbar 2dbe89af65 Install clang-cc to libexec/clang-cc (instead of bin/clang-cc).
- Updated ccc & driver to look in libexec/ for tools.

llvm-svn: 67607
2009-03-24 04:07:10 +00:00
Daniel Dunbar 36245c5a90 Rename clang-driver to clang.
Again, I tried to update cmake but it is untested.

llvm-svn: 67606
2009-03-24 03:07:05 +00:00
Daniel Dunbar e5a7ecc23a Move <root>/Driver into <root>/tools/clang-cc.
Again, I tried to update cmake but it is untested.

llvm-svn: 67605
2009-03-24 03:00:12 +00:00
Daniel Dunbar 3db73ab7f6 Add CMake files for tools/driver; I am just guessing here, can someone test/fix?
llvm-svn: 67604
2009-03-24 02:52:57 +00:00
Daniel Dunbar bf1fe8c36c Support member reference on ?: of struct type.
llvm-svn: 67603
2009-03-24 02:38:23 +00:00
Daniel Dunbar a45cf5b6b0 Rename clang to clang-cc.
Tests and drivers updated, still need to shuffle dirs.

llvm-svn: 67602
2009-03-24 02:24:46 +00:00
Daniel Dunbar 4aacad1f93 Use not instead of ! in tests.
llvm-svn: 67601
2009-03-24 01:59:55 +00:00
Anders Carlsson 8f0d218598 Handle pointers to arrays of abstract types.
llvm-svn: 67598
2009-03-24 01:46:45 +00:00
Anders Carlsson b0ab31b7f6 Remove a task that's completed now.
llvm-svn: 67596
2009-03-24 01:25:56 +00:00
Anders Carlsson b6da73f2e0 class.abstract is complete. Anything that doesn't work is a bug.
llvm-svn: 67595
2009-03-24 01:24:06 +00:00
Anders Carlsson b5a27b460c More work on diagnosing abstract classes. We can now handle cases like
class C {
  void g(C c);

  virtual void f() = 0;
};

In this case, C is not known to be abstract when doing semantic analysis on g. This is done by recursively traversing the abstract class and checking the types of member functions. 

llvm-svn: 67594
2009-03-24 01:19:16 +00:00
Eli Friedman 94c25c66b5 Fix PR3868 by making Evaluate handle cases like "(long)&a + 4".
llvm-svn: 67593
2009-03-24 01:14:50 +00:00
Eli Friedman 703a77f313 Fix a couple of tests.
llvm-svn: 67592
2009-03-24 01:11:18 +00:00
Daniel Dunbar d5f35ca0bf ccc: Have generic GCC tool chain search the driver directory for
executables (e.g., clang).
 - This matches the clang-driver behavior.

llvm-svn: 67590
2009-03-24 01:06:18 +00:00
Douglas Gregor 2134209a2a Cleanup template instantiation for methods, destructors
llvm-svn: 67585
2009-03-24 00:38:23 +00:00
Ted Kremenek 74250d1d68 Update checker build.
llvm-svn: 67584
2009-03-24 00:35:59 +00:00
Daniel Dunbar 06686abfdc Driver: lipo wasn't being called correctly (translation failure from
ccc due to the different way we handle output arguments).

llvm-svn: 67583
2009-03-24 00:24:37 +00:00
Daniel Dunbar b5860facfd ccc/Driver: -r option doesn't take an argument.
llvm-svn: 67581
2009-03-24 00:20:13 +00:00
Douglas Gregor 654b07e029 Template instantiation for destructors. This is somewhat repetitive;
eliminating the duplication is next on the list.

llvm-svn: 67579
2009-03-24 00:15:49 +00:00
Eli Friedman 2dc5f29ff2 Fix the ABI convention for struct returns on x86 outside of Darwin.
llvm-svn: 67577
2009-03-23 23:26:24 +00:00
Douglas Gregor 1f0ce935e8 Another use of adjustParameterType. Plus, GetTypeForDeclarator will
always get ParmVarDecls with already-adjusted types. Assert it.

Thanks, Anders!

llvm-svn: 67576
2009-03-23 23:17:00 +00:00
Douglas Gregor f4f296de01 Template instantiation for the declarations of member functions within
a class template. At present, we can only instantiation normal
methods, but not constructors, destructors, or conversion operators.

As ever, this contains a bit of refactoring in Sema's type-checking. In
particular:

  - Split ActOnFunctionDeclarator into ActOnFunctionDeclarator
    (handling the declarator itself) and CheckFunctionDeclaration
    (checking for the the function declaration), the latter of which
    is also used by template instantiation.
  - We were performing the adjustment of function parameter types in
    three places; collect those into a single new routine.
  - When the type of a parameter is adjusted, allocate an
    OriginalParmVarDecl to keep track of the type as it was written.
  - Eliminate a redundant check for out-of-line declarations of member
    functions; hide more C++-specific checks on function declarations
    behind if(getLangOptions().CPlusPlus).

llvm-svn: 67575
2009-03-23 23:06:20 +00:00
Ted Kremenek f718f0112e Deallocate 'DeclRefExpr's in correctly formed '#pragma unused'
llvm-svn: 67573
2009-03-23 22:50:47 +00:00
Ted Kremenek af6543455f A test case to test that -warn-dead-stores does not emit a warning for stores to variables marked with '#pragma unused'.
llvm-svn: 67570
2009-03-23 22:30:58 +00:00
Ted Kremenek fd14fade2f Implement '#pragma unused'.
llvm-svn: 67569
2009-03-23 22:28:25 +00:00
Daniel Dunbar 95953ce31c Driver: Make argument parsing fast.
On a synthetic command line consisting of almost all defined options,
this drops wall time from .00494 to .00336 and user time from .00258
to .00105.

On the same benchmark, clang-driver is about 15% faster than the
primary gcc driver and almost twice as fast as the gcc driver driver.

llvm-svn: 67564
2009-03-23 21:50:40 +00:00
Anders Carlsson 6a07775423 Add SemaTypeInstantiateDecl.cpp
llvm-svn: 67559
2009-03-23 20:47:43 +00:00
Ted Kremenek 673a4eef07 Update checker build.
llvm-svn: 67553
2009-03-23 19:53:30 +00:00
Daniel Dunbar ee4d1feb44 Driver: Fix off by one in computation of first searchable option.
llvm-svn: 67552
2009-03-23 19:19:19 +00:00
Fariborz Jahanian aedcfa49b9 Must allow for strong cast of floats as well (objc2 gc).
llvm-svn: 67551
2009-03-23 19:10:40 +00:00
Anders Carlsson eb0c532faa More improvements to abstract type checking. Handle arrays correctly, and make sure to check parameter types before they decay.
llvm-svn: 67550
2009-03-23 19:10:31 +00:00
Daniel Dunbar 1773177a99 Driver: Add two special groups of "whitelisted" options which we know
clang doesn't support, and don't want to warn are unused. Eventually
these should disappear.

Here is a more readable list than is in the diff:

W options: -Wall, -Wcast-align, -Wchar-align, -Wchar-subscripts,
-Werror, -Wextra, -Winline, -Wint-to-pointer-cast, -Wmissing-braces,
-Wmost, -Wnested-externs, -Wno-format-y2k, -Wno-four-char-constants,
-Wno-missing-field-initializers, -Wno-trigraphs, -Wno-unknown-pragmas,
-Wno-unused-parameter, -Wparentheses, -Wpointer-arith,
-Wpointer-to-int-cast, -Wreturn-type, -Wshorten-64-to-32, -Wswitch,
-Wunused-function, -Wunused-label, -Wunused-value, -Wunused-variable,
-Wwrite-strings.

f options: -fasm-blocks, -fmessage-length=.

llvm-svn: 67549
2009-03-23 19:03:36 +00:00
Daniel Dunbar 453d79a2db Driver: Check that options are ordered properly (outside of
Release-Asserts mode).

Also, avoid searching through option groups (which will never match).

llvm-svn: 67548
2009-03-23 18:41:45 +00:00
Chris Lattner 656711a36b use isa<>
llvm-svn: 67543
2009-03-23 17:57:53 +00:00
Anders Carlsson 0d5ca29b78 It's an error to try to allocate an abstract object using new.
llvm-svn: 67542
2009-03-23 17:49:10 +00:00
Douglas Gregor 893c2c963a Fix PR3855. When we encounter an incompatible redeclaration of a
library function, accept this declaration and pretend that we do not
know that this is a library function. autoconf depends on this
(broken) behavior.

llvm-svn: 67541
2009-03-23 17:47:24 +00:00
Chris Lattner 5030e5eabe The individual pieces of an invalid paste as still candidates for expansion.
This matters in assembler mode, where this is silently allowed.
This fixes rdar://6709206.

llvm-svn: 67539
2009-03-23 17:32:45 +00:00
Ted Kremenek b294d196b3 analyzer: Provide temporary workaround for false positive reported by
<rdar://problem/6704930> involving SimpleConstraintManager not reasoning well
about symbolic constraint values involving arithmetic operators.

llvm-svn: 67534
2009-03-23 17:10:25 +00:00
Douglas Gregor d6b05f705b Tighten up the determination of whether a function declaration has a
prototype. Thanks Eli!

llvm-svn: 67533
2009-03-23 16:26:51 +00:00
Chris Lattner 6ad3bc2e7f if the driver decides to run clang on a .s file, treat it as a .S file.
llvm-svn: 67532
2009-03-23 16:24:37 +00:00
Douglas Gregor d4eca014e0 Thanks to Eli for pointing out my misreading of 6.2.2p5
llvm-svn: 67530
2009-03-23 16:17:01 +00:00
Daniel Dunbar 76ce7416ae Driver: Setup file and program search paths in tool chains.
llvm-svn: 67529
2009-03-23 16:15:50 +00:00
Daniel Dunbar c53305fd42 Ad FreeBSD ARM target info.
- Patch by Ed Schoeten!

llvm-svn: 67527
2009-03-23 16:09:04 +00:00
Ted Kremenek c7fef2ad53 analyzer: Fix embarrassing regression in BasicStore when invalidating struct
values passed-by-reference to unknown functions.

llvm-svn: 67519
2009-03-23 15:42:58 +00:00
Daniel Dunbar fefce128c5 ccc: Forward -f[no-]builtin to clang.
llvm-svn: 67517
2009-03-23 14:57:31 +00:00
Eli Friedman 449fe54cff Minor Evaluate cleanup; add some boilerplate implementations to
Evaluate for __extension__ and __builtin_choose_expr.

llvm-svn: 67506
2009-03-23 04:56:01 +00:00
Eli Friedman 6400433980 Minor enhancements to Evaluate.
llvm-svn: 67503
2009-03-23 04:38:34 +00:00
Eli Friedman 31a20d680a Some minor fixes for complex IRGen.
llvm-svn: 67501
2009-03-23 04:08:46 +00:00
Eli Friedman 7b4716750b Fix a subtle bug in CodeGen for the increment of a bitfield.
llvm-svn: 67499
2009-03-23 03:00:06 +00:00
Ted Kremenek 43e2deee22 Update checker build.
llvm-svn: 67498
2009-03-23 02:00:36 +00:00
Eli Friedman ba961a920a Add some FIXMEs relating to incomplete types.
llvm-svn: 67497
2009-03-23 00:24:07 +00:00
Eli Friedman 04841eebcb Fix a few more instances of "&>".
llvm-svn: 67496
2009-03-23 00:04:01 +00:00
Sebastian Redl 3b27be6ceb Recognize rvalue references in C++03, but complain about them. This leads to far better error recovery.
llvm-svn: 67495
2009-03-23 00:00:23 +00:00
Eli Friedman 80160bd483 Partial implementation of PR3342: break out pointer sign
incompatibilities in assignments from other pointer incompatibilities.  
Based off of the patch in PR3342.  (This doesn't implement -Wno-pointer-sign,
but I don't know the driver code very well.)

llvm-svn: 67494
2009-03-22 23:59:44 +00:00
Daniel Dunbar a0c89be9cc Driver: Drop code for checking bounds in SeparateArg::render, this
situation should never occur now that arguments are parsed correctly.

llvm-svn: 67493
2009-03-22 23:50:14 +00:00