summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Decl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* RP18408: If a member template is used as a template template argument, it doesRichard Smith2014-01-081-1/+8
| | | | | | not cause the template specialization to have no linkage. llvm-svn: 198726
* Highlight the previous underlying enum type when diagnosing a mismatchAlp Toker2014-01-061-0/+6
| | | | | | | | | | | | | | enum-scoped.cpp:93:6: error: enumeration redeclared with different underlying type 'short' (was 'int') enum Redeclare6 : short; ^ enum-scoped.cpp:92:6: note: previous declaration is here enum Redeclare6 : int; ^ ~~~ The redeclaration source range is still missing but this is a step forward, potentially edging towards a FixIt. llvm-svn: 198601
* Removed one of the string versions of getQualifiedNameAsString, and switched ↵Aaron Ballman2014-01-031-5/+1
| | | | | | over to using printQualifiedName where possible. No functional changes intended. llvm-svn: 198433
* Replacing calls to getAttr with calls to hasAttr for clarity. No functional ↵Aaron Ballman2013-12-191-1/+1
| | | | | | change intended -- this only replaces Boolean uses of getAttr. llvm-svn: 197648
* Fix pr18174.Rafael Espindola2013-12-081-1/+1
| | | | | | | | | | | | | | | Clang outputs LLVM one top level decl at a time. This combined with the visibility computation code looking for the newest NamespaceDecl would cause it to produce different results for nested namespaces. The two options for producing consistent results are * Delay codegen of anything inside a namespace until the end of the file. * Don't look for the newest NamespaceDecl. This patch implements the second option. This matches the gcc behavior too. llvm-svn: 196712
* Add an AdjustedType sugar node for adjusting calling conventionsReid Kleckner2013-12-051-5/+2
| | | | | | | | | | | | | | | | 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
* Don't call getMostRecentDecl when we know we have it.Rafael Espindola2013-11-261-11/+22
| | | | | | On a Release build this takes the testcase in pr18055 from 0m3.892s to 0m1.452s. llvm-svn: 195768
* Add class-specific operator new to Decl hierarchy. This guarantees that DeclsRichard Smith2013-11-221-92/+66
| | | | | | | | | | | | | can't accidentally be allocated the wrong way (missing prefix data for decls from AST files, for instance) and simplifies the CreateDeserialized functions a little. An extra DeclContext* parameter to the not-from-AST-file operator new allows us to ensure that we don't accidentally call the wrong one when deserializing (when we don't have a DeclContext), allows some extra checks, and prepares for some planned modules-related changes to Decl allocation. No functionality change intended. llvm-svn: 195426
* Added warning on structures/unions that are empty or contain onlySerge Pavlov2013-11-141-19/+4
| | | | | | | | | | bit fields of zero size. Warnings are generated in C++ mode and if only such type is defined inside extern "C" block. The patch fixed PR5065. Differential Revision: http://llvm-reviews.chandlerc.com/D2151 llvm-svn: 194653
* C++1y sized deallocation: if we have a use, but not a definition, of a sizedRichard Smith2013-11-051-1/+33
| | | | | | | | | | | | | deallocation function (and the corresponding unsized deallocation function has been declared), emit a weak discardable definition of the function that forwards to the corresponding unsized deallocation. This allows a C++ standard library implementation to provide both a sized and an unsized deallocation function, where the unsized one does not just call the sized one, for instance by putting both in the same object file within an archive. llvm-svn: 194055
* Wraps lazily generated builtins in an extern "C" contextWarren Hunt2013-11-011-22/+17
| | | | | | | | | | | | | Differential Revision: http://llvm-reviews.chandlerc.com/D2082 Adds a lang_c LinkageSpecDecl to lazily generated builtins. This enforces correct behavior for builtins in a variety of cases without special treatment elsewhere within the compiler (special treatment is removed by the patch). It also allows for C++ overloads of builtin functions, which Microsoft uses in their headers e.g. _InterlockedExchangeAdd is an extern C builtin for the long type but an inline wrapper for int type. llvm-svn: 193896
* AST: Mangle fields in anonymous structs/unionsDavid Majnemer2013-10-231-4/+4
| | | | | | | | | | | | | The Itanium mangler couldn't cope with mangling an IndirectFieldDecl. Instead, mangle the field the IndirectFieldDecl refers to. Further, give IndirectFieldDecl no linkage just like FieldDecl. N.B. Decl.cpp:getLVForNamespaceScopeDecl tried to calculate linkage for data members of anonymous structs/unions. However, this seems impossible so turn it into an assertion. llvm-svn: 193269
* Treat aliases as definitions.Rafael Espindola2013-10-221-1/+5
| | | | | | | | | | | | | | This fixes pr17639. Before this patch clang would consider void foo(void) __attribute((alias("__foo"))); a declaration. It now correctly handles it as a definition. Initial patch by Alp Toker. I added support for variables. llvm-svn: 193200
* Simplify some implementations of get*Decl.Rafael Espindola2013-10-191-1/+1
| | | | | | | | | | * NamedDecl and CXXMethodDecl were missing getMostRecentDecl. * The const version can just forward to the non const. * getMostRecentDecl can use cast instead of cast_or_null. This then removes some casts from the callers. llvm-svn: 193039
* Simplify FunctionDecl::getBody.Rafael Espindola2013-10-191-9/+5
| | | | llvm-svn: 193025
* Rename some functions for consistency.Rafael Espindola2013-10-171-17/+11
| | | | | | Every other function in Redeclarable.h was using Decl instead of Declaration. llvm-svn: 192900
* Fix linkage calculation of auto member functions returning lambdasFaisal Vali2013-10-081-5/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | As described by Richard in https://groups.google.com/a/isocpp.org/d/msg/std-discussion/S1kmj0wF5-g/fb6agEYoL2IJ we should allow: template<typename S> struct A { template<typename T> static auto default_lambda() { return [](const T&) { return 42; }; } template<class U = decltype(default_lambda<S>())> U func(U u = default_lambda<S>()) { return u; } }; int run2 = A<double>{}.func()(3.14); int run3 = A<char>{}.func()('a'); This patch allows the code using the same trickery that was used to allow the code in non-member functions at namespace scope. Please see http://llvm-reviews.chandlerc.com/D1844 for richard's approval. llvm-svn: 192166
* When merging class definitions across modules in C++, merge together fields.Richard Smith2013-10-071-1/+9
| | | | | | | | | This change doesn't go all the way to making fields redeclarable; instead, it makes them 'mergeable', which means we can find the canonical declaration, but not much else (and for a declaration that's not from a module, the canonical declaration is always that declaration). llvm-svn: 192092
* Fix computation of linkage within nested lambdas.Faisal Vali2013-10-011-3/+31
| | | | | | | | | | When nested C++11 lambdas are used in NSDMI's - this patch prevents infinite recursion by computing the linkage of any nested lambda by determining the linkage of the outermost enclosing lambda (which might inherit its linkage from its parent). See http://llvm-reviews.chandlerc.com/D1783 for Doug's approval. [On a related note, I need this patch so as to pass tests of transformations of nested lambdas returned from member functions] llvm-svn: 191727
* Revert the linkage fix.Faisal Vali2013-09-291-31/+5
| | | | | | I got a bunch of buildbot failures that i don't understand - sorry. llvm-svn: 191647
* Fix computation of linkage within nested lambdas.Faisal Vali2013-09-291-5/+31
| | | | | | | | | | When nested lambdas are used in NSDMI's - this prevents infinite recursion. See http://llvm-reviews.chandlerc.com/D1783 for Doug's approval regarding the code, and then request for some tests. [On a related note, I need this patch so as to pass tests of transformations of nested lambdas returned from member functions] llvm-svn: 191645
* Implement C++1y sized deallocation (n3778). This is not enabled by -std=c++1y;Richard Smith2013-09-291-1/+4
| | | | | | | instead, it's enabled by the -cc1 flag -fsized-deallocation, until we sort out the backward-compatibility issues. llvm-svn: 191629
* Variable templates: handle instantiation of static data member templatesRichard Smith2013-09-271-12/+40
| | | | | | appropriately, especially when they appear within class templates. llvm-svn: 191548
* Revert "Revert "[-cxx-abi microsoft] Mangle local TagDecls appropriately""David Majnemer2013-09-171-4/+4
| | | | | | This reverts commit r190895 which reverted r190892. llvm-svn: 190904
* Revert "[-cxx-abi microsoft] Mangle local TagDecls appropriately"David Majnemer2013-09-171-4/+4
| | | | | | This reverts commit r190892. llvm-svn: 190895
* [-cxx-abi microsoft] Mangle local TagDecls appropriatelyDavid Majnemer2013-09-171-4/+4
| | | | | | | | | | | | | | | | | | | | | | | Summary: When selecting a mangling for an anonymous tag type: - We should first try it's typedef'd name. - If that doesn't work, we should mangle in the name of the declarator that specified it as a declaration specifier. - If that doesn't work, fall back to a static mangling of <unnamed-type>. This should make our anonymous type mangling compatible. This partially fixes PR16994; we would need to have an implementation of scope numbering to get it right (a separate issue). Reviewers: rnk, rsmith, rjmccall, cdavis5x CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1540 llvm-svn: 190892
* [-cxx-abi microsoft] Correctly identify Win32 entry pointsDavid Majnemer2013-09-161-0/+27
| | | | | | | | | | | | | | | | | | | Summary: This fixes several issues with the original implementation: - Win32 entry points cannot be in namespaces - A Win32 entry point cannot be a function template, diagnose if we it. - Win32 entry points cannot be overloaded. - Win32 entry points implicitly return, similar to main. Reviewers: rnk, rsmith, whunt, timurrrr Reviewed By: rnk CC: cfe-commits, nrieck Differential Revision: http://llvm-reviews.chandlerc.com/D1683 llvm-svn: 190818
* Fix name lookup with dependent using decls.Eli Friedman2013-08-201-0/+9
| | | | | | | | | | We previously mishandled UnresolvedUsingValueDecls in NamedDecl::declarationReplaces, which caused us to forget decls when there are multiple dependent using decls for the same name. Fixes PR16936. llvm-svn: 188737
* Started implementing variable templates. Top level declarations should be ↵Larisse Voufo2013-08-061-9/+55
| | | | | | 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
* Fix assert when instantiating a default argument of a template defined in aRichard Smith2013-08-011-1/+4
| | | | | | module. llvm-svn: 187556
* Tighten up the set of operator new/operator delete calls we're permitted toRichard Smith2013-07-211-2/+48
| | | | | | | | | optimize, to follow the permissions granted in N3664. Under those rules, only calls generated by new-expressions and delete-expressions are permitted to be optimized, and direct calls to ::operator new and ::operator delete must be treated as normal calls. llvm-svn: 186799
* Fix mangling for block literals.Eli Friedman2013-07-011-23/+39
| | | | | | | | | | | | | | | 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
* Remove bogus VarDecl::extendsLifetimeOfTemporary function and inline it intoRichard Smith2013-06-271-13/+0
| | | | | | its only caller with a FIXME explaining why it's bogus. llvm-svn: 185109
* Delete dead code.Eli Friedman2013-06-271-12/+0
| | | | llvm-svn: 185103
* Rewrite record layout for ms_struct structs.Eli Friedman2013-06-261-13/+1
| | | | | | | | | | | | | | 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
* [AST] Introduce a new DecayedType sugar nodeReid Kleckner2013-06-241-0/+8
| | | | | | | | | | | | | | 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
* Cleanup linkage computation for static locals.Rafael Espindola2013-06-171-1/+5
| | | | | | | With this patch we assign VisibleNoLinkage to static locals in inline functions. This lets us simplify CodeGen a bit. llvm-svn: 184114
* Fix linkage computation for local types in template functions.Rafael Espindola2013-06-041-1/+5
| | | | | | | | Template functions (and member functions of class templates) present the same problem as inline functions. They need to be uniqued, so we need to assign VisibleNoLinkage linkage to types defined in them. llvm-svn: 183222
* Fix memory leak for APValues that do memory allocation.Manuel Klimek2013-06-031-1/+16
| | | | | | | | | 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
* Fix PR16060.Rafael Espindola2013-05-301-3/+6
| | | | | | | | | | | The testcase in PR16060 points out that while template arguments can show that a type is not externally visible, the standards still says they have external linkage. In terms of our implementation, it means that we should merge just the isExternallyVisible bit, not the formal linkage. llvm-svn: 182962
* Don't compute the visibility unless we really have to.Rafael Espindola2013-05-291-24/+39
| | | | | | | This brings the number of linkage computations in "clang -cc1" in SemaExpr.ii from 58426 to 43134. With -emit-llvm the number goes from 161045 to 145461. llvm-svn: 182823
* Check the linkage cache at every recursive step.Rafael Espindola2013-05-281-49/+63
| | | | | | | | | | | | | | | | | | | | | | | Before this patch the linkage cache was only used by the entry level function (getLinkage). The function that does the actual computation (getLVForDecl), never looked at it. This means that we would not reuse an entry in the cache when getLVForDecl did a recursive call. This patch fixes that by adding another computation enum value for when we don't care about the linkage at all and having getLVForDecl check the cache in that case. When running "clang -cc1" over SemaExpr.ii this brings the number of linkage computations from 93749 to 58426. When running "clang -cc1 -emit-llvm -O3" it goes from 198708 to 161444. For SemaExpr.ii at least linkage computation is a small enough percentage of the work that the time difference was in the noise. When asserts are enabled this patch also causes clang to check the linkage cache even on recursive calls. llvm-svn: 182799
* Propagate VisibleNoLinkage down to class members.Rafael Espindola2013-05-281-3/+4
| | | | | | Fixes PR16114. llvm-svn: 182750
* use getLVForDecl for consistency.Rafael Espindola2013-05-281-1/+1
| | | | | | No intended functionality change. llvm-svn: 182749
* Fix the linkage of local types in inline VisibleNoLinkage functions.Rafael Espindola2013-05-271-1/+1
| | | | | | We were handling only local types in inline External functions before. llvm-svn: 182737
* Move 3 helper function to Linkage.hRafael Espindola2013-05-271-6/+2
| | | | | | | This removes a duplicate from Decl.cpp and a followup patch will use isExternallyVisible. llvm-svn: 182735
* Fix linkage computation for derived types in inline functions.Rafael Espindola2013-05-251-40/+24
| | | | | | | | | | | | | | | | | John noticed that the fix for pr15930 (r181981) didn't handle indirect uses of local types. For example, a pointer to local struct, or a function that returns it. One way to implement this would be to recursively look for local types. This would look a lot like the linkage computation itself for types. To avoid code duplication and utilize the existing linkage cache, this patch just makes the computation of "type with no linkage but externally visible because it is from an inline function" part of the linkage computation itself. llvm-svn: 182711
* Handle local enum types too.Rafael Espindola2013-05-181-5/+2
| | | | | | Thanks to John McCall for pointing this out. llvm-svn: 182182
* Fix pr15930.Rafael Espindola2013-05-161-1/+40
| | | | | | | | In the case of inline functions, we have to special case local types when they are used as template arguments to make sure the template instantiations are still uniqued in case the function itself is inlined. llvm-svn: 181981
* Use only explicit bool conversion operatorDavid Blaikie2013-05-151-2/+2
| | | | | | | | | | | | | | | | | | | The most common (non-buggy) case are where such objects are used as return expressions in bool-returning functions or as boolean function arguments. In those cases I've used (& added if necessary) a named function to provide the equivalent (or sometimes negative, depending on convenient wording) test. DiagnosticBuilder kept its implicit conversion operator owing to the prevalent use of it in return statements. One bug was found in ExprConstant.cpp involving a comparison of two PointerUnions (PointerUnion did not previously have an operator==, so instead both operands were converted to bool & then compared). A test is included in test/SemaCXX/constant-expression-cxx1y.cpp for the fix (adding operator== to PointerUnion in LLVM). llvm-svn: 181869
OpenPOWER on IntegriCloud