Reid Kleckner [Tue, 20 Oct 2015 21:04:13 +0000 (21:04 +0000)]
Re-land r250592 without rejecting field refs in unevaluated contexts
This time, I went with the first approach from
http://reviews.llvm.org/D6700, where clang actually attempts to form an
implicit member reference from an UnresolvedLookupExpr. We know that
there are only two possible outcomes at this point, a DeclRefExpr of the
FieldDecl or an error, but its safer to reuse the existing machinery for
this.
Reid Kleckner [Tue, 20 Oct 2015 18:12:08 +0000 (18:12 +0000)]
Look through using decls when classifying implicit member access
Clang will now accept this valid C++11 code:
struct A { int field; };
struct B : A {
using A::field;
enum { TheSize = sizeof(field) };
};
Previously we would classify the 'field' reference as something other
than a field, and then forget to apply the C++11 rule to allow
non-static data member references in unevaluated contexts.
This usually arises in class templates that want to reference fields of
a dependent base in an unevaluated context outside of an instance
method. Such contexts do not allow references to 'this', so the only way
to access the field is with a using decl and an implicit member
reference.
Chris Bieneman [Tue, 20 Oct 2015 16:39:25 +0000 (16:39 +0000)]
[CMake] Make external compiler-rt install scripts relative to CMAKE_INSTALL_PREFIX.
This change makes LLVM_BUILD_EXTERNAL_COMPILER_RT work correctly when overriding CMAKE_INSTALL_PREFIX on the install action (which is how LLVM_CREATE_XCODE_TOOLCHAIN works).
This fix is two parts:
(1) Pass CMAKE_INSTALL_PREFIX in as a variable from the parent install to the child install
(2) When passing COMPILER_RT_INSTALL_PATH into the external project make sure it is passed as a string not a path.
Not specifying the full path for COMPILER_RT_INSTALL_PATH isn't enough to fix the issue because relative paths specified on the CMake command line are expanded relative to the working directory before the cache is populated. Forcing this to a string allows it to remain a relative path through to the install() calls. Relative paths specified in install() calls are expanded relative to CMAKE_INSTALL_PREFIX at install time.
Benjamin Kramer [Tue, 20 Oct 2015 15:08:46 +0000 (15:08 +0000)]
[AST] Put TypeLocs and NestedNameSpecifierLocs into the ParentMap.
Firstly this changes the type of parent map to be keyed on DynTypedNode to
simplify the following changes. This comes with a DenseMapInfo for
DynTypedNode, which is a bit incomplete still and will probably only work
for parentmap right now.
Then the RecursiveASTVisitor in ASTContext is updated and finally
ASTMatchers hasParent and hasAncestor learn about the new functionality.
Now ParentMap is only missing TemplateArgumentLocs and CXXCtorInitializers.
Andrea Di Biagio [Tue, 20 Oct 2015 11:19:54 +0000 (11:19 +0000)]
[x86] Fix maskload/store intrinsic definitions in avxintrin.h
According to the Intel documentation, the mask operand of a maskload and
maskstore intrinsics is always a vector of packed integer/long integer values.
This patch introduces the following two changes:
1. It fixes the avx maskload/store intrinsic definitions in avxintrin.h.
2. It changes BuiltinsX86.def to match the correct gcc definitions for avx
maskload/store (see D13861 for more details).
Alexey Bataev [Tue, 20 Oct 2015 04:24:12 +0000 (04:24 +0000)]
[DEBUG INFO] Emit debug info for type used in explicit cast only.
Currently debug info for types used in explicit cast only is not emitted. It happened after a patch for better alignment handling. This patch fixes this bug.
Differential Revision: http://reviews.llvm.org/D13582
Reid Kleckner [Tue, 20 Oct 2015 00:31:42 +0000 (00:31 +0000)]
Revert "Diagnose UnresolvedLookupExprs that resolve to instance members in static methods"
This reverts commit r250592.
It has issues around unevaluated contexts, like this:
template <class T> struct A { T i; };
template <class T>
struct B : A<T> {
using A<T>::i;
typedef decltype(i) U;
};
template struct B<int>;
David Majnemer [Mon, 19 Oct 2015 23:22:49 +0000 (23:22 +0000)]
[MS ABI] Give linkonce_odr, instead of external_linkage, to certain kinds of static data members
Out-of-line definitions of static data members which have an inline
initializer must get GVA_DiscardableODR linkage instead of
GVA_StrongExternal linkage.
MSVC 2013's behavior is different with respect to this and would cause
link errors if one TU provided a definition while another did not.
MSVC 2015 fixed this bug, making this OK. Note that the 2015 behavior
is always compatible with 2013: it never produces a strong definition.
Nico Weber [Mon, 19 Oct 2015 16:21:29 +0000 (16:21 +0000)]
clang-format: Use pipes instead of temporary files for most lit tests.
This makes the format tests look more like most other FileCheck tests in clang.
The multiple-inputs tests still use temp files, to make sure that the file
input code in clang-format stays tested.
Stop stripping out the comment lines in style-on-command-line.cpp as they don't
get in the way and it makes the test simpler. Also remove 2>&1s on the tests in
that file that don't need it.
Marek Kurdej [Mon, 19 Oct 2015 10:08:35 +0000 (10:08 +0000)]
Added new options to ClangFormat VSIX package.
Summary:
Added new options to ClangFormat VSIX package:
* fallback-style
* assume-filename
* sort-includes.
Changed version to 1.1 (otherwise one couldn't update).
Fixed clang-format escaping of XML reserved characters.
Reviewers: hans, aaron.ballman, klimek, rnk, zturner
The Intel MCU psABI requires floating-point values to be passed in-reg.
This makes the x86-32 ABI code respect "-mfloat-abi soft" and generate float inreg arguments.
Alexey Bataev [Mon, 19 Oct 2015 06:40:17 +0000 (06:40 +0000)]
[OPENMP] Fix for http://llvm.org/PR25221: Infinite loop while parsing OpenMP directive
Clang skipped annot_pragma_openmp token, while it should be considered as a stop token while skipping tokens.
Since the attribute documentation is now auto-generated, the previous references
are no longer valid. This prevented the docs build from completing
successfully.
Nico Weber [Mon, 19 Oct 2015 01:08:30 +0000 (01:08 +0000)]
Update `clang-format -help` output in clang-format docs.
-assume-filename, -fallback-style, and -sort-includes are new. (They're also
longer than the previous options, so all descriptions shift over by some amount,
making this diff look larger than it is.)
It looks like someone renamed "General options" to "Generic Options" too.
Nico Weber [Mon, 19 Oct 2015 01:03:19 +0000 (01:03 +0000)]
Update list of languages advertised in OVERVIEW: A tool to format C/C++/Java/JavaScript/Objective-C/Protobuf code.
If no arguments are specified, it formats the code from standard input
and writes the result to the standard output.
If <file>s are given, it reformats the files. If -i is specified
together with <file>s, the files are edited in-place. Otherwise, the
result is written to the standard output.
USAGE: clang-format [options] [<file> ...]
OPTIONS:
-assume-filename=<string> - When reading from stdin, clang-format assumes this
filename to look for a style config file (with
-style=file) and to determine the language.
-cursor=<uint> - The position of the cursor when invoking
clang-format from an editor integration
-dump-config - Dump configuration options to stdout and exit.
Can be used with -style option.
-fallback-style=<string> - The name of the predefined style used as a
fallback in case clang-format is invoked with
-style=file, but can not find the .clang-format
file to use.
Use -fallback-style=none to skip formatting.
-help - Display available options (-help-hidden for more)
-i - Inplace edit <file>s, if specified.
-length=<uint> - Format a range of this length (in bytes).
Multiple ranges can be formatted by specifying
several -offset and -length pairs.
When only a single -offset is specified without
-length, clang-format will format up to the end
of the file.
Can only be used with one input file.
-lines=<string> - <start line>:<end line> - format a range of
lines (both 1-based).
Multiple ranges can be formatted by specifying
several -lines arguments.
Can't be used with -offset and -length.
Can only be used with one input file.
-offset=<uint> - Format a range starting at this byte offset.
Multiple ranges can be formatted by specifying
several -offset and -length pairs.
Can only be used with one input file.
-output-replacements-xml - Output replacements as XML.
-sort-includes - Sort touched include lines
-style=<string> - Coding style, currently supports:
LLVM, Google, Chromium, Mozilla, WebKit.
Use -style=file to load style configuration from
.clang-format file located in one of the parent
directories of the source file (or current
directory for stdin).
Use -style="{key: value, ...}" to set specific
parameters, e.g.:
-style="{BasedOnStyle: llvm, IndentWidth: 8}"
-version - Display the version of this program output.
Nick Lewycky [Sun, 18 Oct 2015 20:32:12 +0000 (20:32 +0000)]
No functionality change, just fix whitespace, a typo and remove an unnecessary
emacs mode marker. (Changes left behind from another patch that ended up not
working out.)
Dimitry Andric [Sun, 18 Oct 2015 13:32:20 +0000 (13:32 +0000)]
Support linking against OpenMP runtime on FreeBSD.
Summary:
Similar to rL248426 (which was a followup to rL248379 and rL248424), add the
required libraries for OpenMP on the linker command line, and update the test
case.
Daniel Jasper [Sun, 18 Oct 2015 07:02:28 +0000 (07:02 +0000)]
clang-format: [JS] Handle string literals spanning character classes.
If a RegExp contains a character group with a quote (/["]/), the
trailing end of it is first tokenized as a string literal, which leads
to the merging code seeing an unbalanced bracket.
This change parses regex literals from the left hand side. That
simplifies the parsing code and also allows correctly handling escapes
and character classes, hopefully correctly parsing all regex literals.
Patch by Martin Probst, thank you.
Review: http://reviews.llvm.org/D13765
Reid Kleckner [Sat, 17 Oct 2015 00:19:04 +0000 (00:19 +0000)]
Diagnose UnresolvedLookupExprs that resolve to instance members in static methods
During the initial template parse for this code, 'member' is unresolved
and we don't know anything about it:
struct A { int member };
template <typename T>
struct B : public T {
using T::member;
static void f() {
(void)member; // Could be static or non-static.
}
};
template class B<A>;
The pattern declaration contains an UnresolvedLookupExpr rather than an
UnresolvedMemberExpr because `f` is static, and `member` should never be
a field. However, if the code is invalid, it may become a field, in
which case we should diagnose it.
Richard Smith [Fri, 16 Oct 2015 23:20:19 +0000 (23:20 +0000)]
[modules] Allow the error when explicitly loading an incompatible module file
via -fmodule-file= to be turned off; in that case, just include the relevant
files textually. This allows module files to be unconditionally passed to all
compile actions via CXXFLAGS, and to be ignored for rules that specify custom
incompatible flags.
Richard Barton [Fri, 16 Oct 2015 20:15:29 +0000 (20:15 +0000)]
Further increase helfulness of assert message
If you increase the number of diags of a particular type by one more than the
number available you get the nice assert message. If you do it by two more
than available you get the old non-helpful message. Combining the two makes
sense I think.
r246877 made __builtin_object_size substantially more aggressive with
unknown bases if Type=1 or Type=3, which causes issues when we encounter
code like this:
__builtin_object_size(&f->str, 1) would hand back 1, which is
technically correct given the type of Foo, but the type of Foo lies to
us about how many bytes are available in this case.
This patch adds support for this "writing off the end" idiom -- we now
answer conservatively when we're given the address of the very last
member in a struct.
Previously, our logic when taking the address of an overloaded function
would not consider enable_if attributes, so long as all of the enable_if
conditions on a given candidate were true. So, two functions with
identical signatures (one with enable_if attributes, the other without),
would be considered equally good overloads. If we were calling the
function instead of taking its address, then the function with enable_if
attributes would be preferred.
This patch makes us prefer the candidate with enable_if regardless of if
we're calling or taking the address of an overloaded function.
Nico Weber [Thu, 15 Oct 2015 16:03:01 +0000 (16:03 +0000)]
clang-format/java: Break after annotations on fields in Chromium style.
Chromium follows the Android style guide for Java code, and that doesn't make
the distinction between fields and non-fields that the Google Java style guide
makes:
NAKAMURA Takumi [Thu, 15 Oct 2015 13:51:13 +0000 (13:51 +0000)]
Tweak to make clang/test/Driver/ps4-linker-win.c less sinsitive of DLL path.
- On mingw-w64, libstdc++-6.dll is used for clang.exe. The DLL might not be in Windows' system directory.
- With --enable-shared, DLLs might be in ${CMAKE_BINARY_DIR}/bin.
I understand this test confirms that appropriate name of executable can be found on %PATH%.
Therefore I added "Output\\" before each expression.
FIXME: The output directory %T is hardcoded like "Output\\ps4-ld.exe".
Teresa Johnson [Thu, 15 Oct 2015 13:41:51 +0000 (13:41 +0000)]
Revert "Clang support for -flto=thin." (bot failures)
Rolling this back for now since there are a couple of bot failures on
the new tests I added, and I won't have a chance to look at them in detail
until later this afternoon. I think the new tests need some restrictions on
having the gold plugin available.
There was a minor problem with a test. Sorry for the noise yesterday.
This patch adds missing pieces to clang, including the PS4 toolchain
definition, added warnings, PS4 defaults, and Driver changes needed for
our compiler.
A patch by Filipe Cabecinhas, Pierre Gousseau and Katya Romanova!
Sean Silva [Wed, 14 Oct 2015 06:45:07 +0000 (06:45 +0000)]
Revert-to-green r250262 (PS4 toolchain patch)
It is breaking llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast
e.g. http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/1362
Alexey Bataev [Wed, 14 Oct 2015 04:05:42 +0000 (04:05 +0000)]
[MSVC] Fix for http://llvm.org/PR24132: __declspec(property): double invocations of foo() when compiling foo()->propertyName
Removes extra codegen for base expression of MS property call
Differential Revision: http://reviews.llvm.org/D13375
I took care of the build problem in the commit 250252.
Resubmitting the patch.
This patch adds missing pieces to clang, including the PS4 toolchain
definition, added warnings, PS4 defaults, and Driver changes needed for
our compiler.
A patch by Filipe Cabecinhas, Pierre Gousseau and Katya Romanova!