Richard Smith [Thu, 17 Apr 2014 03:52:20 +0000 (03:52 +0000)]
PR19340: If we see a declaration of a member of an unspecialized class template
that looks like it might be an explicit specialization, don't recover as an
explicit specialization (bypassing the check that would reject that).
Ben Langmuir [Thu, 17 Apr 2014 03:31:02 +0000 (03:31 +0000)]
When writing YAML in libclang, use yaml::escape instead of write_escaped
The YAMLParser has its own escaped string representation, and does not
handle octal escape sequences. When writing the virtual file system to a
YAML file, use yaml::escape().
Richard Smith [Thu, 17 Apr 2014 02:56:49 +0000 (02:56 +0000)]
Don't emit an ExtWarn on declarations of variable template specializations;
we'll already have issued the relevant diagnostic when we saw the declaration
of the primary template.
Richard Smith [Thu, 17 Apr 2014 01:52:14 +0000 (01:52 +0000)]
Implement [over.match.oper]p3 properly, by filtering the non-candidates out
when building the candidate set, rather than trying to contort name lookup into
handling this.
Richard Smith [Thu, 17 Apr 2014 01:12:17 +0000 (01:12 +0000)]
PR19452: Implement more of [over.match.oper]p3's restrictions on which non-member overloaded operators can be found when no operand is of class type. We used to fail to implement this rule if there was an operand of dependent type.
Adrian Prantl [Thu, 17 Apr 2014 00:30:48 +0000 (00:30 +0000)]
Debug info: When collecting the parameters of C++ partial template
specializations collect all arguments and not just the ones from the
class template partial specialization from which this class template
specialization was instantiated. The debug info does not represent the
partial specialization otherwise and so specialized parameters would
go missing.
More minor refactoring. Updated for const-correctness, moved another deleted function to be private, 0 -> nullptr and some style corrections. No functional changes intended.
Diego Novillo [Wed, 16 Apr 2014 16:54:24 +0000 (16:54 +0000)]
Add support for optimization reports.
Summary:
This patch adds a new flag -Rpass=. The flag indicates the name
of the optimization pass that should emit remarks stating when it
made a transformation to the code.
Other changes:
- Add DiagnosticIDs::isRemark(). Use it in printDiagnosticOptions to
print "-R" instead of "-W" in the diagnostic message.
- In BackendConsumer::OptimizationRemarkHandler, get a SourceLocation
object out of the file name, line and column number. Use that location
in the call to Diags.Report().
- When -Rpass is used without debug info a note is emitted alerting
the user that they need to use -gline-tables-only -gcolumn-info to
get this information.
The function hash should change when control flow changes. This patch
hashes the type of each AST node that affects counters, rather than just
counting how many there are. These types are combined into a small
enumerator that currently has 16 values.
The new hash algorithm packs the enums for consecutively visited types
into a `uint64_t`. In order to save space for new types, the types are
assumed to be 6-bit values (instead of 4-bit). In order to minimize
overhead for functions with little control flow, the `uint64_t` is used
directly as a hash if it never fills up; if it does, it's passed through
an MD5 context.
Hopefully avoid a warning on some GCCs (but not all strangely,
preventing me from seeing it initially). GCC doesn't use the unused
attribute on members for anything, so while it works to suppress Clang's
warning for an unused private member, it adds a GCC warning for the
attribute. =/ Silence Clang's warning with a void cast in the
constructor instead which doesn't trigger any complaints from GCC.
This is a partial revert of 183015.
By not recognizing things like _setjmp we lose (returns_twice) attribute on
them, which leads to incorrect code generation.
Fixes PR16138.
Lex: Fix __has_feature(cxx_exceptions) for objective C++
At one point, -fexceptions was a synonym for -fcxx-exceptions. While
the driver options still enables cxx-exceptions by default, the cc1
flag is purely about exception tables and this doesn't account for
objective C exceptions. Because of this, checking for the
cxx_exceptions feature in objective C++ often gives the wrong answer.
The cxx_exceptions feature should be based on the -fcxx-exceptions cc1
flag, not -fexceptions. Furthermore, at some point the tests were
changed to use cc1 even though they were testing the driver behaviour.
We're better off testing both the driver and cc1 here.
Richard Trieu [Tue, 15 Apr 2014 23:47:53 +0000 (23:47 +0000)]
Make -Wabsolute-value C++-aware.
Warn on std::abs() with unsigned argument.
Suggest std::abs as replacement for the C absolute value functions.
Suggest C++ headers if the specific std::abs overload is not found.
Thread Safety Analysis: rewrite SSA pass to use the new SExpr and CFG
traversal system. The new pass is still undergoing testing; no change in
functionality.
[Allocator] Make the ContentCache object actually carry the 8-byte
alignment constraint rather than using the allocator function's over
alignment "feature". This was the only use of the "feature" which I plan
to remove next. =] Attaching the alignment to the type seems cleaner and
more principled anyways.
CodeGen: Emit warnings for out of date profile data during PGO
This adds a warning that triggers when profile data doesn't match for
the source that's being compiled with -fprofile-instr-use=. This fires
only once per translation unit, as warning on every mismatched
function would be quite noisy.
AST: Respect alignment attributes on typedef'd arrays
When instantiating an array that has an alignment attribute on it, we
were looking through the array type and only considering the element
type for the resulting alignment. We need to make sure we take the
array's requirements into account too.
Eli Bendersky [Tue, 15 Apr 2014 16:57:05 +0000 (16:57 +0000)]
Add support for CUDA __launch_bounds__ attribute to CodeGen.
Sema does have a CUDALaunchBoundsAttr, but CodeGen was doing nothing with it.
This change translates CUDALaunchBoundsAttr to maxntidx and minctasm
metadata, which NVPTX then translates to the correct PTX directives.
Tim Northover [Tue, 15 Apr 2014 14:55:11 +0000 (14:55 +0000)]
ARM64: track alignment padding registers on AAPCS targets
This implements clause C.8 of the AAPCS in the front-end, so that Clang
accurately knows when the registers run out and it has to insert padding before
the stack objects begin.
CodeGen: Handle CapturedStmt in instrumentation based profiling
CapturedStmt was being ignored by instrumentation based profiling, and
its counters attributed to the containing function. Instead, we need
to treat this as a top level entity, like we do with blocks.
Richard Smith [Mon, 14 Apr 2014 23:47:48 +0000 (23:47 +0000)]
Ensure we evaluate VLA bounds if a variably-modified type is used as the
argument to __builtin_va_arg. Patch by Rahul Jain, some test massaging and
IR emission order changes by me.
Ben Langmuir [Mon, 14 Apr 2014 18:00:01 +0000 (18:00 +0000)]
Allow multiple modules with the same name to coexist in the module cache
To differentiate between two modules with the same name, we will
consider the path the module map file that they are defined by* part of
the ‘key’ for looking up the precompiled module (pcm file).
Specifically, this patch renames the precompiled module (pcm) files from
cache-path/<module hash>/Foo.pcm
to
cache-path/<module hash>/Foo-<hash of module map path>.pcm
In addition, I’ve taught the ASTReader to re-resolve the names of
imported modules during module loading so that if the header search
context changes between when a module was originally built and when it
is loaded we can rebuild it if necessary. For example, if module A
imports module B
first time:
clang -I /path/to/A -I /path/to/B ...
second time:
clang -I /path/to/A -I /different/path/to/B ...
will now rebuild A as expected.
* in the case of inferred modules, we use the module map file that
allowed the inference, not the __inferred_module.map file, since the
inferred file path is the same for every inferred module.
OnDiskHashTable: Make the iterable version separate.
Currently the on disk hash table's key_iterator and data_iterator make
the assumption that the table data starts exactly four bytes after the
base of the table. This happens to be true for all of the tables we
currently iterate over, but not for all of the OnDiskHashTables we
currently use. For example, key_ and data_iterator would iterate over
meaningless data if they were used on the hash tables in PTHLexer.
We make the API safer by breaking this into two types. One doesn't
have the iterators, and the other must be told where the payload
starts.
Manuel Klimek [Mon, 14 Apr 2014 09:14:11 +0000 (09:14 +0000)]
Format code around VCS conflict markers.
Now correctly formats:
{
int a;
void f() {
callme(some(parameter1,
<<<<<<< text by the vcs
parameter2),
||||||| text by the vcs
parameter2),
parameter3,
======= text by the vcs
parameter2, parameter3),
>>>>>>> text by the vcs
otherparameter);
}
}
Parse of nested name spacifier is modified so that it properly recovers
if colon is mistyped as double colon in case statement.
This patch fixes PR15133.
Fix diagnostics for C-style cast to function type.
If the C-style type cast is applied to the overloaded
function and the destination type is function type,
then Clang will crash with assertion failure. For example,
void foo(int);
void foo(int, int);
void bar() {
typedef void (ft)(int);
ft p = (ft)foo;
}
In this case, the overloaded function foo will be cast to
a function type, which should be considered as an error.
But, unfortunately, since the function resolution is using
canonical type, the matched function will be returned, and
result in SEGV.
This patch fixes this issue by removing the assertion and
add some error diagnostics as the one in static_cast.