Commit Graph

690 Commits

Author SHA1 Message Date
Alexey Bataev 61deb4dadc Revert accidential "[MSVC] Late parsing of in-class defined member functions in template"
This reverts commit 0253605771b8bd9d414aba74fe2742c730d6fd1a.

llvm-svn: 272776
2016-06-15 11:24:54 +00:00
Alexey Bataev 86e786bd17 [MSVC] Late parsing of in-class defined member functions in template
classes.

MSVC actively uses unqualified lookup in dependent bases, lookup at the
instantiation point (non-dependent names may be resolved on things
declared later) etc. and all this stuff is the main cause of
incompatibility between clang and MSVC.

Clang tries to emulate MSVC behavior but it may fail in many cases.
clang could store lexed tokens for member functions definitions within
ClassTemplateDecl for later parsing during template instantiation.

It will allow resolving many possible issues with lookup in dependent
base classes and removing many already existing MSVC-specific
hacks/workarounds from the clang code.

llvm-svn: 272774
2016-06-15 11:19:39 +00:00
Tim Shen 17b3deeff3 Revert "[Temporary] Add an ExprWithCleanups for each C++ MaterializeTemporaryExpr."
This reverts r272296, since there are clang-tidy failures that appear to
be caused by this change.

llvm-svn: 272310
2016-06-09 21:13:39 +00:00
Tim Shen f120a7b6a3 [Temporary] Add an ExprWithCleanups for each C++ MaterializeTemporaryExpr.
These ExprWithCleanups are added for holding a RunCleanupsScope not
for destructor calls; rather, they are for lifetime marks. This requires
ExprWithCleanups to keep a bit to indicate whether it have cleanups with
side effects (e.g. dtor calls).

Differential Revision: http://reviews.llvm.org/D20498

llvm-svn: 272296
2016-06-09 19:54:46 +00:00
Alexey Bataev 7ace49dff1 [OPENMP] Pass scalar firstprivate vars by value.
For better performance and to unify code with offloading part we pass
scalar firstprivate values by value, instead of by reference. It will
remove some extra copying operations.

llvm-svn: 269751
2016-05-17 08:55:33 +00:00
Erik Pilkington ce26eac511 Test commit
llvm-svn: 267604
2016-04-26 20:55:48 +00:00
Richard Smith 01694c340d P0184R0: Allow types of 'begin' and 'end' expressions in range-based for loops to differ.
llvm-svn: 263895
2016-03-20 10:33:40 +00:00
Steven Wu 92910f69a0 Fix false positives for for-loop-analysis warning
Summary:
For PseudoObjectExpr, the DeclMatcher need to search only all the semantics
but also need to search pass OpaqueValueExpr for all potential uses for the
Decl.

Reviewers: thakis, rtrieu, rjmccall, doug.gregor

Subscribers: xazax.hun, rjmccall, doug.gregor, cfe-commits

Differential Revision: http://reviews.llvm.org/D17627

llvm-svn: 263087
2016-03-10 02:02:48 +00:00
Aaron Ballman e7964789da Implement support for [[nodiscard]] in C++1z that is based off existing support for warn_unused_result, and treat it as an extension pre-C++1z. This also means extending the existing warn_unused_result attribute so that it can be placed on an enum as well as a class.
llvm-svn: 262872
2016-03-07 22:44:55 +00:00
Richard Trieu faca2d83b1 Add -Wcomma warning to Clang.
-Wcomma will detect and warn on most uses of the builtin comma operator.  It
currently whitelists the first and third statements of the for-loop.  For other
cases, the warning can be silenced by casting the first operand of the comma
operator to void.

Differential Revision: http://reviews.llvm.org/D3976

llvm-svn: 261278
2016-02-18 23:58:40 +00:00
Richard Trieu cc3949d99a Remove use of builtin comma operator.
Cleanup for upcoming Clang warning -Wcomma.  No functionality change intended.

llvm-svn: 261271
2016-02-18 22:34:54 +00:00
Benjamin Kramer 536ffdf51d Don't copy a DenseMap just to do lookup in it.
Also remove the now unused isPodLike specialization. DenseMap only uses
it for copies.

llvm-svn: 260822
2016-02-13 15:49:17 +00:00
Manman Ren b4e8a1b308 Fix a crash when there is a typo in the return statement.
If the typo happens after a successful deduction for an earlier
return statement, we should check if the deduced type is null
before using it.

The typo correction happens after we try to deduce the return
type and we ignore the deduction from the typo and continue
to typo correction.

rdar://24342247

