summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Decl.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix crash declaring global allocation function with zero parameters. Fixes ↵Nick Lewycky2014-06-071-1/+1
| | | | | | PR19968! llvm-svn: 210388
* Rename utility function templatesAlp Toker2014-05-311-6/+6
| | | | | | | isExternCTemplate() and getLanguageLinkageTemplate() have nothing to do with templates despite the dubious naming scheme. llvm-svn: 209969
* Take PrintingPolicy::SuppressUnwrittenScope into account when printing theRichard Smith2014-05-301-0/+3
| | | | | | qualified name of a NamedDecl. Patch by Volodymyr Sapsai! llvm-svn: 209924
* Move the logic for testing for namespace std into one location. This check canRichard Trieu2014-05-281-8/+1
| | | | | | be performed by using Decl::isInStdNamespace or DeclContext::isStdNamespace llvm-svn: 209708
* Avoid allocating extra memory to handle the lazy definition data pointer forRichard Smith2014-05-221-1/+1
| | | | | | CXXRecordDecls when modules is enabled. llvm-svn: 209482
* If a declaration is loaded, and then a module import adds a redeclaration, thenRichard Smith2014-05-161-36/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ensure that querying the first declaration for its most recent declaration checks for redeclarations from the imported module. This works as follows: * The 'most recent' pointer on a canonical declaration grows a pointer to the external AST source and a generation number (space- and time-optimized for the case where there is no external source). * Each time the 'most recent' pointer is queried, if it has an external source, we check whether it's up to date, and update it if not. * The ancillary data stored on the canonical declaration is allocated lazily to avoid filling it in for declarations that end up being non-canonical. We'll still perform a redundant (ASTContext) allocation if someone asks for the most recent declaration from a decl before setPreviousDecl is called, but such cases are probably all bugs, and are now easy to find. Some finessing is still in order here -- in particular, we use a very general mechanism for handling the DefinitionData pointer on CXXRecordData, and a more targeted approach would be more compact. Also, the MayHaveOutOfDateDef mechanism should now be expunged, since it was addressing only a corner of the full problem space here. That's not covered by this patch. Early performance benchmarks show that this makes no measurable difference to Clang performance without modules enabled (and fixes a major correctness issue with modules enabled). I'll revert if a full performance comparison shows any problems. llvm-svn: 209046
* Allow dllimport/dllexport on inline functions and adjust the linkage.Hans Wennborg2014-05-151-1/+1
| | | | | | | | This is a step towards handling these attributes on classes (PR11170). Differential Revision: http://reviews.llvm.org/D3772 llvm-svn: 208925
* [C++11] Use 'nullptr'. AST edition.Craig Topper2014-05-121-72/+82
| | | | llvm-svn: 208517
* Add support for __declspec(thread) under -fms-extensionsReid Kleckner2014-05-011-0/+15
| | | | | | | | Reviewers: rsmith Differential Revision: http://reviews.llvm.org/D3551 llvm-svn: 207734
* AST: Fix visibility calculation for VarTemplateSpecializationDeclDavid Majnemer2014-04-291-0/+4
| | | | | | | | | | | | It is possible that a variable template specialization might not have a VisibilityAttr attached to it while the template that it specializes does, in fact, have one. We should consider the template in such cases. This fixes PR19597. llvm-svn: 207498
* Suppress unused variable warningReid Kleckner2014-04-231-1/+3
| | | | llvm-svn: 207039
* Make TypeDecl much less friendly.Richard Smith2014-04-231-2/+2
| | | | llvm-svn: 207007
* AST: Cleanup/simplify some LV calculation codeDavid Majnemer2014-04-231-20/+16
| | | | | | No functional change. llvm-svn: 206943
* Teach getTemplateInstantiationPattern to deal with generic lambdas.Faisal Vali2014-04-031-2/+23
| | | | | | | | | | | | | No functionality change. When determining the pattern for instantiating a generic lambda call operator specialization - we must not go drilling down for the 'prototype' (i.e. as written) pattern - rather we must use our partially transformed pattern (whose DeclRefExprs are wired correctly to any enclosing lambda's decls that should be mapped correctly in a local instantiation scope) that is the templated pattern of the specialization's primary template (even though the primary template might be instantiated from a 'prototype' member-template). Previously, the drilling down was haltted by marking the instantiated-from primary template as a member-specialization (incorrectly). This prompted Richard to remark (http://llvm-reviews.chandlerc.com/D1784?id=4687#inline-10272) "It's a bit nasty to (essentially) set this bit incorrectly. Can you put the check into getTemplateInstantiationPattern instead?" In my reckless youth, I chose to ignore that comment. With the passage of time, I have come to learn the value of bowing to the will of the angry Gods ;) llvm-svn: 205543
* CodeGen: Emit some functions as weak_odr under -fms-compatibilityDavid Majnemer2014-04-021-1/+39
| | | | | | | | | | | | | | | | | | | Summary: MSVC always emits inline functions marked with the extern storage class specifier. The result is something similar to the opposite of __attribute__((gnu_inline)). This extension is also available in C. This fixes PR19264. Reviewers: rnk, rsmith CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D3207 llvm-svn: 205485
* Render anonymous entities as '(anonymous <thing>)' (and lambdas as '(lambda ↵David Blaikie2014-04-021-3/+3
| | | | | | | | | | | | at ... )') For namespaces, this is consistent with mangling and GCC's debug info behavior. For structs, GCC uses <anonymous struct> but we prefer consistency between all anonymous entities but don't want to confuse them with template arguments, etc, so we'll just go with parens in all cases. llvm-svn: 205398
* Simplify FunctionDecl::getMinRequiredArguments().Richard Smith2014-04-011-26/+6
| | | | llvm-svn: 205351
* Don't fold together the name lookup entries for two declarations if they areRichard Smith2014-03-171-4/+10
| | | | | | declared in different namespaces in the same inline namespace set. llvm-svn: 204082
* Make some assertions on constant expressions static.Benjamin Kramer2014-03-151-2/+4
| | | | llvm-svn: 204012
* [C++11] Replacing BlockDecl iterators capture_begin() and capture_end() with ↵Aaron Ballman2014-03-141-3/+2
| | | | | | iterator_range captures(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203958
* [C++11] Replacing DeclBase iterators specific_attr_begin() and ↵Aaron Ballman2014-03-101-5/+2
| | | | | | specific_attr_end() with iterator_range specific_attrs(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203474
* [C++11] Replacing Decl iterators attr_begin() and attr_end() with ↵Aaron Ballman2014-03-081-2/+2
| | | | | | | | iterator_range attrs(). Updating all of the usages of the iterators with range-based for loops. This is a reapplication of r203236 with modifications to the definition of attrs() and following the new style guidelines on auto usage. llvm-svn: 203362
* [C++11] Replace LLVM-style type traits with C++11 standard ones.Benjamin Kramer2014-03-071-3/+1
| | | | | | No functionality change. llvm-svn: 203241
* Fully reverting r203236 -- it seems the only bots that are happy are the ↵Aaron Ballman2014-03-071-2/+2
| | | | | | MSVC bots. llvm-svn: 203237
* [C++11] Replacing iterators attr_begin() and attr_end() with iterator_range ↵Aaron Ballman2014-03-071-2/+2
| | | | | | attrs(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203236
* [C++11] Replacing iterators redecls_begin() and redecls_end() with ↵Aaron Ballman2014-03-061-41/+28
| | | | | | 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
* Exclude invalid old decl from mismatching linkage assertionIsmail Pazarbasi2014-03-061-3/+2
| | | | | | | | This patch fixes PR18964. In linkage computation, assertion fails when an old invalid declaration's linkage mismatches with the current decl's one. llvm-svn: 203168
* [C++11] Replace llvm::tie with std::tie.Benjamin Kramer2014-03-021-1/+1
| | | | llvm-svn: 202639
* PR18839: 'extern "C++"' also adds an implicit 'extern', not just 'extern "C"'.Richard Smith2014-02-171-4/+4
| | | | llvm-svn: 201537
* Report a correct end location for nameless parameters.Benjamin Kramer2014-02-021-1/+3
| | | | | | | | | | | | | | | Ranges before: void test(void (*)(int), int, float); ~~~~~~~~~~~~~ ~~~~ ~~~~~~ Ranges after: void test(void (*)(int), int, float); ~~~~~~~~~~~~~ ~~~ ~~~~~ This does not change the actual location of the ParmVarDecl, it still points to the location where the name would be. PR17970. llvm-svn: 200640
* Introduce and use Decl::getAsFunction() to simplify templated function checksAlp Toker2014-01-221-12/+4
| | | | | | | | | | | | | | Lift the getFunctionDecl() utility out of the parser into a general Decl::getAsFunction() and use it to simplify other parts of the implementation. Reduce isFunctionOrFunctionTemplate() to a simple type check that works the same was as the other is* functions and move unwrapping of shadowed decls to callers so it doesn't get run twice. Shuffle around canSkipFunctionBody() to reduce virtual dispatch on ASTConsumer. There's no need to query when we already know the body can't be skipped. llvm-svn: 199794
* Rename FunctionProtoType accessors from 'arguments' to 'parameters'Alp Toker2014-01-201-7/+8
| | | | | | | | | | | | | | | | | 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
* PR18544: don't assert that 'operator new' is not declared inside a namespace;Richard Smith2014-01-191-4/+9
| | | | | | such an assert will fail in invalid code that does so! llvm-svn: 199617
* 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
OpenPOWER on IntegriCloud