- Feb 03, 2010
-
-
Douglas Gregor authored
that is in an anonymous namespace, give that function or variable internal linkage. This change models an oddity of the C++ standard, where names declared in an anonymous namespace have external linkage but, because anonymous namespace are really "uniquely-named" namespaces, the names cannot be referenced from other translation units. That means that they have external linkage for semantic analysis, but the only sensible implementation for code generation is to give them internal linkage. We now model this notion via the UniqueExternalLinkage linkage type. There are several changes here: - Extended NamedDecl::getLinkage() to produce UniqueExternalLinkage when the declaration is in an anonymous namespace. - Added Type::getLinkage() to determine the linkage of a type, which is defined as the minimum linkage of the types (when we're dealing with a compound type that is not a struct/class/union). - Extended NamedDecl::getLinkage() to consider the linkage of the template arguments and template parameters of function template specializations and class template specializations. - Taught code generation to rely on NamedDecl::getLinkage() when determining the linkage of variables and functions, also considering the linkage of the types of those variables and functions (C++ only). Map UniqueExternalLinkage to internal linkage, taking out the explicit checks for isInAnonymousNamespace(). This fixes much of PR5792, which, as discovered by Anders Carlsson, is actually the reason behind the pass-manager assertion that causes the majority of clang-on-clang regression test failures. With this fix, Clang-built-Clang+LLVM passes 88% of its regression tests (up from 67%). The specific numbers are: LLVM: Expected Passes : 4006 Expected Failures : 32 Unsupported Tests : 40 Unexpected Failures: 736 Clang: Expected Passes : 1903 Expected Failures : 14 Unexpected Failures: 75 Overall: Expected Passes : 5909 Expected Failures : 46 Unsupported Tests : 40 Unexpected Failures: 811 Still to do: - Improve testing - Check whether we should allow the presence of types with InternalLinkage (in addition to UniqueExternalLinkage) given variables/functions internal linkage in C++, as mentioned in PR5792. - Determine how expensive the getLinkage() calls are in practice; consider caching the result in NamedDecl. - Assess the feasibility of Chris's idea in comment #1 of PR5792. llvm-svn: 95216
-
Chris Lattner authored
llvm-svn: 95201
-
Douglas Gregor authored
realize that CXXConstructExpr is always implicit, so we should just return its argument (if there is only one) rather than directly invoking the constructor. llvm-svn: 95192
-
David Chisnall authored
- Don't use GlobalAliases with non-0 GEPs (GNU runtime) - this was unsupported and LLVM will be generating errors if you do it soon. This also simplifies the code generated by the GNU runtime a bit. - Make GetSelector() return a constant (GNU runtime), not a load of a store of a constant. - Recognise @selector() expressions as valid static initialisers (as GCC does). - Add methods to GCObjCRuntime to emit selectors as constants (needed for using @selector() expressions as constants. These need implementing for the Mac runtimes - I couldn't figure out how to do this, they seem to require a load. - Store an ObjCMethodDecl in an ObjCSelectorExpr so that we can get at the type information for the selector. This is needed for generating typed selectors from @selector() expressions (as GCC does). Ideally, this information should be stored in the Selector, but that would be an invasive change. We should eventually add checks for common uses of @selector() expressions. Possibly adding an attribute that can be applied to method args providing the types of a selector so, for example, you'd do something like this: - (id)performSelector: __attribute__((selector_types(id, SEL, id)))(SEL) withObject: (id)object; Then, any @selector() expressions passed to the method will be check to ensure that it conforms to this signature. We do this at run time on the GNU runtime already, but it would be nice to do it at compile time on all runtimes. - Made @selector() expressions emit type info if available and the runtime supports it. Someone more familiar with the Mac runtime needs to implement the GetConstantSelector() function in CGObjCMac. This currently just assert()s. llvm-svn: 95189
-
John McCall authored
appropriately. Call out a few missing cases in the expression mangler. llvm-svn: 95176
-
- Feb 02, 2010
-
-
Douglas Gregor authored
WHAT!?! It turns out that Type::isPromotableIntegerType() was not considering enumeration types to be promotable, so we would never do the promotion despite having properly computed the promotion type when the enum was defined. Various operations on values of enum type just "worked" because we could still compute the integer rank of an enum type; the oddity, however, is that operations such as "add an enum and an unsigned" would often have an enum result type (!). The bug actually showed up as a spurious -Wformat diagnostic (<rdar://problem/7595366>), but in theory it could cause miscompiles. In this commit: - Enum types with a promotion type of "int" or "unsigned int" are promotable. - Tweaked the computation of promotable types for enums - For all of the ABIs, treat enum types the same way as their underlying types (*not* their promotion types) for argument passing and return values - Extend the ABI tester with support for enumeration types llvm-svn: 95117
-
Anders Carlsson authored
Set the correct vtable pointers _before_ generating code for any member initializers. Fixes about ~2000 clang/LLVM tests in the clang-on-clang build. llvm-svn: 95116
-
Chandler Carruth authored
unused variable warning. llvm-svn: 95085
-
John McCall authored
Eliminates a lot of spurious global initializers, fixing PR6205. llvm-svn: 95077
-
Anders Carlsson authored
llvm-svn: 95076
-
Anders Carlsson authored
llvm-svn: 95066
-
Anders Carlsson authored
llvm-svn: 95063
-
Daniel Dunbar authored
llvm-svn: 95030
-
Daniel Dunbar authored
llvm-svn: 95029
-
- Feb 01, 2010
-
-
Devang Patel authored
llvm-svn: 95023
-
Devang Patel authored
llvm-svn: 95016
-
Devang Patel authored
llvm-svn: 95010
-
Devang Patel authored
llvm-svn: 95009
-
Devang Patel authored
llvm-svn: 95008
-
Daniel Dunbar authored
llvm-svn: 95005
-
Chris Lattner authored
by setting the section of the generated global. This is an optimization done by the code generator, and the code being removed didn't handle the case when the string contained an embedded nul (which the code generator does correctly handle). This is rdar://7589850 llvm-svn: 95003
-
Sebastian Redl authored
In C++, an initializer on a variable doesn't necessarily mean it's the definition. With that in mind, rename getDefinition to getAnyInitializer (to distinguish it from getInit) and reimplement it in terms of isThisDeclarationADefinition. Update all code to use this new function. llvm-svn: 94999
-
Devang Patel authored
llvm-svn: 94991
-
- Jan 31, 2010
-
-
Eli Friedman authored
not quite sure what we want to do about the AST representation; comments welcome. llvm-svn: 94967
-
Eli Friedman authored
llvm-svn: 94965
-
Anders Carlsson authored
llvm-svn: 94964
-
Douglas Gregor authored
(necessarily simultaneous) changes: - CXXBaseOrMemberInitializer now contains only a single initializer rather than a set of initialiation arguments + a constructor. The single initializer covers all aspects of initialization, including constructor calls as necessary but also cleanup of temporaries created by the initializer (which we never handled before!). - Rework + simplify code generation for CXXBaseOrMemberInitializers, since we can now just emit the initializer as an initializer. - Switched base and member initialization over to the new initialization code (InitializationSequence), so that it - Improved diagnostics for the new initialization code when initializing bases and members, to match the diagnostics produced by the previous (special-purpose) code. - Simplify the representation of type-checked constructor initializers in templates; instead of keeping the fully-type-checked AST, which is rather hard to undo at template instantiation time, throw away the type-checked AST and store the raw expressions in the AST. This simplifies instantiation, but loses a little but of information in the AST. - When type-checking implicit base or member initializers within a dependent context, don't add the generated initializers into the AST, because they'll look like they were explicit. - Record in CXXConstructExpr when the constructor call is to initialize a base class, so that CodeGen does not have to infer it from context. This ensures that we call the right kind of constructor. There are also a few "opportunity" fixes here that were needed to not regress, for example: - Diagnose default-initialization of a const-qualified class that does not have a user-declared default constructor. We had this diagnostic specifically for bases and members, but missed it for variables. That's fixed now. - When defining the implicit constructors, destructor, and copy-assignment operator, set the CurContext to that constructor when we're defining the body. llvm-svn: 94952
-
Anders Carlsson authored
When performing a derived-to-base cast that we know will not change the offset, we don't need to null check the input pointer. Fixes PR5965. llvm-svn: 94942
-
Anders Carlsson authored
When doing a base-to-derived cast we don't need to null check the derived value if the class offset is 0. llvm-svn: 94939
-
Anders Carlsson authored
llvm-svn: 94938
-
- Jan 30, 2010
-
-
Anders Carlsson authored
llvm-svn: 94920
-
Anders Carlsson authored
llvm-svn: 94917
-
- Jan 29, 2010
-
-
Devang Patel authored
llvm-svn: 94849
-
Devang Patel authored
llvm-svn: 94817
-
Douglas Gregor authored
llvm-svn: 94811
-
Anders Carlsson authored
llvm-svn: 94800
-
Anders Carlsson authored
Add a new EmitLValueForFieldInitialization that will be used for initializing fields (and reference type fields in particular). llvm-svn: 94799
-
Anders Carlsson authored
Simplify EmitLValueForField - we can get whether the field is part of a union or not from the FieldDecl (through its DeclContext). llvm-svn: 94798
-
Daniel Dunbar authored
the ABI spec, this turns out to simplify the code. We still have some annoying code which mismatches the spec with regard to empty structures. llvm-svn: 94796
-
Anders Carlsson authored
llvm-svn: 94791
-