summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Objective-C. After providing a fix-it for aFariborz Jahanian2013-12-181-20/+15
| | | | | | | | cstring, converted to NSString, produce the matching AST for it. This also required some refactoring of the previous code. // rdar://14106083 llvm-svn: 197605
* Objective-C. Make diagnostics and fix-its consistent Fariborz Jahanian2013-12-171-11/+12
| | | | | | | | when diagnosing casting of a cstring literal to NSString in default and -fobjc-arc mode. // rdar://14106083 llvm-svn: 197515
* ObjectiveC. Further improvements of useFariborz Jahanian2013-12-161-6/+7
| | | | | | | | | | of objc_bridge_related attribute; eliminate unnecessary diagnostics which is issued elsewhere, fixit now produces a valid AST tree per convention. This results in some simplification in handling of this attribute as well. // rdar://15499111 llvm-svn: 197436
* Suppress -Wshadow / -Wold-style-cast expanded from system header macrosAlp Toker2013-12-121-3/+3
| | | | | | | | Thanks to Jonathan Sauer for providing initial test cases. Fixes PR16093 and PR18147. llvm-svn: 197150
* Add front-end infrastructure now address space casts are in LLVM IR.David Tweed2013-12-111-3/+12
| | | | | | | | | | With the introduction of explicit address space casts into LLVM, there's a need to provide a new cast kind the front-end can create for C/OpenCL/CUDA and code to produce address space casts from those kinds when appropriate. Patch by Michele Scandale! llvm-svn: 197036
* Objective-C. Provide fixit's for objc_bride_relatedFariborz Jahanian2013-12-101-2/+2
| | | | | | | attributed CF to ObjC type conversions. // rdar://15499111 llvm-svn: 196935
* Implement DR1460: fix handling of default initializers in unions; don't allowRichard Smith2013-12-101-14/+12
| | | | | | | | | more than one such initializer in a union, make mem-initializers override default initializers for other union members, handle anonymous unions with anonymous struct members better. Fix a couple of semi-related bugs exposed by the tests for same. llvm-svn: 196892
* ObjectiveC. Continuing implementation of objc_bridge_relatedFariborz Jahanian2013-12-071-0/+6
| | | | | | | | | attribute in sema and issuing a variety of diagnostics lazily for misuse of this attribute (and what to do) when converting from CF types to ObjectiveC types (and vice versa). // rdar://15499111 llvm-svn: 196629
* Fix code typos spotted while working on type traitsAlp Toker2013-12-061-1/+1
| | | | llvm-svn: 196587
* Fix a tranche of comment, test and doc typosAlp Toker2013-12-051-2/+2
| | | | llvm-svn: 196510
* Fix init-captures for generic lambdas.Faisal Vali2013-12-051-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For an init capture, process the initialization expression right away. For lambda init-captures such as the following: const int x = 10; auto L = [i = x+1](int a) { return [j = x+2, &k = x](char b) { }; }; keep in mind that each lambda init-capture has to have: - its initialization expression executed in the context of the enclosing/parent decl-context. - but the variable itself has to be 'injected' into the decl-context of its lambda's call-operator (which has not yet been created). Each init-expression is a full-expression that has to get Sema-analyzed (for capturing etc.) before its lambda's call-operator's decl-context, scope & scopeinfo are pushed on their respective stacks. Thus if any variable is odr-used in the init-capture it will correctly get captured in the enclosing lambda, if one exists. The init-variables above are created later once the lambdascope and call-operators decl-context is pushed onto its respective stack. Since the lambda init-capture's initializer expression occurs in the context of the enclosing function or lambda, therefore we can not wait till a lambda scope has been pushed on before deciding whether the variable needs to be captured. We also need to process all lvalue-to-rvalue conversions and discarded-value conversions, so that we can avoid capturing certain constant variables. For e.g., void test() { const int x = 10; auto L = [&z = x](char a) { <-- don't capture by the current lambda return [y = x](int i) { <-- don't capture by enclosing lambda return y; } }; If x was not const, the second use would require 'L' to capture, and that would be an error. Make sure TranformLambdaExpr is also aware of this. Patch approved by Richard (Thanks!!) http://llvm-reviews.chandlerc.com/D2092 llvm-svn: 196454
* Remove a whole lot of unused variablesAlp Toker2013-11-271-1/+0
| | | | | | | There are about 30 removed in this patch, generated by a new FixIt I haven't got round to submitting yet. llvm-svn: 195814
* Implement -Wold-style-castAlp Toker2013-11-271-0/+4
| | | | | | Based on a patch by Ondřej Hošek! llvm-svn: 195808
* PR10837: Warn if a null pointer constant is formed by a zero integer constantRichard Smith2013-11-211-6/+8
| | | | | | | expression that is not a zero literal, in C. This is a different, and more targeted, approach than that in r194540. llvm-svn: 195303
* Refine 'deprecated' checking for Objective-C classes/methods.Ted Kremenek2013-11-201-1/+2
| | | | | | | | | - If a deprecated class refers to another deprecated class, do not warn. - @implementations of a deprecated class can refer to other deprecated things. Fixes <rdar://problem/15407366> and <rdar://problem/15466783>. llvm-svn: 195259
* Revert r194540, it breaks various C++ programs.Joerg Sonnenberger2013-11-191-11/+2
| | | | llvm-svn: 195126
* [OpenCL] Make sure we put string literals in the constant address space.Joey Gouly2013-11-141-0/+5
| | | | llvm-svn: 194717
* PR10837: Warn if a null pointer constant is formed by a zero integer constantRichard Smith2013-11-131-2/+11
| | | | | | expression that is not a zero literal, in C. Patch by Ivan A. Kosarev! llvm-svn: 194540
* Add parens for || in && in assert. No functionality change.Benjamin Kramer2013-11-071-2/+2
| | | | llvm-svn: 194200
* This patch implements capturing of variables within generic lambdas.Faisal Vali2013-11-071-35/+132
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Both Richard and I felt that the current wording in the working paper needed some tweaking - Please see http://llvm-reviews.chandlerc.com/D2035 for additional context and references to core-reflector messages that discuss wording tweaks. What is implemented is what we had intended to specify in Bristol; but, recently felt that the specification might benefit from some tweaking and fleshing. As a rough attempt to explain the semantics: If a nested lambda with a default-capture names a variable within its body, and if the enclosing full expression that contains the name of that variable is instantiation-dependent - then an enclosing lambda that is capture-ready (i.e. within a non-dependent context) must capture that variable, if all intervening nested lambdas can potentially capture that variable if they need to, and all intervening parent lambdas of the capture-ready lambda can and do capture the variable. Of note, 'this' capturing is also currently underspecified in the working paper for generic lambdas. What is implemented here is if the set of candidate functions in a nested generic lambda includes both static and non-static member functions (regardless of viability checking - i.e. num and type of parameters/arguments) - and if all intervening nested-inner lambdas between the capture-ready lambda and the function-call containing nested lambda can capture 'this' and if all enclosing lambdas of the capture-ready lambda can capture 'this', then 'this' is speculatively captured by that capture-ready lambda. Hopefully a paper for the C++ committee (that Richard and I had started some preliminary work on) is forthcoming. This essentially makes generic lambdas feature complete, except for known bugs. The more prominent ones (and the ones I am currently aware of) being: - generic lambdas and init-captures are broken - but a patch that fixes this is already in the works ... - nested variadic expansions such as: auto K = [](auto ... OuterArgs) { vp([=](auto ... Is) { decltype(OuterArgs) OA = OuterArgs; return 0; }(5)...); return 0; }; auto M = K('a', ' ', 1, " -- ", 3.14); currently cause crashes. I think I know how to fix this (since I had done so in my initial implementation) - but it will probably take some work and back & forth with Doug and Richard. A warm thanks to all who provided feedback - and especially to Doug Gregor and Richard Smith for their pivotal guidance: their insight and prestidigitation in such matters is boundless! Now let's hope this commit doesn't upset the buildbot gods ;) Thanks! llvm-svn: 194188
* [-fms-extensions] Add support for __FUNCDNAME__David Majnemer2013-11-061-0/+1
| | | | | | | | | | | | | | | | Summary: Similar to __FUNCTION__, MSVC exposes the name of the enclosing mangled function name via __FUNCDNAME__. This implementation is very naive and unoptimized, it is expected that __FUNCDNAME__ would be used rarely in practice. Reviewers: rnk, rsmith, thakis CC: cfe-commits, silvas Differential Revision: http://llvm-reviews.chandlerc.com/D2109 llvm-svn: 194181
* Change the other -Wtautological-compare warnings to not trigger in templateRichard Trieu2013-11-021-2/+4
| | | | | | | specializations. Also switch to -Wuninitialized for a test case that depended on a warning firing in template specializations. llvm-svn: 193906
* ObjectiveC. Define a new cc1 flag Fariborz Jahanian2013-11-011-8/+4
| | | | | | | | | | | -fobjc-subscripting-legacy-runtime which is off by default and on only when using ObjectiveC legacy runtime. Use this flag to allow array and dictionary subscripting and disallow objectiveC pointer arithmatic in ObjectiveC legacy runtime. // rdar://15363492 llvm-svn: 193889
* Minor performance improvement to not do unnecessary workFariborz Jahanian2013-10-251-6/+8
| | | | | | in my last patch. // rdar://14989999 llvm-svn: 193441
* ObjectiveC: under -Wunused-property-ivar warn if property'sFariborz Jahanian2013-10-251-0/+6
| | | | | | | backing warning is not used in one of its accessor methods. // rdar://14989999 llvm-svn: 193439
* Add -Wstring-plus-char, which warns when adding char literals to C strings.Jordan Rose2013-10-251-4/+57
| | | | | | | | | | | Specifically, this warns when a character literal is added (using '+') to a variable with type 'char *' (or any other pointer to character type). Like -Wstring-plus-int, there is a fix-it to change "foo + 'a'" to "&foo['a']" iff the character literal is on the right side of the string. Patch by Anders Rönnholm! llvm-svn: 193418
* Sema: Do not allow lambda expressions to appear inside of constant expressionsDavid Majnemer2013-10-251-6/+15
| | | | | | | | | We would previously not diagnose this which would lead to crashes (on very strange code). This fixes PR17675. llvm-svn: 193397
* Parse: Disable delayed template parsing for constexpr functionsDavid Majnemer2013-10-231-5/+3
| | | | | | | | | | | | | | | Commit r191484 treated constexpr function templates as normal function templates with respect to delaying their parsing. However, this is unnecessarily restrictive because there is no compatibility concern with constexpr, MSVC doesn't support it. Instead, simply disable delayed template parsing for constexpr function templates. This largely reverts the changes made in r191484 but keeps it's unit test. This fixes PR17661. llvm-svn: 193274
* Fix typo.Rafael Espindola2013-10-191-1/+1
| | | | llvm-svn: 193026
* Rename some functions for consistency.Rafael Espindola2013-10-171-1/+1
| | | | | | Every other function in Redeclarable.h was using Decl instead of Declaration. llvm-svn: 192900
* ms-compat: Fix taking the address of a member of a dependent baseReid Kleckner2013-10-151-6/+18
| | | | | | | | | | | | | | | | | | | | | | If unqualified id lookup fails while parsing a class template with a dependent base, clang with -fms-compatibility will pretend the user prefixed the name with 'this->' in order to delay the lookup. However, if there was a unary ampersand, Sema::ActOnDependentIdExpression() will create a DependentDeclRefExpr, which is not what we wanted at all. Fix this by building the CXXDependentScopeMemberExpr directly instead. In order to be fully MSVC compatible, we would have to defer all attempts at name lookup to instantiation time. However, until we have real problems with system headers that can't be parsed, we'll put off implementing that. Fixes PR16014. Reviewers: rsmith Differential Revision: http://llvm-reviews.chandlerc.com/D1892 llvm-svn: 192727
* Sema: Consider it an error to apply __builtin_offsetof to a member in a ↵David Majnemer2013-10-151-2/+8
| | | | | | | | | | virtual base icc 13 and g++ 4.9 both reject this while we would crash. Fixes PR17578. llvm-svn: 192674
* Diagnose by-copy captures of abstract classes.Douglas Gregor2013-10-111-0/+4
| | | | | | Fixes <rdar://problem/14468891>. llvm-svn: 192419
* Sema: Taking the address of a dtor is illegal per C++ [class.dtor]p2.Benjamin Kramer2013-10-101-0/+4
| | | | | | Emit a proper error instead of crashing in CodeGen. PR16892. llvm-svn: 192345
* Make InstantiatingTemplate depth checks clearerAlp Toker2013-10-081-1/+1
| | | | | | | | | | The bool conversion operator on InstantiatingTemplate never added value and only served to obfuscate the template instantiation routines. This replaces the conversion and its callers with an explicit isInvalid() function to make it clear what's going on at a glance. llvm-svn: 192177
* Add support for WG21 N3599 (literal operator template for strings) as a GNURichard Smith2013-10-071-32/+78
| | | | | | | | | extension. The GCC folks have decided to support this even though the standard committee have not yet approved this feature. Patch by Hristo Venev! llvm-svn: 192128
* Sema::tryCaptureVariable(): Prune three unused variables, HasBlocksAttr, ↵NAKAMURA Takumi2013-10-071-4/+0
| | | | | | IsBlock, and IsLambda. [-Wunused-variable] llvm-svn: 192095
* Refactor tryCaptureVar using ExtractMethod. No functionality change.Faisal Vali2013-10-071-301/+394
| | | | | | | | | | In chicago, Doug had requested that I go ahead and commit the refactor as a separate change, if all the tests passed. Lets hope the buildbots stay quiet. Thanks! llvm-svn: 192087
* Tweak changes in r186464 to avoid a crash.Eli Friedman2013-10-011-1/+4
| | | | | | | | | | | | | Currently, IR generation can't handle file-scope compound literals with non-constant initializers in C++. Fixes PR17415 (the first crash in the bug). (We should probably change (T){1,2,3} to use the same codepath as T{1,2,3} in C++ eventually, given that the semantics of the latter are actually defined by the standard.) llvm-svn: 191719
* Switch from putting init capture VarDecls in the surrounding DeclContext toRichard Smith2013-09-281-4/+11
| | | | | | | | putting them in the call operator's DeclContext. This better matches the language wording and avoids some cases where code gets confused by them for namespace-scope lambdas and the like. llvm-svn: 191606
* Variable templates: handle instantiation of static data member templatesRichard Smith2013-09-271-34/+22
| | | | | | appropriately, especially when they appear within class templates. llvm-svn: 191548
* Sema: Respect -fdelayed-template-parsing when parsing constexpr functionsDavid Majnemer2013-09-271-3/+5
| | | | | | | | | | | | | | Functions declared as constexpr must have their parsing delayed in -fdelayed-template-parsing mode so as not to upset later template instantiation. N.B. My reading of the standard makes it seem like delayed template parsing is at odds with constexpr. We may want to make refinements in other places in clang to make constexpr play nicer with this feature. This fixes PR17334. llvm-svn: 191484
* Fix a bug in the typo correction replacement location.Kaelyn Uhrain2013-09-261-1/+3
| | | | | | | | I noticed the wrong text was being replaced with the correction while working on expanding the "namespace-aware" typo correction to include classes. llvm-svn: 191450
* Switch the semantic DeclContext for a block-scope declaration of a function orRichard Smith2013-09-201-1/+1
| | | | | | | | | | | | | | variable from being the function to being the enclosing namespace scope (in C++) or the TU (in C). This allows us to fix a selection of related issues where we would build incorrect redeclaration chains for such declarations, and fail to notice type mismatches. Such declarations are put into a new IdentifierNamespace, IDNS_LocalExtern, which is only found when searching scopes, and not found when searching DeclContexts. Such a declaration is only made visible in its DeclContext if there are no non-LocalExtern declarations. llvm-svn: 191064
* Add the intrinsic __builtin_convertvectorHal Finkel2013-09-181-0/+13
| | | | | | | | | | | | | | | | | | LLVM supports applying conversion instructions to vectors of the same number of elements (fptrunc, fptosi, etc.) but there had been no way for a Clang user to cause such instructions to be generated when using builtin vector types. C-style casting on vectors is already defined in terms of bitcasts, and so cannot be used for these conversions as well (without leading to a very confusing set of semantics). As a result, this adds a __builtin_convertvector intrinsic (patterned after the OpenCL __builtin_astype intrinsic). This is intended to aid the creation of vector intrinsic headers that create generic IR instead of target-dependent intrinsics (in other words, this is a generic _mm_cvtepi32_ps). As noted in the documentation, the action of __builtin_convertvector is defined in terms of the action of a C-style cast on each vector element. llvm-svn: 190915
* Handle PredefinedExpr with templates and lambdasWei Pan2013-09-161-18/+23
| | | | | | | | | | | Summary: - lambdas, blocks or captured statements in templates were not handled which causes codegen crashes. Differential Revision: http://llvm-reviews.chandlerc.com/D1628 llvm-svn: 190784
* Fix regression from r190427.Eli Friedman2013-09-121-1/+1
| | | | | | <rdar://problem/14970968> llvm-svn: 190635
* PR5683: Issue a warning when subtracting pointers to types of zero size, andRichard Smith2013-09-101-0/+12
| | | | | | | treat such subtractions as being non-constant. Patch by Serge Pavlov! With a few tweaks by me. llvm-svn: 190439
* OpenCL allows the (pre/post)-(increment/decrement) operator on integer ↵David Tweed2013-09-061-0/+3
| | | | | | | | | | vector types, so allow that case and add appropriate tests. Patch by Ruiling Song! llvm-svn: 190129
* Add self-comparison warnings for fields.Eli Friedman2013-09-061-30/+43
| | | | | | | | | | | | This expands very slightly what -Wtautological-compare considers to be tautological to include implicit accesses to C++ fields and ObjC ivars. I don't want to turn this into a full expression-identity check, but these additions seem pretty well-contained, and maintain the theme of checking for "x == x". <rdar://problem/14431127> llvm-svn: 190118
OpenPOWER on IntegriCloud