Commit Graph

13622 Commits

Author SHA1 Message Date
Eli Friedman 8246b6f889 PR4290: Handle vfprintf in a way that doesn't give any diagnostics for
valid declarations and doesn't give an error for autoconf-style invalid 
redeclarations.  This isn't quite ideal, but I don't see any other way 
easy way to handle it.  (The only thing I can think of that's reasonably 
general is adding a new builtin type FILETy which is only compatible 
with a type equivalent to FILE, and that seems like overkill.)

llvm-svn: 72760
2009-06-03 09:54:50 +00:00
Zhongxing Xu b027cdfb6f emit ORIGINAL_FILE_NAME record ID to blockinfo block.
llvm-svn: 72759
2009-06-03 09:23:28 +00:00
Argyrios Kyrtzidis b1d51aa18a Use "()" instead of "(void)" when pretty-printing a parameter-less function type for C++.
llvm-svn: 72747
2009-06-03 02:06:50 +00:00
Douglas Gregor f727bb18d9 More PCH documentation
llvm-svn: 72743
2009-06-02 22:08:07 +00:00
Daniel Dunbar 4b665ebb01 Add clang-cc support for -disable-llvm-optzns.
- Avoids running any LLVM optimizations, even at -O2, etc., while still keeping
   any language changes these optimizations imply.

llvm-svn: 72742
2009-06-02 22:07:45 +00:00
Fariborz Jahanian 991a2b1933 Diagnose misuse of __strong attribute in a redeclaration.
llvm-svn: 72737
2009-06-02 20:58:58 +00:00
Fariborz Jahanian 6ab4375f87 Issue diagnostics on __weak attribute mismatch.
Fixes an error recovery issue which caused a crash.

llvm-svn: 72733
2009-06-02 18:32:00 +00:00
Eli Friedman 47b8a8d522 Missing file for __builtin_unwind_init support.
llvm-svn: 72728
2009-06-02 09:39:16 +00:00
Eli Friedman cb9d07caeb Add support for __builtin_unwind_init.
Also, committing an #if 0'ed __builtin_setjmp and __builtin_longjmp 
implementation I've had sitting in my tree for a while.  I haven't 
enabled it because the LLVM backend support isn't complete yet.

llvm-svn: 72727
2009-06-02 09:37:50 +00:00
Eli Friedman 9baa191f31 PR4142: Add %m format string specifier.
llvm-svn: 72726
2009-06-02 08:36:19 +00:00
Eli Friedman 164da6618e A couple minor corrections to the "GCC extensions not implemented yet"
section of the users manual.

llvm-svn: 72725
2009-06-02 08:21:31 +00:00
Eli Friedman fd80b2af16 PR4288: Make -dD (dump macros with preprocessed source) play nicely with
# line directives.

llvm-svn: 72724
2009-06-02 07:55:39 +00:00
Eli Friedman 5aa28de4fe Fix a silly typo in my previous objc_gc merging patch.
llvm-svn: 72723
2009-06-02 07:45:37 +00:00
Eli Friedman f6bd15038c If we recognize alloca, treat it as a builtin. This fixes uses of
alloca without declaring it.

llvm-svn: 72719
2009-06-02 07:10:30 +00:00
Eli Friedman cb8302ee3e Add builtin declarations for the variants of sin and cos.
llvm-svn: 72718
2009-06-02 07:06:02 +00:00
Eli Friedman f83c258eae Add aliases for a couple of SSE intrinsics. Patch by Ed Schouten.
llvm-svn: 72717
2009-06-02 05:55:48 +00:00
Eli Friedman 28d85c0803 Add --shared option.
llvm-svn: 72716
2009-06-02 05:46:32 +00:00
Eli Friedman 091a9ac014 Cleaned-up version of gc attribute type merging. I still don't like it
very much, but I have a feeling we're never going to have an 
implementation that makes sense because of compatibility issues.

llvm-svn: 72715
2009-06-02 05:28:56 +00:00
Eli Friedman 179f2b9ec7 Remove test which doesn't pass with gcc.
llvm-svn: 72714
2009-06-02 05:24:36 +00:00
Sanjiv Gupta 7c72007e2a Add floating point details to PIC16 Target.
llvm-svn: 72713
2009-06-02 04:43:46 +00:00
Fariborz Jahanian 2d725b19da This patch attempts to fix the merging of __strong/__weak attributes
in merge_types. It is incomplete. We probably want to issue 
a warning if user attempts to change the attribute from __weak to
__strong or vice-vera. It also assumes that a __weak/__strong
attribute can not be specified with other (currently one) type
attriute. 

