Commit Graph

511 Commits

Author SHA1 Message Date
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
Reid Kleckner 5c682bc4b8 Add -ast-dump support for new and delete expressions to help figure out which operator got selected
llvm-svn: 232740
2015-03-19 18:09:25 +00:00
Sanjoy Das edadecbe66 Fix test case.
r230921 broke backend-optimization-failure.cpp: after
r230921, LLVM no longer emits an expression to compute 'Length - 1'
and this perturbs LoopSimplify enough to emit the warning on line 10
instead of line 9.  This is a review request to fix the test case once
I re-land r230921.

llvm-svn: 231020
2015-03-02 21:47:47 +00:00
Richard Trieu 555c9673fd Update assumption in template diffing about integer template arguments.
Fix for PR22017.  Integer template arguments are automatically bit extended to
the size of the integer type.  In template diffing, evaluated expressions were
not having their results extending, leading to comparing two APSInt's with
different widths.  Apply the proper bit extending when evaluating template
arguments.  This mainly affected bool template arguments.

llvm-svn: 230603
2015-02-26 02:40:48 +00:00
Aaron Ballman 8a417bd97b Partial revert of r229336; this wasn't intended to go in.
llvm-svn: 229338
2015-02-15 22:18:04 +00:00
Aaron Ballman 673476684e Removing LLVM_EXPLICIT, as MSVC 2012 was the last reason for requiring the macro. NFC; Clang edition.
llvm-svn: 229336
2015-02-15 22:00:28 +00:00
Richard Smith 420fa12dfd Improve the "braces around scalar init" warning to determine whether to warn
based on whether "redundant" braces are ever reasonable as part of the
initialization of the entity, rather than whether the initialization is
"top-level". In passing, add a warning flag for it.

llvm-svn: 228896
2015-02-12 01:50:05 +00:00
Richard Trieu 15b66535ca When checking the template argument list, use a copy of that list for changes
and only update the orginal list on a valid arugment list.  When checking an
individual expression template argument, and conversions are required, update
the expression in the template argument.  Since template arguments are
speculatively checked, the copying of the template argument list prevents
updating the template arguments when the list does not match the template.

Additionally, clean up the integer checking code in the template diffing code.
The code performs unneccessary conversions from APSInt to APInt.

Fixes PR21758.

This essentially reverts r224770 to recommits r224667 and r224668 with extra
changes to prevent the template instantiation problems seen in PR22006.
A test to catch the discovered problem is also added.

llvm-svn: 226983
2015-01-24 02:48:32 +00:00
David Majnemer 2dc8146643 Sema: Variable definitions cannot be __attribute__((alias))
Things that are OK:
  extern int var1 __attribute((alias("v1")));
  static int var2 __attribute((alias("v2")));

Things that are not OK:
  int var3 __attribute((alias("v3")));
  extern int var4 __attribute((alias("v4"))) = 4;

We choose to accpet:
  struct S { static int var5 __attribute((alias("v5"))); };

  This code causes assertion failues in GCC 4.8 and ICC 13.0.1, we have
  no reason to reject it.

This partially fixes PR22217.

llvm-svn: 226436
2015-01-19 09:00:28 +00:00
Richard Trieu 8ac1419dfd Attempt to fix test from r225423 to get build bots green.
llvm-svn: 225426
2015-01-08 02:40:08 +00:00
Richard Trieu b3b8bb0029 When the diagnostic text is simply "%0", sanitize the string for any
unprintable characters.  Fixes PR22048.

llvm-svn: 225423
2015-01-08 01:27:03 +00:00
Nico Weber 49e6bc024d Remove an assert that's not true on invalid code.
r185773 added an assert that checked that a CXXUnresolvedConstructExpr either
has a valid rparen, or exactly one argument.  This doesn't have to be true for
invalid inputs.  Convert the assert to an if, and add a test for this case.

Found by SLi's afl bot.

llvm-svn: 225140
2015-01-04 20:32:12 +00:00
Rafael Espindola 43eba818cd This reverts commit r224668 and r224667.
r224667 broke bootstrap on Fedora 20 X86_64 (at least).

See pr22006 for the details.

r224668 depends on r224667.

llvm-svn: 224770
2014-12-23 15:57:12 +00:00
Richard Trieu d787e8dc9d Fix for PR21758
When a non-type template argument expression needs a conversion to change it
into the argument type, preserve that information by remaking the
TemplateArgument with an expression that has those conversions.  Also a small
fix to template type diffing to handle the extra conversions in some cases.

llvm-svn: 224667
2014-12-20 02:42:08 +00:00
Fariborz Jahanian c10fe600a2 Objective-C. Provide group name for warning
on multiple selector names found during lookup.
rdar://19265296

llvm-svn: 224536
2014-12-18 19:41:11 +00:00
Hans Wennborg 76b005398d ASTDumper: print whether a function is constexpr
llvm-svn: 223538
2014-12-05 22:38:57 +00:00
Fariborz Jahanian 334becf46a Another warning with no group name bites the dust.
rdar://19116886

