Commit Graph

4802 Commits

Author SHA1 Message Date
Fariborz Jahanian ae01f78a31 When building candidate set for built-ins; when looking for
convesion functions, look in base classes to.
(Removes a FIXME).

llvm-svn: 83472
2009-10-07 17:26:09 +00:00
Douglas Gregor e4b05168f6 Class template partial specializations can be declared anywhere that
its definition may be defined, including in a class.

Also, put in an assertion when trying to instantiate a class template
partial specialization of a member template, which is not yet
implemented.

llvm-svn: 83469
2009-10-07 17:21:34 +00:00
Anders Carlsson 1e39bd944b Mangle anonymous structs/unions correctly. Fixes PR5139.
llvm-svn: 83448
2009-10-07 01:45:02 +00:00
Douglas Gregor fbe6d079e2 More testing of explicit specializations
llvm-svn: 83440
2009-10-07 00:45:53 +00:00
Ted Kremenek 3ea4ab8e79 Force a specific target triple in c-index-api-test.m, making the behavior of the test not be dependent on the host.
llvm-svn: 83438
2009-10-07 00:39:48 +00:00
Douglas Gregor 548886518d Refactor checking of the scope of explicit template specialization
declarations and explicit template instantiations, improving
diagnostics and making the code usable for function template
specializations (as well as class template specializations and partial
specializations). 

llvm-svn: 83436
2009-10-07 00:13:32 +00:00
Fariborz Jahanian 34d93dcddd Patch to implement C++ [over.built]p11 of overload resolution.
Doug, please review. There is a FIXME in the test case with a question
which is unrelated to this patch (that is, error is issued
before set of builtins are added to the candidate list).

llvm-svn: 83429
2009-10-06 23:08:05 +00:00
Anders Carlsson b703fd2216 Uncomment some commented out code.
llvm-svn: 83428
2009-10-06 23:02:00 +00:00
Mike Stump da6822f584 Add codegen for __builtin_abort. Convert to FileCheck.
llvm-svn: 83427
2009-10-06 22:58:45 +00:00
Anders Carlsson c6d171ec77 Change GetAddressCXXOfBaseClass to use CXXBasePaths for calculating base class offsets. Fix the code to handle virtual bases as well.
llvm-svn: 83426
2009-10-06 22:43:30 +00:00
Anders Carlsson 11d00cf972 When mangling names, always use the canonical decl. Fixes PR5144.
llvm-svn: 83420
2009-10-06 21:58:01 +00:00
Douglas Gregor 27c26e9a09 Test explicit specialization for all of the various cases where
explicit specializations can occur. Also, fix a minor recovery bug
where we should allow declarations coming from the parser to be NULL.

llvm-svn: 83416
2009-10-06 21:27:51 +00:00
Anders Carlsson 273cdf096c Fix test.
llvm-svn: 83398
2009-10-06 18:12:12 +00:00
Anders Carlsson 6b7378bbe1 Emit the destructor epilogue in a cleanup block so a return from a destructor body still calls the epilogue.
llvm-svn: 83397
2009-10-06 18:09:57 +00:00
Anders Carlsson 80ef6f1a46 Pass the right type to GetAddrOfFunction when getting functions for the VTable. Fixes PR5021.
llvm-svn: 83395
2009-10-06 17:54:23 +00:00
Ted Kremenek 2f935535b1 Fix crash introduced by r83358 where a symbol could be eagerly
evaluated to an APSInt with a different bitwidth than the other
operand in a binary expression.

llvm-svn: 83368
2009-10-06 03:44:49 +00:00
Ted Kremenek 8ec5771dcb Fix: <rdar://problem/7275774> Static analyzer warns about NULL pointer when
adding assert

This fix required a few changes:

SimpleSValuator:
- Eagerly replace a symbolic value with its constant value in EvalBinOpNN
  when it is constrained to a constant.  This allows us to better constant fold
  values along a path.
- Handle trivial case of '<', '>' comparison of pointers when the two pointers
  are exactly the same.

RegionStoreManager:

llvm-svn: 83358
2009-10-06 01:39:48 +00:00
Fariborz Jahanian 333bb733a5 Refixed pr5086 by letting Expr::isNullPointerConstant
handle checking for a null pointer for a zero-valued
enumerator; moving the test case from CodeGen to Sema.

llvm-svn: 83350
2009-10-06 00:09:31 +00:00
Mike Stump 3472ae5bac Ensure we have atleast 2-byte alignment for member functions.
llvm-svn: 83337
2009-10-05 22:49:20 +00:00
Mike Stump f6ab1f0a4d Testcase for recent checkin.
llvm-svn: 83330
2009-10-05 22:24:47 +00:00
Chris Lattner 78a2e6356b remove this test, grepping for define isn't really testing anything.
llvm-svn: 83325
2009-10-05 21:16:22 +00:00
Fariborz Jahanian 092cd6e624 Patch to implement Protocols on class extensions.
<rdar://problem/7269631> Protocols on class extensions don't work

llvm-svn: 83322
2009-10-05 20:41:32 +00:00
Steve Naroff d7eb7179a2 - Fix assert in clang_getCursorDecl (having to do with recently added ObjC_ProtocolRef).
- Make sure CHECK: lines in test case match the expected output. 

