Commit Graph

6046 Commits

Author SHA1 Message Date
Douglas Gregor 869ad45f8f Retain complete source-location information for C++
nested-name-specifiers throughout the parser, and provide a new class
(NestedNameSpecifierLoc) that contains a nested-name-specifier along
with its type-source information.

Right now, this information is completely useless, because we don't
actually store the source-location information anywhere in the
AST. Call this Step 1/N.

llvm-svn: 126391
2011-02-24 17:54:50 +00:00
Axel Naumann 016538ad2a From Vassil Vassilev:
Add an interface for last resort, unqualified lookup. It can provide results for unqualified lookup when Sema fails to find anything itself.

llvm-svn: 126387
2011-02-24 16:47:47 +00:00
Chris Lattner abcf38a064 compute the integer width, not the memory width here. We want to know that
_Bool is 1 bit, not 8.  This fixes an assertion on the testcase, which is
PR9304 and rdar://9045501.

llvm-svn: 126368
2011-02-24 07:31:28 +00:00
Chris Lattner 190aa10fe6 rework processing of unavailable and deprecated attributes to avoid
unneeded allocation of an empty StringLiteral when these don't have
a message.

llvm-svn: 126364
2011-02-24 05:42:24 +00:00
Douglas Gregor 7b26ff912f Teach NestedNameSpecifier to keep track of namespace aliases the same
way it keeps track of namespaces. Previously, we would map from the
namespace alias to its underlying namespace when building a
nested-name-specifier, losing source information in the process.

llvm-svn: 126358
2011-02-24 02:36:08 +00:00
Douglas Gregor 2ab3fee3f3 Tweak the CXXScopeSpec API a bit, so that we require the
nested-name-specifier and source range to be set at the same time.

llvm-svn: 126347
2011-02-24 00:49:34 +00:00
Douglas Gregor 90c9972fb2 Teach CXXScopeSpec to handle the extension of a nested-name-specifier
with another component in the nested-name-specifiers, updating its
representation (a NestedNameSpecifier) and source-location information
(currently a SourceRange) simultaneously. This is groundwork for
adding source-location information to nested-name-specifiers.

llvm-svn: 126346
2011-02-24 00:17:56 +00:00
Chandler Carruth 60ed89dc54 Handle value dependent LHS as well as RHS. Test both of these, they
don't seem to have been covered by our tests previously.

This should fix bootstrap failure.

llvm-svn: 126345
2011-02-24 00:03:53 +00:00
Chandler Carruth 4c6fdca035 Implement a warning for known shift overflows on constant shift
expressions. Consider the code:

  int64_t i = 10 << 30;

This compiles fine, but most developers expect it to produce the value
for 10 gigs, not -2 gigs. This is actually undefined behavior because
the LHS is a signed integer type.

The warning is currently gated behind -Wshift-overflow.

There is a special case where only the sign bit is overridden that gets
a custom error message and is by default ignored. This case is much less
likely to cause observed buggy behavior, it's just undefined behavior
according to the spec. This warning can be enabled with
-Wshift-sign-overflow.

Original patch by Oleg Slezberg, with style tweaks and some correctness
fixes by me.

llvm-svn: 126342
2011-02-23 23:34:11 +00:00
Ted Kremenek e4b316c15c Fix bogus -Warray-bounds warning involving 'array[true]' reported in PR 9296.
llvm-svn: 126341
2011-02-23 23:06:04 +00:00
Chandler Carruth e71b378dc7 Fix the behavior of -Wignored-qualifiers on return type qualifiers in
several ways. We now warn for more of the return types, and correctly
locate the ignored ones. Also adds fix-it hints to remove the ignored
qualifiers. Fixes much of PR9058, although not all of it.

Patch by Hans Wennborg, a couple of minor style tweaks from me.

llvm-svn: 126321
2011-02-23 18:51:59 +00:00
Anders Carlsson d99dbcc2a9 Don't give an error for 'try' and 'throw' if they occur in system headers.
llvm-svn: 126303
2011-02-23 03:46:46 +00:00
Peter Collingbourne 4b66c47a16 Sema: diagnose kernel calls to non-global functions
llvm-svn: 126292
2011-02-23 01:53:29 +00:00
Ted Kremenek 3427fac7c8 Enhance Sema::DiagRuntimeBehavior() to delay some diagnostics to see if the related code is reachable. This suppresses some
diagnostics that occur in unreachable code (e.g., -Warray-bound).

We only pay the cost of doing the reachability analysis when we issue one of these diagnostics.

