Benjamin Kramer [Sat, 6 Oct 2012 14:42:22 +0000 (14:42 +0000)]
Expose __builtin_bswap16.
GCC has always supported this on PowerPC and 4.8 supports it on all platforms,
so it's a good idea to expose it in clang too. LLVM supports this on all targets.
Jordan Rose [Sat, 6 Oct 2012 01:19:36 +0000 (01:19 +0000)]
ParentMap: Restore the ability to update an existing map.
The Clang ASTs are a DAG, not a pure tree. However, ParentMap has to
choose a single parent for each object. In the main (only?) cases in
which the AST forms a DAG, it protects from multiple traversal by using
OpaqueValueExprs. Previously, ParentMap would just unconditionally look
through all OpaqueValueExprs when building its map.
In order to make this behavior better for the analyzer's diagnostics,
ParentMap was changed to not set a statement's parent if there already
was one in the map. However, ParentMap is supposed to allow updating
existing mappings by calling addStmt once again. This change makes the
"transparency" of OpaqueValueExprs explicit, and disables it when it
is not desired, rather than checking the current contents of the map.
This new code seems like a big change, but it should actually have
essentially the same performance as before. Only OpaqueValueExprs and
their users (PseudoObjectExpr and BinaryConditionalOperator) will
have any different behavior.
There should be no user-visible functionality change, though a test
has been added for the current behavior of BinaryConditionalOperator
source locations and accompanying Xcode arrows (which are not so great...).
Jordan Rose [Sat, 6 Oct 2012 01:19:30 +0000 (01:19 +0000)]
[analyzer] Handle implicit statements used for end-of-path nodes' source locs.
Some implicit statements, such as the implicit 'self' inserted for "free"
Objective-C ivar access, have invalid source locations. If one of these
statements is the location where an issue is reported, we'll now look at
the enclosing statements for a valid source location.
[libclang] Don't disable the preprocessing record while indexing so as
to not mess up with module building.
It was not worth trying to combine indexing without preprocessing record
and building modules with one because:
-just importing a module/PCH that was built with a pp record, enables it anyway
-the performance gain of indexing without the preprocessing record is insignificant.
David Blaikie [Fri, 5 Oct 2012 00:41:03 +0000 (00:41 +0000)]
Implement -Wshift-op-parentheses for: a << b + c
This appears to be consistent with GCC's implementation of the same warning
under -Wparentheses. Suppressing a << b + c for cases where 'a' is a user
defined type for compatibility with C++ stream IO. Otherwise suggest
parentheses around the addition or subtraction subexpression.
(this came up when MSVC was complaining (incorrectly, so far as I can tell)
about a perceived violation of this within the LLVM codebase, PR14001)
[preprocessing record] Have PPEntityID be independent of the size of the
loaded entities vector, otherwise its meaning will change when a module
is imported and the vector size changes.
Richard Smith [Thu, 4 Oct 2012 23:52:29 +0000 (23:52 +0000)]
If we flow off the end of a value-returning function:
- outside C++, return undef (behavior is not undefined unless the value is used)
- in C++, with -fcatch-undefined-behavior, perform an appropriate trap
- in C++, produce an 'unreachable' (behavior is undefined immediately)
Richard Smith [Thu, 4 Oct 2012 22:13:39 +0000 (22:13 +0000)]
Egriegious hack to support libstdc++4.6's broken <atomic> header, which defines
a non-inline namespace, then reopens it as inline to try to add its symbols to
the surrounding namespace. In this one special case, permit the namespace to be
reopened as inline, and patch up the name lookup tables to match.
Bill Schmidt [Thu, 4 Oct 2012 20:18:38 +0000 (20:18 +0000)]
Add a test case for r156143, which enabled general varargs support for the
64-bit PPC SVR4 ABI.
The test verifies passing of structures, items with 16-byte alignment, and
small items that are passed right-justified in the parameter save area slot.
Benjamin Kramer [Thu, 4 Oct 2012 19:42:20 +0000 (19:42 +0000)]
Driver: Link crtfastmath.o if it's available and -ffast-math is specified.
crtfastmath.o contains routines to set the floating point flags to a faster,
unsafe mode. Linking it in speeds up code dealing with denormals significantly
(PR14024).
For now this is only enabled on linux where I can test it and crtfastmath.o is
widely available. We may want to provide a similar file with compiler-rt
eventually and/or enable it on other platforms too.
Michael Han [Thu, 4 Oct 2012 16:42:52 +0000 (16:42 +0000)]
Fix scope location when parsing GNU attributes.
For GNU attributes, instead of reusing attribute source
location for the scope location, use SourceLocation() since
GNU attributes don not have scope tokens.
Axel Naumann [Thu, 4 Oct 2012 07:34:43 +0000 (07:34 +0000)]
Fix r165005: The lexical DeclContext is not the right place to make a decision about whether we need to call tryAddTopLevelDecl or not. That call should be made when the DeclContext's redeclaration context is the translation unit.
Eli Friedman [Thu, 4 Oct 2012 02:36:51 +0000 (02:36 +0000)]
Permanently end the whole "pragma got handled by the parser too early"
mess by handling all pragmas which the parser touches uniformly.
<rdar://problem/12248901>, etc.
Simon Atanasyan [Wed, 3 Oct 2012 19:52:37 +0000 (19:52 +0000)]
Remove useless parameter "WantFile" from Driver::GetProgramPath().
This parameter is useless because nowhere used explicitly and always
gets its default value - "false".
Bill Schmidt [Wed, 3 Oct 2012 19:18:57 +0000 (19:18 +0000)]
This patch enables general varargs support for the 64-bit PPC SVR4 ABI.
Most of the pieces for this were already in place, but a proper EmitVAArg
is needed for aggregates and complex numbers to be handled. Although the
va_list for 64-bit PowerPC SVR4 consists of GPRs 3 through 10 together with
the overflow portion of the parameter save area, we can treat va_list as
pointing to contiguous memory for all parameters, since the back end forces
the parameter GPRs to memory for varargs functions.
There is no need at this time to model parameters and return values beyond
what the DefaultABIInfo provides.
Douglas Gregor [Wed, 3 Oct 2012 18:38:43 +0000 (18:38 +0000)]
Remove ASTReader::needPendingInstantiation(), introduced in r164993,
which is neither correct nor necessary. The use of this routine was
eliminated by r165137.
Douglas Gregor [Wed, 3 Oct 2012 18:34:48 +0000 (18:34 +0000)]
Revert most of the functionality in r165001. Instead, make sure that
the ASTReader doesn't attach a body to a function that is already
defined elsewhere.
objective-C arc: Warn under arc about a use of an ivar inside a block
that doesn't have a 'self' as this implicitly captures 'self' and could
create retain cycles. Provide fixit. // rdar://11194874
Simon Atanasyan [Wed, 3 Oct 2012 17:46:38 +0000 (17:46 +0000)]
Implement Adnroid MIPS toolchain support:
1. Add mipsel-linux-android to the list of valid MIPS target triples.
2. Add <gcc install path>/mips-r2 to the list of toolchain specific path
prefixes if target is mipsel-linux-android.
Daniel Jasper [Wed, 3 Oct 2012 13:28:43 +0000 (13:28 +0000)]
As opposed to the clang-fixit tool described on
http://clang.llvm.org/docs/ClangTools.html, this adds -fixit option to
clang-check. Thus, clang-check can become a general-purpose tool to run
clang capitalizing on the info stored in a compilation database.
Bill Wendling [Wed, 3 Oct 2012 08:39:19 +0000 (08:39 +0000)]
The top-level clang Makefile is #included into other Makefiles. (sigh) So we
can't have the logic here to add in the 'tools/{driver,libclang}' directories,
because they will be added in for ALL Makefiles which #include the top-level
one. Place the logic into the 'tools' Makefile.
Nico Weber [Wed, 3 Oct 2012 06:57:02 +0000 (06:57 +0000)]
While I'm here, resync a %select with the enum definition it selects on.
* nullptr used to be mapped to ERROR, now mapped to nullptr
* integral was missing
* expressions now have their own error message, so they won't reach
this. Map them to ERROR.
Note that clang usually crashes before emitting this diagnostic anyway
(see PR13984), so this change alone doesn't have an observable effect.
It makes the code more correct though.
Nico Weber [Wed, 3 Oct 2012 06:46:47 +0000 (06:46 +0000)]
Move expression mangling in the microsoft mangler to its own function.
This matches what's done in ItaniumMangle and makes it a bit easier
to implement mangling for more expressions. Also use the slightly nicer
"not yet implemented" error message from there.
No functionality change (except for the different error message).
Introduce ASTConsumer::HandleImplicitImportDecl() callback that is invoked
when an ImportDecl that was implicitly created due to an inclusion directive.
Michael Han [Wed, 3 Oct 2012 01:56:22 +0000 (01:56 +0000)]
Improve C++11 attribute parsing.
- General C++11 attributes were previously parsed and ignored. Now they are parsed and stored in AST.
- Add support to parse arguments of attributes that in 'gnu' namespace.
- Differentiate unknown attributes and known attributes that can't be applied to statements when emitting diagnostic.
Jordan Rose [Wed, 3 Oct 2012 01:08:35 +0000 (01:08 +0000)]
[analyzer] Adjust the return type of an inlined devirtualized method call.
In C++, overriding virtual methods are allowed to specify a covariant
return type -- that is, if the return type of the base method is an
object pointer type (or reference type), the overriding method's return
type can be a pointer to a subclass of the original type. The analyzer
was failing to take this into account when devirtualizing a method call,
and anything that relied on the return value having the proper type later
would crash.
In Objective-C, overriding methods are allowed to specify ANY return type,
meaning we can NEVER be sure that devirtualizing will give us a "safe"
return value. Of course, a program that does this will most likely crash
at runtime, but the analyzer at least shouldn't crash.
The solution is to check and see if the function/method being inlined is
the function that static binding would have picked. If not, check that
the return value has the same type. If the types don't match, see if we
can fix it with a derived-to-base cast (the C++ case). If we can't,
return UnknownVal to avoid crashing later.