llvm-svn: 259820
2016-02-04 20:05:40 +00:00
Argyrios Kyrtzidis b4030df780 [SemaCXX] Fix crash-on-invalid while trying to deduce return type of a lambda.
rdar://22032373

llvm-svn: 259287
2016-01-30 01:51:20 +00:00
Richard Smith db0ac5572f Split RequireCompleteType into a function that actually requires that the type
is complete (with an error produced if not) and a function that merely queries
whether the type is complete. Either way we'll trigger instantiation if
necessary, but only the former will diagnose and recover from missing module
imports.

The intent of this change is to prevent a class of bugs where code would call
RequireCompleteType(..., 0) and then ignore the result. With modules, we must
check the return value and use it to determine whether the definition of the
type is visible.

This also fixes a debug info quality issue: calls to isCompleteType do not
trigger the emission of debug information for a type in limited-debug-info
mode. This allows us to avoid emitting debug information for type definitions
in more cases where we believe it is safe to do so.

llvm-svn: 256049
2015-12-18 22:40:25 +00:00
Samuel Antao 4af1b7b693 [OpenMP] Update target directive codegen to use 4.5 implicit data mappings.
Summary:
This patch implements the 4.5 specification for the implicit data maps. OpenMP 4.5 specification changes the default way data is captured into a target region. All the non-aggregate kinds are passed by value by default. This required activating the capturing by value during SEMA for the target region. All the non-aggregate values that can be encoded in the size of a pointer are properly casted and forwarded to the runtime library. On top of fixing the previous weird behavior for mapping pointers in nested data regions (an explicit map was always required), this also improves performance as the number of allocations/transactions to the device per non-aggregate map are reduced from two to only one - instead of passing a reference and the value, only the value passed.

Explicit maps will be added later on once firstprivate, private, and map clauses' SEMA and parsing are available.

Reviewers: hfinkel, rjmccall, ABataev

Subscribers: cfe-commits, carlo.bertolli

Differential Revision: http://reviews.llvm.org/D14940

llvm-svn: 254521
2015-12-02 17:44:43 +00:00
Craig Topper 8f7f3ea658 [Sema] Minor formatting fixes. NFC
llvm-svn: 253314
2015-11-17 05:40:05 +00:00
Nico Weber 0e631639be Tweak how -Wunused-value interacts with macros
1. Make the warning more strict in C mode. r172696 added code to suppress
   warnings from macro expansions in system headers, which checks
   `SourceMgr.isMacroBodyExpansion(E->IgnoreParens()->getExprLoc())`. Consider
   this snippet:

   #define FOO(x) (x)
   void f(int a) {
     FOO(a);
   }

   In C, the line `FOO(a)` is an `ImplicitCastExpr(ParenExpr(DeclRefExpr))`,
   while it's just a `ParenExpr(DeclRefExpr)` in C++. So in C++,
   `E->IgnoreParens()` returns the `DeclRefExpr` and the check tests the
   SourceLoc of `a`. In C, the `ImplicitCastExpr` has the effect of checking the
   SourceLoc of `FOO`, which is a macro body expansion, which causes the
   diagnostic to be skipped. It looks unintentional that clang does different
   things for C and C++ here, so use `IgnoreParenImpCasts` instead of
   `IgnoreParens` here. This has the effect of the warning firing more often
   than previously in C code – it now fires as often as it fires in C++ code.