llvm-svn: 72711
2009-06-02 01:40:22 +00:00
Daniel Dunbar 3acbe4ab58 Fix rare failure of .ver-svn creation, it has a dependency that the output
directory exist.

llvm-svn: 72704
2009-06-01 22:15:35 +00:00
Fariborz Jahanian c6d9800564 A corner case of objc2 gc's write-barrier generation
for the Next runtime.

llvm-svn: 72703
2009-06-01 21:29:32 +00:00
Fariborz Jahanian bc60ee2215 Fixed a test case which I am to blame for making it
not runaable.

llvm-svn: 72695
2009-06-01 17:40:54 +00:00
Daniel Dunbar 7614192d03 Update test case.
llvm-svn: 72694
2009-06-01 17:27:37 +00:00
Anders Carlsson a8decaa7c2 Fix a bug in hasEmptyExceptionSpec. (Thanks Sebastian for noticing).
llvm-svn: 72691
2009-06-01 15:02:12 +00:00
Eli Friedman e32c02114f PR4289: Make sure "&func" has the right LLVM type when "func" is a
K&R-style definition.

llvm-svn: 72690
2009-06-01 10:04:20 +00:00
Eli Friedman fcbf7d2baf PR4287: allow a variadic prototype to make a subsequent K&R style
definition variadic.  I'm not completely sure it's legal, but the 
standard can be interpreted as making it legal, and gcc seems to think 
it's legal, so I didn't add an extension warning.

llvm-svn: 72689
2009-06-01 09:24:59 +00:00
Eli Friedman 202a68a917 Simplify run line.
llvm-svn: 72687
2009-06-01 08:55:08 +00:00
Eli Friedman d8cec57b9d PR4283: Don't truncate multibyte character constants in the
preprocessor.

llvm-svn: 72686
2009-06-01 05:25:02 +00:00
Eli Friedman dcca6333c6 Disable type merging with gc attributes. This has a number of nasty
properties at the moment:

1. It allows stuff like "__strong id x; __weak id x;".

2. For constructs like "__strong id x; id x;", subsequent references to 
x lose the objc_gc attribute.

3. This incorrectly allows merges involving the address_space attribute.

4. Constructs like "id x; /* some code using x */ __weak id x;" don't 
apply the objc_gc attribute consistently to all uses of x.

The first three can probably be fixed relatively easily; the fourth 
would be extremely difficult to fix.

llvm-svn: 72683
2009-06-01 01:22:52 +00:00
Zhongxing Xu 84a1af5206 Unify coding style.
llvm-svn: 72682
2009-06-01 00:50:23 +00:00
Zhongxing Xu dccbf28dda Use a reference to modify the DeclIDs map.
llvm-svn: 72681
2009-06-01 00:49:11 +00:00
Anders Carlsson 6f6f6005ab After spending 15 minutes trying to figure out why this was crashing, I realized it was a bug in the test case :)
llvm-svn: 72680
2009-06-01 00:40:08 +00:00
Anders Carlsson fa7c608ecc Fix a thinko.
llvm-svn: 72679
2009-06-01 00:26:14 +00:00
Anders Carlsson ca50119a31 Check for null correctly for new expressions.
llvm-svn: 72678
2009-06-01 00:05:16 +00:00
Anders Carlsson cba81fc4de Improve irgen of 'new' further.
llvm-svn: 72677
2009-05-31 21:53:59 +00:00
Anders Carlsson 96c012ff8b ...and aggregate POD types.
llvm-svn: 72676
2009-05-31 21:12:26 +00:00
Anders Carlsson 60d0c2c1c2 Support for complex types.
llvm-svn: 72675
2009-05-31 21:07:58 +00:00
Anders Carlsson ec71f61608 Better support for scalar POD types in 'new' expressions.
llvm-svn: 72674
2009-05-31 20:56:36 +00:00
Anders Carlsson 6f9dabff6d Make sure to copy back arguments that can be changed by FindAllocationOverload. This fixes placement new. (Sebastian, please review).
llvm-svn: 72673
2009-05-31 20:26:12 +00:00
Anders Carlsson 1832f52b10 Very basic irgen support for new expressions.
llvm-svn: 72672
2009-05-31 20:21:44 +00:00
Anders Carlsson 0955f20473 Don't try to call getFileCharacteristic if the function declaration has an invalid source location (as is the case for the global allocation functions.
llvm-svn: 72671
2009-05-31 20:19:23 +00:00
Anders Carlsson 2418712039 Fix an off by one error when trying to perform copy initialization of operator new and operator delete arguments. Sebastian, please review.
llvm-svn: 72670
2009-05-31 19:49:47 +00:00
Chris Lattner 6e127a6d86 Downgrade an error about "return in a no-return function" from being
an error to being a warning that defaults to error.  If you want this to
be a warning, you have to explicitly pass -Winvalid-noreturn to clang to
map it back to a warning.

