Commit Graph

16832 Commits

Author SHA1 Message Date
Michael Ilseman 43e17ad1d0 Remove unneeded typedef and volatile
llvm-svn: 169743
2012-12-10 18:48:08 +00:00
Aaron Ballman 02df2e0872 Virtual method overrides can no longer have mismatched calling conventions. This fixes PR14339.
llvm-svn: 169705
2012-12-09 17:45:41 +00:00
Chandler Carruth 6bb5c06e17 Add a triple to this test. It depends on little-endian bitfield layout.
llvm-svn: 169696
2012-12-09 10:39:18 +00:00
Chandler Carruth e8f7a95941 Add a test case that I've been using to clarify the bitfield layout for
both LE and BE targets.

AFAICT, Clang get's this correct for PPC64. I've compared it to GCC 4.8
output for PPC64 (thanks Roman!) and to my limited ability to read power
assembly, it looks functionally equivalent. It would be really good to
fill in the assertions on this test case for x86-32, PPC32, ARM, etc.,
but I've reached the limit of my time and energy... Hopefully other
folks can chip in as it would be good to have this in place to test any
subsequent changes.

To those who care about PPC64 performance, a side note: there is some
*obnoxiously* bad code generated for these test cases. It would be worth
someone's time to sit down and teach the PPC backend to pattern match
these IR constructs better. It appears that things like '(shr %foo,
<imm>)' turn into 'rldicl R, R, 64-<imm>, <imm>' or some such. They
don't even get combined with other 'rldicl' instructions *immediately
adjacent*. I'll add a couple of these patterns to the README, but
I think it would be better to look at all the patterns produced by this
and other bitfield access code, and systematically build up a collection
of patterns that efficiently reduce them to the minimal code.

llvm-svn: 169693
2012-12-09 10:08:22 +00:00
Chandler Carruth fd8eca202f Fix the bitfield record layout in codegen for big endian targets.
This was an egregious bug due to the several iterations of refactorings
that took place. Size no longer meant what it original did by the time
I finished, but this line of code never got updated. Unfortunately we
had essentially zero tests for this in the regression test suite. =[

I've added a PPC64 run over the bitfield test case I've been primarily
using. I'm still looking at adding more tests and making sure this is
the *correct* bitfield access code on PPC64 linux, but it looks pretty
close to me, and it is *worlds* better than before this patch as it no
longer asserts! =] More commits to follow with at least additional tests
and maybe more fixes.

Sorry for the long breakage due to this....

llvm-svn: 169691
2012-12-09 07:26:04 +00:00
Richard Smith 0db1ea5f68 Fix overload resolution for the initialization of a multi-dimensional
array from a braced-init-list. There seems to be a core wording wart
here (it suggests we should be testing whether the elements of the init
list are implicitly convertible to the array element type, not whether
there is an implicit conversion sequence) but our prior behavior appears
to be a bug, not a deliberate effort to implement the standard as written.

llvm-svn: 169690
2012-12-09 06:48:56 +00:00
Richard Smith f86b5dc700 PR14550: If a system header contains a bogus constexpr function definition,
don't mark the function as invalid, since we suppress the error.

llvm-svn: 169689
2012-12-09 05:55:43 +00:00
Richard Smith c88e40450d PR14549. Don't assert if we see an incomplete decltype specifier at the end of the file.
llvm-svn: 169688
2012-12-09 04:17:57 +00:00
Benjamin Kramer 2fec65d394 Escape % in the TextDiagnosticBuffer so they aren't interpreted twice when fed into the diagnostic formatting machinery again.
Fixes PR14543.

llvm-svn: 169677
2012-12-08 12:42:30 +00:00
David Chisnall a87d85994b long double should be 64 bits on FreeBSD/MIPS64. It possibly should be on
Linux too, as I think we inherited it from there.  The ABI spec says 128-bit,
although I think SGI's compiler on IRIX may be the only thing ever to support
this.

llvm-svn: 169674
2012-12-08 09:06:08 +00:00
Richard Smith 6b02d46dae Finish implementing 'selected constructor' rules for triviality in C++11. In
the cases where we can't determine whether special members would be trivial
while building the class, we eagerly declare those special members. The impact
of this is bounded, since it does not trigger implicit declarations of special
members in classes which merely *use* those classes.

In order to determine whether we need to apply this rule, we also need to
eagerly declare move operations and destructors in cases where they might be
deleted. If a move operation were supposed to be deleted, it would instead
be suppressed, and we could need overload resolution to determine if we fall
back to a trivial copy operation. If a destructor were implicitly deleted,
it would cause the move constructor of any derived classes to be suppressed.

As discussed on cxx-abi-dev, C++11's selected constructor rules are also
retroactively applied as a defect resolution in C++03 mode, in order to
identify that class B has a non-trivial copy constructor (since it calls
A's constructor template, not A's copy constructor):

struct A { template<typename T> A(T &); };
struct B { mutable A a; };

llvm-svn: 169673
2012-12-08 08:32:28 +00:00
DeLesley Hutchins 0cfa1a5a1d Thread-safety analysis: check member access on guarded non-primitive types.
llvm-svn: 169669
2012-12-08 03:46:30 +00:00
Richard Smith 92f241f188 Properly compute triviality for explicitly-defaulted or deleted special members.
Remove pre-standard restriction on explicitly-defaulted copy constructors with
'incorrect' parameter types, and instead just make those special members
non-trivial as the standard requires.

This required making CXXRecordDecl correctly handle classes which have both a
trivial and a non-trivial special member of the same kind.

This also fixes PR13217 by reimplementing DiagnoseNontrivial in terms of the
new triviality computation technology.

llvm-svn: 169667
2012-12-08 02:53:02 +00:00
Argyrios Kyrtzidis f77b0f8886 [libclang] Resolve a cursor that points to a macro name inside a #ifdef/#ifndef
directive as a macro expansion.

This is more of a "macro reference" than a macro expansion but it's close enough
for libclang's purposes. If it causes issues we can revisit and introduce a new
kind of cursor.

llvm-svn: 169666
2012-12-08 02:21:17 +00:00
Richard Smith 593f993a68 Implement C++03 [dcl.init]p5's checking for value-initialization of references
properly, rather than faking it up by pretending that a reference member makes
the default constructor non-trivial. That leads to rejects-valids when putting
such types inside unions.

llvm-svn: 169662
2012-12-08 02:01:17 +00:00
Argyrios Kyrtzidis 23de34d6d6 [libclang] Declarations inside anonymous namespaces have internal linkage so
their USR should contain a location.

This uniques them from other declarations with the same name but in different translation units.
rdar://10546541

llvm-svn: 169647
2012-12-07 22:41:46 +00:00
Anna Zaks 5d484780fb [analyzer] Optimization heuristic: do not reanalyze every ObjC method as
top level.

This heuristic is already turned on for non-ObjC methods
(inlining-mode=noredundancy). If a method has been previously analyzed,
while being inlined inside of another method, do not reanalyze it as top
level.

This commit applies it to ObjCMethods as well. The main caveat here is
that to catch the retain release errors, we are still going to reanalyze
all the ObjC methods but without inlining turned on.

Gives 21% performance increase on one heavy ObjC benchmark, which
suffered large performance regressions due to ObjC inlining.

llvm-svn: 169639
2012-12-07 21:51:47 +00:00
Jordan Rose 9a33913645 [analyzer] Fix r168019 to work with unpruned paths as well.
This is the case where the analyzer tries to print out source locations
for code within a synthesized function body, which of course does not have
a valid source location. The previous fix attempted to do this during
diagnostic path pruning, but some diagnostics have pruning disabled, and
so any diagnostic with a path that goes through a synthesized body will
either hit an assertion or emit invalid output.

