Commit Graph

16202 Commits

Author SHA1 Message Date
Alexander Kornienko 7a712cea71 Allow specifying a custom PathDiagnosticConsumer for use with the static analyzer.
Summary:
Make objects returned by CreateAnalysisConsumer expose an interface,
that allows providing a custom PathDiagnosticConsumer, so that users can have
raw data in a form easily usable from the code (unlike plist/HTML in a file).

Reviewers: jordan_rose, krememek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D2556

llvm-svn: 200710
2014-02-03 18:37:50 +00:00
Richard Smith 91dfaacd38 Implement DR329. We already did the right thing here in C++98 mode, but r104014
(which implemented the DR) was disabled in C++11.

llvm-svn: 200673
2014-02-03 02:37:59 +00:00
Nico Weber 514ecc8ce8 clang-format: Let chromium style inherit google style's javascript tweaks.
llvm-svn: 200652
2014-02-02 20:50:45 +00:00
Reid Kleckner 314ef7bafd [ms-cxxabi] Use inalloca on win32 when passing non-trivial C++ objects
When a non-trivial parameter is present, clang now gathers up all the
parameters that lack inreg and puts them into a packed struct.  MSVC
always aligns each parameter to 4 bytes and no more, so this is a pretty
simple struct to lay out.

On win64, non-trivial records are passed indirectly.  Prior to this
change, clang was incorrectly using byval on win64.

I'm able to self-host a working clang with this change and additional
LLVM patches.

Reviewers: rsmith

Differential Revision: http://llvm-reviews.chandlerc.com/D2636

llvm-svn: 200597
2014-02-01 00:04:45 +00:00
Reid Kleckner 4982b82b73 [ms-cxxabi] Use x86_cdeclmethodcc for __cdecl methods on win32
This fixes PR15768, where the sret parameter and the 'this' parameter
are in the wrong order.

Instance methods compiled by MSVC never return records in registers,
they always return indirectly through an sret pointer.  That sret
pointer always comes after the 'this' parameter, for both __cdecl and
__thiscall methods.

Unfortunately, the same is true for other calling conventions, so we'll
have to change the overall approach here relatively soon.

Reviewers: rsmith

Differential Revision: http://llvm-reviews.chandlerc.com/D2664

llvm-svn: 200587
2014-01-31 22:54:50 +00:00
Richard Smith 67294e253e Track the currently-being-built submodule inside the preprocessor (rather than
just storing a flag indicating if there was one), and include it in the 'end of
module' annotation. No functionality change.

llvm-svn: 200573
2014-01-31 20:47:44 +00:00
Ben Langmuir 332aafede3 Fix autolinking when modules are imported in pch files
Add the ImportDecl to the set of interesting delcarations that are
deserialized eagerly when an AST file is loaded (rather than lazily like
most decls). This is required to get auto linking to work when there is
no explicit import in the main file. Also resolve a FIXME to rename
'ExternalDefinitions', since that is only one of the things that need eager
deserialization. The new name is 'EagerlyDeserializedDecls'. The corresponding
AST bitcode is also renamed.

llvm-svn: 200505
2014-01-31 01:06:56 +00:00
Peter Collingbourne 252444a777 Introduce Parser::completeExpression.
This function returns a list of completions for a given expression and
completion position.

Differential Revision: http://llvm-reviews.chandlerc.com/D2261

llvm-svn: 200497
2014-01-30 22:38:41 +00:00
Tim Northover c322f838bc ARM & AArch64: share the BI__builtin_neon enum defs.
llvm-svn: 200470
2014-01-30 14:47:51 +00:00
John McCall 2575d88059 Diagnose typedef names for linkage purposes that would change
a previously-computed linkage as an unsupportable error condition.

Per discussion on cfe-commits, this appears to be a
difficult-to-resolve flaw in our implementation approach;
we may pursue this as a language defect, but for now it's
better to diagnose it as unsupported than to produce
inconsistent results (or assertions).  Anything that we can
do to limit how often this diagnostic fires, such as the
changes in r200380, is probably for the best, though.

llvm-svn: 200438
2014-01-30 01:12:53 +00:00
Aaron Ballman 35db2b3d4c Consolidating several table-generated files containing parser-related string switches into a single file. This reduces build-related complexity by replacing four separate projects (and table-gen instantiations) with a single one.
No functional changes intended.

