summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [Sema] Fix typos handling in an overloadable call.Anastasia Stulova2017-05-081-0/+3
| | | | | | | | | | | | | | | | In C typos in arguments in a call of an overloadable function lead to a failure of construction of CallExpr and following recovery does not handle created delayed typos. This causes an assertion fail in Sema::~Sema since Sema::DelayedTypos remains not empty. The patch fixes that behavior by handling a call with arguments having dependant types in the way that C++ does. Differential Revision: https://reviews.llvm.org/D31764 Patch by Dmitry Borisenkov! llvm-svn: 302435
* [ARM] Limit the diagnose when an ISR calls a regular functionWeiming Zhao2017-05-051-2/+4
| | | | | | | | | | | | | | | | Summary: When the function is compiled with soft-float or on CPU with no FPU, we don't need to diagnose for a call from an ISR to a regular function. Reviewers: jroelofs, eli.friedman Reviewed By: jroelofs Subscribers: aemerson, rengolin, javed.absar, cfe-commits Differential Revision: https://reviews.llvm.org/D32918 llvm-svn: 302274
* [Sema] Update function doc; NFCGeorge Burgess IV2017-05-021-1/+1
| | | | llvm-svn: 301970
* Use a consistent style. NFCGeorge Burgess IV2017-04-271-4/+3
| | | | llvm-svn: 301601
* Fix comment. NFCGeorge Burgess IV2017-04-261-2/+1
| | | | llvm-svn: 301486
* -Wunguarded-availability should support if (@available) checks in top-levelAlex Lorenz2017-04-261-3/+11
| | | | | | | | | | | | | blocks and lambdas Prior to this commit Clang emitted the old "partial availability" warning for expressions that referred to declarations that were not yet introduced in blocks and lambdas that were not in a function/method. This commit ensures that top-level blocks and lambdas use the new unguarded availability checks. rdar://31835952 llvm-svn: 301409
* Add support for editor placeholders to ClangAlex Lorenz2017-04-191-0/+6
| | | | | | | | | | | | | | | | | | | | | This commit teaches Clang to recognize editor placeholders that are produced when an IDE like Xcode inserts a code-completion result that includes a placeholder. Now when the lexer sees a placeholder token, it emits an 'editor placeholder in source file' error and creates an identifier token that represents the placeholder. The parser/sema can now recognize the placeholders and can suppress the diagnostics related to the placeholders. This ensures that live issues in an IDE like Xcode won't get spurious diagnostics related to placeholders. This commit also adds a new compiler option named '-fallow-editor-placeholders' that silences the 'editor placeholder in source file' error. This is useful for an IDE like Xcode as we don't want to display those errors in live issues. rdar://31581400 Differential Revision: https://reviews.llvm.org/D32081 llvm-svn: 300667
* Diagnose attempt to take address of bitfield members in anonymous structs.Richard Smith2017-04-131-1/+4
| | | | | | | | Patch by Jacob Young! Differential Revision: https://reviews.llvm.org/D27263 llvm-svn: 300264
* [Sema] Extend GetSignedVectorType to deal with non ExtVector typesSimon Dardis2017-04-061-15/+36
| | | | | | | | | | | | | This improves some error messages which would otherwise refer to ext_vector_type types in contexts where there are no such types. Factored out from D25866 at reviewer's request. Reviewers: bruno Differential Revision: https://reviews.llvm.org/D31667 llvm-svn: 299641
* [OpenCL] Extended diagnostics for atomic initializationEgor Churaev2017-04-051-1/+1
| | | | | | | | | | | | | | | | | | Summary: I saw the same changes in the following review: https://reviews.llvm.org/D17438 I don't know in that way I could determine that atomic variable was initialized by macro ATOMIC_VAR_INIT. Anyway I added check that atomic variables can be initialize only in global scope. I think that we can discuss this change. Reviewers: Anastasia, cfe-commits Reviewed By: Anastasia Subscribers: bader, yaxunl Differential Revision: https://reviews.llvm.org/D30643 llvm-svn: 299537
* [NFC, Scoped Enum] Convert Sema::ExpressionEvaluationContext into a scoped EnumFaisal Vali2017-04-011-30/+34
| | | | | | | | - also replace direct equality checks against the ConstantEvaluated enumerator with isConstantEvaluted(), in anticipation of adding finer granularity to the various ConstantEvaluated contexts and reinstating certain restrictions on where lambda expressions can occur in C++17. - update the clang tablegen backend that uses these Enumerators, and add the relevant scope where needed. llvm-svn: 299316
* Spelling mistakes in comments. NFCI. (PR27635)Simon Pilgrim2017-03-301-1/+1
| | | | llvm-svn: 299083
* [ARC][ObjC++] Use ObjC semantic rules for comparisons between a pointer andAlex Lorenz2017-03-301-1/+4
| | | | | | | | | | | | | | | | | | | | an ObjC object pointer When ARC is enabled in Objective-C++, comparisons between a pointer and Objective-C object pointer typically result in errors like this: "invalid operands to a binary expression". This error message can be quite confusing as it doesn't provide a solution to the problem, unlike the non-C++ diagnostic: "implicit conversion of Objective-C pointer type 'id' to C pointer type 'void *' requires a bridged cast" (it also provides fix-its). This commit forces comparisons between pointers and Objective-C object pointers in ARC to use the Objective-C semantic rules to ensure that a better diagnostic is reported. rdar://31103857 Differential Revision: https://reviews.llvm.org/D31177 llvm-svn: 299080
* [Objective-C] Fix "weak-unavailable" warning with -fobjc-weakBrian Kelley2017-03-291-9/+10
| | | | | | | | | | | | | | Summary: clang should produce the same errors Objective-C classes that cannot be assigned to weak pointers under both -fobjc-arc and -fobjc-weak. Check for ObjCWeak along with ObjCAutoRefCount when analyzing pointer conversions. Add an -fobjc-weak pass to the existing arc-unavailable-for-weakref test cases to verify the behavior is the same. Reviewers: rsmith, doug.gregor, rjmccall Reviewed By: rjmccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D31006 llvm-svn: 299014
* [Objective-C] Fix "repeated use of weak" warning with -fobjc-weakBrian Kelley2017-03-291-7/+11
| | | | | | | | | | | | | | Summary: -Warc-repeated-use-of-weak should produce the same warnings with -fobjc-weak as it does with -objc-arc. Also check for ObjCWeak along with ObjCAutoRefCount when recording the use of an evaluated weak variable. Add a -fobjc-weak run to the existing arc-repeated-weak test case and adapt it slightly to work in both modes. Reviewers: rsmith, doug.gregor, jordan_rose, rjmccall Reviewed By: rjmccall Subscribers: arphaman, rjmccall, cfe-commits Differential Revision: https://reviews.llvm.org/D31005 llvm-svn: 299011
* Encapsulate FPOptions and use it consistentlyAdam Nemet2017-03-271-2/+2
| | | | | | | | | | | | | | | | | | Sema holds the current FPOptions which is adjusted by 'pragma STDC FP_CONTRACT'. This then gets propagated into expression nodes as they are built. This encapsulates FPOptions so that this propagation happens opaquely rather than directly with the fp_contractable on/off bit. This allows controlled transitioning of fp_contractable to a ternary value (off, on, fast). It will also allow adding more fast-math flags later. This is toward moving fp-contraction=fast from an LLVM TargetOption to a FastMathFlag in order to fix PR25721. Differential Revision: https://reviews.llvm.org/D31166 llvm-svn: 298877
* Fix crash with interrupt attribute on ARM.Eli Friedman2017-03-141-1/+1
| | | | | | An indirect call has no associated function declaration. llvm-svn: 297694
* [OpenCL] Fix type compatibility check and generic AS mangling.Anastasia Stulova2017-03-101-63/+84
| | | | | | | | | | | | | | | | | | | | 1. Reimplemented conditional operator so that it checks compatibility of unqualified pointees of the 2nd and the 3rd operands (C99, OpenCL v2.0 6.5.15). Define QualTypes compatibility for OpenCL as following: - corresponding types are compatible (C99 6.7.3) - CVR-qualifiers are equal (C99 6.7.3) - address spaces are equal (implementation defined) 2. Added generic address space to Itanium mangling. Review: D30037 Patch by Dmitry Borisenkov! llvm-svn: 297468
* [Sema] Add variable captured by a block to the enclosing lambda'sAkira Hatanaka2017-03-011-2/+3
| | | | | | | | | | | | | | | potential capture list. Fix Sema::getCurLambda() to return the innermost lambda scope when there is a block enclosed in the lambda. Previously, the method would return a nullptr in such cases, which would prevent a variable captured by the enclosed block to be added to the lambda scope's potential capture list. rdar://problem/28412462 Differential Revision: https://reviews.llvm.org/D25556 llvm-svn: 296584
* Rename ActiveTemplateInstantiation to CodeSynthesisContext in preparation forRichard Smith2017-02-231-4/+5
| | | | | | | using it for other kinds of context (where we currently produce context notes in a highly ad-hoc manner). llvm-svn: 295919
* Factor out function to determine whether we're performing a templateRichard Smith2017-02-211-8/+7
| | | | | | | | | instantiation. In preparation for converting the template stack to a more general context stack (so we can include context notes for other kinds of context). llvm-svn: 295686
* Add an explicit derived class of FunctionDecl to model deduction guides ratherRichard Smith2017-02-171-0/+3
| | | | | | | | than just treating them as FunctionDecls with a funny name. No functionality change intended. llvm-svn: 295491
* Use correct fix-it location for -Wblock-capture-autoreleasingAlex Lorenz2017-02-161-2/+24
| | | | | | | | | The '__autoreleasing' keyword should be inserted after the Objective-C pointer type. rdar://30123548 llvm-svn: 295381
* [OpenCL] Disallow blocks capture other blocks (v2.0, s6.12.5)Anastasia Stulova2017-02-161-0/+7
| | | | llvm-svn: 295307
* [c++1z] Diagnose attempts to use variables with deduced class templateRichard Smith2017-02-101-3/+1
| | | | | | specialization types from within their own initializers. llvm-svn: 294796
* [OpenCL] Accept logical NOT for pointer types in CL1.1Anastasia Stulova2017-02-071-1/+1
| | | | | | | | | Fix for bug 30217 - incorrect error given for logical NOT operation with a pointer type: corrected sema check and improved related tests. Review: D29038 llvm-svn: 294313
* Change how we handle diagnose_if attributes.George Burgess IV2017-01-281-18/+1
| | | | | | | | | | | | | This patch changes how we handle argument-dependent `diagnose_if` attributes. In particular, we now check them in the same place that we check for things like passing NULL to Nonnull args, etc. This is basically better in every way than how we were handling them before. :) This fixes PR31638, PR31639, and PR31640. Differential Revision: https://reviews.llvm.org/D28889 llvm-svn: 293360
* [OpenCL] Add missing address spaces in IR generation of blocksAnastasia Stulova2017-01-271-3/+20
| | | | | | | | | | | | | | | | | | | | | | | | Modify ObjC blocks impl wrt address spaces as follows: - keep default private address space for blocks generated as local variables (with captures); - add global address space for global block literals (no captures); - make the block invoke function and enqueue_kernel prototype with the generic AS block pointer parameter to accommodate both private and global AS cases from above; - add block handling into default AS because it's implemented as a special pointer type (BlockPointer) in the frontend and therefore it is used as a pointer everywhere. This is also needed to accommodate both private and global AS blocks for the two cases above. - removes ObjC RT specific symbols (NSConcreteStackBlock and NSConcreteGlobalBlock) in the OpenCL mode. Review: https://reviews.llvm.org/D28814 llvm-svn: 293286
* PR0091R3: Implement parsing support for using templates as types.Richard Smith2017-01-261-1/+2
| | | | | | | | | | | | | | | This change adds a new type node, DeducedTemplateSpecializationType, to represent a type template name that has been used as a type. This is modeled around AutoType, and shares a common base class for representing a deduced placeholder type. We allow deduced class template types in a few more places than the standard does: in conditions and for-range-declarators, and in new-type-ids. This is consistent with GCC and with discussion on the core reflector. This patch does not yet support deduced class template types being named in typename specifiers. llvm-svn: 293207
* [Sema][ObjC] Make sure -Wblock-capture-autoreleasing issues a warningAkira Hatanaka2017-01-261-3/+20
| | | | | | | | | | | | | | | even in the presence of nullability qualifiers. This commit fixes bugs in r285031 where -Wblock-capture-autoreleasing wouldn't issue warnings when the function parameters were annotated with nullability qualifiers. Specifically, look through the sugar and see if there is an AttributedType of kind attr_objc_ownership to determine whether __autoreleasing was explicitly specified or implicitly added by the compiler. rdar://problem/30193488 llvm-svn: 293194
* [Sema] Fix PR28181 by avoiding calling BuildOverloadedBinOp in C modeAlex Lorenz2017-01-191-6/+5
| | | | | | | | rdar://28532840 Differential Revision: https://reviews.llvm.org/D25213 llvm-svn: 292497
* Warn when calling a non interrupt function from an interrupt on ARMJonathan Roelofs2017-01-181-0/+9
| | | | | | | | | | The idea for this originated from a really tricky bug: ISRs on ARM don't automatically save off the VFP regs, so if say, memcpy gets interrupted and the ISR itself calls memcpy, the regs are left clobbered when the ISR is done. https://reviews.llvm.org/D28820 llvm-svn: 292375
* [Sema] Add warning for unused lambda capturesMalcolm Parsons2017-01-131-1/+3
| | | | | | | | | | | | | | | Summary: Warn when a lambda explicitly captures something that is not used in its body. The warning is part of -Wunused and can be enabled with -Wunused-lambda-capture. Reviewers: rsmith, arphaman, jbcoe, aaron.ballman Subscribers: Quuxplusone, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D28467 llvm-svn: 291905
* [cxx1z-constexpr-lambda] [NFC] Add a FIXME to reinstate certain restrictions ↵Faisal Vali2017-01-091-0/+6
| | | | | | | | | | | | on constexpr lambdas from appearing within function-signatures (CWG1607) For further background, see Richard's comments: http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20170109/181998.html A patch to fix this is being worked on. Thanks! llvm-svn: 291439
* Add the diagnose_if attribute to clang.George Burgess IV2017-01-091-26/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `diagnose_if` can be used to have clang emit either warnings or errors for function calls that meet user-specified conditions. For example: ``` constexpr int foo(int a) __attribute__((diagnose_if(a > 10, "configurations with a > 10 are " "expensive.", "warning"))); int f1 = foo(9); int f2 = foo(10); // warning: configuration with a > 10 are expensive. int f3 = foo(f2); ``` It currently only emits diagnostics in cases where the condition is guaranteed to always be true. So, the following code will emit no warnings: ``` constexpr int bar(int a) { foo(a); return 0; } constexpr int i = bar(10); ``` We hope to support optionally emitting diagnostics for cases like that (and emitting runtime checks) in the future. Release notes will appear shortly. :) Differential Revision: https://reviews.llvm.org/D27424 llvm-svn: 291418
* [cxx1z-constexpr-lambda] Implement constant evaluation of non-capturing ↵Faisal Vali2017-01-091-2/+4
| | | | | | | | | | | | | | | lambda expressions. Add a visitor for lambda expressions to RecordExprEvaluator in ExprConstant.cpp that creates an empty APValue of Struct type to represent the closure object. Additionally, add a LambdaExpr visitor to the TemporaryExprEvaluator that forwards constant evaluation of immediately-called-lambda-expressions to the one in RecordExprEvaluator through VisitConstructExpr. This patch supports: constexpr auto ID = [] (auto a) { return a; }; static_assert(ID(3.14) == 3.14); static_assert([](auto a) { return a + 1; }(10) == 11); Lambda captures are still not supported for constexpr lambdas. llvm-svn: 291416
* PR23135: Don't instantiate constexpr functions referenced in unevaluated ↵Richard Smith2017-01-071-51/+63
| | | | | | | | | | | | | | | | | | | | | operands where possible. This implements something like the current direction of DR1581: we use a narrow syntactic check to determine the set of places where a constant expression could be evaluated, and only instantiate a constexpr function or variable if it's referenced in one of those contexts, or is odr-used. It's not yet clear whether this is the right set of syntactic locations; we currently consider all contexts within templates that would result in odr-uses after instantiation, and contexts within list-initialization (narrowing conversions take another victim...), as requiring instantiation. We could in principle restrict the former cases more (only const integral / reference variable initializers, and contexts in which a constant expression is required, perhaps). However, this is sufficient to allow us to accept libstdc++ code, which relies on GCC's behavior (which appears to be somewhat similar to this approach). llvm-svn: 291318
* Revisit PR10177: don't instantiate a variable if it's only referenced in aRichard Smith2017-01-061-63/+46
| | | | | | | | | | | | | | dependent context and can't be used in a constant expression. Per C++ [temp.inst]p2, "the instantiation of a static data member does not occur unless the static data member is used in a way that requires the definition to exist". This doesn't /quite/ match that, as we still instantiate static data members that are usable in constant expressions even if the use doesn't require a definition. A followup patch will fix that for both variables and functions. llvm-svn: 291295
* Bail out if we try to build a DeclRefExpr naming an invalid declaration.Richard Smith2017-01-041-0/+3
| | | | | | | | | | | Most code paths would already bail out in this case, but certain paths, particularly overload resolution and typo correction, would not. Carrying on with an invalid declaration could in some cases result in crashes due to downstream code relying on declaration invariants that are not necessarily met for invalid declarations, and in other cases just resulted in undesirable follow-on diagnostics. llvm-svn: 291030
* Fix problems in "[OpenCL] Enabling the usage of CLK_NULL_QUEUE as compare ↵Egor Churaev2016-12-231-0/+12
| | | | | | | | | | | | | | operand." Summary: Fixed warnings in commit: https://reviews.llvm.org/rL290171 Reviewers: djasper, Anastasia Subscribers: yaxunl, cfe-commits, bader Differential Revision: https://reviews.llvm.org/D27981 llvm-svn: 290431
* Revert "[OpenCL] Enabling the usage of CLK_NULL_QUEUE as compare operand."Daniel Jasper2016-12-201-12/+0
| | | | | | | | | | This reverts commit r290171. It triggers a bunch of warnings, because the new enumerator isn't handled in all switches. We want a warning-free build. Replied on the commit with more details. llvm-svn: 290173
* [OpenCL] Enabling the usage of CLK_NULL_QUEUE as compare operand.Egor Churaev2016-12-201-0/+12
| | | | | | | | | | | | Summary: Enabling the compression of CLK_NULL_QUEUE to variable of type queue_t. Reviewers: Anastasia Subscribers: cfe-commits, yaxunl, bader Differential Revision: https://reviews.llvm.org/D27569 llvm-svn: 290171
* Recommit r289979 [OpenCL] Allow disabling types and declarations associated ↵Yaxun Liu2016-12-181-5/+8
| | | | | | | | with extensions Fixed undefined behavior due to cast integer to bool in initializer list. llvm-svn: 290056
* Revert r289979 due to regressionsYaxun Liu2016-12-161-8/+5
| | | | llvm-svn: 289991
* [OpenCL] Allow disabling types and declarations associated with extensionsYaxun Liu2016-12-161-5/+8
| | | | | | | | | | | | | | | | | | Added a map to associate types and declarations with extensions. Refactored existing diagnostic for disabled types associated with extensions and extended it to declarations for generic situation. Fixed some bugs for types associated with extensions. Allow users to use pragma to declare types and functions for supported extensions, e.g. #pragma OPENCL EXTENSION the_new_extension_name : begin // declare types and functions associated with the extension here #pragma OPENCL EXTENSION the_new_extension_name : end Differential Revision: https://reviews.llvm.org/D21698 llvm-svn: 289979
* Replace APFloatBase static fltSemantics data members with getter functionsStephan Bergmann2016-12-141-1/+1
| | | | | | | | | | | | | At least the plugin used by the LibreOffice build (<https://wiki.documentfoundation.org/Development/Clang_plugins>) indirectly uses those members (through inline functions in LLVM/Clang include files in turn using them), but they are not exported by utils/extract_symbols.py on Windows, and accessing data across DLL/EXE boundaries on Windows is generally problematic. Differential Revision: https://reviews.llvm.org/D26671 llvm-svn: 289647
* Improve handling of floating point literals in OpenCL to only use double ↵Neil Hickey2016-12-131-5/+16
| | | | | | | | | | | | | | precision if the target supports fp64. This change makes sure single-precision floating point types are used if the cl_fp64 extension is not supported by the target. Also removed the check to see whether the OpenCL version is >= 1.2, as this has been incorporated into the extension setting code. Differential Revision: https://reviews.llvm.org/D24235 llvm-svn: 289544
* DR1213: element access on an array xvalue or prvalue produces an xvalue. In theRichard Smith2016-12-051-5/+33
| | | | | | | | | | | | | | latter case, a temporary array object is materialized, and can be lifetime-extended by binding a reference to the member access. Likewise, in an array-to-pointer decay, an rvalue array is materialized before being converted into a pointer. This caused IR generation to stop treating file-scope array compound literals as having static storage duration in some cases in C++; that has been rectified by modeling such a compound literal as an lvalue. This also improves clang's compatibility with GCC for those cases. llvm-svn: 288654
* DR616, and part of P0135R1: member access (or pointer-to-member access) on aRichard Smith2016-12-031-3/+3
| | | | | | | temporary produces an xvalue, not a prvalue. Support this by materializing the temporary prior to performing the member access. llvm-svn: 288563
* More diagnostic name fixups: w_ -> warn_, warning_ -> warn_, not_ -> note_.Richard Smith2016-12-021-1/+1
| | | | | | In passing, add a warning group for "ignored qualifier in inline assembly" warnings. llvm-svn: 288548
OpenPOWER on IntegriCloud