Commit Graph

556 Commits

Author SHA1 Message Date
Richard Smith 6eedfe77c1 Implement C++ DR1391 (wg21.link/cwg1391)
Check for implicit conversion sequences for non-dependent function
template parameters between deduction and substitution. The idea is to accept
as many cases as possible, on the basis that substitution failure outside the
immediate context is much more common during substitution than during implicit
conversion sequence formation.

This re-commits r290808, reverted in r290811 and r291412, with a couple of
fixes for handling of explicitly-specified non-trailing template argument
packs.

llvm-svn: 291427
2017-01-09 08:01:21 +00:00
Richard Smith 7950d82ab5 Revert r291410 and r291411.
The test-suite bots are still failing even after r291410's fix.

llvm-svn: 291412
2017-01-09 01:18:18 +00:00
Richard Smith d22652122d Implement C++ DR1391 (wg21.link/cwg1391)
Check for implicit conversion sequences for non-dependent function
template parameters between deduction and substitution. The idea is to accept
as many cases as possible, on the basis that substitution failure outside the
immediate context is much more common during substitution than during implicit
conversion sequence formation.

This re-commits r290808, reverted in r290811, with a fix for handling of
explicitly-specified template argument packs.

llvm-svn: 291410
2017-01-09 00:43:47 +00:00
Renato Golin dad96d6751 Revert "DR1391: Check for implicit conversion sequences for non-dependent function template parameters between deduction and substitution. The idea is to accept as many cases as possible, on the basis that substitution failure outside the immediate context is much more common during substitution than during implicit conversion sequence formation."
This reverts commit r290808, as it broken all ARM and AArch64 test-suite
test: MultiSource/UnitTests/C++11/frame_layout

Also, please, next time, try to write a commit message in according to
our guidelines:

http://llvm.org/docs/DeveloperPolicy.html#commit-messages

llvm-svn: 290811
2017-01-02 11:15:42 +00:00
Richard Smith efcfe86072 DR1391: Check for implicit conversion sequences for non-dependent function
template parameters between deduction and substitution. The idea is to accept
as many cases as possible, on the basis that substitution failure outside
the immediate context is much more common during substitution than during
implicit conversion sequence formation.

This does not implement the partial ordering portion of DR1391, which so
far appears to be misguided.

llvm-svn: 290808
2017-01-02 02:42:17 +00:00
Richard Smith fa4a09d8af Add warning flag for "partial specialization is not more specialized than primary template" error (since Eigen hits it), and while I'm here also add a warning flag for "partial specialization is not usable because one or more of its parameters cannot be deduced" warning.
llvm-svn: 290625
2016-12-27 20:03:09 +00:00
Reid Kleckner 078aea9043 Store decls in prototypes on the declarator instead of in the AST
This saves two pointers from FunctionDecl that were being used for some
rare and questionable C-only functionality.  The DeclsInPrototypeScope
ArrayRef was added in r151712 in order to parse this kind of C code:

    enum e {x, y};
    int f(enum {y, x} n) {
     return x; // should return 1, not 0
    }

The challenge is that we parse 'int f(enum {y, x} n)' it its own
function prototype scope that gets popped before we build the
FunctionDecl for 'f'. The original change was doing two questionable
things:

1. Saving all tag decls introduced in prototype scope on a TU-global
Sema variable. This is problematic when you have cases like this, where
'x' and 'y' shouldn't be visible in 'f':
    void f(void (*fp)(enum { x, y } e)) { /* no x */ }
This patch fixes that, so now 'f' can't see 'x', which is consistent
with GCC.

2. Storing the decls in FunctionDecl in ActOnFunctionDeclarator so that
they could be used in ActOnStartOfFunctionDef. This is just an
inefficient way to move information around. The AST lives forever, but
the list of non-parameter decls in prototype scope is short lived.

Moving these things to the Declarator solves both of these issues.

Reviewers: rsmith

Subscribers: jmolloy, cfe-commits

Differential Revision: https://reviews.llvm.org/D27279

llvm-svn: 289225
2016-12-09 17:14:05 +00:00
Duncan P. N. Exon Smith c9073fa806 Driver: Remove support for -fobjc-gc*
As a first step toward removing Objective-C garbage collection from
Clang, remove support from the driver.  I'm hoping this will flush out
any expected bots/configurations/whatever that might rely on it.

I've left the options behind temporarily in -cc1 to keep tests passing.
I'll kill them off entirely in a follow up when I've had a chance to
update/delete the rest of Clang.

llvm-svn: 288872
2016-12-07 00:31:10 +00:00
Richard Smith 01d96986d8 More diagnostic name fixups: w_ -> warn_, warning_ -> warn_, not_ -> note_.
In passing, add a warning group for "ignored qualifier in inline assembly" warnings.

llvm-svn: 288548
2016-12-02 23:00:28 +00:00
Malcolm Parsons 57ae857548 [Sema] Set range end of constructors and destructors in template instantiations
Summary:
clang-tidy checks frequently use source ranges of functions.
The source range of constructors and destructors in template instantiations
is currently a single token.
The factory method for constructors and destructors does not allow the
end source location to be specified.
Set end location manually after creating instantiation.