llvm-svn: 200424
2014-01-29 22:13:45 +00:00
David Majnemer 2c4e00ac1c Sema: Diagnose improper application of inheritance keywords
We would previously allow inappropriate inheritance keywords to appear
on class declarations.  We would also allow inheritance keywords on
templates which were not fully specialized; this was divergent from
MSVC.

Differential Revision: http://llvm-reviews.chandlerc.com/D2585

llvm-svn: 200423
2014-01-29 22:07:36 +00:00
Hans Wennborg cfdd8b54cf clang-cl: Better error message when trying to compile stdin (PR18640)
We should suggest using /Tc or /Tp to set the input type, instead of
erroneously suggesting -x, which isn't a clang-cl flag.

llvm-svn: 200362
2014-01-29 01:04:40 +00:00
Richard Trieu 1e632af0d4 A new conversion warning for when an Objective-C object literal is implicitly
cast into a boolean true value.  This warning will catch code like:

if (@0) {}
if (@"foo") {}

llvm-svn: 200356
2014-01-28 23:40:26 +00:00
Daniel Jasper e9beea24ef clang-format: Add support for a space after @property
Mozilla and WebKit seem to use a space after @property (verified by
grepping their codebases) so we turn this on there as well.

Change by Christian Legnitto. Thank you!

llvm-svn: 200320
2014-01-28 15:20:33 +00:00
Richard Smith 2e87e14490 Remove dead code; MacroDirective's IsHidden flag is always false.
llvm-svn: 200265
2014-01-27 23:54:39 +00:00
Aaron Ballman c669cc0d77 Add a new attribute meta-spelling called "GCC" -- it widens into being a GNU spelling, and a CXX11 spelling with the namespace "gnu". It also sets a bit on the spelling certifying that it is known to GCC. From this, we can warn about the extension appropriately. As a consequence, the FunctionDefinition functionality is completely removed.
Replacing the functionality from r199676, which didn't solve the problem as elegantly.

llvm-svn: 200252
2014-01-27 22:10:04 +00:00
Richard Smith 340e44074b Remove dead code.
llvm-svn: 200251
2014-01-27 22:08:43 +00:00
David Blaikie f36d9bac47 Driver: support -fno-debug-types-section to override -fdebug-types-section
llvm-svn: 200236
2014-01-27 18:52:43 +00:00
Alp Toker 0d865d3d7b Roll back the use of ConstStringRef for now
We might want try a different strategy so hold back on this for the moment, but
fix the off-by-one error in the original function template.

This reverts commit r200190.

llvm-svn: 200193
2014-01-27 05:21:24 +00:00
Alp Toker a80501742c Use ConstStringRef facility for getCustomDiagID() safety
This is one of various functions in clang that don't handle arbitrary strings
well and can benefit from compile-time safety checks.

Also fixes an off-by-one error that caused one additional null byte to get
added to the end of custom diagnostic descriptions. ConstStringRef handles
tricky details like that for us now.

Requires supporting changes in LLVM r200187.

llvm-svn: 200190
2014-01-27 04:22:22 +00:00
Alp Toker 9e6d27d037 Update docstrings following the param name change in r200132
llvm-svn: 200137
2014-01-26 06:41:58 +00:00
Alp Toker 29cb66ba2f Enforce safe usage of DiagnosticsEngine::getCustomDiagID()
Replace the last incorrect uses and templatize the function to require a
compile-time constant string preventing further misuse.

The diagnostic formatter expects well-formed input and has undefined behaviour
with arbitrary input or crafted user strings in source files. Accepting user
input would also have caused unbounded generation of new diagnostic IDs which
can be problematic in long-running sessions or language bindings.

This completes the work to fix several incorrect callers that passed user
input or raw messages to the diagnostics engine where a constant format string
was expected.

llvm-svn: 200132
2014-01-26 06:17:37 +00:00
Alp Toker 42aa21222d ARCMigrate: Introduce proper diagnostics for TransformActions
This starts to switch ARCMT to use proper diagnostic messages. The old use was
based on incorrect example code from the documentation.