llvm-svn: 126290
2011-02-23 01:52:04 +00:00
Ted Kremenek cc7f1f8c2e Have IdempotentOperationsChecker pull its CFGStmtMap from AnalysisContext.
llvm-svn: 126288
2011-02-23 01:51:53 +00:00
Ted Kremenek 1767a27b3e Issue AnalysisBasedWarnings as part of calling Sema::PopBlockOrFunctionScope(). No real functionality change.
llvm-svn: 126287
2011-02-23 01:51:48 +00:00
Ted Kremenek 55ae319a28 Update Sema::DiagRuntimeBehavior() to take an optional Stmt* to indicate the code the diagnostic is associated with.
This Stmt* is unused, but we will use it shortly for pruning diagnostics associated
with unreachable code.

llvm-svn: 126286
2011-02-23 01:51:43 +00:00
Ted Kremenek db3333df71 Change -Warray-bounds logic to use DiagRuntimeBehavior in preparation for using basic dataflow to suppress warnings on unreachable array bounds checks.
llvm-svn: 126285
2011-02-23 01:51:40 +00:00
Richard Smith 2abf6767e3 Fix PR9276: We were missing the checks for auto deducing to different types in the same declaration group in the template instantiation case.
llvm-svn: 126279
2011-02-23 00:37:57 +00:00
Matt Beaumont-Gay 06de2553f3 Clean up the error recovery at the bottom of Sema::LookupMemberExpr. This
mostly just shuffles various possibilities for recovery into a more
straightforward order, but also unifies a couple of diagnostics.

llvm-svn: 126266
2011-02-22 23:52:53 +00:00
Douglas Gregor 385d3fd97d When checking for abstract types, don't crash when we have a
FunctionProtoTypeLoc with NULL function parameter types, which can
occur in invalid code. Fixes PR9247 / <rdar://problem/9037911>.

llvm-svn: 126262
2011-02-22 23:21:06 +00:00
Douglas Gregor e2f943b5cb Implement the GNU C extension which permits the initialization of an
array from a constant array compound literal. Fixes PR9261.

llvm-svn: 126230
2011-02-22 18:29:51 +00:00
Douglas Gregor a78f193e7e Warn about implicit conversions between values of different, named
enumeration types. Fixes <rdar://problem/8559831>.

llvm-svn: 126183
2011-02-22 02:45:07 +00:00
Richard Smith 23eb9f707b In Objective-C, there are no trailing return types, so don't produce diagnostics suggesting they are missing.
llvm-svn: 126174
2011-02-22 01:22:29 +00:00
Richard Smith 59006e4338 Fix a few auto-related issues:
* 'auto' was being rejected on abstract-declarators with trailing return
types and on typedefs with trailing return types. 'auto' is always
allowed in these cases. This was found while testing the fix for PR 9278.

 * A very poor diagnostic was being issued for auto (f() -> int): "return
type must be 'auto', not 'auto'". This is closely related to PR 9060.

 * Trailing return type handling was happening slightly too late,
resulting in the checks for functions returning arrays and functions
returning functions being missed.

llvm-svn: 126166
2011-02-22 00:36:53 +00:00
Fariborz Jahanian d7b0cb5388 Warn when type modifiers on objc method declarations in
protocols do not match with method implementation.
// rdar://7076235

llvm-svn: 126162
2011-02-21 23:49:15 +00:00
Richard Smith 27e39b11b1 C++0x's deduced auto is illegal in typedefs.
This actually rules out too much, since it also catches typedefs for pointers to functions with trailing return types:

  typedef auto (*F)() -> int;

Fix for that (and the same issue in all abstract-declarators) to follow shortly.

llvm-svn: 126153
2011-02-21 23:18:00 +00:00
Chris Lattner 93ede02045 add one more case of mismatched input/output constraints.
When the mismatch is due to a larger input operand that is
a constant, truncate it down to the size of the output.  This
allows us to accept some cases in the linux kernel and elsewhere.
Pedantically speaking, we generate different code than GCC, though
I can't imagine how it would matter:

Clang:
	movb	$-1, %al
	frob %al

GCC:

	movl	$255, %eax
	frob %al

llvm-svn: 126148
2011-02-21 22:09:29 +00:00
Chris Lattner e3694b166a more code restructuring, no functionality change.
llvm-svn: 126146
2011-02-21 21:50:25 +00:00
Chris Lattner 70a4e9b5e2 split the iteration loop out to a helper function, no functionality change.
llvm-svn: 126145
2011-02-21 21:40:33 +00:00
Chris Lattner 169766f306 fix a comment.
llvm-svn: 126143
2011-02-21 21:15:10 +00:00
Richard Smith b2bc2e6752 Tweaks to C++0x deduced auto type support:
* Flag indicating 'we're parsing this auto typed variable's initializer' moved from VarDecl to Sema
 * Temporary template parameter list for auto deduction is now allocated on the stack.
 * Deduced 'auto' types are now uniqued.