Reviewers: aaron.ballman, rsmith, arphaman

Subscribers: arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D26849

llvm-svn: 288025
2016-11-28 11:11:34 +00:00
Benjamin Kramer 60a53d5e16 [ASTDumper] Add some more character escapes for convenience.
llvm-svn: 287859
2016-11-24 09:41:33 +00:00
Richard Smith 5a2e6b97f7 Indicate in AST dump whether special member functions are defaulted and trivial.
llvm-svn: 287599
2016-11-21 23:43:54 +00:00
Joey Gouly 5788b783ac [OpenCL] Introduce ReadPipeType and WritePipeType.
This allows Sema to diagnose passing a read_only pipe to a
write_only pipe argument.

llvm-svn: 287343
2016-11-18 14:10:54 +00:00
Vedant Kumar 4a76350864 [test] Remove implicit deps on libLTO.dylib on Darwin (NFC)
This un-breaks the `check-clang` target.

llvm-svn: 286512
2016-11-10 22:31:06 +00:00
Alex Lorenz a5430bd5d6 Add -Wduplicate-protocol for existing diagnostic
Expose a warning flag for warn_duplicate_protocol_def. This allows control
over the severity of duplicate protocol definitions.

For example -Werror=duplicate-protocol or
#pragma clang diagnostic ignored "-Wduplicate-protocol".

Patch provided by Dave Lee!

Differential Revision: https://reviews.llvm.org/D26406

llvm-svn: 286487
2016-11-10 18:30:26 +00:00
Serge Pavlov a67a4d2f3c Make output of -ast-print a valid C++ code.
Output generated by option -ast-print looks like C/C++ code, and it
really is for plain C. For C++ the produced output was not valid C++
code, but the differences were small. With this change the output
is fixed and can be compiled. Tests are changed so that output produced
by -ast-print is compiled again with the same flags and both outputs are
compared.

Option -ast-print is extensively used in clang tests but it itself
was tested poorly, existing tests only checked that compiler did not
crash. There are unit tests in file DeclPrinterTest.cpp, but they test
only terse output mode.

Differential Revision: https://reviews.llvm.org/D26452

llvm-svn: 286439
2016-11-10 08:49:37 +00:00
Alex Lorenz ddbe0f5138 [AST] Dump dependent scope member expression with its member name
llvm-svn: 286365
2016-11-09 14:02:18 +00:00
Richard Smith e0ab873a84 PR30831: Teach template type diffing to cope with TemplateSpecializationTypes
that desugar to non-TSTs (such as injected-class-names).

llvm-svn: 285437
2016-10-28 19:54:43 +00:00
Richard Smith 5e9746f520 DR583, DR1512: Implement a rewrite to C++'s 'composite pointer type' rules.
This has two significant effects:

1) Direct relational comparisons between null pointer constants (0 and nullopt)
   and pointers are now ill-formed. This was always the case for C, and it
   appears that C++ only ever permitted by accident. For instance, cases like
     nullptr < &a
   are now rejected.

2) Comparisons and conditional operators between differently-cv-qualified
   pointer types now work, and produce a composite type that both source
   pointer types can convert to (when possible). For instance, comparison
   between 'int **' and 'const int **' is now valid, and uses an intermediate
   type of 'const int *const *'.

Clang previously supported #2 as an extension.

We do not accept the cases in #1 as an extension. I've tested a fair amount of
code to check that this doesn't break it, but if it turns out that someone is
relying on this, we can easily add it back as an extension.

This is a re-commit of r284800.

llvm-svn: 284890
2016-10-21 22:00:42 +00:00
Renato Golin 41189656ed Revert "DR583, DR1512: Implement a rewrite to C++'s 'composite pointer type' rules."
This reverts commit r284800, as it failed all ARM/AArch64 bots.

llvm-svn: 284811
2016-10-21 08:03:49 +00:00
Richard Smith 0c1c53e3fa DR583, DR1512: Implement a rewrite to C++'s 'composite pointer type' rules.
This has two significant effects:

1) Direct relational comparisons between null pointer constants (0 and nullopt)
   and pointers are now ill-formed. This was always the case for C, and it
   appears that C++ only ever permitted by accident. For instance, cases like
     nullptr < &a
   are now rejected.

2) Comparisons and conditional operators between differently-cv-qualified
   pointer types now work, and produce a composite type that both source
   pointer types can convert to (when possible). For instance, comparison
   between 'int **' and 'const int **' is now valid, and uses an intermediate
   type of 'const int *const *'.

Clang previously supported #2 as an extension.

We do not accept the cases in #1 as an extension. I've tested a fair amount of
code to check that this doesn't break it, but if it turns out that someone is
relying on this, we can easily add it back as an extension.