llvm-svn: 72669
2009-05-31 19:32:13 +00:00
Sebastian Redl fb3f1794e1 Disallow exception specs on typedefs.
llvm-svn: 72664
2009-05-31 11:47:27 +00:00
Eli Friedman 42a8465518 Fix for PR4285: allow intializing a const wchar_t array with a wide
string.

llvm-svn: 72663
2009-05-31 10:54:53 +00:00
Douglas Gregor 2373c599b5 Initial infrastructure for class template partial specialization. Here
we have the basics of declaring and storing class template partial
specializations, matching class template partial specializations at
instantiation time via (limited) template argument deduction, and
using the class template partial specialization's pattern for
instantiation. 

This patch is enough to make a simple is_pointer type trait work, but
not much else.

llvm-svn: 72662
2009-05-31 09:31:02 +00:00
Douglas Gregor 7a1a7cb09d Add a little FIXME for C++ class printing
llvm-svn: 72660
2009-05-31 07:13:39 +00:00
Duncan Sands 6674a492c4 Unbreak the clang build by applying the same temporary
workaround for machine code emitter changes as was used
in llvm-gcc.

llvm-svn: 72657
2009-05-31 04:09:57 +00:00
Anders Carlsson 4a7b49b56a Add a new function for emitting new functions.
llvm-svn: 72656
2009-05-31 01:40:14 +00:00
Anders Carlsson 8eb93e72f7 Emit destructors correctly for temporaries.
llvm-svn: 72655
2009-05-31 00:34:10 +00:00
Anders Carlsson f3f91cee43 When possible, don't emit the cleanup block. Instead, just move the instructions to the current block.
llvm-svn: 72654
2009-05-31 00:33:20 +00:00
Anders Carlsson c0092ad333 Implement VisitCXXExprWithTemporaries for complex expressions.
llvm-svn: 72653
2009-05-31 00:12:05 +00:00
Anders Carlsson 2262b307aa Call EmitCXXExprWithTemporaries.
llvm-svn: 72652
2009-05-31 00:09:15 +00:00
Anders Carlsson 89391a9272 Add more getters to the new AST nodes.
llvm-svn: 72651
2009-05-31 00:08:52 +00:00
Anders Carlsson fd2af0cf86 Add lvalue irgen support for CXXBindTemporaryExpr.
llvm-svn: 72649
2009-05-30 23:30:54 +00:00
Anders Carlsson 3be22e27b6 More temporary support.
llvm-svn: 72648
2009-05-30 23:23:33 +00:00
Anders Carlsson feefce601f Forgot the implementation. Thanks Eli.
llvm-svn: 72647
2009-05-30 22:51:20 +00:00
Anders Carlsson 777711ba0b Add RemoveOutermostTemporaryBinding. Not used yet.
llvm-svn: 72644
2009-05-30 22:47:03 +00:00
Anders Carlsson 73b836bf3d Clean up the newly added C++ AST nodes.
llvm-svn: 72643
2009-05-30 22:38:53 +00:00
Anders Carlsson a524f6fce6 It's OK for a full expr to be null. This fixes the failing test cases.
llvm-svn: 72642
2009-05-30 22:24:16 +00:00
Anders Carlsson 5de832ecfa ActOnReturnStmt should also take a FullExprArg.
llvm-svn: 72641
2009-05-30 21:42:34 +00:00
Anders Carlsson 5e9444f541 AddInitializerToDecl needs to take a full expression.
llvm-svn: 72640
2009-05-30 21:37:25 +00:00
Anders Carlsson f8e916de85 Update Xcode project
llvm-svn: 72639
2009-05-30 21:32:24 +00:00
Anders Carlsson c78576e250 Add the newly created temporary to the ExprTemporaries stack.
llvm-svn: 72638
2009-05-30 21:21:49 +00:00
Anders Carlsson 4f44fd5c6f Get rid of CXXTempVarDecl.
llvm-svn: 72637
2009-05-30 21:10:34 +00:00
Eli Friedman f7f9f68722 Some small fixes for fields of reference type.
llvm-svn: 72636
2009-05-30 21:09:44 +00:00
Anders Carlsson a29ded9ba8 Stop using CXXTempVarDecl and use CXXTemporary instead.
llvm-svn: 72634
2009-05-30 21:05:25 +00:00
Anders Carlsson 4b2434da54 Remove VarDecl from CXXConstructExpr.
llvm-svn: 72633
2009-05-30 20:56:46 +00:00
Anders Carlsson b228818554 Bind temporaries correctly when instantiating expressions.
llvm-svn: 72632
2009-05-30 20:52:37 +00:00
Anders Carlsson 28486d420b Remove VarDecl from CheckInitializerTypes now that CXXConstructExpr doesn't need to take a VarDecl anymore. (It still does, but it won't for long)
llvm-svn: 72630
2009-05-30 20:41:30 +00:00
Anders Carlsson 2d4cada7f7 Add Sema::MaybeBindToTemporary which takes an expression and (if needed) wraps it in a CXXBindTemporaryExpr. Use this when creating CXXTemporaryObjectExprs.
llvm-svn: 72629
2009-05-30 20:36:53 +00:00
Anders Carlsson ffda606612 Small fixes to CXXTemporary and CXXBindTemporaryExpr.
llvm-svn: 72628
2009-05-30 20:34:37 +00:00
Anders Carlsson 993a4b3080 Add a CXXBindTemporaryExpr.
llvm-svn: 72627
2009-05-30 20:03:25 +00:00
Anders Carlsson f337d8c515 Add a CXXTemporary class. Not used yet.
llvm-svn: 72626
2009-05-30 19:54:15 +00:00
Anders Carlsson 36b75a4619 Replace a cast with a dyn_cast as suggested by Doug.
llvm-svn: 72624
2009-05-30 17:26:39 +00:00
Mike Stump b807c9c622 Cleqnup ideas from Chris, thanks.
llvm-svn: 72621
2009-05-30 14:43:18 +00:00
Douglas Gregor 5f478b78c0 AST printing for C++ base classes
llvm-svn: 72617
2009-05-30 06:58:37 +00:00
Douglas Gregor 182319375a Pretty printing and improved representation for namespace alias declarations
llvm-svn: 72616
2009-05-30 06:48:27 +00:00
Eli Friedman 1730424516 Add a hack to prevent us from printing out the __builtin_va_list
declaration in -ast-print mode.

