summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix diagnostic pragmas.Argyrios Kyrtzidis2010-12-151-2/+13
| | | | | | | | | | | | Diagnostic pragmas are broken because we don't keep track of the diagnostic state changes and we only check the current/latest state. Problems manifest if a diagnostic is emitted for a source line that has different diagnostic state than the current state; this can affect a lot of places, like C++ inline methods, template instantiations, the lexer, etc. Fix the issue by having the Diagnostic object keep track of the source location of the pragmas so that it is able to know what is the diagnostic state at any given source location. Fixes rdar://8365684. llvm-svn: 121873
* Restore r121752 without modification.John McCall2010-12-141-53/+42
| | | | llvm-svn: 121763
* Pull out r121752 in case it's causing the selfhost breakage.John McCall2010-12-141-42/+53
| | | | llvm-svn: 121759
* Factor out most of the extra state in a FunctionProtoType into a separateJohn McCall2010-12-141-53/+42
| | | | | | | class to be passed around. The line between argument and return types and everything else is kindof vague, but I think it's justifiable. llvm-svn: 121752
* Variadic templates: extend Type, NestedNameSpecifier, TemplateName,Douglas Gregor2010-12-131-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | and TemplateArgument with an operation that determines whether there are any unexpanded parameter packs within that construct. Use this information to diagnose the appearance of the names of parameter packs that have not been expanded (C++ [temp.variadic]p5). Since this property is checked often (every declaration, ever expression statement, etc.), we extend Type and Expr with a bit storing the result of this computation, rather than walking the AST each time to determine whether any unexpanded parameter packs occur. This commit is deficient in several ways, which will be remedied with future commits: - Expr has a bit to store the presence of an unexpanded parameter pack, but it is never set. - The error messages don't point out where the unexpanded parameter packs were named in the type/expression, but they should. - We don't check for unexpanded parameter packs in all of the places where we should. - Testing is sparse, pending the resolution of the above three issues. llvm-svn: 121724
* Move the functionality to mark all vtables of key functions as used withinChandler Carruth2010-12-121-13/+1
| | | | | | | | | | | | | | a translation unit to the ActOnEndOfTranslationUnit function instead of doing it at the start of DefineUsedVTables. The latter is now called *recursively* during template instantiation, which causes an absolutely insane number of walks of every record decl in the translation unit. After this patch, an extremely template instantiation heavy test case's compile time drops by 10x, and we see between 15% and 20% improvement in average compile times across a project. This is just recovering a regression, it doesn't make anything faster than it was several weeks ago. llvm-svn: 121644
* Added ParenType type node.Abramo Bagnara2010-12-101-3/+3
| | | | llvm-svn: 121488
* Treat visibility on an enclosing namespace as a non-explicit source ofJohn McCall2010-12-101-2/+2
| | | | | | | | | | | visibility. Fixes PR8713. I've disabled a test which was testing that you can #pragma pop visibility to get out of a namespace's visibility attribute. We should probably just diagnose that as an error unless it's instrumental to someone's system headers. llvm-svn: 121459
* PR5207: Change APInt methods trunc(), sext(), zext(), sextOrTrunc() andJay Foad2010-12-071-4/+4
| | | | | | | | zextOrTrunc(), and APSInt methods extend(), extOrTrunc() and new method trunc(), to be const and to return a new value instead of modifying the object in place. llvm-svn: 121121
* Use Sema::MaybeCreateExprWithCleanups() only after we've checked for a ↵Douglas Gregor2010-12-071-12/+7
| | | | | | NULL/invalid expression llvm-svn: 121081
* Un-templatetize this method. It's definition is out of line in the .cpp file,Chandler Carruth2010-12-061-54/+52
| | | | | | | | | | | | | so that's not a valid thing to do at all. Instead, switch to a ValueDecl argument, the template isn't really necessary here. When handling the types explicitly in the code, it becomes awkward to cerate the CXXBaseOrMemberInitializer object in so many places. Re-flow the code to calculate the Init expression first, and then create the initializer. If this is too gross, we can factor the init expression logic into helper functions, but it's not past my threshold yet. llvm-svn: 120997
* Rename CXXExprWithTemporaries -> ExprWithCleanups; there's no theoreticalJohn McCall2010-12-061-10/+10
| | | | | | reason this is limited to C++, and it's certainly not limited to temporaries. llvm-svn: 120996
* More anonymous struct/union redesign. This one deals with anonymous field ↵Francois Pichet2010-12-041-47/+34
| | | | | | | | | | | | | | | | used in a constructor initializer list: struct X { X() : au_i1(123) {} union { int au_i1; float au_f1; }; }; clang will now deal with au_i1 explicitly as an IndirectFieldDecl. llvm-svn: 120900
* Revert r120063, it was wrong.John McCall2010-11-291-2/+2
| | | | llvm-svn: 120296
* Minor whitespace and comment fixes. No functionality change.Nico Weber2010-11-281-1/+1
| | | | llvm-svn: 120266
* Redeclarations of using declarations are not okay in function scopes.John McCall2010-11-231-2/+2
| | | | | | | | Not sure what I was thinking before. Fixes PR8668. llvm-svn: 120063
* Major anonymous union/struct redesign.Francois Pichet2010-11-211-10/+15
| | | | | | | | | | | A new AST node is introduced: def IndirectField : DDecl<Value>; IndirectFields are injected into the anonymous's parent scope and chain back to the original field. Name lookup for anonymous entities now result in an IndirectFieldDecl instead of a FieldDecl. There is no functionality change, the code generated should be the same. llvm-svn: 119919
* A bundle of whitespace changes, separated out from the functional changes.Nick Lewycky2010-11-201-7/+7
| | | | llvm-svn: 119886
* Refactoring.Argyrios Kyrtzidis2010-11-191-4/+4
| | | | | | Move ErrorTrap from clang/Sema to clang/Basic as DiagnosticErrorTrap and use it in Scope. llvm-svn: 119763
* Add an assertion, fix a whole bunch of bugs, comment the assertionJohn McCall2010-11-181-5/+5
| | | | | | out because there are still bugs left. llvm-svn: 119722
* Calculate the value kind of an expression when it's created andJohn McCall2010-11-181-18/+17
| | | | | | | | | | | | | store it on the expression node. Also store an "object kind", which distinguishes ordinary "addressed" l-values (like variable references and pointer dereferences) and bitfield, @property, and vector-component l-values. Currently we're not using these for much, but I aim to switch pretty much everything calculating l-valueness over to them. For now they shouldn't necessarily be trusted. llvm-svn: 119685
* Region-allocate all AttributeList objects from a factory object instead of ↵Ted Kremenek2010-11-101-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | manually managing them using new/delete and OwningPtrs. After memory profiling Clang, I witnessed periodic leaks of these objects; digging deeper into the code, it was clear that our management of these objects was a mess. The ownership rules were murky at best, and not always followed. Worse, there are plenty of error paths where we could screw up. This patch introduces AttributeList::Factory, which is a factory class that creates AttributeList objects and then blows them away all at once. While conceptually simple, most of the changes in this patch just have to do with migrating over to the new interface. Most of the changes have resulted in some nice simplifications. This new strategy currently holds on to all AttributeList objects during the lifetime of the Parser object. This is easily tunable. If we desire to have more bound the lifetime of AttributeList objects more precisely, we can have the AttributeList::Factory object (in Parser) push/pop its underlying allocator as we enter/leave key methods in the Parser. This means that we get simple memory management while still having the ability to finely control memory use if necessary. Note that because AttributeList objects are now BumpPtrAllocated, we may reduce malloc() traffic in many large files with attributes. This fixes the leak reported in: <rdar://problem/8650003> llvm-svn: 118675
* Diagnose attempst to template using declarations and using directives.John McCall2010-11-101-8/+12
| | | | | | Recover from the latter and fail early for the former. Fixes PR8022. llvm-svn: 118669
* tidy upChris Lattner2010-11-091-5/+4
| | | | llvm-svn: 118626
* Fix source locations in unnamed bitfield diagnostic, from JakubDouglas Gregor2010-11-091-0/+5
| | | | | | Wieczorek! Fixes PR8025. llvm-svn: 118481
* Check for an invalid field earlier in a constructor's initializationDouglas Gregor2010-11-051-3/+3
| | | | | | | | | | | of that field. Otherwise, we can end up building and later trying to instantiate a dependent member initializer that will fail at instantiation time. Unfortunately, I've only managed to trigger this bug with very large sources, so there's no test case :( llvm-svn: 118306
* No really, we don't have a retain/release system for statements/expressionsJohn McCall2010-10-261-11/+3
| | | | | | anymore. llvm-svn: 117357
* Improve the tracking of source locations for parentheses in constructor calls.Chandler Carruth2010-10-251-5/+10
| | | | | | | | | | | | This adds them where missing, and traces them through PCH. We fix at least one bug in the extents found by the Index library, and make a lot of refactoring tools which care about the exact formulation of a constructor call easier to write. Also some minor cleanups to more consistently follow the friend pattern instead of the setter pattern when rebuilding a serialized AST. Patch originally by Samuel Benzaquen. llvm-svn: 117254
* When performing name lookup for a namespace definition, only look intoDouglas Gregor2010-10-221-9/+11
| | | | | | | the current context's redeclaration context, ignoring using directives. Fixes PR8430. llvm-svn: 117097
* Pass TInfo to CXXDestructorDecl::Create(), just like we do for otherCraig Silverstein2010-10-211-1/+1
| | | | | | | | function decls. Reviewed by rjmccall and nlewycky. llvm-svn: 116979
* Redirect templated friend class decls to a new Sema callback andJohn McCall2010-10-191-0/+104
| | | | | | | construct an unsupported friend when there's a friend with a templated scope specifier. Fixes a consistency crash, rdar://problem/8540527 llvm-svn: 116786
* Reformatting.John McCall2010-10-161-2/+2
| | | | llvm-svn: 116662
* White-listing templated-scope friend decls is a good idea, but doing itJohn McCall2010-10-161-0/+11
| | | | | | | | by marking the decl invalid isn't. Make some steps towards supporting these and then hastily shut them down at the last second by marking them as unsupported. llvm-svn: 116661
* Diagnose C++ [class.mem]p13-14, where a class member has the same nameDouglas Gregor2010-10-151-0/+21
| | | | | | as the class itself. Fixes PR7082. llvm-svn: 116573
* Death to blocks, or at least the word "block" in one particular obnoxiouslyJohn McCall2010-10-151-1/+1
| | | | | | ambiguous context. llvm-svn: 116567
* template-ids are looked up differently in friend declarations.John McCall2010-10-141-1/+6
| | | | llvm-svn: 116529
* Generalize the checking for qualification of (non-friend) classDouglas Gregor2010-10-131-0/+21
| | | | | | | | members. Provide a hard error when the qualification doesn't match the current class type, or a warning + Fix-it if it does match the current class type. Fixes PR8159. llvm-svn: 116445
* Preserve the original scope when picking the right scope for a friendJohn McCall2010-10-131-2/+3
| | | | | | declaration, because we'll need it later. Hopefully fixed self-host. llvm-svn: 116399
* Support friend function declarations in local classes correctly.John McCall2010-10-131-6/+22
| | | | | | | | Fixes a crash and diagnoses the error condition of an unqualified friend which doesn't resolve to something. I'm still not certain how this is useful. llvm-svn: 116393
* Handle dependent friends more explicitly and deal with the possibilityJohn McCall2010-10-121-42/+57
| | | | | | | | of templated-scope friends by marking them invalid and white-listing all accesses until such time as we implement them. Fixes a crash, this time without a broken test case. llvm-svn: 116364
* If we end up instantiating a function parameter whose default argumentDouglas Gregor2010-10-121-0/+12
| | | | | | | | | has not yet been parsed, note that the default argument hasn't been parsed and keep track of all of the instantiations of that function parameter. When its default argument does get parsed, imbue the instantiations with that default argument. Fixes PR8245. llvm-svn: 116324
* Track the location of the context requiring an implicit conversion and use itJohn McCall2010-10-081-1/+9
| | | | | | to white-list conversions required by system headers. rdar://problem/8232669 llvm-svn: 116029
* Silence unused variable warning in Release builds.Nick Lewycky2010-10-061-0/+1
| | | | llvm-svn: 115806
* When checking for uninitialized fields in member initializers, special case ↵Anders Carlsson2010-10-061-0/+13
| | | | | | static variables and enums. Fixes PR8075. llvm-svn: 115732
* Move the management of the set of conversion functions in a C++ classDouglas Gregor2010-09-291-28/+9
| | | | | | | | | | into CXXRecordDecl. The only part that we do not handle this way are using declarations, since that would require extra name lookup that we don't currently want to pay for. This fixes <rdar://problem/8459981>, so that LLDB can build a CXXRecordDecl and magically get all of the right bits set. llvm-svn: 115026
* Move the maintenance of CXXRecordDecl::DefinitionData's Abstract bitDouglas Gregor2010-09-291-76/+1
| | | | | | | | | | | completely into CXXRecordDecl, by adding a new completeDefinition() function. This required a little reshuffling of the final-overrider checking code, since the "abstract" calculation in the presence of abstract base classes needs to occur in CXXRecordDecl::completeDefinition() but we don't want to compute final overriders more than one in the common case. llvm-svn: 115007
* Teach FunctionDecl::setPure() to (indirectly) mark the Abstract bit inDouglas Gregor2010-09-281-3/+0
| | | | | | CXXRecordDecl::DefinitionData, rather than having Sema mark the bit. llvm-svn: 114993
* Reinstate r114925 and r114929, both steps towardDouglas Gregor2010-09-281-51/+0
| | | | | | <rdar://problem/8459981>. llvm-svn: 114984
* Centralize the management of CXXRecordDecl::DefinitionData's Empty bitDouglas Gregor2010-09-281-10/+0
| | | | | | | | | | | | in CXXRecordDecl itself. Yes, this is also part of <rdar://problem/8459981>. This reinstates r114924, with one crucial bug fix: we were ignoring the implicit fields created by anonymous structs/unions when updating the bits in CXXRecordDecl, which means that a class/struct containing only an anonymous class/struct would be considered "empty". Hilarity follows. llvm-svn: 114980
* Reinstate r114921, which I've exonerated via a self-host build.Douglas Gregor2010-09-281-8/+0
| | | | | | | | Centralize the management of CXXRecordDecl::DefinitionData's Aggregate and PlainOldData bits in CXXRecordDecl itself. Another milepost on the road toward <rdar://problem/8459981>. llvm-svn: 114977
OpenPOWER on IntegriCloud