summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
...
* Add __sync_fetch_and_nand (again)Hal Finkel2014-10-021-10/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to GCC 4.4, __sync_fetch_and_nand was implemented as: { tmp = *ptr; *ptr = ~tmp & value; return tmp; } but this was changed in GCC 4.4 to be: { tmp = *ptr; *ptr = ~(tmp & value); return tmp; } in response to this change, support for sync_fetch_and_nand (and sync_nand_and_fetch) was removed in r99522 in order to avoid miscompiling code depending on the old semantics. However, at this point: 1. Many years have passed, and the amount of code relying on the old semantics is likely smaller. 2. Through the work of many contributors, all LLVM backends have been updated such that "atomicrmw nand" provides the newer GCC 4.4+ semantics (this process was complete July of 2014 (added to the release notes in r212635). 3. The lack of this intrinsic is now a needless impediment to porting codes from GCC to Clang (I've now seen several examples of this). It is true, however, that we still set GNUC_MINOR to 2 (corresponding to GCC 4.2). To compensate for this, and to address the original concern regarding code relying on the old semantics, I've added a warning that specifically details the fact that the semantics have changed and that we provide the newer semantics. Fixes PR8842. llvm-svn: 218905
* c++ error recovery. Build a valid AST when tryingFariborz Jahanian2014-10-011-1/+3
| | | | | | | | | to recover from parse error parsing the default argument. Patch prevents crash after spewing 100s of errors caused by someone who forgot to compile in c++11 mode. So no test. rdar://18508589 llvm-svn: 218780
* Adds 'override' to overriding methods. NFC.Fariborz Jahanian2014-10-011-1/+1
| | | | | | These were uncoveredby my yet undelivered patch. llvm-svn: 218774
* [OPENMP] Loop collapsing and codegen for 'omp simd' directive.Alexander Musman2014-10-011-49/+527
| | | | | | | | | | | | | This patch implements collapsing of the loops (in particular, in presense of clause 'collapse'). It calculates number of iterations N and expressions nesessary to calculate the nested loops counters values based on new iteration variable (that goes from 0 to N-1) in Sema. It also adds Codegen for 'omp simd', which uses (and tests) this feature. Differential Revision: http://reviews.llvm.org/D5184 llvm-svn: 218743
* Improve -Wuninitialized warnings for fields that are record types.Richard Trieu2014-10-011-31/+59
| | | | | | | Get the record handling code from SelfReferenceChecker into UninitializedFieldVisitor as well as copying the testcases. llvm-svn: 218740
* Update -Wuninitialized to be stricter on CK_NoOp casts.Richard Trieu2014-09-301-5/+10
| | | | llvm-svn: 218715
* Avoid a crash after loading an #undef'd macro in code completionBen Langmuir2014-09-301-1/+2
| | | | | | | | | | | In code-completion, don't assume there is a MacroInfo for everything, since we aren't serializing the def corresponding to a later #undef in the same module. Also setup the HadMacro bit correctly for undefs to avoid an assertion failure. rdar://18416901 llvm-svn: 218694
* CUDA: mark the target of implicit intrinsics properlyEli Bendersky2014-09-301-0/+6
| | | | | | | | | | | | | r218624 implemented target inference for implicit special members. However, other entities can be implicit - for example intrinsics. These can not have inference running on them, so they should be marked host device as before. This is the safest and most flexible setting, since by construction these functions don't invoke anything, and we'd like them to be invokable from both host and device code. LLVM's intrinsics definitions (where these intrinsics come from in the case of CUDA/NVPTX) have no notion of target, so both host and device intrinsics can be supported this way. llvm-svn: 218688
* [OPENMP] Codegen of the ‘aligned’ clause for the ‘omp simd’ directive.Alexander Musman2014-09-301-0/+5
| | | | | | Differential Revision: http://reviews.llvm.org/D5499 llvm-svn: 218660
* Don't trap when passing non-POD arguments to variadic functions in ↵Hans Wennborg2014-09-292-0/+5
| | | | | | | | | | | | | | | | | | MS-compatibility mode Clang warns (treated as error by default, but still ignored in system headers) when passing non-POD arguments to variadic functions, and generates a trap instruction to crash the program if that code is ever run. Unfortunately, MSVC happily generates code for such calls without a warning, and there is code in system headers that use it. This makes Clang not insert the trap instruction when in -fms-compatibility mode, while still generating the warning/error message. Differential Revision: http://reviews.llvm.org/D5492 llvm-svn: 218640
* CUDA: Fix incorrect target inference for implicit members.Eli Bendersky2014-09-293-11/+274
| | | | | | | | | | | | As PR20495 demonstrates, Clang currenlty infers the CUDA target (host/device, etc) for implicit members (constructors, etc.) incorrectly. This causes errors and even assertions in Clang when compiling code (assertions in C++11 mode where implicit move constructors are added into the mix). Fix the problem by inferring the target from the methods the implicit member should call (depending on its base classes and fields). llvm-svn: 218624
* Fix "unsupported friend" diagnostic to also appear for friend functions with ↵Richard Smith2014-09-291-1/+5
| | | | | | dependent scopes. llvm-svn: 218590
* Add back checking for condition of conditional operator for -WuninitializedRichard Trieu2014-09-261-0/+1
| | | | llvm-svn: 218556
* Support the assume_aligned function attributeHal Finkel2014-09-263-9/+106
| | | | | | | | | In addition to __builtin_assume_aligned, GCC also supports an assume_aligned attribute which specifies the alignment (and optional offset) of a function's return value. Here we implement support for the assume_aligned attribute by making use of the @llvm.assume intrinsic. llvm-svn: 218500
* -ms-extensions: Implement __super scope specifier (PR13236).Nikola Smiljanic2014-09-268-3/+95
| | | | | | | | | We build a NestedNameSpecifier that records the CXXRecordDecl in which __super appeared. Name lookup is performed in all base classes of the recorded CXXRecordDecl. Use of __super is allowed only inside class and member function scope. llvm-svn: 218484
* Fix PR20886 - enforce CUDA target match in method callsEli Bendersky2014-09-251-0/+21
| | | | | | http://reviews.llvm.org/D5298 llvm-svn: 218482
* Move calls to ResolveExceptionSpec out of SetDeclDefaulted and into ↵Ben Langmuir2014-09-251-5/+30
| | | | | | | | | DefineImplicit* This fixes an assertion failure in CodeGen where we were not resolving an exception specification. llvm-svn: 218466
* Add increment/decrement operators and compound assignment operators to theRichard Trieu2014-09-252-0/+27
| | | | | | uninitialized checkers that did not have them before. llvm-svn: 218435
* Sema: Inherit the flexible array property from struct fieldsDavid Majnemer2014-09-241-9/+6
| | | | | | | | A record which contains a flexible array member is itself a flexible array member. A struct which contains such a record should also consider itself to be a flexible array member. llvm-svn: 218378
* Fix the argument index error of __builtin___memccpy_chkSteven Wu2014-09-241-1/+3
| | | | | | | memccpy_check should have source and dest size at arg 3 and 4 rdar://18431336 llvm-svn: 218367
* Fix an edge case with BinaryOperator's in -Wuninitialized. Add testcases forRichard Trieu2014-09-241-2/+4
| | | | | | the other visitors as well. llvm-svn: 218366
* Improve -Wuninitialized to take into account field ordering with initializerRichard Trieu2014-09-231-1/+87
| | | | | | | lists. Since the fields are inititalized one at a time, using a field with lower index to initialize a higher indexed field should not be warned on. llvm-svn: 218339
* Don't perform ADL when looking up operator=; there is no non-member form ofRichard Smith2014-09-232-5/+8
| | | | | | | | | that function, and apart from being slow, this is unnecessary: ADL can trigger instantiations that are not permitted here. The standard isn't *completely* clear here, but this seems like the intent, and in any case this approach is permitted by [temp.inst]p7. llvm-svn: 218330
* [OPENMP] Parsing/Sema of directive omp parallel for simdAlexander Musman2014-09-232-0/+88
| | | | llvm-svn: 218299
* Return true from UnifySection when emitting a diagnosticEhsan Akhgari2014-09-221-1/+1
| | | | | | | | | | | | Test Plan: I noticed this through code inspection. The callers use the return value to remove the SectionAttr if a diagnostic is emitted, but I don't think the failure to do so is observable right now. Reviewers: rnk Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5438 llvm-svn: 218265
* ms-inline-asm: Scope inline asm labels to functionsEhsan Akhgari2014-09-225-7/+62
| | | | | | | | | | | | | | | | Summary: This fixes PR20023. In order to implement this scoping rule, we piggy back on the existing LabelDecl machinery, by creating LabelDecl's that will carry the "internal" name of the inline assembly label, which we will rewrite the asm label to. Reviewers: rnk Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4589 llvm-svn: 218230
* Follow-up to r214408: Warn on other callee-cleanup functions without ↵Nico Weber2014-09-191-5/+9
| | | | | | | | | | | | | | | | | | prototype too. According to lore, we used to verifier-fail on: void __thiscall f(); int main() { f(1); } So that's fixed now. System headers use prototype-less __stdcall functions, so make that a warning that's DefaultError -- then it fires on regular code but is suppressed in system headers. Since it's used in system headers, we have codegen tests for this; massage them slightly so that they still compile. llvm-svn: 218166
* [OPENMP] Initial parsing/sema analysis of 'target' directive.Alexey Bataev2014-09-192-0/+87
| | | | llvm-svn: 218110
* Thread Safety Analysis: add new warning flag, -Wthread-safety-reference, whichDeLesley Hutchins2014-09-181-1/+34
| | | | | | | | warns when a guarded variable is passed by reference as a function argument. This is released as a separate warning flag, because it could potentially break existing code that uses thread safety analysis. llvm-svn: 218087
* [X86, inlineasm] Check that the output size is correct for the given constraint.Akira Hatanaka2014-09-181-0/+14
| | | | llvm-svn: 218064
* Patch to check at compile time for overflow whenFariborz Jahanian2014-09-182-3/+50
| | | | | | | | __builtin___memcpy_chk and similar builtins are being used. Patch by Jacques Fortier (with added clang tests). rdar://11076881 llvm-svn: 218063
* Revert r217995 and follow-ups:Hans Wennborg2014-09-186-252/+191
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r218053: Use exceptions() instead of getNumExceptions()/getExceptionType() to avoid r218011: Work around MSVC parser bug by putting redundant braces around the body of r217997: Skip parens when detecting whether we're instantiating a function declaration. r217995: Instantiate exception specifications when instantiating function types (other The Windows build was broken for 16 hours and no one had any good ideas of how to fix it. Reverting for now to make the builders green. See the cfe-commits thread [1] for more info. This was the build error (from [2]): C:\bb-win7\ninja-clang-i686-msc17-R\llvm-project\clang\lib\Sema\SemaTemplateInstantiate.cpp(1590) : error C2668: '`anonymous-namespace'::TemplateInstantiator::TransformFunctionProtoType' : ambiguous call to overloaded function C:\bb-win7\ninja-clang-i686-msc17-R\llvm-project\clang\lib\Sema\SemaTemplateInstantiate.cpp(1313): could be 'clang::QualType `anonymous-namespace'::TemplateInstantiator::TransformFunctionProtoType<clang::Sema::SubstFunctionDeclType::<lambda_756edcbe7bd5c7584849a6e3a1491735>>(clang::TypeLocBuilder &,clang::FunctionProtoTypeLoc,clang::CXXRecordDecl *,unsigned int,Fn)' with [ Fn=clang::Sema::SubstFunctionDeclType::<lambda_756edcbe7bd5c7584849a6e3a1491735> ] c:\bb-win7\ninja-clang-i686-msc17-r\llvm-project\clang\lib\sema\TreeTransform.h(4532): or 'clang::QualType clang::TreeTransform<Derived>::TransformFunctionProtoType<clang::Sema::SubstFunctionDeclType::<lambda_756edcbe7bd5c7584849a6e3a1491735>>(clang::TypeLocBuilder &,clang::FunctionProtoTypeLoc,clang::CXXRecordDecl *,unsigned int,Fn)' with [ Derived=`anonymous-namespace'::TemplateInstantiator, Fn=clang::Sema::SubstFunctionDeclType::<lambda_756edcbe7bd5c7584849a6e3a1491735> ] while trying to match the argument list '(clang::TypeLocBuilder, clang::FunctionProtoTypeLoc, clang::CXXRecordDecl *, unsigned int, clang::Sema::SubstFunctionDeclType::<lambda_756edcbe7bd5c7584849a6e3a1491735>)' 1. http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20140915/115011.html 2. http://bb.pgr.jp/builders/ninja-clang-i686-msc17-R/builds/10515/steps/build_clang_tools_1/logs/stdio llvm-svn: 218058
* Parsing/Sema of directive omp for simdAlexander Musman2014-09-182-6/+75
| | | | llvm-svn: 218029
* Sema: Diagnose undefined structs used as Microsoft anonymous structsDavid Majnemer2014-09-181-5/+11
| | | | | | | | | | | | | | | Previously, we would not mark structs containing anonymous structs as invalid. Later, horrific things would occur when trying to determine the size of the parent record. Instead, require the struct to be a complete type when used as an anonymous struct. Mark both the anonymous field for the struct and the parent context as invalid (this is similar to what we do when a struct contains a field with an incomplete type.) This fixes PR11847. llvm-svn: 218006
* Skip parens when detecting whether we're instantiating a function declaration.Richard Smith2014-09-181-2/+2
| | | | llvm-svn: 217997
* Instantiate exception specifications when instantiating function types (otherRichard Smith2014-09-176-190/+251
| | | | | | | | | | than the type of a function declaration). We previously didn't instantiate these at all! This also covers the pathological case where the only mention of a parameter pack is within the exception specification; this gives us a second way (other than alias templates) to reach the horrible state where a type contains an unexpanded pack, but its canonical type does not. llvm-svn: 217995
* Don't try to devirtualize non-virtual callsReid Kleckner2014-09-161-0/+4
| | | | | | | | | | | We would end up marking the vtable of the derived class as used for no reason. Because the call itself is qualified, it is never virtual, and the vtable of the derived class isn't helpful. We would end up rejecting code that MSVC accepts for no benefit. See http://crbug.com/413478 llvm-svn: 217910
* Objective-C. Prevents a crash generating AST for aFariborz Jahanian2014-09-151-0/+4
| | | | | | | | | a property assignment due to numerous user errors. Cannot come up with a reasonable test case due to array of user errors before the crash point. rdar://17813651. llvm-svn: 217825
* Check delegating constructors for using uninitialized fields.Richard Trieu2014-09-121-0/+2
| | | | llvm-svn: 217716
* patch to add missing warning on sizeof wrong parameterFariborz Jahanian2014-09-121-1/+2
| | | | | | | | for __builtin___strlcpy_chk/__builtin___strlcat_chk. Patch by Jacques Fortier with monir change by me and addition of test. rdar://18259539 llvm-svn: 217700
* Objective-C. Under a special flag, -Wcstring-format-directive,Fariborz Jahanian2014-09-112-31/+64
| | | | | | | | | off by default, issue a warning if %s directive is used in formart argument of a function/method declared as __attribute__((format(CF/NSString, ...))) To complete rdar://18182443 llvm-svn: 217619
* Objective-C. Accept 'nil' as indexing argument toFariborz Jahanian2014-09-101-1/+2
| | | | | | | dictionary literals since the API which implements them accepts it too. // rdar://18254621 llvm-svn: 217543
* Objective-C arc. Fixes a crash when issuing diagnostic forFariborz Jahanian2014-09-101-1/+1
| | | | | | passing parameter to an audited CF API. rdar://18222007 llvm-svn: 217530
* Objective-C. Under a special flag, -Wcstring-format-directive,Fariborz Jahanian2014-09-092-1/+78
| | | | | | | | off by default, issue a warning if %s directive is used in certain CF/NS formatting APIs, to assist user in deprecating use of such %s in these APIs. rdar://18182443 llvm-svn: 217467
* Allow empty statements in naked functions in addition to ASM statementsEhsan Akhgari2014-09-091-1/+1
| | | | | | | | | | | | Summary: This fixes PR20883. Test Plan: The patch includes an automated test. Reviewers: hansw Differential Revision: http://reviews.llvm.org/D5256 llvm-svn: 217413
* Add __builtin_assume and __builtin_assume_aligned using @llvm.assume.Hal Finkel2014-09-072-2/+46
| | | | | | | | | | | This makes use of the recently-added @llvm.assume intrinsic to implement a __builtin_assume(bool) intrinsic (to provide additional information to the optimizer). This hooks up __assume in MS-compatibility mode to mirror __builtin_assume (the semantics have been intentionally kept compatible), and implements GCC's __builtin_assume_aligned as assume((p - o) & mask == 0). LLVM now contains special logic to deal with assumptions of this form. llvm-svn: 217349
* Add -Wunused-local-typedef, a warning that finds unused local typedefs.Nico Weber2014-09-068-6/+115
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The warning warns on TypedefNameDecls -- typedefs and C++11 using aliases -- that are !isReferenced(). Since the isReferenced() bit on TypedefNameDecls wasn't used for anything before this warning it wasn't always set correctly, so this patch also adds a few missing MarkAnyDeclReferenced() calls in various places for TypedefNameDecls. This is made a bit complicated due to local typedefs possibly being used only after their local scope has closed. Consider: template <class T> void template_fun(T t) { typename T::Foo s3foo; // YYY (void)s3foo; } void template_fun_user() { struct Local { typedef int Foo; // XXX } p; template_fun(p); } Here the typedef in XXX is only used at end-of-translation unit, when YYY in template_fun() gets instantiated. To handle this, typedefs that are unused when their scope exits are added to a set of potentially unused typedefs, and that set gets checked at end-of-TU. Typedefs that are still unused at that point then get warned on. There's also serialization code for this set, so that the warning works with precompiled headers and modules. For modules, the warning is emitted when the module is built, for precompiled headers each time the header gets used. Finally, consider a function using C++14 auto return types to return a local type defined in a header: auto f() { struct S { typedef int a; }; return S(); } Here, the typedef escapes its local scope and could be used by only some translation units including the header. To not warn on this, add a RecursiveASTVisitor that marks all delcs on local types returned from auto functions as referenced. (Except if it's a function with internal linkage, or the decls are private and the local type has no friends -- in these cases, it _is_ safe to warn.) Several of the included testcases (most of the interesting ones) were provided by Richard Smith. (gcc's spelling -Wunused-local-typedefs is supported as an alias for this warning.) llvm-svn: 217298
* Move the initialization of VAListTagName after InitializeSema()Ben Langmuir2014-09-051-2/+4
| | | | | | | | | | | | | | | | | | | | This innocuous statement to get the identifier info for __va_list_tag was causing an assertion failure: NextIsPrevious() && "decl became non-canonical unexpectedly" if the __va_list_tag identifier was found in a PCH in some circumstances, because it was looked up before the ASTReader had a Sema object to use to find existing decls to merge with. We could possibly move getting the identifier info even later, or make it lazy if we wanted to, but this seemed like the minimal change. Now why a PCH would have this identifier in the first place is a bit mysterious. This seems to be related to the global module index in some way, because when the test case is built without the global module index it will not emit an identifier for __va_list_tag into the PCH, but with the global module index it does. llvm-svn: 217275
* Stop double visiting some expressions during self reference checking.Richard Trieu2014-09-041-5/+17
| | | | | | | | Originally, self reference checking made a double pass over some expressions to handle reference type checking. Now, allow HandleValue to also check reference types, and fallback to Visit for unhandled expressions. llvm-svn: 217203
* Don't allow inline asm statements to reference parameters in naked functionsHans Wennborg2014-09-041-0/+13
| | | | | | Differential Revision: http://reviews.llvm.org/D5183 llvm-svn: 217200
OpenPOWER on IntegriCloud