Commit Graph

45483 Commits

Author SHA1 Message Date
Reid Kleckner 140c4a74e2 Refactor diagnostics for MS attributes without -fms-extensions
This shares the warn_attribute_unused diagnostic and reduces the
indentation level.  No functionality change.

llvm-svn: 182096
2013-05-17 14:04:52 +00:00
Ted Kremenek 35de14540f [analyzer; alternate edges] improve support for edges with PseudoObjectExprs.
This optimizes some spurious edges resulting from PseudoObjectExprs.
This required far more changes than I anticipated.  The current
ParentMap does not record any hierarchy information between
a PseudoObjectExpr and its *semantic* expressions that may be
wrapped in OpaqueValueExprs, which are the expressions actually
laid out in the CFG.  This means the arrow pruning logic could
not map from an expression to its containing PseudoObjectExprs.

To solve this, this patch adds a variant of ParentMap that
returns the "semantic" parentage of expressions (essentially
as they are viewed by the CFG).  This alternate ParentMap is then
used by the arrow reducing logic to identify edges into pseudo
object expressions, and then eliminate them.

llvm-svn: 182083
2013-05-17 09:41:40 +00:00
Daniel Jasper 473c62c485 Slightly modify the formatting rules for braced lists.
Basically, the new rule is: The opening "{" always has to be on the
same line as the first element if the braced list is nested
(e.g. in another braced list or in a function).

