Eli Friedman [Sat, 7 Nov 2009 00:02:45 +0000 (00:02 +0000)]
Make sure isCopyAssignment is only true for actual copy assignment operators,
instead of all assignment operators. The mistake messes up IRGen because
it ends up assuming that the assignment operator is actually the implicit
copy assignment operator, and therefore tries to emit the RHS as an lvalue.
Douglas Gregor [Sat, 7 Nov 2009 00:00:49 +0000 (00:00 +0000)]
Various improvements to Clang's code-completion infrastructure:
- Introduce more code-completion string "chunk" kinds that describe
symbols, the actual text that the user is expected to type, etc.
- Make the generation of macro results optional, since it can be
slow
- Make code-completion accessible through the C API, marshalling the
code-completion results through a temporary file (ick) to maintain
process separation.
Since default writable attribute is 'assign', allow
specification of 'assign' (no warning to be issued),
when a continuation class makes a 'readonly' attribute
'readwrite' but also specifies the 'assign' attribute.
(this matches gcc's behavior and prevents exessive
warnings)/
Ted Kremenek [Fri, 6 Nov 2009 20:16:31 +0000 (20:16 +0000)]
Sentence-case bug type, and pull tests from region-only-test.c into misc-ps-region.store.m (removing an extra unneeded test file). Also add a bunch of FIXME comments for future enhancements.
John McCall [Fri, 6 Nov 2009 08:49:08 +0000 (08:49 +0000)]
Improve the -Wsign-compare heuristics:
* If the unsigned type is smaller than the signed type, never warn, because
its value will not change when zero-extended to the larger type.
* If we're testing for (in)equality, and the unsigned value is an integer
constant whose sign bit is not set, never warn, because even though the
signed value might change, it can't affect the result of the equality.
Also make the comparison test cases much more rigorous, and have them expose
the subtle differences between C and C++ here.
John McCall [Fri, 6 Nov 2009 07:53:21 +0000 (07:53 +0000)]
Create a warning group "non-gcc" for diagnostics which are not enabled
by default in GCC. Users who want to emulate gcc's warning behavior
exactly should be able to use CC="clang -Wno-non-gcc"; this should help
projects to transition.
Douglas Gregor [Fri, 6 Nov 2009 06:30:47 +0000 (06:30 +0000)]
Rework the fix-it hint for code like
get_origin->x
where get_origin is actually a function and the user has forgotten the
parentheses. Instead of giving a lame note for the fix-it, give a
full-fledge error, early, then build the call expression to try to
recover.
Ted Kremenek [Fri, 6 Nov 2009 02:24:13 +0000 (02:24 +0000)]
static analyzer: refactor checking logic for returning the address of a stack variable or a garbage
value into their own respective subclasses of Checker (and put them in .cpp files where their
implementation details are hidden from GRExprEngine).
Douglas Gregor [Fri, 6 Nov 2009 01:14:41 +0000 (01:14 +0000)]
If we have a C-style cast, functional cast, or a static_cast to a
class type, don't perform the array-to-pointer or function-to-pointer
conversions, because we may end up binding a reference to a function
or array.
With this change, FileCheck now passes -fsyntax-only!
Douglas Gregor [Fri, 6 Nov 2009 01:02:41 +0000 (01:02 +0000)]
When we encounter a derived-to-base conversion when performing an
implicit conversion sequence, check the validity of this conversion
and then perform it.
This patch implements Sema for clause 13.3.3.1p4.
It has to do with vararg constructors used as conversion
functions. Code gen needs work. This is WIP.
Douglas Gregor [Thu, 5 Nov 2009 20:54:04 +0000 (20:54 +0000)]
Be a little more careful when trying to extract a TypeDecl from a enum/class/struct/union specifier; in invalid code, we may also see ClassTemplateDecls.
Douglas Gregor [Thu, 5 Nov 2009 17:49:26 +0000 (17:49 +0000)]
Eliminate some false positives due to a thinko in the "'blah' is
always zero in this context" warning logic. Also, make the diagnostic
itself more precise when referring to pointer values ("NULL" vs. "zero").
Sebastian Redl [Thu, 5 Nov 2009 16:36:20 +0000 (16:36 +0000)]
When collecting types for built-in candidates, make arrays decay to pointers. Otherwise, subscripting an array leads to no candidates at all. Fixes PR5360.
Daniel Dunbar [Thu, 5 Nov 2009 16:36:19 +0000 (16:36 +0000)]
Add clang_site_config user variable, so that extra tests (e.g., utils/C++Syntax)
can always find the main clang site config (when invoked via CMake/Makefiles, at
least).
Sebastian Redl [Thu, 5 Nov 2009 15:52:31 +0000 (15:52 +0000)]
Allow the element type of arrays to be incomplete in C++.
This fixes PR5048. Also fix a bug where zero-sized arrays weren't warned about when the size was unsigned.
Douglas Gregor [Thu, 5 Nov 2009 13:06:35 +0000 (13:06 +0000)]
Fixed two places where we needed to force completion of a type
(without complaining if it fails) to get proper semantics: reference
binding with a derived-to-base conversion and the enumeration of
constructors for user-defined conversions. There are probably more
cases to fix, but my prior attempt at statically ensuring that
complete-type checking always happens failed. Perhaps I'll try again.
With this change, Clang can parse include/llvm/*.h!
John McCall [Thu, 5 Nov 2009 09:23:39 +0000 (09:23 +0000)]
Implement the conditional-operator part of -Wsign-compare. Turn
DiagnoseSignCompare into Sema::CheckSignCompare and call it from more places.
Add some enumerator tests. These seem to expose some oddities in the
types we're converting C++ enumerators to; in particular, they're converting
to unsigned before int, which seems to contradict 4.5 [conv.prom] p2.
Note to self: stop baiting Doug in my commit messages.
Daniel Dunbar [Thu, 5 Nov 2009 02:42:12 +0000 (02:42 +0000)]
Replace DiagnosticClient::setLangOptions with {Begin,End}SourceFile, and clarify
invariants (diagnostics with source informations must occur between
{Begin,End}SourceFile).
Daniel Dunbar [Thu, 5 Nov 2009 02:11:37 +0000 (02:11 +0000)]
Remove clang-cc -html-diags option, this doesn't fit in well and we get plenty
of coverage of this from the analyzer.
If this bothers you, I can add it back in a mode where non-source diagnostics go
to stderr and only source diagnostics use -html-diags, but I don't think anyone
uses this.
Ted Kremenek [Thu, 5 Nov 2009 02:09:23 +0000 (02:09 +0000)]
Acting on Daniel's nagging, remove PathDiagnosticClientFactory() and
migrate work in the destructors of PathDiagnosticClients from their
destructors to FlushReports(). The destructors now currently call
FlushReports(); this will be fixed in a subsequent patch.
Douglas Gregor [Thu, 5 Nov 2009 00:51:44 +0000 (00:51 +0000)]
When instantiating a UnaryOperator, allow the resulting expression to
still be dependent or invoke an overloaded operator. Previously, we
only supported builtin operators.
BinaryOperator/CompoundAssignOperator didn't have this issue because
we always built a CXXOperatorCallExpr node, even when name lookup
didn't find any functions to save until instantiation time. Now, that
code builds a BinaryOperator or CompoundAssignOperator rather than a
CXXOperatorCallExpr, to save some space.
Ted Kremenek [Thu, 5 Nov 2009 00:42:23 +0000 (00:42 +0000)]
Modify GRExprEngine::EvalBind() to take both a "store expression" and
an "assign expression", representing the expressions where the value
binding occurs and the assignment takes place respectively. These are
largely syntactic clues for better error reporting.
Douglas Gregor [Wed, 4 Nov 2009 22:49:18 +0000 (22:49 +0000)]
When starting a C++ member access expression, make sure to compute the
type of the object even when it is dependent. Specifically, this makes
sure that we get the right type for "this->", which is important when
performing name lookup into this scope to determine whether an
identifier or operator-function-id is a template name.