Introduce CompilerInvocation::setLangDefaults function
This patch refactors the CompilerInvocation code to introduce a
CompilerInvocation::setLangDefaults function, which can set up a
LangOptions with the defaults for a given language and language
standard. This function is useful for non-command line based Clang
clients which need to set up a CompilerInvocation manually for a
specific language.
Bob Wilson [Fri, 3 Dec 2010 17:50:54 +0000 (17:50 +0000)]
Add missing vext_f32 and vextq_f32 Neon intrinsics (Radar 8592601).
For some reason these were not included in the list of Neon intrinsics in
ARM's documentation, so they didn't make it into Clang either.
Douglas Gregor [Fri, 3 Dec 2010 17:11:42 +0000 (17:11 +0000)]
Implement caching for the linkage and visibility calculations of
declarations.
The motivation for this patch is that linkage/visibility computations
are linear in the number of redeclarations of an entity, and we've run
into a case where a single translation unit has > 6500 redeclarations
of the same (unused!) external variable. Since each redeclaration
involves a linkage check, the resulting quadratic behavior makes Clang
slow to a crawl. With this change, a simple test with 512
redeclarations of a variable syntax-checks ~20x faster than
before.
That said, I hate this change, and will probably end up reverting it
in a few hours. Reasons to hate it:
- It makes NamedDecl larger, since we don't have enough free bits in
Decl to squeeze in the extra information about caching.
- There are way too many places where we need to invalidate this
cache, because the visibility of a declaration can change due to
redeclarations (!). Despite self-hosting and passing the testsuite,
I have no confidence that I've found all of places where this cache
needs to be invalidated.
Bob Wilson [Fri, 3 Dec 2010 17:10:24 +0000 (17:10 +0000)]
Add a separate name field to the Neon intrinsic table.
This is currently the same as a lowercase version of the record name, but
it will allow us to have multiple records with the same name, which is
needed for intrinsics (e.g., vmul and vmull) that are implemented
differently depending on the type.
Ted Kremenek [Fri, 3 Dec 2010 06:52:30 +0000 (06:52 +0000)]
Fix an insidious bug in BugReporter where
a node in the trimmed graph might not always
correctly map back to the original error node.
This could cause a crash in some cases when
flagging memory leaks.
Douglas Gregor [Thu, 2 Dec 2010 21:47:04 +0000 (21:47 +0000)]
When we're performing an explicit cast of some sort, don't complain
about deprecated Objective-C pointer conversions. Plus, make sure to
actually set an appropriate AssignmentAction when performing an
implicit conversion from an InitializationSequence. Fixes regressions
in the GCC DejaGNU testsuite.
Bob Wilson [Thu, 2 Dec 2010 17:31:16 +0000 (17:31 +0000)]
Attempt to fix linux buildbots by adding -ffreestanding for arm_neon tests.
The arm_neon.h header includes stdint.h and it picks up the system header
without -ffreestanding.
IR Gen. part of API support for __block cxx
objects imported into blocks. //rdar://8594790.
Will have a test case coming (as well as one
sent to llvm test suite).
Douglas Gregor [Thu, 2 Dec 2010 16:14:14 +0000 (16:14 +0000)]
Remove NDEBUG-controlled extra data from
TemplateArgumentLocInfo. Unfortunately, this means that we lose some
internal consistency checking when building a debug Clang. However,
having data structures change size/layout depending on NDEBUG causes
pain for clients of the Clang API.
Bob Wilson [Thu, 2 Dec 2010 07:13:31 +0000 (07:13 +0000)]
Add a test for calling a Neon intrinsic macro with the wrong vector type.
This does not work so well with the -fno-lax-vector-conversions option for
testing the arm_neon.h header but that is a really useful test, so I split
this out to a separate Sema test to check for the warning.
Chris Lattner [Thu, 2 Dec 2010 07:07:26 +0000 (07:07 +0000)]
Improve codegen for initializer lists to use memset more aggressively
when an initializer is variable (I handled the constant case in a previous
patch). This has three pieces:
1. Enhance AggValueSlot to have a 'isZeroed' bit to tell CGExprAgg that
the memory being stored into has previously been memset to zero.
2. Teach CGExprAgg to not emit stores of zero to isZeroed memory.
3. Teach CodeGenFunction::EmitAggExpr to scan initializers to determine
whether they are profitable to emit a memset + inividual stores vs
stores for everything.
The heuristic used is that a global has to be more than 16 bytes and
has to be 3/4 zero to be candidate for this xform. The two testcases
are illustrative of the scenarios this catches. We now codegen test9 into:
Previously we produced 99 stores of zero for test9 and also tons for test10.
This xforms should substantially speed up -O0 builds when it kicks in as well
as reducing code size and optimizer heartburn on insane cases. This resolves
PR279.
Chris Lattner [Thu, 2 Dec 2010 01:58:41 +0000 (01:58 +0000)]
Enhance the init generation logic to emit a memset followed by a few stores when
a global is larger than 32 bytes and has fewer than 6 non-zero values in the
initializer. Previously we'd turn something like this:
char test8(int X) {
char str[10000] = "abc";
into a 10K global variable which we then memcpy'd from. Now we generate:
Bob Wilson [Thu, 2 Dec 2010 00:25:18 +0000 (00:25 +0000)]
Add a testcase for Radar 8228022.
Make sure the -Wvector-conversions does not cause unnecessary warnings when
using Neon intrinsics with the correct types.
Bob Wilson [Thu, 2 Dec 2010 00:25:15 +0000 (00:25 +0000)]
Swap order of checking for compatible vector types.
Check for compatible gcc, Altivec and Neon vectors before handling the
lax-vector-conversions case. Otherwise there is no way to avoid the
warnings from -Wvector-conversions.
Douglas Gregor [Wed, 1 Dec 2010 23:49:52 +0000 (23:49 +0000)]
Extend ExternalASTSource with the ability to lazily complete the
definition of an Objective-C class. Unlike with C/C++ classes, we
don't have a well-defined point in Sema where Objective-C classes are
checked for completeness, nor do we need to involve Sema when
completing a class. Therefore, we take the appropriate of having the
external AST source mark a particular Objective-C class as having an
external declaration; when using one of the accessors of an
Objective-C class that has an external declaration, we request that
the external AST source fill in the Objective-C class definition.
Douglas Gregor [Wed, 1 Dec 2010 21:43:58 +0000 (21:43 +0000)]
Improve our handling of cv-qualifiers in Objective-C pointer
conversions. Previously, we would end up collapsing qualification
conversions into the Objective-C pointer conversion step, including
(possibly) stripping qualifiers that shouldn't be removed.
This generalizes BuildSimilarlyQualifiedPointerType() to also work on
Objective-C object pointers, then eliminates the (redundant, not
totally correct) BuildSimilarlyQualifiedObjCObjectPointerType()
function.
Douglas Gregor [Wed, 1 Dec 2010 20:32:20 +0000 (20:32 +0000)]
Not content to implement just "extern" explicit template
instantiations, GCC also supports "inline" and "static" explicit
template instantiations. Parse and warn about such constructs, but
don't implement the semantics of either "inline" or "static". They
don't seem to be widely used.
Douglas Gregor [Wed, 1 Dec 2010 17:42:47 +0000 (17:42 +0000)]
After parsing a ':' in an enum-specifier within class context,
disambiguate between an expression (for a bit-field width) and a type
(for a fixed underlying type). Since the disambiguation can be
expensive (due to tentative parsing), we perform a simplistic
disambiguation based on one-token lookahead before going into the
full-blown tentative parsing. Based on a patch by Daniel Wallin.
Douglas Gregor [Wed, 1 Dec 2010 16:10:38 +0000 (16:10 +0000)]
Improve the diagnostic when the fixed underlying type of a
redeclaration of an enum type differs from that of the original
declaration, from Daniel Wallin
Dan Gohman [Wed, 1 Dec 2010 02:59:44 +0000 (02:59 +0000)]
Don't check the isysroot path for Path::isValid(); if the user has
specified a syntactically invalid path, it's better to let the OS
diagnose the problem than to silently skip it.
John McCall [Tue, 30 Nov 2010 23:21:46 +0000 (23:21 +0000)]
A CGRecordLayout object persists. Since its contained types may
refer to opaque types, they must be held via PATypeHolders. I'm
not sure why this hasn't blown up before.
Such function decls,as objc's objc_msgSend, builtins in
a specific language. We are adding such language info. by
extensing Builtins.def and via a language flag added
to LIBBUILTIN/BUILTIN and check for that when deciding
a name is builtin or not. Implements //rdar://8689273.