Aaron Ballman [Fri, 21 Feb 2014 14:14:04 +0000 (14:14 +0000)]
Moving the documentation for the type safety checking attributes into AttrDocs. If a custom heading is provided, do not automatically generate the alternate spelling list. This is necessary because some attributes have distinct semantic spellings and meanings, but use the same semantic attribute internally. Such attributes should have multiple elements in their documentation list, but not show all spellings. At some point, it would be nice to have a way to attach the documentation element to a specific spelling for these cases.
Tim Northover [Fri, 21 Feb 2014 11:57:24 +0000 (11:57 +0000)]
ARM & AArch64: use table for EmitCommonNeonBuiltinExpr
This extends the intrinsic lookup table format slightly, and adds
entries for use the shared ARM/AArch64 definitions. The benefit is
currently smaller than for the SISD intrinsics (there's more custom
code implementing this set), but a few lines are saved and there's
scope for future expansion.
NAKAMURA Takumi [Fri, 21 Feb 2014 07:59:59 +0000 (07:59 +0000)]
[CMake] Get rid of explicit dependencies to include/clang/*.inc and introduce CLANG_TABLEGEN_TARGETS.
This does;
- clang_tablegen() adds each tblgen'd target to global property CLANG_TABLEGEN_TARGETS as list.
- List of targets is added to LLVM_COMMON_DEPENDS.
- all clang libraries and targets depend on generated headers.
You might wonder this would be regression, but in fact, this is little loss.
- Almost all of clang libraries depend on tblgen'd files and clang-tblgen.
- clang-tblgen may cause short stall-out but doesn't cause unconditional rebuild.
- Each library's dependencies to tblgen'd files might vary along headers' structure.
It made hard to track and update *really optimal* dependencies.
Each dependency to intrinsics_gen and ClangSACheckers is left as DEPENDS.
Reid Kleckner [Fri, 21 Feb 2014 02:27:32 +0000 (02:27 +0000)]
MS ABI: Include the vfptr offset in memptrs to virtual methods
Virtual methods expect 'this' to point to the vfptr containing the
virtual method, and this extends to virtual member pointer thunks. The
relevant vfptr is always at offset zero on entry to the thunk, and no
this adjustment is needed.
Previously we would not include the vfptr adjustment in the member
pointer, and we'd look at the vfptr offset when loading from the vftable
in the thunk.
Warren Hunt [Fri, 21 Feb 2014 01:40:35 +0000 (01:40 +0000)]
[MS-ABI] Update to zero-sized padding algorithm
Slight change to the way zero-sized sub-objects are tracked in the
presence of virtual bases.
In addition we correctly distinguish between dsize and nvsize.
addresses http://llvm.org/bugs/show_bug.cgi?id=18826
Unit tests are included.
Bob Wilson [Fri, 21 Feb 2014 00:20:07 +0000 (00:20 +0000)]
Fix an assertion failure when invoking dsymutil.
There is no bound architecture for the dsymutil action in the driver. Trying
to check various properties of the target will cause an assertion failure
because the target doesn't get initialized without a bound architecture.
<rdar://problem/16111555>
Reid Kleckner [Thu, 20 Feb 2014 23:37:45 +0000 (23:37 +0000)]
Revert the removal of PPCallbacks::PragmaComment() in r201821
The pp-trace clang tool was using it successfully. We can still delete
the callbacks in Frontend/PrintPreprocessedOutput.cpp because they were
effectively dead.
David Majnemer [Thu, 20 Feb 2014 23:22:07 +0000 (23:22 +0000)]
Sema: Do not assert when dereferencing member pointer using virtual inheritance with an incomplete class type
The MS ABI requires that we determine the vbptr offset if have a
virtual inheritance model. Instead, raise an error pointing to the
diagnostic when this happens.
Reid Kleckner [Thu, 20 Feb 2014 23:07:29 +0000 (23:07 +0000)]
Revert "Enable MSRecordLayout in the presence of external sources."
This reverts commit r201810.
It was failing these tests on my workstation:
Clang :: CodeGen/override-layout.c
Clang :: CodeGenCXX/override-layout.cpp
Clang :: PCH/check-deserializations.cpp
Reid Kleckner [Thu, 20 Feb 2014 22:59:51 +0000 (22:59 +0000)]
Expand macros in pragmas with -fms-extensions and -E
gcc never expands macros in pragmas and MSVC always expands macros
before processing pragmas. Clang usually allows macro expansion, except
in a handful of pragmas, most of which are handled by the lexer.
Also remove PPCallbacks for pragmas that are currently handled in the
parser. Without a Parser, such as with clang -E, these callbacks would
never be called.
Ben Langmuir [Thu, 20 Feb 2014 21:59:23 +0000 (21:59 +0000)]
Recommit virtual file system
Previously reverted in r201755 due to causing an assertion failure.
I've removed the offending assertion, and taught the CompilerInstance to
create a default virtual file system inside createFileManager. In the
future, we should be able to reach into the CompilerInvocation to
customize this behaviour without breaking clients that don't care.
Warren Hunt [Thu, 20 Feb 2014 20:14:29 +0000 (20:14 +0000)]
Enable MSRecordLayout in the presence of external sources.
External sources shouldn't prevent the layout engine from using
MSLayout. If lldb were to support debugging in microsoft mode, some
code will need to be added to MSRecordLayoutBuilder to handel external
layouts.
Jordan Rose [Thu, 20 Feb 2014 17:43:31 +0000 (17:43 +0000)]
[CMake] Fix installation without CLANG_BUILD_EXAMPLES
When CLANG_BUILD_EXAMPLES is not on we set the EXCLUDE_FROM_ALL
directory property for the examples/ directory to tell CMake not to
build them by default. The AddLLVM.cmake APIs are not aware of this and
try to install targets that are not built. This does not cause an
install-time error because CMake excludes the directory from the default
installation. However, now that installation attaches targets to the
LLVMExports export set CMake-based applications that find_package(LLVM)
fail because the example plugin binary is not available.
Tell the AddLLVM.cmake APIs to exclude the examples from installation by
setting the EXCLUDE_FROM_ALL variable they check.
Which basically accepts any pointer. Changing this to char* simply
breaks a lot of existing code. I have tried changing char* to
"const void*", which seems to be the right thing as per Intel
specification this should work on basically any pointer. However,
apparently this breaks windows compatibility (because of a conflicting
declaration in windows.h).
So, we probably need to #ifdef this based on whether clang is compiling
for windows. According to Chandler, this might be done by introducing an
additional symbol to a fake type in BuiltinsX86.def and then condition
the type expansion on the platform.
Warren Hunt [Wed, 19 Feb 2014 23:20:20 +0000 (23:20 +0000)]
Add _mm_prefetch and some others as MS builtins
This patch adds several built-ins that are required for ms
compatibility. _mm_prefetch must be a built-in because it takes a
compile-time constant argument and our prior approach of using a #define
to the current built-in doesn't work in the presence of re-declaration
of _mm_prefetch. The others can be obtained by including the windows
system headers. If a user includes the windows system headers but not
intrin.h they still need to work and therefore must be built-in because
we don't get a chance to implement them in intrin.h in this case.
Aaron Ballman [Wed, 19 Feb 2014 23:09:37 +0000 (23:09 +0000)]
Until attribute documentation is implemented as a server-side feature, I will be manually committing AttributeReference.rst so that attribute documentation can be on the live server instead of simply disappearing from the language extensions page without obvious replacement.
This is a temporary stop-gap solution until server-side generation is implemented, at which point the AttributeReference.rst will go back to holding placeholder text.
Aaron Ballman [Wed, 19 Feb 2014 22:59:32 +0000 (22:59 +0000)]
Refactored the way attribute category headers are handled so that it is possible to use custom categories. This allows for moving the consumable attributes (consumable, callable_when, return_typestate, etc) to be grouped together, with a content heading, like they were in the language extensions documentation. Moved the consumable attribute documentation from the language extensions into the attribute documentation table.
Richard Smith [Wed, 19 Feb 2014 22:53:42 +0000 (22:53 +0000)]
Remove a broken attempt to cope with someone #undef'ing __has_include_next.
This was broken because __has_include_next(...) would not be valid in a
preprocessor condition if __has_include_next is not defined.
Chandler Carruth [Wed, 19 Feb 2014 22:35:01 +0000 (22:35 +0000)]
Teach Clang to provide ::max_align_t in C11 and C++11 modes.
This definition is not chosen idly. There is an unfortunate reality with
max_align_t -- the specific nature of its definition leaks into the ABI
almost immediately. Because it is part of C11 and C++11 it becomes
essential for it to match with other systems on that ABI. There is an
effort to discourage any further use of this construct as a consequence
-- using max_align_t introduces an immediate ABI problem. We can never
update it to have larger alignment even as the microarchitecture changes
to necessitate higher alignment. =/
The particular definition here exactly matches the ABI of GCC's chosen
::max_align_t definition, for better or worse. This was written with the
help of Richard Smith who was decoding the exact ABI implications of the
selected definition in GCC. Notably, in-register arguments are impacted
by the particular definition chosen. =/
No one is under the illusion that this is a "good" or "useful"
definition of max_align_t, and we are working with the standards
committee to specify a more useful interface to address this need.
Reid Kleckner [Wed, 19 Feb 2014 22:06:10 +0000 (22:06 +0000)]
MS ABI: Let non-virtual method overloads participate in vftable ordering
In the Microsoft ABI, the vftable is laid out as if all methods in every
overload set were declared in reverse order of declaration at the point
of declaration of the first overload in the set.
Previously we only considered virtual methods in an overload set, but
MSVC includes non-virtual methods for ordering purposes.
Aaron Ballman [Wed, 19 Feb 2014 20:43:58 +0000 (20:43 +0000)]
Some of these headings had the incorrect number of "underlines" and so would get warnings when generating the content from Sphinx. No functional changes intended.
Jordan Rose [Wed, 19 Feb 2014 17:44:16 +0000 (17:44 +0000)]
[analyzer] Extend IdenticalExprChecker to check logical and bitwise expressions.
IdenticalExprChecker now warns if any expressions in a logical or bitwise
chain (&&, ||, &, |, or ^) are the same. Unlike the previous patch, this
actually checks all subexpressions against each other (an O(N^2) operation,
but N is likely to be small).
Jordan Rose [Wed, 19 Feb 2014 17:44:11 +0000 (17:44 +0000)]
[analyzer] Extend IdenticalExprChecker to check the two branches of an if.
This extends the checks for identical expressions to handle identical
statements, and compares the consequent and alternative ("then" and "else")
branches of an if-statement to see if they are identical, treating a single
statement surrounded by braces as equivalent to one without braces.
This does /not/ check subsequent branches in an if/else chain, let alone
branches that are not consecutive. This may improve in a future patch, but
it would certainly take more work.
Aaron Ballman [Wed, 19 Feb 2014 14:48:31 +0000 (14:48 +0000)]
Moving the documentation for the enable_if attribute into AttrDocs. Removed the "clang introduces" phrase for style consistency, but otherwise the documentation is identical.
Tim Northover [Wed, 19 Feb 2014 11:55:06 +0000 (11:55 +0000)]
AArch64: look up EmitAArch64Scalar support before calling.
This fixes one immediate bug where an expression with side-effects
could be emitted twice during a NEON call.
It also prepares the way for folding CodeGen for many of the SISD
intrinsics into a table, reducing code size and hopefully increasing
performance eventually ("binary search + few switch cases" should be
better than "lots of switch cases").
Tim Northover [Wed, 19 Feb 2014 10:37:13 +0000 (10:37 +0000)]
ARM NEON: add vcvtX (with rounding mode) intrinsics to v8 ARM.
These instructions (well, the f32 ones) are supported on 32-bit ARMv8, not just
AArch64. Now that the arm_neon.td refactoring is complete, adding them is
surprisingly simple.
Tim Northover [Wed, 19 Feb 2014 10:37:09 +0000 (10:37 +0000)]
ARM NEON: use more flexible TableGen field for defs.
We used to have special handling for isCrypto and isA64 bits in the
NeonEmitter.cpp file (it knew the former was predicated on __ARM_FEATURE_CRYPTO
and the latter on __aarch64__ and went through various contortions to make sure
the correct intrinsics were emitted under the correct guard.
This is ugly and has obvious scalability problems (e.g. vcvtX intrinsics are
needed, which are ARMv8 only but available on both, yet another category). This
patch moves the #if predicate into the arm_neon.td file directly and makes
NeonEmitter.cpp agnostic about what goes in there.
It also deduplicates arm_neon.td so that each desired intrinsic is mentioned in
just one place (necessary because of the new mechanism for creating
arm_neon.h).
Tim Northover [Wed, 19 Feb 2014 10:37:05 +0000 (10:37 +0000)]
ARM & AArch64: merge the semantic checking of NEON intrinsics
There are two kinds of automatically generated tests for NEON intrinsics, both
of which can be merged without adversely affecting users.
1. We check that a valid kind of __builtin_neon_XYZ overload is requested (e.g.
we're not asking for a float32x4_t version when it only accepts integers. Since
the __builtin_neon_XYZ intrinsics should only be used in arm_neon.h, relaxing
this test and permitting AArch64 types for AArch32 should not cause a problem.
The extra arm_neon.h definitions should be #ifdefed out anyway.
2. We check that intrinsics which take immediates are actually given
compile-time constants within range. Since all NEON intrinsics should be
backwards compatible, these tests should be identical on AArch64 and AArch32
anyway.
This patch, therefore, merges the separate AArch64 and 32-bit checks.
David Majnemer [Wed, 19 Feb 2014 03:00:56 +0000 (03:00 +0000)]
Implement DR577
DR18 previously forebode typedefs to be used as parameter types if they
were of type 'void'. DR577 allows 'void' to be used as a function
parameter type regardless from where it came.
TU is not guaranteed to be initialised in all cases. In particular if CIdx or
ast_filename is NULL (or if &TU is NULL), then clang_createTranslationUnit2 will
not initialise the out parameter out_TU. This is followed by an assertion check
which may perform a branch based on unitialised memory.