Commit Graph

40387 Commits

Author SHA1 Message Date
Adrian Prantl 5578e44df8 Add missing overrides to MultiplexConsumer. Test coverage will be
provided by an upcoming commit.

llvm-svn: 240026
2015-06-18 16:41:53 +00:00
Daniel Jasper 1bf729cee1 clang-format: Row back on the AlwaysBreakBeforeMultilineStrings change.
It was a bit too aggressive.

With this patch, we keep on breaking here:
  aaaaaaaaaaaaa(aaaaaaa,
                "aaaaaaa"
                "bbbbbbb");

But don't break in:
  aaaaaaaaaaaaa(aaaaaaa, aaaaaaaa("aaaaaaa"
                                  "bbbbbbb"));

llvm-svn: 240024
2015-06-18 16:05:17 +00:00
Daniel Jasper 47721ac75d clang-format: Better support functions with elaborated enum return types.
Before, this wasn't formatted properly:
  enum ::C f() {
    return a;
  }

llvm-svn: 240021
2015-06-18 15:45:17 +00:00
Gabor Ballabas 3645149ea2 Allow case-insensitive values for -march for AArch64 target in line with GCC.
GCC allows case-insensitive values for -mcpu, -march and -mtune options.
This patch implements the same behaviour for the -march option for the AArch64 target.

llvm-svn: 240019
2015-06-18 14:23:12 +00:00
Alexey Bataev 7f210c6dab [OPENMP] Codegen for 'proc_bind' clause (4.0).
Adds emission of the code for 'proc_bind(master|close|spread)' clause:
call void @__kmpc_push_proc_bind(<loc>, i32 thread_id, i32 4|3|2)

llvm-svn: 240018
2015-06-18 13:40:03 +00:00
Daniel Jasper ed3f395773 clang-format: [JS] Add a special case for indenting function literals.
Before:
  var func =
      function() {
        doSomething();
      };

After:
  var func =
      function() {
    doSomething();
  };

This is a very narrow special case which fixes most of the discrepency
with what our users do. In the long run, we should try to come up with
a more generic fix for indenting these.

llvm-svn: 240014
2015-06-18 12:32:59 +00:00
Alexey Bataev c30dd2daf9 [OPENMP] Support for '#pragma omp taskgroup' directive.
Added parsing, sema analysis and codegen for '#pragma omp taskgroup' directive (OpenMP 4.0).
The code for directive is generated the following way:
#pragma omp taskgroup
<body>

void __kmpc_taskgroup(<loc>, thread_id);
<body>
void __kmpc_end_taskgroup(<loc>, thread_id);

llvm-svn: 240011
2015-06-18 12:14:09 +00:00
Daniel Marjamaki e59f8d7f1d [clang] Refactoring of conditions so they use isOneOf() instead of multiple is().
llvm-svn: 240008
2015-06-18 10:59:26 +00:00
Alexey Bataev 3b5b5c492e [OPENMP] Add support for 'omp parallel for' directive.
Codegen for this directive is a combined codegen for 'omp parallel' region with 'omp for simd' region inside. Clauses are supported.

llvm-svn: 240006
2015-06-18 10:10:12 +00:00
Daniel Jasper 2aaedd3a7e clang-format: Make AlwaysBreakBeforeMultilineStrings more conservative.
In essence this is meant to consistently indent multiline strings by a
fixed amount of spaces from the start of the line. Don't do this in
cases where it wouldn't help anyway.

Before:
  someFunction(aaaaa,
               "aaaaa"
               "bbbbb");

After:
  someFunction(aaaaa, "aaaaa"
                      "bbbbb");

llvm-svn: 240004
2015-06-18 09:12:47 +00:00
Alexey Bataev 58e5bdb091 [OPENMP] Add support for 'omp for simd' directive.
Added codegen for combined 'omp for simd' directives, that is a combination of 'omp for' directive followed by 'omp simd' directive. Includes support for all clauses.

llvm-svn: 239990
2015-06-18 04:45:29 +00:00
Alexey Samsonov 92b0b02e29 [Driver] Remove unused class member. NFC.
llvm-svn: 239981
2015-06-18 00:36:40 +00:00
Alexey Samsonov fd0bb3a9ac [Driver] Simplify code choosing between MacOS and iOS platforms. NFC.
llvm-svn: 239980
2015-06-18 00:36:38 +00:00
Richard Smith 75ea855fd7 [modules] Ensure that if we merge the definitions of two enumerations, that
making either of them visible makes the merged definition visible.

llvm-svn: 239969
2015-06-17 23:07:50 +00:00
Alexey Samsonov 60e85f8c9e [Driver] Add an assert to Darwin::isTargetMacOS() for consistency.
llvm-svn: 239967
2015-06-17 22:51:12 +00:00
Alexey Samsonov 9bc2ad5e6c Revert "[Sanitizers] Provide better diagnostic for sanitizers unsupported for target triple."
This reverts commit r239953, while I'm investigating assertion
failure from http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_check/9994/

llvm-svn: 239958
2015-06-17 22:27:32 +00:00
Richard Smith afe800c456 [modules] Fix typo in default argument merging.
llvm-svn: 239954
2015-06-17 22:13:23 +00:00
Alexey Samsonov 9170efdc0d [Sanitizers] Provide better diagnostic for sanitizers unsupported for target triple.
Summary:
Introduce ToolChain::getSupportedSanitizers() that would return the set
of sanitizers available on given toolchain. By default, these are
sanitizers which don't necessarily require runtime support (i.e.
set from -fsanitize=undefined-trap).

Sanitizers (ASan, DFSan, TSan, MSan etc.) which cannot function
without runtime library are marked as supported only on platforms
for which we actually build these runtimes.

This would allow more fine-grained checks in the future: for instance,
we have to restrict availability of -fsanitize=vptr to Mac OS 10.9+
(PR23539)

Update test cases accrodingly: add tests for certain unsupported
configurations, remove test cases for -fsanitize=vptr + PS4
integration, as we don't build the runtime for PS4 at the moment.

Test Plan: regression test suite

Reviewers: pcc

Subscribers: cfe-commits, filcab, eugenis, thakis, kubabrecka, emaste, rsmith

Differential Revision: http://reviews.llvm.org/D10467

llvm-svn: 239953
2015-06-17 22:07:28 +00:00
David Majnemer fcbdb6ea58 Update clang to take into account the changes to personality fns
llvm-svn: 239941
2015-06-17 20:53:19 +00:00
Richard Smith 63e09bf70b [modules] If we merge a template, also track that its parameters are merged so
that we know when its default arguments should be visible.

