John McCall [Wed, 9 Mar 2011 04:27:21 +0000 (04:27 +0000)]
Use the "undergoes default argument promotion" bit on parameters to
simplify the logic of initializing function parameters so that we don't need
both a variable declaration and a type in FunctionArgList. This also means
that we need to propagate the CGFunctionInfo down in a lot of places rather
than recalculating it from the FAL. There's more we can do to eliminate
redundancy here, and I've left FIXMEs behind to do it.
NAKAMURA Takumi [Wed, 9 Mar 2011 03:02:28 +0000 (03:02 +0000)]
c-index-test.c: Fix cygwin warning not to pass signed char to islower(c).
Cygwin's ctype.h says;
/* These macros are intentionally written in a manner that will trigger
a gcc -Wall warning if the user mistakenly passes a 'char' instead
of an int containing an 'unsigned char'.
(snip) */
Add 'OverridenFilesKeepOriginalName' field in SourceManager which if true the SourceManager
should report the original file name for contents of files that were overriden by other files,
otherwise it should report the name of the new file. Default is true.
Also add similar field in PreprocessorOptions and pass similar parameter in ASTUnit::LoadFromCommandLine.
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.