llvm-svn: 83316
2009-10-05 17:58:19 +00:00
Anders Carlsson 2ee3c011d9 Implement code generation of member function pointer calls. Fixes PR5121.
llvm-svn: 83271
2009-10-03 19:43:08 +00:00
Anders Carlsson de55f647ff Ignore No-op casts when evaluating lvalue expressions. Fixes PR5122.
llvm-svn: 83267
2009-10-03 16:30:22 +00:00
Anders Carlsson c46bf276e1 Teach AggExprEmitter about pointers to member functions.
llvm-svn: 83266
2009-10-03 15:43:24 +00:00
Anders Carlsson 3162e4945a Handle base-to-derived casts of member function pointers in CGExprConstant.cpp
llvm-svn: 83265
2009-10-03 15:13:22 +00:00
Anders Carlsson 128a5d5147 Handle members to function pointers in CGExprConstant.
llvm-svn: 83264
2009-10-03 15:02:02 +00:00
Anders Carlsson 6ad01742d5 Rewrite member function pointer test not to rely on -O2.
llvm-svn: 83262
2009-10-03 14:39:13 +00:00
Benjamin Kramer 80401b96c2 FileCheckize test case.
llvm-svn: 83244
2009-10-02 10:32:51 +00:00
Anders Carlsson 8a744ad8a6 Don't update the struct alignment when adding fields to a packed struct. Fixes PR5118.
llvm-svn: 83235
2009-10-02 04:52:12 +00:00
Anders Carlsson 39e3eb12ae When building constant structs, check if the resulting LLVM struct will be bigger than the record layout size and use a packed struct if that's the case. Fixes PR5108.
llvm-svn: 83230
2009-10-02 02:15:20 +00:00
Douglas Gregor f343fd8929 Make sure to free the explicit template arguments provided for an
explicit instantiation. Also, tighten up reference-count checking to
help catch these issues earlier. Fixes PR5069.

llvm-svn: 83225
2009-10-01 23:51:25 +00:00
Douglas Gregor 78b691a458 When the return type of a function is dependent, don't perform any
of the flow-control checks for falling off the end of a function,
since the return type may instantiate to void. Similarly, if a
return statement has an expression and the return type of the function
is void, don't complain if the expression is type-dependent, since
that type could instantiate to void.

Fixes PR5071.

llvm-svn: 83222
2009-10-01 23:25:31 +00:00
Fariborz Jahanian a0f91ad59c enumerator value of 0 is not a null pointer constant for
deciding const of null pointer conversion. Fixes PR5086.

llvm-svn: 83217
2009-10-01 22:10:15 +00:00
Douglas Gregor 369acf9304 CodeGen may see out-of-line declarations of the various special member
functions when they are explicitly declared, e.g., via a function
template specialization or explicit template instantiation
declaration. Don't try to synthesize bodies for the special member
functions in this case; rather, check whether we have an implicit
declaration and, if so, synthesize the appropriate function
body. Fixes PR5084.

llvm-svn: 83212
2009-10-01 20:44:19 +00:00
Fariborz Jahanian b3c44f9ee9 Patch to implement static casting which requires one
user-defined type conversion. Fixes PR5040.

llvm-svn: 83211
2009-10-01 20:39:51 +00:00
Ted Kremenek 5c22e110a1 Fix bad grammar in static analyzer diagnostic. Reported by Robert Purves!
llvm-svn: 83204
2009-10-01 17:31:50 +00:00
Douglas Gregor e364e7bc2b Fix a lame regression in IR gen for C++ delete expressions. PR5102
llvm-svn: 83195
2009-10-01 05:49:51 +00:00
Steve Naroff a6c56bb849 Add support for class and protocol references.
llvm-svn: 83186
2009-10-01 00:31:07 +00:00
John McCall 4fa5342758 Anonymous namespaces, sema + codegen. A lot of semantics are still broken,
apparently because using directives aren't quite working correctly.

llvm-svn: 83184
2009-10-01 00:25:31 +00:00
Douglas Gregor 42909754f6 Improve template argument deduction in the case where the parameter
type is a template-id (e.g., basic_ostream<CharT, Traits>) and the
argument type is a class that has a derived class matching the
parameter type. Previously, we were giving up on template argument
deduction too early.

llvm-svn: 83177
2009-09-30 22:13:51 +00:00
Douglas Gregor 66950a32d9 When overload resolution fails for an overloaded operator, show the
overload candidates (but not the built-in ones). We still rely on the
underlying built-in semantic analysis to produce the initial
diagnostic, then print the candidates following that diagnostic. 

