Commit Graph

2128 Commits

Author SHA1 Message Date
Nick Lewycky a096b14d1d The meat of this patch is in BuildCXXMemberCalLExpr where we make it use
MarkMemberReferenced instead of marking functions referenced directly. An audit
of callers to MarkFunctionReferenced and DiagnoseUseOfDecl also caused a few
other changes:
 * don't mark functions odr-used when considering them for an initialization
   sequence. Do mark them referenced though.
 * the function nominated by the cleanup attribute should be diagnosed.
 * operator new/delete should be diagnosed when building a 'new' expression.

llvm-svn: 174951
2013-02-12 08:08:54 +00:00
Chad Rosier b31d71367b Testcase for r174477.
llvm-svn: 174640
2013-02-07 18:32:25 +00:00
Tim Northover 570b7478fa Add AArch64 wchar definition to test
This should allow it to pass if the default triple is AArch64

llvm-svn: 174620
2013-02-07 15:11:44 +00:00
Ted Kremenek c43636a53d Remove unneeded test. We have plenty of subgroup relations between warnings,
and for those we care about we should have a general way of testing them.

llvm-svn: 174531
2013-02-06 19:24:28 +00:00
Ted Kremenek 8ae67871b4 Change subexpressions to be visited in the CFG from left-to-right.
This is a more natural order of evaluation, and it is very important
for visualization in the static analyzer.  Within Xcode, the arrows
will not jump from right to left, which looks very visually jarring.
It also provides a more natural location for dataflow-based diagnostics.

Along the way, we found a case in the analyzer diagnostics where we
needed to indicate that a variable was "captured" by a block.

-fsyntax-only timings on sqlite3.c show no visible performance change,
although this is just one test case.

Fixes <rdar://problem/13016513>

llvm-svn: 174447
2013-02-05 22:00:19 +00:00
Richard Smith c084bd2888 PR15132: Replace "address expression must be an lvalue or a function
designator" diagnostic with more correct and more human-friendly "cannot take
address of rvalue of type 'T'".

For the case of & &T::f, provide a custom diagnostic, rather than unhelpfully
saying "cannot take address of rvalue of type '<overloaded function type>'".

For the case of &array_temporary, treat it just like a class temporary
(including allowing it as an extension); the existing diagnostic wording
for the class temporary case works fine.

llvm-svn: 174262
2013-02-02 02:14:45 +00:00
Richard Smith 9eaab4be04 Fix diagnostic for bad alignas use: it can't be applied to functions.
llvm-svn: 174160
2013-02-01 08:25:07 +00:00
Richard Smith 848e1f1960 Implement [dcl.align]p5 and C11 6.7.5/4: alignas cannot underalign.
Also support alignas(0), which C++11 and C11 require us to ignore.

llvm-svn: 174157
2013-02-01 08:12:08 +00:00
Michael Han af02bbe84f [Sema][Attr]Fix alignment attribute printing.
Remove "IsMSDeclspec" argument from Align attribute since the arguments in Attr.td should
only model those appear in source code. Introduce attribute Accessor, and teach TableGen
to generate syntax kind accessors for Align attribute, and use those accessors to decide
if an alignment attribute is a declspec attribute.

llvm-svn: 174133
2013-02-01 01:19:17 +00:00
Fariborz Jahanian 1a0cf80533 [Comment parsing] Add support for recognizing
\headerfile command and representing it in an xml
document. Patch reviewed by Dmitri Gribenko.
// rdar://12397511

llvm-svn: 174109
2013-01-31 23:12:39 +00:00
Richard Trieu de5cc7d3d8 Add indents to AST dumping and removed parenthesis from AST nodes.
Indents were given the color blue when outputting with color.
AST dumping now looks like this:

Node
|-Node
| `-Node
`-Node
  `-Node

Compared to the previous:

(Node
  (Node
    (Node))
  (Node
    (Node)))

llvm-svn: 174022
2013-01-31 01:44:26 +00:00
Tim Northover da16507111 Also promote fp16 types to double when they're anonymous variadic arguments.
__fp16 isn't covered by the standard, but this resolves the oddity that float
gets promoted when passed variadically, but not the smaller type. This is
required by the AArch64 ABI, and a sane action elsewhere.

llvm-svn: 173918
2013-01-30 09:46:55 +00:00
Richard Smith d4cca6b2db Fix test failure from previous change.
llvm-svn: 173899
2013-01-30 06:27:44 +00:00
Richard Smith debc59d1f3 Semantic analysis and CodeGen support for C11's _Noreturn. This is modeled as
an attribute for consistency with our other noreturn mechanisms.

llvm-svn: 173898
2013-01-30 05:45:05 +00:00
Fariborz Jahanian 4d365ba9b9 c: When checking on validity of sizeof passed as size of
argument to be memset, check for its type to be complete 
before calling Context.getTypeSize(PointeeTy) to prevent 
crash. // rdar://13081751.

llvm-svn: 173872
2013-01-30 01:12:44 +00:00
Richard Smith 064697ca06 Test update missed in r173789.
llvm-svn: 173790
2013-01-29 10:18:33 +00:00
Richard Smith 810ad3eb44 Downgrade 'attribute ignored when parsing type' from error to warning, to match
the diagnostic's warn_ name. Switch some places (notably C++11 attributes)
which really wanted an error over to a different diagnostic. Finally, suppress
the diagnostic entirely for __ptr32, __ptr64 and __w64, to avoid producing
diagnostics in important system headers.

llvm-svn: 173788
2013-01-29 10:02:16 +00:00
Richard Smith 1dba27cd49 Implement C++11 [dcl.align]p1 and C11 6.7.5/2 rules for alignas and _Alignas.
llvm-svn: 173779
2013-01-29 09:02:09 +00:00
Richard Smith 210b67d221 Test that we print MS keyword attributes without a __declspec(...) adornment.
llvm-svn: 173754
2013-01-29 02:31:57 +00:00
Richard Smith 0cdcc98200 Replace AS_MSTypespec with AS_Keyword, for representing any attribute spelled
as a keyword. Rationalize existing attributes to use it as appropriate, and to
not lie about some __declspec attributes being GNU attributes. In passing,
remove a gross hack which was discarding attributes which we could handle. This
results in us actually respecting the __pascal keyword again.

llvm-svn: 173746
2013-01-29 01:24:26 +00:00
Dmitri Gribenko 01b065117b Comment parsing: attach any tag type's documentation to its typedef if latter
does not have one of its own. // rdar://13067629

Original patch (r173586 and r173587) by Fariborz Jahanian, modified by me.

llvm-svn: 173626
2013-01-27 21:18:39 +00:00
Dmitri Gribenko 7146930591 Comment parsing: actually check for a block command after "\param x"
This fixes PR15068.

llvm-svn: 173539
2013-01-26 00:36:14 +00:00
Fariborz Jahanian d0ed6c249d Add space after ';'.
llvm-svn: 173462
2013-01-25 17:47:49 +00:00
Fariborz Jahanian 740396437b Improve diagnsotic further on integer overflow.
llvm-svn: 173461
2013-01-25 17:19:07 +00:00
Fariborz Jahanian ee19ceb409 Fixes text of diagnostics in integer overflow patch.
llvm-svn: 173388
2013-01-24 23:24:32 +00:00
Fariborz Jahanian e735ff93e8 Patch to check for integer overflow. It has been
commented on and approved by Richard Smith.

llvm-svn: 173377
2013-01-24 22:11:45 +00:00
Jordan Rose 7f43dddae0 Handle universal character names and Unicode characters outside of literals.
This is a missing piece for C99 conformance.

This patch handles UCNs by adding a '\\' case to LexTokenInternal and
LexIdentifier -- if we see a backslash, we tentatively try to read in a UCN.
If the UCN is not syntactically well-formed, we fall back to the old
treatment: a backslash followed by an identifier beginning with 'u' (or 'U').

Because the spelling of an identifier with UCNs still has the UCN in it, we
need to convert that to UTF-8 in Preprocessor::LookUpIdentifierInfo.

Of course, valid code that does *not* use UCNs will see only a very minimal
performance hit (checks after each identifier for non-ASCII characters,
checks when converting raw_identifiers to identifiers that they do not
contain UCNs, and checks when getting the spelling of an identifier that it
does not contain a UCN).

This patch also adds basic support for actual UTF-8 in the source. This is
treated almost exactly the same as UCNs except that we consider stray
Unicode characters to be mistakes and offer a fixit to remove them.

llvm-svn: 173369
2013-01-24 20:50:46 +00:00
Jordan Rose aa89cf1a66 Unify diagnostics for \x, \u, and \U without any following hex digits.
llvm-svn: 173368
2013-01-24 20:50:13 +00:00
Chad Rosier 879edcd1a4 Fail these tests in a way that doesn't cause unexpected successes, per Daniel's
suggestion.

llvm-svn: 173367
2013-01-24 20:46:39 +00:00
Chad Rosier 709863514e Temporarily XFAIL this test; the compiler will segfault if the target-specific
parser is not included in the compiler. Thanks to Renato for discovering the
underlying issue.

llvm-svn: 173365
2013-01-24 20:33:35 +00:00
Chad Rosier 282d675b28 [ms-inline asm] Add an error when trying to compile MS-style inline assembly
for an unsupported architecture.
rdar://13063988

llvm-svn: 173364
2013-01-24 20:24:34 +00:00
Michael Han 9931593299 PR14922: when printing an attribute, use the real syntax of the attribute (GNU, C++11, MS Declspec) instead of hardcoded GNU syntax.
Introduce a spelling index to Attr class, which is an index into the attribute spelling list of an attribute defined in Attr.td. 
This index will determine the actual spelling used by an attribute, as it incorporates both the syntax and naming of the attribute.
When constructing an attribute AST node, the spelling index is computed based on attribute kind, scope (if it's a C++11 attribute), and
name, then passed to Attr that will use the index to print itself. 

Thanks to Richard Smith for the idea and review.

llvm-svn: 173358
2013-01-24 16:46:58 +00:00
Joey Gouly 7b79dff544 Properly remove this test file, that I copied over to test/SemaOpenCL in r173352.
llvm-svn: 173353
2013-01-24 15:19:51 +00:00
Dmitri Gribenko 6c926ccbd2 Implement -Wvla correctly
GCC implements -Wvla as "warn on every VLA" (this is useful to find every VLA,
for example, if they are forbidden by coding guidelines).  Currently Clang
implements -Wvla as "warn on VLA when it is an extension".

The attached patch makes our behavior match GCC.  The existing vla extwarn is
moved under -Wvla-extension and is still included into -Wgnu.

This fixes PR5953.

llvm-svn: 173286
2013-01-23 20:02:51 +00:00
Chad Rosier e3aac2c864 [ms-inline asm] Remove the -fenable-experimental-ms-inline-asm flag. MS-style
inline assembly can be enable with -fasm-blocks or -fms-extensions alone.

llvm-svn: 173186
2013-01-22 19:38:32 +00:00
Ted Kremenek c0da34e6ab Split "discards qualifiers" warnings of -Wincompatible-pointer-types into subgroup.
This allows users to promote -Wincompatible-pointer-type warnings to
errors but keep those for "discard qualifiers" as warnings (if they
so desire).

Addresses <rdar://problem/13062738>.

llvm-svn: 173184
2013-01-22 19:32:27 +00:00
Dmitri Gribenko 7ec6f3ddeb Add a fixit for _Noreturn main,
add tests for fixits removing static and inline from main

llvm-svn: 173024
2013-01-21 11:25:03 +00:00
Chad Rosier 92c487d13c [ms-inline asm] Test case for r172773.
llvm-svn: 172774
2013-01-18 00:51:29 +00:00
Jordan Rose 1eb342920b Format strings: don't ever convert %+d to %lu.
Presumably, if the printf format has the sign explicitly requested, the user
wants to treat the data as signed.

This is a fix-up for r172739, and also includes several test changes that
didn't make it into that commit.

llvm-svn: 172762
2013-01-17 22:34:10 +00:00
Richard Smith 0015f09877 Parsing support for C11's _Noreturn keyword. No semantics yet.
llvm-svn: 172761
2013-01-17 22:16:11 +00:00
Chad Rosier e343bc83f0 [ms-inline asm] Updates and test case for r172743.
Part of rdar://12576868

llvm-svn: 172744
2013-01-17 19:22:48 +00:00
Matt Beaumont-Gay 978cca9f49 Suppress all -Wunused-value warnings from macro body expansions.
This is inspired by a number of false positives in real code, including
PR14968. I've added test cases reduced from these false positives to
test/Sema/unused-expr.c, as well as corresponding test cases that pass the
offending expressions as arguments to a no-op macro to ensure that we do warn
there.

This also removes my previous tweak from r166522/r166534, so that we warn on
unused cast expressions in macro arguments.

There were several test cases that were using -Wunused-value to test general
diagnostic emission features; I changed those to use other warnings or warn on
a macro argument expression. I stared at the test case for PR14399 for a while
with Richard Smith and we believe the new test case exercises the same
codepaths as before.

llvm-svn: 172696
2013-01-17 02:06:08 +00:00
Dmitri Gribenko ae73417b69 Implement a fixit for -Wmain-return-type
llvm-svn: 172684
2013-01-17 00:26:13 +00:00
Rafael Espindola f1d2f0ea21 Check for internal weak decls after merging.
This fixes pr14946. The problem was that the linkage computation was done too
early, so things like "extern int a;" would be given external linkage, even if
a previous declaration was static.

llvm-svn: 172667
2013-01-16 23:11:15 +00:00
Reed Kotler 373feca7a0 First step in implementation of mips16 and nomips16 attributes.
Waiting for new llvm attribute code for the next step.

llvm-svn: 172626
2013-01-16 17:10:28 +00:00
Dmitri Gribenko 813985b073 Add a comment to test to clarify the intention here
Comment is taken from the commit message of r151080, by Jean-Daniel Dupas

llvm-svn: 172332
2013-01-12 22:39:30 +00:00
Matt Beaumont-Gay b1e71a7d0c Fix -Wunused-comparison for comparisons in arguments to function-like macros.
Previously, -Wunused-comparison ignored comparisons in both macro bodies and
macro arguments, but we would still emit a -Wunused-value warning for either.
Now we correctly emit -Wunused-comparison for expressions in macro arguments.

Also, add isMacroBodyExpansion to SourceManager, to go along with
isMacroArgExpansion.

llvm-svn: 172279
2013-01-12 00:54:16 +00:00
Rafael Espindola 46afb35181 Reject incompatible redeclarations of extern C symbols.
Before we were only checking if the new declaration itself was marked extern
C. Fixes prpr14766.

llvm-svn: 172243
2013-01-11 19:34:23 +00:00
Fariborz Jahanian 70ae634f87 Improve diagnostic per Richard's suggestion
(which may yet change if we move the diagnostic
 outside case value).

llvm-svn: 172242
2013-01-11 19:33:54 +00:00
Fariborz Jahanian 941827931e Provide a better warning when case value overflows.
// rdar://11577384

llvm-svn: 172102
2013-01-10 20:26:42 +00:00