llvm-svn: 72615
2009-05-30 06:35:22 +00:00
Douglas Gregor 3bc6e4c72a Printing for using directives, e.g.,
using namespace std::debug;

Extended UsingDirectiveDecl to store the nested-name-specifier that
precedes the nominated namespace.

llvm-svn: 72614
2009-05-30 06:31:56 +00:00
Douglas Gregor 2d042f1cf4 Never suppress specifiers when printing the parameters of a function
declaration.

llvm-svn: 72613
2009-05-30 05:39:39 +00:00
Eli Friedman c4fc839c57 Pass an ASTContext into Stmt::printPretty.
llvm-svn: 72612
2009-05-30 05:32:46 +00:00
Eli Friedman 0905f14e62 Pass an ASTContext into Stmt::printPretty.
llvm-svn: 72611
2009-05-30 05:19:26 +00:00
Eli Friedman ef334fdfa2 Add a Stmt::printPretty overload which takes an ASTContext; start
transitioning callers over to pass one in.

llvm-svn: 72609
2009-05-30 05:03:24 +00:00
Eli Friedman 796358498f Expose an API to print a group of decls (like "int a,b;").
Make StmtPrinter use DeclPrinter to print all declarations.  Merge 
declarations in the limited case of an unnamed TagDecl followed by one 
or more declarations using that TagDecl directly.  Change
SuppressTypeSpecifiers to the more general SuppressSpecifiers, and 
use it to suppress stuff like "typedef" and "extern".  Replace 
OwnedTag with SuppressTag, since it's more convenient to print 
declarations from DeclPrinter at the moment.  
improvements to declaration printing.  Fix pretty-printing for K&R 
function definitions and __builtin_va_arg.