<rdar://problem/12657843> (again)

llvm-svn: 169631
2012-12-07 19:56:29 +00:00
Matthew Curtis e5df381201 Hexagon TC: forward appropriate args to assembler
llvm-svn: 169611
2012-12-07 17:23:04 +00:00
Matthew Curtis 6b22278aa7 Hexagon TC: add cc1 defaults for hexagon-gcc
compatibility

llvm-svn: 169599
2012-12-07 13:52:44 +00:00
John McCall c818bbb8b2 Fix the required args count for variadic blocks.
We were emitting calls to blocks as if all arguments were
required --- i.e. with signature (A,B,C,D,...) rather than
(A,B,...).  This patch fixes that and accounts for the
implicit block-context argument as a required argument.
In addition, this patch changes the function type under which
we call unprototyped functions on platforms like x86-64 that
guarantee compatibility of variadic functions with unprototyped
function types;  previously we would always call such functions
under the LLVM type T (...)*, but now we will call them under
the type T (A,B,C,D,...)*.  This last change should have no
material effect except for making the type conventions more
explicit;  it was a side-effect of the most convenient implementation.

llvm-svn: 169588
2012-12-07 07:03:17 +00:00
NAKAMURA Takumi 3f2f792673 clang/test: Remove "REQUIRES:LP64" in two tests. Each of them have explicit triple.
llvm-svn: 169587
2012-12-07 06:57:40 +00:00
Richard Smith 50d705b5b0 Per [dcl.fct.def.default]p1, don't allow variadic special members to be defaulted.
llvm-svn: 169574
2012-12-07 02:10:28 +00:00
NAKAMURA Takumi 3c114f81b6 test/Index/skip-parsed-bodies/compile_commands.json: Remove XFAIL on cygming.
llvm-svn: 169566
2012-12-07 00:05:36 +00:00
Logan Chien 48a353d339 Revert r169557. It seems that the test is too restricted
and will break the build on buildbot.

llvm-svn: 169562
2012-12-06 23:40:31 +00:00
Argyrios Kyrtzidis fc7f04510c [libclang] Add a test to make sure we skip bodies properly from "#pragma once" headers.
llvm-svn: 169558
2012-12-06 23:04:24 +00:00
Logan Chien 74aa8f1141 Add i686-linux-android for gcc toolchain detection.
* Look for i686-linux-android under <sysroot>/lib/gcc.

* This patch also slightly enhance the test suite for
  Android GCC toolchain detection.

llvm-svn: 169557
2012-12-06 22:59:37 +00:00
Matthew Curtis 4446bca53e hexagon-toolchain.c now passes on win32
llvm-svn: 169548
2012-12-06 21:25:18 +00:00
Matthew Curtis 1ece04413c relax hexagon-toolchain.c even more to accomodate mingw32 targets
llvm-svn: 169544
2012-12-06 20:55:41 +00:00
Matthew Curtis ed6f395c68 relax hexagon-toolchain.c CHECK to accomodate mingw32 targets
llvm-svn: 169543
2012-12-06 20:21:20 +00:00
Argyrios Kyrtzidis 8b71bc7d6b [libclang] Introduce a new indexing mode where we skip function bodies
that were already parsed in the same "indexing session".

An indexing session is defined as using the same CXIndexAction object
for multiple clang_indexSourceFile calls.
Passing CXIndexOpt_SkipParsedBodiesInSession as an indexing option will
enable the mode where we try to skip bodies that were already parsed in
another translation unit.

If a function's body was skipped, the "flags" field in the CXIdxDeclInfo
structure will have "CXIdxDeclFlag_Skipped" bit was set.

llvm-svn: 169539
2012-12-06 19:41:16 +00:00
Matthew Curtis c91f0be499 Un-XFAIL hexagon-toolchain.c test for mingw32
llvm-svn: 169533
2012-12-06 19:03:09 +00:00
Jordan Rose ff03c1d26d [analyzer] Simplify RetainCountChecker's handling of dead symbols.
Previously we made three passes over the set of dead symbols, and removed
them from the state /twice/. Now we combine the autorelease pass and the
symbol death pass, and only have to remove the bindings for the symbols
that leaked.

llvm-svn: 169527
2012-12-06 18:58:18 +00:00
Fariborz Jahanian a14523f11c Fixes a typo in this test.
llvm-svn: 169519
2012-12-06 17:50:40 +00:00
Matthew Curtis e8f80a12bd Hexagon TC: Add/improve support for small data
threshold, pic, pie

llvm-svn: 169517
2012-12-06 17:49:03 +00:00
Matthew Curtis ff15a1d2e5 Fix hexagon-toolchain.c test to handle versioned clang executables.
llvm-svn: 169513
2012-12-06 16:01:06 +00:00
Matthew Curtis e689b0570c Hexagon TC: Reimplement Link::ConstructJob to call
linker directly

Rather than calling gcc.

llvm-svn: 169512
2012-12-06 15:46:07 +00:00
Benjamin Kramer 6928cf7826 Sema: Don't emit a warning when __func__ is used in a lambda outside of a function.
Fixes PR14518.

llvm-svn: 169510
2012-12-06 15:42:21 +00:00
NAKAMURA Takumi 8ccff08f76 test/Driver/hexagon-toolchain.c: Unbreak XPASS. Cygwin can be treated as unix-like system.
llvm-svn: 169509
2012-12-06 14:42:56 +00:00
Matthew Curtis f10a595eac Hexagon TC: Move getHexagonTargetCPU from Tools.cpp to
ToolChains.cpp

This is in anticipation of forthcoming library path changes.

Also ...
- Fixes some inconsistencies in how the arch is passed to tools.
- Add test cases for various forms of arch flags

llvm-svn: 169505
2012-12-06 14:16:43 +00:00
Matthew Curtis b69d3da00b Disable hexagon toolchain test on windows targets
llvm-svn: 169498
2012-12-06 13:06:19 +00:00
Matthew Curtis 22dd8da6cd Hexagon TC: Update toolchain to add appropriate include
paths

- Inherit from Linux rather than ToolChain
- Override AddClangSystemIncludeArgs and AddClangCXXStdlibIncludeArgs
  to properly set include paths.

llvm-svn: 169495
2012-12-06 12:43:18 +00:00
NAKAMURA Takumi dbe7d7e965 clang/test/CodeGen/2008-01-07-UnusualIntSize.c: Add triple x86_64. It doesn't assume 32-bit target, for now.
llvm-svn: 169492
2012-12-06 12:05:25 +00:00
Chandler Carruth ff0e3a1e1c Rework the bitfield access IR generation to address PR13619 and
generally support the C++11 memory model requirements for bitfield
accesses by relying more heavily on LLVM's memory model.

The primary change this introduces is to move from a manually aligned
and strided access pattern across the bits of the bitfield to a much
simpler lump access of all bits in the bitfield followed by math to
extract the bits relevant for the particular field.

This simplifies the code significantly, but relies on LLVM to
intelligently lowering these integers.

I have tested LLVM's lowering both synthetically and in benchmarks. The
lowering appears to be functional, and there are no really significant
performance regressions. Different code patterns accessing bitfields
will vary in how this impacts them. The only real regressions I'm seeing
are a few patterns where the LLVM code generation for loads that feed
directly into a mask operation don't take advantage of the x86 ability
to do a smaller load and a cheap zero-extension. This doesn't regress
any benchmark in the nightly test suite on my box past the noise
threshold, but my box is quite noisy. I'll be watching the LNT numbers,
and will look into further improvements to the LLVM lowering as needed.

llvm-svn: 169489
2012-12-06 11:14:44 +00:00
Ted Kremenek 3e871d8cf6 Use the BlockDecl captures list to infer the direct captures for a BlockDataRegion. Fixes <rdar://problem/12415065>.
We still need to do a recursive walk to determine all static/global variables
referenced by a block, which is needed for region invalidation.