One side advantage of this approach is that we can perform more validation
of C++'s operator overloading with built-in candidates vs. the
semantic analysis for those built-in operators: when there are no
viable candidates, we know to expect an error from the built-in
operator handling code. Otherwise, we are not modeling the built-in
semantics properly within operator overloading. This is checked as:

      assert(Result.isInvalid() && 
             "C++ binary operator overloading is missing
             candidates!");
      if (Result.isInvalid())
        PrintOverloadCandidates(CandidateSet, /*OnlyViable=*/false);

The assert() catches cases where we're wrong in a +Asserts build. The
"if" makes sure that, if this happens in a production clang
(-Asserts), we still build the proper built-in operator and continue
on our merry way. This is effectively what happened before this
change, but we've added the assert() to catch more flies.

llvm-svn: 83175
2009-09-30 21:46:01 +00:00
Douglas Gregor 3dc959f88b Tweak CHECK lines to eliminate a failure on i686-apple-darwin10
llvm-svn: 83173
2009-09-30 21:39:51 +00:00
Fariborz Jahanian db82308633 Issue good diagnostics when initializing a refernce type with
a bad initializer. Fixes pr4274.

llvm-svn: 83169
2009-09-30 21:23:30 +00:00
Tanya Lattner fd2dcba7f3 Add an error for function parameters that have a qualified address space since this is not allowed by the embedded c extension spec.
llvm-svn: 83165
2009-09-30 20:47:43 +00:00
Chris Lattner 24440102aa Convert from nonportable grep to filecheck, patch by John Thompson
llvm-svn: 83158
2009-09-30 19:55:07 +00:00
Fariborz Jahanian ac3005cecc Note location of operators caused the circularity.
llvm-svn: 83153
2009-09-30 17:46:20 +00:00
Fariborz Jahanian e01e434aef <rdar://problem/7263113> Make clang produce gcc's objc_assign_StrongCast as a result of type-cast of an ivar in assignment.
llvm-svn: 83150
2009-09-30 17:10:29 +00:00
John McCall c1538c08d7 Detect operator-> chains of arbitrary length. Use a terrible data structure
to strike fear into the hearts of CPUs everywhere.

llvm-svn: 83133
2009-09-30 01:01:30 +00:00
Fariborz Jahanian 10ce958550 self-referecing operator '->' member function was causing
infinit recursion. This patch fixes it. [13.3.1.2]-p2

llvm-svn: 83124
2009-09-30 00:19:41 +00:00
Douglas Gregor 80a6cc5800 Find operators new/delete in base classes. FIXME -= 2;
llvm-svn: 83119
2009-09-30 00:03:47 +00:00
Douglas Gregor 98496dc3eb The C++ delete expression strips cv-qualifiers from the pointed-to type. My previous fix eliminated this behavior, so bring it back again.
llvm-svn: 83113
2009-09-29 21:38:53 +00:00
Fariborz Jahanian 3a36ab08b7 13.1-p3 Overloadable declarations
Parameter declarations that differ only in the presence or absence of const and/or volatile are equivalent.

llvm-svn: 83104
2009-09-29 20:28:06 +00:00
Argyrios Kyrtzidis 4cbe85904c Modify ASTLocation and apart from being a Decl or Stmt, allow it to also be:
-A NamedDecl reference
-A TypeLoc

llvm-svn: 83095
2009-09-29 19:44:27 +00:00
Daniel Dunbar d71a03b164 Fix truck sized thinko where Darwin/ARM toolchain didn't look for programs in
libexec, *blush*.

llvm-svn: 83086
2009-09-29 18:52:10 +00:00
Daniel Dunbar 88f2300d19 Add a test case demonstrating a situation where we get protocol type checking
right for multiple anonymous categories.

llvm-svn: 83085
2009-09-29 18:51:43 +00:00
Douglas Gregor bb3e12fc0b Handle C++ delete expressions when the overloaded delete operator is a
"usual deallocation function" with two arguments. CodeGen will have to
handle this case specifically, since the value for the second argument
(the size of the allocated object) may have to be computed at run
time.

Fixes the Sema part of PR4782.

llvm-svn: 83080
2009-09-29 18:16:17 +00:00
Ted Kremenek 228539f015 Fix: <rdar://problem/7261075> [RegionStore] crash when handling load: '*((unsigned int *)"????")'
This issue was originally reported via personal email by Thomas Clement!

llvm-svn: 83069
2009-09-29 16:36:48 +00:00
Douglas Gregor 6b603c9ec5 Allow the PYTHON make variable to override the default Python when running Clang tests, from Ken Dyck.
llvm-svn: 83065
2009-09-29 14:54:28 +00:00
Douglas Gregor a49cb4e494 Slightly improve the semantics of extern templates for member functions of class templates
llvm-svn: 83063
2009-09-29 14:38:03 +00:00
Ted Kremenek cc22424c87 Fix really insidious bug in RegionStoreManager::RemoveDeadBindings()
identified with a false positive reported by Thomas Clement.  This
involved doing another rewrite of
RegionStoreManager::RemoveDeadBindings(), which phrases the entire
problem of scanning for dead regions as a graph exploration problem.
It is more methodic than the previous implementation.

llvm-svn: 83053
2009-09-29 06:35:00 +00:00
Anders Carlsson 025893300c Remove PR5061 workaround.
llvm-svn: 83046
2009-09-29 05:36:21 +00:00
Anders Carlsson 8f4fd60c47 Handle CXXMemberCallExprs that point to a static method. Fixes PR5093.
llvm-svn: 83045
2009-09-29 03:54:11 +00:00
Anders Carlsson 33c6a7a12e Forgot test.
llvm-svn: 83044
2009-09-29 03:38:56 +00:00
Ted Kremenek 5daec8a834 Reapply most of r82939, but add a guard that FieldRegions and friends
are only specially treated by RegionStore::InvalidateRegion() when
their super region is also invalidated.  When this isn't the case,
conjure a new symbol for a FieldRegion.  Thanks to Zhongxing Xu and
Daniel Dunbar for pointing out this issue.

llvm-svn: 83043
2009-09-29 03:34:03 +00:00
Mike Stump e7a2b48572 Fix http://llvm.org/PR5090.
llvm-svn: 83035
2009-09-29 00:50:50 +00:00
Ted Kremenek 196d2a0095 Remove test case's dependency on platform headers.
llvm-svn: 83030
2009-09-28 23:54:40 +00:00
Douglas Gregor 56fbc37bbb Provide a custom diagnostic when code tries to use an unknown builtin
llvm-svn: 83014
2009-09-28 21:14:19 +00:00
Fariborz Jahanian c9c3917a86 Multiple conversions to the same type are ambiguous but for the
purpose of overload resolution is to be treated as a uner-defined
conversion.

llvm-svn: 83004
2009-09-28 19:06:58 +00:00
Douglas Gregor 5ad7c54bb9 Make sure that out-of-line function and variable definitions are not
pushed into scope. Fixes PR5056.

llvm-svn: 83003
2009-09-28 18:41:37 +00:00
Fariborz Jahanian 774cf79987 Patch for AST representation for the implicit conversion to a function
reference/pointer. And a test case for code gen.

llvm-svn: 83000
2009-09-28 18:35:46 +00:00
Douglas Gregor c5790dfeb4 Parse a C++ scope specifier followed by a "typename" annotation token as a type name within the declaration specifiers. Fixes PR5061.
llvm-svn: 82974
2009-09-28 07:26:33 +00:00
Douglas Gregor e6688e653f Determinism is for wimps. <Wimper>
llvm-svn: 82962
2009-09-28 03:51:44 +00:00
Douglas Gregor 505ad49a09 Teach Sema::isDeclInScope to handle overload sets constructed from
functions that occur in multiple declaration contexts, e.g., because
some were found via using declarations. Now, isDeclInScope will build
a new overload set (when needed) containing only those declarations
that are actually in scope. This eliminates a problem found with
libstdc++'s <iostream>, where the presence of using 

In the longer term, I'd like to eliminate Sema::isDeclInScope in favor
of better handling of the RedeclarationOnly flag in the name-lookup
routines. That way, name lookup only returns the entities that matter,
rather than taking the current two-pass approach of producing too many
results and then filtering our the wrong results. It's not efficient,
and I'm sure that we aren't filtering everywhere we should be.

llvm-svn: 82954
2009-09-28 00:47:05 +00:00
Douglas Gregor a29a3ffd18 Improve handling of friend function templates somewhat
llvm-svn: 82950
2009-09-28 00:08:27 +00:00
Ted Kremenek e41b81e9ab Fix:
<rdar://problem/6914474> checker doesn't realize that variable might
have been assigned if a pointer to that variable was passed to another
function via a structure

The problem here was the RegionStoreManager::InvalidateRegion didn't
invalidate the bindings of invalidated regions.  This required a
rewrite of this method using a worklist.

As part of this fix, changed ValueManager::getConjuredSymbolVal() to
require a 'void*' SymbolTag argument.  This tag is used to
differentiate two different symbols created at the same location.

llvm-svn: 82920
2009-09-27 20:45:21 +00:00
Anders Carlsson 02bca738b4 Mangle dependent name expressions. Fixes PR5063.
llvm-svn: 82915
2009-09-27 20:11:34 +00:00
Anders Carlsson d122de5f32 Use mangleTemplatePrefix when we know that we're mangling a nested template name.
llvm-svn: 82912
2009-09-27 19:53:49 +00:00
Anders Carlsson 9bf787ad1f Look for substitutions when mangling TypenameTypes.
llvm-svn: 82885
2009-09-27 01:06:07 +00:00
Anders Carlsson e00745b285 Better template parameter type mangling.
llvm-svn: 82883
2009-09-27 00:38:53 +00:00
Anders Carlsson 2e5935241a Mangle std::basic_string<char, std::char_traits<char>, std::allocator<char> > as Ss.
llvm-svn: 82882
2009-09-27 00:12:57 +00:00
Anders Carlsson 853bb50382 Mangle ::std::basic_string as Sb.
llvm-svn: 82881
2009-09-26 23:14:39 +00:00
Anders Carlsson 872ce0dc31 Mangle ::std::allocator as Sa.
llvm-svn: 82880
2009-09-26 23:10:05 +00:00
Anders Carlsson 3e83c30c4c Handle substitutions in mangleTemplatePrefix.
llvm-svn: 82879
2009-09-26 22:18:22 +00:00
Chris Lattner a26b471f1d builtin_trap should be noreturn, this fixes PR5062, patch by
Roman Divacky!

llvm-svn: 82876
2009-09-26 21:16:00 +00:00
Douglas Gregor 2208a2912c Simplify the handling of non-dependent friend class template
specializations such as:

  friend class std::vector<int>;

by using the same code path as explicit specializations, customized to
reference an existing ClassTemplateSpecializationDecl (or build a new
"undeclared" one).

llvm-svn: 82875
2009-09-26 20:57:03 +00:00
Anders Carlsson aa9e3c8793 Substitute "::std::" as "St".
llvm-svn: 82874
2009-09-26 20:53:44 +00:00
Anders Carlsson 49232b9f42 Don't crash when trying to mangle function templates.
llvm-svn: 82872
2009-09-26 20:13:56 +00:00
Anders Carlsson e33eed5c1e Set alignment on static function level decls and VLAs. Fixes PR5060.
llvm-svn: 82868
2009-09-26 18:16:06 +00:00
Ted Kremenek 2f5198b022 Added test case for <rdar://problem/7152418>.
llvm-svn: 82866
2009-09-26 17:18:44 +00:00
Daniel Dunbar bb6ac47ea1 Revert "Force triple in test.", this wasn't the problem.
llvm-svn: 82855
2009-09-26 07:43:49 +00:00
Daniel Dunbar a87097a6ac Add the lib path to LD_LIBRARY_PATH, so finding .so works (more) portably.
llvm-svn: 82853
2009-09-26 07:36:09 +00:00
Daniel Dunbar 1b436d6950 Force triple in test.
llvm-svn: 82850
2009-09-26 07:06:36 +00:00
Douglas Gregor 9acb690827 Fix name lookup for friend class templates to consider anything in a
scope *up to and including* the innermost namespace scope, rather than
just searching in the innermost namespace scope. 

llvm-svn: 82849
2009-09-26 07:05:09 +00:00
Douglas Gregor 3dad842b35 Rework the Parse-Sema interaction for friends to better support friend
class templates. We now treat friend class templates much more like
normal class templates, except that they still get special name lookup
rules. Fixes PR5057 and eliminates a bunch of spurious diagnostics in
<iostream>.

llvm-svn: 82848
2009-09-26 06:47:28 +00:00
Anders Carlsson 0374742326 Use ABIArgInfo::getDirect() for all types that have a pointer representation.
llvm-svn: 82845
2009-09-26 03:56:53 +00:00
Anders Carlsson 296f8dc52f Mangle record types as decls.
llvm-svn: 82843
2009-09-26 03:55:37 +00:00
Ted Kremenek 7226af69cb Add a "positive" matching test case for attribute 'noreturn' that involves a nested infinite loop.
llvm-svn: 82842
2009-09-26 03:54:06 +00:00
Ted Kremenek 9fa2eefa4c Add two more test cases for attribute 'noreturn'.
llvm-svn: 82841
2009-09-26 03:48:56 +00:00
Anders Carlsson bdaaab4671 Improve mangling of typename types.
llvm-svn: 82833
2009-09-26 02:26:02 +00:00
Anders Carlsson 7f78d85be4 Start at NextOffset when laying out bases as well.
llvm-svn: 82831
2009-09-26 01:29:10 +00:00
Anders Carlsson a6d95b5a3e Use NextOffset when laying out a field.
llvm-svn: 82828
2009-09-26 01:09:35 +00:00
Douglas Gregor 0e876e0180 Use explicitly-specified template argument lists to help naming
explicit template specializations, when available.

llvm-svn: 82824
2009-09-25 23:53:26 +00:00
Steve Naroff 43b118fc2c Fix cut/paste error resulting in bad column info.
llvm-svn: 82810
2009-09-25 22:15:54 +00:00
Douglas Gregor d90fd526d3 Declarators can now properly represent template-ids, e.g., for
template void f<int>(int);
                ~~~~~~
Previously, we silently dropped the template arguments. With this
change, we now use the template arguments (when available) as the
explicitly-specified template arguments used to aid template argument
deduction for explicit template instantiations.

llvm-svn: 82806
2009-09-25 21:45:23 +00:00
Steve Naroff 63f475a212 Add clang_getDeclLine and clang_getDeclColumn
Fix clang_getCursorDecl to do the right thing for expr refs
Fixup test file to accommodate new output (which includes the line/column for the referenced decl)

llvm-svn: 82798
2009-09-25 21:32:34 +00:00
Fariborz Jahanian 49850dfc4e Refixed pr5050 per Anders comment. Test case enhanced
per Doug's comment.

llvm-svn: 82791
2009-09-25 18:59:21 +00:00
Douglas Gregor 450f0084a2 WIP implementation of explicit instantiation of function templates,
member functions of class template specializations, and static data
members. The mechanics are (mostly) present, but the semantic analysis
is very weak.

llvm-svn: 82789
2009-09-25 18:43:00 +00:00
Fariborz Jahanian 5aec1b54bc Fix the AST tree so ir-gen can do the conversion via copy construction.
Fixed pr5050.

llvm-svn: 82783
2009-09-25 18:11:25 +00:00
Anders Carlsson d7d358a65e Even more work on empty classes.
llvm-svn: 82770
2009-09-25 15:39:00 +00:00
Douglas Gregor dc880d67f7 Don't look for __builtin_va_list; it isn't present for all targets
llvm-svn: 82757
2009-09-25 06:44:41 +00:00
Douglas Gregor 56751b5981 Fix checking for a null pointer constant when the expression itself is
value-dependent. Audit (and fixed) all calls to
Expr::isNullPointerConstant() to provide the correct behavior with
value-dependent expressions. Fixes PR5041 and a crash in libstdc++
<locale>.

In the same vein, properly compute value- and type-dependence for
ChooseExpr. Fixes PR4996.

llvm-svn: 82748
2009-09-25 04:25:58 +00:00
John McCall 6cb02c1d7e Add a reduced test case for the weak ivar infinite recursion.
llvm-svn: 82747
2009-09-25 02:18:37 +00:00
Anders Carlsson e1883100a3 Who would have thought that empty classes were so tricky? Handle cases where an empty virtual base class needs to be moved aside because it conflicts with the first field.
llvm-svn: 82746
2009-09-25 01:54:38 +00:00
Anders Carlsson 4bf82141e7 Handle array fields that contain empty structs.
llvm-svn: 82744
2009-09-25 01:23:32 +00:00
Ted Kremenek f694f421e1 Fix <rdar://problem/7249327> by allowing silent conversions between signed and unsigned integer values for symbolic values. This is an intermediate solution (i.e. hack) until we support extension/truncation of symbolic integers.
llvm-svn: 82737
2009-09-25 00:18:15 +00:00
Anders Carlsson 6f95c705ea More work on empty classes.
llvm-svn: 82736
2009-09-25 00:02:51 +00:00
Douglas Gregor 5013a7e42d When entering the scope of a declarator, make sure that the scope is
complete (or, possibly causing template instantiation).

Test this via some explicit specializations of member functions.

llvm-svn: 82732
2009-09-24 23:39:01 +00:00
Douglas Gregor 3a923c2d37 WIP implementation of explicit function template specialization. This
first implementation recognizes when a function declaration is an
explicit function template specialization (based on the presence of a
template<> header), performs template argument deduction + ambiguity
resolution to determine which template is being specialized, and hooks

There are many caveats here:
  - We completely and totally drop any explicitly-specified template
  arguments on the floor
  - We don't diagnose any of the extra semantic things that we should
  diagnose. 
  - I haven't looked to see that we're getting the right linkage for
  explicit specializations

On a happy note, this silences a bunch of errors that show up in
libstdc++'s <iostream>, although Clang still can't get through the
entire header.

llvm-svn: 82728
2009-09-24 23:14:47 +00:00
Douglas Gregor 9fb4bf4d57 Clean up the CodeCompletion testsuite's use of FileCheck
llvm-svn: 82726
2009-09-24 22:57:42 +00:00
Steve Naroff a7753c492e Add test for C-based indexing API, using FileCheck utility.
llvm-svn: 82706
2009-09-24 20:03:06 +00:00
John McCall 8ccfcb51ee Refactor the representation of qualifiers to bring ExtQualType out of the
Type hierarchy.  Demote 'volatile' to extended-qualifier status.  Audit our
use of qualifiers and fix a few places that weren't dealing with qualifiers
quite right;  many more remain.

llvm-svn: 82705
2009-09-24 19:53:00 +00:00
Daniel Dunbar a5840dbcb5 cmake: Run tests with 'verbose' enabled by default, so that the failure is
visible in the log.

llvm-svn: 82688
2009-09-24 07:18:36 +00:00
Daniel Dunbar c437eb831b We no longer need anything from the llvm/test/Scripts dir.
llvm-svn: 82687
2009-09-24 06:31:08 +00:00
Ted Kremenek 1b40e5978f Fix crash in RegionStoreManager::Bind() by using 'getAs<PointerType>()' instead of 'cast<PointerType>()' (to handle pointer typedefs).
llvm-svn: 82686
2009-09-24 06:24:32 +00:00
Anders Carlsson bb66bc8e84 More improvements with laying out empty bases.
llvm-svn: 82682
2009-09-24 05:21:31 +00:00
Daniel Dunbar b3b1e53d33 Darwin/x86-32: Enumerated types and block pointer types in structures were not
handled correctly.
 - <rdar://problem/7247671> Function arguments incorrect when function returns a
   struct on i386 w/ llvm-g++ and clang

llvm-svn: 82681
2009-09-24 05:12:36 +00:00
Ted Kremenek 267e45adab Fix: <rdar://problem/7249340> [RegionStore] model stores to symbolic parameter regions
The issue was a discrepancy between how RegionStoreManager::Bind() and
RegionStoreManager::Retrieve() derived the "key" for the first element
of a symbolic region.

llvm-svn: 82680
2009-09-24 04:11:44 +00:00
Anders Carlsson f24b18fb06 More work on empty classes.
llvm-svn: 82679
2009-09-24 03:22:10 +00:00
Ted Kremenek d9120d3575 Shorten the static analyzer diagnostic for 'use of garbage value'.
llvm-svn: 82672
2009-09-24 00:44:26 +00:00
Douglas Gregor 96ab942a69 Make C++ temporary-related expressions provide proper source-range information.
llvm-svn: 82665
2009-09-23 22:51:26 +00:00
Fariborz Jahanian 9ce90d13e3 patch to ir-gen conversion function call used in
initializing a reference class.

llvm-svn: 82664
2009-09-23 22:34:00 +00:00
Douglas Gregor e412a5a8f7 For code completion, note that injected-class-names found as part of
lookup in a member access expression always start a
nested-name-specifier. Additionally, rank names that start
nested-name-specifiers after other names.

llvm-svn: 82663
2009-09-23 22:26:46 +00:00
Fariborz Jahanian af0262dccf This patch addresses a few issues related to 8.5.3 [dcl.init.ref]
It uses a recent API to find inherited conversion functions to do
the initializer to reference lvalue conversion (and removes a FIXME).
It issues the ambiguity diagnostics when multiple conversions are found.
WIP.

llvm-svn: 82649
2009-09-23 20:55:32 +00:00
Anders Carlsson 649a17e861 Handle namespace aliases.
llvm-svn: 82644
2009-09-23 19:19:16 +00:00
Anders Carlsson f771681e63 Emit new[] cookie when needed.
llvm-svn: 82642
2009-09-23 18:59:48 +00:00
Anders Carlsson b4bd0666d2 Basic support for new[].
llvm-svn: 82628
2009-09-23 16:07:23 +00:00
Douglas Gregor 2a920014d3 When code-completion after a "," is building an overload set, note
that there is one more argument (the one following the comma) and make
the candidate non-viable if the function cannot accept any argument in
that position.

llvm-svn: 82625
2009-09-23 14:56:09 +00:00
Gabor Greif a8f9374661 fix typo in file name
llvm-svn: 82623
2009-09-23 13:15:04 +00:00
Chris Lattner d545ad1301 implement support for __builtin_eh_return_data_regno on x86-32 and x86-64.
This implements PR5034 and rdar://6836445.

llvm-svn: 82614
2009-09-23 06:06:36 +00:00
Ted Kremenek 1624a4784a Fix PR 4988 by removing an invalid assertion (a function can be referenced in
GRExprEngine::VisitDeclRefExpr without 'asLValue' being true).

llvm-svn: 82598
2009-09-23 01:30:01 +00:00
Fariborz Jahanian 21ccf06352 Produce detailed diagnostics when overload
resolution failed to select a candidate due to
ambiguity in type conversion function selection.

llvm-svn: 82596
2009-09-23 00:58:07 +00:00
Anders Carlsson 8ab20bb144 Cast the array size expr to a size_t
llvm-svn: 82594
2009-09-23 00:37:25 +00:00
Douglas Gregor f0f51985a1 Print the results of code-completion for overloading by displaying the
signature of the function with the current parameter highlighted as a
placeholder.

llvm-svn: 82593
2009-09-23 00:34:09 +00:00
Douglas Gregor 05f477c177 Separate the code-completion results for call completion from the
results for other, textual completion. For call completion, we now
produce enough information to show the function call argument that we
are currently on.

llvm-svn: 82592
2009-09-23 00:16:58 +00:00
Douglas Gregor 2b3ee156fc When code-completion finds a declaration only because it is usable as
the start of a nested-name-specifier, add the "::" after the
nested-name-specifier to the code-completion string.

llvm-svn: 82587
2009-09-22 23:22:24 +00:00
Douglas Gregor 5bf52697b0 Tweak the code-completion results ranking and formation, so that
members found in base classes have the same ranking as members found
in derived classes. However, we will introduce an informative note for
members found in base classes, showing (as a nested-name-specifier)
the qualification to name the base class, to make it clear which
members are from bases.
 

llvm-svn: 82586
2009-09-22 23:15:58 +00:00
Daniel Dunbar 81fff1c358 Spell clang-cc correctly.
llvm-svn: 82582
2009-09-22 22:30:59 +00:00
Douglas Gregor ba4490399b Teach code-completion to introduce a ", ..." placeholder for variadic functions
llvm-svn: 82577
2009-09-22 21:42:17 +00:00
Douglas Gregor 9bfc2e50a7 In C++, a variadic function does not need an ellipsis prior to the comma. Parse it in both C and C++, but diagnose it as an error in C with a fix-it hint to add the comma.
llvm-svn: 82576
2009-09-22 21:41:40 +00:00
Ted Kremenek 3003001a86 Fix: <rdar://problem/7242006> [RegionStore] compound literal assignment with floats not honored
llvm-svn: 82575
2009-09-22 21:19:14 +00:00
Douglas Gregor ea9b03e6e2 Replace the -code-completion-dump option with
-code-completion-at=filename:line:column

which performs code completion at the specified location by truncating
the file at that position and enabling code completion. This approach
makes it possible to run multiple tests from a single test file, and
gives a more natural command-line interface.

llvm-svn: 82571
2009-09-22 21:11:38 +00:00
Anders Carlsson 1d3b6f62df CXXMethodDecls should always be mangled, even if they are inside an extern "C" block. Fixes PR5017.
llvm-svn: 82567
2009-09-22 20:33:31 +00:00
Fariborz Jahanian 0b51c729c9 Issue good ambiguity diagnostic when convesion fails.
llvm-svn: 82565
2009-09-22 19:53:15 +00:00
Anders Carlsson 55640546e4 If we already set a primary base, don't set it to the first nearly empty base class.
llvm-svn: 82563
2009-09-22 19:16:59 +00:00
Anders Carlsson fc51cc968b Don't assert that linkage decls are always C++, it's not true. Fixes PR5019.
llvm-svn: 82557
2009-09-22 17:23:30 +00:00
Fariborz Jahanian e983d17570 Fix a regression in accessing class getter using the dot-syntax
notation. There is still an issue accessing field of a 'Class''s isa
in legacy code using dot field access notation (as noted in the test case)
but unrelated to this patch.

llvm-svn: 82555
2009-09-22 16:48:37 +00:00
Douglas Gregor cabea40ea3 Implement code completion within a function call, triggered after the
opening parentheses and after each comma. We gather the set of visible
overloaded functions, perform "partial" overloading based on the set
of arguments that we have thus far, and return the still-viable
results sorted by the likelihood that they will be the best candidate.

Most of the changes in this patch are a refactoring of the overloading
routines for a function call, since we needed to separate out the
notion of building an overload set (common to code-completion and
normal semantic analysis) and then what to do with that overload
set. As part of this change, I've pushed explicit template arguments
into a few more subroutines.

There is still much more work to do in this area. Function templates
won't be handled well (unless we happen to deduce all of the template
arguments before we hit the completion point), nor will overloaded
function-call operators or calls to member functions.

