Ted Kremenek [Thu, 5 Aug 2010 00:19:24 +0000 (00:19 +0000)]
Correctly handle 'Class<...>' when examining Cocoa conventions in the static analyzer. Fixes a crash reported in <rdar://problem/8272168>. Patch by Henry Mason!
John McCall [Wed, 4 Aug 2010 23:46:35 +0000 (23:46 +0000)]
Extend the visibility-hidden optimization to linkonce_odr thunks for
functions with in-line definitions, since such thunks will be emitted at any
use of the function.
Completes the feature work for rdar://problem/7523229.
Ted Kremenek [Wed, 4 Aug 2010 20:01:07 +0000 (20:01 +0000)]
Teach SemaChecking::CheckReturnStackAddr about ImplicitCastExprs that convert values to an lvalue. This allows us to warn (again) about returning references to stack variables. (fixes PR 7812).
Douglas Gregor [Wed, 4 Aug 2010 17:07:00 +0000 (17:07 +0000)]
When performing in-process code completion, don't free the remapped
file buffers until the code completion results are destroyed;
diagnostics may end up referring into the source.
Douglas Gregor [Wed, 4 Aug 2010 16:47:14 +0000 (16:47 +0000)]
Add code-completion support directly to ASTUnit, which performs code
completion within the translation unit using the same command-line
arguments for parsing the translation unit. Eventually, we'll reuse
the precompiled preamble to improve code-completion performance, and
this also gives us a place to cache results.
Expose this function via the new libclang function
clang_codeCompleteAt(), which performs the code completion within a
CXTranslationUnit. The completion occurs in-process
(clang_codeCompletion() runs code completion out-of-process).
John McCall [Wed, 4 Aug 2010 08:34:44 +0000 (08:34 +0000)]
Emit standard-library RTTI with external linkage, not weak_odr.
Apply hidden visibility to most RTTI; libstdc++ does not rely on exact
pointer equality for the type info (just the type info names). Apply
the same optimization to RTTI that we do to vtables.
Jordy Rose [Wed, 4 Aug 2010 07:10:57 +0000 (07:10 +0000)]
Change the checker callback cache in GRExprEngine to be more compact (and IMHO a little easier to understand), and add the same sort of caching for EvalAssume (tied for least-used callback), mostly as proof-of-concept.
Before we go further with these, we should figure out a way to reuse the visit-and-cache code in CheckerVisit.
John McCall [Wed, 4 Aug 2010 05:59:32 +0000 (05:59 +0000)]
Some more correctness fixes and code-size optimizations for fragile-ABI
ObjC exceptions:
- don't enter a try for the catch blocks unless there's a finally
- put the setjmp buffer in the locals set for liveness reasons
- dump the sync object into an alloca in the locals set for liveness reasons
Some of this can go away if the backend starts to properly calculate liveness
in the presence of setjmp (which would also be a *much* stabler solution).
Douglas Gregor [Wed, 4 Aug 2010 05:53:38 +0000 (05:53 +0000)]
When we try (but fail) to build a precompiled preamble, wait for a
short "cooling off" period (defaulting to 5 reparses) before trying to
build a precompiled preamble again. Previously, if we failed to build
the precompiled preamble at any time, we just gave up the whole
charade any never tried again.
John McCall [Tue, 3 Aug 2010 22:46:07 +0000 (22:46 +0000)]
Do a very simple pass over every function we emit to infer whether we can
mark it nounwind based on whether it contains any non-nounwind calls.
<rdar://problem/8087431>
Tom Care [Tue, 3 Aug 2010 21:24:13 +0000 (21:24 +0000)]
Improved false positive detection and numerous small issues in UnreachableCodeChecker
- Reporting now uses getUnreachableStmt which returns the Stmt* we should report
- Indexing of reachable and visited blocks now use CFGBlock ID's instead of pointers
- The CFG used in the unreachable search is now the unoptimized CFG
- Added 'Dead code' category to warnings
- Removed obsolete function getCondition
- Simplified false positive detection based on properties of FindUnreachableEntryPoints
Jordy Rose [Tue, 3 Aug 2010 20:44:35 +0000 (20:44 +0000)]
Makes GRState::makeWithStore private, to encourage clients to make store changes through GRState instead of directly accessing the StoreManager. Also adds cover methods for InvalidateRegion(s) and EnterStackFrame to GRState.
This is in preparation for proposed region change notifications. No functionality change.
Douglas Gregor [Tue, 3 Aug 2010 19:06:41 +0000 (19:06 +0000)]
When using a precompiled preamble, keep track of the top-level
declarations that we saw when creating the precompiled preamble, and
provide those declarations in addition to the declarations parsed in
the main source file when traversing top-level declarations. This
makes the use of precompiled preambles a pure optimization, rather
than changing the semantics of the parsed translation unit.
Apart from storing/retrieving the previous redeclaration from PCH, also store/retrieve the most recent
redeclaration. That way we are sure that the full redeclarations chain is loaded.
When using chained PCHs, first declarations point to the most recent redeclarations in the same PCH.
To address this use a REDECLS_UPDATE_LATEST record block to keep track of which first declarations need
to point to a most recent redeclaration in another PCH.
Support x86 AVX 256-bit instructions built-ins. Right now support all of them, but
as soon as we properly codegen the simple vector operations, remove the
unnecessary built-ins/intrinsics from clang and llvm. Also add tests for the new
built-ins
Tom Care [Tue, 3 Aug 2010 01:55:07 +0000 (01:55 +0000)]
Changed GRExprEngine to pass down a reference to itself when checkers are doing postanalysis. This allows the checker to gather information about the state of the engine when it has finished.
- Exposed the worklist and BlockAborted flag in GRCoreEngine
- Changed postanalysis checkers to use the new infrastructure
Ted Kremenek [Mon, 2 Aug 2010 23:46:59 +0000 (23:46 +0000)]
Add 'AnalysisContext::getUnoptimizedCFG()' to allow clients to get access to the original
CFG without any edges pruned out because of trivially solvable conditions (e.g., 'if (0)').
Ted Kremenek [Mon, 2 Aug 2010 21:59:12 +0000 (21:59 +0000)]
Fix idempotent operations false positive caused by ivars not being invalidated in function
calls when the enclosing object had retain/release state. Fixes <rdar://problem/8261992>.
Douglas Gregor [Mon, 2 Aug 2010 20:51:39 +0000 (20:51 +0000)]
When using a precompiled preamble, save the diagnostics produced when
creating the preamble and "replay" them when reusing the
preamble. Also, fix a thinko in the copying of the preamble when
building the precompiled preamble.
Sebastian Redl [Mon, 2 Aug 2010 18:30:12 +0000 (18:30 +0000)]
Query only the latest version of an identifier in the PCH chain. Make sure this version holds the entire declaration chain. This is a much saner solution than trying to merge the info from all elements, and makes redeclarations work properly. Expand the declarations test case to cover more compliated cases.
Sebastian Redl [Mon, 2 Aug 2010 18:27:05 +0000 (18:27 +0000)]
Remove mutable data on TagType and InjectedClassNameType, by instead walking the declaration chain in search of a definition. This is necessary for a sane chained PCH implementation. No observable performance change on Carbon.h syntax-only, and bootstraps cleanly.
Daniel Dunbar [Mon, 2 Aug 2010 15:31:28 +0000 (15:31 +0000)]
Frontend: Change PluginASTAction::ParseArgs to take a CompilerInstance object
for use in reporting diagnostics.
- We don't want to use the Action's own CompilerInstance, because that is only
initialized during file processing and I like that invariant.
Also, if ParseArgs returns false then abandon execution.
Daniel Dunbar [Mon, 2 Aug 2010 05:43:51 +0000 (05:43 +0000)]
Driver: Give Build{Universal,}Actions access to the default host tool chain. I
avoided this originally to enforce that the driver actions aren't toolchain
dependent, but it isn't worth the cumbersone additional hostinfo split.
Zhongxing Xu [Mon, 2 Aug 2010 04:56:14 +0000 (04:56 +0000)]
Improve flat store: MemRegion::getAsOffset() computes a region's offset within
the top-level object. FlatStore now can bind and retrieve element and field
regions.
PR7297 is fixed by flat store.
Daniel Dunbar [Sun, 1 Aug 2010 22:29:51 +0000 (22:29 +0000)]
Driver: Keep track of a separate "install dir", which is the path where clang
was invoked from (which may not be where the executable itself is).
- This allows having e.g., /Developer/usr/bin/clang be a symlink to some other
location, while still making sure the Driver finds 'as', 'ld', etc. relative
to itself.
Eli Friedman [Sun, 1 Aug 2010 22:13:15 +0000 (22:13 +0000)]
PR7777: Set EnabledByDefault to something useful, instead of setting it
randomly. This makes us consistently show "-pedantic" as the warning option
for a warning where appropriate.
John McCall [Sun, 1 Aug 2010 20:20:59 +0000 (20:20 +0000)]
Make a first pass at implementing -Wglobal-constructors. I'm worried that this
will end up bizarrely mirroring CGExprConstant, but that might be the hazard of
this feature.
John McCall [Sun, 1 Aug 2010 00:26:45 +0000 (00:26 +0000)]
Only run the jump-checker if there's a branch-protected scope *and* there's
a switch or goto somewhere in the function. Indirect gotos trigger the
jump-checker regardless, because the conditions there are slightly more
elaborate and it's too marginal a case to be worth optimizing.
Turns off the jump-checker in a lot of cases in C++. rdar://problem/7702918
John McCall [Sat, 31 Jul 2010 23:20:56 +0000 (23:20 +0000)]
Fix fragile-ABI ObjC exceptions in the presence of optimization with
the magic of inline assembly. Essentially we use read and write hazards
on the set of local variables to force flushing locals to memory
immediately before any protected calls and to inhibit optimizing locals
across the setjmp->catch edge. Fixes rdar://problem/8160285