summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Decl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [-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
* Cleanup handling of UniqueExternalLinkage.Rafael Espindola2013-05-131-3/+7
| | | | | | | | | | | | | 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
* Fix stack overflow in linkage computation when a function with a deduced returnRichard Smith2013-05-121-3/+14
| | | | | | | | | | | | | | | type returns a lambda defined within itself. The computation of linkage for the function looked at the linkage of the lambda, and vice versa. This is solved by not checking whether an 'auto' in a function return type deduces to a type with unique external linkage. We don't need this check, because the type deduced for 'auto' doesn't affect whether two otherwise-identical declarations would name different functions, so we don't need to give an ostensibly external-linkage function internal linkage for this reason. (We also don't need unique-external linkage in C++11 onwards at all, but that's not implemented yet.) llvm-svn: 181675
* Make all 'is in extern "C"' tests use the lexical context.Rafael Espindola2013-05-051-11/+40
| | | | | | | I was not able to find a case (other than the fix in r181163) where this makes a difference, but it is a more obviously correct API to have. llvm-svn: 181165
* Replace ArrayRef<T>() with None, now that we have an implicit ArrayRef ↵Dmitri Gribenko2013-05-051-1/+1
| | | | | | | | constructor from None Patch by Robert Wilhelm. llvm-svn: 181139
* Serialization for captured statementsBen Langmuir2013-05-031-1/+8
| | | | | | | | | | | Add serialization for captured statements and captured decls. Also add a const_capture_iterator to CapturedStmt. Test contributed by Wei Pan Differential Revision: http://llvm-reviews.chandlerc.com/D727 llvm-svn: 181048
* Move CapturedStmt parameters to CapturedDeclBen Langmuir2013-05-031-2/+4
| | | | | | | | | | | Move the creation of CapturedStmt parameters out of CodeGen and into Sema, making it easier to customize the outlined function. The ImplicitParamDecls are stored in the CapturedDecl using an ASTContext-allocated array. Differential Revision: http://llvm-reviews.chandlerc.com/D722 llvm-svn: 181043
* Add r180263 back, but fix hasBraces() to be correct during parsing.Rafael Espindola2013-04-261-6/+11
| | | | | | | | Original commit message: Fix a case in linkage computation that should check for single line extern "C". llvm-svn: 180591
* Revert r180263. It's causing failures.Bill Wendling2013-04-251-11/+6
| | | | llvm-svn: 180583
* Fix a case in linkage computation that should check for single line extern "C".Rafael Espindola2013-04-251-6/+11
| | | | llvm-svn: 180263
* Don't mark 'extern "C" void f(void)' as having extern storage class.Rafael Espindola2013-04-251-7/+10
| | | | | | | | | | Instead, we check for one line extern "C" context in linkage computation and when deciding if a variable is a definition. This hopefully completes the transition to having "as written" semantics for hasExternalStorage. llvm-svn: 180258
* Correct the range returned by ParmVarDecl::getSourceRange(), for parameters ↵Argyrios Kyrtzidis2013-04-171-0/+5
| | | | | | | | | | | | | | in ObjC methods with postfix types. For a parameter in a method like this: -(int)methodWithFn:(void (*)(int *p))fn; we would return the source range of the type and not include the parameter name. Fixes rdar://13668626. llvm-svn: 179660
* Sema for Captured StatementsTareq A. Siraj2013-04-161-0/+4
| | | | | | | | | | | | | Add CapturedDecl to be the DeclContext for CapturedStmt, and perform semantic analysis. Currently captures all variables by reference. TODO: templates Author: Ben Langmuir <ben.langmuir@intel.com> Differential Revision: http://llvm-reviews.chandlerc.com/D433 llvm-svn: 179618
* Basic support for Microsoft property declarations andJohn McCall2013-04-161-1/+9
| | | | | | | | references thereto. Patch by Tong Shen! llvm-svn: 179585
* Remove hasExternalLinkageUncached.Rafael Espindola2013-04-151-4/+0
| | | | | | | | It was being used correctly, but it is a very dangerous API to have around. Instead, move the logic from the filtering to when we are deciding if we should link two decls. llvm-svn: 179523
* Add hasExternalLinkageUncached back with the test that Richard provided, butRafael Espindola2013-04-041-0/+4
| | | | | | keep the call at the current location. llvm-svn: 178741
* Avoid computing the linkage instead of avoiding caching it.Rafael Espindola2013-04-041-4/+0
| | | | | | | | | | | | | | This mostly reverts 178733, but keeps the tests. I don't claim to understand how hidden sub modules work or when we need to see them (is that documented?), but this has the same semantics and avoids adding hasExternalLinkageUncached which has the same foot gun potential as the old hasExternalLinkage. Last but not least, not computing linkage when it is not needed is more efficient. llvm-svn: 178739
* Fix 41 of the 61 tests which fail with modules enabled: we were computing andRichard Smith2013-04-041-0/+4
| | | | | | | | | caching the linkage for a declaration before we set up its redeclaration chain, when determining whether a declaration could be a redeclaration of something from an unimported submodule. We actually want to look at the declaration as if it were not a redeclaration here, so compute the linkage but don't cache it. llvm-svn: 178733
* Add 178663 back.Rafael Espindola2013-04-031-55/+41
| | | | | | | | | | | http://lab.llvm.org:8011/builders/clang-x86_64-darwin10-gdb went back green before it processed the reverted 178663, so it could not have been the culprit. Revert "Revert 178663." This reverts commit 4f8a3eb2ce5d4ba422483439e20c8cbb4d953a41. llvm-svn: 178682
* Revert 178663.Rafael Espindola2013-04-031-41/+55
| | | | | | | | | | Looks like it broke http://lab.llvm.org:8011/builders/clang-x86_64-darwin10-gdb Revert "Don't compute a patched/semantic storage class." This reverts commit 8f187f62cb0487d31bc4afdfcd47e11fe9a51d05. llvm-svn: 178681
* Don't compute a patched/semantic storage class.Rafael Espindola2013-04-031-55/+41
| | | | | | | | | | | For variables and functions clang used to store two storage classes. The one "as written" in the code and a patched one, which, for example, propagates static to the following decls. This apparently is from the days clang lacked linkage computation. It is now redundant and this patch removes it. llvm-svn: 178663
* Avoid computing the linkage too early. Don't invalidate it.Rafael Espindola2013-03-141-44/+30
| | | | | | | | | | | | | | | | | | Before this patch we would compute the linkage lazily and cache it. When the AST was modified in ways that could change the value, we would invalidate the cache. That was fairly brittle, since any code could ask for the a linkage before the correct value was available. We should change the API to one where the linkage is computed explicitly and trying to get it when it is not available asserts. This patch is a first step in that direction. We still compute the linkage lazily, but instead of invalidating a cache, we assert that the AST modifications didn't change the result. llvm-svn: 176999
* Whitespace cleanup.Rafael Espindola2013-03-121-4/+4
| | | | llvm-svn: 176896
* Correctly compute linkage of decls forward declared extern C.Rafael Espindola2013-03-121-2/+1
| | | | | | | | | | | | | | This fixes a crash in namespace { struct X {}; } extern "C" X test2_b; X test2_b before we would assign different linkages to each of the test2_b decls. llvm-svn: 176869
* Add TagDecl::hasNameForLinkage(), which is true if the tagJohn McCall2013-03-091-1/+1
| | | | | | is non-anonymous or is defined in a typedef of itself. llvm-svn: 176742
* Add a hasExternalStorageAsWritten helper. No functionality change.Rafael Espindola2013-03-071-5/+3
| | | | | | | | It is possible that some of the current uses of "getStorageClassAsWritten() == SC_Extern" should use this but I don't know enough about SC_PrivateExtern to change and test them. llvm-svn: 176606
OpenPOWER on IntegriCloud