2. Suppress the warning if it would warn on `UNREFERENCED_PARAMETER`.
   `UNREFERENCED_PARAMETER` is a commonly used macro on Windows and it happens
   to uselessly trigger -Wunused-value. As discussed in the thread
   "rfc: winnt.h's UNREFERENCED_PARAMETER() vs clang's -Wunused-value" on
   cfe-dev, fix this by special-casing this specific macro. (This costs a string
   comparison and some fast-path lexing per warning, but the warning is emitted
   rarely. It fires once in Windows.h itself, so this code runs at least once
   per TU including Windows.h, but it doesn't run hundreds of times.)

http://reviews.llvm.org/D13969

llvm-svn: 251441
2015-10-27 19:47:40 +00:00
Richard Smith 9f690bd80b [coroutines] Creation of promise object, lookup of operator co_await, building
of await_* calls, and AST representation for same.

llvm-svn: 251387
2015-10-27 06:02:45 +00:00
Richard Smith cfd53b4e99 [coroutines] Initial stub Sema functionality for handling coroutine await / yield / return.
llvm-svn: 250993
2015-10-22 06:13:50 +00:00
Olivier Goffart 122993bfd6 Keep the IfStmt node even if the condition is invalid
This is important to keep the information in IDE or other tools
even if the code contains a few errors

llvm-svn: 249982
2015-10-11 17:27:29 +00:00
Douglas Gregor a602a153de Perform Objective-C lifetime adjustments before comparing deduced lambda result types.
Objective-C ARC lifetime qualifiers are dropped when canonicalizing
function types. Perform the same adjustment before comparing the
deduced result types of lambdas. Fixes rdar://problem/22344904.

llvm-svn: 249065
2015-10-01 20:20:47 +00:00
Douglas Gregor 6032d5b332 Simplify Sema::DeduceFunctionTypeFromReturnExpr and eliminae a redundant check.
NFC

llvm-svn: 249060
2015-10-01 19:52:44 +00:00
Richard Smith 332653ccf6 Fix a potential APInt memory leak when using __attribute__((flag_enum)), and
simplify the implementation a bit.

llvm-svn: 246830
2015-09-04 01:03:03 +00:00
Sanjay Patel 69e7f6e436 fix typo; NFC
llvm-svn: 246303
2015-08-28 14:42:54 +00:00
Benjamin Kramer 6e4f6e1f06 [AST] Turn the callbacks of lookupInBases and forallBases into a function_ref
This lets us pass functors (and lambdas) without void * tricks. On the
downside we can't pass CXXRecordDecl's Find* members (which are now type
safe) to lookupInBases directly, but a lambda trampoline is a small
price to pay. No functionality change intended.

llvm-svn: 243217
2015-07-25 15:07:25 +00:00
Reid Kleckner 8819a4065f Re-enable 32-bit SEH after the alignment fix
llvm-svn: 241878
2015-07-10 00:16:25 +00:00
Reid Kleckner e7844ea7f8 Disable 32-bit SEH, again
Move the diagnostic back to codegen so that we can compile ATL on the
self-host bot. We don't actually end up emitting code for the __try, so
the diagnostic won't be hit.

llvm-svn: 241761
2015-07-08 23:57:03 +00:00
Reid Kleckner 9fe7f2396b Revert "Revert 241171, 241187, 241199 (32-bit SEH)."
This reverts commit r241244, but restricts SEH support to Win64.

This way, Chromium builds will still fall back on TUs with SEH, and
Clang developers can work on this incrementally upstream while patching
this small predicate locally. It'll also make it easier to review small
fixes.

llvm-svn: 241533
2015-07-07 00:36:30 +00:00
Nico Weber e4f974c6fb Revert 241171, 241187, 241199 (32-bit SEH).
It still doesn't produce quite the right code, test binaries built with this
enabled fail some tests.

llvm-svn: 241244
2015-07-02 06:10:53 +00:00
Reid Kleckner d0d9a1f63f [SEH] Add 32-bit lowering for SEH __try
This re-lands r236052 and adds support for __exception_code().

In 32-bit SEH, the exception code is not available in eax. It is only
available in the filter function, and now we arrange to load it and
store it into an escaped variable in the parent frame.

As a consequence, we have to disable the "catch i8* null" optimization
on 32-bit and always generate a filter function. We can re-enable the
optimization if we detect an __except block that doesn't use the
exception code, but this probably isn't worth optimizing.

Reviewers: majnemer

Differential Revision: http://reviews.llvm.org/D10852

llvm-svn: 241171
2015-07-01 17:10:10 +00:00
Meador Inge f0af05c4a5 [Parse] Allow 'constexpr' in condition declarations
This patch implements the functionality specified by DR948.
The changes are two fold.  First, the parser was modified
to allow 'constexpr's to appear in condition declarations
(which was a hard error before).  Second, Sema was modified
to cleanup maybe odr-used declarations by way of a call to
'ActOnFinishFullExpr'.  As 'constexpr's were not allowed in
condition declarations before the cleanup wasn't necessary
(such declarations were always odr-used).

This fixes PR22491.

Differential Revision: http://reviews.llvm.org/D8978

llvm-svn: 240707
2015-06-25 22:06:40 +00:00
Alexander Kornienko ab9db51042 Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").
llvm-svn: 240353
2015-06-22 23:07:51 +00:00
Alexander Kornienko 3d9d929e42 Fixed/added namespace ending comments using clang-tidy. NFC
The patch is generated using this command:

  $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \
      -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \
      work/llvm/tools/clang

To reduce churn, not touching namespaces spanning less than 10 lines.

llvm-svn: 240270
2015-06-22 09:47:44 +00:00
Eric Christopher 2c4555ad1b Fix "the the" in comments/documentation/etc.
llvm-svn: 240110
2015-06-19 01:52:53 +00:00
Reid Kleckner 0b9bbbfc13 Revert "Re-land r236052, "[SEH] Add 32-bit lowering code for __try""
This reverts commit r239415. This was committed accidentally, LLVM isn't
ready for this.

llvm-svn: 239417
2015-06-09 17:49:42 +00:00
Reid Kleckner 65870442b3 Re-land r236052, "[SEH] Add 32-bit lowering code for __try"
This reverts r236167.

LLVM should be ready for this now.

llvm-svn: 239415
2015-06-09 17:47:50 +00:00
Kaelyn Takata fb8cf4087d When performing delayed typo correction in a for-range loop's variable
declaration, ensure the loop variable is properly marked as invalid when
it is an "auto" variable.

llvm-svn: 236682
2015-05-07 00:11:02 +00:00
Benjamin Kramer 439ee9d7bc Make helper functions static. NFC.
llvm-svn: 236315
2015-05-01 13:59:53 +00:00
Reid Kleckner cb7a0a0562 Revert most of r236271, leaving only the datalayout change in lib/Basic/Targets.cpp
llvm-svn: 236274
2015-04-30 22:29:25 +00:00
Reid Kleckner af67602e14 Use 4 byte preferred aggregate alignment in datalayout on x86 Win32
llvm-svn: 236271
2015-04-30 22:13:05 +00:00
Reid Kleckner be9843ce54 Revert r236128, LLVM isn't falling back in the right way
llvm-svn: 236167
2015-04-29 21:55:21 +00:00
Reid Kleckner 0bb12a8981 Re-land r236052, the linker errors were fixed by LLVM r236123
Basic __finally blocks don't cause linker errors anymore (although they
are miscompiled).