llvm-svn: 169481
2012-12-06 07:17:26 +00:00
Richard Smith 16b65394ee Fix http://stackoverflow.com/questions/13521163
Don't require that, during template deduction, a template specialization type
as a function parameter has at least as many template arguments as one used in
a function argument (not even if the argument has been resolved to an exact
type); the additional parameters might be provided by default template
arguments in the template. We don't need this check, since we now implement
[temp.deduct.call]p4 with an additional check after deduction.

llvm-svn: 169475
2012-12-06 06:44:44 +00:00
Richard Smith 7808c6aa7e Don't use dyn_cast on a Type* which might not be canonical. Fixes an extremely obscure record layout bug.
llvm-svn: 169467
2012-12-06 03:04:50 +00:00
NAKAMURA Takumi 5c9f577c7f Disable clang/test/Preprocessor/macro-multiline.c for now, while investigating lit.ShUtil.parser.
llvm-svn: 169458
2012-12-06 01:09:31 +00:00
Fariborz Jahanian b42b6f2674 more test of template declarations in a
<declaration> XML tag. // rdar://12378714

llvm-svn: 169457
2012-12-06 00:57:28 +00:00
Fariborz Jahanian 3ec39215f9 More C++ testing of declarations embedded in
<declaration> tag of Comment XML  and fixing 
DeclPrint of templates along the way - wip. 
//rdar://12378714

llvm-svn: 169453
2012-12-06 00:09:40 +00:00
Chad Rosier 636386753a [driver, ms-inline asm] Have -fms-extensions enable the AsmBlocks language
option.  MS-style inline asm can now be enabled by either -fasm-blocks or
-fms-extensions.
rdar://12808010

llvm-svn: 169445
2012-12-05 23:08:09 +00:00
Richard Smith b958980cec Looks like lit on Windows can't cope with parens here, and in any case, we shouldn't need them after r169441.
llvm-svn: 169442
2012-12-05 22:59:28 +00:00
Richard Smith 48f244ac2c More workarounds for PR10867.
llvm-svn: 169437
2012-12-05 22:33:14 +00:00
Richard Smith c524ec4411 Fix an egregiously broken test. This pattern doesn't work:
RUN: a
RUN: b || true

lit expands it to a && b || true, and the || true applies to both commands (thus ignoring failures in 'a')! This is PR10867 again.

llvm-svn: 169434
2012-12-05 22:18:04 +00:00
Bill Wendling 0edf38167f Fix name. The array is unboundED.
llvm-svn: 169429
2012-12-05 21:43:37 +00:00
Chad Rosier c8e56e8931 [driver, ms-inline asm] MS-Style inline assembly is controlled by the
-fasm-blocks flag, not the -fms-extensions flag.
rdar://12808010

llvm-svn: 169422
2012-12-05 21:08:21 +00:00
Fariborz Jahanian 14ef4790d1 Testing C++ declarations embedded in
<declaration> tag of Comment XML.
Added DeclPrint support for constructors
and fix tests accordingly.
This is wip. // rdar://12378714

llvm-svn: 169412
2012-12-05 19:54:11 +00:00
Chad Rosier ed92815cb0 [ms-inline asm] Add more tests.
llvm-svn: 169411
2012-12-05 19:52:05 +00:00
Jordan Rose 0e5badd93b Format strings: offer a cast to 'unichar' for %C in Objective-C contexts.
For most cases where a conversion specifier doesn't match an argument,
we usually guess that the conversion specifier is wrong. However, if
the argument is an integer type and the specifier is %C, it's likely
the user really did mean to print the integer as a character.

(This is more common than %c because there is no way to specify a unichar
literal -- you have to write an integer literal, such as '0x2603',
and then cast it to unichar.)

This does not change the behavior of %S, since there are fewer cases
where printing a literal Unicode *string* is necessary, but this could
easily be changed in the future.

<rdar://problem/11982013>

