summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ASTContext.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [C++11] Replacing FunctionDecl iterators param_begin() and param_end() with ↵Aaron Ballman2014-03-071-6/+3
| | | | | | iterator_range params(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203248
* [C++11] Replacing iterators redecls_begin() and redecls_end() with ↵Aaron Ballman2014-03-061-12/+8
| | | | | | iterator_range redecls(). Updating all of the usages of the iterators with range-based for loops, which allows the begin/end forms to be removed entirely. llvm-svn: 203179
* [-cxx-abi microsoft] Implement local manglings accuratelyDavid Majnemer2014-03-051-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The MSVC ABI appears to mangle the lexical scope into the names of statics. Specifically, a counter is incremented whenever a scope is entered where things can be declared in such a way that an ambiguity can arise. For example, a class scope inside of a class scope doesn't do anything interesting because the nested class cannot collide with another nested class. There are problems with this scheme: - It is unreliable. The counter is only incremented when a previously never encountered scope is entered. There are cases where this will cause ambiguity amongst declarations that have the same name where one was introduced in a deep scope while the other was introduced right after in the previous lexical scope. - It is wasteful. Statements like: {{{{{{{ static int foo = a; }}}}}}} will make the mangling of "foo" larger than it need be because the scope counter has been incremented many times. Because of these problems, and practical implementation concerns. We choose not to implement this scheme if the local static or local type isn't visible. The mangling of these declarations will look very similar but the numbering will make far more sense, this scheme is lifted from the Itanium ABI implementation. Reviewers: rsmith, doug.gregor, rnk, eli.friedman, cdavis5x Reviewed By: rnk CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2953 llvm-svn: 202951
* [C++11] Replace llvm::tie with std::tie.Benjamin Kramer2014-03-021-1/+1
| | | | llvm-svn: 202639
* [ASTUnit] Fix use-after-free bug in ↵Argyrios Kyrtzidis2014-02-271-3/+3
| | | | | | | | | | | | | | | ASTUnit::getMainBufferWithPrecompiledPreamble(). With r197755 we started reading the contents of buffer file entries, but the buffers may point to ASTReader blobs that have been disposed. Fix this by having the CompilerInstance object keep a reference to the ASTReader as well as having the ASTContext keep reference to the ExternalASTSource. This was very difficult to construct a test case for. rdar://16149782 llvm-svn: 202346
* AST: Small code cleanupDavid Majnemer2014-02-241-1/+1
| | | | | | | | Move the pointer to be adjacent to the variable instead of the type. No functional change. llvm-svn: 202089
* Sema: Make getPreferredTypeAlign respect alignments specified with an ↵David Majnemer2014-02-241-1/+6
| | | | | | | | | | | | aligned attribute on a typedef When calculating the preferred alignment of a type, consider if a alignment attribute came from a typedef declaration. If one did, do not naturally align the type. Patch by Stephan Tolksdorf, with a little tweaking and an additional testcase by me. llvm-svn: 202088
* [AArch64] Change int64_t from 'long long int' to 'long int' for AArch64 target.Kevin Qin2014-02-241-0/+13
| | | | | | | | | | Most 64-bit targets define int64_t as long int, and AArch64 should make same definition to follow LP64 model. In GNU tool chain, int64_t is defined as long int for 64-bit target. So to get consistent with GNU, it's better Changing int64_t from 'long long int' to 'long int', otherwise clang will get different name mangling suffix compared with g++. llvm-svn: 202004
* Use llvm::DeleteContainerSeconds when possibleReid Kleckner2014-02-191-5/+1
| | | | llvm-svn: 201739
* MS ABI: Mangle member pointer template argumentsReid Kleckner2014-02-051-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Member pointers are mangled as they would be represented at runtime. They can be a single integer literal, single decl, or a tuple with some more numbers tossed in. With Clang today, most of those numbers will be zero because we reject pointers to members of virtual bases. This change required moving VTableContextBase ownership from CodeGenVTables to ASTContext, because mangling now depends on vtable layout. I also hoisted the inheritance model helpers up to be inline static methods of MSInheritanceAttr. This makes the AST code that deals with member pointers much more readable. MSVC doesn't appear to have stable manglings of null member pointers: - Null data memptrs in function templates have a mangling collision with the first field of a non-polymorphic single inheritance class. - The mangling of null data memptrs changes if you add casts. - Large null function memptrs in class templates crash MSVC. Clang uses the class template mangling for null data memptrs and the function template mangling for null function memptrs to deal with this. Reviewers: majnemer Differential Revision: http://llvm-reviews.chandlerc.com/D2695 llvm-svn: 200857
* Objective-C. provide legacy encoding of *id and *Class typesFariborz Jahanian2014-01-281-1/+13
| | | | | | instead of crashing. // rdar://15824769. llvm-svn: 200338
* Rename getResultType() on function and method declarations to getReturnType()Alp Toker2014-01-251-28/+22
| | | | | | | | | | | | | | | A return type is the declared or deduced part of the function type specified in the declaration. A result type is the (potentially adjusted) type of the value of an expression that calls the function. Rule of thumb: * Declarations have return types and parameters. * Expressions have result types and arguments. llvm-svn: 200082
* ObjectiveC. When issuing property implementation isFariborz Jahanian2014-01-221-31/+34
| | | | | | | | not using backing ivar warning, ignore when property is not being synthesized (user declared its implementation @dynamic). // rdar://1583425 llvm-svn: 199820
* Correct various uses of 'argument' that in fact refer to function parametersAlp Toker2014-01-211-35/+30
| | | | | | Cleanup only. llvm-svn: 199773
* Update FunctionTypeLoc and related names to match r199686Alp Toker2014-01-211-4/+4
| | | | llvm-svn: 199699
* Rename FunctionProtoType accessors from 'arguments' to 'parameters'Alp Toker2014-01-201-25/+25
| | | | | | | | | | | | | | | | | Fix a perennial source of confusion in the clang type system: Declarations and function prototypes have parameters to which arguments are supplied, so calling these 'arguments' was a stretch even in C mode, let alone C++ where default arguments, templates and overloading make the distinction important to get right. Readability win across the board, especially in the casting, ADL and overloading implementations which make a lot more sense at a glance now. Will keep an eye on the builders and update dependent projects shortly. No functional change. llvm-svn: 199686
* Rename language option MicrosoftMode to MSVCCompatAlp Toker2014-01-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | There's been long-standing confusion over the role of these two options. This commit makes the necessary changes to differentiate them clearly, following up from r198936. MicrosoftExt (aka. fms-extensions): Enable largely unobjectionable Microsoft language extensions to ease portability. This mode, also supported by gcc, is used for building software like FreeBSD and Linux kernel extensions that share code with Windows drivers. MSVCCompat (aka. -fms-compatibility, formerly MicrosoftMode): Turn on a special mode supporting 'heinous' extensions for drop-in compatibility with the Microsoft Visual C++ product. Standards-compilant C and C++ code isn't guaranteed to work in this mode. Implies MicrosoftExt. Note that full -fms-compatibility mode is currently enabled by default on the Windows target, which may need tuning to serve as a reasonable default. See cfe-commits for the full discourse, thread 'r198497 - Move MS predefined type_info out of InitializePredefinedMacros' No change in behaviour. llvm-svn: 199209
* Delete inaccurate doc comment - isVariadic is long goneAlp Toker2014-01-121-2/+0
| | | | | | The canonical documentation in the header is up-to-date. llvm-svn: 199054
* ObjectiveC. Computation of offsets when doing @encode type encodingFariborz Jahanian2014-01-071-1/+12
| | | | | | is only used in an assert. Do not do it if assert is not on. llvm-svn: 198652
* ASTContext: Refactor implicit record creationAlp Toker2013-12-171-61/+38
| | | | | | | | Tidy up built-in record creation to reduce code duplication. Continuation of r197336. llvm-svn: 197452
* ASTContext: Declare builtin types implicitlyAlp Toker2013-12-151-184/+71
| | | | | | | | | | | | | | __builtin_va_list and friends have been showing up where they shouldn't for way to long, making unwanted appearences in -ast-print, tooling and source level visitors and even the hello world tutorial on the clang website. This commit factors down the implicit typedef and record creation facilities to ensure they're marked implicit. Also fixes a unit test that was testing incorrect behaviour, and removes old hacks in the DeclPrinter that tried to skip implicit declarations manually. llvm-svn: 197336
* Add an AdjustedType sugar node for adjusting calling conventionsReid Kleckner2013-12-051-14/+36
| | | | | | | | | | | | | | | | Summary: In general, this type node can be used to represent any type adjustment that occurs implicitly without losing type sugar. The immediate use of this is to adjust the calling conventions of member function pointer types without breaking template instantiation. Fixes PR17996. Reviewers: rsmith Differential Revision: http://llvm-reviews.chandlerc.com/D2332 llvm-svn: 196451
* ObjectiveC ARC. Better checking of toll free briding Fariborz Jahanian2013-11-201-11/+9
| | | | | | | from qualified-id objects to CF types with objc_bridge annotation. // rdar://15454846 llvm-svn: 195264
* ObjectiveC ARC. validate toll free bridge castingFariborz Jahanian2013-11-201-0/+58
| | | | | | | to or from 'id' and qualified-id types. // rdar://15454846 llvm-svn: 195178
* XCore target requires preferred alignment.Robert Lytton2013-11-121-0/+4
| | | | | | | | The xcore llvm backend does not handle 8 byte alignment viz: "%BadAlignment = alloca i64, align 8" So getPreferredTypeAlign() must never overalign. llvm-svn: 194462
* OS X 10.9+ and iOS 7+ support load/store of big atomic objects.Bob Wilson2013-11-021-0/+4
| | | | | | | | rdar://13973577 Patch by Fariborz Jahanian. llvm-svn: 193935
* Improves compatibility with cl.exe when laying out array fieldsWarren Hunt2013-11-011-2/+6
| | | | | | | | | | | | | Differential Revision: http://llvm-reviews.chandlerc.com/D2090 Clang was "improperly" over-aligning arrays with sizes are not a multiple of their alignment. This behavior was removed in microsoft 32 bit mode. In addition, after examination of ASTContext::getTypeInfoImpl, a redundant code block in MicrosoftRecordLayoutBuilder::getAdjustedFieldInfo was deleted. llvm-svn: 193898
* Add isFirstDecl to DecBase too and use it instead of getPreviousDecl() == 0.Rafael Espindola2013-10-191-4/+2
| | | | | | Redeclarable already had a isFirstDecl, but it was missing from DeclBase. llvm-svn: 193027
* Correctly skip type sugar when determining the width of an enum type. DerivedRichard Smith2013-10-151-1/+1
| | | | | | from a patch by Justin Bogner. llvm-svn: 192671
* Fix getIntegerTypeOrder() to properly handle enums by first unwrapping their ↵Ted Kremenek2013-10-101-0/+15
| | | | | | | | | | | | underlying integer type. This is a precondition for calling getIntegerRank(). Fixes an assertion failure in a test case involving vectors. Fixes <rdar://problem/15091442> Please somebody check this. llvm-svn: 192334
* Extract ABI-specific parts of MangleContext into separate classesTimur Iskhodzhanov2013-10-031-2/+2
| | | | | | Reviewed at http://llvm-reviews.chandlerc.com/D1807 llvm-svn: 191878
* Variable templates: handle instantiation of static data member templatesRichard Smith2013-09-271-8/+1
| | | | | | appropriately, especially when they appear within class templates. llvm-svn: 191548
* Fix ObjC @encode for C++ classes w/virtual bases.Eli Friedman2013-09-181-1/+2
| | | | | | PR17142. llvm-svn: 190912
* Prune "return" after llvm_unreachable(). It was redundant.NAKAMURA Takumi2013-09-161-1/+0
| | | | llvm-svn: 190774
* ASTContext.cpp: Fix a warning in r190684. [-Wcovered-switch-default]NAKAMURA Takumi2013-09-131-1/+2
| | | | llvm-svn: 190705
* Certain multi-platform languages, such as OpenCL, have the concept ofDavid Tweed2013-09-131-0/+14
| | | | | | | | | | | | | | address spaces which is both (1) a "semantic" concept and (2) possibly a hardware level restriction. It is desirable to be able to discard/merge the LLVM-level address spaces on arguments for which there is no difference to the current backend while keeping track of the semantic address spaces in a funciton prototype. To do this enable addition of the address space into the name-mangling process. Add some tests to document this behaviour against inadvertent changes. Patch by Michele Scandale! llvm-svn: 190684
* [ms-cxxabi] Implement guard variables for static initializationReid Kleckner2013-09-101-1/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | Static locals requiring initialization are not thread safe on Windows. Unfortunately, it's possible to create static locals that are actually externally visible with inline functions and templates. As a result, we have to implement an initialization guard scheme that is compatible with TUs built by MSVC, which makes thread safety prohibitively difficult. MSVC's scheme is that every function that requires a guard gets an i32 bitfield. Each static local is assigned a bit that indicates if it has been initialized, up to 32 bits, at which point a new bitfield is created. MSVC rejects inline functions with more than 32 static locals, and the externally visible mangling (?_B) only allows for one guard variable per function. On Eli's recommendation, I used MangleNumberingContext to track which bit each static corresponds to. Implements PR16888. Reviewers: rjmccall, eli.friedman Differential Revision: http://llvm-reviews.chandlerc.com/D1416 llvm-svn: 190427
* Add new methods for TargetInfo:Stepan Dyatkovskiy2013-09-051-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | getRealTypeByWidth and getIntTypeByWidth for ASTContext names are almost same(invokes new methods from TargetInfo): getIntTypeForBitwidth and getRealTypeForBitwidth. As first commit for PR16752 fix: 'mode' attribute for unusual targets doesn't work properly Description: Troubles could be happened due to some assumptions in handleModeAttr function (see SemaDeclAttr.cpp). For example, it assumes that 32 bit integer is 'int', while it could be 16 bit only. Instead of asking target: 'which type do you want to use for int32_t ?' it just hardcodes general opinion. That doesn't looks pretty correct. Please consider the next solution: 1. In Basic/TargetInfo add getIntTypeByWidth and getRealTypeByWidth virtual methods. By default current behaviour could be implemented here. 2. Fix handleModeAttr according to new methods in TargetInfo. This approach is implemented in the patch attached to this post. Fixes: 1st Commit (Current): Add new methods for TargetInfo: getRealTypeByWidth and getIntTypeByWidth for ASTContext names are almost same(invokes new methods from TargetInfo): getIntTypeForBitwidth and getRealTypeForBitwidth 2nd Commit (Next): Fix SemaDeclAttr, handleModeAttr function. llvm-svn: 190044
* Delete CC_Default and use the target default CC everywhereReid Kleckner2013-08-271-26/+12
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Makes functions with implicit calling convention compatible with function types with a matching explicit calling convention. This fixes things like calls to qsort(), which has an explicit __cdecl attribute on the comparator in Windows headers. Clang will now infer the calling convention from the declarator. There are two cases when the CC must be adjusted during redeclaration: 1. When defining a non-inline static method. 2. When redeclaring a function with an implicit or mismatched convention. Fixes PR13457, and allows clang to compile CommandLine.cpp for the Microsoft C++ ABI. Excellent test cases provided by Alexander Zinenko! Reviewers: rsmith Differential Revision: http://llvm-reviews.chandlerc.com/D1231 llvm-svn: 189412
* Revert "Implement a rudimentary form of generic lambdas."Manuel Klimek2013-08-221-11/+6
| | | | | | This reverts commit 606f5d7a99b11957e057e4cd1f55f931f66a42c7. llvm-svn: 189004
* Implement a rudimentary form of generic lambdas.Faisal Vali2013-08-221-6/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Specifically, the following features are not included in this commit: - any sort of capturing within generic lambdas - nested lambdas - conversion operator for captureless lambdas - ensuring all visitors are generic lambda aware As an example of what compiles: template <class F1, class F2> struct overload : F1, F2 { using F1::operator(); using F2::operator(); overload(F1 f1, F2 f2) : F1(f1), F2(f2) { } }; auto Recursive = [](auto Self, auto h, auto ... rest) { return 1 + Self(Self, rest...); }; auto Base = [](auto Self, auto h) { return 1; }; overload<decltype(Base), decltype(Recursive)> O(Base, Recursive); int num_params = O(O, 5, 3, "abc", 3.14, 'a'); Please see attached tests for more examples. Some implementation notes: - Add a new Declarator context => LambdaExprParameterContext to clang::Declarator to allow the use of 'auto' in declaring generic lambda parameters - Augment AutoType's constructor (similar to how variadic template-type-parameters ala TemplateTypeParmDecl are implemented) to accept an IsParameterPack to encode a generic lambda parameter pack. - Add various helpers to CXXRecordDecl to facilitate identifying and querying a closure class - LambdaScopeInfo (which maintains the current lambda's Sema state) was augmented to house the current depth of the template being parsed (id est the Parser calls Sema::RecordParsingTemplateParameterDepth) so that Sema::ActOnLambdaAutoParameter may use it to create the appropriate list of corresponding TemplateTypeParmDecl for each auto parameter identified within the generic lambda (also stored within the current LambdaScopeInfo). Additionally, a TemplateParameterList data-member was added to hold the invented TemplateParameterList AST node which will be much more useful once we teach TreeTransform how to transform generic lambdas. - SemaLambda.h was added to hold some common lambda utility functions (this file is likely to grow ...) - Teach Sema::ActOnStartOfFunctionDef to check whether it is being called to instantiate a generic lambda's call operator, and if so, push an appropriately prepared LambdaScopeInfo object on the stack. - Teach Sema::ActOnStartOfLambdaDefinition to set the return type of a lambda without a trailing return type to 'auto' in C++1y mode, and teach the return type deduction machinery in SemaStmt.cpp to process either C++11 and C++14 lambda's correctly depending on the flag. - various tests were added - but much more will be needed. A greatful thanks to all reviewers including Eli Friedman, James Dennett and the ever illuminating Richard Smith. And yet I am certain that I have allowed unidentified bugs to creep in; bugs, that I will do my best to slay, once identified! Thanks! llvm-svn: 188977
* [Mips][msa] Add support for halfJack Carter2013-08-151-0/+5
| | | | | | | | | Add support for half (a.k.a. __fp16) in builtin descriptions. The second argument to BUILTIN() now accepts 'h' to represent half. Patch by Daniel Sanders llvm-svn: 188464
* Fix alignof computation of large arrays on x86_64.Rafael Espindola2013-08-081-9/+4
| | | | | | | | | | | We were exposing the extra alignment given to large arrays. The new behavior matches gcc, which is a good thing since this is a gcc extension. Thanks to Joerg Sonnenberger for noticing it. While at it, centralize the method description in the .h file. llvm-svn: 187999
* Correctly allign arrays on 32 bit systems.Rafael Espindola2013-08-071-7/+8
| | | | | | | | | | | Before this patch we would align long long int big[1024]; to 4 bytes on 32 bit systems. The problem is that we were only looking at the element type when getLargeArrayMinWidth returned non zero. llvm-svn: 187897
* Patch to fix doxygen trailing comments for ObjectiveC methods.Fariborz Jahanian2013-08-071-1/+1
| | | | | | // rdar://14258334 llvm-svn: 187893
* Patch to fix doxygen trailing comments for ObjectiveC properties.Fariborz Jahanian2013-08-061-1/+2
| | | | | | // rdar://14258334 llvm-svn: 187835
* Started implementing variable templates. Top level declarations should be ↵Larisse Voufo2013-08-061-22/+35
| | | | | | fully supported, up to some limitations documented as FIXMEs or TODO. Static data member templates work very partially. Static data member templates of class templates need particular attention... llvm-svn: 187762
* AST: Treat inline function declarations in -fms-compatibility as if it were ↵David Majnemer2013-08-011-2/+3
| | | | | | | | in C++ when in C mode This essentially fixes PR16766. llvm-svn: 187586
* [libclang] Remove comma from the blacklist of characters that prevent a ↵Argyrios Kyrtzidis2013-07-261-1/+1
| | | | | | | | | comment to be attached to a decl. It's common to use an availability function macro at the start of a decl. rdar://13965065 llvm-svn: 187230
* Documentation parsing: if typedef name is being declaredFariborz Jahanian2013-07-241-1/+7
| | | | | | | | via a macro, try using declaration's starting location. This is improvement over not having a valid location and dropping comment altogether. // rdar://14348912 llvm-svn: 187085
OpenPOWER on IntegriCloud