John McCall [Mon, 21 Sep 2009 23:43:11 +0000 (23:43 +0000)]
Change all the Type::getAsFoo() methods to specializations of Type::getAs().
Several of the existing methods were identical to their respective
specializations, and so have been removed entirely. Several more 'leaf'
optimizations were introduced.
The getAsFoo() methods which imposed extra conditions, like
getAsObjCInterfacePointerType(), have been left in place.
Douglas Gregor [Mon, 21 Sep 2009 20:12:40 +0000 (20:12 +0000)]
When providing a code-completion suggestion for a hidden name, include
a nested-name-specifier that describes how to refer to that name. For
example, given:
struct Base { int member; };
struct Derived : Base { int member; };
the code-completion result for a member access into "Derived" will
provide both "member" to refer to Derived::member (no qualification needed) and
"Base::member" to refer to Base::member (qualification included).
Douglas Gregor [Mon, 21 Sep 2009 19:57:38 +0000 (19:57 +0000)]
Enhance "case" code completion in C++ to suggest qualified names for
enumerators when either the user intentionally wrote a qualified name
(in which case we just use that nested-name-specifier to match
the user's code) or when this is the first "case" statement and we
need a qualified name to refer to an enumerator in a different scope.
Douglas Gregor [Mon, 21 Sep 2009 16:56:56 +0000 (16:56 +0000)]
Refactor and simplify the CodeCompleteConsumer, so that all of the
real work is performed within Sema. Addresses Chris's comments, but
still retains the heavyweight list-of-multimaps data structure.
Daniel Dunbar [Mon, 21 Sep 2009 03:03:47 +0000 (03:03 +0000)]
Change ASTUnit to only initialize the predefines buffer to the suggested predefines.
- It isn't really clear what to do with the preprocessor here, but this is more sensible.
Daniel Dunbar [Mon, 21 Sep 2009 03:03:22 +0000 (03:03 +0000)]
Add Diagnostic to Indexer, and have it keep its own FileManager instead of taking an external reference (which was leaked in the case of the CIndex library).
Nick Lewycky [Sat, 19 Sep 2009 20:00:52 +0000 (20:00 +0000)]
Make clang stop relying on ConstantStruct::get's default value for isPacked
which will be going away (ie. it's becoming a required parameter) later today.
Douglas Gregor [Fri, 18 Sep 2009 23:55:56 +0000 (23:55 +0000)]
In C++ code completion, only suggest the "template" keyword after ".",
"->", or "::" if we will be looking into a dependent context. It's not
wrong to use the "template" keyword, but it's to needed, either.
Douglas Gregor [Fri, 18 Sep 2009 23:21:38 +0000 (23:21 +0000)]
Make the construction of the code-completion string for a function
template smarter, by taking into account which function template
parameters are deducible from the call arguments. For example,
Re-introduce diagnostic caching in BugReporter that was originally added in
r82198 and then reverted. This is an intermediate solution, as diagnostic
caching should not rely on static variables.
Douglas Gregor [Fri, 18 Sep 2009 22:15:54 +0000 (22:15 +0000)]
Introduce code completion strings, which describe how to *use* the
results of code completion, e.g., by providing function call syntax
with placeholders for each of the parameters.
Douglas Gregor [Fri, 18 Sep 2009 19:03:04 +0000 (19:03 +0000)]
Introduce four new code-completion hooks for C++:
- after "using", show anything that can be a nested-name-specifier.
- after "using namespace", show any visible namespaces or namespace aliases
- after "namespace", show any namespace definitions in the current scope
- after "namespace identifier = ", show any visible namespaces or
namespace aliases
Douglas Gregor [Fri, 18 Sep 2009 17:42:29 +0000 (17:42 +0000)]
For code completion in C++ member access expressions and tag names,
look into the current scope for anything that could start a
nested-names-specifier. These results are ranked worse than any of the
results actually found in the lexical scope.
Perform a little more pruning of the result set, eliminating
constructors, __va_list_tag, and any duplication of declarations in
the result set. For the latter, implemented
NamespaceDecl::getCanonicalDecl.
Douglas Gregor [Fri, 18 Sep 2009 15:51:54 +0000 (15:51 +0000)]
When gathering results for code completion, only include hidden
results when there is some way to refer to them in the language, such
as with a qualified name in C++.
Douglas Gregor [Fri, 18 Sep 2009 15:37:17 +0000 (15:37 +0000)]
Implement code completion for tags, e.g., code completion after "enum"
will provide the names of various enumerations currently
visible. Introduced filtering of code-completion results when we build
the result set, so that we can identify just the kinds of declarations
we want.
This implementation is incomplete for C++, since we don't consider
that the token after the tag keyword could start a
nested-name-specifier.
Revert most of r82198, which was causing a large number of crashes
when running the analyzer on real projects. We'll keep the change to
AnalysisManager.cpp in r82198 so that -fobjc-gc analyzes code
correctly in both GC and non-GC modes, although this may emit two
diagnostics for each bug in some cases (a better solution will come
later).
Introduce caching of diagnostics in BugReporter. This provides extra
pruning of diagnostics that may be emitted multiple times. This is
accomplished by adding FoldingSet profiling support to PathDiagnostic,
and then having BugReporter record what diagnostics have been issued.
This was motived to a serious bug introduced by moving the
'divide-by-zero' checking outside of GRExprEngine into a separate
'Checker' class. When analyzing code using the '-fobjc-gc' option, a
given function would be analyzed twice, but the second time various
"internal checks" would be disabled to avoid emitting multiple
diagnostics (e.g., "null dereference") for the same issue. The
problem is that such checks also effect path pruning and don't just
emit diagnostics. This resulted in an assertion failure involving a
real divide-by-zero in some analyzed code where we would get an
assertion failure in APInt because the 'DivZero' check was disabled
and didn't prune the logic that resulted in the divide-by-zero in the
analyzer.
The implemented solution is somewhat of a hack, and may not perform
extremely well. This will need to be cleaned up over time.
As a regression test, 'misc-ps.m' has been modified so that its tests
are run using -fobjc-gc to test this diagnostic pruning behavior.
Douglas Gregor [Thu, 17 Sep 2009 21:32:03 +0000 (21:32 +0000)]
Initial implementation of a code-completion interface in Clang. In
essence, code completion is triggered by a magic "code completion"
token produced by the lexer [*], which the parser recognizes at
certain points in the grammar. The parser then calls into the Action
object with the appropriate CodeCompletionXXX action.
Sema implements the CodeCompletionXXX callbacks by performing minimal
translation, then forwarding them to a CodeCompletionConsumer
subclass, which uses the results of semantic analysis to provide
code-completion results. At present, only a single, "printing" code
completion consumer is available, for regression testing and
debugging. However, the design is meant to permit other
code-completion consumers.
This initial commit contains two code-completion actions: one for
member access, e.g., "x." or "p->", and one for
nested-name-specifiers, e.g., "std::". More code-completion actions
will follow, along with improved gathering of code-completion results
for the various contexts.
[*] In the current -code-completion-dump testing/debugging mode, the
file is truncated at the completion point and EOF is translated into
"code completion".
Daniel Dunbar [Thu, 17 Sep 2009 19:55:53 +0000 (19:55 +0000)]
Tweak clang testing.
- Move CMake to using the new test runner.
- Switch Makefiles to use the lit.site.cfg.in template.
- Remove explicit --path arguments, instead this gets written into the site
configuration. This means running lit from the command line should use the
exact same configuration as is used in 'make test', assuming it can find the
site configuration file. You still need to run 'make test' (or the cmake
build target equivalent) at least once.
Douglas Gregor [Thu, 17 Sep 2009 19:51:30 +0000 (19:51 +0000)]
Merge uninstantiated default arguments more carefully, and try not to
complain about specializations of member functions that are not
definitions. Fixes PR4995.