summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ASTContext.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* ObjC migrator: finding conforming protocolFariborz Jahanian2013-07-151-0/+32
| | | | | | candidates for each class. wip. llvm-svn: 186349
* Add 'static' and 'const' qualifiers to some arrays of strings.Craig Topper2013-07-151-2/+2
| | | | llvm-svn: 186314
* Simplify getTypeInfoImpl handling of 'non-canonical unless dependent' types.David Blaikie2013-07-131-26/+4
| | | | | | | | | These types are not dependent in this context, so just look through the sugar. Review by Richard Smith & Eli Friedman. llvm-svn: 186260
* fixes a typo caught by Jordan.Fariborz Jahanian2013-07-121-1/+1
| | | | llvm-svn: 186171
* Objective-C: Produce gcc compatible encoding ofFariborz Jahanian2013-07-121-0/+14
| | | | | | | ivar type in meta-data while preventing recursive encoding in a corner case. // rdar://14408244 llvm-svn: 186169
* More local mangling fixes.Eli Friedman2013-07-101-14/+9
| | | | | | | | | | | | Compute mangling numbers for externally visible local variables and tags. Change the mangler to consistently use discriminators where necessary. Tweak the scheme we use to number decls which are not externally visible to avoid unnecessary discriminators in common cases now that we request them more consistently. Fixes <rdar://problem/14204721>. llvm-svn: 185986
* Fix mangling for block literals.Eli Friedman2013-07-011-5/+2
| | | | | | | | | | | | | | | Blocks, like lambdas, can be written in contexts which are required to be treated as the same under ODR. Unlike lambdas, it isn't possible to actually take the address of a block, so the mangling of the block itself doesn't matter. However, objects like static variables inside a block do need to be mangled in a consistent way. There are basically three components here. One, block literals need a consistent numbering. Two, objects/types inside a block literal need to be mangled using it. Three, objects/types inside a block literal need to have their linkage computed correctly. llvm-svn: 185372
* Delete dead code.Eli Friedman2013-06-271-9/+0
| | | | llvm-svn: 185101
* Rewrite record layout for ms_struct structs.Eli Friedman2013-06-261-32/+0
| | | | | | | | | | | | | | The old implementation of ms_struct in RecordLayoutBuilder was a complete mess: it depended on complicated conditionals which didn't really reflect the underlying logic, and placed a burden on users of the resulting RecordLayout. This commit rips out almost all of the old code, and replaces it with simple checks in RecordLayoutBuilder::LayoutBitField. This commit also fixes <rdar://problem/14252115>, a bug where class inheritance would cause us to lay out bitfields incorrectly. llvm-svn: 185018
* Don't try to get the layout of an invalid decl in getDeclAlign.Matt Beaumont-Gay2013-06-251-17/+20
| | | | | | | | | | | When the decl that we're getting alignment for is a FieldDecl, and the field's parent record is invalid, skip the actual field alignment calculation (and return 1-byte alignment in the general case). Also, assert in in getASTRecordLayout that the decl is valid. This was inspired by PR16292; see also r184581 and r184751. llvm-svn: 184883
* [AST] Introduce a new DecayedType sugar nodeReid Kleckner2013-06-241-16/+44
| | | | | | | | | | | | | | The goal of this sugar node is to be able to look at an arbitrary FunctionType and tell if any of the parameters were decayed from an array or function type. Ultimately this is necessary to implement Microsoft's C++ name mangling scheme, which mangles decayed arrays differently from normal pointers. Reviewers: rsmith Differential Revision: http://llvm-reviews.chandlerc.com/D1014 llvm-svn: 184763
* Add an assert() suggested by Richard.Nico Weber2013-06-211-0/+1
| | | | llvm-svn: 184516
* Fix a crash with __flaot128 noticed by Eli.Nico Weber2013-06-201-6/+6
| | | | llvm-svn: 184498
* Lazily provide a __float128 dummy type in -std=gnu++11 mode.Nico Weber2013-06-201-1/+14
| | | | | | This is needed to parse libstdc++ 4.7's type_traits, see PR13530. llvm-svn: 184476
* [AST] Don't include RecursiveASTVisitor.h in ASTContext.hReid Kleckner2013-06-171-0/+95
| | | | | | | | | | | | | | | | | | | | The untemplated implementation of getParents() doesn't need to be in a header file. RecursiveASTVisitor.h is full of repeated macro expansion. Moving this include to ASTContext.cpp speeds up compilation of LambdaMangleContext.cpp, a small C++ file with few includes, from 3.7s to 2.8s for me locally. I haven't measured a full build, but it can't hurt. I had to fix a few static analyzer files that were depending on transitive includes of C++ AST headers. Reviewers: rsmith, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D982 llvm-svn: 184075
* Use FPT::getArgTypes() instead of manually building ArrayRefsReid Kleckner2013-06-101-13/+4
| | | | | | | | Made significantly easier with git-clang-format. Differential Revision: http://llvm-reviews.chandlerc.com/D947 llvm-svn: 183694
* Revert "[Sema] Make FunctionType's TSI use unadjusted argument types"Reid Kleckner2013-06-081-15/+0
| | | | | | | | | This reverts commit r183614. It broke test/Sema/block-printf-attribute-1.c on non-Windows platforms, and the fix is not trivial. llvm-svn: 183616
* [Sema] Make FunctionType's TSI use unadjusted argument typesReid Kleckner2013-06-081-0/+15
| | | | | | | | | | | | | | | | This helps preserve the type-as-written in the AST, which we need for MSVC mangling. In particular, we need to preserve the types of array parameters in function pointer types. The essence of this change is: - QualType ArgTy = Param->getType(); + QualType ArgTy = Param->getTypeSourceInfo()->getType(); ... followed by the adjustment in ActOnFunctionDeclarator(). Differential Revision: http://llvm-reviews.chandlerc.com/D883 llvm-svn: 183614
* Model temporary lifetime-extension explicitly in the AST. Use this model toRichard Smith2013-06-051-0/+13
| | | | | | | | | handle temporaries which have been lifetime-extended to static storage duration within constant expressions. This correctly handles nested lifetime extension (through reference members of aggregates in aggregate initializers) but non-constant-expression emission hasn't yet been updated to do the same. llvm-svn: 183283
* Objective-C encoding. Fixes up encodeing forFariborz Jahanian2013-06-041-6/+3
| | | | | | | arrays of empty structs. // rdar://14053082 (also pr13062). llvm-svn: 183234
* Fix memory leak for APValues that do memory allocation.Manuel Klimek2013-06-031-5/+7
| | | | | | | | | This patch ensures that APValues are deallocated with the ASTContext by registering a deallocation function for APValues to the ASTContext. Original version of the patch by James Dennett. llvm-svn: 183101
* Remove unused field.Rafael Espindola2013-05-291-2/+1
| | | | llvm-svn: 182874
* Patch to issue error when target of MacOS and iOS Fariborz Jahanian2013-05-281-0/+14
| | | | | | | does not support large load/store of atomic objects. // rdar://13973577 llvm-svn: 182781
* Fix a crash when we were trying to compute the linkage too early.Rafael Espindola2013-05-281-2/+1
| | | | llvm-svn: 182773
* In -ast-dump, only dump comments when dumping the actual Decl to which theyRichard Smith2013-05-211-0/+5
| | | | | | | | attach, rather than merging all comments on the declaration chain. This gives a more faithful dump, and has the side benefit of unbreaking uses of dump() from within AST deserialization (where the redeclaration chain may not be sane). llvm-svn: 182350
* Add static_cast to assertion to silence sign/unsigned comparison warning.Richard Trieu2013-05-141-1/+2
| | | | llvm-svn: 181849
* When computing the size of large arrays, use char units instead of bits.Richard Trieu2013-05-141-2/+21
| | | | | | | This prevents an overflow and assertion when the number of bits cannot be stored in 64-bits. llvm-svn: 181839
* Objective-C error recovery. This patch makes a quickFariborz Jahanian2013-05-131-0/+2
| | | | | | | | | recovery form duplicate method definition error thus preventing doc parsing to loop trying to find comment for the invalid redefinition in a previous declaration. // rdar://13836387 llvm-svn: 181710
* Fix a gcc warning.Rafael Espindola2013-05-131-0/+2
| | | | | | | | | In r181677 I removed this llvm_unreachable and it introduced a gcc warning. Add it back. Thanks to Patrik Hägglund for noticing it. llvm-svn: 181704
* Cleanup handling of UniqueExternalLinkage.Rafael Espindola2013-05-131-45/+30
| | | | | | | | | | | | | This patch renames getLinkage to getLinkageInternal. Only code that needs to handle UniqueExternalLinkage specially should call this. Linkage, as defined in the c++ standard, is provided by getFormalLinkage. It maps UniqueExternalLinkage to ExternalLinkage. Most places in the compiler actually want isExternallyVisible, which handles UniqueExternalLinkage as internal. llvm-svn: 181677
* C++1y deduced return types: when we deduce a return type for a function whichRichard Smith2013-05-111-2/+10
| | | | | | | we loaded from PCH, if we're building another PCH, create an update record to patch the return type of the earlier declaration. llvm-svn: 181659
* Add support for __wchar_t in -fms-extensions mode.Hans Wennborg2013-05-101-7/+11
| | | | | | | | | | | | | | | | | MSVC provides __wchar_t. This is the same as the built-in wchar_t type from C++, but it is also available with -fno-wchar and in C. The commit changes ASTContext to have two different types for this: - WCharTy is the built-in type used for wchar_t in C++ and __wchar_t. - WideCharTy is the type of a wide character literal. In C++ this is the same as WCharTy, and in C it is an integer type compatible with the type in <stddef.h>. This fixes PR15815. llvm-svn: 181587
* Objective-C: Correctly encode 'retain' and 'copy' for readonly properties.Nico Weber2013-05-081-0/+4
| | | | | | | | | | clang would omit 'C' for 'copy' properties and '&' for 'retain' properties if the property was also 'readonly'. Fix this, which makes clang match gcc4.2's behavior. Fixes PR15928. llvm-svn: 181491
* Grab-bag of bit-field fixes:John McCall2013-05-061-1/+1
| | | | | | | | | | | | | | - References to ObjC bit-field ivars are bit-field lvalues; fixes rdar://13794269, which got me started down this. - Introduce Expr::refersToBitField, switch a couple users to it where semantically important, and comment the difference between this and the existing API. - Discourage Expr::getBitField by making it a bit longer and less general-sounding. - Lock down on const_casts of bit-field gl-values until we hear back from the committee as to whether they're allowed. llvm-svn: 181252
* Add SystemZ supportUlrich Weigand2013-05-061-0/+76
| | | | | | | | | | | | | | This patch then adds all the usual platform-specific pieces for SystemZ: driver support, basic target info, register names and constraints, ABI info and vararg support. It also adds new tests to verify pre-defined macros and inline asm, and updates a test for the minimum alignment change. This version of the patch incorporates feedback from reviews by Eric Christopher and John McCall. Thanks to all reviewers! Patch by Richard Sandiford. llvm-svn: 181211
* Allow targets to define minimum alignment for global variablesUlrich Weigand2013-05-061-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds a new common code feature that allows platform code to request minimum alignment of global symbols. The background for this is that on SystemZ, the most efficient way to load addresses of global symbol is the LOAD ADDRESS RELATIVE LONG (LARL) instruction. This instruction provides PC-relative addressing, but only to *even* addresses. For this reason, existing compilers will guarantee that global symbols are always aligned to at least 2. [ Since symbols would otherwise already use a default alignment based on their type, this will usually only affect global objects of character type or character arrays. ] GCC also allows creating symbols without that extra alignment by using explicit "aligned" attributes (which then need to be used on both definition and each use of the symbol). To enable support for this with Clang, this patch adds a TargetInfo::MinGlobalAlign variable that provides a global minimum for the alignment of every global object (unless overridden via explicit alignment attribute), and adds code to respect this setting. Within this patch, no platform actually sets the value to anything but the default 1, resulting in no change in behaviour on any existing target. This version of the patch incorporates feedback from reviews by Eric Christopher and John McCall. Thanks to all reviewers! Patch by Richard Sandiford. llvm-svn: 181210
* Reverting r181004 since it has broken test/Sema/wchar.c.Aaron Ballman2013-05-041-3/+2
| | | | llvm-svn: 181122
OpenPOWER on IntegriCloud