Commit Graph

39 Commits

Author SHA1 Message Date
Galina Kistanova efa712444c Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.
llvm-svn: 304648
2017-06-03 06:30:08 +00:00
Egor Churaev 89831421af Fix problems in "[OpenCL] Enabling the usage of CLK_NULL_QUEUE as compare 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
2016-12-23 14:55:49 +00:00
Yaxun Liu 0bc4b2d337 [OpenCL] Generate opaque type for sampler_t and function call for the initializer
Currently Clang use int32 to represent sampler_t, which have been a source of issue for some backends, because in some backends sampler_t cannot be represented by int32. They have to depend on kernel argument metadata and use IPA to find the sampler arguments and global variables and transform them to target specific sampler type.

This patch uses opaque pointer type opencl.sampler_t* for sampler_t. For each use of file-scope sampler variable, it generates a function call of __translate_sampler_initializer. For each initialization of function-scope sampler variable, it generates a function call of __translate_sampler_initializer.

Each builtin library can implement its own __translate_sampler_initializer(). Since the real sampler type tends to be architecture dependent, allowing it to be initialized by a library function simplifies backend design. A typical implementation of __translate_sampler_initializer could be a table lookup of real sampler literal values. Since its argument is always a literal, the returned pointer is known at compile time and easily optimized to finally become some literal values directly put into image read instructions.

This patch is partially based on Alexey Sotkin's work in Khronos Clang (3d4eec6162).

Differential Revision: https://reviews.llvm.org/D21567

llvm-svn: 277024
2016-07-28 19:26:30 +00:00
George Burgess IV df1ed0099b [Bugfix] Fix ICE on constexpr vector splat.
In {CG,}ExprConstant.cpp, we weren't treating vector splats properly.
This patch makes us treat splats more properly.

Additionally, this patch adds a new cast kind which allows a bool->int
cast to result in -1 or 0, instead of 1 or 0 (for true and false,
respectively), so we can sanely model OpenCL bool->int casts in the AST.

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

llvm-svn: 257559
2016-01-13 01:52:39 +00:00
Fariborz Jahanian be7bf7285b Objective-C modernization. Convert -initWithUTF8String messaging
with auto-boxing syntax for literals. rdar://18080352

llvm-svn: 216405
2014-08-25 20:22:25 +00:00
Craig Topper 2145bc0229 [C++11] Use 'nullptr'.
llvm-svn: 208392
2014-05-09 08:15:10 +00:00
David Tweed e1468322eb Add front-end infrastructure now address space casts are in LLVM IR.
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
2013-12-11 13:39:46 +00:00
Fariborz Jahanian 85e988bbea ObjectiveC migrator: Remove semicolon after the typedef
declaration when converting to NS_ENUM. This required
some code refactoring.

llvm-svn: 186619
2013-07-18 22:17:33 +00:00
Fariborz Jahanian 92463274e6 ObjectiveC migration. migration to NS_ENUM/SN_OPTION
- wip.

llvm-svn: 186604
2013-07-18 20:11:45 +00:00
Fariborz Jahanian 3eb3159816 ObjectiveC migration: complete migrating class
declaration to include list of protocols class
conforms to. 

llvm-svn: 186443
2013-07-16 18:58:41 +00:00
Fariborz Jahanian 5bd5affe2d ObjC migrator: build conforming interface
declaration (not yet used). wip.

llvm-svn: 186369
2013-07-16 00:20:21 +00:00
Fariborz Jahanian 56f48d09f8 ObjC migrator: Improve on hueristics.
migrate to 'copy attribute if Object
class implements NSCopying otherwise 
assume implied 'strong'. Remove 
lifetime qualifier on property as it has
moved to property's attribute. Added TODO
comment for future work by poking into
setter implementation.

llvm-svn: 186037
2013-07-10 21:30:22 +00:00
Fariborz Jahanian a830ea7431 objc migrator: More refinment of property
attributes in migration. Specialli use of
'copy' attribute for retainable object types.

llvm-svn: 185985
2013-07-10 00:20:11 +00:00
Fariborz Jahanian bfaabe40e7 [Objective-C migrator] replace candidate user setter/getter with
their equivalent property declaration. wip.