We're now to the point where the pretty-printing output for non-trivial 
programs can actually be piped back into clang.

llvm-svn: 72608
2009-05-30 04:20:30 +00:00
Mike Stump 2346cd2a10 Improve __builtin_nanf support; we now can deal with them as constants.
llvm-svn: 72607
2009-05-30 03:56:50 +00:00
Eli Friedman 258ffef5b5 Fix some test failures involving -ast-print.
llvm-svn: 72605
2009-05-30 01:45:29 +00:00
Douglas Gregor 36098ff480 Clean up printing for Objective-C, designated initializers.
llvm-svn: 72602
2009-05-30 00:56:08 +00:00
Anders Carlsson 65d5820892 Add a member lookup criteria constructor for searching for overridden virtual member functions. Use this instead of regular name lookup when checking for overriding functions so we will see declarations that would otherwise be hidden. Fixes 6902298.
llvm-svn: 72601
2009-05-30 00:52:53 +00:00
Eli Friedman 15ea880358 Some enhancements to DeclStmt printing. Some of this should
move to DeclPrinter.cpp, but I haven't quite worked out how best to do 
that.

llvm-svn: 72599
2009-05-30 00:19:54 +00:00
Eli Friedman d5ef49ff54 Add support for PrintingPolicy::SuppressTypeSpecifiers to type printing.
(I have a work-in-progress patch which uses this.)

llvm-svn: 72598
2009-05-30 00:10:16 +00:00
Douglas Gregor 278f52ec29 Refactor and clean up the AST printer, so that it uses a DeclVisitor,
walks through DeclContexts properly, and prints more of the
information available in the AST. The functionality is still available
via -ast-print, -ast-dump, etc., and also via the new member functions
Decl::dump() and Decl::print().

llvm-svn: 72597
2009-05-30 00:08:05 +00:00
Anders Carlsson 01bcef4a17 Make the LookupBase boolean an enum instead.
llvm-svn: 72594
2009-05-29 23:42:05 +00:00
Anders Carlsson 0a63741a3f Add code for emitting C++ destructors. Not used yet.
llvm-svn: 72591
2009-05-29 21:03:38 +00:00
Douglas Gregor 7de5966d76 Create a new PrintingPolicy class, which we pass down through the AST
printing logic to help customize the output. For now, we use this
rather than a special flag to suppress the "struct" when printing
"struct X" and to print the Boolean type as "bool" in C++ but "_Bool"
in C.

llvm-svn: 72590
2009-05-29 20:38:28 +00:00
Eli Friedman bd32745978 Make sure we don't give the wrong warning, and make sure not to set
hadError (suppressing future diagnostics) if we didn't print an 
error.

llvm-svn: 72588
2009-05-29 20:20:05 +00:00
Eli Friedman be7e42b27f Add an assertion so that we don't accidentally build constant arrays of
VLAs.

llvm-svn: 72587
2009-05-29 20:17:55 +00:00
Eli Friedman 9444638e4e Re-add a slightly more general version of the check from r72578; it is
actually necessary in some obscure cases.

llvm-svn: 72585
2009-05-29 19:23:46 +00:00
Mike Stump a678874975 Oops, the testcase I was thinking of is supposed to error out. I
tried other things that might trip, but they all worked.

llvm-svn: 72584
2009-05-29 19:14:13 +00:00
Eli Friedman 20da71e3b6 Add a couple missing ARM defines.
llvm-svn: 72583
2009-05-29 19:00:15 +00:00
Douglas Gregor 6181ded4ad Reduce the amount of stack space we use in SmallVectors during
template instantiation. This helps reduce our stack footprint when
performing deep template instantiations.

llvm-svn: 72582
2009-05-29 18:27:38 +00:00
Eli Friedman 893abe482d Revert r72575, which isn't really right, and fix up other code to
handle the construct in question correctly.

