Richard Smith [Sun, 21 Jul 2013 23:12:18 +0000 (23:12 +0000)]
Tighten up the set of operator new/operator delete calls we're permitted to
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.
Daniel Jasper [Sun, 21 Jul 2013 10:45:33 +0000 (10:45 +0000)]
clang-format: Smarter replacement in the vim integration.
With this fix, only changed regions will be replaced in vim's buffer.
Thereby, marks should mostly be left intact. Furthermore, this is a
better fix for the performance problem in conjunction with
'foldmethod=syntax' (see r186660).
add type attribute warn_unused, for -Wunused-variable warnings (pr#14253)
The functionality is equivalent to the GCC attribute. Variables of tagged
types will be warned about as unused if they are not used in any way
except for possible (even non-trivial) ctors/dtors called. Useful for tagging
classes like std::string (which is not part of this commit).
fix sometimes incorrect line numbers in -frewrite-includes mode (pr#14795)
Every #include is surrounded by #if 0 in order to comment it out, which adds
lines. That is fixed up right after, but that all can be inside #if part
that is not processed, so fix up also after every end of a conditional part.
David Majnemer [Sat, 20 Jul 2013 07:15:15 +0000 (07:15 +0000)]
DiagnosticIDs: Forbid Diag ID from being valid
Diag ID is used throughout clang as a sentinel id meaning "this is an
invalid diagnostic id." Confusingly, Diag ID maps to a valid, usable,
diagnostic id. Instead, start diagnostic ids at ID one.
Incidently, remove an unused element from StaticDiagInfo.
Richard Trieu [Sat, 20 Jul 2013 03:49:02 +0000 (03:49 +0000)]
If a default argument is a dependent type, get the real type from the desugared
template. Passing around dependent types can lead to integral arguments that
cannot be evaluated.
Eli Friedman [Sat, 20 Jul 2013 01:06:31 +0000 (01:06 +0000)]
Fix bug in computing POD-for-layout.
A class with a field of non-POD-for-layout type is not POD-for-layout.
This computation should not depend on whether the field is of POD type
in the language sense.
Eli Friedman [Sat, 20 Jul 2013 00:40:58 +0000 (00:40 +0000)]
Make IgnoreParens() look through ChooseExprs.
This is the same way GenericSelectionExpr works, and it's generally a
more consistent approach.
A large part of this patch is devoted to caching the value of the condition
of a ChooseExpr; it's needed to avoid threading an ASTContext into
IgnoreParens().
FIXME fix: improving diagnostics for template arguments deduction of class templates and explicit specializations
This patch essentially removes all the FIXMEs following calls to DeduceTemplateArguments() that want to keep track of deduction failure info.
Eli Friedman [Fri, 19 Jul 2013 21:49:32 +0000 (21:49 +0000)]
Correctly handle packs for variadic type traits.
I'm not sure how to write a test for this; the following shows the
difference in -ast-dump:
template <int x> struct A {};
template <class T> struct B { };
template <class ...Args> using C = A<(__is_trivially_constructible(Args...))>;
template <class ...Args> using D = C<B<Args>...>;
However, I can't seem to write a test that triggers a visible difference
in behavior.
Fix another place where clang check objc selector name instead of checking the selector family
Summary: In ARC mode, clang emits a warning if the result of an 'init' method is unused but miss cases where the method does not follows the Cocoa naming convention but is properly declared as an init family method.
Samuel Benzaquen [Fri, 19 Jul 2013 20:02:35 +0000 (20:02 +0000)]
Add support for raw_ostream on the printing methods of Diagnostics.
Summary:
Add printToStream*(llvm::raw_ostream&) methods to Diagnostics, and reimplement everything based on streams instead of concatenating strings.
Also, fix some functions to start with lowercase to match the style guide.
Canonical types are unchanged. The type printer had to be changed to
avoid printing any non-default implicit calling convention as well as
the calling convention attribute.
Eli Friedman [Fri, 19 Jul 2013 19:40:38 +0000 (19:40 +0000)]
Fix for template substitution with packs.
When we see a pack, and replace it with a template argument which is
also a pack, we want to use the pack pattern, not the expanded pack.
The caller should take care of expanding the pack afterwards.
Richard Smith [Fri, 19 Jul 2013 19:06:48 +0000 (19:06 +0000)]
Update users manual to indicate:
1) clang++ must be used when linking C++ programs using -fsanitize=undefined, and
2) MSan can't be combined with TSan or ASan.
Roman Divacky [Fri, 19 Jul 2013 17:28:36 +0000 (17:28 +0000)]
This patch implements __get_cpuid_max() as an inline and __cpuid() and
__cpuid_count() as macros to be compatible with GCC's cpuid.h. It also adds
bit_<foo> constants for the various feature bits as described in version 039
(May 2011) of Intel's SDM Volume 2 in the description of the CPUID
instruction. The list of bit_<foo> constants is a bit exhaustive (GCC
doesn't do near this many). More bits could be added from a newer version of
SDM if desired.
Daniel Jasper [Fri, 19 Jul 2013 09:30:44 +0000 (09:30 +0000)]
Improve clang-format vim integration.
The previous line-by-line replacement causes vim to take a long time if
the foldmethod is set to 'syntax'. This should significantly improve
performance in that case.
Hans Wennborg [Thu, 18 Jul 2013 20:29:38 +0000 (20:29 +0000)]
Turn Driver::CCCIsCXX and CCCIsCPP into a single Mode enum,
and add a new option --driver-mode= to control it explicitly.
The CCCIsCXX and CCCIsCPP flags were non-overlapping, i.e. there
are currently really three modes that Clang can run in: gcc, g++
or cpp, so it makes sense to represent them as an enum.
Having a command line flag to control it helps testing.
[Driver] Use LLVM's response file parser because it can read UTF-16
MSBuild writes response files as UTF-16 little endian with a byte order
mark. With this change, clang will be able to read them, although we
still can't parse any of their flags.
Adds a UTF-16-LE response file with a BOM for testing.
Samuel Benzaquen [Thu, 18 Jul 2013 19:47:59 +0000 (19:47 +0000)]
Separate the notion of 'context' when recursing down in the parser and actual errors.
Summary:
Change how error messages are constructed and stored in Diagnostics.
Separate the notion of 'context' when recursing down in the parser and actual errors.
This will simplify adding some new features, like argument overloading and error recovery.
Removed a parameter from handleAttrWithMessage to make it more consistent with other attribute handlers, as well as other attribute error messages. Added missing test cases for the unavailable attribute, and updated the deprecated test case.
Eric Christopher [Thu, 18 Jul 2013 00:52:50 +0000 (00:52 +0000)]
Instead of checking against some version of "isType()" go ahead and
use the conversion to bool to check if we've managed to get a type
that isn't default constructed - as we meant to in the first place.
Adrian Prantl [Thu, 18 Jul 2013 00:28:02 +0000 (00:28 +0000)]
Replace llvm::DIBuilder::DisableDebugLocations() with two RAII interfaces
inspired by CodegenFunction::LexicalScope.
- NoLocation temporarily turns off debug locations altogether.
This is useful for emitting instructions that should be
counted towards the function prologue.
- BuiltinLocation temporarily switches to an artificial debug location
that has a valid scope, but no line information. This is useful when
emitting compiler-generated helper functions that have no source
location associated with them.
Richard Smith [Wed, 17 Jul 2013 23:53:16 +0000 (23:53 +0000)]
Reinstate r186040, with additional fixes and more test coverage (reverted in
r186331).
Original commit log:
If we friend a declaration twice, that should not make it visible to
name lookup in the surrounding context. Slightly rework how we handle
friend declarations to inherit the visibility of the prior
declaration, rather than setting a friend declaration to be visible
whenever there was a prior declaration.
Jordan Rose [Wed, 17 Jul 2013 17:16:42 +0000 (17:16 +0000)]
[analyzer] Handle C++11 member initializer expressions.
Previously, we would simply abort the path when we saw a default member
initialization; now, we actually attempt to evaluate it. Like default
arguments, the contents of these expressions are not actually part of the
current function, so we fall back to constant evaluation.
Jordan Rose [Wed, 17 Jul 2013 17:16:38 +0000 (17:16 +0000)]
[analyzer] Handle C string default values for const char * arguments.
Previously, SValBuilder knew how to evaluate StringLiterals, but couldn't
handle an array-to-pointer decay for constant values. Additionally,
RegionStore was being too strict about loading from an array, refusing to
return a 'char' value from a 'const char' array. Both of these have been
fixed.
Jordan Rose [Wed, 17 Jul 2013 17:16:33 +0000 (17:16 +0000)]
[analyzer] Treat std::initializer_list as opaque rather than aborting.
Previously, the use of a std::initializer_list (actually, a
CXXStdInitializerListExpr) would cause the analyzer to give up on the rest
of the path. Now, it just uses an opaque symbolic value for the
initializer_list and continues on.
At some point in the future we can add proper support for initializer_list,
with access to the elements in the InitListExpr.