llvm-svn: 239936
2015-06-17 20:39:41 +00:00
Richard Smith 35c1df5cb6 [modules] Improve diagnostic for a template-id that's invalid because a default
argument is not visible.

llvm-svn: 239934
2015-06-17 20:16:32 +00:00
Peter Collingbourne 86d34a72b3 CodeGen: Factor out some of the bitset entry creation code. NFC.
llvm-svn: 239927
2015-06-17 19:08:05 +00:00
Eric Christopher 3d920eed5d Move xtest to its own file to match the gcc header organization.
llvm-svn: 239926
2015-06-17 18:42:07 +00:00
Eric Christopher 29b78091e7 Update comments on HLE, RTM, and ADX support for intrinsics.
llvm-svn: 239925
2015-06-17 18:42:03 +00:00
Reid Kleckner 3df5dd4de7 [fixit] Use overwriteChangedFiles() to deal with Windows mapped files
Fixes one instance of PR17960.

llvm-svn: 239920
2015-06-17 17:47:30 +00:00
Daniel Jasper e6fcf7d372 clang-format: clang-format (NFC)
llvm-svn: 239903
2015-06-17 13:08:06 +00:00
Daniel Jasper d6e618892f clang-format: Don't generate unnecessary replacements for \r\n line endings.
Patch by Mathieu Champlon. Thank you.

llvm-svn: 239900
2015-06-17 12:23:15 +00:00
Daniel Jasper 9f4ec15270 clang-format: [JS] Don't put top-level typescript enums on a single line.
This makes this consistent with non-typescript enums.

Also shuffle the language-dependent stuff in mustBreakBefore to a
single location.

Patch initiated by Martin Probst.

llvm-svn: 239894
2015-06-17 09:44:07 +00:00
Daniel Jasper 90cf380e92 clang-format: [JS] Fix typescript enum formatting.
Patch by Martin Probst.

Before:
  enum {
    A,
    B
  } var x = 1;

After:
  enum {
    A,
    B
  }
  var x = 1;

llvm-svn: 239893
2015-06-17 09:44:02 +00:00
Daniel Jasper e285b8dd2e clang-format: NFC. Add a function to test whether an annotated line
starts with a given sequence of tokens. Only the one-token version is
used yet, but other usages are coming up momentarily.

llvm-svn: 239892
2015-06-17 09:43:56 +00:00
Alexey Bataev cbdcbb7690 [OPENMP] Code reformatting for omp simd codegen, NFC.
llvm-svn: 239889
2015-06-17 07:45:51 +00:00
Eric Christopher 9fc7fb274e Update the intel intrinsic headers to use the target attribute support.
This involved removing the conditional inclusion and replacing them
with target attributes matching the original conditional inclusion
and checks. The testcase update removes the macro checks for each
file and replaces them with usage of the __target__ attribute, e.g.:

int __attribute__((__target__(("sse3")))) foo(int a) {
  _mm_mwait(0, 0);
  return 4;
}

This usage does require the enclosing function have the requisite
__target__ attribute for inlining and code generation - also for
any macro intrinsic uses in the enclosing function. There's no change
for existing uses of the intrinsic headers.

llvm-svn: 239883
2015-06-17 07:09:32 +00:00
Eric Christopher 4d185168e9 Use a define for per-file function attributes for the Intel intrinsic headers.
This is a precursor to changing them to use the new target attribute
code.

llvm-svn: 239882
2015-06-17 07:09:20 +00:00
Alexey Bataev 89e7e8eb0e [OPENMP] Supported reduction clause in omp simd construct.
The following code is generated for reduction clause within 'omp simd' loop construct:
#pragma omp simd reduction(op:var)
for (...)
  <body>

alloca priv_var
priv_var = <initial reduction value>;
<loop_start>:
<body> // references to original 'var' are replaced by 'priv_var'
<loop_end>:
var op= priv_var;

llvm-svn: 239881
2015-06-17 06:21:39 +00:00
Rafael Espindola 4914d3a5ec Update for llvm api change.
llvm-svn: 239859
2015-06-16 22:32:44 +00:00
Richard Smith 5293379374 [modules] Fix merging of default template arguments onto friend templates.
Previously we'd complain about redefinition of default arguments when we
instantiated a class with a friend template that inherits its default argument,
because we propagate the default template arguemnt onto the friend when we
reload the AST.

llvm-svn: 239857
2015-06-16 21:57:05 +00:00
Douglas Gregor b32684eb65 Honor the objc_runtime_name attribute when encoding class/protocol names.
While the rest of the Objective-C metadata seems to honor
objc_runtime_name, the encoding strings produced by, e.g., @encode and
property meta, were not. Fixes rdar://problem/21408305.

llvm-svn: 239852
2015-06-16 21:04:55 +00:00
Saleem Abdulrasool f7ffec3b5f parser: diagnose empty attribute blocks
MS attributes do not permit empty attribute blocks.  Correctly diagnose those.
We continue to parse to ensure that we recover correctly.  Because the block is
empty, we do not need to skip any tokens.

Bonus: tweak the comment that I updated but forgot to remove the function name
in a previous commit.

llvm-svn: 239846
2015-06-16 20:03:47 +00:00
Douglas Katzman 76b080ac4d Remove duplicated alteration to getProgramPaths().
This appears to have been accidental.

Differential Revision: http://reviews.llvm.org/D10444