llvm-svn: 72581
2009-05-29 18:22:49 +00:00
Sebastian Redl d643456d45 Reject incomplete types in exception specs.
llvm-svn: 72580
2009-05-29 18:02:33 +00:00
Mike Stump 7f12d51a48 Fixup codegen for composition of vla types using a normal array type.
llvm-svn: 72578
2009-05-29 17:06:45 +00:00
Sebastian Redl eed0ec5fdb Fix usage of placement new. Placement new is not actually declared implicitly.
llvm-svn: 72576
2009-05-29 16:43:59 +00:00
Mike Stump fc30bf9b16 Avoid dumping during semantic analysis when checking array types when
a vla is used.

llvm-svn: 72575
2009-05-29 16:34:15 +00:00
Mike Stump de83126b80 We don't want to validate bad code,
llvm-svn: 72574
2009-05-29 16:24:13 +00:00
Mike Stump f9f89a3fee Note another case that doesn't work yet.
llvm-svn: 72573
2009-05-29 16:12:36 +00:00
Mike Stump df0fe27b66 Fixup the rest of the trivial cases of the codegen of volatile. If
any body can spot codegen bugs with volatile, or knows of any in the
bug database, let me know.

llvm-svn: 72572
2009-05-29 15:46:01 +00:00
Sebastian Redl 10b9de45c3 Disallow exception specifications on multi-level indirections.
llvm-svn: 72571
2009-05-29 15:01:05 +00:00
Douglas Gregor 82dbbd7054 Some cleanups and commenting to our declaration-name handling
llvm-svn: 72570
2009-05-29 14:49:33 +00:00
Douglas Gregor 0558094464 Follow-on test case for template instantiation of interesting DeclGroups
llvm-svn: 72569
2009-05-29 14:26:40 +00:00
Douglas Gregor 8157b07caf Now that we have declared/defined tag types within DeclGroups,
instantiation of tags local to member functions of class templates
(and, eventually, function templates) works when the tag is defined as
part of the decl-specifier-seq, e.g.,

  struct S { T x, y; } s1;

Also, make sure that we don't try to default-initialize a dependent
type.

llvm-svn: 72568
2009-05-29 14:25:00 +00:00
Eli Friedman 55b9ecbc7a If a declarator group declares a type, make sure to add that declaration
to the DeclGroup.

llvm-svn: 72559
2009-05-29 01:49:24 +00:00
Douglas Gregor d6ab8744dc When we parse a tag specifier, keep track of whether that tag
specifier resulted in the creation of a new TagDecl node, which
happens either when the tag specifier was a definition or when the tag
specifier was the first declaration of that tag type. This information
has several uses, the first of which is implemented in this commit:

  1) In C++, one is not allowed to define tag types within a type
  specifier (e.g., static_cast<struct S { int x; } *>(0) is
  ill-formed) or within the result or parameter types of a
  function. We now diagnose this.

  2) We can extend DeclGroups to contain information about any tags
  that are declared/defined within the declaration specifiers of a
  variable, e.g.,

    struct Point { int x, y, z; } p;

  This will help improve AST printing and template instantiation,
  among other things.

  3) For C99, we can keep track of whether a tag type is defined
  within the type of a parameter, to properly cope with cases like,
  e.g.,

    int bar(struct T2 { int x; } y) {
      struct T2 z;
    }

  We can also do similar things wherever there is a type specifier,
  e.g., to keep track of where the definition of S occurs in this
  legal C99 code:

    (struct S { int x, y; } *)0

  

llvm-svn: 72555
2009-05-28 23:31:59 +00:00
Eli Friedman 2a69547f38 PR4281: Fix bogus CodeGen assertion. The issue is that
getUnqualifiedType() doesn't strip off all qualifiers for non-canonical 
types.

llvm-svn: 72552
2009-05-28 23:04:00 +00:00
Eli Friedman 5d3a16f693 ARM is a legitimate Darwin architecture; don't assert.
llvm-svn: 72538
2009-05-28 20:57:06 +00:00
Douglas Gregor 019d3750cb Add the missing public: thanks, Fariborz
llvm-svn: 72528
2009-05-28 16:41:44 +00:00
Daniel Dunbar 044a702f2f Move clang-cc's -v output to the start (vs. end) of compilation, and change
clang -> clang-cc to be less confusing.

