John McCall [Tue, 8 Mar 2011 07:59:04 +0000 (07:59 +0000)]
Fix my earlier commit to work with escaped newlines and leave breadcrumbs
in case we want to make a world where we can check intermediate instantiations
for this kind of breadcrumb.
John McCall [Tue, 8 Mar 2011 04:17:03 +0000 (04:17 +0000)]
objc_gc wants a pointer type, not a function type; give it a more appropriate
diagnostic. Also, these attributes are commonly written with macros which we
actually pre-define, so instead of expanding the macro location, refer to the
instantiation location and name it using the macro loc.
Bill Wendling [Mon, 7 Mar 2011 22:47:14 +0000 (22:47 +0000)]
When we adjust the inline ASM type, we need to take into account an early
clobber with the 'y' constraint. Otherwise, we get the wrong return type and an
assert, because it created a '<1 x i64>' vector type instead of the x86_mmx
type.
Devang Patel [Mon, 7 Mar 2011 18:45:56 +0000 (18:45 +0000)]
DebugInfo can be enabled or disabled at function level (e.g. using an attribute). However, at module level it is determined by command line option and the state of command line option does not change during compilation. Make this layering explicit and fix accidental cases where the code generator was checking whether module has debug info enabled instead of checking whether debug info is enabled for this function or not.
Douglas Gregor [Mon, 7 Mar 2011 16:54:27 +0000 (16:54 +0000)]
Support explicit template specialization and instantiation for members
of a C++0x inline namespace within enclosing namespaces, as noted in
C++0x [namespace.def]p8.
Fixes <rdar://problem/9006349>, a libc++ failure where Clang was
rejected an explicit specialization of std::swap (since libc++ puts it
into an inline, versioned namespace std::__1).
Douglas Gregor [Mon, 7 Mar 2011 15:13:34 +0000 (15:13 +0000)]
When rebuilding a dependent template specialization type to another
dependent template specialization type, make sure to set the keyword
location. Fixes some valgrind issues introduced in r127150.
Douglas Gregor [Mon, 7 Mar 2011 02:33:33 +0000 (02:33 +0000)]
When transforming a dependent template specialization type, make sure
to set the source-location information for the template arguments to
the *transformed* source-location information, not the original
source-location information. Fixes <rdar://problem/8986308> (a libc++
SFINAE issue) and the Boost.Polygon failure.
John McCall [Mon, 7 Mar 2011 01:52:56 +0000 (01:52 +0000)]
An operator new with an empty exception specifier returns null on a bad
allocation and therefore requires a null-check. We were doing that, but
we weren't treating the new-initializer as being conditionally executed,
which means it was possible to get ill-formed IR as in PR9298.
Redo part of r127137:
Pass down the correct C->getArgs, but keep it with the original
DerivedArgList type. Slightly adjust the MakeIndex call for the
different base type. This unbreaks the handling of --no-mangle on Darwin.
Douglas Gregor [Mon, 7 Mar 2011 01:03:30 +0000 (01:03 +0000)]
Remove the AST printer (-ast-print-xml), which is too incomplete and
too low-level to actually be useful but is just interesting enough for
people to try to use it (which won't actually work beyond toy examples).
To bring back the AST printer, it needs to be:
- Complete, covering all of C/C++/Objective-C
- Documented, with appropriate Schema against which we can validate
the output
- Designed for C/C++/Objective-C, not Clang's specific ASTs
- Stable across Clang versions
- Well-tested
Douglas Gregor [Sun, 6 Mar 2011 20:12:45 +0000 (20:12 +0000)]
We may fail to map a declaration in a template to its instantiated
declaration because of interesting ordering dependencies while
instantiating a class template or member class thereof. Complain,
rather than asserting (+Asserts) or silently rejecting the code
(-Asserts).
Anders Carlsson [Sun, 6 Mar 2011 18:19:42 +0000 (18:19 +0000)]
When serializing a DeclRefExpr, always store the number of explicit template
arguments at the same offset, since it's needed when creating the empty
DeclRefExpr when deserializing. Fixes a memory corruption issue that would lead
to random bugs and crashes.
Douglas Gregor [Sun, 6 Mar 2011 09:03:20 +0000 (09:03 +0000)]
When performing template argument deduction for a non-reference
conversion function when we're binding the result to a reference, drop
cv-qualifiers on the type we're referring to, since we should be
deducing a type that can be adjusted (via cv-qualification) to the
requested type. Fixes PR9336, and the remaining Boost.Assign failure.
Douglas Gregor [Sat, 5 Mar 2011 20:06:51 +0000 (20:06 +0000)]
When substituting in for a template name, do not produce a qualified
template name as the result of substitution. The qualifier is handled
separately by the tree transformer, so we would end up in an
inconsistent state.
This is actually the last bit of PR9016, and possibly also fixes
PR8965. It takes Boost.Icl from "epic fail" down to a single failure.
Douglas Gregor [Sat, 5 Mar 2011 17:54:25 +0000 (17:54 +0000)]
When determining template instantiation arguments within a function
template (not a specialization!), use the "injected" function template
arguments, which correspond to the template parameters of the function
template. This is required when substituting into the default template
parameters of template template parameters within a function template.
Douglas Gregor [Sat, 5 Mar 2011 17:19:27 +0000 (17:19 +0000)]
When transforming a substituted template type parameter, try to
transform the type that replaces the template type parameter. In the
vast majority of cases, there's nothing to do, because most template
type parameters are replaced with something non-dependent that doesn't
need further transformation. However, when we're dealing with the
default template arguments of template template parameters, we might
end up replacing a template parameter (of the template template
parameter) with a template parameter of the enclosing template.
This addresses part of PR9016, but not within function
templates. That's a separate issue.
Normalize target triple passed out of driver. Basically this means
that at cc1 level we will always have normalized triple and thus can
provide necessary default based on e.g. environment value (e.g. for
"arm-eabi" triple, etc.)
Douglas Gregor [Sat, 5 Mar 2011 01:35:54 +0000 (01:35 +0000)]
When we're deserializing a template parameter declaration, temporarily
use the translation unit as its declaration context, then deserialize
the actual lexical and semantic DeclContexts after the template
parameter is complete. This avoids problems when the DeclContext
itself (e.g., a class template) is dependent on the template parameter
(e.g., for the injected-class-name).
Currently we can only remap a file by creating a MemoryBuffer and replacing the file contents with it.
Allow remapping a file by specifying another filename whose contents should be loaded if the original
file gets loaded. This allows to override files without having to create & load buffers in advance.
Nick Lewycky [Sat, 5 Mar 2011 00:32:47 +0000 (00:32 +0000)]
Give warnings about static initializers of non-integral type their own warning
flag so it can be individually controlled. The new flag is
-Wc++0x-static-nonintegral-init.
Douglas Gregor [Fri, 4 Mar 2011 21:37:14 +0000 (21:37 +0000)]
Teach Sema::ActOnCXXNestedNameSpecifier and Sema::CheckTemplateIdType
to cope with non-type templates by providing appropriate
errors. Previously, we would either assert, crash, or silently build a
dependent type when we shouldn't. Fixes PR9226.
Douglas Gregor [Fri, 4 Mar 2011 20:42:52 +0000 (20:42 +0000)]
After an error of any kind has occurred, don't assert when attempting
to find the instantiated declaration within a template instantiation
fails to do so. It's likely that the original instantiation got
dropped due to instantiation failures, which doesn't actually break
the invariants of the AST. This eliminates a number of
crash-on-invalid failures, e.g., PR9300.
Devang Patel [Fri, 4 Mar 2011 18:54:42 +0000 (18:54 +0000)]
Emit a stop point before a call expression so that debugger has some chance of getting some footing when user wants to stop at 2nd bar() in following expression when all function calls are inlined.
= bar() + ... + bar() + ...
clang keeps track of column numbers, so we could put location entries for all subexpressions but that will significantly bloat debug info in general, but a location for call expression is helpful here.
Douglas Gregor [Fri, 4 Mar 2011 18:53:13 +0000 (18:53 +0000)]
When constructing source-location information for a
DependentTemplateSpecializationType during tree transformation, retain
the NestedNameSpecifierLoc as it was used to translate the template
name, rather than reconstructing it from the template name.
Douglas Gregor [Fri, 4 Mar 2011 17:52:15 +0000 (17:52 +0000)]
Make sure to put template parameters into their owning template's
DeclContext once we've created it. This mirrors what we do for
function parameters, where the parameters start out with
translation-unit context and then are adopted by the appropriate
DeclContext when it is created. Also give template parameters public
access and make sure that they don't show up for the purposes of name
lookup.
Fixes PR9400, a regression introduced by r126920, which implemented
substitution of default template arguments provided in template
template parameters (C++ core issue 150).
How on earth could the DeclContext of a template parameter affect the
handling of default template arguments?
I'm so glad you asked! The link is
Sema::getTemplateInstantiationArgs(), which determines the outer
template argument lists that correspond to a given declaration. When
we're instantiating a default template argument for a template
template parameter within the body of a template definition (not it's
instantiation, per core issue 150), we weren't getting any outer
template arguments because the context of the template template
parameter was the translation unit. Now that the context of the
template template parameter is its owning template, we get the
template arguments from the injected-class-name of the owning
template, so substitution works as it should.
If we look at the main location of the first explicit specialization (Spec 1) it can be seen that it points to the name of the *second* explicit specialization (Spec 2), which is a redeclaration of Spec1.
Hence, the source range obtained for Spec1 is not only inaccurate, but also invalid (the end location comes before the start location).
John McCall [Fri, 4 Mar 2011 10:39:25 +0000 (10:39 +0000)]
Don't consider visibility from template parameter lists if we're
computing for a nested decl with explicit visibility. This is all part
of the general philosophy of explicit visibility attributes, where
any information that was obviously available at the attribute site
should probably be ignored. Fixes PR9371.
John McCall [Fri, 4 Mar 2011 08:25:59 +0000 (08:25 +0000)]
Access ivars with inbounds GEPs, even in -fwrapv. It's unlikely that
this can have any optimization effect, given the opacity of objects pointers,
but you never know.
John McCall [Fri, 4 Mar 2011 04:00:19 +0000 (04:00 +0000)]
Make AttributedTypes for GC-qualified types and fix some miscellaneous
bugs with such types. Not sure this is quite how I want the desugaring
and a.k.a. logic to go, but it suffices.