llvm-svn: 169400
2012-12-05 18:44:49 +00:00
Jordan Rose ea0fdfe146 Format strings: add more expression types that don't need parens to cast.
No functionality change (the test change is a comment only, and the new
functionality can't be tested using the current test).

llvm-svn: 169399
2012-12-05 18:44:44 +00:00
Jordan Rose 598ec0992d Format strings: a character literal should be printed with %c, not %d.
The type of a character literal is 'int' in C, but if the user writes a
character /as/ a literal, we should assume they meant it to be a
character and not a numeric value, and thus offer %c as a correction
rather than %d.

There's a special case for multi-character literals (like 'MooV'), which
have implementation-defined value and usually cannot be printed with %c.
These still use %d as the suggestion.

In C++, the type of a character literal is 'char', and so this problem
doesn't exist.

<rdar://problem/12282316>

llvm-svn: 169398
2012-12-05 18:44:40 +00:00
Jordan Rose 6aaa87e0d2 Format strings: the correct conversion for 'char' is %c, not %d or %hhd.
We tried to account for 'uint8_t' by saying that /typedefs/ of 'char'
should be corrected as %hhd rather than %c, but the condition was wrong.

llvm-svn: 169397
2012-12-05 18:44:37 +00:00
Evgeniy Stepanov cdc22553eb Reuse an existing diagnostic for tsan/msan needing -pie error.
Add a diagnosting for -fsanitize=memory conflicting with other sanitizers.
Extend tests.

llvm-svn: 169380
2012-12-05 13:37:12 +00:00
NAKAMURA Takumi 55bccc3702 test/Modules/build-fail-notes.m: Tweak to unbreak Win32 hosts to relax expressions, for now.
llvm-svn: 169375
2012-12-05 11:52:45 +00:00
Richard Smith 3e284699d9 In C++, if we hit an error in the class-head, don't try to parse the class body.
Our error recovery path may have made the class anonymous, and that has a pretty
disastrous impact on any attempt to parse a class body containing constructors.

llvm-svn: 169374
2012-12-05 11:34:06 +00:00
Richard Smith f89e2e2583 PR14049: Don't say "expanded from macro 'foo'" when 'foo' just happens to be
the LHS of a token paste. Use "expanded from here" instead when we're not sure
it's actually a macro.

llvm-svn: 169373
2012-12-05 11:04:55 +00:00
Richard Smith afa874d4c0 This test used to fail forever if it failed once, because it does not clean up after itself if it failed.
llvm-svn: 169356
2012-12-05 06:16:54 +00:00
DeLesley Hutchins f489d2b86c Thread-safety analysis: check locks on method calls, operator=, and
copy constructors.

llvm-svn: 169350
2012-12-05 01:20:45 +00:00
Anna Zaks 25dd07c112 [analyzer] Implement an opt-in variant of direct ivar assignment.
This will only check the direct ivar assignments in the annotated
methods.

llvm-svn: 169349
2012-12-05 01:14:37 +00:00
Fariborz Jahanian bfc3ef55be Testing C++ declarations embedded in
<declaration> tag of Comment XML and 
added support for friend declaration printing.
This is wip. // rdar://12378714

llvm-svn: 169346
2012-12-05 00:38:44 +00:00
Chandler Carruth 210c77b38c Add -whole-archive around the ASan runtime archive in the link command.
This ensures that even though it comes first, we pick up its .o files.
Note that if we can use this (or something similar / equivalent) on
other platforms, we could potentially remove
ReplaceOperatorsNewAndDelete from the ASan runtimes.

We should probably do something similar for TSan and MSan as well.

llvm-svn: 169328
2012-12-04 22:54:37 +00:00
Bill Wendling 751afdc3d1 Use the 'count' attribute to calculate the upper bound of an array.
The count attribute is more accurate with regards to the size of an array. It
also obviates the upper bound attribute in the subrange. We can also better
handle an unbound array by setting the count to -1 instead of the lower bound to
1 and upper bound to 0.

llvm-svn: 169311
2012-12-04 21:33:58 +00:00
Matt Beaumont-Gay 35439dff76 Currently, with -fsanitize=address, the driver appends libclang_rt.asan.a to
the link command. This all works fine when the driver is also responsible for
adding -lstdc++ to the link command. But, if -lstdc++ (or libstdc++.a, etc) is
passed explicitly to the driver, the ASan runtime will appear in the link
command after the standard library, leading to multiple-definition errors for
the global 'operator new' and 'operator delete'. Fix this in a painfully
simple way, by inserting libclang_rt.asan.a at the start of the link command
instead of the end.

If we need to do something more clever, we can walk the link command looking
for something that resembles libstdc++ and insert libclang_rt.asan.a as late
as possible, but the simple solution works for now.

llvm-svn: 169310
2012-12-04 21:18:26 +00:00
Fariborz Jahanian 1ace8cb994 Testing C declarations embedded in
<declaration> tag of Comment XML and fixed a
missing block literal printout as result of the testing. 
// rdar://12378714

llvm-svn: 169307
2012-12-04 21:15:23 +00:00
Fariborz Jahanian 4a7dc6e3e6 additional test for declaration tag of a class extension.
// rdar://12378714

llvm-svn: 169289
2012-12-04 18:25:34 +00:00
Fariborz Jahanian 4cf177e238 objective-c blocks: Consider padding due to alignment
after the fixed size block header when generating
captured block variable info. // rdar://12773256

llvm-svn: 169285
2012-12-04 17:20:57 +00:00
Dmitri Gribenko b506ba1d79 libclang: Add a function to libclang for retrieving the bit width value
Patch by Jyun-Yan You.

llvm-svn: 169276
2012-12-04 15:13:46 +00:00
Bill Wendling 6246013f7a Don't test for ASM output but for IR output.
llvm-svn: 169232
2012-12-04 07:33:40 +00:00
NAKAMURA Takumi ecc759a684 clang/test/CodeGenCXX/debug-info-zero-length-arrays.cpp: Add explicit triple, x86_64-unknown-unknown. It was incompatible to i686.
llvm-svn: 169220
2012-12-04 06:58:05 +00:00
Bill Wendling 1ca9862cfb Add a 'count' field to the DWARF subrange.
The count field is necessary because there isn't a difference between the 'lo'
and 'hi' attributes for a one-element array and a zero-element array. When the
count is '0', we know that this is a zero-element array. When it's >=1, then
it's a normal constant sized array. When it's -1, then the array is unbounded.

llvm-svn: 169219
2012-12-04 06:21:27 +00:00
NAKAMURA Takumi 384a957051 clang/test/Index/comment-objc-decls.m: Try to fix r169193, to add x86_64-darwin.
llvm-svn: 169199
2012-12-04 01:03:31 +00:00
Fariborz Jahanian 95759ff807 Testing objective-C declarations embedded in
<declaration> tag of Comment XML and fixed a
missing declaration of ivars private to @implementation
as result of the testing. // rdar://12378714

llvm-svn: 169193
2012-12-04 00:47:33 +00:00
Michael Ilseman 7a167eef2f Have clang use LLVM IR's fast-math flags when in FastMath or FiniteMathOnly modes. Test cases included.
llvm-svn: 169191
2012-12-04 00:36:06 +00:00
NAKAMURA Takumi 55a8d1d1c1 clang/test/Driver/fsanitize-blacklist.c: Mark it as XFAIL:cygming, due to PR12920.
llvm-svn: 169180
2012-12-03 23:29:49 +00:00
Alexey Samsonov 9ab73626fc Add Clang flags -fsanitize-blacklist and -fno-sanitize-blacklist. Make this flag usable for ASan. Blacklisting can be used to disable sanitizer checks for particular file/function/object.
llvm-svn: 169144
2012-12-03 19:12:58 +00:00
Alexey Samsonov 9c1b9f60ad Fix PR14474: don't emit debug info for interface types in -gline-tables-only mode.
llvm-svn: 169138
2012-12-03 18:28:12 +00:00
Will Dietz 88e0233ff4 [ubsan] Add flag to enable recovery from checks when possible.
llvm-svn: 169114
2012-12-02 19:50:33 +00:00
Simon Atanasyan 2eaec51f66 [MIPS] Add -mxgot/-mno-xgot command line options
to enable/disable support of GOT larger than 64k.

llvm-svn: 169098
2012-12-01 18:27:21 +00:00
Eli Bendersky 2592e4e851 Fix a test that was redefining FileCheck variables while referencing old ones.
In preparation for the FileCheck enhancement to support backreferences.

llvm-svn: 169090
2012-12-01 13:50:51 +00:00
Joey Gouly a35a289de6 Switch to using -### as mentioned by chandlerc.
llvm-svn: 169089
2012-12-01 13:07:22 +00:00
Joey Gouly f1040fdd51 Add -emit-llvm to test/Driver/fsanitize.c to stop this failing on the ARM bot. Approved by d0k.
llvm-svn: 169088
2012-12-01 12:15:28 +00:00
Eli Friedman fe9d110f3a Try to make the source location information for token pastes a bit more consistent.
Fixes a crash printing diagnostics on the gcc testsuite, and also makes
diagnostic range printing print nicer results for token pastes.

llvm-svn: 169068
2012-12-01 01:15:54 +00:00
Richard Smith 06d87f1e5d Remove restriction on combining ubsan with asan or tsan. This has worked for a while.
llvm-svn: 169066
2012-12-01 01:02:45 +00:00
Douglas Gregor c401755f46 Fix the determination of whether a capture refers to an enclosing
scope when dealing with nested blocks. Fixes <rdar://problem/12778708>.

llvm-svn: 169065
2012-12-01 01:01:09 +00:00
Bill Wendling 0517508c00 Don't emit a warning with an input/output parameter. We assume the user knows what they're doing here.
llvm-svn: 169059
2012-11-30 23:46:56 +00:00
Douglas Gregor 47238dc057 Fix test for Windows path separators
llvm-svn: 169058
2012-11-30 23:40:49 +00:00
Douglas Gregor fa686fb4ed Teach the serialized diagnostic writer to clone() itself, sharing
state so that all of the various clones end up rendering their
diagnostics into the same serialized-diagnostics file. This is
important when we actually want failures during module build to be
reported back to the translation unit that tried to import the
not-yet-built or out-of-date module. <rdar://problem/12565727>

llvm-svn: 169057
2012-11-30 23:32:31 +00:00
Bill Wendling 3c6591d6ea Don't warn if the input size is less than the register size. Also don't warn if
the output size is greater than the register size. No truncation occurs with
those. Reword warning to make it clearer what's the problem is.

llvm-svn: 169054
2012-11-30 23:18:12 +00:00
Eli Friedman 5ac9875160 Make -Wtautological-constant-out-of-range-compare behave sanely for enums with a signed fixed type.
<rdar://problem/12780159>.

llvm-svn: 169051
2012-11-30 23:09:29 +00:00
Douglas Gregor 22103e3416 When we're emitting a diagnostic with a source location in an imported
module, provide a module import stack similar to what we would get for
an include stack, e.g.,

In module 'DependsOnModule' imported from build-fail-notes.m:4:
In module 'Module' imported from DependsOnModule.framework/Headers/DependsOnModule.h:1:
Inputs/Module.framework/Headers/Module.h:15:12: note: previous definition is here
@interface Module

<rdar://problem/12696425>

llvm-svn: 169042
2012-11-30 21:58:49 +00:00
Aaron Ballman 406ea51cfb Support for #pragma region/endregion for MSVC compatibility. Patch thanks to pravic!
llvm-svn: 169028
2012-11-30 19:52:30 +00:00
Douglas Gregor af8f02634b When an error occurs while building a module on demand, provide "While
building module 'Foo' imported from..." notes (the same we we provide
"In file included from..." notes) in the diagnostic, so that we know
how this module got included in the first place. This is part of
<rdar://problem/12696425>.