llvm-svn: 284800
2016-10-21 02:36:37 +00:00
Matthias Braun ee43f21296 Put new warning in a diagnostic group.
The warning I added in r282426 should be a diagnostic group.

llvm-svn: 282557
2016-09-27 23:44:38 +00:00
Matthias Braun abb6eea19c CC1: Add -save-stats option
This option behaves in a similar spirit as -save-temps and writes
internal llvm statistics in json format to a file.

Differential Revision: https://reviews.llvm.org/D24820

llvm-svn: 282426
2016-09-26 18:53:34 +00:00
Akira Hatanaka 3d17313734 [tablegen] Check that an optional IdentifierArgument of an attribute is
provided before trying to print it.

This fixes a segfault that occurs when function printPretty generated by
tablegen tries to print an optional argument of attribute
objc_bridge_related.

rdar://problem/28155469

llvm-svn: 281132
2016-09-10 03:29:43 +00:00
James Molloy 75b1fb9b9e Attempt to pacify buildbots after r280217
These clang tests check diagnostics from the backend by giving it an unvectorizable loop. This loop is now vectorized :/

Make it really unvectorizable by making it unprofitable to ifconvert.

llvm-svn: 280220
2016-08-31 11:01:41 +00:00
Yaxun Liu 9385680c24 [OpenCL] AMDGPU: add support of cl_khr_subgroups
Patch by Aaron En Ye Shi.

Differential Revision: https://reviews.llvm.org/D23573

llvm-svn: 278972
2016-08-17 20:39:49 +00:00
Yaxun Liu 3317446301 [OpenCL] AMDGPU: Add extensions cl_amd_media_ops and cl_amd_media_ops2
Differential Revision: https://reviews.llvm.org/D23322

llvm-svn: 278851
2016-08-16 20:49:49 +00:00
Richard Trieu e1a6a7d6d3 Fix crash in template type diffing.
When the type being diffed is a type alias, and the orginal type is not a
templated type, then there will be no unsugared TemplateSpecializationType.
When this happens, exit early from the constructor.  Also add assertions to
the other iterator accessor to prevent the iterator from being used.

llvm-svn: 277797
2016-08-05 03:16:36 +00:00
Yaxun Liu 3f9e91286e [OpenCL] Add extension cl_khr_mipmap_image to clang
Adding extension cl_khr_mipmap_image to clang's OpenCL Extensions and initiated inside AMDGPU Target.

Patch by Aaron En Ye Shi.

Differential Revision: https://reviews.llvm.org/D22637

llvm-svn: 277181
2016-07-29 17:52:34 +00:00
Richard Smith a547eb27fa P0305R0: Semantic analysis and code generation for C++17 init-statement for 'if' and 'switch':
if (stmt; condition) { ... }

Patch by Anton Bikineev! Some minor formatting and comment tweets by me.

llvm-svn: 275350
2016-07-14 00:11:03 +00:00
Manman Ren ccf25bbf3f AvailabilityAttr: we accept "macos" as the platform name.
We continue accepting "macosx" but canonicalize it to "macos", When emitting
diagnostics, we use "macOS" instead of "OS X".

The PlatformName in TargetInfo is changed from "macosx" to "macos" so we can
directly compare the Platform in AvailabilityAttr with the PlatformName
in TargetInfo.

rdar://26795172
rdar://26800775

llvm-svn: 274064
2016-06-28 20:55:30 +00:00
Matt Arsenault 4deb4ed21e Update for DiagnosticInfoStackSize changes
llvm-svn: 273178
2016-06-20 18:13:09 +00:00
Jan Vesely 9674bd4f97 NVPTX: Add supported CL features
Fixes libclc compilation broken by r269670

Reviewers: jholewinsky

Differential Revision: http://reviews.llvm.org/D20389

llvm-svn: 273031
2016-06-17 19:02:14 +00:00
Jan Vesely 211ba785d9 AMDGPU: Fix supported CL features
Reviewers: arsenm

Differential Revision: http://reviews.llvm.org/D20388

llvm-svn: 272986
2016-06-17 02:25:03 +00:00
Olivier Goffart 119dad63bc Keep invalid functions as part of the AST
Differential Revision: http://reviews.llvm.org/D19764

llvm-svn: 272962
2016-06-16 21:39:55 +00:00
Adam Nemet 2de463ece3 Add loop pragma for Loop Distribution
Summary:
This is similar to other loop pragmas like 'vectorize'.  Currently it
only has state values: distribute(enable) and distribute(disable).  When
one of these is specified the corresponding loop metadata is generated:

  !{!"llvm.loop.distribute.enable", i1 true/false}

As a result, loop distribution will be attempted on the loop even if
Loop Distribution in not enabled globally.  Analogously, with 'disable'
distribution can be turned off for an individual loop even when the pass
is otherwise enabled.

There are some slight differences compared to the existing loop pragmas.

1. There is no 'assume_safety' variant which makes its handling slightly
different from 'vectorize'/'interleave'.

