summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ItaniumMangle.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Add support for GCC's '__auto_type' extension, per the GCC manual:Richard Smith2015-11-111-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | https://gcc.gnu.org/onlinedocs/gcc/Typeof.html Differences from the GCC extension: * __auto_type is also permitted in C++ (but only in places where it could appear in C), allowing its use in headers that might be shared across C and C++, or used from C++98 * __auto_type can be combined with a declarator, as with C++ auto (for instance, "__auto_type *p") * multiple variables can be declared in a single __auto_type declaration, with the C++ semantics (the deduced type must be the same in each case) This patch also adds a missing restriction on applying typeof to a bit-field, which GCC has historically rejected in C (due to lack of clarity as to whether the operand should be promoted). The same restriction also applies to __auto_type in C (in both GCC and Clang). This also fixes PR25449. Patch by Nicholas Allegra! llvm-svn: 252690
* [coroutines] Creation of promise object, lookup of operator co_await, buildingRichard Smith2015-10-271-0/+12
| | | | | | of await_* calls, and AST representation for same. llvm-svn: 251387
* [coroutines] Add overloaded unary 'operator co_await'.Richard Smith2015-10-221-0/+3
| | | | llvm-svn: 250991
* PR14858: Initial support for proper sizeof... handling within alias templates.Richard Smith2015-09-231-1/+10
| | | | | | | This doesn't quite get alias template equivalence right yet, but handles the egregious cases where we would silently give the wrong answers. llvm-svn: 248431
* Run clang-format to unify the switch statement style as suggest here: ↵Alexey Bader2015-09-151-33/+100
| | | | | | | | http://reviews.llvm.org/D12855#246073. NFC. llvm-svn: 247678
* [OpenCL] Add new types for OpenCL 2.0.Alexey Bader2015-09-151-0/+30
| | | | | | | | Patch by Pedro Ferreira. Reviewers: pekka.jaaskelainen Differential Revision: http://reviews.llvm.org/D12855 llvm-svn: 247676
* CFI: Introduce -fsanitize=cfi-icall flag.Peter Collingbourne2015-09-101-17/+0
| | | | | | | | | | This flag causes the compiler to emit bit set entries for functions as well as runtime bitset checks at indirect call sites. Depends on the new function bitset mechanism. Differential Revision: http://reviews.llvm.org/D11857 llvm-svn: 247238
* [OPENMP 4.0] Initial support for array sections.Alexey Bataev2015-08-251-0/+1
| | | | | | | | Adds parsing/sema analysis/serialization/deserialization for array sections in OpenMP constructs (introduced in OpenMP 4.0). Currently it is allowed to use array sections only in OpenMP clauses that accepts list of expressions. Differential Revision: http://reviews.llvm.org/D10732 llvm-svn: 245937
* Remove and forbid raw_svector_ostream::flush() calls.Yaron Keren2015-08-131-1/+0
| | | | | | | | | | After r244870 flush() will only compare two null pointers and return, doing nothing but wasting run time. The call is not required any more as the stream and its SmallString are always in sync. Thanks to David Blaikie for reviewing. llvm-svn: 244928
* AST: Implement mangling support for function types without a prototype.Peter Collingbourne2015-08-071-1/+15
| | | | | | | | | | Function types without prototypes can arise when mangling a function type within an overloadable function in C. We mangle these as the absence of any parameter types (not even an empty parameter list). Differential Revision: http://reviews.llvm.org/D11848 llvm-svn: 244374
* [AST] Really allocate a SmallVector to the right size.Benjamin Kramer2015-08-041-2/+1
| | | | | | | | | | set_size only resets the end pointer and asserts if it is used to grow the buffer. This would crash when mangling a float with more than 80 bits, add a test with a ppc double double (128 bits). Found by inspection. llvm-svn: 243979
* Implement the Objective-C __kindof type qualifier.Douglas Gregor2015-07-071-0/+13
| | | | | | | | | | The __kindof type qualifier can be applied to Objective-C object (pointer) types to indicate id-like behavior, which includes implicit "downcasting" of __kindof types to subclasses and id-like message-send behavior. __kindof types provide better type bounds for substitutions into unspecified generic types, which preserves more type information. llvm-svn: 241548
* [OPENMP] Introduced type trait "__builtin_omp_required_simd_align" for ↵Alexey Bataev2015-07-021-1/+9
| | | | | | | | | default simd alignment. Adds type trait "__builtin_omp_required_simd_align" after discussions here http://reviews.llvm.org/D9894 Differential Revision: http://reviews.llvm.org/D10597 llvm-svn: 241237
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-1/+1
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-1/+1
| | | | | | | | | | | | The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
* CFI: Implement bitset emission for the Microsoft ABI.Peter Collingbourne2015-06-191-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Clang's control flow integrity implementation works by conceptually attaching "tags" (in the form of bitset entries) to each virtual table, identifying the names of the classes that the virtual table is compatible with. Under the Itanium ABI, it is simple to assign tags to virtual tables; they are simply the address points, which are available via VTableLayout. Because any overridden methods receive an entry in the derived class's virtual table, a check for an overridden method call can always be done by checking the tag of whichever derived class overrode the method call. The Microsoft ABI is a little different, as it does not directly use address points, and overrides in a derived class do not cause new virtual table entries to be added to the derived class; instead, the slot in the base class is reused, and the compiler needs to adjust the this pointer at the call site to (generally) the base class that initially defined the method. After the this pointer has been adjusted, we cannot check for the derived class's tag, as the virtual table may not be compatible with the derived class. So we need to determine which base class we have been adjusted to. Specifically, at each call site, we use ASTRecordLayout to identify the most derived class whose virtual table is laid out at the "this" pointer offset we are using to make the call, and check the virtual table for that tag. Because address point information is unavailable, we "reconstruct" it as follows: any virtual tables we create for a non-derived class receive a tag for that class, and virtual tables for a base class inside a derived class receive a tag for the base class, together with tags for any derived classes which are laid out at the same position as the derived class (and therefore have compatible virtual tables). Differential Revision: http://reviews.llvm.org/D10520 llvm-svn: 240117
* Implementing C99 partial re-initialization behavior (DR-253)Yunzhong Gao2015-06-101-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Based on previous discussion on the mailing list, clang currently lacks support for C99 partial re-initialization behavior: Reference: http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-April/029188.html Reference: http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_253.htm This patch attempts to fix this problem. Given the following code snippet, struct P1 { char x[6]; }; struct LP1 { struct P1 p1; }; struct LP1 l = { .p1 = { "foo" }, .p1.x[2] = 'x' }; // this example is adapted from the example for "struct fred x[]" in DR-253; // currently clang produces in l: { "\0\0x" }, // whereas gcc 4.8 produces { "fox" }; // with this fix, clang will also produce: { "fox" }; Differential Review: http://reviews.llvm.org/D5789 llvm-svn: 239446
* [ItaniumMangle] Mangle long double as __float128 for some Power targetsDavid Majnemer2015-06-091-1/+5
| | | | | | | | | | GCC mangles long double like __float128 in order to support compatibility with ABI variants which had a different interpretation of long double. This fixes PR23791. llvm-svn: 239421
* Modernize some doc comments. NFCJustin Bogner2015-05-221-13/+12
| | | | llvm-svn: 238006
* [ItaniumMangle] Fix a typo.David Majnemer2015-05-221-1/+1
| | | | llvm-svn: 238002
* Itanium mangler: don't trip an assertion when unresolved members have ↵Douglas Gregor2015-05-211-5/+6
| | | | | | | | | | | | implicit bases. When we find a member of the current instantation, the base of the unresolved member expression is implicit; use nullptr for such bases. This is not a change in behavior: the AST already contains null in such cases, so non-asserts builds do the right thing already. Fixes rdar://problem/21020559. llvm-svn: 237929
* [AArch64 ACLE] Allow to define poly64_t as 'unsigned long long' on LLP64 system.Kevin Qin2015-05-141-0/+1
| | | | | | This fixes PR23414 as well. llvm-svn: 237348
* Reland r234613 (and follow-ups 234614, 234616, 234618)Reid Kleckner2015-04-141-0/+12
| | | | | | | The frameescape intrinsic cannot be inlined, so I fixed the inliner in r234937. This should address PR23216. llvm-svn: 234942
* Revert r234613 (and follow-ups 234614, 234616, 234618), it caused PR23216.Nico Weber2015-04-131-12/+0
| | | | llvm-svn: 234789
* Revert r234786, it contained a bunch of stuff I did not mean to commit.Nico Weber2015-04-131-0/+12
| | | | llvm-svn: 234787
* Revert r234613 (and follow-ups 234614, 234616, 234618), it caused PR23216.Nico Weber2015-04-131-12/+0
| | | | llvm-svn: 234786
* [SEH] Re-land r234532, but use internal linkage for all SEH helpersReid Kleckner2015-04-101-0/+12
| | | | | | | | | | Even though these symbols are in a comdat group, the Microsoft linker really wants them to have internal linkage. I'm planning to tweak the mangling in a follow-up change. This is a straight revert with a 1-line fix. llvm-svn: 234613
* Revert r234532 for a bit, it very likely caused http://crbug.com/475768Nico Weber2015-04-101-12/+0
| | | | llvm-svn: 234563
* [SEH] Outline finally blocks using the new variable capture supportReid Kleckner2015-04-091-0/+12
| | | | | | | | | | | | | | | WinEHPrepare was going to have to pattern match the control flow merge and split that the old lowering used, and that wasn't really feasible. Now we can teach WinEHPrepare to pattern match this, which is much simpler: %fp = call i8* @llvm.frameaddress(i32 0) call void @func(iN [01], i8* %fp) This prototype happens to match the prototype used by the Win64 SEH personality function, so this is really simple. llvm-svn: 234532
* MS ABI: Implement copy-ctor closures, finish implementing throwDavid Majnemer2015-03-111-0/+3
| | | | | | | | | | | | | | | 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
* For PR22870: produce an error rather than asserting if a designated ↵Richard Smith2015-03-111-1/+1
| | | | | | initializer appears in a signature. llvm-svn: 231892
* Teach raw_ostream to accept SmallString.Yaron Keren2015-03-101-1/+1
| | | | | | | | | | | | | | Saves adding .str() call to any raw_ostream << SmallString usage and a small step towards making .str() consistent in the ADTs by removing one of the SmallString::str() use cases, discussion at http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20141013/240026.html I'll update the Phabricator patch http://reviews.llvm.org/D6372 for review of the Twine SmallString support, it's more complex than this one. llvm-svn: 231763
* Implement Control Flow Integrity for virtual calls.Peter Collingbourne2015-02-201-0/+18
| | | | | | | | | | | | | | | This patch introduces the -fsanitize=cfi-vptr flag, which enables a control flow integrity scheme that checks that virtual calls take place using a vptr of the correct dynamic type. More details in the new docs/ControlFlowIntegrity.rst file. It also introduces the -fsanitize=cfi flag, which is currently a synonym for -fsanitize=cfi-vptr, but will eventually cover all CFI checks implemented in Clang. Differential Revision: http://reviews.llvm.org/D7424 llvm-svn: 230055
* Itanium ABI: Pack expansions change the arity of expressions to unknownDavid Majnemer2015-02-191-3/+8
| | | | llvm-svn: 229918
* CXXNameMangler::mangleUnresolvedPrefix(): Prune an obsolete \param, ↵NAKAMURA Takumi2015-02-191-2/+0
| | | | | | according to r229809. [-Wdocumentation] llvm-svn: 229823
* Itanium ABI: Don't pass nullptr to a bool argumentDavid Majnemer2015-02-191-1/+1
| | | | llvm-svn: 229822
* Itanium ABI: Properly qualify the destructor-nameDavid Majnemer2015-02-191-206/+169
| | | | | | | We didn't have enough qualificaiton before the scope specifier and we had too much qualification in the destructor name itself. llvm-svn: 229809
* Itanium ABI: Write a character instead of a string literalDavid Majnemer2015-02-181-1/+1
| | | | | | No functional change intended. llvm-svn: 229726
* Itanium ABI: Properly mangle extern "C" template argumentsDavid Majnemer2015-02-181-0/+8
| | | | | | | | | extern "C" declarations should be considered like global declarations for mangling purposes. Differential Revision: http://reviews.llvm.org/D7718 llvm-svn: 229724
* Itanium ABI: Mangle <mangled-name> according to the ABIDavid Majnemer2015-02-181-12/+6
| | | | | | | | | | | | | | | We attempted to be compatible with GCC's buggy mangling for templates with a declaration for a template argument. However, we weren't completely successful in copying their bug in cases like: char foo; template <char &C> decltype(C) f() { return foo; }; template char &f<foo>(); Instead, just follow the ABI specification. This fixes PR22621. llvm-svn: 229644
* Itanium ABI: Improve our mangling of <destructor-name>David Majnemer2015-02-181-42/+90
| | | | | | | | | | | | | Our mangling of <destructor-name> wasn't quite right: we'd introduce mangling substitutions where one shouldn't be possible. We also didn't correctly handle the case where the destroyed type was not dependent but still a TemplateSpecializationType. N.B. There isn't a mangling for a template-template parameter showing up as the destroyed type. We do the 'obvious' thing and mangle the index of the parameter. llvm-svn: 229615
* ItaniumMangle: Correctly mangle <base-unresolved-name>David Majnemer2015-02-141-25/+63
| | | | | | | | | | We had two bugs: - We were missing the "on" prefix for unresolved operators. - We didn't handle the mangling of destructors at all. This fixes PR22584. llvm-svn: 229255
* PR22465: when performing list-initialization for a class type C, if we see anRichard Smith2015-02-051-3/+13
| | | | | | | | | | initializer of the form {x}, where x is of type C or a type derived from C, perform *non-list* initialization of the entity from x, but create a CXXConstructExpr that knows that we used list-initialization syntax. Plus some fixes to ensure we mangle correctly in this and related cases. llvm-svn: 228276
* Various fixes to mangling of list-initialization.Richard Smith2015-02-051-15/+56
| | | | llvm-svn: 228274
* Initial support for Win64 SEH IR emissionReid Kleckner2015-01-221-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix the issue of mangling of local anonymous unions (Itanium C++ ABI):Evgeny Astigeevich2014-12-121-24/+9
| | | | | | | | | | | | | | | | | | | | | | A discriminator is used for the first occurrence of a name. inline int f1 () { static union { int a; long int b; }; static union { int c; double d; }; return a+c; } The name of the second union is mangled as _ZZ2f1vE1c_0 instead of _ZZ2f1vE1c. Differential Revision: http://reviews.llvm.org/D6295 llvm-svn: 224131
* AST: Consider pseudo-struct builtin types as substitutableDavid Majnemer2014-11-281-1/+14
| | | | | | | | We didn't consider types like ObjCSel as a substitution candidate. This fixes PR21688. llvm-svn: 222941
* When mangling member-expressions, skip implicit accesses of anonymous unionRichard Smith2014-11-201-0/+12
| | | | | | objects. This is consistent with GCC's behavior. Patch by Tomasz Miąsko! llvm-svn: 222402
* Update fold-expression mangling to match cxx-abi-dev discussion.Richard Smith2014-11-101-5/+3
| | | | llvm-svn: 221623
* [c++1z] N4295: fold-expressions.Richard Smith2014-11-081-2/+25
| | | | | | | | | | | | | | | | This is a new form of expression of the form: (expr op ... op expr) where one of the exprs is a parameter pack. It expands into (expr1 op (expr2onwards op ... op expr)) (and likewise if the pack is on the right). The non-pack operand can be omitted; in that case, an empty pack gives a fallback value or an error, depending on the operator. llvm-svn: 221573
OpenPOWER on IntegriCloud