llvm-svn: 126139
2011-02-21 20:05:19 +00:00
John McCall 15dd404c46 Don't warn about static const integral data members with in-line constant
initializers just because they don't have a proper out-of-line definition.
Such code is technically ill-formed but is too common and too unlikely to be
a problem to be seriously worth worrying about.

llvm-svn: 126137
2011-02-21 19:25:48 +00:00
Fariborz Jahanian f5bfc46c95 Remove warning on future change in ivar lookup rule
when doing the property default synthesis.
// rdar://9027673.

llvm-svn: 126128
2011-02-21 17:31:28 +00:00
John McCall 5decec97e5 Reorganize subelement initialization checking, no functionality change.
llvm-svn: 126116
2011-02-21 07:57:55 +00:00
John McCall 66884dd93c Small optimization: avoid redundant checks of whether a type is an array
when checking an initialization.

llvm-svn: 126115
2011-02-21 07:22:22 +00:00
Chandler Carruth d05b352b0e Clean up the tests for warning about unused function results given the
appropriate attribute. Add a bit more testing that finds a pretty bad
regression (since ~forever) in this warning. Fix it with a nice 2 line
change. =]

llvm-svn: 126098
2011-02-21 00:56:56 +00:00
Benjamin Kramer ae1e5c250c Remove unused function.
llvm-svn: 126084
2011-02-20 16:04:14 +00:00
Daniel Dunbar 67e556249c Remove a dead variable.
llvm-svn: 126073
2011-02-20 06:15:13 +00:00
Richard Smith 30482bc786 Implement the C++0x deduced 'auto' feature.
This fixes PR 8738, 9060 and 9132.

llvm-svn: 126069
2011-02-20 03:19:35 +00:00
Anders Carlsson ce8dd3a5d4 Add a new ObjCExceptions member variable to LangOptions. This controls whether Objective-C exceptions are enabled or not (they are by default).
llvm-svn: 126061
2011-02-19 23:53:54 +00:00
Douglas Gregor 5b05454f24 Don't produce "comparison is always (true|false)" warnings when the
comparison itself is a constant expression. Fixes PR7536.

llvm-svn: 126057
2011-02-19 22:34:59 +00:00
Chris Lattner b0ed51da10 implement a tiny amount of codegen support for gnu array range
designators: allowing codegen when the element initializer is a
constant or something else without a side effect.  This unblocks
enough to let process.c in the linux kernel build, PR9257.

llvm-svn: 126056
2011-02-19 22:28:58 +00:00
Anders Carlsson b94ad3ec22 There's no need to return early if we encounter a try/throw and exceptions are disabled.
llvm-svn: 126053
2011-02-19 21:53:09 +00:00
Douglas Gregor b491ed36b4 Handle the resolution of a reference to a function template (which
includes explicitly-specified template arguments) to a function
template specialization in cases where no deduction is performed or
deduction fails. Patch by Faisal Vali, fixes PR7505!

llvm-svn: 126048
2011-02-19 21:32:49 +00:00
Anders Carlsson 68b36aff46 Disallow try/catch/throw when exceptions are disabled.
llvm-svn: 126039
2011-02-19 19:26:44 +00:00
Douglas Gregor bf2b26d805 The member classes of a current instantiation aren't necessarily a
current instantiation, even though we have a RecordDecl describing
them. Fixes PR9255.

Amusingly, I've had this patch sitting around for a month or two
because it was "obviously" wrong, but hadn't gotten around to writing
a test case to submit the fix :)

llvm-svn: 126038
2011-02-19 19:24:40 +00:00
Douglas Gregor 0cf82f6ad0 Teach the virtual-functions-without-virtual-destructor warning to only
warn about polymorphic classes (which have virtual functions) rather
than dynamic classes (which are polymorphic or have virtual bases).

llvm-svn: 126036
2011-02-19 19:14:36 +00:00
Douglas Gregor f05c0958e2 Remove the Fix-It for "main must return 'int'", which is not always
correct and is not worth fixing. Fixes PR8396.

llvm-svn: 126035
2011-02-19 19:04:23 +00:00
Argyrios Kyrtzidis 12f146a3ef Use PointerUnion::getAddrOf instead of messing with PointerUnion & reinterpret_cast.
llvm-svn: 126021
2011-02-19 04:02:34 +00:00