2. Unlike the existing loop pragmas, it does not have a corresponding
numeric pragma like 'vectorize' -> 'vectorize_width'.  So for the
consistency checks in CheckForIncompatibleAttributes we don't need to
check it against other pragmas.  We just need to check for duplicates of
the same pragma.

Reviewers: rsmith, dexonsmith, aaron.ballman

Subscribers: bob.wilson, cfe-commits, hfinkel

Differential Revision: http://reviews.llvm.org/D19403

llvm-svn: 272656
2016-06-14 12:04:26 +00:00
Richard Trieu 4b259c8add Fix a crash in the AST dumper.
Boxed expressions in a template context may have a null method decl.  If so,
don't try to access the selector.

llvm-svn: 272318
2016-06-09 22:03:04 +00:00
Hal Finkel c07e19b2c1 Add a loop's debug location to its llvm.loop metadata
Getting accurate locations for loops is important, because those locations are
used by the frontend to generate optimization remarks. Currently, optimization
remarks for loops often appear on the wrong line, often the first line of the
loop body instead of the loop itself. This is confusing because that line might
itself be another loop, or might be somewhere else completely if the body was
an inlined function call. This happens because of the way we find the loop's
starting location. First, we look for a preheader, and if we find one, and its
terminator has a debug location, then we use that. Otherwise, we look for a
location on an instruction in the loop header.

The fallback heuristic is not bad, but will almost always find the beginning of
the body, and not the loop statement itself. The preheader location search
often fails because there's often not a preheader, and even when there is a
preheader, depending on how it was formed, it sometimes carries the location of
some preceeding code.

I don't see any good theoretical way to fix this problem. On the other hand,
this seems like a straightforward solution: Put the debug location in the
loop's llvm.loop metadata. When emitting debug information, this commit causes
us to add the debug location as an operand to each loop's llvm.loop metadata.
Thus, we now generate this metadata for all loops (not just loops with
optimization hints) when we're otherwise generating debug information.

The remark test case changes depend on the companion LLVM commit r270771.

llvm-svn: 270772
2016-05-25 21:53:24 +00:00
Yaxun Liu 39cf40f6b4 [OpenCL] Add supported OpenCL extensions to target info.
Add supported OpenCL extensions to target info. It serves as default values to save the users of the burden setting each supported extensions and optional core features in command line.

Re-commit after fixing build error due to missing override attribute.

Differential Revision: http://reviews.llvm.org/D19484

llvm-svn: 269670
2016-05-16 17:06:34 +00:00
Adrian McCarthy e4b26fc7a7 Get default -fms-compatibility-version from cl.exe's version
-fms-compatibility-version was defaulting to 18 (VS 2013), which is a pain if your environment is pointing to version 19 (VS 2015) libraries.

If cl.exe can be found, this patch uses its version number as the default instead. It re-uses the existing code to find the Visual Studio binaries folder and WinAPI methods to check its version. You can still explicitly specify a compatibility version on the command line. If you don't have cl.exe, this should be a no-op and you'll get the old default of 18.

This affected the tests, which assumed that if you didn't specific a version, that it would default to 18, but this won't be true for all machines. So a couple test cases had to be eliminated and a couple others had to be tweaked to allow for various outputs.

Addresses: https://llvm.org/bugs/show_bug.cgi?id=27215

Differential Revision: http://reviews.llvm.org/D20136