llvm-svn: 169021
2012-11-30 18:38:50 +00:00
Eli Friedman dea98de3fb Fix the computation of highlight ranges so we produce something sane when
the beginning and end of the range are in different macro arguments.
PR14399.

llvm-svn: 168984
2012-11-30 06:19:40 +00:00
Quentin Colombet 317962381a Add a test case for the new cortex-a5 switch
llvm-svn: 168968
2012-11-30 01:34:36 +00:00
Douglas Gregor 7a626570ef Keep track of modules that have failed to build. If we encounter an
import of that module elsewhere, don't try to build the module again:
it won't work, and the experience is quite dreadful. We track this
information somewhat globally, shared among all of the related
CompilerInvocations used to build modules on-the-fly, so that a
particular Clang instance will only try to build a given module once.

Fixes <rdar://problem/12552849>.

llvm-svn: 168961
2012-11-29 23:55:25 +00:00
Eli Friedman a92db6773a Fix a small calling-convention bug for x86-32. PR14453.
llvm-svn: 168959
2012-11-29 23:21:04 +00:00
Alexey Samsonov 0e96becfb1 This patch exposes to Clang users three more sanitizers are experimental features of ASan:
1) init-order sanitizer: initialization-order checker.
Status: usable, but may produce false positives w/o proper blacklisting.
2) use-after-return sanitizer
Status: implemented, but heavily understed.
Should be optional, as it significanlty slows program down.
3) use-after-scope sanitizer
Status: in progress.

llvm-svn: 168950
2012-11-29 22:36:21 +00:00
Eli Bendersky 479b1b5986 Make the test less sensitive to DWARF emission implementation details.
Note: the ":" goes into the regex because FileCheck wrongly complains about
unbalanced brackets otherwise.

llvm-svn: 168934
2012-11-29 20:01:14 +00:00
Eric Christopher 0499778517 Make sure that we put the rest of the sanitizer libraries on the link line
before libstdc++ like we do with ubsan.

llvm-svn: 168918
2012-11-29 18:51:05 +00:00
Eric Christopher a0f27b3e2c Use newer command line option here.
llvm-svn: 168908
2012-11-29 18:08:24 +00:00
Eric Christopher 5535598bbc Remove duplicate test run lines.
llvm-svn: 168907
2012-11-29 18:08:22 +00:00
Rafael Espindola 8778c28022 Merge function types in C.
Among other differences, GCC accepts

  typedef int IA[];
  typedef int A10[10];
  static A10 *f(void);
  static IA  *f(void);
  void g(void) {
    (void)sizeof(*f());
  }

but clang used to reject it with:

  invalid application of 'sizeof' to an incomplete type 'IA' (aka 'int []')

The intention of c99's 6.2.7 seems to be that we should use the composite type
and accept as gcc does.

Doing the type merging required some extra fixes:
  * Use the type from the function type in initializations, even if an parameter
    is available.
  * Fix the merging of the noreturn attribute in function types.
  * Make CodeGen  handle the fact that an parameter type can be different from
    the corresponding type in the function type.

llvm-svn: 168895
2012-11-29 16:09:03 +00:00
Timur Iskhodzhanov 6732d350ef [-cxx-abi microsoft] Also spill the argument-back-references context when mangling templates
llvm-svn: 168862
2012-11-29 08:58:47 +00:00
Richard Smith e6a56db2e6 Reject uses of __int128 on platforms that don't support it. Also move the ugly
'getPointerWidth(0) >= 64' test to be a method on TargetInfo, ready to be
properly cleaned up.

llvm-svn: 168856
2012-11-29 05:41:51 +00:00
Eli Friedman fd41aee2f8 Fix crash-on-invalid. <rdar://problem/12765391>.
llvm-svn: 168851
2012-11-29 03:13:49 +00:00
Richard Smith 8bf22e5b52 The declaration of a special member can require overload resolution to be
performed, to determine whether that special member is deleted or constexpr.
That overload resolution process can in turn trigger the instantiation of a
template, which can do anything, including triggering the declaration of that
very same special member function. When this happens, do not try to recursively
declare the special member -- that's impossible. Instead, only try to realise
the truth. There is no special member.

llvm-svn: 168847
2012-11-29 01:34:07 +00:00
Ted Kremenek 2317f30f4d Correctly handle IntegralToBool casts in C++ in the static analyzer. Fixes <rdar://problem/12759044>.
llvm-svn: 168843
2012-11-29 00:50:20 +00:00
Chad Rosier 9ae53f8e3a [driver] -mkernel implies -mstrict-align; don't add the redundant option.
rdar://12771737

llvm-svn: 168841
2012-11-29 00:42:06 +00:00
Michael Han ddc016d4d7 Implement C++11 [dcl.attr.grammar] p4: If an attribute-specifier-seq appertains to a friend declaration, that declaration shall be a definition.
llvm-svn: 168826
2012-11-28 23:17:40 +00:00
Fariborz Jahanian 998f0a3360 objective-C blocks: Make sure that identical logic is used
in deciding a copy/dispose field is needed in a byref structure
and when generating the copy/dispose helpers. In certain
cases, these fields were being added but no copy/dispose was
being generated. This was uncovered in ARC, but not in MRR.
// rdar://12759433

llvm-svn: 168825
2012-11-28 23:12:17 +00:00
Richard Smith a118c6a8c0 Per C++11 [except.spec]p2, rvalue references are not permitted in exception specifications.
llvm-svn: 168824
2012-11-28 22:52:42 +00:00
Richard Smith 8606d75265 PR14388: An array or function type in an exception specification should be
decayed to a pointer type. Patch by WenHan Gu, with a little tweaking and
additional testcases by me.

llvm-svn: 168822
2012-11-28 22:33:28 +00:00
Manman Ren 836a93bdb3 ABI: comments from Eli on r168820.
rdar://12723368

llvm-svn: 168821
2012-11-28 22:29:41 +00:00
Manman Ren 84b921f805 ABI: modify CreateCoercedLoad and CreateCoercedStore to not use load or store of
the original parameter or return type.

Since we do not accurately represent the data fields of a union, we should not
directly load or store a union type.

As an exmple, if we have i8,i8, i32, i32 as one field type and i32,i32 as
another field type, the first field type will be chosen to represent the union.
If we load with the union's type, the 3rd byte and the 4th byte will be skipped.

rdar://12723368

llvm-svn: 168820
2012-11-28 22:08:52 +00:00
Richard Smith 58db83d11d PR13098: If we're instantiating an overloaded binary operator and we could
determine which member function would be the callee from within the template
definition, don't pass that function as a "non-member function" to
CreateOverloadedBinOp. Instead, just rely on it to select the member function
for itself.

llvm-svn: 168818
2012-11-28 21:47:39 +00:00
Alexey Samsonov 53f7e12909 Refactor -fsanitize, -f*-sanitizer arguments parsing. Provide a more careful diagnostic for invalid sets of sanitizers
llvm-svn: 168794
2012-11-28 17:34:24 +00:00
Richard Smith 9a67f47882 Teach Lexer::getSpelling about raw string literals. Specifically, if a raw
string literal needs cleaning (because it contains line-splicing in the
encoding prefix or in the ud-suffix), do not clean the section between the
double-quotes -- that's the "raw" bit!

