[OpenCL] Adding reserved operator logical xor for OpenCL
This patch adds the reserved operator ^^ when compiling for OpenCL (spec v1.1 s6.3.g),
which results in a more meaningful error message.
Patch by Neil Hickey!
Review: http://reviews.llvm.org/D13280
M test/SemaOpenCL/unsupported.cl
M include/clang/Basic/TokenKinds.def
M include/clang/Basic/DiagnosticParseKinds.td
M lib/Basic/OperatorPrecedence.cpp
M lib/Lex/Lexer.cpp
M lib/Parse/ParseExpr.cpp
Yury Gribov [Wed, 3 Feb 2016 13:35:33 +0000 (13:35 +0000)]
[analyzer] AnalysisConsumer: print fully-qualified function name while displaying progress
-analyzer-display progress option prints only function names which may be ambiguous. This patch forces AnalysisConsumer to print fully-qualified function names.
Patch by Alex Sidorin!
Marina Yatsina [Wed, 3 Feb 2016 11:32:08 +0000 (11:32 +0000)]
-inline-asm][X86] Add ability to use AVX512 in MS inline asm
Defined the new AVX512 registers in clang inline asm.
Fixed a bug in the MC subtarget info creation during the parsing of MS asm statement - now it receives the actual CPU and target features information.
Ben Langmuir [Wed, 3 Feb 2016 03:26:19 +0000 (03:26 +0000)]
Make CF constant string decl visible to name lookup to fix module errors
The return type of the __builtin___*StringMakeConstantString functions
is a pointer to a struct, so we need that struct to be visible to name
lookup so that we will correctly merge multiple declarations of that
type if they come from different modules.
Incidentally, to make this visible to name lookup we need to rename the
type to __NSConstantString, since the real NSConstantString is an
Objective-C interface type. This shouldn't affect anyone outside the
compiler since users of the constant string builtins cast the result
immediately to CFStringRef.
Since this struct type is otherwise implicitly created by the AST
context and cannot access namelookup, we make this a predefined type
and initialize it in Sema.
Note: this issue of builtins that refer to types not visible to name
lookup technically also affects other builtins (e.g. objc_msgSendSuper),
but in all other cases the builtin is a library builtin and the issue
goes away if you include the library that defines the types it uses,
unlike for these constant string builtins.
Richard Smith [Wed, 3 Feb 2016 02:58:20 +0000 (02:58 +0000)]
Fix miscompile and rejects-valids when disambiguating after an ambiguous
C-style-cast to function/array type or parenthesized function-style cast/array
indexing.
Richard Smith [Wed, 3 Feb 2016 01:43:59 +0000 (01:43 +0000)]
Fix typo in OpenCL type mangling. This is still bogus (we should either use the
actual source name of the typedef or a vendor mangling) but at least it stands
a chance of demangling now.
We would also benefit from some test coverage of this (OpenCL +
__attribute__((overloadable)) is probably required to reach this).
Richard Smith [Wed, 3 Feb 2016 01:32:42 +0000 (01:32 +0000)]
Fix Itanium RTTI emission so that we emit fundamental type information into the
C++ ABI library for the same set of types for which we expect the C++ ABI
library to provide the RTTI.
Specifically:
1) __int128 and unsigned __int128 are now emitted into the ABI library. We
always expected them to be there but never actually made sure to emit them.
2) Do not expect OpenCL builtin types to have type info in the C++ ABI library.
Neither libc++abi nor libstdc++ puts them there when built with either GCC
or Clang.
Richard Smith [Tue, 2 Feb 2016 23:58:56 +0000 (23:58 +0000)]
PR24989: Stop trying to use the C++11 rules for lambda return type inference in
C++14 generic lambdas. It conflicts with the C++14 return type deduction
mechanism, and results in us failing to actually deduce the lambda's return
type in some cases.
Richard Smith [Tue, 2 Feb 2016 23:11:49 +0000 (23:11 +0000)]
Work around build failure due to GCC 4.8.1 bug. We don't completely understand
the details of the bug, but avoiding overloading llvm::cast with another
function template sidesteps it.
See gcc.gnu.org/PR58022 for details of the bug, and llvm.org/PR26362 for more
backgound on how it manifested in Clang. Patch by Igor Sugak!
Artem Belevich [Tue, 2 Feb 2016 22:29:48 +0000 (22:29 +0000)]
[CUDA] Do not allow dynamic initialization of global device side variables.
In general CUDA does not allow dynamic initialization of
global device-side variables. One exception is that CUDA allows
records with empty constructors as described in section E2.2.1 of
CUDA 7.5 Programming guide.
This patch applies initializer checks for all device-side variables.
Empty constructors are accepted, but no code is generated for them.
Manman Ren [Tue, 2 Feb 2016 22:23:03 +0000 (22:23 +0000)]
ObjCXX: fix a crash during typo correction.
For ObjCXX, we can create a CastExpr with Kind being CK_UserDefinedConversion
and SubExpr being BlockExpr. Specifically one can return BlockExpr from
BuildCXXMemberCallExpr and the result can be used to build a CastExpr.
Fix the assumption in CastExpr::getSubExprAsWritten that SubExpr can only
be CXXMemberCallExpr.
Tim Northover [Tue, 2 Feb 2016 18:02:10 +0000 (18:02 +0000)]
ARM: allow both vfma and vfms intrinsics on v7.
The main purpose here is that vfma/vfms should be symmetric, and they are
supported on most v7 cores.
The new ArchGuard is suggested by ACLE but prophylactic for us. Almost all CPUs
with NEON *will* have vfma, and the few exceptions I know of (e.g. Cortex-A8)
are incorrectly modelled by Clang so can't trigger a test.
Fortunately, they're getting rarer. But if we ever do support them properly
arm_neon.h should now do the right thing.
Denis Zobnin [Tue, 2 Feb 2016 17:33:09 +0000 (17:33 +0000)]
PR23057: Fix assertion `Val && "isa<> used on a null pointer"' on invalid for-range expression.
Fix the issue discovered by fuzzing (PR23057, comment 18) by handling nullptr in Sema::ActOnCXXForRangeDecl
and correct delayed typos in for-range expression before calling Sema::ActOnCXXForRangeStmt. Also fixes PR26288.
Oliver Stannard [Tue, 2 Feb 2016 13:52:52 +0000 (13:52 +0000)]
Add backend dignostic printer for unsupported features
Re-commit of r258950 after fixing layering violation.
The related LLVM patch adds a backend diagnostic type for reporting
unsupported features, this adds a printer for them to clang.
In the case where debug location information is not available, I've
changed the printer to report the location as the first line of the
function, rather than the closing brace, as the latter does not give the
user any information. This also affects optimisation remarks.
[OpenCL] Eliminate warning when declaring OpenCL builtin functions.
OpenCL builtin functions are usually declared in header files.
Currently clang emits warning for OpenCL builtin functions
which have the same name as standard C library functions.
This commit eliminates such warnings by not adding the C standard
includes following the restriction from OpenCL v1.2 s6.9.f.
[OpenMP] Prevent nesting of target constructs within target code execution regions.
Summary:
This patch enhances Sema to check for the following restriction:
OpenMP 4.5 [2.17 Nesting of Regions]
If a target, target update, target data, target enter data, or
target exit data construct is encountered during execution of a
target region, the behavior is unspecified.
Nico Weber [Mon, 1 Feb 2016 22:31:51 +0000 (22:31 +0000)]
Always build a new TypeSourceInfo for function templates with parameters
RecursiveASTVisitor::TraverseFunctionHelper() traverses a function's
ParmVarDecls by going to the function's getTypeSourceInfo if it exists, and
`DEF_TRAVERSE_TYPELOC(FunctionProtoType` then goes to the function's
ParmVarDecls.
For a function template that doesn't have parameters that explicitly depend on
the template parameter, we used to be clever and not build a new
TypeSourceInfo. That meant that when an instantiation of such a template is
visited, its TypeSourceInfo would point to the ParmVarDecls of the template,
not of the instantiation, which then confused clients of RecursiveASTVisitor.
So don't be clever for function templates that have parameters, even if none of
the parameters depend on the type.
Reid Kleckner [Mon, 1 Feb 2016 18:58:24 +0000 (18:58 +0000)]
Fix attribute((mode([word|unwind_word]))) for x32
Patch by H.J. Lu
```
typedef unsigned int gcc_word __attribute__((mode(word)));
```
and
```
typedef unsigned int gcc_unwind_word __attribute__((mode(unwind_word)));
```
define the largest unsigned integer types which can be stored in a
general purpose register, which may not be the pointer type. For x32,
they aren't pointer nor unsigned long. We should
1. Make getUnwindWordWidth and getRegisterWidth virtual,
2. Override them for x32, similar to hasInt128Type.
3. Use getRegisterWidth for __attribute__((mode(word)));
[OpenMP] Prevent nesting of target constructs within target code execution regions.
Summary:
This patch enhances Sema to check for the following restriction:
OpenMP 4.5 [2.17 Nesting of Regions]
If a target, target update, target data, target enter data, or
target exit data construct is encountered during execution of a
target region, the behavior is unspecified.
Artem Dergachev [Mon, 1 Feb 2016 09:29:17 +0000 (09:29 +0000)]
[analyzer] Use a wider integer type for an array index.
Avoids unexpected overflows while performing pointer arithmetics in 64-bit code.
Moreover, neither PointerDiffType nor 'int' can be used as a common array index
type because arrays may have size (and indexes) more than PTRDIFF_MAX but less
than SIZE_MAX.
Craig Topper [Sun, 31 Jan 2016 04:20:03 +0000 (04:20 +0000)]
Replace usage of llvm::utostr_32 with just llvm::utostr. While this is less efficient, its unclear that the one place using the _32 version was doing so for efficiency.
This patch adds doxygen comments for the intrinsincs in the header file __wmmintrin_aes.h.
The doxygen comments are automatically generated based on Sony's intrinsics document.
Richard Trieu [Fri, 29 Jan 2016 23:51:16 +0000 (23:51 +0000)]
Improve -Wconstant-conversion
Switch the evaluation from isIntegerConstantExpr to EvaluateAsInt.
EvaluateAsInt will evaluate more types of expressions than
isIntegerConstantExpr.
Move one case from -Wsign-conversion to -Wconstant-conversion. The case is:
1) Source and target types are signed
2) Source type is wider than the target type
3) The source constant value is positive
4) The conversion will store the value as negative in the target.
Manman Ren [Fri, 29 Jan 2016 23:46:55 +0000 (23:46 +0000)]
Class Property: generate metadata for class properties in protocols.
The list of class properties is saved in
Old ABI: protocol->ext->class_properties (protocol->ext->size will be updated)
New ABI: protocol->class_properties (protocol->size will be updated)
Manman Ren [Fri, 29 Jan 2016 23:45:01 +0000 (23:45 +0000)]
Class Property: generate metadata for class properties in categories.
The list of class properties is saved in
Old ABI: category->class_properties (category->size will be updated as well)
New ABI: category->class_properties (a flag in objc_image_info to indicate
whether or not the list of class properties is present)
This patch adds doxygen comments for the intrinsincs in the header file __wmmintrin_pclmul.h. The doxygen comments are automatically generated based on Sony's intrinsics document.
- Include the position of the argument on which the nullability is violated
- Differentiate between a 'method' and a 'function' in the message wording
- Test for the error message text in the tests
- Fix a bug with setting 'IsDirectDereference' which resulted in regular dereferences assumed to have call context.
Nathan Wilson [Fri, 29 Jan 2016 04:43:59 +0000 (04:43 +0000)]
[Concepts] Implement a portion of Concepts TS[dcl.spec.concept]p5 and p6:
Diagnose if the return type of a function concept or declaration type of a
variable concept is not bool.
Justin Lebar [Thu, 28 Jan 2016 23:58:28 +0000 (23:58 +0000)]
[CUDA] Generate CUDA's printf alloca in its function's entry block.
Summary:
This is necessary to prevent llvm from generating stacksave intrinsics
around this alloca. NVVM doesn't have a stack, and we don't handle said
intrinsics.
Manman Ren [Thu, 28 Jan 2016 23:36:05 +0000 (23:36 +0000)]
Class Property: change PropertyMap to include isClassProperty.
PropertyMap used to map IdentifierInfo (name of the property) to
ObjcPropertyDecl *. Now that a class property can have the same name as
an instance property, we change PropertyMap to map a pair <IdentifierInfo *,
unsigned> to ObjcPropertyDecl *.
Also update a few places from iterating over instance_properties to
iterating over all properties.
Manman Ren [Thu, 28 Jan 2016 23:29:02 +0000 (23:29 +0000)]
Check for frontend errors after releasing the Builder.
Frontend can emit errors when releaseing the Builder. If there are errors before
or when releasing the Builder, we reset the module to stop here before invoking
the backend.
Before this commit, clang will continue to invoke the backend and backend can
crash.
Devin Coughlin [Thu, 28 Jan 2016 22:23:34 +0000 (22:23 +0000)]
[analyzer] Suppress nullability warnings in copy, mutableCopy, and init families.
There are multiple, common idioms of defensive nil-checks in copy,
mutableCopy, and init methods in ObjC. The analyzer doesn't currently have the
capability to distinguish these idioms from true positives, so suppress all
warnings about returns in those families. This is a pretty blunt suppression
that we should improve later.
Nico Weber [Thu, 28 Jan 2016 19:25:00 +0000 (19:25 +0000)]
Include RecordDecls from anonymous unions in the AST.
For
void f() {
union { int i; };
}
clang used to omit the RecordDecl from the anonymous union from the AST.
That's because the code creating it only called PushOnScopeChains(), which adds
it to the current DeclContext, which here is the function's DeclContext. But
RecursiveASTVisitor doesn't descent into all decls in a FunctionDecl.
Instead, for DeclContexts that contain statements, return the RecordDecl so
that it can be included in the DeclStmt containing the VarDecl for the union.
Interesting bits from the AST before this change:
|-FunctionDecl
| `-CompoundStmt
| |-DeclStmt
| | `-VarDecl 0x589cd60 <col:3> col:3 implicit used 'union (anonymous at test.cc:3:3)' callinit
After this change:
-FunctionDecl
| `-CompoundStmt
| |-DeclStmt
| | |-CXXRecordDecl 0x4612e48 <col:3, col:18> col:3 union definition
| | | |-FieldDecl 0x4612f70 <col:11, col:15> col:15 referenced i 'int'
| | `-VarDecl 0x4613010 <col:3> col:3 implicit used 'union (anonymous at test.cc:3:3)' callinit
This is now closer to how anonymous struct and unions are represented as
members of structs. It also enabled deleting some one-off code in the
template instantiation code.
Finally, it fixes a crash with ASTMatchers, see the included test case
(this fixes http://crbug.com/580749).
Manman Ren [Thu, 28 Jan 2016 18:49:28 +0000 (18:49 +0000)]
Class Property: class property and instance property can have the same name.
Add "enum ObjCPropertyQueryKind" to a few APIs that used to only take the name
of the property: ObjCPropertyDecl::findPropertyDecl,
ObjCContainerDecl::FindPropertyDeclaration,
ObjCInterfaceDecl::FindPropertyVisibleInPrimaryClass,
ObjCImplDecl::FindPropertyImplDecl, and Sema::ActOnPropertyImplDecl.
ObjCPropertyQueryKind currently has 3 values:
OBJC_PR_query_unknown, OBJC_PR_query_instance, OBJC_PR_query_class
This extra parameter specifies that we are looking for an instance property with
the given name, or a class property with the given name, or any property with
the given name (if both exist, the instance property will be returned).
1. Make test case more focused and robust by focusing on what to be tested (linkage, icall) -- make it easier to validate
2. Testing linkages of data and counter variables instead of names. Counters and data are more relavant to be tested.
Oliver Stannard [Thu, 28 Jan 2016 10:07:34 +0000 (10:07 +0000)]
Add backend dignostic printer for unsupported features
Re-commit of r258950 after fixing layering violation.
Add backend dignostic printer for unsupported features
The related LLVM patch adds a backend diagnostic type for reporting
unsupported features, this adds a printer for them to clang.
In the case where debug location information is not available, I've
changed the printer to report the location as the first line of the
function, rather than the closing brace, as the latter does not give the
user any information. This also affects optimisation remarks.