llvm-svn: 269515
2016-05-13 23:20:11 +00:00
Yaxun Liu fa1df45c0d Revert "[OpenCL] Add supported OpenCL extensions to target info."
Revert r269431 due to build failure caused by warning msg:

  llvm/tools/clang/lib/Basic/Targets.cpp:2090:9: error: 'setSupportedOpenCLOpts' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-override]
   void setSupportedOpenCLOpts() {

llvm-svn: 269435
2016-05-13 17:16:26 +00:00
Yaxun Liu 64936ce91d [OpenCL] Add supported OpenCL extensions to target info.
Add supported OpenCL extensions to target info. It serves as default values to save the users of the burden setting each supported extensions and optional core features in command line.

Differential Revision: http://reviews.llvm.org/D19484

llvm-svn: 269431
2016-05-13 15:44:37 +00:00
Xiuli Pan 2d12e65b6b [OpenCL] Fix pipe type dump.
Summary:
Fix the dump of PipeType.
Now we will have "pipe int" and element type.

Reviewers: yaxunl, Anastasia

Subscribers: cfe-commits, bader

Differential Revision: http://reviews.llvm.org/D19524

llvm-svn: 268364
2016-05-03 05:37:07 +00:00
Bruno Cardoso Lopes 34c549ea02 Revert "[Driver] Quote clang full version in dwarf producer when invoking cc1as"
This reverts commit r264813 / 6484b95d634f53dd929c75265ef3c4decf397584.

While using it in the shell is fine, this a problem when cc1as is
invoked directly by the driver because single quoting the clang full
version makes cc1as write out the version with the quotes in the final
binary.

If the user wants to copy-n-pastable output, it could use either -###
or CC_PRINT_OPTIONS=1 clang -v ...

llvm-svn: 268297
2016-05-02 20:20:49 +00:00
Mehdi Amini 5655795bf4 Make thinlto clang test more robust against LLVM changes.
We should just test the effect of the clang level option here, i.e.
that a summary is correctly emitted with -flto=thin

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 267321
2016-04-24 03:44:55 +00:00
Richard Trieu a7564d7d66 Fix Clang crash with template type diffing.
Fixes https://llvm.org/bugs/show_bug.cgi?id=27129 which is crash involving type
aliases and template type diffing.  Template arguments for type aliases and
template arguments for the underlying desugared type may not have one-to-one
relations, which could mess us the attempt to get more information from the
desugared type.  For type aliases, ignore the iterator over the desugared type.

llvm-svn: 264940
2016-03-30 22:23:00 +00:00
Bruno Cardoso Lopes b741e10402 [Driver] Quote clang full version in dwarf producer when invoking cc1as
Convenience to allow easy copy-n-paste from clang -v output when
reproducing cc1as comandline.

rdar://problem/23959295

llvm-svn: 264813
2016-03-30 00:25:57 +00:00
Nico Weber dde29407c4 Fix typo in test from r264210, sigh.
(The test passes both with and without this change, but it's confusing without
it.)

llvm-svn: 264211
2016-03-23 23:01:38 +00:00
Nico Weber fbe3adf10e clang-cl: With -fmsc-version=1900, use MSVS2015 diag formatting.
Remove tests that have neither a triple nor an explicit -fmsc-version flag,
since in the absence of an -fmsc-version flag, the implicit value of the flag
is 17 (MSVC2013) with MSVC triples but 0 (not set) for other triples, and
the default triple is platform dependent.

This relands r263974 with a test fix.

llvm-svn: 264210
2016-03-23 22:57:55 +00:00
NAKAMURA Takumi 8794f98e21 Revert r263974, "clang-cl: With -fmsc-version=1900, use MSVS2015 diag formatting."
It seems the test wouldn't expect if default target is *-win32.

llvm-svn: 264007
2016-03-21 23:51:50 +00:00
Nico Weber 920341c7a9 clang-cl: With -fmsc-version=1900, use MSVS2015 diag formatting.
llvm-svn: 263974
2016-03-21 19:44:18 +00:00
Teresa Johnson f39a70cf32 Update test case for llvm summary format changes in D17592.
llvm-svn: 263276
2016-03-11 18:52:42 +00:00
Aaron Ballman 22b5a4d597 Speculative fix for this test case (the test doesn't run on my typical build environment).
llvm-svn: 263034
2016-03-09 17:34:16 +00:00
Saleem Abdulrasool ac25f2c073 Misc: add a test for TargetParser usage
Ensure that an invalid value passed to target parser does not cause an assertion
in +Asserts builds.

Supporting test for PR26839.

llvm-svn: 262780
2016-03-05 21:12:33 +00:00
David Majnemer 38a3dbdcbf Don't crash w/ a diagnostic range containing a null byte
We prematurely ended the line at the null byte which caused us to crash
down stream because we tried to reason about columns beyond the end of
the line.

llvm-svn: 261171
2016-02-17 22:37:45 +00:00
Steven Watanabe e43ae19b31 Fix the ASTPrinter output for ascii char literals >127.
Differential Revision: http://reviews.llvm.org/D17206

llvm-svn: 260795
2016-02-13 02:31:28 +00:00
Oliver Stannard 9181785a0c Add backend dignostic printer for unsupported features
Re-commit of r258950 after fixing layering violation.

The related LLVM patch adds a backend diagnostic type for reporting
unsupported features, this adds a printer for them to clang.

In the case where debug location information is not available, I've
changed the printer to report the location as the first line of the
function, rather than the closing brace, as the latter does not give the
user any information. This also affects optimisation remarks.

llvm-svn: 259499
2016-02-02 13:52:52 +00:00
Richard Trieu 12074509d7 Template Type Diffing change
When all the arguments of a template are elided, print "A<...>" instead of
"A<[2 * ...]>".  Also remove comment fragment that means nothing.

llvm-svn: 259445
2016-02-02 00:36:59 +00:00
Oliver Stannard 92d4c328d1 Revert r259036, it introduces a cyclic library dependency
llvm-svn: 259043
2016-01-28 13:09:49 +00:00
Oliver Stannard 7a964feccb Add backend dignostic printer for unsupported features
Re-commit of r258950 after fixing layering violation.

Add backend dignostic printer for unsupported features

The related LLVM patch adds a backend diagnostic type for reporting
unsupported features, this adds a printer for them to clang.

In the case where debug location information is not available, I've
changed the printer to report the location as the first line of the
function, rather than the closing brace, as the latter does not give the
user any information. This also affects optimisation remarks.

Differential Revision: http://reviews.llvm.org/D16591

llvm-svn: 259036
2016-01-28 10:07:34 +00:00
NAKAMURA Takumi 628a7a0aef Revert r258951 (and r258950), "Refactor backend diagnostics for unsupported features"
It broke layering violation in LLVMIR.

clang r258950 "Add backend dignostic printer for unsupported features"
llvm  r258951 "Refactor backend diagnostics for unsupported features"

llvm-svn: 259016
2016-01-28 04:41:32 +00:00
Oliver Stannard 5e03a4b837 Add backend dignostic printer for unsupported features
The related LLVM patch adds a backend diagnostic type for reporting
unsupported features, this adds a printer for them to clang.

In the case where debug location information is not available, I've
changed the printer to report the location as the first line of the
function, rather than the closing brace, as the latter does not give the
user any information. This also affects optimisation remarks.

Differential Revision: http://reviews.llvm.org/D16591

llvm-svn: 258950
2016-01-27 17:30:28 +00:00
Ehsan Akhgari d851833c9a [MSVC Compat] Only warn for unknown clang-cl arguments
Summary:
MSVC's driver accepts all unknown arguments but warns about them.  clang
by default rejects all unknown arguments.  This causes issues
specifically with build systems such as autoconf which liberally pass
things such as $LDFLAGS to the compiler and expect everything to work.
This patch teaches clang-cl to ignore unknown driver arguments.

Reviewers: rnk

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D16511

llvm-svn: 258720
2016-01-25 21:14:52 +00:00
Richard Trieu 2331c8bdd3 Fixing more issues with template type diffing
1) Print qualifiers for templates with zero arguments
2) Add a few more tests for the template type diffing refactoring.
Specifically, PR24587 has been fixed and has a test case from
http://reviews.llvm.org/D15384
3) Adds asserts to check the DiffTree is in correct state when moving nodes
4) Rename the field FromType and ToType since it is heavily used within
member functions.

