summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
...
* Tweak how -Wunused-value interacts with macrosNico Weber2015-10-271-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Properly clear current coroutine promise on FunctionScopeInfo reuse. ShouldRichard Smith2015-10-271-0/+1
| | | | | | hopefully make bots happy again. llvm-svn: 251397
* [coroutines] Creation of promise object, lookup of operator co_await, buildingRichard Smith2015-10-277-65/+352
| | | | | | of await_* calls, and AST representation for same. llvm-svn: 251387
* Be more conservative about diagnosing "incorrect" uses of __weak:John McCall2015-10-273-60/+138
| | | | | | | | | | | | allow them to be written in certain kinds of user declaration and diagnose on the use-site instead. Also, improve and fix some diagnostics relating to __weak and properties. rdar://23228631 llvm-svn: 251384
* MismatchingNewDeleteDetector uses incorrect field, and finds no initializerIsmail Pazarbasi2015-10-261-2/+4
| | | | | | | | | | | | | | | Summary: In `MismatchingNewDeleteDetector::analyzeInClassInitializer`, if `Field`'s initializer expression is null, lookup the field in implicit instantiation, and use found field's the initializer. Reviewers: rsmith, rtrieu Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D9898 llvm-svn: 251335
* Define weak and __weak to mean ARC-style weak references, even in MRC.John McCall2015-10-227-59/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, __weak was silently accepted and ignored in MRC mode. That makes this a potentially source-breaking change that we have to roll out cautiously. Accordingly, for the time being, actual support for __weak references in MRC is experimental, and the compiler will reject attempts to actually form such references. The intent is to eventually enable the feature by default in all non-GC modes. (It is, of course, incompatible with ObjC GC's interpretation of __weak.) If you like, you can enable this feature with -Xclang -fobjc-weak but like any -Xclang option, this option may be removed at any point, e.g. if/when it is eventually enabled by default. This patch also enables the use of the ARC __unsafe_unretained qualifier in MRC. Unlike __weak, this is being enabled immediately. Since variables are essentially __unsafe_unretained by default in MRC, the only practical uses are (1) communication and (2) changing the default behavior of by-value block capture. As an implementation matter, this means that the ObjC ownership qualifiers may appear in any ObjC language mode, and so this patch removes a number of checks for getLangOpts().ObjCAutoRefCount that were guarding the processing of these qualifiers. I don't expect this to be a significant drain on performance; it may even be faster to just check for these qualifiers directly on a type (since it's probably in a register anyway) than to do N dependent loads to grab the LangOptions. rdar://9674298 llvm-svn: 251041
* [coroutines] Initial stub Sema functionality for handling coroutine await / ↵Richard Smith2015-10-225-7/+133
| | | | | | yield / return. llvm-svn: 250993
* [coroutines] Add overloaded unary 'operator co_await'.Richard Smith2015-10-222-0/+2
| | | | llvm-svn: 250991
* Convert ActOnForwardProtocolDeclaration to take an ArrayRef and use a ↵Craig Topper2015-10-221-6/+5
| | | | | | range-based for loop. NFC llvm-svn: 250990
* Use an ArrayRef<OffsetOfComponent> instead of pointer and size throughout ↵Craig Topper2015-10-222-18/+12
| | | | | | offsetof handling code. Also use a range-based for loop. NFC llvm-svn: 250989
* Change FindProtocolDeclaration to take an ArrayRef and use a range-based for ↵Craig Topper2015-10-221-12/+8
| | | | | | loop. NFC llvm-svn: 250988
* Use front() instead of [0] to make code more consistent with the next line ↵Craig Topper2015-10-221-1/+1
| | | | | | that uses back(). llvm-svn: 250970
* [Sema] Remove an unreachable llvm_unreachableDavid Majnemer2015-10-211-1/+0
| | | | | | No functionality change is intended. llvm-svn: 250935
* Some minor ARC diagnostic improvements.John McCall2015-10-211-2/+5
| | | | llvm-svn: 250917
* [modules] libstdc++ defines some static inline functions in its internalRichard Smith2015-10-211-0/+36
| | | | | | | | | | | headers. If those headers end up being textually included twice into the same module, we get ambiguity errors. Work around this by downgrading the ambiguity error to a warning if multiple identical internal-linkage functions appear in an overload set, and just pick one of those functions as the lookup result. llvm-svn: 250884
* Use ArrayRef and MutableArrayRef instead of a pointer and size. NFCCraig Topper2015-10-211-2/+2
| | | | llvm-svn: 250876
* Re-land r250592 without rejecting field refs in unevaluated contextsReid Kleckner2015-10-201-2/+13
| | | | | | | | | | | This time, I went with the first approach from http://reviews.llvm.org/D6700, where clang actually attempts to form an implicit member reference from an UnresolvedLookupExpr. We know that there are only two possible outcomes at this point, a DeclRefExpr of the FieldDecl or an error, but its safer to reuse the existing machinery for this. llvm-svn: 250856
* [-fms-extensions] Allow missing exception specifications in redeclarations ↵David Majnemer2015-10-201-4/+8
| | | | | | | | | | | as an extension Microsoft's ATL headers make use of this MSVC extension, add support for it and issue a diagnostic under -Wmicrosoft-exception-spec. This fixes PR25265. llvm-svn: 250854
* Look through using decls when classifying implicit member accessReid Kleckner2015-10-201-4/+4
| | | | | | | | | | | | | | | | | | | | | Clang will now accept this valid C++11 code: struct A { int field; }; struct B : A { using A::field; enum { TheSize = sizeof(field) }; }; Previously we would classify the 'field' reference as something other than a field, and then forget to apply the C++11 rule to allow non-static data member references in unevaluated contexts. This usually arises in class templates that want to reference fields of a dependent base in an unevaluated context outside of an instance method. Such contexts do not allow references to 'this', so the only way to access the field is with a using decl and an implicit member reference. llvm-svn: 250839
* Roll-back r250822.Angel Garcia Gomez2015-10-2010-14/+14
| | | | | | | | | | Summary: It breaks the build for the ASTMatchers Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D13893 llvm-svn: 250827
* Apply modernize-use-default to clang.Angel Garcia Gomez2015-10-2010-14/+14
| | | | | | | | | | | | Summary: Replace empty bodies of default constructors and destructors with '= default'. Reviewers: bkramer, klimek Subscribers: klimek, alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13890 llvm-svn: 250822
* Revert "Diagnose UnresolvedLookupExprs that resolve to instance members in ↵Reid Kleckner2015-10-202-22/+15
| | | | | | | | | | | | | | | | | static methods" This reverts commit r250592. It has issues around unevaluated contexts, like this: template <class T> struct A { T i; }; template <class T> struct B : A<T> { using A<T>::i; typedef decltype(i) U; }; template struct B<int>; llvm-svn: 250774
* No functionality change, just fix whitespace, a typo and remove an unnecessaryNick Lewycky2015-10-181-3/+3
| | | | | | | emacs mode marker. (Changes left behind from another patch that ended up not working out.) llvm-svn: 250666
* Diagnose UnresolvedLookupExprs that resolve to instance members in static ↵Reid Kleckner2015-10-172-15/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | methods During the initial template parse for this code, 'member' is unresolved and we don't know anything about it: struct A { int member }; template <typename T> struct B : public T { using T::member; static void f() { (void)member; // Could be static or non-static. } }; template class B<A>; The pattern declaration contains an UnresolvedLookupExpr rather than an UnresolvedMemberExpr because `f` is static, and `member` should never be a field. However, if the code is invalid, it may become a field, in which case we should diagnose it. Reviewers: rjmccall, rsmith Differential Revision: http://reviews.llvm.org/D6700 llvm-svn: 250592
* [Sema] Fix address-of + enable_if overloading logicGeorge Burgess IV2015-10-161-57/+93
| | | | | | | | | | | | | | | | | Previously, our logic when taking the address of an overloaded function would not consider enable_if attributes, so long as all of the enable_if conditions on a given candidate were true. So, two functions with identical signatures (one with enable_if attributes, the other without), would be considered equally good overloads. If we were calling the function instead of taking its address, then the function with enable_if attributes would be preferred. This patch makes us prefer the candidate with enable_if regardless of if we're calling or taking the address of an overloaded function. Differential Revision: http://reviews.llvm.org/D13795 llvm-svn: 250486
* [MSVC] Fix for http://llvm.org/PR24132: __declspec(property): double ↵Alexey Bataev2015-10-141-11/+12
| | | | | | | | | invocations of foo() when compiling foo()->propertyName Removes extra codegen for base expression of MS property call Differential Revision: http://reviews.llvm.org/D13375 llvm-svn: 250265
* [Sema/objc] When checking for unimplemented methods treat methods from class ↵Argyrios Kyrtzidis2015-10-131-4/+2
| | | | | | extensions as continuation of the class interface. llvm-svn: 250250
* [modules] Allow the error on importing a C++ module within an extern "C"Richard Smith2015-10-131-6/+9
| | | | | | | | | context (but otherwise at the top level) to be disabled, to support use of C++ standard library implementations that (legitimately) mark their <blah.h> headers as being C++ headers from C libraries that wrap things in 'extern "C"' a bit too enthusiastically. llvm-svn: 250137
* [Sema] Make `&function_with_enable_if_attrs` an errorGeorge Burgess IV2015-10-124-15/+67
| | | | | | | | | | | | | | | | | | This fixes a bug where one can take the address of a conditionally enabled function to drop its enable_if guards. For example: int foo(int a) __attribute__((enable_if(a > 0, ""))); int (*p)(int) = &foo; int result = p(-1); // compilation succeeds; calls foo(-1) Overloading logic has been updated to reflect this change, as well. Functions with enable_if attributes that are always true are still allowed to have their address taken. Differential Revision: http://reviews.llvm.org/D13607 llvm-svn: 250090
* [Sema] Don't emit multiple diags for one errorGeorge Burgess IV2015-10-121-5/+13
| | | | | | | | | Fixed a bug where we'd emit multiple diagnostics if there was a problem taking the address of an overloaded template function. Differential Revision: http://reviews.llvm.org/D13664 llvm-svn: 250078
* Fix warning caused by r249995George Burgess IV2015-10-111-0/+1
| | | | llvm-svn: 249997
* [Sema] Allow C conversions in C overload logicGeorge Burgess IV2015-10-112-30/+63
| | | | | | | | | | C allows for some implicit conversions that C++ does not, e.g. void* -> char*. This patch teaches clang that these conversions are okay when dealing with overloads in C. Differential Revision: http://reviews.llvm.org/D13604 llvm-svn: 249995
* Keep the IfStmt node even if the condition is invalidOlivier Goffart2015-10-111-17/+11
| | | | | | | This is important to keep the information in IDE or other tools even if the code contains a few errors llvm-svn: 249982
* Fix inference of _Nullable for weak Objective-C properties.Douglas Gregor2015-10-092-11/+9
| | | | | | | | | | | | | | | | | | | | The inference of _Nullable for weak Objective-C properties was broken in several ways: * It was back-patching the type information very late in the process of checking the attributes for an Objective-C property, which is just wrong. * It was using ad hoc checks to try to suppress the warning about missing nullability specifiers (-Wnullability-completeness), which didn't actual work in all cases (rdar://problem/22985457) * It was inferring _Nullable even outside of assumes-nonnull regions, which is wrong. Putting the inference of _Nullable for weak Objective-C properties in the same place as all of the other inference logic fixes all of these ills. llvm-svn: 249896
* Amending r249721 to properly handle pathological attribute-related names ↵Aaron Ballman2015-10-091-2/+2
| | | | | | | | like __ and ____. Patch by Adrian Zgorzalek! llvm-svn: 249833
* [Sema] Add "Ty" suffix to QualType variables for clarity (NFC)Vedant Kumar2015-10-091-5/+5
| | | | llvm-svn: 249801
* Skip NonNull sema checks in unevaluated contexts.Eric Fiselier2015-10-091-1/+2
| | | | | | | | | | | | | | Summary: Currently when a function annotated with __attribute__((nonnull)) is called in an unevaluated context with a null argument a -Wnonnull warning is emitted. This warning seems like a false positive unless the call expression is potentially evaluated. Change this behavior so that the non-null warnings use DiagRuntimeBehavior so they wont emit when they won't be evaluated. Reviewers: majnemer, rsmith Subscribers: mclow.lists, cfe-commits Differential Revision: http://reviews.llvm.org/D13408 llvm-svn: 249787
* When mapping no_sanitize_* attributes to no_sanitize attributes, handle ↵Aaron Ballman2015-10-081-11/+17
| | | | | | | | GNU-style formatting that involves prefix and suffix underscores. Cleans up other usages of similar functionality. Patch by Adrian Zgorzalek! llvm-svn: 249721
* [MSVC Compat] Try to treat an implicit, fixed enum as an unfixed enumDavid Majnemer2015-10-082-5/+13
| | | | | | | | | | | | | | | | | | consider the following: enum E *p; enum E { e }; The above snippet is not ANSI C because 'enum E' has not bee defined when we are processing the declaration of 'p'; however, it is a popular extension to make the above work. This would fail using the Microsoft enum semantics because the definition of 'E' would implicitly have a fixed underlying type of 'int' which would trigger diagnostic messages about a mismatch between the declaration and the definition. Instead, treat fixed underlying types as not fixed for the purposes of the diagnostic. llvm-svn: 249674
* [OPENMP 4.1] Codegen for array sections/subscripts in 'reduction' clause.Alexey Bataev2015-10-081-55/+88
| | | | | | OpenMP 4.1 adds support for array sections/subscripts in 'reduction' clause. Patch adds codegen for this feature. llvm-svn: 249672
* [Sema] Tweak incomplete enum types on MSVC ABI targetsDavid Majnemer2015-10-081-2/+4
| | | | | | | | | Enums without an explicit, fixed, underlying type are implicitly given a fixed 'int' type for ABI compatibility with MSVC. However, we can enforce the standard-mandated rules on these types as-if we didn't know this fact if the tag is not part of a definition. llvm-svn: 249667
* [MSVC Compat] Enable ABI impacting non-conforming behavior independently of ↵David Majnemer2015-10-081-1/+2
| | | | | | | | | | -fms-compatibility No ABI for C++ currently makes it possible to implement the standard 100% perfectly. We wrongly hid some of our compatible behavior behind -fms-compatibility instead of tying it to the compiler ABI. llvm-svn: 249656
* Fix Clang-tidy modernize-use-nullptr warnings in source directories; other ↵Hans Wennborg2015-10-063-31/+29
| | | | | | | | | | minor cleanups Patch by Eugene Zelenko! Differential Revision: http://reviews.llvm.org/D13406 llvm-svn: 249484
* Revert r107690 (for PR7417) and add a testcase that it breaks. The approach ofRichard Smith2015-10-052-50/+1
| | | | | | | | | that change turns out to not be reasonable: mutating the AST of a parsed template during instantiation is not a sound thing to do, does not work across chained PCH / modules builds, and is in any case a special-case workaround to a more general problem that should be solved centrally. llvm-svn: 249342
* SourceRanges are small and trivially copyable, don't them by reference.Craig Topper2015-10-046-22/+21
| | | | llvm-svn: 249259
* Diagnose const atomics in __atomic builtins.Eric Fiselier2015-10-041-3/+10
| | | | | | | | | | | Diagnose when a pointer to const T is used as the first argument in at atomic builtin unless that builtin is a load operation. This is already checked for C11 atomics builtins but not for __atomic ones. This patch was given the LGTM by rsmith when it was part of a larger review. (See http://reviews.llvm.org/D10407) llvm-svn: 249252
* Replace double negation of !FileID.isInvalid() with FileID.isValid().Yaron Keren2015-10-033-5/+5
| | | | | | +couple more of double-negated !SourceLocation.isInvalid() unfixed in r249228. llvm-svn: 249235
* Replace double-negated !SourceLocation.isInvalid() with ↵Yaron Keren2015-10-031-1/+1
| | | | | | SourceLocation.isValid(). llvm-svn: 249228
* [OpenMP] Capture global variables in target regions.Samuel Antao2015-10-022-3/+63
| | | | | | | | | All global variables that are not enclosed in a declare target region must be captured in the target region as local variables do. Currently, there is no support for declare target, so this patch adds support for capturing all the global variables used in a the target region. llvm-svn: 249154
* Be slightly more permissive when checking for type-erased blocks.Bob Wilson2015-10-021-1/+2
| | | | | | This is a patch from Doug that was inadvertently omitted from r241543. llvm-svn: 249116
OpenPOWER on IntegriCloud