llvm-svn: 168776
2012-11-28 07:29:00 +00:00
Richard Smith 1c33fe8fea Store on the CXXRecordDecl whether the class has, or would have, a copy
constructor/assignment operator with a const-qualified parameter type. The
prior method for determining this incorrectly used overload resolution.

llvm-svn: 168775
2012-11-28 06:23:12 +00:00
Richard Smith 58c3cc12da C++ core issue 1344, PR10618: promote "addition of default argument makes this
a special member" diagnostic from warning to error, and fix the cases where it
produced diagnostics with incorrect wording.

We don't support this as an extension, and we ban it even in C++98 mode. This
breaks too much (for instance, the ABI-specified calling convention for a type
can change if it acquires a copy constructor through the addition of a default
argument).

llvm-svn: 168769
2012-11-28 03:45:24 +00:00
Ted Kremenek 18035d7125 Fix another false positive due to a CXX temporary object appearing in a C initializer.
The stop-gap here is to just drop such objects when processing the InitListExpr.
We still need a better solution.

Fixes <rdar://problem/12755044>.

llvm-svn: 168757
2012-11-28 01:49:01 +00:00
Ted Kremenek 5092c73187 Provide stop-gap solution to crash reported in PR 14436.
This was also covered by <rdar://problem/12753384>.  The static analyzer
evaluates a CXXConstructExpr within an initializer expression and
RegionStore doesn't know how to handle the resulting CXXTempObjectRegion
that gets created.  We need a better solution than just dropping the
value, but we need to better understand how to implement the right
semantics here.

Thanks to Jordan for his help diagnosing the behavior here.

llvm-svn: 168741
2012-11-27 23:05:37 +00:00
Fariborz Jahanian fbd19749a3 objective-C arc: load of a __weak object happens via call to
objc_loadWeak. This retains and autorelease the weakly-refereced
object. This hidden autorelease sometimes makes __weak variable alive even
after the weak reference is erased, because the object is still referenced
by an autorelease pool. This patch overcomes this behavior by loading a 
weak object via call to objc_loadWeakRetained(), followng it by objc_release
at appropriate place, thereby removing the hidden autorelease. // rdar://10849570

llvm-svn: 168740
2012-11-27 23:02:53 +00:00
Will Dietz 1897cb3b9c Add -fsanitize=integer for reporting suspicious integer behaviors.
Introduces new sanitizer "unsigned-integer-overflow".

llvm-svn: 168701
2012-11-27 15:01:55 +00:00
Timur Iskhodzhanov b7029398f3 Remove outdated FIXME; should have removed that in r160782
llvm-svn: 168698
2012-11-27 12:55:47 +00:00
NAKAMURA Takumi eb360a0d4f clang/test/lit.cfg: Disable dev-fd-fs on cygwin for now.
open("/dev/fd/1-foobar") fails with EEXIST on cygwin.

llvm-svn: 168676
2012-11-27 05:25:41 +00:00
Eli Friedman 6fdc1221c7 Test for r168674.
llvm-svn: 168675
2012-11-27 02:58:49 +00:00
Bill Schmidt 90b22c9de6 This patch addresses an incompatibility relative to the 64-bit PowerPC
ELF ABI.

Complex values are to be passed in registers as though the real and
imaginary parts were passed as separate parameters.  Prior to this
patch, complex values were passed as byval aggregates.  It turns out
that specifying getDirect() for all complex types when classifying the
argument type results in the desired behavior.

The new Clang test case verifies that the correct LLVM IR is generated
for caller and callee for each of the underlying types for _Complex.

llvm-svn: 168673
2012-11-27 02:46:43 +00:00
Jordan Rose 3ba8c792e5 [analyzer] Fix test to work on non-LP64 systems.
Thanks for the original catch in r168303, Takumi.

llvm-svn: 168671
2012-11-27 02:37:49 +00:00
Rafael Espindola 9c235640e1 Add a testcase that r168411 would break.
llvm-svn: 168669
2012-11-27 01:56:54 +00:00
Daniel Dunbar db0745ab86 Frontend: Create a virtual file for named pipe inputs.
- This ensures we see the right buffer size for the file.

llvm-svn: 168636
2012-11-27 00:04:16 +00:00
Michael Han 9407e50b04 Improve diagnostic on C++11 attribute specifiers that appear at wrong syntactic locations around class specifiers.
This change list implemented logic that explicitly detects several combinations of locations where C++11 attribute
specifiers might be incorrectly placed within a class specifier. Previously we emit generic diagnostics like 
"expected identifier" for such cases; now we emit specific diagnostic against the misplaced attributes, this also 
fixed a bug in old code where attributes appear at legitimate locations were incorrectly rejected.

Thanks to Richard Smith for reviewing!

llvm-svn: 168626
2012-11-26 22:54:45 +00:00
Sebastian Pop 3ff4416458 check that always_inline attribute works with -fno-inline
Clean up the existing test to use FileCheck.

llvm-svn: 168607
2012-11-26 20:44:46 +00:00
Anna Zaks e3beeaa5e7 [analyzer] Fix a crash reported in PR 14400.
The AllocaRegion did not have the superRegion (based on LocationContext)
as part of it's hash. As a consequence, the AllocaRegions from
different frames were uniqued to be the same region.

llvm-svn: 168599
2012-11-26 19:11:46 +00:00
Timur Iskhodzhanov 09848e709c Fix PR14413 - incorrect mangling of anonymous namespaces with -cxx-abi microsoft
llvm-svn: 168583
2012-11-26 08:55:48 +00:00
Richard Smith dd2ca571ae PR14428: When instantiating a 'new' expression, if we had a non-dependent
initialization, don't rebuild it. Remove a couple of hacks which were trying to
work around this. Fix the special case for one-argument CXXConstructExprs to
not apply if the one argument is a default argument.

llvm-svn: 168582
2012-11-26 08:32:48 +00:00
Rafael Espindola 48cf0dc360 Add a basic testcase for the "variable is not needed" warning and one that
regressed in r168519.

llvm-svn: 168563
2012-11-25 14:00:51 +00:00
Alexey Samsonov e0619f5241 Fix test case for linking with sanitizer opts added in r168428.
llvm-svn: 168562
2012-11-25 13:40:21 +00:00
Benjamin Kramer 90633e39fc Sema: Provide a valid source location when instantiating templates based on a CXXDefaultArgExpr.
Fixes PR13758.

llvm-svn: 168521
2012-11-23 17:04:52 +00:00
Rafael Espindola 53192e7d93 Check that we don't warn on this testcase. This is basically a test that
Decl::isUsed checks the attribute. If the function had a body just the check
is DeclMustBeEmitted would be sufficient.

llvm-svn: 168514
2012-11-23 13:54:40 +00:00
Joey Gouly ebc59d5eb4 PR14306: Move -fbounds-checking to -fsanitize=bounds.
llvm-svn: 168510
2012-11-23 10:39:49 +00:00
Richard Smith b2c5f963d6 Fix regression in r168477. Use canonical decl when looking for base class
specified as a qualified name.

llvm-svn: 168479
2012-11-22 00:40:54 +00:00
Richard Smith d80b2d57cf Fix CXXRecordDecl::forallBases to not look through bases which are dependent
and defined within the current instantiation, but which are not part of the
current instantiation. Previously, it would look at bases which could be
specialized separately from the current template.

llvm-svn: 168477
2012-11-22 00:24:47 +00:00
Richard Smith 56cb16dd92 Test that we correctly deal with multiple copy constructors when detecting
non-trivial special members for varargs calls.