The logic of the previous report() functions has been retained to support any
external consumers that might be intercepting diagnostic messages through the
old interface.

Note that the change in test/Misc/warning-flags.c isn't a new warning without a
flag, rather one that was previously invisible to the test. Adding a flag might
be a good idea though.

llvm-svn: 200124
2014-01-26 05:07:32 +00:00
Alp Toker 2652153904 Remove flawed diagnostic mapping functions
These haven't been usable since the early return was accidentally removed some
years ago causing all cases to fall through to the !Enabled condition.

llvm-svn: 200123
2014-01-26 05:07:02 +00:00
Alp Toker 42a16a67f5 Rename getResultLoc() too
Follow up to r200082.

Spotted by Dmitri

llvm-svn: 200105
2014-01-25 23:51:36 +00:00
Alp Toker 1f307f49ef Remove obsolete ObjCMethodDecl arg_type iterator functions
These were set into deprecation in r199773.

llvm-svn: 200086
2014-01-25 17:32:04 +00:00
Alp Toker 314cc81b8c Rename getResultType() on function and method declarations to getReturnType()
A return type is the declared or deduced part of the function type specified in
the declaration.

A result type is the (potentially adjusted) type of the value of an expression
that calls the function.

Rule of thumb:

  * Declarations have return types and parameters.
  * Expressions have result types and arguments.

llvm-svn: 200082
2014-01-25 16:55:45 +00:00
Alp Toker 48047f5d75 PlistSupport: Eliminate duplicated EmitLocation() and EmitRange() functions
llvm-svn: 200077
2014-01-25 14:38:41 +00:00
Alp Toker bdbcfbf160 PlistSupport: Unify ARCMigrate / StaticAnalyzer plist writers
Reduces the ARCMT migrator plist writer down to a single function,
arcmt::writeARCDiagsToPlist() which shares supporting functions with the
analyzer plist writer.

llvm-svn: 200075
2014-01-25 11:14:41 +00:00
Richard Smith 4b5a949834 Allow virt-specifiers after GNU attributes in member-declarators. GCC doesn't
allow this, and we should warn on it, but it turns out that people were already
relying on this.

We should introduce a -Wgcc-compat warning for this if the attributes are known
to GCC, but we don't currently track enough information about attributes to do
so reliably.

llvm-svn: 200045
2014-01-24 22:34:35 +00:00
Aaron Ballman 81cb8cbfa6 Adds a getSemanticSpelling function to semantic attribute subclasses which have a meaningful semantic spelling. Adds a sibling function to parsed attribtues (via AttributeList) for getting the semantic spelling, if one were to exist. This can be used for cleaner code that deals directly with the semantic spellings (such as the MSInheritance attribute).
llvm-svn: 200041
2014-01-24 21:32:49 +00:00
Amara Emerson 05d816d0e2 [AArch64] Replace underscores with dashes in -mgeneral_regs_only.
This should now match the equivalent gcc option.

llvm-svn: 200008
2014-01-24 15:15:27 +00:00
Aaron Ballman cc396f85d9 Adding a new diagnostics group (-Wattributes) which covers both UnknownAttributes and IgnoredAttributes.
llvm-svn: 200004
2014-01-24 14:16:23 +00:00
Artyom Skrobov 9f2134402c Combine the checks for returns_nonnull and for operator new returning null, in Sema::CheckReturnValExpr. Add the missing handling of value-dependent expressions for returns_nonnull.
llvm-svn: 199989
2014-01-24 11:10:39 +00:00
Richard Smith 7ff2bcb814 PR18560: When switching to a new context, don't just save and restore an
override for the type of 'this', also clear it out (unless we're entering the
context of a lambda-expression, where it should be inherited).

llvm-svn: 199962
2014-01-24 01:54:52 +00:00
Richard Smith 72553fc19b Factor out repeated parsing of a member-declarator when parsing a
member-declaration. In the process, fix a couple of bugs that had crept in
where we would parse the first and subsequent member-declarators differently
(in particular, we didn't accept an asm-label on a member function definition
within a class, and we would accept virt-specifiers and attributes in the wrong
order on the first declarator but not on subsequent ones).