llvm-svn: 223168
2014-12-02 22:42:52 +00:00
Richard Smith f7514454a7 Refactor tree printing in AST dumping.
Instead of manually maintaining a flag indicating whether we're about to print
out the last child of the parent node (to determine whether we print "`" or
"|"), capture a callable to print that child and defer printing it until we
either see a next child or finish the parent.

No functionality change intended.

llvm-svn: 220930
2014-10-30 21:02:37 +00:00
NAKAMURA Takumi 729be14435 Prune CRLF.
llvm-svn: 220678
2014-10-27 12:37:26 +00:00
Justin Bogner 5a6a2fcdee Driver: Include driver diagnostics when we --serialize-diagnostics
Currently, when --serialize-diagnostics is passed this only includes
the diagnostics from clang -cc1, and driver diagnostics are
dropped. This causes issues for tools that use the serialized
diagnostics, since stderr is lost and these diagnostics aren't seen at
all.

We handle this by merging the diagnostics from the CC1 process and the
driver diagnostics into a single file when the driver invokes CC1.

Fixes rdar://problem/10585062

llvm-svn: 220525
2014-10-23 22:20:11 +00:00
David Majnemer 51c8b3e9db Basic: Add ext_delete_void_ptr_operand to -Wdelete-incomplete
This fixes PR21340.

llvm-svn: 220442
2014-10-22 23:03:58 +00:00
Aaron Ballman 260995b86b Adding attributes to the IndirectFieldDecl that we generate for anonymous struct/union fields. This fixes PR20930.
llvm-svn: 219807
2014-10-15 16:58:18 +00:00
Tyler Nowicki c724a83e20 Allow constant expressions in pragma loop hints.
Previously loop hints such as #pragma loop vectorize_width(#) required a constant. This patch allows a constant expression to be used as well. Such as a non-type template parameter or an expression (2 * c + 1).

Reviewed by Richard Smith

llvm-svn: 219589
2014-10-12 20:46:07 +00:00
Justin Bogner a8dd73229e Correctly handle reading locations from serialized diagnostics
When reading a serialized diagnostic location with no file ID, we were
failing to increment the cursor past the rest of the location. This
would lead to the flags and category always appearing blank in such
diagnostics.

This changes the function to unconditionally increment the cursor and
updates the test to check for the correct output instead of testing
that we were doing this wrong. I've also updated the error check to
check for the correct number of fields.

llvm-svn: 219538
2014-10-10 22:20:26 +00:00
Fariborz Jahanian 2618dbaf5f Patch to wrap up '_' as separator in version numbers
in availability attribute by preserving this info.
in VersionTuple and using it in pretty printing of attributes
and yet using '.' as separator when diagnosing unavailable 
message calls. rdar://18490958

llvm-svn: 219124
2014-10-06 16:46:02 +00:00
Fariborz Jahanian aae7fefce8 Objective-C. Assortment of improvements pretty printing
objective-C declarations, including printing of availability
attributes on methods.

llvm-svn: 219013
2014-10-03 20:05:33 +00:00
Fariborz Jahanian b417b8f71f Objective-C [qoi] - provide group name for
warn_property_types_are_incompatible. rdar://18487506

llvm-svn: 218621
2014-09-29 20:17:04 +00:00
Ben Langmuir 2f8e6b87ef Move calls to ResolveExceptionSpec out of SetDeclDefaulted and into DefineImplicit*
This fixes an assertion failure in CodeGen where we were not resolving
an exception specification.

llvm-svn: 218466
2014-09-25 20:55:00 +00:00
Richard Trieu 40bcd9f664 Don't print 'NULL TYPE' when dumping a delegating constructor.
llvm-svn: 217707
2014-09-12 21:20:53 +00:00
Nico Weber 728894340f Add -Wunused-local-typedef, a warning that finds unused local typedefs.
The warning warns on TypedefNameDecls -- typedefs and C++11 using aliases --
that are !isReferenced(). Since the isReferenced() bit on TypedefNameDecls
wasn't used for anything before this warning it wasn't always set correctly,
so this patch also adds a few missing MarkAnyDeclReferenced() calls in
various places for TypedefNameDecls.

This is made a bit complicated due to local typedefs possibly being used only
after their local scope has closed. Consider:

    template <class T>
    void template_fun(T t) {
      typename T::Foo s3foo;  // YYY
      (void)s3foo;
    }
    void template_fun_user() {
      struct Local {
        typedef int Foo;  // XXX
      } p;
      template_fun(p);
    }

Here the typedef in XXX is only used at end-of-translation unit, when YYY in
template_fun() gets instantiated. To handle this, typedefs that are unused when
their scope exits are added to a set of potentially unused typedefs, and that
set gets checked at end-of-TU. Typedefs that are still unused at that point then
get warned on. There's also serialization code for this set, so that the
warning works with precompiled headers and modules. For modules, the warning
is emitted when the module is built, for precompiled headers each time the
header gets used.

