Richard Smith [Fri, 13 Jul 2012 23:33:44 +0000 (23:33 +0000)]
PR13360: When deciding the earliest point which inevitably leads to an
uninitialized variable use, walk back over branches where we've reached all the
non-null successors, not just cases where we've reached all successors.
Joel Jones [Fri, 13 Jul 2012 23:26:27 +0000 (23:26 +0000)]
This is one of the first steps at moving to replace target-dependent
intrinsics with target-indepdent intrinsics. The first instruction(s) to be
handled are the vector versions of count leading zeros (ctlz).
The changes here are to clang so that it generates a target independent
vector ctlz when it sees an ARM dependent vector ctlz. The changes in llvm
are to match the target independent vector ctlz and in VMCore/AutoUpgrade.cpp
to update any existing bc files containing ARM dependent vector ctlzs with
target-independent ctlzs. There are also changes to an existing test case in
llvm for ARM vector count instructions and a new test for the bitcode upgrade.
There is deliberately no test for the change to clang, as so far as I know, no
consensus has been reached regarding how to test neon instructions in clang;
q.v. <rdar://problem/8762292>
Richard Trieu [Fri, 13 Jul 2012 21:18:32 +0000 (21:18 +0000)]
Modify tree printing mode for template type diffing. If a diagnostic has
multiple %diff's, only print the first tree and fallback to inline printing
for the rest of the diagnostic.
Rafael Espindola [Fri, 13 Jul 2012 18:04:45 +0000 (18:04 +0000)]
Apply visibility pragmas to class template declarations. This is needed because
we might use the declaration to build a type before seeing the definition.
Richard Smith [Fri, 13 Jul 2012 04:12:04 +0000 (04:12 +0000)]
Provide a special-case diagnostic when two class member functions instantiate
to the same signature. Fix a bug in the type printer which would cause this
diagnostic to print wonderful types like 'const const int *'.
Rafael Espindola [Fri, 13 Jul 2012 01:19:08 +0000 (01:19 +0000)]
Fix a bug in my previous commit. The problem is not that we were not using the
canonical decl for the template, but that we were not merging attributes for
templates at all!
Dmitri Gribenko [Thu, 12 Jul 2012 16:34:32 +0000 (16:34 +0000)]
Always initialize variable. If opening quote is the last character in comment, we will be using an uninitialized value. There is already a test for that in unittests/AST/CommentLexer.cpp, but it seems like we were lucky with the value that got loaded into the variable so the test passed.
Daniel Jasper [Thu, 12 Jul 2012 08:50:38 +0000 (08:50 +0000)]
This commit combines three patches to the ASTMatchers.
One adds matchers for the various parts of a for loop (initializer, condition,
increment), as well as extending the hasBody matcher to work for while and
do-while loops. The second patch adds an isInteger matcher for types.
The third patch fixes a bug in allOf, where a few of the name chages
(AllOf --> allOf) had been missed.
Benjamin Kramer [Thu, 12 Jul 2012 08:34:31 +0000 (08:34 +0000)]
Be lax about trailing whitespace when checking fixit formatting, this depends on locale settings.
If a non-unicode locale is used, the unicode character is escaped and any
byte that is in the escaped representation but not the semicolon will
become whitespace.
Jordan Rose [Thu, 12 Jul 2012 00:16:25 +0000 (00:16 +0000)]
[analyzer] Don't inline virtual calls unless we can devirtualize properly.
Previously we were using the static type of the base object to inline
methods, whether virtual or non-virtual. Now, we try to see if the base
object has a known type, and if so ask for its implementation of the method.
Richard Smith [Wed, 11 Jul 2012 22:37:56 +0000 (22:37 +0000)]
Stop instantiating a class if we hit a static_assert failure. Also, if the
static_assert fails when parsing the template, don't diagnose it again on every
instantiation.
Dmitri Gribenko [Wed, 11 Jul 2012 21:38:39 +0000 (21:38 +0000)]
Enable comment parsing and semantic analysis to emit diagnostics. A few
diagnostics implemented -- see testcases.
I created a new TableGen file for comment diagnostics,
DiagnosticCommentKinds.td, because comment diagnostics don't logically
fit into AST diagnostics file. But I don't feel strongly about it.
This also implements support for self-closing HTML tags in comment
lexer and parser (for example, <br />).
In order to issue precise diagnostics CommentSema needs to know the
declaration the comment is attached to. There is no easy way to find a decl by
comment, so we match comments and decls in lockstep: after parsing one
declgroup we check if we have any new, not yet attached comments. If we do --
then we do the usual comment-finding process.
It is interesting that this automatically handles trailing comments.
We pick up not only comments that precede the declaration, but also
comments that *follow* the declaration -- thanks to the lookahead in
the lexer: after parsing the declgroup we've consumed the semicolon
and looked ahead through comments.
Added -Wdocumentation-html flag for semantic HTML errors to allow the user to
disable only HTML warnings (but not HTML parse errors, which we emit as
warnings in -Wdocumentation).
Introduce a flag in SourceManager to treat non-system source files
as "volatile", meaning there's a high enough chance that they may
change while we are trying to use them.
This flag is only enabled by libclang.
Currently "volatile" source files will be stat'ed immediately
before opening them, because the file size stat info
may not be accurate since when we got it (e.g. from the PCH).
This avoids crashes when trying to reference mmap'ed memory
from a file whose size is not what we expect.
Note that there's still a window for a racing issue to occur
but the window for it should be way smaller than before.
We can consider later on to avoid mmap completely on such files.
Jordan Rose [Wed, 11 Jul 2012 19:58:23 +0000 (19:58 +0000)]
Allow -verify directives to be filtered by preprocessing.
This is accomplished by making VerifyDiagnosticsConsumer a CommentHandler,
which then only reads the -verify directives that are actually in live
blocks of code. It also makes it simpler to handle -verify directives that
appear in header files, though we still have to manually reparse some files
depending on how they are generated.
This requires some test changes. In particular, all PCH tests now have their
-verify directives outside the "header" portion of the file, using the @line
syntax added in r159978. Other tests have been modified mostly to make it
clear what is being tested, and to prevent polluting the expected output with
the directives themselves.
Patch by Andy Gibbs! (with slight modifications)
The new Frontend/verify-* tests exercise the functionality of this commit,
as well as r159978, r159979, and r160053 (Andy's other -verify enhancements).
Daniel Jasper [Wed, 11 Jul 2012 19:13:13 +0000 (19:13 +0000)]
Add a hook to supply a custom CompilationDatabase. To add a custom CompilationDatabase, make it implement findCompilationDatabaseForDirectory in CustomCompilationDatabase.h and set USE_COSTUM_COMPILATION_DATABASE.
Chad Rosier [Wed, 11 Jul 2012 19:08:21 +0000 (19:08 +0000)]
[driver] Fix so that clang can find correct path prefix for libc object files
from GNU binutils supporting multi-arch folder for ARM target.
Patch by Jiangning Liu <jiangning.liu@arm.com>.
Jordan Rose [Wed, 11 Jul 2012 16:50:36 +0000 (16:50 +0000)]
Emit -verify diagnostics even when we have a fatal error.
Previously we'd halt at the fatal error as expected, but not actually emit
any -verify-related diagnostics. This lets us catch cases that emit a
/different/ fatal error from the one we expected.
This is implemented by adding a "force emit" mode to DiagnosticBuilder, which
will cause diagnostics to immediately be emitted regardless of current
suppression. Needless to say this should probably be used /very/ sparingly.
Patch by Andy Gibbs! Tests for all of Andy's -verify patches coming soon.
Rafael Espindola [Wed, 11 Jul 2012 02:15:51 +0000 (02:15 +0000)]
Don't process #pragma visibility during instantiation. The visibility of the
instantiation depends on the template, its arguments and parameters, but not
where it is instantiated.
Eric Christopher [Wed, 11 Jul 2012 01:49:26 +0000 (01:49 +0000)]
The end of a block doesn't necessarily need a line table entry unless
there's something going on there. Remove the unconditional line entry
and only add one if we're emitting cleanups (any other statements
would be handled normally).
Jordan Rose [Tue, 10 Jul 2012 22:08:01 +0000 (22:08 +0000)]
[analyzer] Construct stack variables directly in their VarDecl.
Also contains a number of tweaks to inlining that are necessary
for constructors and destructors. (I have this enabled on a private
branch, but it is very much unstable.)
Jordan Rose [Tue, 10 Jul 2012 22:07:57 +0000 (22:07 +0000)]
[analyzer] Use CallEvent for building inlined stack frames.
In order to accomplish this, we now build the callee's stack frame
as part of the CallEnter node, rather than the subsequent BlockEdge node.
This should not have any effect on perceived behavior or diagnostics.
This makes it safe to re-enable inlining of member overloaded operators.
Jordan Rose [Tue, 10 Jul 2012 22:07:47 +0000 (22:07 +0000)]
[analyzer] Add a CXXDestructorCall CallEvent.
While this work is still fairly tentative (destructors are still left out of
the CFG by default), we now handle destructors in the same way as any other
calls, instead of just automatically trying to inline them.
Jordan Rose [Tue, 10 Jul 2012 22:07:42 +0000 (22:07 +0000)]
[analyzer] Add new PreImplicitCall and PostImplicitCall ProgramPoints.
These are currently unused, but are intended to be used in lieu of PreStmt
and PostStmt when the call is implicit (e.g. an automatic object destructor).
This also modifies the Data1 field of ProgramPoints to allow storing any
pointer-sized value, as opposed to only aligned pointers. This is necessary
to store SourceLocations.
There is currently no BugReporter support for these; they should be skipped
over in any diagnostic output.
This commit also tags checkers that currently rely on function calls only
occurring at StmtPoints.
Axel Naumann [Tue, 10 Jul 2012 16:50:27 +0000 (16:50 +0000)]
Improve r159256 following Chandler's comments:
Implement UniqueFileContainer::erase(), camelCase, add comment on future optimizations of the cache versus de-optimizations of invalidations.
Axel Naumann [Tue, 10 Jul 2012 16:24:07 +0000 (16:24 +0000)]
Clear diagnostic counts after processing the diagnostics.
The consumer might see multiple input files (e.g. for cling) and since r159977 the count is maintained across input files.
Manuel Klimek [Tue, 10 Jul 2012 13:10:51 +0000 (13:10 +0000)]
Adds support for auto-detection of compilation databases
from a source file and changes clang-check to make use of this.
This makes clang-check just work on in-tree builds, and allows
easy setup via a symlink per source directory to make clang-check
work without any extra configuration.
Chris Lattner [Tue, 10 Jul 2012 05:03:05 +0000 (05:03 +0000)]
Jordan points out that this was incorrect: clang should recover from
*errors* with fixits on them by following the recovery advised by the
fixit, but if it is a fixit on a warning, then obviously the AST
should be for the code as-written.