llvm-svn: 199957
2014-01-23 23:53:27 +00:00
Peter Collingbourne d32e28c87a Introduce Registry::getCompletions.
This returns a list of valid (and useful) completions for a context (a list
of outer matchers), ordered by decreasing relevance then alphabetically. It
will be used by the matcher parser to implement completion.

Differential Revision: http://llvm-reviews.chandlerc.com/D2210

llvm-svn: 199950
2014-01-23 22:48:38 +00:00
DeLesley Hutchins 8a7117d4c8 Thread safety analysis: handle duplicate assert_lock attributes.
llvm-svn: 199949
2014-01-23 22:35:26 +00:00
Amara Emerson 04e2ecfda2 [AArch64] Add -mgeneral_regs_only option.
llvm-svn: 199904
2014-01-23 15:48:30 +00:00
Serge Pavlov 09f9924acf Fix to PR8880 (clang dies processing a for loop)
Due to statement expressions supported as GCC extension, it is possible
to put 'break' or 'continue' into a loop/switch statement but outside
its body, for example:

    for ( ; ({ if (first) { first = 0; continue; } 0; }); )

This code is rejected by GCC if compiled in C mode but is accepted in C++
code. GCC bug 44715 tracks this discrepancy. Clang used code generation
that differs from GCC in both modes: only statement of the third
expression of 'for' behaves as if it was inside loop body.

This change makes code generation more close to GCC, considering 'break'
or 'continue' statement in condition and increment expressions of a
loop as it was inside the loop body. It also adds error for the cases
when 'break'/'continue' appear outside loop due to this syntax. If
code generation differ from GCC, warning is issued.

Differential Revision: http://llvm-reviews.chandlerc.com/D2518

llvm-svn: 199897
2014-01-23 15:05:00 +00:00
Hans Wennborg 80429048db clang-cl: Expose the -ferror-limit= option
llvm-svn: 199828
2014-01-22 20:06:53 +00:00
Fariborz Jahanian dad9630398 ObjectiveC. When issuing property implementation is
not using backing ivar warning, ignore when
property is not being synthesized (user declared its
implementation @dynamic). // rdar://1583425

llvm-svn: 199820
2014-01-22 19:02:20 +00:00
Alp Toker a2794f9f36 Introduce and use Decl::getAsFunction() to simplify templated function checks
Lift the getFunctionDecl() utility out of the parser into a general
Decl::getAsFunction() and use it to simplify other parts of the implementation.

Reduce isFunctionOrFunctionTemplate() to a simple type check that works the
same was as the other is* functions and move unwrapping of shadowed decls to
callers so it doesn't get run twice.

Shuffle around canSkipFunctionBody() to reduce virtual dispatch on ASTConsumer.
There's no need to query when we already know the body can't be skipped.

llvm-svn: 199794
2014-01-22 07:29:52 +00:00
Ted Kremenek ef9e7f8059 Add basic checking for returning null from functions/methods marked 'returns_nonnull'.
This involved making CheckReturnStackAddr into a static function, which
is now called by a top-level return value checking routine called
CheckReturnValExpr.

llvm-svn: 199790
2014-01-22 06:10:28 +00:00
Hans Wennborg a6ae1209df clang-cl: make /Zp a Joined option (PR18503)
We don't currently support this option, but we should be able to parse it.

llvm-svn: 199787
2014-01-22 03:23:35 +00:00
Richard Smith b63b6ee9a0 Enforce restrictions that 'main' is not allowed to be deleted, or to be used by
the program, in C++. (We allow the latter as an extension, since we've always
permitted it, and GCC does the same, and our supported C++ ABIs don't do
anything special in main.)

llvm-svn: 199782
2014-01-22 01:43:19 +00:00
Fariborz Jahanian bbf322b0bb ObjectiveC driver. change to reinstate -fno-objc-legacy-dispatch behavior
when the deployment target is 10.5. // rdar://15852259

llvm-svn: 199780
2014-01-22 00:43:54 +00:00
Alp Toker 601b22c377 Correct various uses of 'argument' that in fact refer to function parameters
Cleanup only.

llvm-svn: 199773
2014-01-21 23:35:24 +00:00
David Woodhouse 6996f6b9ec Add -m16 option for using x86-*-*-code16 triple
llvm-svn: 199754
2014-01-21 17:19:44 +00:00