Eli Friedman [Tue, 18 Dec 2012 00:52:36 +0000 (00:52 +0000)]
More conservative fix for <rdar://problem/12847524> (a crash printing diagnostic ranges).
I'm not really happy with this fix, but I'm confident it's correct.
Chandler Carruth [Mon, 17 Dec 2012 21:40:04 +0000 (21:40 +0000)]
Fix PR14625 by teaching the driver to detect PWD for assembly files.
This also requires adding support to -cc1as for passing the detecting
PWD down through LLVM's debug info (which in turn required the LLVM
change in r170371).
The test case is weak (we only test the driver behavior) because there
is currently to infrastructure for running cc1as in the test suite. So
those four lines are untested (much like all other lines in that file),
but we have a test for the same pattern using llvm-mc in the LLVM
repository.
Anna Zaks [Mon, 17 Dec 2012 20:08:51 +0000 (20:08 +0000)]
[analyzer] Implement "do not inline large functions many times"
performance heuristic
After inlining a function with more than 13 basic blocks 32 times, we
are not going to inline it anymore. The idea is that inlining large
functions leads to drastic performance implications. Since the function
has already been inlined, we know that we've analyzed it in many
contexts.
The following metrics are used:
- Large function is a function with more than 13 basic blocks (we
should switch to another metric, like cyclomatic complexity)
- We consider that we've inlined a function many times if it's been
inlined 32 times. This number is configurable with -analyzer-config
max-times-inline-large=xx
This heuristic addresses a performance regression introduced with
inlining on one benchmark. The analyzer on this benchmark became 60
times slower with inlining turned on. The heuristic allows us to analyze
it in 24% of the time. The performance improvements on the other
benchmarks I've tested with are much lower - under 10%, which is
expected.
Daniel Jasper [Mon, 17 Dec 2012 14:34:14 +0000 (14:34 +0000)]
Add basic support for splitting before function calls if it can't be
avoided.
This required a minor modification of the memoization as now the
"CurrentPenalty" depends on whether or not we break before the current
token. Therefore, the CurrentPenalty should not be memoized but added
after retrieving a value from memory. This should not affect the runtime
behavior.
Daniel Jasper [Mon, 17 Dec 2012 11:29:41 +0000 (11:29 +0000)]
Fix several formatting problems.
More specifically:
- Improve formatting of static initializers.
- Fix formatting of lines comments in enums.
- Fix formmating of trailing line comments.
Bill Schmidt [Mon, 17 Dec 2012 04:20:17 +0000 (04:20 +0000)]
This patch fixes PR13624, which notes a 64-bit PowerPC ELF ABI
incompatibility with how complex values are returned. It is sufficient
to flag all complex types as direct rather than indirect.
A new test case is provided that checks correct IR generation for the
various supported flavors of _Complex.
Jordan Rose [Sat, 15 Dec 2012 00:37:01 +0000 (00:37 +0000)]
Docs: redirect "static analysis extensions" section to the analyzer site.
The notes on the objc_method_family and ns_returns_retained-type attributes
have been moved to the Objective-C section, since both are used by ARC.
The notes on analyzer_noreturn are now only on the analyzer site.
The inadequacy of these docs was noticed months ago by Jonathan Sauer;
I'm only just now getting around to cleaning them up.
Jordan Rose [Sat, 15 Dec 2012 00:36:53 +0000 (00:36 +0000)]
Remove old description of analyzer internals from public docs.
The file still exists in docs/analyzer/, but it won't be linked to from
clang.llvm.org or processed as part of the default Sphinx doc-build.
RegionStore has changed a lot from what Ted and Zhongxing describe here!
Edwin Vane [Fri, 14 Dec 2012 18:58:25 +0000 (18:58 +0000)]
Style and Doc fix for CommonOptionsParser
- Renaming GetCompilations() and GetSourcePathList() to follow LLVM
style.
- Updating docs to reflect name change.
- Also updating help text to not mention clang-check since this class
can be used by any tool.
Nico Weber [Fri, 14 Dec 2012 18:22:38 +0000 (18:22 +0000)]
Don't require a space between the two ">" in "vector<id<protocol>>" in objc++11.
C++11 allowed writing "vector<vector<int>>" without a space between the two ">".
This change allows this for protocols in template lists too in -std=c++11 mode,
and improves the diagnostic in c++98 mode.
David Blaikie [Thu, 13 Dec 2012 22:29:06 +0000 (22:29 +0000)]
Debug Info: Emit vtables pointer members as artificial.
I wasn't sure where to put the test case for this, but this seemed like as good
a place as any. I had to reorder the tests here to make them legible while
still matching the order of metadata output in the IR file (for some reason
making it virtual changed the ordering).
Relevant commit to fix up LLVM to actually respect 'artificial' member
variables is coming once I write up a test case for it.
[PCH] Make the new PCH format (control block) backwards compatible and
don't crash when loading a PCH with the older format.
The introduction of the control block broke compatibility with PCHs from
older versions. This patch allows loading (and rejecting) PCHs from an older
version and allows newer PCHs to be rejected from older clang versions as well.
Roman Divacky [Thu, 13 Dec 2012 16:09:42 +0000 (16:09 +0000)]
Dont use/link ARCMT, StaticAnalyzer and Rewriter to clang when the user
specifies not to. Dont build ASTMatchers with Rewriter disabled and
StaticAnalyzer when it's disabled.
Without all those three, the clang binary shrinks (x86_64) from ~36MB
to ~32MB (unstripped).
Richard Smith [Thu, 13 Dec 2012 07:11:50 +0000 (07:11 +0000)]
ubsan: Add -fsanitize=bool and -fsanitize=enum, which check for loads of
bit-patterns which are not valid values for enumerated or boolean types.
These checks are the ubsan analogue of !range metadata.
Eli Friedman [Thu, 13 Dec 2012 01:43:21 +0000 (01:43 +0000)]
Using CanQualType::getAs<ArrayType> is unsafe; fix the code currently using it,
and make sure additional uses don't get introduced. <rdar://problem/12858424>.
Anna Zaks [Thu, 13 Dec 2012 00:42:19 +0000 (00:42 +0000)]
[analyzer] Fix a self-init checker false positive.
This is a Band-Aid fix to a false positive, where we complain about not
initializing self to [super init], where self is not coming from the
init method, but is coming from the caller to init.
The proper solution would be to associate the self and it's state with
the enclosing init.
Eli Friedman [Thu, 13 Dec 2012 00:14:59 +0000 (00:14 +0000)]
More hacking on mapDiagnosticRanges to make it handle more cases.
This still isn't quite right, but it fixes a crash.
I factored out findCommonParent because we need it on the result of
getImmediateExpansionRange: for a function macro, the beginning
and end of an expansion range can come out of different
macros/macro arguments, which means the resulting range is a complete
mess to handle consistently.
I also made some changes to how findCommonParent works; it works somewhat
better in some cases, and somewhat worse in others, but I think overall
it's a better balance. I'm coming to the conclusion that mapDiagnosticRanges
isn't using the right algorithm, though: chasing the caret is fundamentally
more complicated than any algorithm which only considers one FileID for the
caret can handle because each SourceLocation doesn't really have a single parent.
We need to follow the same path of choosing expansion locations and spelling
locations which the caret used to come up with the correct range
in the general case.
Sean Silva [Wed, 12 Dec 2012 23:02:30 +0000 (23:02 +0000)]
docs: Initial Sphinx setup for Clang.
I don't think this will be visible just yet on <clang.llvm.org/docs/>
since I don't think that the necessary server-side setup has taken
place.
Don't shoot me over the theme. I don't want to duplicate LLVM's theme
into the clang repo at the moment, so I just used one of Sphinx's
default themes.
[objc] For the ARC error that is emitted when a synthesized property implementation
has inconsistent ownership with the backing ivar, point the error location to the
ivar.
Pointing to the ivar (instead of the @synthesize) is better since this is where a fix is needed.
Also provide the location of @synthesize via a note.
This also fixes the problem where an auto-synthesized property would emit an error without
any location.
John McCall [Wed, 12 Dec 2012 22:21:47 +0000 (22:21 +0000)]
Rewrite calls to bitcast unprototyped functions when emitting a definition.
My variadics patch, r169588, changed these calls to typically be
bitcasts rather than calls to a supposedly variadic function.
This totally subverted a hack where we intentionally dropped
excess arguments from such calls in order to appease the inliner
and a "warning" from the optimizer. This patch extends the hack
to also work with bitcasts, as well as teaching it to rewrite
invokes.
Jordan Rose [Wed, 12 Dec 2012 19:13:44 +0000 (19:13 +0000)]
[analyzer] Don't crash running destructors for multidimensional arrays.
We don't handle array destructors correctly yet, but we now apply the same
hack (explicitly destroy the first element, implicitly invalidate the rest)
for multidimensional arrays that we already use for linear arrays.
Chad Rosier [Wed, 12 Dec 2012 17:52:21 +0000 (17:52 +0000)]
Marking the objc_autoreleaseReturnValue and objc_retainAutoreleaseReturnValue
call sites as tail calls unconditionally. While it's theoretically true that
this is just an optimization, it's an optimization that we very much want to
happen even at -O0, or else ARC applications become substantially harder to
debug. See r169796 for the llvm/fast-isel side of things.
rdar://12553082
Richard Smith [Wed, 12 Dec 2012 02:46:14 +0000 (02:46 +0000)]
Don't warn about disabled macro expansion if we see the name of a function-like macro which isn't immediately followed by '('. FreeBSD's stdio.h #defines foo(x) to (foo)(x), apparently.
Hal Finkel [Tue, 11 Dec 2012 19:59:32 +0000 (19:59 +0000)]
Add -fslp-vectorize to enable bb-vectorize
Add -fslp-vectorize (with -ftree-slp-vectorize as an alias for gcc compatibility)
to provide a way to enable the basic-block vectorization pass. This uses the same
acronym as gcc, superword-level parallelism (SLP), also common in the literature,
to refer to basic-block vectorization.
Nadav suggested this as a follow-up to the adding of -fvectorize.
objective-C blocks: Check for record type when deciding if
byref variable requires extended layout info. to prevent
a crash involving arrays declared __block. // rdar://12787751