llvm-svn: 82549
2009-09-22 15:41:20 +00:00
Daniel Dunbar 79327b6efe Always execute tests internally on Windows.
llvm-svn: 82542
2009-09-22 10:08:03 +00:00
Daniel Dunbar 3967fca364 CMake: Add a clang-c++tests target for running the experimental C++ header
-fsyntax-only'ing tests.

llvm-svn: 82541
2009-09-22 10:07:55 +00:00
Daniel Dunbar b45012dcde Update PCH serialization of FunctionDecl flags.
llvm-svn: 82526
2009-09-22 05:38:14 +00:00
Daniel Dunbar b5cbf77c2e Remove old test runner, this has moved to LLVM/utils/lit and all known clients
have been updated.
 - Please let me know of any problems.

llvm-svn: 82524
2009-09-22 05:16:02 +00:00
Ted Kremenek f9539d0c3f Fix: <rdar://problem/7242015> [RegionStore] variable passed-by-reference (via integer) to function call not invalidated
llvm-svn: 82523
2009-09-22 04:48:39 +00:00
Daniel Dunbar 0512647362 Force triple in test.
llvm-svn: 82519
2009-09-22 03:50:39 +00:00
Daniel Dunbar a25a9dff0d Add test case for PR4894 (it was fixed in LLVM).
llvm-svn: 82510
2009-09-22 02:18:40 +00:00
Ted Kremenek fd68c7bdc0 Add test case for <rdar://problem/6829164>, which was implicitly fixed in r79694.
llvm-svn: 82495
2009-09-21 23:22:11 +00:00
Fariborz Jahanian 71848a3ff1 Removed -fobjc-newgc-api option. clang now conforms to
gcc-style write-barrier api only.