llvm-svn: 257870
2016-01-15 05:48:38 +00:00
Richard Trieu 9213ce559a Add new diff modes to template type diffing.
Remove an old assertion that does not hold.  It is possible for a template
argument to be a declaration in one instantiation and an integer in another.
Create two new diff kinds for these (decl vs int and int vs decl).

llvm-svn: 257869
2016-01-15 05:01:53 +00:00
Richard Trieu d5c7378b9e Save the integer type for integral template arguments.
Save the integer type when diffing integers in template type diffing.  When
integers are different sizes, print out the type along with the integer value.
Also with the type information, print true and false instead of 1 and 0 for
boolean values.

llvm-svn: 257861
2016-01-15 02:55:17 +00:00
Richard Trieu 2c22a86f94 Make template type diffing use the new desguared iterator.
If available, use the canonical template argument to fill in information for
template type diffing instead of attempting to special case and evaluate Expr's
for the value.  Since those are the values used in template instantiation,
we don't have to worry about difference between our evaluator and theirs.  Also
move the nullptr template arguments from DiffKind::Expression to
DiffKind::Declaration and allow DiffKind::Declaration to set an Expr.  The only
effect that should result is that a named nullptr will show up as
'ptr aka nullptr' in diagnostics.

llvm-svn: 257853
2016-01-15 01:08:56 +00:00
Richard Trieu 14714c4181 Refactor template type diffing
1) Instead of using pairs of From/To* fields, combine fields into a struct
TemplateArgInfo and have two in each DiffNode.
2) Use default initialization in DiffNode so that the constructor shows the
only field that is initialized differently on construction.
3) Use Set and Get functions per each DiffKind to make sure all fields for the
diff is set.  In one case, the Expr fields were not set.
4) Don't print boolean literals for boolean template arguments.  This prevents
printing 'false aka 0'

Only #3 has a functional change, which is reflected in the test change.

llvm-svn: 257831
2016-01-14 22:56:39 +00:00
Richard Smith ba3a4f917f Improve AST dumping:
1) When dumping a declaration that declares a name for a type, also dump the named type.
 2) Add a #pragma clang __debug dump X, that dumps the lookup results for X in
    the current context.

llvm-svn: 257529
2016-01-12 21:59:26 +00:00
Aaron Ballman 9a17c85454 Properly track that a character literal is UTF-8, and pretty print the prefix properly.
llvm-svn: 257097
2016-01-07 20:59:26 +00:00
Reid Kleckner da30cff9ef [diagnostics] Avoid crashes while printing macro backtraces
When attempting to map a source into a given level of macro expansion,
this code was ignoring the possibility that the start and end of the
range might take wildly different paths through the tree of macro
expansions. It was assuming that the begin spelling location would
always precede the end spelling location, which is false. A macro can
easily transpose its arguments.

This also fixes a related issue where there are extra macro arguments
between the begin location and the end location. In this situation, we
now highlight the entire macro invocation.

Pair programmed with Richard Smith.

Fixes PR12818.

llvm-svn: 254981
2015-12-08 01:08:09 +00:00
Aaron Ballman 415c414bf2 Do not crash when dumping the objc_bridge_related attribute when its optional arguments are not supplied.
Patch thanks to Joe Ranieri!