llvm-svn: 236128
2015-04-29 17:17:17 +00:00
Nico Weber ea721b64df Revert r236052, it caused linker errors when building 32-bit applications.
llvm-svn: 236082
2015-04-29 03:08:32 +00:00
Reid Kleckner ddd40964f0 [SEH] Add 32-bit lowering code for __try
This is just the clang-side of 32-bit SEH. LLVM still needs work, and it
will determinstically fail to compile until it's feature complete.

On x86, all outlined handlers have no parameters, but they do implicitly
take the EBP value passed in and use it to address locals of the parent
frame. We model this with llvm.frameaddress(1).

This works (mostly), but __finally block inlining can break it. For now,
we apply the 'noinline' attribute. If we really want to inline __finally
blocks on 32-bit x86, we should teach the inliner how to untangle
frameescape and framerecover.

Promote the error diagnostic from codegen to sema. It now rejects SEH on
non-Windows platforms. LLVM doesn't implement SEH on non-x86 Windows
platforms, but there's nothing preventing it.

llvm-svn: 236052
2015-04-28 22:19:32 +00:00
Richard Trieu 3e1d483e0e Add new warning -Wrange-loop-analysis to warn on copies during loops.
-Wrange-loop-analysis is a subgroup of -Wloop-analysis and will warn when
a range-based for-loop makes copies of the elements in the range.  If possible,
suggest the proper type to prevent copies, or the non-reference to help
distinguish copy versus non-copy forms.  Existing warnings in -Wloop-analysis
are moved to -Wfor-loop-analysis, also a subgroup of -Wloop-analysis.

Differential Revision: http://reviews.llvm.org/D4169

llvm-svn: 234804
2015-04-13 22:08:55 +00:00
Kaelyn Takata 0a2e84c41a Properly implement warn_unused_result checking for classes/structs.
The previous implementation would copy the attribute from the class to
functions that have the class as their return type when the functions
are first declared. This proved to have two flaws:
  1) if the class is forward-declared without the attribute and a
     function or method with the class as a its return type is declared,
     and afterward the class is defined with warn_unused_result, the
     function or method would never inherit the attribute, and
  2) the check simply failed for functions and methods that are part of
     a template instantiation, regardless of whether the class with
     warn_unused_result is part of a specific instantiation or part of
     the template itself (presumably because those function/method
     declaration does not hit the same code path as a non-template one
     and so never inherits the attribute).

The new approach is to instead modify the two places where a function or
method call is checked for the warn_unused_result attribute on the decl
by extending the checks to also look for the attribute on the decl's
return type.

Additionally, the check for return types that have the warn_unused_result
now excludes pointers and references to such types, as such return types do
not necessarily imply a transfer of ownership for the underlying object
being referred to by the return value. This does not change the behavior
of functions that are directly given the warn_unused_result attribute.