llvm-svn: 72527
2009-05-28 16:37:33 +00:00
Douglas Gregor 9e927abc41 Introduced DeclContext::isDependentContext, which determines whether a
given DeclContext is dependent on type parameters. Use this to
properly determine whether a TagDecl is dependent; previously, we were
missing the case where the TagDecl is a local class of a member
function of a class template (phew!).

Also, make sure that, when we instantiate declarations within a member
function of a class template (or a function template, eventually),
that we add those declarations to the "instantiated locals" map so
that they can be found when instantiating declaration references.

Unfortunately, I was not able to write a useful test for this change,
although the assert() that fires when uncommenting the FIXME'd line in
test/SemaTemplate/instantiate-declref.cpp tells the "experienced user"
that we're now doing the right thing.

llvm-svn: 72526
2009-05-28 16:34:51 +00:00
Chris Lattner 378d72cc40 update test for r72519
llvm-svn: 72520
2009-05-28 05:41:32 +00:00
Chris Lattner 7f4153dbee fix the "pasting formed 'a]', an invalid preprocessing token"
diagnostic to include the full instantiation location for the
invalid paste.  For:

#define foo(a, b)  a ## b
#define bar(x) foo(x, ])
bar(a)
bar(zdy)

Instead of:

t.c:3:22: error: pasting formed 'a]', an invalid preprocessing token
#define foo(a, b)  a ## b
                     ^
t.c:3:22: error: pasting formed 'zdy]', an invalid preprocessing token

we now produce:

t.c:7:1: error: pasting formed 'a]', an invalid preprocessing token
bar(a)
^
t.c:4:16: note: instantiated from:
#define bar(x) foo(x, ])
               ^
t.c:3:22: note: instantiated from:
#define foo(a, b)  a ## b
                     ^
t.c:8:1: error: pasting formed 'zdy]', an invalid preprocessing token
bar(zdy)
^
t.c:4:16: note: instantiated from:
#define bar(x) foo(x, ])
               ^
t.c:3:22: note: instantiated from:
#define foo(a, b)  a ## b
                     ^

llvm-svn: 72519
2009-05-28 05:39:39 +00:00
Mike Stump 01c2d0a17c Not setting all the fields is confusing...
llvm-svn: 72506
2009-05-28 00:16:27 +00:00
Daniel Dunbar 16f422ec86 Fix a use-of-undefined, IRgen expects the RValue for "void" to be a scalar RValue.
llvm-svn: 72504
2009-05-27 23:45:33 +00:00
Douglas Gregor 14f5c132c1 Add a target triple, because this test depends on details of the x86-64 ABI
llvm-svn: 72503
2009-05-27 23:32:34 +00:00
Douglas Gregor e44a2adf41 Reimplement much of the way that we track nested classes in the
parser. Rather than placing all of the delayed member function
declarations and inline definitions into a single bucket corresponding
to the top-level class, we instead mirror the nesting structure of the
nested classes and place the delayed member functions into their
appropriate place. Then, when we actually parse the delayed member
function declarations, set up the scope stack the same way as it was
when we originally saw the declaration, so that we can find, e.g.,
template parameters that are in scope.

llvm-svn: 72502
2009-05-27 23:11:45 +00:00
Eli Friedman b5f33c1634 A few tweaks to the "Differences between various standard modes"
section.

llvm-svn: 72501
2009-05-27 23:02:57 +00:00
Eli Friedman 259109f9df restrict is not a keyword in gnu89 mode. Change TokenKinds.def to
reflect that.

llvm-svn: 72500
2009-05-27 22:48:34 +00:00
Eli Friedman 98dbc1c79a Don't vary token concatenation based on the language options; this
behavior is more likely to be confusing than useful.