llvm-svn: 254303
2015-11-30 15:25:34 +00:00
Craig Topper 7f5ff2175f Use %select to merge similar diagnostics. NFC
llvm-svn: 253119
2015-11-14 02:09:55 +00:00
Teresa Johnson 945bc50f21 Recommit "Clang support for -flto=thin."
This recommits r250398 with fixes to the tests for bot failures.

Add "-target x86_64-unknown-linux" to the clang invocations that
check for the gold plugin.

llvm-svn: 250455
2015-10-15 20:35:53 +00:00
Teresa Johnson fca505c674 Revert "Clang support for -flto=thin." (bot failures)
Rolling this back for now since there are a couple of bot failures on
the new tests I added, and I won't have a chance to look at them in detail
until later this afternoon. I think the new tests need some restrictions on
having the gold plugin available.

This reverts commit r250398.

llvm-svn: 250402
2015-10-15 13:41:51 +00:00
Teresa Johnson 31b2354929 Clang support for -flto=thin.
Summary:
Add clang support for -flto=thin option, which is used to set the
EmitFunctionSummary code gen option on compiles.

Add -flto=full as an alias to the existing -flto.

Add tests to check for proper overriding of -flto variants on the
command line, and convert grep tests to FileCheck.

Reviewers: dexonsmith, joker.eph

Subscribers: davidxl, cfe-commits

Differential Revision: http://reviews.llvm.org/D11908

llvm-svn: 250398
2015-10-15 13:08:13 +00:00
Richard Smith 2c072af95e Add warning flags for #include_next and some nearby warnings.
llvm-svn: 250105
2015-10-12 21:05:54 +00:00
Alexey Bataev 6d45532961 [ATTR] Automatic line feed after pragma-like attribute.
Automatically insert line feed after pretty printing of all pragma-like attributes + fix printing of pragma-like pragmas on declarations.
Differential Revision: http://reviews.llvm.org/D13546

llvm-svn: 250017
2015-10-12 06:59:48 +00:00
Olivier Goffart 122993bfd6 Keep the IfStmt node even if the condition is invalid
This is important to keep the information in IDE or other tools
even if the code contains a few errors

llvm-svn: 249982
2015-10-11 17:27:29 +00:00
Douglas Katzman 3459ce2e5e Stop messing with the 'g' group of options in CompilerInvocation.
With this change, most 'g' options are rejected by CompilerInvocation.
They remain only as Driver options. The new way to request debug info
from cc1 is with "-debug-info-kind={line-tables-only|limited|standalone}"
and "-dwarf-version={2|3|4}". In the absence of a command-line option
to specify Dwarf version, the Toolchain decides it, rather than placing
Toolchain-specific logic in CompilerInvocation.

Also fix a bug in the Windows compatibility argument parsing
in which the "rightmost argument wins" principle failed.

Differential Revision: http://reviews.llvm.org/D13221

llvm-svn: 249655
2015-10-08 04:24:12 +00:00
Richard Smith a91de375f2 Promote a warning on ill-formed code (redeclaration missing an exception
specification) to an error. No compiler other than Clang seems to allow this,
and it doesn't seem like a useful thing to accept as an extension in general.

The current behavior was added for PR5957, where the problem was specifically
related to mismatches of the exception specification on the implicitly-declared
global operator new and delete. To retain that workaround, we downgrade the
error to an ExtWarn when the declaration is of a replaceable global allocation
function.

Now that this is an error, stop trying (and failing) to recover from a missing
computed noexcept specification. That recovery didn't work, and led to crashes
in code like the added testcase.

llvm-svn: 248867
2015-09-30 00:48:50 +00:00
Richard Trieu c3096249c1 Improve the printing of ranges when macros are involved.
Trace the ranges through the macro backtrace better.  This allows better
range highlighting through all levels of the macro bracktrace.  Also some
improvements to backtrace printer for omitting different backtraces.

Patch by Zhengkai Wu.

Differential Revision: http://reviews.llvm.org/D12379

llvm-svn: 248454
2015-09-24 01:21:01 +00:00
Rachel Craik 022bdc7d73 C11 _Bool bitfield diagnostic
Summary: Implement DR262 (for C). This patch will mainly affect bitfields of type _Bool

Reviewers: fraggamuffin, rsmith

Subscribers: hubert.reinterpretcast, cfe-commits

Differential Revision: http://reviews.llvm.org/D10018

llvm-svn: 247618
2015-09-14 21:27:36 +00:00
Ed Schouten e8eab68b55 Put ext_implicit_lib_function_decl in ImplicitFunctionDeclare.
If we build with -Werror=implicit-function-declaration, only implicit
function declarations of non-library functions throw compiler errors.
For library functions, we only produce a warning. There is no way to
promote both of these cases to an error without promoting other
warnings.

It makes little sense to introduce an additional compiler flag just to
control this specific warning. In my opinion it should just be part of
the same group.