llvm-svn: 185873
2013-07-08 21:42:08 +00:00
Fariborz Jahanian 266926d85e [objc migrator]: More knobs to do migration to
use of objc's properties.

llvm-svn: 185724
2013-07-05 20:46:03 +00:00
David Blaikie 05785d1622 Include llvm::Optional in clang/Basic/LLVM.h
Post-commit CR feedback from Jordan Rose regarding r175594.

llvm-svn: 175679
2013-02-20 22:23:23 +00:00
Dmitri Gribenko 60e92e55cc Remove an unneeded const_cast
llvm-svn: 175160
2013-02-14 13:49:48 +00:00
Guy Benyei 1b4fb3e08b Implement OpenCL event_t as Clang builtin type, including event_t related OpenCL restrictions (OpenCL 1.2 spec 6.9)
llvm-svn: 172973
2013-01-20 12:31:11 +00:00
Argyrios Kyrtzidis 6b4f341ecd [objcmt] Rewrite a NSDictionary dictionaryWithObjects:forKeys: to a dictionary literal
if we can see the elements of the arrays.

for example:

 NSDictionary *dict = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"1", @"2", nil] forKeys:[NSArray arrayWithObjects:@"A", @"B", nil]];

-->

 NSDictionary *dict = @{ @"A" : @"1", @"B" : @"2" };

rdar://12428166

llvm-svn: 172679
2013-01-16 23:54:48 +00:00
Chandler Carruth 3a02247dc9 Sort all of Clang's files under 'lib', and fix up the broken headers
uncovered.

This required manually correcting all of the incorrect main-module
headers I could find, and running the new llvm/utils/sort_includes.py
script over the files.

I also manually added quite a few missing headers that were uncovered by
shuffling the order or moving headers up to be main-module-headers.

llvm-svn: 169237
2012-12-04 09:13:33 +00:00
Eli Friedman 34866c7719 Change the representation of builtin functions in the AST
(__builtin_* etc.) so that it isn't possible to take their address.
Specifically, introduce a new type to represent a reference to a builtin
function, and a new cast kind to convert it to a function pointer in the
operand of a call.  Fixes PR13195.

llvm-svn: 162962
2012-08-31 00:14:07 +00:00
Argyrios Kyrtzidis 89b928eb6a [objcmt] Check for classes that accept 'objectForKey:' (or the other selectors
that the migrator handles) but return their instances as 'id', resulting
in the compiler resolving 'objectForKey:' as the method from NSDictionary.

When checking if we can convert to subscripting syntax, check whether
the receiver is a result of a class method from a hardcoded list of
such classes. In such a case return the specific class as the interface
of the receiver.

llvm-svn: 159788
2012-07-06 00:07:09 +00:00
Argyrios Kyrtzidis 13b92929dc [objcmt] Allow migrating to subscripting syntax for other classes
(apart from NSDictionary/NSArray) that implement objectForKey:/objectAtIndex/etc.
and the subscripting methods as well.

Part of rdar://11734969

llvm-svn: 159783
2012-07-05 21:49:51 +00:00
Benjamin Kramer 1ea8e092be Drop the ASTContext.h include from Stmt.h and fix up transitive users.
This required moving the ctors for IntegerLiteral and FloatingLiteral out of
line which shouldn't change anything as they are usually called through Create
methods that are already out of line.

ASTContext::Deallocate has been a nop for a long time, drop it from ASTVector
and make it independent from ASTContext.h

Pass the StorageAllocator directly to AccessedEntity so it doesn't need to
have a definition of ASTContext around.

llvm-svn: 159718
2012-07-04 17:04:04 +00:00
Argyrios Kyrtzidis 927a437ac7 [objcmt] Have the modern objc migration warning change from:
[NSNumber numberWithDouble:cppb];
warning: converting to boxing syntax requires a cast

to something like:

[NSNumber numberWithDouble:cppb];
warning: converting to boxing syntax requires casting 'bool' to 'double'

This is way better to fully understand the warning.
rdar://11705106

llvm-svn: 158783
2012-06-20 01:28:32 +00:00
Argyrios Kyrtzidis a3fcbeb908 [objcmt] When checking whether the subscripting methods are declared use
ObjCInterfaceDec::lookupInstanceMethod to make sure we check categories as well
and update related tests.