llvm-svn: 72499
2009-05-27 22:33:06 +00:00
Sebastian Redl 5068f77ac7 Reintroduce the home for exception specs, and make Sema fill it. However, keep the spec out of the canonical type this time. Net effect is currently nothing, because the spec isn't checked anywhere.
llvm-svn: 72498
2009-05-27 22:11:52 +00:00
Eli Friedman 54eb224c3b Make the bad paste diagnostic print the entire pasted token.
llvm-svn: 72497
2009-05-27 22:00:37 +00:00
Fariborz Jahanian 7c1baf46d6 No write-barrier for initializations.
llvm-svn: 72492
2009-05-27 19:54:11 +00:00
Fariborz Jahanian 7551257f00 Change a confusing variable name.
llvm-svn: 72491
2009-05-27 19:48:48 +00:00
Sebastian Redl a81b0b7ef5 Add a big test case for I-C-Es in C++, and a fix to make it work. The fix might not be the right way to do it.
llvm-svn: 72490
2009-05-27 19:34:06 +00:00
Sebastian Redl eed3d4c73e Fix the type of a enum non-type template argument within the instantiation.
llvm-svn: 72489
2009-05-27 19:21:29 +00:00
Douglas Gregor cd3a097925 Simplify, and improve the performance of, template instantiation for
declaration references. The key realization is that dependent Decls,
which actually require instantiation, can only refer to the current
instantiation or members thereof. And, since the current context
during instantiation contains all of those members of the current
instantiation, we can simply find the real instantiate that matches up
with the "current instantiation" template.

llvm-svn: 72486
2009-05-27 17:54:46 +00:00
Douglas Gregor b8006fafe8 Add some more tests for instantiation of declaration references. Also,
improve some error recovery with explicit template instantiation.

llvm-svn: 72484
2009-05-27 17:30:49 +00:00
Douglas Gregor 7a74938fca Enumeration declarations that were instantiated from an enumeration
within a template now have a link back to the enumeration from which
they were instantiated. This means that we can now find the
instantiation of an anonymous enumeration.

llvm-svn: 72482
2009-05-27 17:20:35 +00:00
Douglas Gregor f98d9b60db Improve name lookup for and template instantiation of declaration
references. There are several smallish fixes here:

  - Make sure we look through template parameter scope when
    determining whether we're parsing a nested class (or nested class
    *template*). This makes sure that we delay parsing the bodies of
    inline member functions until after we're out of the outermost
    class (template) scope.
  - Since the bodies of member functions are always parsed
    "out-of-line", even when they were declared in-line, teach
    unqualified name lookup to look into the (semantic) parents.
  - Use the new InstantiateDeclRef to handle the instantiation of a
    reference to a declaration (in DeclRefExpr), which drastically
    simplifies template instantiation for DeclRefExprs.
  - When we're instantiating a ParmVarDecl, it must be in the current
    instantiation scope, so only look there.

Also, remove the #if 0's and FIXME's from the dynarray example, which
now compiles and executes thanks to Anders and Eli.

llvm-svn: 72481
2009-05-27 17:07:49 +00:00
Anders Carlsson ddcbfe7b53 IRgen support for calls to functions that return references to aggregate exressions.
llvm-svn: 72479
2009-05-27 16:45:02 +00:00
Anders Carlsson 5063613a3b Fix another test case.
llvm-svn: 72478
2009-05-27 16:38:58 +00:00
Anders Carlsson d48a008b46 Relax an assert to an if check.
llvm-svn: 72477
2009-05-27 16:28:34 +00:00
Fariborz Jahanian a4872a411c Initialize ObjCSenderDispatch in LangOptions.
Patch by Benjamin Kramer.

llvm-svn: 72476
2009-05-27 16:27:50 +00:00
Steve Naroff 4fc95aa0d4 Convert ObjC qualified type clients over to using iterators.
This allows me to remove some API that I don't want to carry over to ObjCObjectPointerType.

No functionality change.

llvm-svn: 72475
2009-05-27 16:21:00 +00:00
Anders Carlsson 98cee2fde0 Create CXXConstructExprs when constructing via copy initialization.
llvm-svn: 72474
2009-05-27 16:10:08 +00:00
Eli Friedman 751aa72b72 Fix up constant expression handling to deal with the address
of a reference correctly.

llvm-svn: 72463
2009-05-27 06:04:58 +00:00
Eli Friedman 55422ad068 Add IRGen support for local variables of reference type.
llvm-svn: 72462
2009-05-27 05:39:06 +00:00
Douglas Gregor 5178331379 Initial stab at a generalized operation for determining the
instantiation of a declaration from the template version (or version
that lives in a template) and a given set of template arguments. This
needs much, much more testing, but it suffices for simple examples
like

  typedef T* iterator;
  iterator begin();

llvm-svn: 72461
2009-05-27 05:35:12 +00:00