The solution that clang-format produces almost always adheres to this
rule anyway and this makes clang-format significantly faster for larger
lists. Added a test cases for the only exception I could find
(which doesn't seem to be very important at first sight).

llvm-svn: 182082
2013-05-17 09:35:01 +00:00
Manuel Klimek bf2d568900 Add embedded video for the AST tutorial.
As asked for by Sean, putting the video into the docs.

llvm-svn: 182081
2013-05-17 08:40:22 +00:00
Ted Kremenek fd8f4b0171 [analyzer; alternate edges] treat 'if' statements the same way we do as 'for' or 'while'.
This means adding an extra edge from the 'if' to the condition,
which aesthetically looks more pleasing.

llvm-svn: 182079
2013-05-17 06:48:27 +00:00
Ted Kremenek 504eb552a8 [analyzer; alternate edges] don't add an edge incoming from the start of a function
for a nested call.  This matches what we do with the first stack frame.

llvm-svn: 182078
2013-05-17 06:48:22 +00:00
Richard Smith 1239d84f77 Use 'c++' not 'cxx' in these diagnostic group names for consistency.
llvm-svn: 182075
2013-05-17 03:11:25 +00:00
Richard Smith 841d8b2610 A little ArrayRef'ization.
llvm-svn: 182074
2013-05-17 03:04:50 +00:00
Richard Smith 4c163a093f PR15757: When we instantiate an inheriting constructor template, also
instantiate the inherited constructor template and mark that as the constructor
which the instantiated specialization is inheriting. This fixes a
crash-on-valid when trying to compute the exception specification of a
specialization of the inheriting constructor.

llvm-svn: 182072
2013-05-17 02:19:35 +00:00
Jordan Rose fbe4d85035 [analyzer] Don't inline ~shared_ptr.
The analyzer can't see the reference count for shared_ptr, so it doesn't
know whether a given destruction is going to delete the referenced object.
This leads to spurious leak and use-after-free warnings.

For now, just ban destructors named '~shared_ptr', which catches
std::shared_ptr, std::tr1::shared_ptr, and boost::shared_ptr.

PR15987

llvm-svn: 182071
2013-05-17 02:16:49 +00:00
Richard Smith adaa015900 AST dumping: if a declaration has an uncomputed or uninstantiated exception specification, include that in the dump.
llvm-svn: 182070
2013-05-17 02:09:46 +00:00
Anna Zaks c5e2eca042 [analyzer] Add an option to use the last location in the main source file as the report location.
Previously, we’ve used the last location of the analyzer issue path as the location of the
report. This might not provide the best user experience, when one analyzer a source
file and the issue appears in the header. Introduce an option to use the last location
of the path that is in the main source file as the report location.

New option can be enabled with -analyzer-config report-in-main-source-file=true.

llvm-svn: 182058
2013-05-16 22:30:45 +00:00
Richard Smith a3ee78df28 Since we're counting number of steps, switch to turing machines which maximize
#steps not #1s, and use a more traditional step count where the 'halt' step is
not counted.

llvm-svn: 182057
2013-05-16 22:18:32 +00:00
Argyrios Kyrtzidis 065d720c31 [Lexer] Improve Lexer::getSourceText() when the given range deals with function macro arguments.
This is a modified version of a patch by Manuel Klimek.

llvm-svn: 182055
2013-05-16 21:37:39 +00:00
Richard Smith 2414a6997b Add testcase omitted from r181998.
llvm-svn: 182043
2013-05-16 19:52:25 +00:00
Fariborz Jahanian 39d1c42f30 Objective-C arc: Diagnose when user attempts to
synthesize a property getter method that overrides
a method definition named 'retain' and the like.
Fixes // rdar://13885083

llvm-svn: 182039
2013-05-16 19:08:44 +00:00
David Fang 072d47b67f fix PR 15726: ptrdiff_t should be int on PowerPC Darwin
llvm-svn: 182029
2013-05-16 17:51:48 +00:00
Daniel Jasper 9271650e61 Add additional test-case for one-line-function.
This ensures that we format:
void longFunctionName {
} // long comment here

And not:
void longFunctionName {}
// long comment here

As requested in post-commit-review.

llvm-svn: 182024
2013-05-16 16:54:34 +00:00
Daniel Jasper 5b38f744e8 Add basic clang-format integration for sublime text.
llvm-svn: 182015
2013-05-16 15:08:25 +00:00
Daniel Jasper 8bb99e8911 Don't insert a break into include lines with trailing comments.
llvm-svn: 182003
2013-05-16 12:59:13 +00:00
Daniel Jasper 997af66087 Add config parsing test for new parameter.
llvm-svn: 182001
2013-05-16 12:16:23 +00:00
Daniel Jasper 3a685df7e0 Add option to put short loops on a single line.
This enables things like:

for (int &v : vec) v *= 2;

Enabled for Google style.

llvm-svn: 182000
2013-05-16 12:12:21 +00:00
Enea Zaffanella cf51a8ac3f Let CodeGenFunction::EmitVarDecl query the semantic storage class info.
Added testcase corresponding to PR15991.

llvm-svn: 181998
2013-05-16 11:27:56 +00:00
Daniel Jasper ec04c0dba0 Add a more convenient interface to use clang-format.
It turns out that several implementations go through the trouble of
setting up a SourceManager and Lexer and abstracting this into a
function makes usage easier.

Also abstracts SourceManager-independent ranges out of
tooling::Refactoring and provides a convenience function to create them
from line ranges.

llvm-svn: 181997
2013-05-16 10:40:07 +00:00
Daniel Jasper f9eb9b1883 Comments should not prevent single-line functions.
Before:
void f() {}
void g() {
} // comment

After:
void f() {}
void g() {} // comment

llvm-svn: 181996
2013-05-16 10:17:39 +00:00
Hans Wennborg 950f318ff1 SemaInit.cpp: give both IsStringInit() functions the same return type.
This addresses Richard's comment on r181880.

llvm-svn: 181995
2013-05-16 09:22:40 +00:00
NAKAMURA Takumi 267b446324 clang/test/Modules/self-import-header/test.m: Add explicit -target.
Clang has an issue between mingw/include/float.h and clang/Headers/float.h with cyclic include_next.
For now, it should work to suppress #include_next in clang/float.h with an explicit target.
(It may work with -U__MINGW32__, though.)

llvm-svn: 181988
2013-05-16 06:59:30 +00:00
Richard Smith ba71c08523 First pass of semantic analysis for init-captures: check the initializer, build
a FieldDecl from it, and propagate both into the closure type and the
LambdaExpr.

You can't do much useful with them yet -- you can't use them within the body
of the lambda, because we don't have a representation for "the this of the
lambda, not the this of the enclosing context". We also don't have support or a
representation for a nested capture of an init-capture yet, which was intended
to work despite not being allowed by the current standard wording.

llvm-svn: 181985
2013-05-16 06:20:58 +00:00
Richard Smith 37dc92eb4c Tidy up now that PointerUnion has an operator== that works.
llvm-svn: 181983
2013-05-16 05:04:51 +00:00
Rafael Espindola c1b38a29e7 Fix pr15930.
In the case of inline functions, we have to special case local types
when they are used as template arguments to make sure the template
instantiations are still uniqued in case the function itself is inlined.

llvm-svn: 181981
2013-05-16 04:30:21 +00:00
Daniel Jasper 7dd22c51b1 Add back accidentally deleted line and add test for it.
Before:
f("a", "b"
  "c");
After:
f("a", "b"
       "c");

llvm-svn: 181980
2013-05-16 04:26:02 +00:00
Richard Trieu b48e62fb45 Check a pointer is not null before attempting to use it. This prevents a
crash on an explicit specialization of a member function in a class scope.

llvm-svn: 181971
2013-05-16 02:14:08 +00:00
Richard Trieu 388a33f3a3 Return QualType() when a too large array is attempting to be created. This
prevents further errors and some overflows in size calculations.
One overflow was previously triggering an assert.

llvm-svn: 181970
2013-05-16 01:46:09 +00:00
Richard Smith c8adfc8957 Start a page tracking which C++ defect reports have been implemented in Clang.
The page is generated from a text file listing DR numbers and implementation
status, plus a copy of the cwg_index.html from the WG21 website. Recipe:

  $ wget http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_index.html
  $ ./make_cxx_dr_status >! cxx_dr_status.html

The intent here is to go through all the DRs, add tests for each one, then mark
them as done once such tests are committed and passing. I've not linked to this
page from anywhere, since it doesn't contain any useful information yet.

llvm-svn: 181967
2013-05-16 01:23:30 +00:00
Eric Christopher d78d4c91d1 Whitespace.
llvm-svn: 181966
2013-05-16 00:52:23 +00:00
Eric Christopher 0fdcb315e3 80-columns.
llvm-svn: 181965
2013-05-16 00:52:20 +00:00
Eric Christopher 75e1768b46 Replace a pile of calls with an instance variable that's set
once. Should be no functional change.

llvm-svn: 181964
2013-05-16 00:45:23 +00:00
Eric Christopher 2ec1211c87 Add a test to verify that -flimit-debug-info is working in some way.
llvm-svn: 181963
2013-05-16 00:45:20 +00:00
Eric Christopher c65920b203 Fix comment.
llvm-svn: 181962
2013-05-16 00:45:18 +00:00
Eric Christopher a45ae1f1f1 Remove xfail'd test. This method of limiting debug info isn't
going to go anywhere.

llvm-svn: 181961
2013-05-16 00:45:15 +00:00
Eric Christopher b2a008c615 Whitespace.
llvm-svn: 181960
2013-05-16 00:45:12 +00:00
Adrian Prantl 48b3c7dd3d Clarify comment.
llvm-svn: 181959
2013-05-16 00:41:31 +00:00
Adrian Prantl 5e5ff6e170 Set the debug location for landing pad code to the canonical EH location.
It used to point to the first call that caused the landing pad to
be generated.

rdar://problem/13888152

llvm-svn: 181958
2013-05-16 00:41:29 +00:00
Adrian Prantl dc237b52bc Cleanup: Use a member variable to store the SourceLocation for EH code.
rdar://problem/13888152

llvm-svn: 181957
2013-05-16 00:41:26 +00:00
David Blaikie db35281468 Revert "Debug Info: Using declarations/DW_TAG_imported_declaration of variables, types, and functions."
This reverts commit r181393 (git 3923d6a87fe7b2c91cc4a7dbd90c4ec7e2316bcd).

This seems to be emitting too much extra debug info for two (known)
reasons:
* full class definitions are emitted when only declarations are expected
* unused using declarations still produce DW_TAG_imported_declarations

llvm-svn: 181947
2013-05-15 23:46:19 +00:00
Jordan Rose a7f94ce8a3 Remove unused, awkward CFGStmtVisitor and subclasses.
This class is a StmtVisitor that distinguishes between block-level and
non-block-level statements in a CFG. However, it does so using a hard-coded
idea of which statements might be block-level, which probably isn't accurate
anymore. The only implementer of the CFGStmtVisitor hierarchy was the
analyzer's DeadStoresChecker, and the analyzer creates a linearized CFG
anyway (every non-trivial statement is a block-level statement).

This also allows us to remove the block-expr map ("BlkExprMap"), which
mapped statements to positions in the CFG. Apart from having a helper type
that really should have just been Optional<unsigned>, it was only being
used to ask /if/ a particular expression was block-level, for traversal
purposes in CFGStmtVisitor.

llvm-svn: 181945
2013-05-15 23:22:55 +00:00
Fariborz Jahanian 0b11ef2ef0 Objective-C: More cases of -Wsign-conversion not
working on new Objective-C array subscripting
syntax. // rdar://13855682

llvm-svn: 181940
2013-05-15 22:25:03 +00:00
Samuel Benzaquen a76d8cd05b Test commit
llvm-svn: 181915
2013-05-15 19:49:05 +00:00
Fariborz Jahanian 2cb4a957c6 Objective-C: patch to issue the conversion
warning when property-dot syntax is used
with -Wsign-conversion. // rdar://13855394

llvm-svn: 181914
2013-05-15 19:03:04 +00:00
Jordan Rose 519188414e [analyzer] Put back DefaultBool's implicit conversion to bool.
DefaultBool is basically just "bool with a default constructor", so it
really should implicitly convert to bool. In fact, it should convert to
bool&, so that it could be passed to functions that take bools by reference.

This time, mark the operator bool& as implicit to promise that it's
deliberate.

llvm-svn: 181908
2013-05-15 18:08:15 +00:00