llvm-svn: 168476
2012-11-22 00:21:13 +00:00
Chandler Carruth 05fb585a36 Fix the '-fuse-init-array' option to actually be an option.
Previously, this flag to CC1 was never exposed at the clang driver
layer, and if you happened to enable it (by being on Android or GCC 4.7
platform), you couldn't *disable* it, because there was no 'no' variant.
The whole thing was confusingly implemented.

Now, the target-specific flag processing gets the driver arg list, and
we use standard hasFlag with a default based on the GCC version and/or
Android platform. The user can still pass the 'no-' variant to forcibly
disable the flag, or pass the positive variant to clang itself to enable
the flag.

The test has also been substantially cleaned up and extended to cover
these use cases.

llvm-svn: 168473
2012-11-21 23:40:23 +00:00
Benjamin Kramer 3d3ddcec70 SemaCXX: an enumeral type can be of character or boolean type in a C++11 enum class. Make sure we create a literal of the right type.
Fixes PR14386.

llvm-svn: 168441
2012-11-21 17:42:47 +00:00
Alexey Samsonov 062441b8d4 Try to fix test from r168428 on mingw bot
llvm-svn: 168431
2012-11-21 15:52:36 +00:00
NAKAMURA Takumi 0597d355a2 clang/test/Driver/x86_64-nacl-defines.cpp: Specify filename generated.
FIXME: It could be /dev/null.
llvm-svn: 168429
2012-11-21 14:45:57 +00:00
Alexey Samsonov 8368b376ad [Sanitizer] force linking with static sanitizer runtimes on Darwin even if they are not found in resource directory. Add test checking sanitizer linker flags on Darwin.
llvm-svn: 168428
2012-11-21 14:17:42 +00:00
Dmitri Gribenko 3233391b50 Use color for -ast-dump-filter only when it is supported
Patch by Philip Craig.

llvm-svn: 168420
2012-11-21 10:54:55 +00:00
Richard Smith 1ab34b3ad5 PR14381: Never skip constexpr function bodies when code-completing. We may need
them in order to parse the rest of the file.

llvm-svn: 168327
2012-11-19 21:13:18 +00:00
Kaelyn Uhrain f60b55ae49 When adding a NamedDecl to a correction, add the underlying Decl (via
getUnderlyingDecl()) so that derivatives of
CorrectionCandidateCallback::ValidateCandidate(...) don't have to worry
about being thrown by UsingDecls and such.

llvm-svn: 168317
2012-11-19 18:49:53 +00:00
Logan Chien 3d3373ceb6 Add -ldl for non-static libgcc in Android.
According to Android ABI, we have to link with
libdl.so, if we are linking with non-static libgcc.

Besides, this also fixes MIPS link error of
undefined references to `_Unwind_Find_FDE' and
`dl_iterate_phdr'.

llvm-svn: 168310
2012-11-19 12:04:11 +00:00
Logan Chien 1d8cc65a9b Enable -fuse-init-array for Android X86/MIPS.
The dynamic linker of Android does not support .ctors/.dtors.
We should emit .init_array and .fini_array regardless the
gcc version.

NOTE: This patch does not affect the ARM backend, because
it is required to generate .init_array and .fini_array
for program targeting ARM AAPCS and AEABI.

llvm-svn: 168309
2012-11-19 11:45:31 +00:00
NAKAMURA Takumi d05b01a8df clang/test: Suppress two tests on LLP64 target, Windows x64.
llvm-svn: 168303
2012-11-19 10:00:59 +00:00
Chandler Carruth 76a943be7b Completely re-work how the Clang driver interprets PIC and PIE options.
There were numerous issues here that were all entangled, and so I've
tried to do a general simplification of the logic.
1) The logic was mimicing actual GCC bugs, rather than "features". These
   have been fixed in trunk GCC, and this fixes Clang as well. Notably,
   the logic was always intended to be last-match-wins like any other
   flag.
2) The logic for handling '-mdynamic-no-pic' was preposterously unclear.
   It also allowed the use of this flag on non-Darwin platforms where it
   has no actual meaning. Now this option is handled directly based on
   tests of how llvm-gcc behaves, and it is only supported on Darwin.
3) The APIs for the Driver's ToolChains had the implementation ugliness
   of dynamic-no-pic leaking through them. They also had the
   implementation details of the LLVM relocation model flag names
   leaking through.
4) The actual results of passing these flags was incorrect on Darwin in
   many cases. For example, Darwin *always* uses PIC level 2 if it uses
   in PIC level, and Darwin *always* uses PIC on 64-bit regardless of
   the flags specified, including -fPIE. Darwin never compiles in PIE
   mode, but it can *link* in PIE mode.
5) Also, PIC was not always being enabled even when PIE was. This isn't
   a supported mode at all and may have caused some fallout in builds
   with complex PIC and PIE interactions.

The result is (I hope) cleaner and clearer for readers. I've also left
comments and tests about some of the truly strage behavior that is
observed on Darwin platforms. We have no real testing of Windows
platforms and PIC, but I don't have the tools handy to figure that out.
Hopefully others can beef up our testing here.

Unfortunately, I can't test this for every platform. =/ If folks have
dependencies on these flags that aren't covered by tests, they may
break. I've audited and ensured that all the changes in behavior of the
existing tests are intentional and good. In particular I've tried to
make sure the Darwin behavior (which is more suprising than the Linux
behavior) also matches that of 'gcc' on my mac.

llvm-svn: 168297
2012-11-19 03:52:03 +00:00
NAKAMURA Takumi 3424550294 clang/test/Sema/warn-documentation.cpp: Try to fix up the testcase in r168277.
llvm-svn: 168278
2012-11-18 02:34:33 +00:00
Dmitri Gribenko 76b91c3431 Documentation parsing: propely handle a lone '\endverbatim' and emit a warning.
We actually used to assert on this.

Thanks to NAKAMURA Takumi for noticing this!

llvm-svn: 168277
2012-11-18 00:30:31 +00:00
Fariborz Jahanian d91d21cc33 objective-C: Do not issue deprecated warning about implementation
of a deprecated method in original class (or category), only
in overrides. // rdar://12717705

llvm-svn: 168270
2012-11-17 20:53:53 +00:00
Nico Weber 4e270380c1 Fix crash on end-of-file after \ in a char literal, fixes PR14369.
This makes LexCharConstant() look more like LexStringLiteral(), which doesn't
have this bug. Add tests for eof after \ for several other cases.

llvm-svn: 168269
2012-11-17 20:25:54 +00:00
Andy Gibbs d41d094244 Prevent premature macro expansion in __has_builtin, __has_feature,
__has_attribute, __has_extension, making them behave more akin to
conventional macros.

llvm-svn: 168268
2012-11-17 19:18:27 +00:00
Andy Gibbs a8df57a962 Made the "expected string literal" diagnostic more expressive
llvm-svn: 168267
2012-11-17 19:16:52 +00:00
Andy Gibbs 58905d251b Refactored duplicate string literal lexing code within Preprocessor, into a
common LexStringLiteral function.  In doing so, some consistency problems have
been ironed out (e.g. where the first token in the string literal was lexed
with macro expansion, but subsequent ones were not) and also an erroneous
diagnostic has been corrected.

LexStringLiteral is complemented by a FinishLexStringLiteral function which
can be used in the situation where the first token of the string literal has
already been lexed.

llvm-svn: 168266
2012-11-17 19:15:38 +00:00
Andy Gibbs f591982bb2 Fix handling of invalid uses of the __has_warning builtin macro
llvm-svn: 168265
2012-11-17 19:14:53 +00:00
Benjamin Kramer 37196de31e Enable inlining of 4 byte atomic ops on ppc32, 8 byte atomic ops on ppc64.
Also fixes a bit/byte mismatch when checking if a target supports atomic ops of a certain size.

