summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
Commit message (Collapse)AuthorAgeFilesLines
...
* PR9882: Fix noexcept to deal with dependent new, delete, calls, andEli Friedman2011-05-111-17/+24
| | | | | | dynamic_cast correctly. llvm-svn: 131177
* Support pack pragma and ms_struct attributes. // rdar://8823265Fariborz Jahanian2011-05-101-0/+7
| | | | llvm-svn: 131142
* 'long long' requires special treatment in ms_structFariborz Jahanian2011-05-091-0/+10
| | | | | | structs (impacts 32-bit only though). llvm-svn: 131103
* Clean up trivial default constructors now.Alexis Hunt2011-05-091-18/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | hasTrivialDefaultConstructor() really really means it now. Also implement a fun standards bug regarding aggregates. Doug, if you'd like, I can un-implement that bug if you think it is truly a defect. The bug is that non-special-member constructors are never considered user-provided, so the following is an aggregate: struct foo { foo(int); }; It's kind of bad, but the solution isn't obvious - should struct foo { foo (int) = delete; }; be an aggregate or not? Lastly, add a missing initialization to FunctionDecl. llvm-svn: 131101
* Rename "hasTrivialConstructor" to "hasTrivialDefaultConstructor" andAlexis Hunt2011-05-094-42/+45
| | | | | | | modify the semantics slightly to accomodate default constructors (I hope). llvm-svn: 131087
* Implement a minor optimization by not introducing declarations intoDouglas Gregor2011-05-061-4/+4
| | | | | | DeclContext's lookup table when they aren't in any identifier namespace. llvm-svn: 131037
* In ms_struct structs, Establish a new alignment for a Fariborz Jahanian2011-05-061-3/+7
| | | | | | non-bitfield following a bitfield if size of their types differ. llvm-svn: 131032
* Establish a new alignment for an ms_struct bitfield followingFariborz Jahanian2011-05-062-1/+16
| | | | | | a non-bitfield if size of their types differ. llvm-svn: 131023
* Modify some deleted function methods to better reflect reality:Alexis Hunt2011-05-064-7/+18
| | | | | | | | | | | | | | | | | | | | - New isDefined() function checks for deletedness - isThisDeclarationADefinition checks for deletedness - New doesThisDeclarationHaveABody() does what isThisDeclarationADefinition() used to do - The IsDeleted bit is not propagated across redeclarations - isDeleted() now checks the canoncial declaration - New isDeletedAsWritten() does what it says on the tin. - isUserProvided() now correct (thanks Richard!) This fixes the bug that we weren't catching void foo() = delete; void foo() {} as being a redefinition. llvm-svn: 131013
* Revert r130912 in order to approach defaulted functions from the otherAlexis Hunt2011-05-062-7/+4
| | | | | | | direction and not introduce things in the wrong place three different times. llvm-svn: 130968
* Implement support for C++0x alias templates.Richard Smith2011-05-056-28/+102
| | | | llvm-svn: 130953
* __alignof attribute on the field must considerFariborz Jahanian2011-05-051-0/+4
| | | | | | packed attribute on the field. //rdar://9217290 llvm-svn: 130948
* Scoped enumerations should not be treated as integer types (in the CDouglas Gregor2011-05-051-3/+3
| | | | | | | | sense). Fixes <rdar://problem/9366066> by eliminating an inconsistency between C++ overloading (which handled scoped enumerations correctly) and C binary operator type-checking (which didn't). llvm-svn: 130924
* Implement some framework for defaulted constructors.Alexis Hunt2011-05-052-4/+7
| | | | | | There's some unused stuff for now. llvm-svn: 130912
* More ms_struct bitfield stuff:Fariborz Jahanian2011-05-042-1/+33
| | | | | | | | Adjacent bit fields are packed into the same 1-, 2-, or 4-byte allocation unit if the integral types are the same size. // rdar://8823265. llvm-svn: 130851
* From Vassil Vassilev:Axel Naumann2011-05-041-0/+2
| | | | | | Like in r126648, provide (empty) default implementation for pure virtual getMemoryBufferSizes(). Not all use cases have meaningful implementations. llvm-svn: 130838
* Type prefixes of unresolved-names should only be mangled as unresolved-typesJohn McCall2011-05-041-15/+92
| | | | | | | | if they match that production, i.e. if they're template type parameters or decltypes (or, as an obvious case not yet described in the ABI document, if they're template template parameters applied to template arguments). llvm-svn: 130824
* Only the first zero-length bitfield decides alignment ofFariborz Jahanian2011-05-032-3/+6
| | | | | | | the followup data member in an ms_struct struct. // rdar:// 8823265 llvm-svn: 130795
* Finish off rules for z-length bitfields in ms_structFariborz Jahanian2011-05-032-18/+36
| | | | | | structs. // rdar://8823265 llvm-svn: 130783
* More rule enforcement of zero bitfields for ms_struct.Fariborz Jahanian2011-05-023-3/+26
| | | | llvm-svn: 130696
* I updated this constructor's interface, and didn't have to fix anyChandler Carruth2011-05-021-20/+0
| | | | | | callers. Shockingly enough, *there are none*! llvm-svn: 130677
* Remove dead variable caught by GCC.Nick Lewycky2011-05-021-3/+0
| | | | llvm-svn: 130676
* Nuke stale code for separately importing the qualifer -- it's just partChandler Carruth2011-05-021-7/+0
| | | | | | of the QualifierLoc, and that's all we need to import now. llvm-svn: 130675
* Add an optional field attached to a DeclRefExpr which points back to theChandler Carruth2011-05-013-12/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Decl actually found via name lookup & overload resolution when that Decl is different from the ValueDecl which is actually referenced by the expression. This can be used by AST consumers to correctly attribute references to the spelling location of a using declaration, and otherwise gain insight into the name resolution performed by Clang. The public interface to DRE is kept as narrow as possible: we provide a getFoundDecl() which always returns a NamedDecl, either the ValueDecl referenced or the new, more precise NamedDecl if present. This way AST clients can code against getFoundDecl without know when exactly the AST has a split representation. For an example of the data this provides consider: % cat x.cc namespace N1 { struct S {}; void f(const S&); } void test(N1::S s) { f(s); using N1::f; f(s); } % ./bin/clang -fsyntax-only -Xclang -ast-dump x.cc [...] void test(N1::S s) (CompoundStmt 0x5b02010 <x.cc:5:20, line:9:1> (CallExpr 0x5b01df0 <line:6:3, col:6> 'void' (ImplicitCastExpr 0x5b01dd8 <col:3> 'void (*)(const struct N1::S &)' <FunctionToPointerDecay> (DeclRefExpr 0x5b01d80 <col:3> 'void (const struct N1::S &)' lvalue Function 0x5b01a20 'f' 'void (const struct N1::S &)')) (ImplicitCastExpr 0x5b01e20 <col:5> 'const struct N1::S' lvalue <NoOp> (DeclRefExpr 0x5b01d58 <col:5> 'N1::S':'struct N1::S' lvalue ParmVar 0x5b01b60 's' 'N1::S':'struct N1::S'))) (DeclStmt 0x5b01ee0 <line:7:3, col:14> 0x5b01e40 "UsingN1::;") (CallExpr 0x5b01fc8 <line:8:3, col:6> 'void' (ImplicitCastExpr 0x5b01fb0 <col:3> 'void (*)(const struct N1::S &)' <FunctionToPointerDecay> (DeclRefExpr 0x5b01f80 <col:3> 'void (const struct N1::S &)' lvalue Function 0x5b01a20 'f' 'void (const struct N1::S &)' (UsingShadow 0x5b01ea0 'f'))) (ImplicitCastExpr 0x5b01ff8 <col:5> 'const struct N1::S' lvalue <NoOp> (DeclRefExpr 0x5b01f58 <col:5> 'N1::S':'struct N1::S' lvalue ParmVar 0x5b01b60 's' 'N1::S':'struct N1::S')))) Now we can tell that the second call is 'using' (no pun intended) the using declaration, and *which* using declaration it sees. Without this, we can mistake calls that go through using declarations for ADL calls, and have no way to attribute names looked up with using declarations to the appropriate UsingDecl. llvm-svn: 130670
* Store a parameter index and function prototype depth in everyJohn McCall2011-05-012-24/+152
| | | | | | | | | | parameter node and use this to correctly mangle parameter references in function template signatures. A follow-up patch will improve the storage usage of these fields; here I've just done the lazy thing. llvm-svn: 130669
* Remove the NameQualifier struct, which was just a wrapper aroundChandler Carruth2011-05-011-4/+4
| | | | | | | | | NestedNameSpecifierLoc. It predates when we had such an object. Reference the NNSLoc directly in DREs, and embed it directly into the MemberNameQualifier struct. llvm-svn: 130668
* Several cosmetic changes, no functionality changed.Chandler Carruth2011-05-011-9/+4
| | | | | | | | | | Mostly trailing whitespace so that me editor nuking it doesn't muddy the waters of subsequent commits that do change functionality. Also nukes a stray statement that was harmless but redundant that I introduced in r130666. llvm-svn: 130667
* Move the state bits in DeclRefExpr out of the pointer union and intoChandler Carruth2011-05-011-10/+10
| | | | | | | | | | | | | | | a bitfield in the base class. DREs weren't using any bits here past the normal Expr bits, so we have plenty of room. This makes the common case of getting a Decl out of a DRE no longer need to do any masking etc. Also, while here, clean up code to use the accessor methods rather than directly poking these bits, and provide a nice comment for DREs that includes the information previously attached to the bits going into the pointer union. No functionality changed here, but DREs should be a tad faster now. llvm-svn: 130666
* Remove a few more bogus returns when the switch covers all theChandler Carruth2011-05-011-4/+3
| | | | | | | | | enumerators. Also remove a default that led to llvm_unreachable to make another switch warn if any enumerators fail to be covered. llvm-svn: 130646
* Remove another default and a *completely* bogus return from a switchChandler Carruth2011-05-011-2/+2
| | | | | | | | over type traits. Add the missing trait from this switch that Clang's warning uncovered. llvm-svn: 130645
* Remove the type traits UTT_IsLvalueExpr and UTT_IsRvalueExpr.Chandler Carruth2011-05-011-2/+0
| | | | | | | | | | | As might be surmised from their names, these aren't type traits, they're expression traits. Amazingly enough, they're expression traits that we have, and fully implement. These "type" traits are even parsed from the same tokens as the expression traits. Luckily, the parser only tried the expression trait parsing for these tokens, so this was all just a pile of dead code. llvm-svn: 130643
* Compress some bits. Only matters for MSVC, or if we everJohn McCall2011-05-011-1/+1
| | | | | | | devirtualize Decl (because bits can't get laid out in base classes if the base is POD). llvm-svn: 130632
* Switch the interface name for both TemplateTypeParmType andChandler Carruth2011-05-012-2/+2
| | | | | | | | | | | SubstTemplateTypeParmType to be 'getIdentifier' instead of 'getName' as it returns an identifier. This makes them more consistent with the NamedDecl interface. Also, switch back to using this interface to acquire the indentifier in TypePrinter.cpp. I missed this in r130628. llvm-svn: 130629
* Re-applies the patch first applied way back in r106099, withChandler Carruth2011-05-015-14/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | accompanying fixes to make it work today. The core of this patch is to provide a link from a TemplateTypeParmType back to the TemplateTypeParmDecl node which declared it. This in turn provides much more precise information about the type, where it came from, and how it functions for AST consumers. To make the patch work almost a year after its first attempt, it needed serialization support, and it now retains the old getName() interface. Finally, it requires us to not attempt to instantiate the type in an unsupported friend decl -- specifically those coming from template friend decls but which refer to a specific type through a dependent name. A cleaner representation of the last item would be to build FriendTemplateDecl nodes for these, storing their template parameters etc, and to perform proper instantation of them like any other template declaration. They can still be flagged as unsupported for the purpose of access checking, etc. This passed an asserts-enabled bootstrap for me, and the reduced test case mentioned in the original review thread no longer causes issues, likely fixed at somewhere amidst the 24k revisions that have elapsed. llvm-svn: 130628
* Remove unused function.Benjamin Kramer2011-04-301-14/+0
| | | | llvm-svn: 130622
* PR9792: Make sure to use the right definition of wchar_t when the defaultEli Friedman2011-04-301-1/+1
| | | | | | wchar_t is an unsigned type. llvm-svn: 130620
* When comparing parameters of reference-to-qualified type duringDouglas Gregor2011-04-301-0/+12
| | | | | | | | | partial ordering of function templates, use a simple superset relationship rather than the convertibility-implying isMoreQualifiedThan/compatibilyIncludes relationship. Fixes partial ordering between references and address-space-qualified references. llvm-svn: 130612
* Make type-traits reflect that Clang's vectors act like scalar types.Chandler Carruth2011-04-301-4/+8
| | | | llvm-svn: 130606
* Switch the type-trait like APIs on the AST to only check for incompleteChandler Carruth2011-04-301-5/+28
| | | | | | | | | | | types after looking through arrays. Arrays with an unknown bound seem to be specifically allowed in the library type traits in C++0x, and GCC's builtin __is_trivial returns 'true' for the type 'int[]'. Now Clang agrees with GCC about __is_trivial here. Also hardens these methods against dependent types by just returning false. llvm-svn: 130605
* Rename the last '[hH]asStandardLayout' entites to '[iI]sStandardLayout'Chandler Carruth2011-04-302-16/+16
| | | | | | | based on Doug's preferences when we discussed this in IRC. This brings the wording more in line with the standard. llvm-svn: 130603
* Hoist all of the type-specific trait logic for __is_standard_layout intoChandler Carruth2011-04-301-14/+30
| | | | | | | | | | | | a Type method isStandardLayoutType, to keep our user API matching the type trait builtins as closely as possible. Also, implement it in terms of other Type APIs rather than in terms of other type traits. This models the implementation on that of isLiteralType and isTrivialType. There remain some common problems with these traits still, so this is a bit of a WIP. However, we can now fix all of these traits at the same time and in a consistent manner. llvm-svn: 130602
* Completely re-implement the core logic behind the __is_standard_layoutChandler Carruth2011-04-302-90/+103
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | type trait. The previous implementation suffered from several problems: 1) It implemented all of the logic in RecordType by walking over every base and field in a CXXRecordDecl and validating the constraints of the standard. This made for very straightforward code, but is extremely inefficient. It also is conceptually wrong, the logic tied to the C++ definition of standard-layout classes should be in CXXRecordDecl, not RecordType. 2) To address the performance problems with #1, a cache bit was added to CXXRecordDecl, and at the completion of every C++ class, the RecordType was queried to determine if it was a standard layout class, and that state was cached. Two things went very very wrong with this. First, the caching version of the query *was never called*. Even within the recursive steps of the walk over all fields and bases the caching variant was not called, making each query a full *recursive* walk. Second, despite the cache not being used, it was computed for every class declared, even when the trait was never used in the program. This probably significantly regressed compile time performance for edge-case files. 3) An ASTContext was required merely to query the type trait because querying it performed the actual computations. 4) The caching bit wasn't managed correctly (uninitialized). The new implementation follows the system for all the other traits on C++ classes by encoding all the state needed in the definition data and building up the trait incrementally as each base and member are added to the definition of the class. The idiosyncracies of the specification of standard-layout classes requires more state than I would like; currently 5 bits. I could eliminate one of the bits easily at the expense of both clarity and resilience of the code. I might be able to eliminate one of the other bits by computing its state in terms of other state bits in the definition. I've already done that in one place where there was a fairly simple way to achieve it. It's possible some of the bits could be moved out of the definition data and into some other structure which isn't serialized if the serialized bloat is a problem. That would preclude serialization of a partial class declaration, but that's likely already precluded. Comments on any of these issues welcome. llvm-svn: 130601
* Initialize HasStandardLayout.Benjamin Kramer2011-04-301-1/+1
| | | | llvm-svn: 130600
* Remove comments about __int8 and friends from the mangler. Turns out we don'tCharles Davis2011-04-291-7/+0
| | | | | | | actually have to implement them, since in modern versions of MSVC they're aliases to the standard C types. llvm-svn: 130509
* Relax the non-POD memset warning to use the less restrictive C++11Chandler Carruth2011-04-291-0/+46
| | | | | | | | | | | definition of POD. Specifically, this allows certain non-aggregate types due to their data members being private. The representation of C++11 POD testing is pretty gross. Any suggestions for improvements there are welcome. Especially the name 'isCXX11PODType()' seems truly unfortunate. llvm-svn: 130492
* Don't assume that the AST methods will only be invoked on C++ types.Chandler Carruth2011-04-291-23/+26
| | | | | | | | | | Teaches isLiteralType and isTrivialType to behave plausibly and most importantly not crash on normal RecordDecls. Sadly I have no real way to test this. I stumbled onto it by mis-implementing a warning. llvm-svn: 130483
* ms_struct patch for initialization and field access irgen.Fariborz Jahanian2011-04-281-2/+13
| | | | | | // rdar://8823265 - wip. llvm-svn: 130451
* Silence more -Wnon-pod-memset given its current implementation. I may beChandler Carruth2011-04-281-1/+1
| | | | | | | able to revert these based on a patch I'm working on, but no reason for people to be spammed with warnings in the interim. llvm-svn: 130394
* Enhance clang_getCXTUResourceUsage() to report the amount of memory used by ↵Ted Kremenek2011-04-281-0/+16
| | | | | | ASTContext's side tables. llvm-svn: 130383
* Implement the mangling for non-ADL call expressions that we justJohn McCall2011-04-281-2/+47
| | | | | | worked out. llvm-svn: 130376
OpenPOWER on IntegriCloud