llvm-svn: 234526
2015-04-09 19:43:04 +00:00
Aaron Ballman aa301de7e4 Appease build bots that cannot find a viable conversion through CanQualType.
llvm-svn: 234376
2015-04-08 00:13:33 +00:00
Aaron Ballman 8aee642909 Generate a diagnostic when a catch handler cannot execute due to class hierarchy inversion with regards to other catch handlers for the same block.
llvm-svn: 234375
2015-04-08 00:05:29 +00:00
Benjamin Kramer 3a8650af77 [Sema] Factor diags with %plural. No functionality change intended.
llvm-svn: 233387
2015-03-27 17:23:14 +00:00
Yaron Keren 49c63695c0 Fix gcc ambiguity error (Visual C++ was OK with these).
llvm-svn: 232623
2015-03-18 10:26:22 +00:00
Yaron Keren 92e1b62d45 Remove many superfluous SmallString::str() calls.
Now that SmallString is a first-class citizen, most SmallString::str()
calls are not required. This patch removes a whole bunch of them, yet
there are lots more.

There are two use cases where str() is really needed:
1) To use one of StringRef member functions which is not available in
SmallString.
2) To convert to std::string, as StringRef implicitly converts while 
SmallString do not. We may wish to change this, but it may introduce
ambiguity.

llvm-svn: 232622
2015-03-18 10:17:07 +00:00
Nico Weber ce90329824 Fix a theoretical bug when ParseCompoundStatement() returns StmtError.
ParseCompoundStatement() currently never returns StmtError, but if it did,
Sema would keep the __finally scope on its stack indefinitely.  Explicitly
add an error callback that clears it.

llvm-svn: 231625
2015-03-09 03:17:15 +00:00
Nico Weber d64657f298 Warn when jumping out of a __finally block via continue, break, return, __leave.
Since continue, break, return are much more common than __finally, this tries
to keep the work for continue, break, return O(1).  Sema keeps a stack of active
__finally scopes (to do this, ActOnSEHFinally() is split into
ActOnStartSEHFinally() and ActOnFinishSEHFinally()), and the various jump
statements then check if the current __finally scope (if present) is deeper
than then destination scope of the jump.

The same warning for goto statements is still missing.

This is the moral equivalent of MSVC's C4532.

llvm-svn: 231623
2015-03-09 02:47:59 +00:00
Nico Weber 9af63b22a5 Fix typo in comment.
llvm-svn: 231622
2015-03-09 02:34:29 +00:00
Fariborz Jahanian b0553e21cc [Objctive-C sema]. Do not do the unused-getter-return-value
warning when property getter is used in direct method call
and return value of property is unused. rdar://19773512

llvm-svn: 229458
2015-02-16 23:49:44 +00:00
Aaron Ballman 8a417bd97b Partial revert of r229336; this wasn't intended to go in.
llvm-svn: 229338
2015-02-15 22:18:04 +00:00
Aaron Ballman 673476684e Removing LLVM_EXPLICIT, as MSVC 2012 was the last reason for requiring the macro. NFC; Clang edition.
llvm-svn: 229336
2015-02-15 22:00:28 +00:00
Reid Kleckner deeddeced3 Re-land r228258 and make clang-cl's /EHs- disable -fexceptions again
After r228258, Clang started emitting C++ EH IR that LLVM wasn't ready
to deal with, even when exceptions were disabled with /EHs-. This time,
make /EHs- turn off -fexceptions while still emitting exceptional
constructs in functions using __try.  Since Sema rejects C++ exception
handling constructs before CodeGen, landingpads should only appear in
such functions as the result of a __try.