rdar://11695288

llvm-svn: 158697
2012-06-19 02:22:02 +00:00
Argyrios Kyrtzidis 63aebfb4ae [objcmt] When in ARC mode, also convert "[[.. alloc] init]" messages to literals,
since the change from +1 to +0 will be handled fine by ARC.

rdar://11606358

llvm-svn: 158114
2012-06-06 22:23:12 +00:00
Argyrios Kyrtzidis 6310fdd982 [objcmt] Don't migrate to subscripting syntax if the required methods have not
been declared on NSArray/NSDictionary.

rdar://11581975

llvm-svn: 157951
2012-06-04 21:23:26 +00:00
Argyrios Kyrtzidis b482260748 [objcmt] Warn when modern objc migrator does not convert a NSNumber message because it requires a cast.
rdar://11525138

llvm-svn: 157395
2012-05-24 16:48:23 +00:00
Argyrios Kyrtzidis 94442980c0 [objcmt] Don't add redundant parentheses when migrating subscripting of an ivar.
rdar://11501256

llvm-svn: 157227
2012-05-22 00:47:53 +00:00
Argyrios Kyrtzidis 8154147942 [objcmt] Accept char arrays for rewriting to @() syntax.
Part of rdar://11438360

llvm-svn: 156880
2012-05-16 00:21:21 +00:00
Argyrios Kyrtzidis cebe722ef6 [objcmt] When using NSNumber numberWithInteger:/numberWithUnsignedInteger: be
more liberal in rewriting when the parameter is an enum constant.

Part of rdar://11438360

llvm-svn: 156873
2012-05-15 22:59:54 +00:00
Argyrios Kyrtzidis 7bd957c12a [objcmt] Rewrite messages to NSString's stringWithUTF8String:/stringWithCString:
to use the @() boxing syntax.

It will also rewrite uses of stringWithCString:encoding: where the encoding that is
used is NSASCIIStringEncoding or NSUTF8StringEncoding.

rdar://11438360

llvm-svn: 156868
2012-05-15 22:22:10 +00:00
Argyrios Kyrtzidis 491e4aed31 [objcmt] Rewrite [NSNumber numberWith*] messages to the new @() boxing syntax.
There are some caveats:
-If an implicit cast (e.g. int -> float for numberWithFloat:) was required, the message
 will not get rewritten
-If the message was with numberWithInteger:/numberWithUnsignedInteger:, which are very
 commonly used, be more liberal and allow the boxing syntax if the underlying type has
 same signedness and will not lose precision.

Part of rdar://11438360

llvm-svn: 156844
2012-05-15 19:17:49 +00:00
Argyrios Kyrtzidis 0bbe94f737 [objcmt] When rewriting to subscripting syntax, make sure we put
the receiver in parentheses when necessary.

Part of rdar://11438360

llvm-svn: 156789
2012-05-14 23:33:49 +00:00
Argyrios Kyrtzidis c1dfed6572 [objcmt] When rewriting to array/dictionary literals, add an explicit
cast to 'id' for any argument that requires it.

Part of rdar://11438360.

llvm-svn: 156782
2012-05-14 22:01:53 +00:00
Benjamin Kramer ece209afbc Remove unused-but-set variable.
llvm-svn: 152633
2012-03-13 17:05:43 +00:00
David Blaikie bbafb8a745 Unify naming of LangOptions variable/get function across the Clang stack (Lex to AST).
The member variable is always "LangOpts" and the member function is always "getLangOpts".

Reviewed by Chris Lattner

llvm-svn: 152536
2012-03-11 07:00:24 +00:00
Ted Kremenek f7639e1b4a Add new code migrator support for migrating existing Objective-C code to use
the new Objective-C NSArray/NSDictionary/NSNumber literal syntax.

This introduces a new library, libEdit, which provides a new way to support
migration of code that improves on the original ARC migrator.  We now believe
that most of its functionality can be refactored into the existing libraries,
and thus this new library may shortly disappear.

llvm-svn: 152141
2012-03-06 20:06:33 +00:00