llvm-svn: 82493
2009-09-21 23:03:37 +00:00
Ted Kremenek 25c9c1427a Provide intermediate solution to handling assignments to structs via an
integer pointer.  For now just invalidate the fields of the struct.

This addresses: <rdar://problem/7185607> [RegionStore] support invalidation of bit fields using integer assignment

llvm-svn: 82492
2009-09-21 22:58:52 +00:00
Douglas Gregor 9d64c5e3a5 Code completion for ordinary names when we're starting a declaration, expression, or statement
llvm-svn: 82481
2009-09-21 20:51:25 +00:00
Fariborz Jahanian a74039426d -fobjc-newgc-api is now the default.
llvm-svn: 82478
2009-09-21 20:17:37 +00:00
Douglas Gregor 2af2f670d1 When providing a code-completion suggestion for a hidden name, include
a nested-name-specifier that describes how to refer to that name. For
example, given:

  struct Base { int member; };
  struct Derived : Base { int member; };

the code-completion result for a member access into "Derived" will
provide both "member" to refer to Derived::member (no qualification needed) and
"Base::member" to refer to Base::member (qualification included).

llvm-svn: 82476
2009-09-21 20:12:40 +00:00
Douglas Gregor f251067530 Enhance "case" code completion in C++ to suggest qualified names for
enumerators when either the user intentionally wrote a qualified name
(in which case we just use that nested-name-specifier to match
the user's code) or when this is the first "case" statement and we
need a qualified name to refer to an enumerator in a different scope.

llvm-svn: 82474
2009-09-21 19:57:38 +00:00
Fariborz Jahanian 38c3ae9bc4 Miscellanous fixes in generatation of objc gc's write-barriers.
llvm-svn: 82472
2009-09-21 18:54:29 +00:00
Douglas Gregor d328d57c39 Code completion for "case" statements within a switch on an expression
of enumeration type, providing the various unused enumerators as options.

llvm-svn: 82467
2009-09-21 18:10:23 +00:00
Daniel Dunbar 607a2a1ed1 Add an XFAIL test which compiles differently from a .ast.
llvm-svn: 82437
2009-09-21 05:16:43 +00:00
Chris Lattner bf20638966 Implement __builtin_unreachable(), a GCC 4.5 extension.
llvm-svn: 82433
2009-09-21 03:09:59 +00:00
Daniel Dunbar 26e37a77c6 Switch ProcessASTInputFile to still use ParseAST.
- Currently this requires us to fake an input file.

 - This allows Sema to be keep all the logic for how to pull decls out of the external AST source and how to handle things like tentative definitions.

llvm-svn: 82432
2009-09-21 03:03:56 +00:00
Anders Carlsson a18322cea5 Start mangling expressions.
llvm-svn: 82423
2009-09-21 01:21:10 +00:00
Daniel Dunbar 1d9b45304d Work around FileCheck -NOT restriction.
llvm-svn: 82417
2009-09-20 23:35:52 +00:00
Daniel Dunbar 22d5360ed0 Switch TestRunner.sh to just use 'lit'.
- Does people use this?

llvm-svn: 82406
2009-09-20 22:00:23 +00:00
Daniel Dunbar c6bca95723 Switch to using the new LLVM lit test runner by default.
llvm-svn: 82405
2009-09-20 22:00:17 +00:00
Daniel Dunbar a173d9b874 Include LLVM {src,obj} root in lit.site.cfg, to support non-standard layouts.
llvm-svn: 82401
2009-09-20 19:04:35 +00:00
Douglas Gregor b5c738b434 In C++ code completion, only suggest the "template" keyword after ".",
"->", or "::" if we will be looking into a dependent context. It's not
wrong to use the "template" keyword, but it's to needed, either.

llvm-svn: 82307
2009-09-18 23:55:56 +00:00
Douglas Gregor ce23bae4f8 Make the construction of the code-completion string for a function
template smarter, by taking into account which function template
parameters are deducible from the call arguments. For example,

  template<typename RandomAccessIterator>
  void sort(RandomAccessIterator first, RandomAccessIterator last);

will have a code-completion string like

  sort({RandomAccessIterator first}, {RandomAccessIterator last})

since the template argument for its template parameter is
deducible. On the other hand,

  template<class X, class Y>
  X* dyn_cast(Y *Val);

will have a code-completion string like

  dyn_cast<{class X}>({Y *Val})

since the template type parameter X is not deducible from the function
call.

llvm-svn: 82306
2009-09-18 23:21:38 +00:00
Douglas Gregor 3f6ca38927 Introduce code completion patterns for templates, which provide the
angle brackets < > along with placeholder template arguments.

llvm-svn: 82304
2009-09-18 22:47:56 +00:00
Ted Kremenek 0ccd06c017 Re-introduce diagnostic caching in BugReporter that was originally added in
r82198 and then reverted. This is an intermediate solution, as diagnostic
caching should not rely on static variables.

llvm-svn: 82301
2009-09-18 22:37:37 +00:00
Douglas Gregor fedc328ae9 Introduce code completion strings, which describe how to *use* the
results of code completion, e.g., by providing function call syntax
with placeholders for each of the parameters.

llvm-svn: 82293
2009-09-18 22:15:54 +00:00
Daniel Dunbar b90893dc41 Attempt to make a test portable.
llvm-svn: 82292
2009-09-18 22:09:24 +00:00
Douglas Gregor c811ede9b7 C++ code completion after the "operator" keyword. Provide overloaded
operators, type specifiers, type names, and nested-name-specifiers.

llvm-svn: 82264
2009-09-18 20:05:18 +00:00
Anders Carlsson 327c8df90c Make our char vector types not be explicitly signed to match GCC and to fix compilation with C++ and -fno-lax-vector-conversions
llvm-svn: 82254
2009-09-18 19:18:19 +00:00
Douglas Gregor 7e90c6db18 Introduce four new code-completion hooks for C++:
- after "using", show anything that can be a nested-name-specifier.
  - after "using namespace", show any visible namespaces or namespace aliases
  - after "namespace", show any namespace definitions in the current scope
  - after "namespace identifier = ", show any visible namespaces or
    namespace aliases

llvm-svn: 82251
2009-09-18 19:03:04 +00:00
Douglas Gregor 56c2dbcfe7 Handle using declarations and overload sets in code completion.
llvm-svn: 82233
2009-09-18 17:54:00 +00:00
Douglas Gregor 945e8d9762 For code completion in C++ member access expressions and tag names,
look into the current scope for anything that could start a
nested-names-specifier. These results are ranked worse than any of the
results actually found in the lexical scope.

Perform a little more pruning of the result set, eliminating
constructors, __va_list_tag, and any duplication of declarations in
the result set. For the latter, implemented
NamespaceDecl::getCanonicalDecl.

llvm-svn: 82231
2009-09-18 17:42:29 +00:00
Douglas Gregor 2da11086f3 When gathering results for code completion, only include hidden
results when there is some way to refer to them in the language, such
as with a qualified name in C++.

llvm-svn: 82223
2009-09-18 15:51:54 +00:00
Douglas Gregor f45b0cf389 Implement code completion for tags, e.g., code completion after "enum"
will provide the names of various enumerations currently
visible. Introduced filtering of code-completion results when we build
the result set, so that we can identify just the kinds of declarations
we want.

This implementation is incomplete for C++, since we don't consider
that the token after the tag keyword could start a
nested-name-specifier. 

llvm-svn: 82222
2009-09-18 15:37:17 +00:00
Daniel Dunbar ebc5140e22 Disable questionable code for handling isNullPointerConstant on value dependent
expression.

llvm-svn: 82217
2009-09-18 08:46:16 +00:00
Daniel Dunbar 23c1ae7fae Force a triple.
llvm-svn: 82216
2009-09-18 08:46:07 +00:00
Ted Kremenek e3d209ff77 Revert most of r82198, which was causing a large number of crashes
when running the analyzer on real projects.  We'll keep the change to
AnalysisManager.cpp in r82198 so that -fobjc-gc analyzes code
correctly in both GC and non-GC modes, although this may emit two
diagnostics for each bug in some cases (a better solution will come
later).

llvm-svn: 82201
2009-09-18 07:31:15 +00:00
Ted Kremenek 82f7f9c080 Introduce caching of diagnostics in BugReporter. This provides extra
pruning of diagnostics that may be emitted multiple times.  This is
accomplished by adding FoldingSet profiling support to PathDiagnostic,
and then having BugReporter record what diagnostics have been issued.

This was motived to a serious bug introduced by moving the
'divide-by-zero' checking outside of GRExprEngine into a separate
'Checker' class.  When analyzing code using the '-fobjc-gc' option, a
given function would be analyzed twice, but the second time various
"internal checks" would be disabled to avoid emitting multiple
diagnostics (e.g., "null dereference") for the same issue.  The
problem is that such checks also effect path pruning and don't just
emit diagnostics.  This resulted in an assertion failure involving a
real divide-by-zero in some analyzed code where we would get an
assertion failure in APInt because the 'DivZero' check was disabled
and didn't prune the logic that resulted in the divide-by-zero in the
analyzer.

The implemented solution is somewhat of a hack, and may not perform
extremely well.  This will need to be cleaned up over time.

As a regression test, 'misc-ps.m' has been modified so that its tests
are run using -fobjc-gc to test this diagnostic pruning behavior.

llvm-svn: 82198
2009-09-18 05:37:41 +00:00