llvm-svn: 239844
2015-06-16 19:34:52 +00:00
Douglas Katzman 678d0cb146 If/else looks nicer when both branches have (or don't have) braces. NFC
llvm-svn: 239834
2015-06-16 18:01:24 +00:00
Ulrich Weigand 47fd253f56 [SystemZ] Mangle long double as __float128
In r239421, the mangling of long double on PowerPC Linux targets
was changed to use "g" instead of "e".  This same change also needs
to be done for SystemZ (all targets, since we support only Linux
on SystemZ anyway).

This is because an old ABI variant set "long double" to a 64-bit
type equivalent to "double", and the "e" mangling code is still
used to refer to that old ABI for compatibility reasons.

llvm-svn: 239822
2015-06-16 15:21:47 +00:00
Toma Tabacu 94ea6867cc [mips] Don't propagate -mfpxx by default if soft/single float were also set.
Summary:
If the driver is only given -msoft-float/-mfloat-abi=soft or -msingle-float,
we should refrain from propagating -mfpxx, unless it was explicitly given on the
command line.

Reviewers: atanasyan, dsanders

Reviewed By: atanasyan, dsanders

Subscribers: cfe-commits, mpf

Differential Revision: http://reviews.llvm.org/D10387

llvm-svn: 239818
2015-06-16 13:54:13 +00:00
Alexey Bataev fc087ecc05 [OPENMP] Support lastprivate clause in omp simd directive.
Added codegen for lastprivate clauses within simd loop-based directives.

llvm-svn: 239813
2015-06-16 13:14:42 +00:00
Daniel Sanders 8d8b13dc19 Recommit r239721: Replace string GNU Triples with llvm::Triple in InitMCObjectFileInfo. NFC.
Summary:
This affects other tools so the previous C++ API has been retained as a
deprecated function for the moment. Clang has been updated with a trivial
patch (not covered by the pre-commit review) to avoid breaking -Werror builds.
Other in-tree tools will be fixed with similar patches.

This continues the patch series to eliminate StringRef forms of GNU triples
from the internals of LLVM that began in r239036.

The first time this was committed it accidentally fixed an inconsistency in
triples in llvm-mc and this caused a failure. This inconsistency was fixed in
r239808.

Reviewers: rengolin

Reviewed By: rengolin

Subscribers: llvm-commits, rengolin

Differential Revision: http://reviews.llvm.org/D10366

llvm-svn: 239812
2015-06-16 12:18:07 +00:00
Alexey Bataev ae05c29ab5 [OPENMP] Remove last iteration separation for loop-based constructs.
Previously the last iteration for simd loop-based OpenMP constructs were generated as a separate code. This feature is not required and codegen is simplified.

llvm-svn: 239810
2015-06-16 11:59:36 +00:00
Daniel Jasper 0f29127636 Tooling: When applying a set of replacements, do deletions before
insertions. It is unlikely to be the intention to delete parts of newly
inserted code. To do so, changed sorting Replacements at the same offset
to have decreasing length.

llvm-svn: 239809
2015-06-16 10:22:10 +00:00
Justin Bogner 055ebc348d InstrProf: Fix coverage mapping when "if" is a macro
We were propagating the coverage map into the body of an if statement,
but not into the condition thereafter. This is fine as long as the two
locations are in the same virtual file, but they won't be when the
"if" part of the statement is from a macro and the condition is not.

llvm-svn: 239803
2015-06-16 06:24:15 +00:00
Richard Smith cf18b79ccf [modules] Rename -fmodule-maps to -fimplicit-module-maps (and likewise for
-fno-module-maps). The old names are preserved for compatibility.

llvm-svn: 239792
2015-06-16 00:20:23 +00:00
Richard Smith 47972afd10 [modules] Simplify -cc1 interface for enabling implicit module maps.
We used to have a flag to enable module maps, and two more flags to enable
implicit module maps. This is all redundant; we don't need any flag for
enabling module maps in the abstract, and we don't usually have -fno- flags for
-cc1. We now have just a single flag, -fimplicit-module-maps, that enables
implicitly searching the file system for module map files and loading them.

The driver interface is unchanged for now. We should probably rename
-fmodule-maps to -fimplicit-module-maps at some point.

llvm-svn: 239789
2015-06-16 00:08:24 +00:00
Samuel Antao eab747b9f5 According to the OpenMP spec, all the preprocessor macros should be
expanded in OpenMP pragmas. This patch adds support for that in -E.

llvm-svn: 239784
2015-06-15 23:44:27 +00:00
Eric Christopher 5a9bec104b Use a macro for the omnipresent attributes on header functions in Intrin.h.
Saves some typing and if someone wants to change them it makes it much easier.

llvm-svn: 239782
2015-06-15 23:20:35 +00:00
Adrian Prantl c6f91a2081 Debug Info: Turn on ODR type uniquing for (the C++ part of) Objective-C++.
rdar://problem/20571359

llvm-svn: 239781
2015-06-15 23:18:16 +00:00
Peter Collingbourne c4122c17b4 Protection against stack-based memory corruption errors using SafeStack: Clang command line option and function attribute
This patch adds the -fsanitize=safe-stack command line argument for clang,
which enables the Safe Stack protection (see http://reviews.llvm.org/D6094
for the detailed description of the Safe Stack).

This patch is our implementation of the safe stack on top of Clang. The
patches make the following changes:

- Add -fsanitize=safe-stack and -fno-sanitize=safe-stack options to clang
  to control safe stack usage (the safe stack is disabled by default).

- Add __attribute__((no_sanitize("safe-stack"))) attribute to clang that can be
  used to disable the safe stack for individual functions even when enabled
  globally.

Original patch by Volodymyr Kuznetsov and others at the Dependable Systems
Lab at EPFL; updates and upstreaming by myself.

Differential Revision: http://reviews.llvm.org/D6095

llvm-svn: 239762
2015-06-15 21:08:13 +00:00
Saleem Abdulrasool 425efcf6ea parser: improve diagnostics for MS attributes
Switch to using BalancedDelimiterTracker to get better diagnostics for
unbalanced delimiters.  This still does not handle any of the attributes, simply
improves the parsing.

llvm-svn: 239758
2015-06-15 20:57:04 +00:00
James Y Knight b240652746 [Sparc] Make soft-float emit an error.
LLVM does not and has not ever supported a soft-float ABI mode on
Sparc, so don't pretend that it does.

Also switch the default from "soft-float" -- which was actually
hard-float because soft-float is unimplemented -- to hard-float.

Differential Revision: http://reviews.llvm.org/D10457

llvm-svn: 239755
2015-06-15 20:51:24 +00:00
Richard Smith f2b1eb9eb2 [modules] Better support for redefinitions of an entity from the same module.
Support this across module save/reload and extend the 'missing import'
diagnostics with a list of providing modules.

llvm-svn: 239750
2015-06-15 20:15:48 +00:00
Luke Cheeseman 59b2d83909 This patch implements clang support for the ACLE special register intrinsics
in section 10.1, __arm_{w,r}sr{,p,64}.

This includes arm_acle.h definitions with builtins and codegen to support
these, the intrinsics are implemented by generating read/write_register calls
which get appropriately lowered in the backend based on the register string
provided. SemaChecking is also implemented to fault invalid parameters.

Differential Revision: http://reviews.llvm.org/D9697

llvm-svn: 239737
2015-06-15 17:51:01 +00:00
Daniel Sanders fa555dc7f8 Revert r239721 - Replace string GNU Triples with llvm::Triple in InitMCObjectFileInfo. NFC.
It appears to cause sparc-little-endian.s to assert on Windows and Darwin.

llvm-svn: 239724
2015-06-15 10:34:38 +00:00
Daniel Jasper b2ad4d4c26 clang-format: [JS] Tweak behavior for multiline array initializer parameters
Before:
  var someVariable = SomeFuntion(aaaa, [
    aaaaaaaaaaaaaaaaaaaaaaaaaaa,
    bbbbbbbbbbbbbbbbbbbbbbbbbbb,
    ccccccccccccccccccccccccccc
  ],
                                 aaaa);

After:
  var someVariable = SomeFuntion(aaaa,
                                 [
                                   aaaaaaaaaaaaaaaaaaaaaaaaaaa,
                                   bbbbbbbbbbbbbbbbbbbbbbbbbbb,
                                   ccccccccccccccccccccccccccc
                                 ],
                                 aaaa);

llvm-svn: 239722
2015-06-15 09:23:17 +00:00
Daniel Sanders d6d12a1192 Replace string GNU Triples with llvm::Triple in InitMCObjectFileInfo. NFC.
Summary:
This affects other tools so the previous C++ API has been retained as a
deprecated function for the moment. Clang has been updated with a trivial
patch (not covered by the pre-commit review) to avoid breaking -Werror builds.
Other in-tree tools will be fixed with similar trivial patches.

This continues the patch series to eliminate StringRef forms of GNU triples
from the internals of LLVM that began in r239036.

Reviewers: rengolin

Reviewed By: rengolin

Subscribers: llvm-commits, rengolin

Differential Revision: http://reviews.llvm.org/D10366

llvm-svn: 239721
2015-06-15 09:19:41 +00:00
Devin Coughlin 0bee1d7ff1 [analyzer] Remove ObjCContainersChecker size information when a CFMutableArrayRef escapes
Update ObjCContainersChecker to be notified when pointers escape so it can
remove size information for escaping CFMutableArrayRefs. When such pointers
escape, un-analyzed code could mutate the array and cause the size information
to be incorrect.

rdar://problem/19406485

llvm-svn: 239709
2015-06-15 01:00:42 +00:00
Daniel Jasper 2ebb0c57fb clang-format: [JS] Fix corner case in template string parsing.
Before, these would not properly detected because of the char/string
literal found when re-lexing after the first `:

  var x = `'`;  // comment with matching quote '
  var x = `"`;  // comment with matching quote "

llvm-svn: 239693
2015-06-14 07:16:57 +00:00
Ed Schouten 7893e6874d Add some basic support for CloudABI on i686.
Some people want to experiment with building i686 CloudABI binaries. I
am not entirely sure this is a good idea, as I'd rather see Intel x32
support appear.

As it only requires a two-line change, let's at least provide compiler
to ease experimenting.

llvm-svn: 239689
2015-06-13 21:33:49 +00:00
Rafael Espindola 408b45249a Don't use std::errc.
As noted on Errc.h:

// * std::errc is just marked with is_error_condition_enum. This means that
//   common patters like AnErrorCode == errc::no_such_file_or_directory take
//   4 virtual calls instead of two comparisons.

And on some libstdc++ those virtual functions conclude that

------------------------
int main() {
  std::error_code foo = std::make_error_code(std::errc::no_such_file_or_directory);
  return foo == std::errc::no_such_file_or_directory;
}
-------------------------

should exit with 0.

llvm-svn: 239684
2015-06-13 17:23:13 +00:00
Eric Fiselier 098e6de9aa Add `-verify-ignore-unexpected` option to ignore unexpected diagnostics in VerifyDiagnosticsConsumer
Summary:
The goal of this patch is to make `-verify` easier to use when testing libc++. The `notes` attached to compile error diagnostics are numerous and relatively unstable when they reference libc++ header internals. This patch allows libc++ to write stable compilation failure tests by allowing unexpected diagnostic messages to be ignored where they are not relevant.

This patch adds a new CC1 flag called `-verify-ignore-unexpected`. `-verify-ignore-unexpected` tells `VerifyDiagnosticsConsumer` to ignore *all* unexpected diagnostic messages. `-verify-ignore-unexpected=<LevelList>` can be used to only ignore certain diagnostic levels. `<LevelList>` is a comma separated list of diagnostic levels to ignore. The supported levels are `note`, `remark`, `warning` and `error`.



Reviewers: bogner, grosser, EricWF

Reviewed By: EricWF

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D10138

llvm-svn: 239665
2015-06-13 07:11:40 +00:00
Hans Wennborg 8fa9677d4e Revert r239213: "clang-cl: Implement /GL in terms of -flto."
Reverting until it's easier to use this in a real-world build, e.g.
when the linker can handle it.

llvm-svn: 239656
2015-06-13 02:53:50 +00:00
Ahmed Bougacha f6a9f0e112 [CodeGen] Don't evaluate immediate inlineasm arguments using isICE().
Instead, just EvaluateAsInt().

Follow-up to r239549: rsmith points out that isICE() is expensive;
seems like it's not the right concept anyway, as it fails on
`static const' in C, and will actually trigger the assert below on:
    test/Sema/inline-asm-validate-x86.c

llvm-svn: 239651
2015-06-13 01:16:10 +00:00
Alexey Samsonov d918ff62e5 [CodeGen] Use IRBuilder to create llvm.lifetime intrinsics.
Summary:
In addition to easier syntax, IRBuilder makes sure to set correct
debug locations for newly added instructions (bitcast and
llvm.lifetime itself). This restores the original behavior, which
was modified by r234581 (reapplied as r235553).

Extend one of the tests to check for debug locations.

Test Plan: regression test suite

Reviewers: aadg, dblaikie

Subscribers: cfe-commits, majnemer

Differential Revision: http://reviews.llvm.org/D10418

llvm-svn: 239643
2015-06-12 22:31:32 +00:00
Hans Wennborg b274738725 [ms] Don't try to delay lookup for failures in SFINAE context (PR23823)
The underlying problem in PR23823 already existed before my recent change
in r239558, but that change made it worse (failing not only for undeclared
symbols, but also failed overload resolution). This makes Clang not try to
delay the lookup in SFINAE context. I assume no current code is relying on
SFINAE working with lookups that need to be delayed, because that never
seems to have worked.

Differential Revision: http://reviews.llvm.org/D10417

llvm-svn: 239639
2015-06-12 21:23:23 +00:00
Alexey Samsonov 1054420ba3 [CGCall] Fix potential invalid iterator decrement in findDominatingStoreToReturnValue.
If llvm.lifetime.end turns out to be the first instruction in the last
basic block, we can decrement the iterator twice, going past rend.
At the moment, this can never happen because llvm.lifetime.end always
goes immediately after bitcast, but relying on this is very brittle.

llvm-svn: 239638
2015-06-12 21:05:32 +00:00
Tim Northover 018578c395 Driver: only set -mlinker-version based on host if it's valid
We were adding an extra "-mlinker-version" argument to the invocation
based on a value inferred from "ld -v". This is set by the build
systems to either a sane value or an empty string (e.g. for custom
built ld), which we don't want to pass on.

No test really possible because the value depends on both host system
and how CMake was invoked.

llvm-svn: 239633
2015-06-12 19:21:35 +00:00
David Majnemer fc22e4774b [MS ABI] Lock-in the derived memptr rep. for base-to-derived conversions
We would get this right in the case where an explicit cast was formed
but not when we were performing an implicit conversion.

This fixes PR23828.

llvm-svn: 239625
2015-06-12 17:55:44 +00:00
Gabor Ballabas 726ce7fc57 Allow case-insensitive values for -mcpu for AArch64 target in line with GCC.
GCC allows case-insensitive values for -mcpu, -march and -mtune options.
This patch implements the same behaviour for the -mcpu option for the AArch64 target.

llvm-svn: 239619
2015-06-12 17:33:37 +00:00
Douglas Katzman 0024909c68 Allow ToolChain to decide if Clang is not the right C compiler.
Removed comment in Driver::ShouldUseClangCompiler implying that there
was an opt-out ability at that point - there isn't.

Differential Revision: http://reviews.llvm.org/D10246

llvm-svn: 239608
2015-06-12 15:45:21 +00:00
Benjamin Kramer f367dd90cc push_back() loop -> append() for random access iterators.
append will resize the vector to the optimal size. No functional change
intended.

llvm-svn: 239607
2015-06-12 15:31:50 +00:00
Benjamin Kramer 133aa20e22 [clang-format] Use in-class initializers to simplify constructor.
Sadly C++11 doesn't let us use initializers on bitfield members (DR1341). NFC.

llvm-svn: 239606
2015-06-12 14:39:08 +00:00
Benjamin Kramer 8ad86fc644 [clang-format] Reorder and pack ParenState members to minimize padding
sizeof(ParenState) goes from 64 bytes to 52 bytes. NFC.

llvm-svn: 239605
2015-06-12 13:07:03 +00:00
Benjamin Kramer 3aa55db86d [clang-format] Hoist vector allocation out of loop. NFC.
llvm-svn: 239604
2015-06-12 13:06:57 +00:00
Daniel Jasper 60ba32d453 clang-format: Always add space before lambda-{
Before:
  int c = []() -> int *{ return 2; }();

After:
  int c = []() -> int * { return 2; }();

Based on patch by James Dennett (http://reviews.llvm.org/D10410), thank you!

llvm-svn: 239600
2015-06-12 09:59:16 +00:00
Daniel Jasper 554e49fe84 clang-format: Understand C-style case in case label.
Before:
  case (my_int) ONE:

After:
  case (my_int)ONE:

This fixed llvm.org/PR23760

llvm-svn: 239597
2015-06-12 07:15:33 +00:00
Daniel Jasper 216c9cdb1d clang-format: [JS] Support "export enum" declarations.
llvm-svn: 239595
2015-06-12 05:08:18 +00:00
Daniel Jasper 259188b1b5 clang-format: [JS] Fix regression caused by r239592.
Without it, it would do:

  interface I {
    x: string;
  } var y;

llvm-svn: 239593
2015-06-12 04:56:34 +00:00
Daniel Jasper 910807d4b9 clang-format: [JS] fix incorrectly collapsed lines after export
statement.

When an exported function would follow a class declaration, it would not
be recognized as a stand-alone function. That would then collapse the
following line with the current one, e.g.

  class C {}
  export function f() {} var x;

llvm-svn: 239592
2015-06-12 04:52:02 +00:00
Nico Weber 9c39f83f80 Wrap to 80 columns. No behavior change.
llvm-svn: 239591
2015-06-12 04:44:52 +00:00
Teresa Johnson edca6e507e Revert commit r239481 as it is dependent on reverted llvm commit r239480.
llvm-svn: 239588
2015-06-12 03:11:50 +00:00
Eric Christopher 789a7ad1a8 Add a warning for unsupported elements of the target attribute.
Since we're ignoring the tune= and fpmath= attributes go ahead
and add a warning alerting people to the fact that we're going
to ignore that part of it during code generation and tie it to
the attribute warning set.

llvm-svn: 239583
2015-06-12 01:36:05 +00:00
Eric Christopher 249e3762e5 Handle fpmath= in the target attribute.
Right now we're ignoring the fpmath attribute since there's no
backend support for a feature like this and to do so would require
checking the validity of the strings and doing general subtarget
feature parsing of valid and invalid features with the target
attribute feature.

llvm-svn: 239582
2015-06-12 01:36:00 +00:00
Eric Christopher 4dfe075f93 Handle -mno-<feature> in target attribute strings by replacing the
-mno- with a -<feature> to match how we handle this in the rest
of the frontend.

llvm-svn: 239581
2015-06-12 01:35:58 +00:00
Eric Christopher 64a247b68b Add support for tune= to the target attribute support by ignoring it.
We don't currently support the -mtune option in any useful way
so ignoring the annotation is fine.

llvm-svn: 239580
2015-06-12 01:35:56 +00:00
Eric Christopher 11acf739f8 Add support for the the target attribute.
Modeled after the gcc attribute of the same name, this feature
allows source level annotations to correspond to backend code
generation. In llvm particular parlance, this allows the adding
of subtarget features and changing the cpu for a particular function
based on source level hints.

This has been added into the existing support for function level
attributes without particular verification for any target outside
of whether or not the backend will support the features/cpu given
(similar to section, etc).

llvm-svn: 239579
2015-06-12 01:35:52 +00:00
Richard Smith a1431077de [modules] Apply name visibility rules to names found by ADL.
llvm-svn: 239578
2015-06-12 01:32:13 +00:00
David Majnemer 03a9056f58 [IRGen] Fix the MSVC2013 build
llvm-svn: 239576
2015-06-12 00:17:26 +00:00
Sean Silva b5aee61c36 [cleanup] Remove some unused #ifdef's
This is all going through the VFS layer now, so there's nothing
platform-specific here.

llvm-svn: 239573
2015-06-11 23:34:13 +00:00
Tyler Nowicki 9d268e178e Add assume_safety option for pragma loop vectorize and interleave.
Specifying #pragma clang loop vectorize(assume_safety) on a loop adds the
mem.parallel_loop_access metadata to each load/store operation in the loop. This
metadata tells loop access analysis (LAA) to skip memory dependency checking.

llvm-svn: 239572
2015-06-11 23:23:17 +00:00
Richard Smith 0f192e8940 [modules] Fix assert/crash when parsing and merging a definition of a class with a base-specifier inside a namespace.
llvm-svn: 239569
2015-06-11 22:48:25 +00:00
Hans Wennborg 64937c6f97 [ms] Do lookup in dependent base classes also when overload resolution fails (PR23810)
This patch does two things in order to enable compilation of the problematic code in PR23810:

1. In Sema::buildOverloadedCallSet, it postpones lookup for MS mode when no
viable candidate is found in the overload set. Previously, lookup would only
be postponed here if the overload set was empty.

2. Make BuildRecoveryCallExpr call Sema::DiagnoseEmptyLookup under more circumstances.
There is a comment in DiagnoseTwoPhaseLookup that says "Don't diagnose names we find in
classes; we get much better diagnostics for these from DiagnoseEmptyLookup." The problem
was that DiagnoseEmptyLookup might not get called later, and we failed to recover.

Differential Revision: http://reviews.llvm.org/D10369

llvm-svn: 239558
2015-06-11 21:21:57 +00:00
Ahmed Bougacha ff75f3dd6c [CodeGen] Emit Constants for immediate inlineasm arguments.
For inline assembly immediate constraints, we currently always use
EmitScalarExpr, instead of directly emitting the constant. When the
overflow sanitizer is enabled, this generates overflow intrinsics
instead of constants.

Instead, emit a constant for constraints that either require an
immediate (e.g. 'I' on X86), or only accepts constants (immediate
or symbolic; i.e., don't accept registers or memory).

Fixes PR19763.

Differential Revision: http://reviews.llvm.org/D10255

llvm-svn: 239549
2015-06-11 18:19:34 +00:00
Douglas Katzman fd5286717c Add comments to PrintActions1 and Driver::PrintActions.
Differential Revision: http://reviews.llvm.org/D10214

llvm-svn: 239537
2015-06-11 15:05:22 +00:00
Sanjay Patel 2987c29a1e add the -mrecip driver flag and process its options (3rd try)
The 1st and 2nd tries to land this (r238055, r238851) were reverted due to
bot failures caused by the LLVM part of the patch. That was hopefully fixed 
after r239001.

This is the front-end counterpart to D8982.

The -mrecip option interface is based on maintaining compatibility with gcc:
https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/i386-and-x86-64-Options.html#index-mrecip_003dopt-1627
https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/RS_002f6000-and-PowerPC-Options.html#index-mrecip-2289

...while adding more functionality (allowing users to specify the number of refinement steps for each
estimate type).

Differential Revision: http://reviews.llvm.org/D8989

llvm-svn: 239536
2015-06-11 14:53:41 +00:00
Daniel Jasper 20580fd5d3 clang-format: Make SFS_Inline imply SFS_Empty.
In the long run, these two might be independent or we might to only
allow specific combinations. Until we have a corresponding request,
however, it is hard to do the right thing and choose the right
configuration options. Thus, just don't touch the options yet and
just modify the behavior slightly.

llvm-svn: 239531
2015-06-11 13:31:45 +00:00
Daniel Jasper 56691b8cb9 clang-format: [JS] Ensure that formatting actually takes place in tests.
And fix formatting issue discovered by that :-).

llvm-svn: 239530
2015-06-11 13:29:20 +00:00
Yaron Keren b54db52a7b C++11 rangify several loops.
llvm-svn: 239528
2015-06-11 12:33:25 +00:00
Gabor Ballabas cebcb3b52f Allow case-insensitive values for -march for ARM in line with GCC.
GCC allows case-insensitive values for -mcpu, -march and -mtune options.
This patch implements the same behaviour for the -march option for ARM.

llvm-svn: 239527
2015-06-11 12:29:56 +00:00
Toma Tabacu b36d610cc2 [mips] Pass on -m{single,double}-float to GAS.
Summary: We already pass these to the IAS, but not to GAS.

Reviewers: dsanders, atanasyan

Reviewed By: atanasyan

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D10358

llvm-svn: 239525
2015-06-11 12:13:18 +00:00
Alexey Bataev 6e8248fdad [OPENMP] Fox for http://llvm.org/PR23663: OpenMP crash
Destroy RuntimeCleanupScope before generation of termination instruction in parallel loop precondition.

llvm-svn: 239524
2015-06-11 10:53:56 +00:00
Manuel Klimek f0c95b32ec Fix crash in clang-format.
The following example used to crash clang-format.
 #define a\
  /**/}

Adjusting the indentation level cache for the line starting with the
comment would lead to an out-of-bounds array read.

llvm-svn: 239521
2015-06-11 10:14:13 +00:00
Daniel Jasper 229628b39e clang-format: Don't add spaces in foreach macro definition.
Before clang-format would e.g. add a space into

   #define Q_FOREACH(x, y)

which turns this into a non-function-like macro.

Patch by Strager Neds, thank you!

llvm-svn: 239513
2015-06-11 08:38:19 +00:00
David Majnemer e0e228a380 Reinstate r239499 and r239503
They were reverted because the FileCheck patterns didn't match on
release builds.

llvm-svn: 239512
2015-06-11 08:12:44 +00:00
Manuel Klimek aad3b8486d Revert "[MS ABI] Allow fastcall member function pointers to get CodeGen'd"
Revert "[MS ABI] Allow memfn pointers with unconvertible types to be formed"

This reverts r239499 and r239503; the former breaks tests [1] and the
latter is based on the former.

[1]
http://lab.llvm.org:8080/green/job/clang-stage2-configure-Rlto_check/4473/testReport/Clang/CodeGenCXX/microsoft_abi_virtual_member_pointers_cpp/

llvm-svn: 239511
2015-06-11 07:54:35 +00:00
Nemanja Ivanovic b17f1129fa Clang support for vector quad bit permute and gather instructions through builtins
This patch corresponds to review:
http://reviews.llvm.org/D10095

This is for just two instructions and related builtins:
vbpermq
vgbbd

llvm-svn: 239506
2015-06-11 06:25:36 +00:00
Richard Smith 00be6d0ff8 [modules] Fix a few places where merging wasn't performed if modules was disabled but local module visibilty was enabled.
llvm-svn: 239504
2015-06-11 03:05:39 +00:00
David Majnemer 9321f926b0 [MS Compatibility] Handle cleanups we create for a ctor closure
This fixes PR23801.

llvm-svn: 239503
2015-06-11 02:38:06 +00:00
David Majnemer ac936ff5ab [MS ABI] Allow fastcall member function pointers to get CodeGen'd
This restriction appears unnecessary and most likely came about during
early work for musttail.

llvm-svn: 239500
2015-06-11 00:45:44 +00:00
David Majnemer 01b9bb42d4 [MS ABI] Allow memfn pointers with unconvertible types to be formed
Remove the restriction which forbade forming pointers to member
functions which had parameter types or return types which were not
convertible.

llvm-svn: 239499
2015-06-11 00:20:57 +00:00
Alexei Starovoitov f657ca8d78 [bpf] add support for BPF backend
add support for bpfel/bpfeb targets

llvm-svn: 239496
2015-06-10 22:59:13 +00:00
Richard Smith 95d83959d8 [modules] Don't allow use of non-visible (inherited) default template arguments.
llvm-svn: 239487
2015-06-10 20:36:34 +00:00
Richard Smith e7bd6defd7 [modules] Track all default template arguments for a given parameter across
modules, and allow use of a default template argument if any of the parameters
providing it is visible.

llvm-svn: 239485
2015-06-10 20:30:23 +00:00
Serge Pavlov 47ebb75cf9 Do not parse members of incomplete class.
If definition of a class is unknown and out-of-line definition of its
member is encountered, do not parse the member declaration.
This change fixes PR18542.

Differential Revision: http://reviews.llvm.org/D8010

llvm-svn: 239483
2015-06-10 19:06:59 +00:00
Teresa Johnson 88c3c67997 Pass down the -flto option to the -cc1 job, and from there into the
CodeGenOptions and onto the PassManagerBuilder. This enables gating
the new EliminateAvailableExternally module pass on whether we are
preparing for LTO.

If we are preparing for LTO (e.g. a -flto -c compile), the new pass is not
included as we want to preserve available externally functions for possible
link time inlining.

llvm-svn: 239481
2015-06-10 17:49:45 +00:00
Scott Douglass cc01359cfe some StmtExprs do not have side-effects
Differential Revision: http://reviews.llvm.org/D10211

llvm-svn: 239476
2015-06-10 15:18:23 +00:00
Scott Douglass 503fc39d1f add ConstEvaluatedExprVisitor
Differential Revision: http://reviews.llvm.org/D10210

llvm-svn: 239474
2015-06-10 13:53:15 +00:00
Alexander Musman 70e9f5fcb3 PR5172: Fix for a bug in pragma redefine_extname implementation:
it doesn't work correctly when a structure is declared before pragma
and then a function with the same name declared after pragma.

Patch by Andrey Bokhanko

Differential Revision: http://reviews.llvm.org/D10187

llvm-svn: 239466
2015-06-10 11:20:26 +00:00
Daniel Jasper 11ca263994 clang-format: [JS] Only special case top level object literal
assignments as enums.

Top level object literals are treated as enums, and their k/v pairs are put on
separate lines:

  X.Y = {
    A: 1,
    B: 2
  };

However assignments within blocks should not be affected:

  function x() {
    y = {a:1, b:2};
  }

This change fixes the second case. Patch by Martin Probst.

llvm-svn: 239462
2015-06-10 09:21:09 +00:00
Richard Smith 8346e52f89 [modules] Reconstruct template default argument inheritance on reload rather
than wasting storage and triggering eager deserializations by serializing it.

llvm-svn: 239454
2015-06-10 01:47:58 +00:00
Sean Silva 4881e8b239 [cleanup] Remove unused default argument and tidy up.
The RequestingModule argument was unused and always its default value of
nullptr.

Also move a declaration closer to its use, and range-for'ify.

llvm-svn: 239453
2015-06-10 01:37:59 +00:00
Richard Smith 1469b9196c Refactor storage of default template arguments.
This is just a preparatory step towards fixing visibility for default template
arguments in modules builds.

llvm-svn: 239447
2015-06-10 00:29:03 +00:00
Yunzhong Gao cb77930d6b Implementing C99 partial re-initialization behavior (DR-253)
Based on previous discussion on the mailing list, clang currently lacks support
for C99 partial re-initialization behavior:
Reference: http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-April/029188.html
Reference: http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_253.htm

This patch attempts to fix this problem.

Given the following code snippet,

struct P1 { char x[6]; };
struct LP1 { struct P1 p1; };

struct LP1 l = { .p1 = { "foo" }, .p1.x[2] = 'x' };
// this example is adapted from the example for "struct fred x[]" in DR-253;
// currently clang produces in l: { "\0\0x" },
//   whereas gcc 4.8 produces { "fox" };
// with this fix, clang will also produce: { "fox" };


Differential Review: http://reviews.llvm.org/D5789

llvm-svn: 239446
2015-06-10 00:27:52 +00:00
Akira Hatanaka 262a4c4ec0 Attach attribute "disable-tail-calls" to the functions in the IR.
This commit adds back the code that seems to have been dropped unintentionally
in r176985.

rdar://problem/13752163

Differential Revision: http://reviews.llvm.org/D10100

llvm-svn: 239426
2015-06-09 19:04:36 +00:00
David Majnemer 2617ea6756 [ItaniumMangle] Mangle long double as __float128 for some Power targets
GCC mangles long double like __float128 in order to support
compatibility with ABI variants which had a different interpretation of
long double.

This fixes PR23791.

llvm-svn: 239421
2015-06-09 18:05:33 +00:00
Reid Kleckner 0b9bbbfc13 Revert "Re-land r236052, "[SEH] Add 32-bit lowering code for __try""
This reverts commit r239415. This was committed accidentally, LLVM isn't
ready for this.

llvm-svn: 239417
2015-06-09 17:49:42 +00:00
Reid Kleckner 65870442b3 Re-land r236052, "[SEH] Add 32-bit lowering code for __try"
This reverts r236167.

LLVM should be ready for this now.

llvm-svn: 239415
2015-06-09 17:47:50 +00:00
Bill Seurer 703e8486ec [PowerPC] Reformat altivec.h with clang-format
This revision just fixes the formatting of altivec.h.

llvm-svn: 239408
2015-06-09 14:39:47 +00:00
Jonathan Roelofs 78f9e038e0 Fix printing of GCCAsmExprs with input or output arguments.
Patch by Nick Sumner!

llvm-svn: 239406
2015-06-09 14:13:31 +00:00
Daniel Jasper dee894f6bb clang-format: Support //!-comments, increase test coverage.
llvm-svn: 239404
2015-06-09 13:16:54 +00:00
Aaron Ballman 825fb3c9d4 Removing spurious semi colons; NFC.
llvm-svn: 239400
2015-06-09 12:04:17 +00:00
Daniel Jasper c83d76991c clang-format: [JS] Hotfix for runtime issue with deeply nested JS code.
I have not succeeded in writing a proper test case for this yet and we
also need to solve the underlying fundamental problem of trying too
many combinations with nested blocks (basically this somewhat works
around our Dijkstra algorithm). Preventing this linebreak is good
anyways as usually the penalties never make us choose it (that's why I
can't create a test) and it also looks ugly.

Also cleaned up state comparison code that I discovered while hunting
this down.

llvm-svn: 239398
2015-06-09 11:39:22 +00:00
Greg Bedwell 065f70ae80 clang-cl: Ignore the /o option when /P is specified.
This matches the cl.exe behavior (tested with 18.00.31101).  In order to
specify an output file for /P, use the /Fi option instead.

Differential Revision: http://reviews.llvm.org/D10313

llvm-svn: 239393
2015-06-09 10:24:06 +00:00
David Majnemer 75fdd6b888 [Driver] Preserve the object file format in ComputeEffectiveClangTriple
The object file format is sometimes overridden for MSVC targets to use
ELF instead of COFF.  Make sure we preserve this choice when setting the
msvc version number in the triple.

llvm-svn: 239388
2015-06-09 06:30:01 +00:00
David Majnemer 78324f2bce [MSVC Compatibility] Don't diagnose c-style cast from void-ptr to fn-ptr
The machinery added to permit a static_cast from void-ptr to fn-ptr
unintentionally gets triggered for c-style casts and function-style
casts.  The observable effect was a diagnostic issued inappropriately.

llvm-svn: 239382
2015-06-09 02:41:08 +00:00
Sean Silva 14facf307c range-for'ify Args->filtered_begin(...) loops
We already have Args->filtered(...) which is a drop-in range-for
replacement.

llvm-svn: 239381
2015-06-09 01:57:17 +00:00
Sean Silva ab70cfa3af Simplify this code a bit.
We weren't using the short-circuiting property anyway.

llvm-svn: 239376
2015-06-09 00:47:20 +00:00
Hans Wennborg fce87cae44 Enable DLL attribute propagation on explicit instantiation definitions (PR23770)
This is a follow-up to r225570 which enabled adding DLL attributes when a
class template goes from explicit instantiation declaration to explicit
instantiation definition.

llvm-svn: 239375
2015-06-09 00:39:09 +00:00
Hans Wennborg c0875507be MinGW: don't allow adding DLL attribute if template already has explicit instantiation declaration
This is a follow-up to r238266 which failed to take MinGW into account.

llvm-svn: 239374
2015-06-09 00:39:05 +00:00
Hans Wennborg bb1983cf3a Enable propagation of dll attributes to previously instantiated base class templates in some cases
It is safe to add a dll attribute if the base class template previously only had
an explicit instantiation declaration, or was implicitly instantiated.

I both those cases, the members would not have been codegenned yet. In the case
of explicit instantiation declaration this is natural, and for implicit
instantiations, codegen is deferred (see r225570).

This is work towards fixing PR23770.

llvm-svn: 239373
2015-06-09 00:39:03 +00:00
Hans Wennborg 29b7a93935 Narrow the -Wunsupported-dll-base-class-template warning.
Don't warn about not being able to propagate dll attribute to a base class template
when that base already has a different attribute.

MSVC doesn't actually try to do this; the first attribute that was propagated
takes precedence, so Clang is already doing the right thing and there's no
need to warn.

(This is a step towards fixing PR21718.)

llvm-svn: 239372
2015-06-09 00:38:56 +00:00
Richard Smith 87bb569844 [modules] Fix some visibility issues with default template arguments.
There are still problems here, but this is a better starting point.

The main part of the change is: when doing a lookup that would accept visible
or hidden declarations, prefer to produce the latest visible declaration if
there are any visible declarations, rather than always producing the latest
declaration.

Thus, when we inherit default arguments (and other properties) from a previous
declaration, we inherit them from the previous visible declaration; if the
previous declaration is hidden, we already suppress inheritance of default
arguments.

There are a couple of other changes here that fix latent bugs exposed by this
change.

llvm-svn: 239371
2015-06-09 00:35:49 +00:00
Tyler Nowicki 4e8e900dd1 Eliminate unnecessary namespace to prevent conflicts.
llvm-svn: 239365
2015-06-08 23:27:35 +00:00
Tyler Nowicki 24853c123a Correct Loop Hint Diagnostic Message
When pragma clang loop unroll() is specified without an argument the diagnostic message should inform that user that 'full' and 'disable' are valid arguments (not 'enable').

llvm-svn: 239363
2015-06-08 23:13:43 +00:00
Hubert Tong 13234ae40d Consider unsigned long for non-u/U decimal literals (C90/C++03)
Summary:
This modifies Clang to reflect that under pre-C99 ISO C, decimal
constants may have type `unsigned long` even if they do not contain `u`
or `U` in their suffix (C90 subclause 6.1.3.2 paragraph 5). The same is
done for C++ without C++11 which--because of undefined behaviour--allows
for behaviour compatible with ISO C90 in the case of an unsuffixed
decimal literal and is otherwise identical to C90 in its treatment of
integer literals (C++03 subclause 2.13.1 [lex.icon] paragraph 2).

Messages are added to the `c99-compat` and `c++11-compat` groups to warn
on such literals, since they behave differently under the newer
standards.

Fixes PR 16678.

Test Plan:
A new test file is added to exercise both pre-C99/C++11 and C99/C++11-up
on decimal literals with no suffix or suffixes `l`/`L` for both 32-bit
and 64-bit `long`.

In the file, 2^31 (being `INT_MAX+1`) is tested for the expected type
using `__typeof__` and multiple declarations of the same entity. 2^63
is similarly tested when it is within the range of `unsigned long`.

Preprocessor arithmetic tests are added to ensure consistency given
that Clang (like GCC) uses greater than 32 bits for preprocessor
arithmetic even when `long` and `unsigned long` is 32 bits and a
pre-C99/C++11 mode is in effect.

Tests added:
  test/Sema/PR16678.c

Reviewers: fraggamuffin, rsmith

Reviewed By: rsmith

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D9794

llvm-svn: 239356
2015-06-08 21:59:59 +00:00
Leny Kholodov 6aab1117e8 [CodeGen] Reuse stack space from unused function results (with more accurate unused result detection)
This patch fixes issues with unused result detection which were found in patch http://reviews.llvm.org/D9743.

Differential Revision: http://reviews.llvm.org/D10042

llvm-svn: 239294
2015-06-08 10:23:49 +00:00