Tom Care [Wed, 25 Aug 2010 22:37:26 +0000 (22:37 +0000)]
Improved the handling of blocks and block variables in PseudoConstantAnalysis
- Removed the assumption that __block vars are all non-constant
- Simplified some repetitive code in RunAnalysis
- Added block walking support
- Code/comments cleanup
- Separated out test for block pseudoconstants
Ted Kremenek [Wed, 25 Aug 2010 22:16:02 +0000 (22:16 +0000)]
When annotating tokens, don't fallback to annotating with a null cursor for cursors that come before a macro instantiation. Fixes <rdar://problem/7974151>.
Douglas Gregor [Wed, 25 Aug 2010 22:15:42 +0000 (22:15 +0000)]
Move the sorting of code-completion results out of the main path and
into the clients, e.g., the printing code-completion consumer and
c-index-test. Clients may want to re-sort the results anyway.
John McCall [Wed, 25 Aug 2010 22:03:47 +0000 (22:03 +0000)]
Split out a header to hold APIs meant for the Sema implementation from Sema.h.
Clients of Sema don't need to know (for example) the list of diagnostics we
support.
Douglas Gregor [Wed, 25 Aug 2010 18:41:16 +0000 (18:41 +0000)]
When combining the code-completion results from Sema long with the
code-completion results cached by ASTUnit, sort the resulting result
set. This makes testing far, far easier, so this commit also includes
tests for the previous few fixes.
Douglas Gregor [Wed, 25 Aug 2010 18:07:12 +0000 (18:07 +0000)]
Initialize the translation-unit scope before lexing the first
token. The first token might be something that ends up triggering code
completion, which in turn requires a valid Scope. Test case forthcoming.
Douglas Gregor [Wed, 25 Aug 2010 18:04:15 +0000 (18:04 +0000)]
Fix an off-by-one error when computing the precompiled preamble for
code completion. We were allowing the preamble to include the line
that we're code-completing on. Again, testcase is forthcoming.
Douglas Gregor [Wed, 25 Aug 2010 17:04:25 +0000 (17:04 +0000)]
Introduce a preprocessor code-completion hook for contexts where we
expect "natural" language and should not provide any completions,
e.g., comments, string literals, #error.
Chandler Carruth [Wed, 25 Aug 2010 08:27:02 +0000 (08:27 +0000)]
Support explicit instantiation of function templates and members of class
templates when only the declaration is in scope. This requires deferring the
instantiation to be lazy, and ensuring the definition is required for that
translation unit. We re-use the existing pending instantiation queue,
previously only used to track implicit instantiations which were required to be
lazy. Fixes PR7979.
A subsequent change will rename *PendingImplicitInstantiations to
*PendingInstatiations for clarity given its broader role.
John McCall [Wed, 25 Aug 2010 02:50:31 +0000 (02:50 +0000)]
Expression statements undergo lvalue-to-rvalue conversion in C,
but not in C++, so don't emit aggregate loads of volatile references
in null context in C++. Happens to have been caught by an assertion.
We do not get the scalar case right. Volatiles are really broken.
Douglas Gregor [Wed, 25 Aug 2010 01:08:01 +0000 (01:08 +0000)]
When performing completions involving Objective-C method declarations
(e.g., for message sends or method declaration/definition
completions), adjust methods that come from a base class.
Douglas Gregor [Tue, 24 Aug 2010 23:58:17 +0000 (23:58 +0000)]
Give a slight preference to functions returning "void" when we're
performing code completion at the statement level (rather than in an
arbitrary expression).
Douglas Gregor [Tue, 24 Aug 2010 23:40:45 +0000 (23:40 +0000)]
In code-completion contexts where both types and other values are
present, prefer values to types, since it's more common to compute
with values than it is to declare new entities or perform type
casts. So, tweak the ranking of types vs. other declarations and
constants accordingly.
John McCall [Tue, 24 Aug 2010 22:52:39 +0000 (22:52 +0000)]
When trying to resolve the address of an overloaded expression,
only form pointers-to-member if the expression has the appropriate
form. This avoids assertions later on on invalid code, but also
allows us to properly resolve mixed-staticity overloads.
Daniel Dunbar [Tue, 24 Aug 2010 21:39:55 +0000 (21:39 +0000)]
tests: Use REQUIRES: instead of XFAIL: for crash recovery tests; running them on
Windows breaks things (because it pops up dialogs) since we don't have crash
recovery support there (yet).
Chris Lattner [Tue, 24 Aug 2010 21:09:16 +0000 (21:09 +0000)]
Implement -iwithsysroot, an apple extension which is a close cousin of -isystem.
Instead of implementing -isystem, I accidentally implemented this cousin. Next
up is to implement -isystem right.
Tom Care [Tue, 24 Aug 2010 21:09:07 +0000 (21:09 +0000)]
Improvements to IdempotentOperationChecker and its use of PseudoConstantAnalysis
- Added wasReferenced function to PseudoConstantAnalysis to determine if a variable was ever referenced in a function (outside of a self-assignment)
- BlockDeclRefExpr referenced variables are now explicitly added to the non-constant list
- Remove unnecessary ignore of implicit casts
- Generalized parameter self-assign detection to detect deliberate self-assigns of variables to avoid unused variable warnings
- Updated test cases with deliberate self-assignments
- Fixed bug with C++ references and pseudoconstants
- Added test case for C++ references and pseudoconstants
Douglas Gregor [Tue, 24 Aug 2010 20:21:13 +0000 (20:21 +0000)]
Implement preprocessor code completion where a macro name is expected,
e.g., after #ifdef/#ifndef or #undef, or inside a defined <macroname>
expression in a preprocessor conditional.
Fix a bug in nonfragile-abi2 when attempting to diagnose
previous use of a synthesized 'ivar' with property of same name
declared as @dynamic. In this case, 'ivar' is in the
inherited class and no diagnostics should be issued.
Daniel Dunbar [Tue, 24 Aug 2010 16:47:49 +0000 (16:47 +0000)]
Driver/Clang: Forward -Wa, and -Xassembler to clang -cc1 when using the
integrated assembler. For now this mostly just means that we will error out if
someone tries to use this mechanism to send an argument to the assembler.
John McCall [Tue, 24 Aug 2010 08:50:51 +0000 (08:50 +0000)]
More header elimination. The goal of all this is to allow Parser to
#include Sema.h while keeping all the AST declarations opaque. That may
not be reasonably attainable, though.
John McCall [Tue, 24 Aug 2010 06:29:42 +0000 (06:29 +0000)]
OwningExprResult -> ExprResult. This patch brought to you by
M-x query-replace-regexp
\(Sema::\|Action::\|Parser::\|\)Owning\(Expr\|Stmt\)Result -> \2Result
Move ExecuteCompilerInvocation to a new library FrontendTool
r110903 introduced a dependency from Frontend to every library that
declared an Action by introducing Action references that previously
resided in the driver in the file ExecuteCompilerInvocation.cpp.
This patch moves ExecuteCompilerInvocation to a new library named
FrontendTool which is intended to bear these dependencies.
Douglas Gregor [Mon, 23 Aug 2010 23:51:41 +0000 (23:51 +0000)]
When calling a function or messaging a method marked "sentinel", add
the ", nil", ", NULL", or ", (void*)0" to the end of the code
completion, since it always has to be there anyway.