summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX
Commit message (Collapse)AuthorAgeFilesLines
* Re-land "MS ABI: lambda call operators are instance methods and should use ↵Reid Kleckner2015-04-012-12/+12
| | | | | | | | | | | | | thiscall" Update the test cases to pass when lambda call operators use thiscall. Update the lambda-to-block conversion operator to use the default free function calling convention instead of the call operator's convention. This reverts commit r233082 and re-instates r233023. llvm-svn: 233835
* Fix inlinehint.cpp with an explicit triple to avoid x86_thiscallcc problemsReid Kleckner2015-04-011-2/+1
| | | | llvm-svn: 233821
* Remove comdats from inlinehint.cpp to pass test on DarwinReid Kleckner2015-04-011-5/+6
| | | | llvm-svn: 233820
* Mark instantiated function decls as inline specified if any pattern isReid Kleckner2015-04-011-0/+33
| | | | | | | | | | | | A function template pattern can be declared without the 'inline' specifier and defined later with the 'inline' specifier. However, during instantiation, we were only looking at the canonical decl to see if we should mark the instantiated decl as inline specified. Since the instantiated decl actually represents many pattern declarations, put the inline specifier on the instantiation decl if any of the pattern decls have it. llvm-svn: 233817
* [MS ABI] Disregard restrictive exception specificationsDavid Majnemer2015-04-011-0/+8
| | | | | | | | | | | MSVC treats all non-empty exception specifications the same way: all exceptions are permitted. The .xdata tables provide a way to efficiently lower exception specifications *but* this probably has to be implemented as a catch-all/rethrow mechanism instead of the Itanium way. This fixes PR23092. llvm-svn: 233787
* [MS ABI] Rework .xdata HandlerType emissionDavid Majnemer2015-03-291-3/+3
| | | | | | | | | | Utilizing IMAGEREL relocations for synthetic IR constructs isn't valuable, just clutter. While we are here, simplify HandlerType names by making the numeric value for the 'adjective' part of the mangled name instead of appending '.const', etc. The old scheme made for very long global names and leads to wordy things like '.std_bad_alloc' llvm-svn: 233503
* Remove test for PR12917 for now. I'm relatively sure this is ill-formed per ↵Benjamin Kramer2015-03-271-22/+0
| | | | | | [dcl.fct.default]p3. llvm-svn: 233379
* Reverting r233023 -- it caused test failures on Windows with MSVC x86.Aaron Ballman2015-03-241-5/+5
| | | | | | http://bb.pgr.jp/builders/ninja-clang-i686-msc18-R/builds/572 llvm-svn: 233082
* MS ABI: lambda call operators are instance methods and should use thiscallReid Kleckner2015-03-231-5/+5
| | | | | | Fixes an issue reported by Daniel Berenyi on cfe-dev. llvm-svn: 233023
* C++14: Disable sized deallocation by default due to ABI breakageReid Kleckner2015-03-203-98/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are no widely deployed standard libraries providing sized deallocation functions, so we have to punt and ask the user if they want us to use sized deallocation. In the future, when such libraries are deployed, we can teach the driver to detect them and enable this feature. N3536 claimed that a weak thunk from sized to unsized deallocation could be emitted to avoid breaking backwards compatibility with standard libraries not providing sized deallocation. However, this approach and other variations don't work in practice. With the weak function approach, the thunk has to have default visibility in order to ensure that it is overridden by other DSOs providing sized deallocation. Weak, default visibility symbols are particularly expensive on MachO, so John McCall was considering disabling this feature by default on Darwin. It also changes behavior ELF linking behavior, causing certain otherwise unreferenced object files from an archive to be pulled into the link. Our second approach was to use an extern_weak function declaration and do an inline conditional branch at the deletion call site. This doesn't work because extern_weak only works on MachO if you have some archive providing the default value of the extern_weak symbol. Arranging to provide such an archive has the same challenges as providing the symbol in the standard library. Not to mention that extern_weak doesn't really work on COFF. Reviewers: rsmith, rjmccall Differential Revision: http://reviews.llvm.org/D8467 llvm-svn: 232788
* Don't crash-on-valid when an inline function is friend of class templateDavid Majnemer2015-03-201-0/+15
| | | | | | | | | We assumed that the most recent declaration of an inline function would also be inline. However, a more recent declaration can come from a friend declaration in a class template that is instantiated at the definition of the function. llvm-svn: 232786
* MS ABI: Implement the MSVC 2015 scheme for scope disambiguationDavid Majnemer2015-03-193-5/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | consider C++ that looks like: inline int &f(bool b) { if (b) { static int i; return i; } static int i; return i; } Both 'i' variables must have distinct (and stable) names for linkage purposes. The MSVC 2013 ABI would number the variables using a count of the number of scopes that have been created. However, the final 'i' returns to a scope that has already been created leading to a mangling collision. MSVC 2015 fixes this by giving the second 'i' the name it would have if it were declared before the 'if'. However, this results in ABI breakage because the mangled name, in cases where there was no ambiguity, would now be different. We implement the new behavior and only enable it if we are targeting the MSVC 2015 ABI, otherwise the old behavior will be used. This fixes PR18131. llvm-svn: 232766
* Revert "Improvement on sized deallocation from r230160"Reid Kleckner2015-03-193-55/+33
| | | | | | | | | This reverts commit r230580. extern_weak functions don't appear to work on Darwin (PR22951), so we'll need to come up with a new approach. llvm-svn: 232731
* MS ABI: Don't try to emit VF/VB-Tables for extern class templatesDavid Majnemer2015-03-182-3/+24
| | | | | | | | | There will be an explicit template instantiation in another translation unit which will provide the definition of the VF/VB-Tables. This fixes PR22932. llvm-svn: 232680
* MS ABI: Empty pack expansions had their mangling changed in 2013->2015David Majnemer2015-03-181-3/+6
| | | | | | | | | | We used to support the 2013 mangling and changed it to the more reasonable 2015 mangling. Let's make the mangling conditional on what version of MSVC is targeted. This fixes PR21888. llvm-svn: 232609
* Fix test in release mode. This reapplies r232456, corresponding to r232579.NAKAMURA Takumi2015-03-181-1/+1
| | | | llvm-svn: 232582
* Fix the LLVM type used when lowering initializer list reference temporaries ↵Nick Lewycky2015-03-181-0/+33
| | | | | | to global variables. Reapplies r232454 with fix for PR22940. llvm-svn: 232579
* MS ABI: Build C++ default argument exprs for exported template classesReid Kleckner2015-03-171-0/+9
| | | | | | This was an omission from r232229. llvm-svn: 232554
* MS ABI: Emit HandlerMap entries for C++ catchDavid Majnemer2015-03-171-2/+4
| | | | | | | | | | | | | The HandlerMap describes, to the runtime, what sort of catches surround the try. In principle, this structure has to be emitted by the backend because only it knows the layout of the stack (the runtime needs to know where on the stack the destination of a copy lives, etc.) but there is some C++ specific information that the backend can't reason about. Stick this information in special LLVM globals with the relevant "const", "volatile", "reference" info mangled into the name. llvm-svn: 232538
* MS ABI: Delay default constructor closure checking until the outermost class ↵Reid Kleckner2015-03-171-5/+21
| | | | | | | | | | | | | | | | | scope ends Previously, we would error out on this code because the default argument wasn't parsed until the end of Outer: struct __declspec(dllexport) Outer { struct __declspec(dllexport) Inner { Inner(void *p = 0); }; }; Now we do the checking on the closing brace of Outer instead of Inner. llvm-svn: 232519
* Revert r232454 and r232456: "Fix the LLVM type used when lowering ↵Hans Wennborg2015-03-171-24/+0
| | | | | | | | initializer list reference temporaries to global variables." This caused PR22940. llvm-svn: 232496
* Fix test in release mode.Nick Lewycky2015-03-171-1/+1
| | | | llvm-svn: 232456
* Fix the LLVM type used when lowering initializer list reference temporaries ↵Nick Lewycky2015-03-171-0/+24
| | | | | | to global variables. llvm-svn: 232454
* CodeGenCXX: Test that linetables work with variadic virtual thunksDuncan P. N. Exon Smith2015-03-171-0/+23
| | | | | | | | Add a frontend test for PR22929, which was fixed by LLVM r232449. Besides the crash test, check that the `!dbg` attachment is sane since its presence was the trigger. llvm-svn: 232450
* MS ABI: Don't use qualified pointee types for 'catch' EH TypeDescriptorsDavid Majnemer2015-03-151-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Qualifiers are located next to the TypeDescriptor in order to properly ensure that a pointer type can only be caught by a more qualified catch handler. This means that a catch handler of type 'const int *' requires an RTTI object for 'int *'. We got this correct for 'throw' but not for 'catch'. N.B. We don't currently have the means to store the qualifiers because LLVM's EH strategy is tailored to the Itanium scheme. The Itanium ABI stores qualifiers inside the type descriptor in such a way that the manner of qualification is stored in addition to the pointee type's descriptor. Perhaps the best way of modeling this for the MS ABI is using an aggregate type to bundle the qualifiers with the descriptor? This is tricky because we want to make it clear to the optimization passes which catch handlers invalidate other handlers. My current thoughts on a design for this is along the lines of: { { TypeDescriptor* TD, i32 QualifierFlags }, i32 MiscFlags } The idea is that the inner most aggregate is all that is needed to communicate that one catch handler might supercede another. The 'MiscFlags' field would be used to hold the bitpattern for the notion that the 'catch' handler does not need to invoke a copy-constructor because we are catching by reference. llvm-svn: 232318
* CodeGen: Correctly initialize bitfields with non-constant initializersDavid Majnemer2015-03-141-1/+8
| | | | | | | | It is possible to construct an initializer for a bitfield which is not constant. Instead of emitting code to initialize the field before the execution of main, clang would crash. llvm-svn: 232285
* MS ABI: Mangle virtual member pointer thunks with the correct CCDavid Majnemer2015-03-142-3/+22
| | | | | | | | | | Virtual member pointers are implemented using a thunk. We assumed that the calling convention for this thunk was always __thiscall for 32-bit targets and __cdecl for 64-bit targets. However, this is not the case. Mangle in whichever calling convention is appropriate for this member function thunk. llvm-svn: 232254
* Implement bad cast checks using control flow integrity information.Peter Collingbourne2015-03-141-0/+109
| | | | | | | | | | | This scheme checks that pointer and lvalue casts are made to an object of the correct dynamic type; that is, the dynamic type of the object must be a derived class of the pointee type of the cast. The checks are currently only introduced where the class being casted to is a polymorphic class. Differential Revision: http://reviews.llvm.org/D8312 llvm-svn: 232241
* Add a bunch of missing "CHECK" colons in tests. NFC.Ahmed Bougacha2015-03-142-2/+2
| | | | llvm-svn: 232237
* MS ABI: Generate default constructor closuresDavid Majnemer2015-03-131-0/+22
| | | | | | | | | | | | | | | | | | | | The MS ABI utilizes a compiler generated function called the "vector constructor iterator" to construct arrays of objects with non-trivial constructors/destructors. For this to work, the constructor must follow a specific calling convention. A thunk must be created if the default constructor has default arguments, is variadic or is otherwise incompatible. This thunk is called the default constructor closure. N.B. Default constructor closures are only generated if the default constructor is exported because clang itself does not utilize vector constructor iterators. Failing to export the default constructor closure will result in link/load failure if a translation unit compiled with MSVC is on the import side. Differential Revision: http://reviews.llvm.org/D8331 llvm-svn: 232229
* MS ABI: Implement __GetExceptionInfo for std::make_exception_ptrDavid Majnemer2015-03-131-1/+13
| | | | | | | | | std::make_exception_ptr calls std::__GetExceptionInfo in order to figure out how to properly copy the exception object. Differential Revision: http://reviews.llvm.org/D8280 llvm-svn: 232188
* Test case updates for explicit type parameter to the gep operatorDavid Blaikie2015-03-1336-215/+215
| | | | llvm-svn: 232187
* MS ABI: Allow a nullptr_t exception to be caught by void * catch handlerDavid Majnemer2015-03-121-0/+5
| | | | | | | | | A nullptr exception object can be caught by any pointer type catch handler. However, it is not possible to express this in the exception info for the MS ABI. As a middle ground, allow such exception objects to be caught with pointer-to-void catch handlers. llvm-svn: 232069
* Don't overconstrain a FileCheck patternDavid Majnemer2015-03-111-1/+1
| | | | llvm-svn: 231971
* MS ABI: Implement copy-ctor closures, finish implementing throwDavid Majnemer2015-03-111-1/+53
| | | | | | | | | | | | | | | This adds support for copy-constructor closures. These are generated when the C++ runtime has to call a copy-constructor with a particular calling convention or with default arguments substituted in to the call. Because the runtime has no mechanism to call the function with a different calling convention or know-how to evaluate the default arguments at run-time, we create a thunk which will do all the appropriate work and package it in a way the runtime can use. Differential Revision: http://reviews.llvm.org/D8225 llvm-svn: 231952
* Sema: Properly track mangling number/name for linkage for using declsDavid Majnemer2015-03-111-0/+30
| | | | | | | | | | | | Using declarations which are aliases to struct types have their name used as the struct type's name for linkage purposes. Otherwise, make sure to give an anonymous struct defined inside a using declaration a mangling number to disambiguate it from other anonymous structs in the same context. This fixes PR22809. llvm-svn: 231909
* Prevent test from accessing files.Daniel Jasper2015-03-111-3/+3
| | | | llvm-svn: 231907
* Fix test to specify an Itanium triple.Richard Smith2015-03-111-3/+3
| | | | llvm-svn: 231900
* For PR22870: produce an error rather than asserting if a designated ↵Richard Smith2015-03-111-0/+26
| | | | | | initializer appears in a signature. llvm-svn: 231892
* MS ABI: Mangle the location of the catchable type into it's nameDavid Majnemer2015-03-101-4/+4
| | | | | | | | Because the catchable type has a reference to its name, mangle the location to ensure that two catchable types with different locations are distinct. llvm-svn: 231819
* Suppress a couple of tests, clang/test/CodeGen/catch-undef-behavior.c and ↵NAKAMURA Takumi2015-03-091-0/+1
| | | | | | one, for -Asserts for now. They were introduced in r231711. llvm-svn: 231717
* [UBSan] Split -fsanitize=shift into -fsanitize=shift-base and ↵Alexey Samsonov2015-03-092-6/+10
| | | | | | | | | | | | | | | | -fsanitize=shift-exponent. This is a recommit of r231150, reverted in r231409. Turns out that -fsanitize=shift-base check implementation only works if the shift exponent is valid, otherwise it contains undefined behavior itself. Make sure we check that exponent is valid before we proceed to check the base. Make sure that we actually report invalid values of base or exponent if -fsanitize=shift-base or -fsanitize=shift-exponent is specified, respectively. llvm-svn: 231711
* Reapply r231508 "CodeGen: Emit constant temporaries into read-only globals."Benjamin Kramer2015-03-074-20/+46
| | | | | | | | | | | | I disabled putting the new global into the same COMDAT as the function for now. There's a fundamental problem when we inline references to the global but still have the global in a COMDAT linked to the inlined function. Since this is only an optimization there may be other versions of the COMDAT around that are missing the new global and hell breaks loose at link time. I hope the chromium build doesn't break this time :) llvm-svn: 231564
* Revert r231508 "CodeGen: Emit constant temporaries into read-only globals."Hans Wennborg2015-03-074-46/+20
| | | | | | | | | This broke the Chromium build. Links were failing with messages like: obj/dbus/libdbus_test_support.a(obj/dbus/dbus_test_support.mock_object_proxy.o):../../dbus/mock_object_proxy.cc:function dbus::MockObjectProxy::Detach(): warning: relocation refers to discarded section /usr/local/google/work/chromium/src/third_party/binutils/Linux_x64/Release/bin/ld.gold: error: treating warnings as errors llvm-svn: 231541
* Unbreak build botsDavid Majnemer2015-03-061-2/+2
| | | | llvm-svn: 231536
* MS ABI: Stick throw-related data into the .xdata sectionDavid Majnemer2015-03-062-8/+8
| | | | | | | This is a little nicer as it keeps the contents of .xdata away from normal .rdata; we expect .xdata to be far colder than .rdata. llvm-svn: 231534
* MS ABI: Correctly generate throw-info for pointer to const qual typesDavid Majnemer2015-03-061-1/+7
| | | | | | | We didn't create type info based on the unqualified pointee type, causing RTTI mismatches. llvm-svn: 231533
* CodeGen: Emit constant temporaries into read-only globals.Benjamin Kramer2015-03-064-20/+46
| | | | | | | | | | | | | | | | | | | | | | | Instead of creating a copy on the stack just stash them in a private constant global. This saves both the copying overhead and the stack space, and gives the optimizer more room to constant fold. This tries to make array temporaries more similar to regular arrays, they can't use the same logic because a temporary has no VarDecl to be bound to so we roll our own version here. The original use case for this optimization was code like for (int i : {1, 2, 3, 4, 5, 6, 7, 8, 10}) foo(i); where without this patch (assuming that the loop is not unrolled) we would alloca an array on the stack, copy the 10 values over and iterate on that. With this patch we put the array in .text use it directly. Apart from that case this helps on virtually any passing of a constant std::initializer_list as a function argument. Differential Revision: http://reviews.llvm.org/D8034 llvm-svn: 231508
* MS ABI: Insert copy-constructors into the CatchableTypeDavid Majnemer2015-03-061-3/+3
| | | | | | | | | | | | | | | | Find all unambiguous public classes of the exception object's class type and reference all of their copy constructors. Yes, this is not conforming but it is necessary in order to implement their ABI. This is because the copy constructor is actually referenced by the metadata describing which catch handlers are eligible to handle the exception object. N.B. This doesn't yet handle the copy constructor closure case yet, that work is ongoing. Differential Revision: http://reviews.llvm.org/D8101 llvm-svn: 231499
* Don't crash on non-public referenced dtors in toplevel classes.Nico Weber2015-03-061-0/+14
| | | | | | | Fixes PR22793, a bug that caused self-hosting to fail after the innocuous r231254. See the bug for details. llvm-svn: 231451
OpenPOWER on IntegriCloud