llvm-svn: 246857
2015-09-04 16:07:39 +00:00
Richard Trieu a1d7ece05c Fix macro backtrace printing.
Sometimes, a macro that expands to another macro name will not be printed in
the macro backtrace.  This patch finds the missed macro expansions and prints
them.  Fixes PR16799

llvm-svn: 246237
2015-08-27 23:38:45 +00:00
Richard Trieu ecd36ee80b Stop printing macro backtraces that don't help diagnostics.
When displaying the macro backtrace, ignore some of the backtraces that do not
provide extra information to the diagnostic.  Typically, if the problem is
entirely contained within a macro argument, the macro expansion is often not
needed.  Also take into account SourceRange's attached to the diagnostic when
selecting which backtraces to ignore.  Two previous test cases have also been
updated.

Patch by Zhengkai Wu, with minor formatting fixes.

Differential Revision: http://reviews.llvm.org/D11778

llvm-svn: 244788
2015-08-12 18:24:59 +00:00
Argyrios Kyrtzidis e26aea5b29 [Frontend] Fix crash when serializing diagnostics with really long text.
rdar://21896690

llvm-svn: 244245
2015-08-06 18:46:36 +00:00
Richard Smith 9b88a4cdf4 [modules] Add an assert for redeclarations that we never added to their redecl
chain and fix the cases where it fires.

 * Handle the __va_list_tag as a predefined decl. Previously we failed to merge
   sometimes it because it's not visible to name lookup. (In passing, remove
   redundant __va_list_tag typedefs that we were creating for some ABIs. These
   didn't affect the mangling or representation of the type.)

 * For Decls derived from Redeclarable that are not in fact redeclarable
   (implicit params, function params, ObjC type parameters), remove them from
   the list of expected redeclarable decls.

llvm-svn: 243259
2015-07-27 05:40:23 +00:00
Steven Wu ae480ecaec Fix the cc1as crash when it outputs assembly
In clang cc1as_main, when the output file type is “asm”, AsmStreamer
owns a formatted_raw_ostream which has a reference to FDOS
(raw_ostream), so AsmStreamer must be closed before FDOS is closed.

llvm-svn: 243085
2015-07-24 02:12:43 +00:00
Nikola Smiljanic fa00728f58 PR10405 - Desugar FunctionType and TemplateSpecializationType if any type that appears inside needs to be desugared.
llvm-svn: 242371
2015-07-16 01:06:17 +00:00
Yaron Keren b0b4132bcc Erase REQUIRES: shell-preserves-root from remaining tests, see r242312.þ
llvm-svn: 242323
2015-07-15 20:04:18 +00:00
David Majnemer c7ee97d696 Reenable Misc/interpreter.c as r239388 correctly handles such targets
llvm-svn: 239389
2015-06-09 06:33:13 +00:00
NAKAMURA Takumi b21e942ac1 Disable clang/test/Misc/interpreter.c, for now, since r239273 mishandled *-msvc-elf.
llvm-svn: 239387
2015-06-09 06:27:21 +00:00
Richard Trieu d3967635bc Fix typo from r237482. "to reference of type" --> "to reference to type"
llvm-svn: 237507
2015-05-16 01:39:39 +00:00
Richard Trieu f956a49e6d When emitting a dropped qualifier error, show which qualifiers are dropped.
llvm-svn: 237505
2015-05-16 01:27:03 +00:00
Richard Trieu 0ff51f39de Reverse the order of types in the reference dropping qualifiers error.
The error has the form ... 'int' ... 'const int' ... dropped qualifiers.  At
first glance, it appears that the const qualifier is added.  Reverse the types
so that the second type is less qualified than the first.

llvm-svn: 237482
2015-05-15 22:07:49 +00:00
Diego Novillo 86f884ed46 Fix BackendConsumer::EmitOptimizationMessage()
Patch from Geoff Berry <gberry@codeaurora.org>

Fix BackendConsumer::EmitOptimizationMessage() to check if the
DiagnosticInfoOptimizationBase object has a valid location before
calling getLocation() to avoid dereferencing a null pointer inside
getLocation() when no debug info is present.

llvm-svn: 236898
2015-05-08 20:59:56 +00:00
Aaron Ballman 8aee642909 Generate a diagnostic when a catch handler cannot execute due to class hierarchy inversion with regards to other catch handlers for the same block.
llvm-svn: 234375
2015-04-08 00:05:29 +00:00
Eli Bendersky 5f4d76efd3 Record correct source range for defaulted/deleted members.
Fixes https://llvm.org/bugs/show_bug.cgi?id=20744

struct A {

A() = default;
};

Previously the source range of the declaration of A ended at the ')'. It should
include the '= default' part as well. The same for '= delete'.

Note: this will break one of the clang-tidy fixers, which is going to be
addessed in a follow-up patch.

Differential Revision: http://reviews.llvm.org/D8465

llvm-svn: 233028
2015-03-23 21:43:28 +00:00
Reid Kleckner 461c0c6934 Fix -ast-dump of dependent new and delete exprs
llvm-svn: 232748
2015-03-19 18:47:47 +00:00