llvm-svn: 228329
2015-02-05 18:56:03 +00:00
Nico Weber 94b2368c24 Revert r228258.
It caused a chromium base unittest that tests throwing and catching SEH
exceptions to fail (http://crbug.com/455488) and I suspect it might also
be the cause of the chromium clang win 64-bit shared release builder timing
out during compiles.  So revert to see if that's true.

llvm-svn: 228262
2015-02-05 02:08:50 +00:00
Reid Kleckner 11ca834bef SEH: Track users of __try so we can pick a per-func EH personality
There are four major kinds of declarations that cause code generation:
- FunctionDecl (includes CXXMethodDecl etc)
- ObjCMethodDecl
- BlockDecl
- CapturedDecl

This patch tracks __try usage on FunctionDecls and diagnoses __try usage
in other decls. If someone wants to use __try from ObjC, they can use it
from a free function, since the ObjC code will need an ObjC-style EH
personality.

Eventually we will want to look through CapturedDecls and track SEH
usage on the parent FunctionDecl, if present.

llvm-svn: 228058
2015-02-03 22:52:35 +00:00
Reid Kleckner e71759103e SEH: Diagnose use of C++ EH and SEH in the same function
This check does not apply when Borland extensions are enabled, as they
have a checked in test case indicating that mixed usage of SEH and C++
is supported.

llvm-svn: 227876
2015-02-02 22:15:31 +00:00
Alexey Bataev 19acc3d351 Rename RefersToCapturedVariable to RefersToEnclosingVariableOrCapture, NFC
llvm-svn: 225624
2015-01-12 10:17:46 +00:00
Richard Smith 5a0e50cd87 DR1048: drop top-level cv-qualifiers when deducing the return type of a
lambda-expression in C++11, to match the C++14 rules.

llvm-svn: 224620
2014-12-19 22:10:51 +00:00
Alexey Bataev 07649fb7c5 Renamed RefersToEnclosingLocal bitfield to RefersToCapturedVariable.
Bitfield RefersToEnclosingLocal of Stmt::DeclRefExprBitfields renamed to RefersToCapturedVariable to reflect latest changes introduced in commit 224323. Also renamed method Expr::refersToEnclosingLocal() to Expr::refersToCapturedVariable() and comments for constant arguments.
No functional changes.

llvm-svn: 224329
2014-12-16 08:01:48 +00:00
David Majnemer 418ad3ff10 Sema: Don't leave switch stack inconsistent when recovering
We would exit Sema::ActOnFinishSwitchStmt early if we didn't have a
body.  This would leave an extra SwitchStmt on the SwitchStack.

This fixes PR21841.

llvm-svn: 224237
2014-12-15 07:46:12 +00:00
David Majnemer 2887ad35c5 Sema: Constexpr functions must have return statements which have an expr
clang lets programmers be pretty cavalier when it comes to void return
statements in functions which have non-void return types.  However, we
cannot be so forgiving in constexpr functions: evaluation will go off
the rails very quickly.

Instead, keep the return statement in the AST but mark the function as
invalid.  Doing so gives us nice diagnostics while making constexpr
evaluation halt.

This fixes PR21859.

llvm-svn: 224189
2014-12-13 08:12:56 +00:00
Alexis Hunt 724f14e75c Create a new 'flag_enum' attribute.
This attribute serves as a hint to improve warnings about the ranges of
enumerators used as flag types. It currently has no working C++ implementation
due to different semantics for enums in C++. For more explanation, see the docs
and testcases.

Reviewed by Aaron Ballman.

llvm-svn: 222906
2014-11-28 00:53:20 +00:00
Kaelyn Takata 1586782767 Enable ActOnIdExpression to use delayed typo correction for non-C++ code
when calling DiagnoseEmptyLookup.

llvm-svn: 222551
2014-11-21 18:48:04 +00:00
Kaelyn Takata b16e632c64 Wire up delayed typo correction to DiagnoseEmptyLookup and set up
Sema::ActOnIdExpression to use the new functionality.

Among other things, this allows recovery in several cases where it
wasn't possible before (e.g. correcting a mistyped static_cast<>).

llvm-svn: 222464
2014-11-20 22:06:40 +00:00
Richard Smith 5b555da775 PR21531: fix crash on invalid with unexpanded pack in case value.
llvm-svn: 222400
2014-11-20 01:24:12 +00:00
Alexey Bataev 330de03083 Improved capturing variable-length array types in CapturedStmt.
An updated implemnentation of VLA types capturing based on previously committed solution for Lambdas.
This version captures the whole VLA type instead of particular variables which are part of VLA size expression and allows to use previusly calculated size of VLA type in captured regions. Required for OpenMP.
Differential Revision: http://reviews.llvm.org/D5099

llvm-svn: 220850
2014-10-29 12:21:55 +00:00
Saleem Abdulrasool e8aab7480c Sema: address post-commit review comment
Hoist the IgnoreParens so that we ignore it around attributes as well in order
to future-proof the code.  Addresses Richard's comments for SVN r219974.

llvm-svn: 220053
2014-10-17 17:20:33 +00:00
Saleem Abdulrasool 374b5aa170 Sema: handle additional case of qualified types
A second instance of attributed types escaped the previous change, identified
thanks to Richard Smith!  When deducing the void case, we would also assume that
the type would not be attributed.  Furthermore, properly handle multiple
attributes being applied to a single TypeLoc.

Properly handle this case and future-proof a bit by ignoring parenthesis
further.  The test cases do use the additional parenthesis to ensure that this
case remains properly handled.

Addresses post-commit review comments from Richard Smith to SVN r219851.

llvm-svn: 219974
2014-10-16 22:42:53 +00:00
Aaron Ballman 78ecb8737d No longer emit diagnostics about unused results (comparisons, etc) from unevaluated contexts. Fixes PR18571.
llvm-svn: 219954
2014-10-16 20:13:28 +00:00
Saleem Abdulrasool bbdd6c13de Sema: handle AttributedTypeLocs in C++14 auto deduction
When performing a type deduction from the return type, the FunctionDecl may be
attributed with a calling convention.  In such a case, the retrieved type
location may be an AttributedTypeLoc.  Performing a castAs<FunctionProtoTypeLoc>
on such a type loc would result in an assertion as they are not derived types.

Ensure that we correctly handle the attributed type location by looking through
it to the modified type loc.

Fixes an assertion triggered in C++14 mode.

llvm-svn: 219851
2014-10-15 21:37:55 +00:00
Ehsan Akhgari 31097581aa ms-inline-asm: Scope inline asm labels to functions
Summary:
This fixes PR20023.  In order to implement this scoping rule, we piggy
back on the existing LabelDecl machinery, by creating LabelDecl's that
will carry the "internal" name of the inline assembly label, which we
will rewrite the asm label to.

Reviewers: rnk

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D4589

llvm-svn: 218230
2014-09-22 02:21:54 +00:00
Nico Weber 728894340f Add -Wunused-local-typedef, a warning that finds unused local typedefs.
The warning warns on TypedefNameDecls -- typedefs and C++11 using aliases --
that are !isReferenced(). Since the isReferenced() bit on TypedefNameDecls
wasn't used for anything before this warning it wasn't always set correctly,
so this patch also adds a few missing MarkAnyDeclReferenced() calls in
various places for TypedefNameDecls.

This is made a bit complicated due to local typedefs possibly being used only
after their local scope has closed. Consider:

    template <class T>
    void template_fun(T t) {
      typename T::Foo s3foo;  // YYY
      (void)s3foo;
    }
    void template_fun_user() {
      struct Local {
        typedef int Foo;  // XXX
      } p;
      template_fun(p);
    }

Here the typedef in XXX is only used at end-of-translation unit, when YYY in
template_fun() gets instantiated. To handle this, typedefs that are unused when
their scope exits are added to a set of potentially unused typedefs, and that
set gets checked at end-of-TU. Typedefs that are still unused at that point then
get warned on. There's also serialization code for this set, so that the
warning works with precompiled headers and modules. For modules, the warning
is emitted when the module is built, for precompiled headers each time the
header gets used.

Finally, consider a function using C++14 auto return types to return a local
type defined in a header:

    auto f() {
      struct S { typedef int a; };
      return S();
    }

Here, the typedef escapes its local scope and could be used by only some
translation units including the header. To not warn on this, add a
RecursiveASTVisitor that marks all delcs on local types returned from auto
functions as referenced. (Except if it's a function with internal linkage, or
the decls are private and the local type has no friends -- in these cases, it
_is_ safe to warn.)

Several of the included testcases (most of the interesting ones) were provided
by Richard Smith.

(gcc's spelling -Wunused-local-typedefs is supported as an alias for this
warning.)

llvm-svn: 217298
2014-09-06 01:25:55 +00:00
Aaron Ballman dd69ef38db C++1y is now C++14!
Changes diagnostic options, language standard options, diagnostic identifiers, diagnostic wording to use c++14 instead of c++1y. It also modifies related test cases to use the updated diagnostic wording.

llvm-svn: 215982
2014-08-19 15:55:55 +00:00
Craig Topper 4dd9b43c8d Repace SmallPtrSet with SmallPtrSetImpl in function arguments to avoid needing to mention the size.
llvm-svn: 215869
2014-08-17 23:49:53 +00:00
Jordan Rose 5790d5295e Allow @synchronized to contextually convert a C++ object to an ObjC object pointer.
Patch by Grant Paul!

llvm-svn: 215453
2014-08-12 16:20:36 +00:00
Richard Smith 077d083b4d PR11778: Fix the rejects-valid half of this bug. We still produce the same
poorly-worded warning for a case value that is not a possible value of the
switched-on expression.

llvm-svn: 214678
2014-08-04 00:40:48 +00:00
Warren Hunt f6be4cb4cb Revert r213437
We no longer plan to use __except_hander3 and rather use custom 
personality functions per __try block.

llvm-svn: 213971
2014-07-25 20:52:51 +00:00
Warren Hunt b530bc0242 [MS-ABI] Assign SEH handler indices to __try blocks
Assigns indices to try blocks. These indices will used in constructing 
tables that the mscrt function __except_handler3 reads during SEH.
Testing will occur once we actually emit the tables, in a subsequent 
patch.

llvm-svn: 213437
2014-07-19 00:45:07 +00:00
Fariborz Jahanian ac6b4efaab Objective-C. Patch to warn if the result of calling a property getter
is unused (this is match behavior when property-dot syntax is used to
use same getter). rdar://17514245
Patch by Anders Carlsson with minor refactoring by me.

llvm-svn: 213423
2014-07-18 22:59:10 +00:00
Nico Weber 9b982078e9 Add an AST node for __leave statements, hook it up.
Codegen is still missing (and I won't work on that), but __leave is now
as implemented as __try and friends.

llvm-svn: 212425
2014-07-07 00:12:30 +00:00
Nico Weber eb61d4d7c2 Sema: Check that __leave is contained in a __try block.
Give scope a SEHTryScope bit, set that in ParseSEHTry(), and let Sema
walk the scope chain to find the SEHTry parent on __leave statements.
(They are rare enough that it seems better to do the walk instead of
giving Scope a SEHTryParent pointer -- this is similar to AtCatchScope.)

llvm-svn: 212422
2014-07-06 22:53:19 +00:00
Nico Weber c7d0596429 Add parser support for __leave (sema and onward still missing).
llvm-svn: 212421
2014-07-06 22:32:59 +00:00
Craig Topper e3d2ecbe86 Import MutableArrayRef into clang namespace.
llvm-svn: 211988
2014-06-28 23:22:33 +00:00
Alp Toker d4a3f0e894 Hide the concept of diagnostic levels from lex, parse and sema
The compilation pipeline doesn't actually need to know about the high-level
concept of diagnostic mappings, and hiding the final computed level presents
several simplifications and other potential benefits.

The only exceptions are opportunistic checks to see whether expensive code
paths can be avoided for diagnostics that are guaranteed to be ignored at a
certain SourceLocation.

This commit formalizes that invariant by introducing and using
DiagnosticsEngine::isIgnored() in place of individual level checks throughout
lex, parse and sema.

llvm-svn: 211005
2014-06-15 23:30:39 +00:00
Alexander Musman a8e9d2eccc [OPENMP] Loop canonical form analysis (Sema)
This patch implements semantic analysis to make sure that the loop is in OpenMP canonical form.
This is the form required for 'omp simd', 'omp for' and other loop pragmas.

Differential revision: http://reviews.llvm.org/D3778

llvm-svn: 210095
2014-06-03 10:16:47 +00:00
Nikola Smiljanic 03ff2596cb Refactoring. Remove Owned method from Sema.
llvm-svn: 209812
2014-05-29 14:05:12 +00:00
Nikola Smiljanic 01a7598561 Refactoring. Remove release and take methods from ActionResult. Rename takeAs to getAs.
llvm-svn: 209800
2014-05-29 10:55:11 +00:00
Craig Topper c3ec149bb2 [C++11] Use 'nullptr'. Sema edition.
llvm-svn: 209613
2014-05-26 06:22:03 +00:00
Serge Pavlov 921c2ba18b Improved recovery of switch statement
Make better diagnostic produced by erroneous switch statement.
It fixes PR19022.

Differential Revision: http://reviews.llvm.org/D3137

llvm-svn: 209302
2014-05-21 14:48:43 +00:00
Alexey Bataev 301a2d9249 [OPENMP] Fix warning in Release builds.
llvm-svn: 208768
2014-05-14 10:40:54 +00:00
Alexey Bataev 9959db5fa9 [OPENMP] Initial codegen for '#pragma omp parallel'
llvm-svn: 208077
2014-05-06 10:08:46 +00:00
Nick Lewycky d78f92fbb2 Rewrite NRVO determination. Track NRVO candidates on the parser Scope and apply the NRVO candidate flag to all possible NRVO candidates here, and remove the flags in computeNRVO or upon template instantiation. A variable now has NRVO applied if and only if every return statement in that scope returns that variable. This is nearly optimal.
Performs NRVO roughly 7% more often in a bootstrap build of clang. Patch co-authored by Richard Smith.

llvm-svn: 207890
2014-05-03 00:41:18 +00:00
Richard Smith 100b24abc5 Implement [over.match.oper]p3 properly, by filtering the non-candidates out
when building the candidate set, rather than trying to contort name lookup into
handling this.

llvm-svn: 206436
2014-04-17 01:52:14 +00:00
Aaron Ballman 535bbcccb1 [C++11] Replacing DeclStmt iterators decl_begin() and decl_end() with iterator_range decls(). Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 203947
2014-03-14 17:01:24 +00:00