Finally, consider a function using C++14 auto return types to return a local
type defined in a header:

    auto f() {
      struct S { typedef int a; };
      return S();
    }

Here, the typedef escapes its local scope and could be used by only some
translation units including the header. To not warn on this, add a
RecursiveASTVisitor that marks all delcs on local types returned from auto
functions as referenced. (Except if it's a function with internal linkage, or
the decls are private and the local type has no friends -- in these cases, it
_is_ safe to warn.)

Several of the included testcases (most of the interesting ones) were provided
by Richard Smith.

(gcc's spelling -Wunused-local-typedefs is supported as an alias for this
warning.)

llvm-svn: 217298
2014-09-06 01:25:55 +00:00
David Majnemer 467e856600 Adjust test to handle fallout from r217102.
llvm-svn: 217104
2014-09-03 23:20:58 +00:00
Nico Weber f69cba649e Add a warning flag for an existing diagnostic.
One more, and the number of flags without a dedicated flag fits in two decimal
digits :-)

llvm-svn: 215946
2014-08-18 23:02:03 +00:00
Aaron Ballman 3ed2fb1ab6 Adding some test cases to test attribute-related source range diagnostics. This augments r214722, r214723 and r214507.
llvm-svn: 215444
2014-08-12 14:00:40 +00:00
Richard Smith 35f986d3cd Modify behavior of -ast-dump-lookups: if -ast-dump is not also provided, dump
anyway. If -ast-dump *is* also provided, then dump the AST declarations as well
as the lookup results. This is invaluable for cross-correlating the lookup
information with the declarations actually found.

llvm-svn: 215393
2014-08-11 22:11:07 +00:00
Fariborz Jahanian 2056b38fac Provide warning name for property attribute warning
mismatch. //rdar://17845264

llvm-svn: 214203
2014-07-29 19:45:49 +00:00
Richard Trieu 97bacec221 If a template argument is non-evaluable expression, use the profile ID to see
if the two arguments are equal.

llvm-svn: 214008
2014-07-26 02:10:52 +00:00
Richard Trieu d86c901f29 Pass the PrintingPolicy when converting types to strings in template type
diffing.  This removes extra "struct"/"class" in the type names and gives
"bool" instead of "_Bool" for booleans.

llvm-svn: 213912
2014-07-25 00:24:02 +00:00
Richard Trieu 116083159c Print "(default)" for default template template arguments to match the
printing of other types.

llvm-svn: 213902
2014-07-24 23:14:16 +00:00
Richard Trieu 3880089fc7 Add support for nullptr template arguments to template type diffing.
llvm-svn: 213840
2014-07-24 04:24:50 +00:00
Richard Smith a4bb292095 When pretty-printing a declaration of a pack, put the ellipsis before the name
being declared, not at the end. When pretty-printing a non-type template
parameter, put the name of the parameter in the middle of the type, not at the
end.

llvm-svn: 213718
2014-07-23 03:17:06 +00:00
Richard Trieu d53def22ef Fix '&' printing for template arguments in parentheses in template diffing.
llvm-svn: 213613
2014-07-22 04:42:15 +00:00
Richard Trieu 63056c3918 More gracefully handle parentheses in templare arguments in template diffing.
llvm-svn: 213611
2014-07-22 04:06:54 +00:00
Richard Trieu 965cfa1d5b Fix a template diffing problem were an '&' is unexpectedly printed in
a template argument.

llvm-svn: 213609
2014-07-22 03:33:01 +00:00
Richard Smith 1b98ccc4e9 PR20356: Fix all Sema warnings with mismatched ext_/warn_ versus
ExtWarn/Warnings. Mostly the name of the warning was changed to match the
semantics, but in the PR20356 cases, the warning was about valid code, so the
diagnostic was changed from ExtWarn to Warning instead.

llvm-svn: 213443
2014-07-19 01:39:17 +00:00
NAKAMURA Takumi 6096d44f76 clang/test/Misc/backend-optimization-failure.cpp: Appease to add -triple=x86_64.
FIXME: Could this be made generic?
llvm-svn: 213441
2014-07-19 01:17:32 +00:00
Tyler Nowicki f8a767df67 Recommit: Handle diagnostic warnings in Frontend diagnostic handler.
Clang uses a diagnostic handler to grab diagnostic messages so it can print them
with the line of source code they refer to. This patch extends this to handle
optimization failures that were added to llvm to produce a warning when
loop vectorization is explicitly specified (using a pragma clang loop directive)
but fails.

Update renames warning flag name to avoid indicating the flag's severity and
adds a test.

Reviewed by Alp Toker

llvm-svn: 213400
2014-07-18 19:40:19 +00:00