summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
* Don't let virtual calls and dynamic casts call Sema::MarkVTableUsed().Nico Weber2015-01-265-43/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | clang currently calls MarkVTableUsed() for classes that get their virtual methods called or that participate in a dynamic_cast. This is unnecessary, since CodeGen only emits vtables when it generates constructor, destructor, and vtt code. (*) Note that Sema::MarkVTableUsed() doesn't cause the emission of a vtable. Its main user-visible effect is that it instantiates virtual member functions of template classes, to make sure that if codegen decides to write a vtable all the entries in the vtable are defined. While this shouldn't change the behavior of codegen (other than being faster), it does make clang more permissive: virtual methods of templates (in particular destructors) end up being instantiated less often. In particular, classes that have members that are smart pointers to incomplete types will now get their implicit virtual destructor instantiated less frequently. For example, this used to not compile but does now compile: template <typename T> struct OwnPtr { ~OwnPtr() { static_assert((sizeof(T) > 0), "TypeMustBeComplete"); } }; class ScriptLoader; struct Base { virtual ~Base(); }; struct Sub : public Base { virtual void someFun() const {} OwnPtr<ScriptLoader> m_loader; }; void f(Sub *s) { s->someFun(); } The more permissive behavior matches both gcc (where this is not often observable, since in practice most things with virtual methods have a key function, and Sema::DefineUsedVTables() skips vtables for classes with key functions) and cl (which is my motivation for this change) – this fixes PR20337. See this issue and the review thread for some discussions about optimizations. This is similar to r213109 in spirit. r225761 was a prerequisite for this change. Various tests relied on "a->f()" marking a's vtable as used (in the sema sense), switch these to just construct a on the stack. This forces instantiation of the implicit constructor, which will mark the vtable as used. (*) The exception is -fapple-kext mode: In this mode, qualified calls to virtual functions (`a->Base::f()`) still go through the vtable, and since the vtable pointer off this doesn't point to Base's vtable, this needs to reference Base's vtable directly. To keep this working, keep referencing the vtable for virtual calls in apple kext mode. llvm-svn: 227073
* [X86] Add immediate range checking to AVX512 integer comparision builtins.Craig Topper2015-01-251-0/+24
| | | | llvm-svn: 227066
* Sema: Formatting. No behavior change.Francisco Lopes da Silva2015-01-251-1/+1
| | | | llvm-svn: 227052
* Sema: require a complete type before lookup.Francisco Lopes da Silva2015-01-251-11/+14
| | | | llvm-svn: 227037
* Name a bool parameter. No behavior change.Nico Weber2015-01-251-1/+2
| | | | llvm-svn: 227026
* First steps in implementing DR1467: List-initialization of aggregate from ↵Larisse Voufo2015-01-241-32/+92
| | | | | | | | | | same-type object. Only the first two items for now, changing Sections 8.5.4 [dcl.init.list] paragraph 3 and 13.3.1.7 [over.match.list] paragraph 1, so that defining class objects and character arrays using uniform initialization syntax is actually treated as list initialization and before it is treated aggregate initialization. llvm-svn: 227022
* When checking the template argument list, use a copy of that list for changesRichard Trieu2015-01-241-22/+34
| | | | | | | | | | | | | | | | | | | and only update the orginal list on a valid arugment list. When checking an individual expression template argument, and conversions are required, update the expression in the template argument. Since template arguments are speculatively checked, the copying of the template argument list prevents updating the template arguments when the list does not match the template. Additionally, clean up the integer checking code in the template diffing code. The code performs unneccessary conversions from APSInt to APInt. Fixes PR21758. This essentially reverts r224770 to recommits r224667 and r224668 with extra changes to prevent the template instantiation problems seen in PR22006. A test to catch the discovered problem is also added. llvm-svn: 226983
* Sema: code completion for variadic prototypes.Francisco Lopes da Silva2015-01-231-1/+3
| | | | llvm-svn: 226908
* Make the ?: precedence warning handle pointers to the left of ?Hans Wennborg2015-01-221-0/+2
| | | | | | | | | | Previously, Clang would fail to warn on: int n = x + foo ? 1 : 2; when foo is a pointer. llvm-svn: 226870
* Sema: code completion for pointer and reference to functions.Francisco Lopes da Silva2015-01-221-19/+29
| | | | llvm-svn: 226865
* When reporting constraints that should be constant, the type doesn'tJoerg Sonnenberger2015-01-221-3/+2
| | | | | | really help. Improve diagnostics. llvm-svn: 226863
* Sema: Add FIXME noteFrancisco Lopes da Silva2015-01-221-0/+1
| | | | llvm-svn: 226813
* Revert commit r226784.Alexey Bataev2015-01-221-1/+1
| | | | | | Accidentally modified file SemaType.cpp must be restored to its original state. llvm-svn: 226785
* [OPENMP] CodeGen for "omp atomic read [seq_cst]" directive.Alexey Bataev2015-01-221-1/+1
| | | | | | | | | | | | | "omp atomic read [seq_cst]" accepts expressions "v=x;". In this patch we perform an atomic load of "x" (using builtin atomic loading instructions or a call to "atomic_load()" for simple lvalues and "kmpc_atomic_start();load <x>;kmpc_atomic_end();" for other lvalues), convert the result of loading to type of "v" (using EmitScalarConversion() for simple types and EmitComplexToScalarConversion() for conversions from complex to scalar) and then store the result in "v". Differential Revision: http://reviews.llvm.org/D6431 llvm-svn: 226784
* Initial support for Win64 SEH IR emissionReid Kleckner2015-01-223-0/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The lowering looks a lot like normal EH lowering, with the exception that the exceptions are caught by executing filter expression code instead of matching typeinfo globals. The filter expressions are outlined into functions which are used in landingpad clauses where typeinfo would normally go. Major aspects that still need work: - Non-call exceptions in __try bodies won't work yet. The plan is to outline the __try block in the frontend to keep things simple. - Filter expressions cannot use local variables until capturing is implemented. - __finally blocks will not run after exceptions. Fixing this requires work in the LLVM SEH preparation pass. The IR lowering looks like this: // C code: bool safe_div(int n, int d, int *r) { __try { *r = normal_div(n, d); } __except(_exception_code() == EXCEPTION_INT_DIVIDE_BY_ZERO) { return false; } return true; } ; LLVM IR: define i32 @filter(i8* %e, i8* %fp) { %ehptrs = bitcast i8* %e to i32** %ehrec = load i32** %ehptrs %code = load i32* %ehrec %matches = icmp eq i32 %code, i32 u0xC0000094 %matches.i32 = zext i1 %matches to i32 ret i32 %matches.i32 } define i1 zeroext @safe_div(i32 %n, i32 %d, i32* %r) { %rr = invoke i32 @normal_div(i32 %n, i32 %d) to label %normal unwind to label %lpad normal: store i32 %rr, i32* %r ret i1 1 lpad: %ehvals = landingpad {i8*, i32} personality i32 (...)* @__C_specific_handler catch i8* bitcast (i32 (i8*, i8*)* @filter to i8*) %ehptr = extractvalue {i8*, i32} %ehvals, i32 0 %sel = extractvalue {i8*, i32} %ehvals, i32 1 %filter_sel = call i32 @llvm.eh.seh.typeid.for(i8* bitcast (i32 (i8*, i8*)* @filter to i8*)) %matches = icmp eq i32 %sel, %filter_sel br i1 %matches, label %eh.except, label %eh.resume eh.except: ret i1 false eh.resume: resume } Reviewers: rjmccall, rsmith, majnemer Differential Revision: http://reviews.llvm.org/D5607 llvm-svn: 226760
* Remove an out-of-date and incorrect comment.Richard Smith2015-01-221-10/+0
| | | | llvm-svn: 226756
* Initial support for C++ parameter completionFrancisco Lopes da Silva2015-01-213-109/+200
| | | | | | | | | | | | | | | | | | | | The improved completion in call context now works with: - Functions. - Member functions. - Constructors. - New expressions. - Function call expressions. - Template variants of the previous. There are still rough edges to be fixed: - Provide support for optional parameters. (fix known) - Provide support for member initializers. (fix known) - Provide support for variadic template functions. (fix unknown) - Others? llvm-svn: 226670
* AST: Don't ignore alignas on EnumDecls when calculating alignmentDavid Majnemer2015-01-211-8/+11
| | | | | | | | | | | | | | | | | | | | | | We didn't consider any alignment attributes on an EnumDecl when calculating alignment. While we are here, ignore alignment specifications on typedef types if one is used as the underlying type. Otherwise, weird things happen: enum Y : int; Y y; typedef int __attribute__((aligned(64))) u; enum Y : u {}; What is the alignment of 'Y'? It would be more consistent with the overall design of enums with fixed underlying types to consider the underlying type's UnqualifiedDesugaredType. This fixes PR22279. llvm-svn: 226653
* Revert "Sema: err_after_alias is unreachable, remove it"David Majnemer2015-01-211-1/+5
| | | | | | This reverts commit r226626. err_after_alias is, in fact, reachable. llvm-svn: 226633
* Sema: err_after_alias is unreachable, remove itDavid Majnemer2015-01-211-5/+1
| | | | | | | Examples this would have catched are now handled by the attribute verification code. llvm-svn: 226626
* Correct all typos in the initialization arguments, even if one could notKaelyn Takata2015-01-211-3/+4
| | | | | | | | | | be corrected. This fixes PR22250, which exposed the bug where if there's more than one TypoExpr in the arguments, once one failed to be corrected none of the TypoExprs after it would be handled at all thanks to an early return. llvm-svn: 226624
* Fix crashes on missing @interface for categoryBen Langmuir2015-01-203-5/+14
| | | | | | | In a few places we didn't check that Category->getClassInterface() was not null before using it. llvm-svn: 226605
* Patch fixes PR21932 crash on invalid code. UsingFariborz Jahanian2015-01-201-21/+22
| | | | | | | property-dot syntax on 'super' with no super class. Patch by Jason Haslam. llvm-svn: 226578
* Re-apply "r226548 - Introduce SPIR calling conventions" reverted in r226558.Alexander Kornienko2015-01-201-2/+18
| | | | | | | | | | | | | | | | | | | | | | | The test was fixed after a discussion with the revision author: the check pattern was made more flexible as the "%call" part is not what we actually want to check strictly there. The original patch description: === Introduce SPIR calling conventions. This implements Section 3.7 from the SPIR 1.2 spec: SPIR kernels should use "spir_kernel" calling convention. Non-kernel functions use "spir_func" calling convention. All other calling conventions are disallowed. The patch works only for OpenCL source. Any other uses will need to ensure that kernels are assigned the spir_kernel calling convention correctly. === llvm-svn: 226561
* Reverting r226548 as one of the tests fails in some configurations.Alexander Kornienko2015-01-201-18/+2
| | | | | | | | | | | | | | | | | | | | | | Here's the fail log from our internal setup: === .../tools/clang/clang -cc1 -internal-isystem .../tools/clang/staging/include -nostdsysteminc .../tools/clang/test/CodeGenOpenCL/spir-calling-conv.cl -triple spir-unknown-unknown -emit-llvm -o - FileCheck .../tools/clang/test/CodeGenOpenCL/spir-calling-conv.cl .../tools/clang/test/CodeGenOpenCL/spir-calling-conv.cl:11:12: error: expected string not found in input // CHECK: %call = tail call spir_func i32 @get_dummy_id(i32 0) ^ <stdin>:6:52: note: scanning from here define spir_kernel void @foo(i32 addrspace(1)* %A) #0 { ^ <stdin>:7:2: note: possible intended match here %1 = tail call spir_func i32 @get_dummy_id(i32 0) #2 ^ === Here's a failure on a public CI server: http://lab.llvm.org:8080/green/job/clang-stage2-configure-Rlto_check/1183/ llvm-svn: 226558
* [OPENMP] Fixed DSA processing for predetermined shared variables.Alexey Bataev2015-01-201-6/+6
| | | | | | | This patch allows to use predetermined shared variables in private clauses in parallel or tasks regions. llvm-svn: 226549
* Introduce SPIR calling conventions.Sameer Sahasrabuddhe2015-01-201-2/+18
| | | | | | | | | | | | | | This implements Section 3.7 from the SPIR 1.2 spec: SPIR kernels should use "spir_kernel" calling convention. Non-kernel functions use "spir_func" calling convention. All other calling conventions are disallowed. The patch works only for OpenCL source. Any other uses will need to ensure that kernels are assigned the spir_kernel calling convention correctly. llvm-svn: 226548
* Add back a check removed in r226436David Majnemer2015-01-191-2/+12
| | | | | | | It shouldn't have been removed, the code which replaced it didn't cover this case. llvm-svn: 226442
* SemaDeclCXX.cpp: Suppress a warning. [-Wunused-variable]NAKAMURA Takumi2015-01-191-0/+1
| | | | llvm-svn: 226441
* Sema: Variable definitions cannot be __attribute__((alias))David Majnemer2015-01-192-24/+28
| | | | | | | | | | | | | | | | | | | | Things that are OK: extern int var1 __attribute((alias("v1"))); static int var2 __attribute((alias("v2"))); Things that are not OK: int var3 __attribute((alias("v3"))); extern int var4 __attribute((alias("v4"))) = 4; We choose to accpet: struct S { static int var5 __attribute((alias("v5"))); }; This code causes assertion failues in GCC 4.8 and ICC 13.0.1, we have no reason to reject it. This partially fixes PR22217. llvm-svn: 226436
* [OPENMP] Disable copyprivate an nowait clauses in 'single' directive.Alexey Bataev2015-01-191-0/+17
| | | | | | | The copyprivate clause must not be used with the nowait clause in single directive. llvm-svn: 226429
* PR6037Nathan Sidwell2015-01-191-3/+58
| | | | | | Warn on inaccessible direct base llvm-svn: 226423
* [x86] Teach Sema to check size of comparison immediate on avx512 cmpps/cmppd ↵Craig Topper2015-01-191-1/+3
| | | | | | buitins. llvm-svn: 226422
* Handle unscoped enumeration in nested name specifier.Serge Pavlov2015-01-181-8/+27
| | | | | | | | | | If an unscoped enum is used as a nested name specifier and the language dialect is not C++ 11, issue an extension warning. This fixes PR16951. Differential Revision: http://reviews.llvm.org/D6389 llvm-svn: 226413
* Address review feedback from r215780: Use a flag insteda of the heap. No ↵Nico Weber2015-01-181-24/+12
| | | | | | behavior change. llvm-svn: 226389
* If a function decl cannot be merged, mark it as invalid.Nico Weber2015-01-171-0/+1
| | | | | | | | | | | | | | | | | | | Clang currently crashes on class C { C() = default; C() = delete; }; My cunning plan for fixing this was to change the `if (!FnD)` in Parser::ParseCXXInlineMethodDef() to `if (!FnD || FnD->isInvalidDecl)` – but alas, the second constructor decl wasn't marked as invalid. This lets Sema::MergeFunctionDecl() return true on function redeclarations, which leads to them being marked invalid. This also improves error messages when functions are redeclared. llvm-svn: 226365
* Suggest objc_method_family(none) for a property named -newFoo or similar.Jordan Rose2015-01-161-0/+34
| | | | | | | | | | | | | | | As mentioned in the previous commit, if a property (declared with @property) has a name that matches a special Objective-C method family, the getter picks up that family despite being declared by the property. The most correct way to solve this problem is to add the 'objc_method_family' attribute to the getter with an argument of 'none', which unfortunately requires an explicit declaration of the getter. This commit adds a note to the existing error (ARC) or warning (MRR) for such a poorly-named property that suggests the solution; if there's already a declaration of the getter, it even includes a fix-it. llvm-svn: 226339
* Fix a case where delayed typo correction should have resolved anKaelyn Takata2015-01-161-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ambiguity but wasn't. In the new test case, "click" wasn't being corrected properly because Sema::ClassifyName would call CorrectTypo for "click" then later Sema::DiagnoseEmptyLookup would call CorrectTypoDelayed for the same use of "click" (the former by the parser needing to determine what the identifier is so it knows how to parse the statement, i.e. is it the beginning of a declaration or an expression). CorrectTypo would record that typo correction for "click" failed and CorrectTypoDelayed would see that and not even try to correct the typo, even though in this case CorrectTypo failed due to an ambiguity (both "Click" and "clock" having an edit distance of one from "click") that could be resolved with more information. The fix is two-fold: 1) Have CorrectTypo not record failed corrections if the reason for the failure was two or more corrections with the same edit distance, and 2) Make the CorrectionCandidateCallback used by Parser::ParseCastExpression reject FunctionDecl candidates when the next token after the identifier is a ".", "=", or "->" since functions cannot be assigned to and do not have members that can be referenced. The reason for two correction spots is that from r222549 until r224375 landed, the first correction attempt would fail completely but the second would suggest "clock" while having the note point to the declaration of "Click". llvm-svn: 226334
* Wrap to 80 columns. No behavior change.Nico Weber2015-01-161-1/+2
| | | | llvm-svn: 226320
* restore fix for 18645, buildbot apparently gave a false positive.Nathan Sidwell2015-01-161-30/+17
| | | | | | Correct logic concerning 'T &&' deduction against lvalues. llvm-svn: 226278
* [OPENMP] Fixed data-sharing attributes processing for variables with globalAlexey Bataev2015-01-161-21/+14
| | | | | | | | storage. This fix allows to use non-constant global variables, static local variables and static data members in data-sharing attribute clauses in parallel and task regions. llvm-svn: 226250
* Warn about dllexported explicit class template instantiation declarations ↵Hans Wennborg2015-01-152-6/+29
| | | | | | | | | | | | | | | (PR22035) Clang would previously become confused and crash here. It does not make a lot of sense to export these, so warning seems appropriate. MSVC will export some member functions for this kind of specializations, whereas MinGW ignores the dllexport-edness. The latter behaviour seems better. Differential Revision: http://reviews.llvm.org/D6984 llvm-svn: 226208
* PR 20146Nathan Sidwell2015-01-151-2/+10
| | | | | | reject CV void return type on C definitions per 6.9.1/3 llvm-svn: 226178
* Sema: Recover when a function template is in an extern "C" blockDavid Majnemer2015-01-151-2/+2
| | | | llvm-svn: 226135
* Remove ASTConsumer::HandleVTable()'s bool parameter.Nico Weber2015-01-151-1/+2
| | | | | | | | | | | Sema calls HandleVTable() with a bool parameter which is then threaded through three layers. The only effect of this bool is an early return at the last layer. Instead, remove this parameter and call HandleVTable() only if the bool is true. No intended behavior change. llvm-svn: 226096
* PR13699: Include friend declarations in code completion results if they had aRichard Smith2015-01-151-3/+6
| | | | | | | | | prior visible declaration. Prefer to take template parameter names from the first declaration. Testcase from a patch by Francisco Lopes! llvm-svn: 226083
* Fix crash-on-invalid and name lookup when recovering from ~X::X() typo.Richard Smith2015-01-151-0/+3
| | | | llvm-svn: 226067
* [cleanup] Re-sort *all* #include lines with llvm/utils/sort_includes.pyChandler Carruth2015-01-141-1/+1
| | | | | | | | | | Sorry for the noise, I managed to miss a bunch of recent regressions of include orderings here. This should actually sort all the includes for Clang. Again, no functionality changed, this is just a mechanical cleanup that I try to run periodically to keep the #include lines as regular as possible across the project. llvm-svn: 225979
* Sema: It's cheaper to ask LookupResult::empty than to calculate linkageDavid Majnemer2015-01-141-1/+1
| | | | llvm-svn: 225960
* Sema: Check type compatibility with the most recent decl when mergingDavid Majnemer2015-01-141-1/+8
| | | | | | | | | | We would check the type information from the declaration found by lookup but we would neglect checking compatibility with the most recent declaration. This would make it possible for us to not correctly diagnose inconsistencies with declarations which were made in a different scope. llvm-svn: 225934
OpenPOWER on IntegriCloud