llvm-svn: 168260
2012-11-17 17:30:55 +00:00
Eli Friedman 3e94f57a0f Add missing features for misc x86 CPUs to CPU feature translation. Patch by Jung-uk Kim.
llvm-svn: 168239
2012-11-17 01:43:10 +00:00
Dmitri Gribenko 44ae282c6e Testcase overriding-ftemplate-comments.cpp: use [[@LINE]] to make it less fragile.
llvm-svn: 168213
2012-11-16 22:34:07 +00:00
Chad Rosier 808baaf232 [driver] Add the missing TY_PP_ObjCXX_Alias case to the isCXX function.
This was causing different behavior when using -x objective-c++-cpp-output as
compared to -x objc++-cpp-output.  Specifically, the driver was not adding the
-fcxx-exceptions flag in the latter case.
rdar://12680312

llvm-svn: 168212
2012-11-16 22:31:39 +00:00
NAKAMURA Takumi a95099ebd3 Revert r168132, "clang/test/lit.cfg: Suppress the feature 'dev-fd-fs' for now." I missed Daniel's r168095 by my accident.
llvm-svn: 168134
2012-11-16 03:50:55 +00:00
NAKAMURA Takumi 0e551c191c clang/test/lit.cfg: Suppress the feature 'dev-fd-fs' for now.
None of my buildhost (centos6 x86-64 and cygwin) is passing. Investigating.

llvm-svn: 168132
2012-11-16 03:28:51 +00:00
Daniel Dunbar 5d38875d81 CPP Output: Do not emit an enter file marker for the main file.
- This diverges from gcc, and confuses tools (like dtrace) which track # line
   markers as a way to determine which content is in the context of the main
   file.

llvm-svn: 168128
2012-11-16 01:51:11 +00:00
Richard Trieu 08b5fef122 Take into account the zero sign bit for positive numbers when computing the bit
width of an enum with negative values in IntRange.  Include a test for
-Wtautological-constant-out-of-range-compare where this had manifested.

llvm-svn: 168126
2012-11-16 01:32:40 +00:00
Eli Friedman ab19712823 Make sure CodeGenTypes correctly reconverts function types. Fixes PR14355, a crash in IR generation.
llvm-svn: 168112
2012-11-15 23:40:48 +00:00
Richard Smith 2603b096df PR9903: Recover from a member functon declared with the 'typedef' specifier by
dropping the specifier, just like we do for non-member functions and function
templates declared 'typedef'. Patch by Brian Brooks!

llvm-svn: 168108
2012-11-15 22:54:20 +00:00
Dmitri Gribenko abbb210b6b Comment to XML conversion test: correct filename.
llvm-svn: 168101
2012-11-15 22:21:42 +00:00
Dmitri Gribenko d947a66c13 Split annotate-comments.cpp into a fragile (that uses hardcoded line numbers)
and a non-fragile (that uses [[@LINE]]) parts.

llvm-svn: 168098
2012-11-15 22:03:13 +00:00
Daniel Dunbar c61fae4205 tests: Mark the /dev/fd test as requiring Darwin until I can test on other OSes.
llvm-svn: 168095
2012-11-15 21:31:13 +00:00
Daniel Dunbar d9cb0ba660 tests: Check that we can output to /dev/fd filesystem.
- An LLVM unique_file() bug could cause us to infinite loop on the later test
   case.

llvm-svn: 168082
2012-11-15 20:24:58 +00:00
Daniel Dunbar 523855929b tests: Add a test for reading from named pipes.
- Realized I could use the /dev/fd filesystem to make a simple portable test.

llvm-svn: 168079
2012-11-15 20:06:10 +00:00
Douglas Gregor 4b27a64b92 If an excluded header does not exist, just ignore it
llvm-svn: 168077
2012-11-15 19:47:16 +00:00
Jordan Rose e37ab50a6e [analyzer] Report leaks at the closing brace of a function body.
This fixes a few cases where we'd emit path notes like this:

  +---+
 1|   v
  p = malloc(len);
  ^   |2
  +---+

In general this should make path notes more consistent and more correct,
especially in cases where the leak happens on the false branch of an if
that jumps directly to the end of the function. There are a couple places
where the leak is reported farther away from the cause; these are usually
cases where there are several levels of nested braces before the end of
the function. This still matches our current behavior for when there /is/
a statement after all the braces, though.

llvm-svn: 168070
2012-11-15 19:11:43 +00:00
Jordan Rose b5b0fc196e [analyzer] Mark symbol values as dead in the environment.
This allows us to properly remove dead bindings at the end of the top-level
stack frame, using the ReturnStmt, if there is one, to keep the return value
live. This in turn removes the need for a check::EndPath callback in leak
checkers.

This does cause some changes in the path notes for leak checkers. Previously,
a leak would be reported at the location of the closing brace in a function.
Now, it gets reported at the last statement. This matches the way leaks are
currently reported for inlined functions, but is less than ideal for both.

llvm-svn: 168066
2012-11-15 19:11:27 +00:00
Fariborz Jahanian 0e3043b2ed block extended signatur option. Change previous option
to a cc1 -fencode-extended-block-signature and pass it
to cc1 and recognize this option to produce extended block
type signature. // rdar://12109031 

llvm-svn: 168063
2012-11-15 19:02:45 +00:00
Dmitri Gribenko 60d4b99693 Comment to XML conversion: convert some tests to use the new [[@LINE]]
FileCheck feature.  This will hopefully make tests less fragile.

llvm-svn: 168056
2012-11-15 18:37:27 +00:00
Nick Lewycky c363afb19e Teach the uninitialized field warning about anonymous structs and union members.
Fixes PR14073!

llvm-svn: 168031
2012-11-15 08:19:20 +00:00
Richard Trieu 03c3a2f5bb Fix an off-by-one error by switching < to <= in -Wtautological-constant-out-of-range-compare and added test case.
llvm-svn: 168023
2012-11-15 03:43:50 +00:00
Jordan Rose 90ba0218e2 [analyzer] Fix test case broken by previous commit.
llvm-svn: 168020
2012-11-15 02:17:09 +00:00
Jordan Rose 2d98b97e10 [analyzer] Make sure calls in synthesized functions have valid path locations.
We do this by using the "most recent" good location: if a synthesized
function 'A' calls another function 'B', the path notes for the call to 'B'
will be placed at the same location as the path note for calling 'A'.

Similarly, the call to 'A' will have a note saying "Entered call from...",
and now we just don't emit that (since the user doesn't have a body to look
at anyway).

Previously, we were doing this for the "Calling..." notes, but not for the
"Entered call from..." or "Returning to caller". This caused a crash when
the path entered and then exiting a call within a synthesized body.

<rdar://problem/12657843>

llvm-svn: 168019
2012-11-15 02:07:23 +00:00
Argyrios Kyrtzidis a660ae4421 [PCH] Reading expressions from attributes should be done using ReadExpr(),
not ReadExpr().

Also add a test case making sure the thread safety attributes work as expected
when they come from a PCH.

Fixes rdar://12584141 & http://llvm.org/PR13982

llvm-svn: 168017
2012-11-15 01:31:39 +00:00
Eli Friedman 6745c3b732 Fix a trivial bool-related bug I spotted while skimming David Fang's
current list of powerpc-darwin8 failures.

llvm-svn: 168016
2012-11-15 01:21:59 +00:00
Richard Smith af41696bc4 Per [basic.lookup.classref]p3, in an expression of the form p->~type-name, the
type-name is looked up in the context of the complete postfix-expression. Don't
forget to pass the scope into this lookup when the type-name is a template-id;
it might name an alias template which can't be found within the class itself.

Bug spotted by Johannes Schaub on #llvm.

llvm-svn: 168011
2012-11-15 00:31:27 +00:00