summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
* Extend format specifier checking to include field function pointers in ↵Aaron Ballman2015-04-231-3/+6
| | | | | | addition to variable function pointers. Addresses PR21082. llvm-svn: 235606
* Diagnose variadic main() as an extension; addresses PR17905.Aaron Ballman2015-04-231-0/+6
| | | | llvm-svn: 235605
* [OPENMP] Codegen for 'atomic capture'.Alexey Bataev2015-04-231-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds codegen for 'atomic capture' constructs with the following forms of expressions/statements: v = x binop= expr; v = x++; v = ++x; v = x--; v = --x; v = x = x binop expr; v = x = expr binop x; {v = x; x = binop= expr;} {v = x; x++;} {v = x; ++x;} {v = x; x--;} {v = x; --x;} {x = x binop expr; v = x;} {x binop= expr; v = x;} {x++; v = x;} {++x; v = x;} {x--; v = x;} {--x; v = x;} {x = x binop expr; v = x;} {x = expr binop x; v = x;} {v = x; x = expr;} If x and expr are integer and binop is associative or x is a LHS in a RHS of the assignment expression, and atomics are allowed for type of x on the target platform atomicrmw instruction is emitted. Otherwise compare-and-swap sequence is emitted. Update of 'v' is not required to be be atomic with respect to the read or write of the 'x'. bb: ... atomic load <x> cont: <expected> = phi [ <x>, label %bb ], [ <new_failed>, %cont ] <desired> = <expected> binop <expr> <res> = cmpxchg atomic &<x>, desired, expected <new_failed> = <res>.field1; br <res>field2, label %exit, label %cont exit: atomic store <old/new x>, <v> ... Differential Revision: http://reviews.llvm.org/D9049 llvm-svn: 235573
* [OPENMP] Codegen for 'private' clause in 'for' directive.Alexey Bataev2015-04-221-4/+4
| | | | | | | This patch generates helper variables which used as a private copies of the corresponding original variables inside an OpenMP 'for' directive. These generated variables are initialized by default (with the default constructor, if any). In OpenMP region references to original variables are replaced by the references to these private helper variables. Differential Revision: http://reviews.llvm.org/D9106 llvm-svn: 235503
* [OPENMP] Fix use of unsigned counters in loops with zero trip count.Alexey Bataev2015-04-221-6/+27
| | | | | | | | Patch fixes bugs in codegen for loops with unsigned counters and zero trip count. Previously preconditions for all loops were built using logic (Upper - Lower) > 0. But if the loop is a loop with zero trip count, then Upper - Lower is < 0 only for signed integer, for unsigned we're running into an underflow situation. In this patch we're using original Lower<Upper condition to check that loop body can be executed at least once. Also this allows to skip code generation for loops, if it is known that preconditions for the loop are always false. Differential Revision: http://reviews.llvm.org/D9103 llvm-svn: 235500
* Don't dllimport/export class members with internal linkage (PR23308)Hans Wennborg2015-04-221-0/+3
| | | | | | | | | | For example, a function taking a parameter with internal linkage will itself have internal linkage since it cannot be called outside the translation unit. Differential Revision: http://reviews.llvm.org/D9182 llvm-svn: 235471
* Wrap to 80 columns, fix typo in comment. No behavior change.Nico Weber2015-04-221-2/+3
| | | | llvm-svn: 235470
* [cuda] Allow using integral non-type template parameters as launch_bounds ↵Artem Belevich2015-04-212-10/+85
| | | | | | | | | | | | | | | | attribute arguments. - Changed CUDALaunchBounds arguments from integers to Expr* so they can be saved in AST for instantiation. - Added support for template instantiation of launch_bounds attrubute. - Moved evaluation of launch_bounds arguments to NVPTXTargetCodeGenInfo:: SetTargetAttributes() where it can be done after template instantiation. - Added a warning on negative launch_bounds arguments. - Amended test cases. Differential Revision: http://reviews.llvm.org/D8985 llvm-svn: 235452
* [Sema] Check availability of ObjC super class and protocols of a containerArgyrios Kyrtzidis2015-04-191-4/+29
| | | | | | | | | | | in the context of the container itself. Otherwise we will emit 'unavailable' errors when referencing an unavailable super class even though the subclass is also marked 'unavailable'. rdar://20598702 llvm-svn: 235276
* [Sema] Don't crash if array bound calculation overflowed constexpr arrayDavid Majnemer2015-04-181-0/+2
| | | | | | | | | We didn't correctly expect a QualifiedTypeLoc when faced with fixing a variable array type into a constant array type. Differential Revision: http://reviews.llvm.org/D8958 llvm-svn: 235251
* Move fixit for const init from note to diag, weaken to warning in MS mode.Nico Weber2015-04-171-23/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r235046 turned "extern __declspec(selectany) int a;" from a declaration into a definition to fix PR23242 (required for compatibility with mc.exe output). However, this broke parsing Windows headers: A d3d11 headers contain something like struct SomeStruct {}; extern const __declspec(selectany) SomeStruct some_struct; This is now a definition, and const objects either need an explicit default ctor or an initializer so this errors out with d3d11.h(1065,48) : error: default initialization of an object of const type 'const CD3D11_DEFAULT' without a user-provided default constructor (cl.exe just doesn't implement this rule, independent of selectany.) To work around this, weaken this error into a warning for selectany decls in microsoft mode, and recover with zero-initialization. Doing this is a bit hairy since it adds a fixit on an error emitted by InitializationSequence – this means it needs to build a correct AST, which in turn means InitializationSequence::Failed() cannot return true when this fixit is applied. As a workaround, the patch adds a fixit member to InitializationSequence, and InitializationSequence::Perform() prints the diagnostic if the fixit member is set right after its call to Diagnose. That function is usually called when InitializationSequences are used – InitListChecker::PerformEmptyInit() doesn't call it, but the InitListChecker case never performs default-initialization, so this is technically OK. This is the alternative, original fix for PR20208 that got reviewed in the thread "[patch] Improve diagnostic on default-initializing const variables (PR20208)". This change basically reverts r213725, adds the original fix for PR20208, and makes the error a warning in Microsoft mode. llvm-svn: 235166
* [Objective-C Sema] patch to introduce IndependentClassFariborz Jahanian2015-04-162-2/+22
| | | | | | | | | attribute to be placed on Objective-C pointer typedef to make them strong enough so on their "new" method family no attempt is made to override these types. rdar://20255473 llvm-svn: 235128
* [OPENMP] Fix for checking of data-sharing attributes for canonical var decls ↵Alexey Bataev2015-04-161-1/+10
| | | | | | | | | | | only. Currently checks for active data-sharing attributes for variables are performed for found var decls. Instead these checks must be performed for canonical decls of these variables to avoid possible troubles with with the differently qualified re-declarations of the same variable, for example: namespace A { int x; } namespace B { using A::x; } Both A::x and B::x actually reference the same object A::x and this fact must be taken into account during data-sharing attributes analysis. llvm-svn: 235096
* [OPENMP] Codegen for 'copyin' clause in 'parallel' directive.Alexey Bataev2015-04-161-26/+40
| | | | | | | | | | | | | | | Emits the following code for the clause at the beginning of the outlined function for implicit threads: if (<not a master thread>) { ... <thread local copy of var> = <master thread local copy of var>; ... } <sync point>; Checking for a non-master thread is performed by comparing of the address of the thread local variable with the address of the master's variable. Master thread always uses original variables, so you always know the address of the variable in the master thread. Differential Revision: http://reviews.llvm.org/D9026 llvm-svn: 235075
* [OPENMP] Codegen for 'lastprivate' clause in 'for' directive.Alexey Bataev2015-04-161-84/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | #pragma omp for lastprivate(<var>) for (i = a; i < b; ++b) <BODY>; This construct is translated into something like: <last_iter> = alloca i32 <lastprivate_var> = alloca <type> <last_iter> = 0 ; No initializer for simple variables or a default constructor is called for objects. ; For arrays perform element by element initialization by the call of the default constructor. ... OMP_FOR_START(...,<last_iter>, ..); sets <last_iter> to 1 if this is the last iteration. <BODY> ... OMP_FOR_END if (<last_iter> != 0) { <var> = <lastprivate_var> ; Update original variable with the lastprivate value. } call __kmpc_cancel_barrier() ; an implicit barrier to avoid possible data race. Differential Revision: http://reviews.llvm.org/D8658 llvm-svn: 235074
* Create a frontend flag to disable CUDA cross-target call checksEli Bendersky2015-04-151-0/+5
| | | | | | | | | | | | | | | For CUDA source, Sema checks that the targets of call expressions make sense (e.g. a host function can't call a device function). Adding a flag that lets us skip this check. Motivation: for source-to-source translation tools that have to accept code that's not strictly kosher CUDA but is still accepted by nvcc. The source-to-source translation tool can then fix the code and leave calls that are semantically valid for the actual compilation stage. Differential Revision: http://reviews.llvm.org/D9036 llvm-svn: 235049
* [Objective-C Sema]This patch fixes the warning when clang issuesFariborz Jahanian2015-04-154-38/+51
| | | | | | | | | | "multiple methods named '<selector>' found" warning by noting the method that is actualy used. It also cleans up and refactors code in this area and selects a method that matches actual arguments in case of receiver being a forward class object. rdar://19265430 llvm-svn: 235023
* [OPENMP] Codegen for 'firstprivate' clause in 'for' directive.Alexey Bataev2015-04-151-22/+22
| | | | | | | | Adds proper codegen for 'firstprivate' clause in for directive. Initially codegen for 'firstprivate' clause was implemented for 'parallel' directive only. Also this patch emits sync point only after initialization of firstprivate variables, not all private variables. This sync point is not required for privates, lastprivates etc., only for initialization of firstprivate variables. Differential Revision: http://reviews.llvm.org/D8660 llvm-svn: 234978
* Use concrete type instead of auto in for-loop. No functionality change.Richard Trieu2015-04-151-1/+1
| | | | llvm-svn: 234976
* Change range-based for-loops to be -Wrange-loop-analysis clean.Richard Trieu2015-04-152-2/+2
| | | | | | No functionality change. llvm-svn: 234964
* Move the logic to avoid double global emission from Sema to CodeGenReid Kleckner2015-04-151-14/+7
| | | | | | | | | | | Reverts the code changes from r234675 but keeps the test case. We were already maintaining a DenseMap of globals with dynamic initializers anyway. Fixes the test case from PR23234. llvm-svn: 234961
* [SemaCXX patch] Patch to fix a crash when a 'delete' constructorFariborz Jahanian2015-04-141-4/+5
| | | | | | | is being accessed. Reviewed by Richard Smith. rdar://20281011 llvm-svn: 234912
* Remove useless statement.Nikola Smiljanic2015-04-141-1/+0
| | | | llvm-svn: 234881
* [OPENMP] Fixed codegen for arrays in 'copyprivate' clause.Alexey Bataev2015-04-141-8/+9
| | | | | | | Fixed a bug with codegen of variables with array types specified in 'copyprivate' clause of 'single' directive. Differential Revision: http://reviews.llvm.org/D8914 llvm-svn: 234856
* [OPENMP] Initial codegen for 'parallel sections' directive.Alexey Bataev2015-04-141-0/+4
| | | | | | | | | | | | | | | Emits code for outlined 'parallel' directive with the implicitly inlined 'sections' directive: ... call __kmpc_fork_call(..., outlined_function, ...); ... define internal void outlined_function(...) { <code for implicit sections directive>; } Differential Revision: http://reviews.llvm.org/D8997 llvm-svn: 234849
* Add new warning -Wrange-loop-analysis to warn on copies during loops.Richard Trieu2015-04-131-0/+152
| | | | | | | | | | | | -Wrange-loop-analysis is a subgroup of -Wloop-analysis and will warn when a range-based for-loop makes copies of the elements in the range. If possible, suggest the proper type to prevent copies, or the non-reference to help distinguish copy versus non-copy forms. Existing warnings in -Wloop-analysis are moved to -Wfor-loop-analysis, also a subgroup of -Wloop-analysis. Differential Revision: http://reviews.llvm.org/D4169 llvm-svn: 234804
* Use 'override/final' instead of 'virtual' for overridden methodsAlexander Kornienko2015-04-112-16/+12
| | | | | | | | | | | | | | | | | | | | Summary: The patch is generated using clang-tidy misc-use-override check. This command was used: tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py \ -checks='-*,misc-use-override' -header-filter='llvm|clang' -j=32 -fix Reviewers: dblaikie Reviewed By: dblaikie Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D8926 llvm-svn: 234678
* Improve the error message for assigning to read-only variables.Richard Trieu2015-04-111-3/+141
| | | | | | | | | | Previously, many error messages would simply be "read-only variable is not assignable" This change provides more information about why the variable is not assignable, as well as note to where the const is located. Differential Revision: http://reviews.llvm.org/D4479 llvm-svn: 234677
* Only notify consumers about static data members of class templates onceReid Kleckner2015-04-111-7/+14
| | | | llvm-svn: 234675
* [Objective-C Sema] Fixes a typo which did not allow Fariborz Jahanian2015-04-101-1/+1
| | | | | | | bridge casting to super class of object's bridge type. rdar://18311183 llvm-svn: 234652
* Reduce dyn_cast<> to isa<> or cast<> where possible. Clang edition.Benjamin Kramer2015-04-102-6/+4
| | | | | | No functional change intended. llvm-svn: 234587
* [OPENMP] Codegen for 'reduction' clause in 'parallel' directive.Alexey Bataev2015-04-101-66/+201
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Emit a code for reduction clause. Next code should be emitted for reductions: static kmp_critical_name lock = { 0 }; void reduce_func(void *lhs[<n>], void *rhs[<n>]) { ... *(Type<i> *)lhs[i] = RedOp<i>(*(Type<i> *)lhs[i], *(Type<i> *)rhs[i]); ... } ... void *RedList[<n>] = {&<RHSExprs>[0], ..., &<RHSExprs>[<n> - 1]}; switch (__kmpc_reduce{_nowait}(<loc>, <gtid>, <n>, sizeof(RedList), RedList, reduce_func, &<lock>)) { case 1: ... <LHSExprs>[i] = RedOp<i>(*<LHSExprs>[i], *<RHSExprs>[i]); ... __kmpc_end_reduce{_nowait}(<loc>, <gtid>, &<lock>); break; case 2: ... Atomic(<LHSExprs>[i] = RedOp<i>(*<LHSExprs>[i], *<RHSExprs>[i])); ... break; default: ; } Reduction variables are a kind of a private variables, they have private copies, but initial values are chosen in accordance with the reduction operation. Differential Revision: http://reviews.llvm.org/D8915 llvm-svn: 234583
* [Sema] Don't assume that an initializer list has an initializerDavid Majnemer2015-04-101-3/+3
| | | | | | | | Given something like 'int({}, 1)', we would try to emit a diagnostic regarding the excess element in the scalar initializer. However, we assumed that the initializer list had an element in it. llvm-svn: 234565
* Add Clang support for remaining integer divide and permute instructions from ↵Nemanja Ivanovic2015-04-091-0/+22
| | | | | | | | | | | ISA 2.06 This patch corresponds to review: http://reviews.llvm.org/D8398 It adds some builtin functions to access the extended divide and bit permute instructions. llvm-svn: 234547
* [Objective-C Sema] It is permissable to bridge cast to 'id'Fariborz Jahanian2015-04-091-5/+6
| | | | | | | of a CFType bridged to some unknown Objective-C type. rdar://20113785 llvm-svn: 234545
* [Sema] Diagnose references to unbound arrays in function definitionsDavid Majnemer2015-04-091-0/+4
| | | | | | | | A [*] is only allowed in a declaration for a function, not in its definition. We didn't correctly recurse on reference types while looking for it, causing us to crash in CodeGen instead of rejecting it. llvm-svn: 234528
* Properly implement warn_unused_result checking for classes/structs.Kaelyn Takata2015-04-092-15/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous implementation would copy the attribute from the class to functions that have the class as their return type when the functions are first declared. This proved to have two flaws: 1) if the class is forward-declared without the attribute and a function or method with the class as a its return type is declared, and afterward the class is defined with warn_unused_result, the function or method would never inherit the attribute, and 2) the check simply failed for functions and methods that are part of a template instantiation, regardless of whether the class with warn_unused_result is part of a specific instantiation or part of the template itself (presumably because those function/method declaration does not hit the same code path as a non-template one and so never inherits the attribute). The new approach is to instead modify the two places where a function or method call is checked for the warn_unused_result attribute on the decl by extending the checks to also look for the attribute on the decl's return type. Additionally, the check for return types that have the warn_unused_result now excludes pointers and references to such types, as such return types do not necessarily imply a transfer of ownership for the underlying object being referred to by the return value. This does not change the behavior of functions that are directly given the warn_unused_result attribute. llvm-svn: 234526
* [Objective-C Sema] Use canonical type of properties when comparing Fariborz Jahanian2015-04-081-3/+5
| | | | | | | redeclaration of property in class extension and to avoid bogus error. rdar://20469452 llvm-svn: 234440
* [OPENMP] Allow redeclaration of variables as threadprivate.Alexey Bataev2015-04-081-1/+1
| | | | | | No need to emit an error message if the variable is redeclared as threadprivate. llvm-svn: 234402
* Appease build bots that cannot find a viable conversion through CanQualType.Aaron Ballman2015-04-081-1/+2
| | | | llvm-svn: 234376
* Generate a diagnostic when a catch handler cannot execute due to class ↵Aaron Ballman2015-04-081-57/+153
| | | | | | hierarchy inversion with regards to other catch handlers for the same block. llvm-svn: 234375
* Use the most recent previous decl to check if inline is added after a definitionReid Kleckner2015-04-081-1/+2
| | | | | | | | | | | | | | | | | | | | | | | This affects this test case: void foo(); template <typename T> class C { friend inline void foo(); }; inline void foo() {} C<int> c; Here, we instantiate the foo friend decl and add it to foo's redecl chain. However, our previous decl pointer happens to reference the first declaration of foo, which is not marked inline. When we check to see if foo was already defined, we implicitly search all previous decls. We should do the same for the inline check, instead of just checking this particular previous decl. Reviewers: rsmith Differential Revision: http://reviews.llvm.org/D8872 llvm-svn: 234374
* [Sema] Correctly recurse when looking for [*] in function definitionsDavid Majnemer2015-04-071-9/+28
| | | | | | | | | | A [*] is only allowed in a declaration for a function, not in its definition. We didn't correctly recurse while looking for it, causing us to crash in CodeGen instead of rejecting it. This fixes PR23151. llvm-svn: 234363
* Revert "Mark instantiated function decls as inline specified if any pattern is"Reid Kleckner2015-04-071-15/+5
| | | | | | | | | | | | | | | | | | | It breaks down on this test case: void foo(); template <typename T> class C { friend void foo(); }; inline void foo() {} C<int> c; We shouldn't be marking the instantiation of the friend decl of foo as inline-specified. It may be possible to fix this by determining if the full definition is part of the current template, but it seems better to rever tot green until we come up with a full solution. This reverts commit r233817, as well as follow-ups r233820 and r233821. llvm-svn: 234355
* [Objective-C Sema] Patch to not issue unavailbility/deprecatedFariborz Jahanian2015-04-071-1/+7
| | | | | | | | warning when multiple method declarations are found in global pool with differing types and some are available. rdar://20408445 llvm-svn: 234328
* [Sema] Don't crash when __attribute__((nonnull)) is applied to blocksDavid Majnemer2015-04-071-2/+7
| | | | | | | | | A simple case of asserting isFunctionOrMethod when we should have asserted isFunctionOrMethodOrBlock. This fixes PR23117. llvm-svn: 234297
* [Sema] Don't permit dependent alignments on non-dependent typedef-namesDavid Majnemer2015-04-071-0/+10
| | | | | | | | | | | | | | | | | A dependent alignment attribute (like __attribute__((aligned(...))) or __declspec(align(...))) on a non-dependent typedef or using declaration poses a considerable challenge: the type is _not_ dependent, the size _may_ be dependent if the type is used as an array type, the alignment _is_ dependent. It is reasonable for a compiler to be able to query the size and alignment of a complete type. Let's help that become an invariant. This fixes PR22042. Differential Revision: http://reviews.llvm.org/D8693 llvm-svn: 234280
* [Objective-C patch] Patch to fix a crash in IRGen because Fariborz Jahanian2015-04-061-1/+9
| | | | | | | | of incorrect AST when a compound literal of Objective-C property access is used to initialize a vertor of floats. rdar://20407999 llvm-svn: 234176
* [OPENMP] Fix crash on private variables not used in OpenMP region in templates.Alexey Bataev2015-04-022-2/+11
| | | | llvm-svn: 233913
* [OPENMP] Fix crash on private variables not used in OpenMP region.Alexey Bataev2015-04-021-0/+20
| | | | llvm-svn: 233902
OpenPOWER on IntegriCloud