Commit Graph

34660 Commits

Author SHA1 Message Date
Diego Novillo e6d398189e Update call DIBuilder::createLexicalBlock.
Create lexical blocks with discriminator value 0 by default.

llvm-svn: 202737
2014-03-03 18:53:32 +00:00
Jordan Rose 7ef1c387a0 Serialized diagnostic severity levels should be stable.
Serialized diagnostics were accidentally using the AST diagnostic level values
rather than a dedicated stable enum, so the addition of "remark" broke the
reading of existing serialized diagnostics files. I've added a .dia file
generated from Xcode 5's Clang to make sure we don't break this in the future.

llvm-svn: 202733
2014-03-03 18:29:52 +00:00
Robert Lytton d21e2d76fc correct consitency of XCore caps
llvm-svn: 202711
2014-03-03 13:45:29 +00:00
Argyrios Kyrtzidis 1594c15500 Introduce '-fmodules-user-build-path' which accepts the "canonical" path to a user workspace build.
This is used to avoid conflicts with user modules with the same name from different workspaces.

rdar://16042513

llvm-svn: 202683
2014-03-03 08:12:05 +00:00
Ahmed Charles bf8e283f15 [C++11] Add #include's for OwningPtr.
Allows removing #include's in LLVM while switching to std::unique_ptr.

llvm-svn: 202677
2014-03-03 07:11:21 +00:00
Peter Collingbourne c0423b349b Disable all dependency output options when using the Tooling library.
It isn't appropriate for a tool to be stomping over the dependency files,
especially if the actual build uses a compiler other than Clang or the tool
cannot find all the headers for some reason (which would cause the existing
dependency file to be deleted).

If a tool actually needs to care about dependency files we can think about
adding a mechanism for getting to this information.

Differential Revision: http://llvm-reviews.chandlerc.com/D2912

llvm-svn: 202669
2014-03-02 23:37:26 +00:00
David Majnemer dbd6acb64b Revert "Preprocessor: Add __ALIGNOF_MAX_ALIGN_T__"
This commit reverts r201037, it's functionality is not needed given the
definition of std::max_align_t in libcxx circa r201843.

llvm-svn: 202667
2014-03-02 23:01:10 +00:00
David Majnemer b100410365 Normalize line endings
Some files had CRLF line terminators, some only had a mixture of
CRLF and LF.  Switch to LF.

llvm-svn: 202659
2014-03-02 18:46:05 +00:00
Hal Finkel f7a07a5010 Add a PPC inline asm constraint type for single CR bits
This adds support for the PPC "wc" inline asm constraint (used for allocating
individual CR bits). Support for this constraint type was recently added to the
LLVM PowerPC backend. Although gcc does not currently support allocating
individual CR bits, this identifier choice has been coordinated with the gcc
PowerPC team, and will be marked as reserved for this purpose in the gcc
constraints.md file.

Prior to this change, none of the multi-character PPC constraints were handled
correctly (the '^' escape character was not being added as required by the
parsing code in LLVM). This should now be fixed. I'll add tests for these other
constraints as support is added for them in the backend.

llvm-svn: 202658
2014-03-02 18:24:18 +00:00
Benjamin Kramer bd39f6e364 [C++11] ASTMatchers: Use standard static_assert and type traits.
llvm-svn: 202653
2014-03-02 17:08:43 +00:00
Benjamin Kramer 4527fb2f33 [C++11] Use std::atomic instead of LLVM's.
No intended functionality change.

llvm-svn: 202652
2014-03-02 17:08:31 +00:00
Benjamin Kramer cef536ec0f [C++11] Work around an incompatibility between llvm::tie and std::tie.
llvm-svn: 202643
2014-03-02 13:18:22 +00:00
Chandler Carruth 06dde92cd6 [C++11] Switch from LLVM_STATIC_ASSERT to static_assert now that we
require host toolchains which support this.

llvm-svn: 202640
2014-03-02 13:02:01 +00:00
Benjamin Kramer 867ea1d426 [C++11] Replace llvm::tie with std::tie.
llvm-svn: 202639
2014-03-02 13:01:17 +00:00
Chandler Carruth f8b7266d57 [C++11] Switch the clang-format LLVM style to use C++11 style braced
init list formatting. This suggestion has now gone into the LLVM coding
standards, and is particularly relevant now that we're using C++11.

Updated a really ridiculous number of tests to reflect this change.

llvm-svn: 202637
2014-03-02 12:37:31 +00:00
Benjamin Kramer 167e999be9 [C++11] Replace llvm::next and llvm::prior with std::next and std::prev.
llvm-svn: 202635
2014-03-02 12:20:24 +00:00
Craig Topper bbc6d62736 [C++11] Remove an LLVM_OVERRIDE use that I missed in my previous commit.
llvm-svn: 202630
2014-03-02 10:02:43 +00:00
Craig Topper a798a9db93 Switch all uses of LLVM_OVERRIDE to just use 'override' directly.
llvm-svn: 202625
2014-03-02 09:32:10 +00:00
Richard Smith 7794486846 Add [extern_c] attribute for modules, allowing a C module to be imported within an extern "C" block in C++ code.
llvm-svn: 202615
2014-03-02 05:58:18 +00:00
Chandler Carruth c72d9b33af [C++11] Switch from the llvm_move macro to directly calling std::move.
llvm-svn: 202611
2014-03-02 04:02:40 +00:00
Alp Toker ceb95c47c4 [C++11] Expand and eliminate the LLVM_ENUM_INT_TYPE() macro
llvm-svn: 202606
2014-03-02 03:20:16 +00:00
Benjamin Kramer 3d6220d981 Move private classes into anonymous namespaces.
llvm-svn: 202595
2014-03-01 17:21:22 +00:00
Benjamin Kramer bbdd7640e8 [C++11] Replace verbose functors with succinct lambdas
No functionality change.

llvm-svn: 202590
2014-03-01 14:48:57 +00:00
Warren Hunt fed55979b1 Fixed an assertion failure related to bitfield lowering.
When lowering a bitfield, CGRecordLowering would assign the wrong 
storage type to a bitfield in some cases and trigger an assertion.  In 
these cases the layout was still correct, just the bitfield info was 
wrong.

llvm-svn: 202562
2014-03-01 00:38:40 +00:00
Richard Smith 49f906a36f If a module A exports a macro M, and a module B imports that macro and #undef's
it, importers of B should not see the macro. This is complicated by the fact
that A's macro could also be visible through a different path. The rules (as
hashed out on cfe-commits) are included as a documentation update in this
change.

With this, the number of regressions in libc++'s testsuite when modules are
enabled drops from 47 to 7. Those remaining 7 are also macro-related, and are
due to remaining bugs in this change (in particular, the handling of submodules
is imperfect).

llvm-svn: 202560
2014-03-01 00:08:04 +00:00
Reid Kleckner 3331128994 Fix leak in MicrosoftVTableContext
llvm-svn: 202558
2014-02-28 23:26:22 +00:00
Anton Yartsev 68a172ca16 [analyzer] Fix for PR18394.
Additional conditions that prevent useful nodes before call from being reclaimed.

llvm-svn: 202553
2014-02-28 22:29:48 +00:00
Ben Langmuir d066d4c849 Reapply fixed "Honour 'use-external-names' in FileManager"
Was r202442

There were two issues with the original patch that have now been fixed.
1. We were memset'ing over a FileEntry in a test case. After adding a
   std::string to FileEntry, this still happened to not break for me.
2. I didn't pass the FileManager into the new compiler instance in
   compileModule. This was hidden in some cases by the fact I didn't
   clear the module cache in the test.

Also, I changed the copy constructor for FileEntry, which was memcpy'ing
in a (now) unsafe way.

llvm-svn: 202539
2014-02-28 21:16:07 +00:00
Richard Smith 35ddad0723 Fix a minor bug in lexing pp-numbers with digit separators: if a pp-number contains "'e+", the pp-number ends between the 'e' and the '+'.
llvm-svn: 202533
2014-02-28 20:06:02 +00:00
Anders Carlsson 382ba41c48 When completing Objective-C instance method invocations, perform a contextual conversion to an Objective-C pointer type of the target expression if needed. This fixes code completion of method invocations where the target is a smart pointer that has an explicit conversion operator to an Objective-C type.
llvm-svn: 202529
2014-02-28 19:07:22 +00:00
Kaelyn Uhrain b4b1475322 Don't suggest non-static methods as corrections when they obviously
won't work (i.e. when not doing a member lookup and not in a method from
the same class or a descendant class).

llvm-svn: 202520
2014-02-28 18:12:42 +00:00
Tobias Grosser 741602461d Add 'remark' diagnostic type in 'clang'
A 'remark' is information that is not an error or a warning, but rather some
additional information provided to the user. In contrast to a 'note' a 'remark'
is an independent diagnostic, whereas a 'note' always depends on another
diagnostic.

A typical use case for remark nodes is information provided to the user, e.g.
information provided by the vectorizer about loops that have been vectorized.

This patch provides the initial implementation of 'remarks'. It includes the
actual definiton of the remark nodes, their printing as well as basic parameter
handling. We are reusing the existing diagnostic parameters which means a remark
can be enabled with normal '-Wdiagnostic-name' flags and can be upgraded to
an error using '-Werror=diagnostic-name'. '-Werror' alone does not upgrade
remarks.

This patch is by intention minimal in terms of parameter handling. More
experience and more discussions will most likely lead to further enhancements
in the parameter handling.

llvm-svn: 202475
2014-02-28 09:11:08 +00:00
Argyrios Kyrtzidis 24c55228a9 [ASTUnit] Don't let the preamble diagnostics out-live the CompilerInstance that created them,
this is inherently unsafe.

Instead get the diagnostic info into a SourceManager-independent form.

llvm-svn: 202471
2014-02-28 07:11:01 +00:00
Nick Lewycky b8336b7d13 Fix crash with enable_if on constructors.
llvm-svn: 202467
2014-02-28 05:26:13 +00:00
Rafael Espindola cc126271f8 Add support for OpenBSD SPARC assembler.
Patch by Brad Smith.

llvm-svn: 202462
2014-02-28 01:55:21 +00:00
Richard Smith 2868a736f8 Add a -Wclass-varargs to warn on objects of any class type being passed through an ellipsis. Since C++11 relaxed the rules on this, we allow a lot more bad code through silently, such as:
const char *format = "%s";
  std::experimental::string_view view = "foo";
  printf(format, view);

In this case, not only warn about a class type being used here, but also suggest that calling c_str() might be a good idea.

llvm-svn: 202461
2014-02-28 01:36:39 +00:00
Reid Kleckner 383c2f232e Attempt to fix non-MSVC build
llvm-svn: 202458
2014-02-28 01:12:55 +00:00
Reid Kleckner ad59deb436 -fdump-record-layouts: Sort nvbases by offset before printing them
It makes our -fdump-record-layouts a little more sane.

llvm-svn: 202457
2014-02-28 01:03:09 +00:00
Richard Trieu 86738692fd "&&&" != "&&"
llvm-svn: 202444
2014-02-27 23:59:14 +00:00
Ben Langmuir 1b8d44f59b Revert "Honour 'use-external-names' in FileManager"
Revert r202442, which broke the buildbots.

llvm-svn: 202443
2014-02-27 23:48:03 +00:00
Ben Langmuir 09e0d5c1bb Honour 'use-external-names' in FileManager
Pass through the externally-visible names that we got from the VFS down
to FileManager, and test that this is the name showing up in __FILE__,
diagnostics, and debug information.

llvm-svn: 202442
2014-02-27 23:27:54 +00:00
Reid Kleckner d6f9b83ae1 MS ABI: Attempt to fix DenseMap entry reference invalidation
llvm-svn: 202441
2014-02-27 22:51:43 +00:00
Ben Langmuir c9b7234e5c Reapply r202420 hopefully fixed for other STLs
Keep the copy constructor around, and add a FIXME that we should really
remove it as soon as we have C++11 std::map's emplace function.

llvm-svn: 202439
2014-02-27 22:21:32 +00:00
Bob Wilson 32dc99a480 Remove an assertion that no longer holds. <rdar://problem/16135814>
In r201528, I changed the PGO instrumentation counter for a "do" loop to not
include the fall-through count. That fall-through count is included later, b
it means that this assertion may fail for "do" loops.

llvm-svn: 202437
2014-02-27 21:59:17 +00:00
Ted Kremenek 08da97819a [-Wunreachable-code] always treat 'case:' and 'default:' cases as reachable.
This is a heuristic.  Many switch statements, although they look covered
over an enum, may actually handle at runtime more values than in the enum.

This is overly conservative, as there are some cases that clearly
can be ruled as being clearly unreachable, e.g. 'switch (42) { case 1: ... }'.
We can refine this later.

llvm-svn: 202436
2014-02-27 21:56:47 +00:00
Ted Kremenek 9238c5c878 [CFG] record the original (now unreachable) block of 'case:' and 'default:' cases.
llvm-svn: 202435
2014-02-27 21:56:44 +00:00
Ted Kremenek 4b408e7a04 [analyzer] check for now possibly null predecessor edge.
llvm-svn: 202434
2014-02-27 21:56:41 +00:00
Rui Ueyama ad33e60bef Fix -Wunused-function in Release build.
llvm-svn: 202429
2014-02-27 20:50:04 +00:00
John McCall 95833f33bd Diagnose attempts to apply ms_struct to records with base classes
or virtual functions, but permit that error to be downgraded to
a warning (with -Wno-error=incompatible-ms-struct), and officially
support this kind of dual, ABI-mixing layout.

The basic problem here is that projects which use ms_struct are often
not very circumspect about what types they annotate; for example,
some projects enable the pragma in a prefix header and then only
selectively disable it around system header inclusions.  They may
only care about binary compatibility with MSVC for a subset of
those structs, but that doesn't mean they have no binary
compatibility concerns at all for the rest; thus we are essentially
forced into supporting this hybrid ABI.  But it's reasonable for
us to at least point out the places where we're not making
any guarantees.

The original diagnostic was for dynamic classes, i.e. those with
virtual functions or virtual bases; I've extended it to include
all classes with bases, because we are not actually making any
attempt to duplicate MSVC's base subobject layout in ms_struct
(and it is indeed quite different from Itanium, even for
non-virtual bases).

rdar://16178895

llvm-svn: 202427
2014-02-27 20:30:49 +00:00
Reid Kleckner 9c6e9e313d MS ABI: Fix vftable mangling by using the vbtable name algorithm
Summary:
This merges VFPtrInfo and VBTableInfo into VPtrInfo, since they hold
almost the same information.  With that change, the vbtable mangling
code can easily be applied to vftable data and we magically get the
correct, unambiguous vftable names.

Fixes PR17748.

Reviewers: timurrrr, majnemer

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D2893

llvm-svn: 202425
2014-02-27 19:40:09 +00:00
Ben Langmuir 90292a57fc Revert "Remove constructors from FileEntry that prevent owning resources"
This reverts commit r202420, which broke the build.

llvm-svn: 202421
2014-02-27 19:20:35 +00:00
Ben Langmuir e2db0cb07b Remove constructors from FileEntry that prevent owning resources
This cleans up some constructors that would not be safe once FileEntry
owns the storage for its name. These were already suspect, since they
wouldn't work if the FileEntry had an open file descriptor. The only
user for these constructors was in UniqueFileContainer, which wasn't a
very useful abstraction anyway. So it and UniqueDirContainer have been
replaced with std::map<UniqueID, *>.

This change should not affect anything outside the FileManager.

llvm-svn: 202420
2014-02-27 19:14:03 +00:00
Rafael Espindola 5179a4ea28 Use private linkage for globals we already name with \01L and \01l.
In llvm the only semantic difference between internal and private is that llvm
tries to hide private globals my mangling them with a private prefix. Since
the globals changed by this patch already had the magic don't mangle marker,
there should be no change in the generated assembly.

A followup patch should then be able to drop the \01L and \01l prefixes and let
llvm mangle as appropriate.

llvm-svn: 202419
2014-02-27 19:01:11 +00:00
Ben Langmuir c8a71468b7 Split FileEntry name vs. isValid
This is a small bit of refactoring in preparation for FileEntry owning
the storage for its own name.

llvm-svn: 202412
2014-02-27 17:23:33 +00:00
Rafael Espindola 21039aac60 Assert that the name of some internal variables start with \01L or \01l.
No functionality change. This is just an intermediate patch for changing those
global variables to use private linkage.

llvm-svn: 202409
2014-02-27 16:26:32 +00:00
Alexey Bataev 1b59ab5683 [OPENMP] First changes for Parsing and Sema for 'omp simd' directive support
llvm-svn: 202360
2014-02-27 08:29:12 +00:00
Ted Kremenek 5441c18824 [-Wunreachable-code] Don't warn about trivially unreachable return statements preceded by 'noreturn' functions.
llvm-svn: 202352
2014-02-27 06:32:32 +00:00
Ted Kremenek 35883155bb [-Wunreachable-code] Don't warn about unreachable 'default:' cases.
They are covered by -Wcovered-switch-default.

llvm-svn: 202349
2014-02-27 05:42:07 +00:00
Argyrios Kyrtzidis 1b7ed91e44 [ASTUnit] Fix use-after-free bug in ASTUnit::getMainBufferWithPrecompiledPreamble().
With r197755 we started reading the contents of buffer file entries, but the
buffers may point to ASTReader blobs that have been disposed.

Fix this by having the CompilerInstance object keep a reference to the ASTReader
as well as having the ASTContext keep reference to the ExternalASTSource.

This was very difficult to construct a test case for.
rdar://16149782

llvm-svn: 202346
2014-02-27 04:11:59 +00:00
Nick Lewycky cdf1108b61 As of r202325, CFGBlock predecessors may be NULL. Ignore such preds. Fixes a crasher, PR18983.
llvm-svn: 202340
2014-02-27 02:43:25 +00:00
Eric Christopher e4200a291b Pass down the debug emission kind into the compile unit for code
generation purposes.
Paired with a commit to llvm.

llvm-svn: 202334
2014-02-27 01:25:08 +00:00
Hans Wennborg d7895aca99 [MS ABI] Error instead of generating bad vftables for certain virtual hierarchies (PR18967)
Erroring out until we fix the bug means we don't have to keep chasing down
this same miscompile in a bunch of different places.

Differential Revision: http://llvm-reviews.chandlerc.com/D2890

llvm-svn: 202331
2014-02-27 01:14:31 +00:00
Nick Lewycky 9a4416486d Fix -Wunused-variable in non-assert builds. No functionality change.
llvm-svn: 202330
2014-02-27 00:36:00 +00:00
Ben Langmuir b59cf679e8 Add a 'use-external-names' option to VFS overlay files
When true, sets the name of the file to be the name from
'external-contents'. Otherwise, you get the virtual path that the file
was looked up by. This will not affect any non-virtual paths, or fully
virtual paths (for which there is no reasonable 'external' name anyway).

The setting is available globally, but can be overriden on a per-file
basis.

The goal is that this setting will control which path you see in debug
info, diagnostics, etc. which are sensitive to which path is used. That
will come in future patches that pass the name through to FileManager.

llvm-svn: 202329
2014-02-27 00:25:12 +00:00
Ted Kremenek cc893386bc [-Wunreachable-code] Prune out unreachable warnings where a 'break' is preceded by a call to a 'noreturn' function.
For example:

	unreachable();
    break;

This code is idiomatic and defensive.  The fact that 'break' is
unreachable here is not interesting.  This occurs frequently
in LLVM/Clang itself.

llvm-svn: 202328
2014-02-27 00:24:08 +00:00
Ted Kremenek f353919e8e [CFG] encode unreachable block information for would-have-been successors for calls to 'noreturn' functions.
llvm-svn: 202327
2014-02-27 00:24:05 +00:00
Ted Kremenek f389861052 [CFG] Encode unreachable block information for successors when visiting 'if' statements.
llvm-svn: 202326
2014-02-27 00:24:03 +00:00
Ted Kremenek 4b6fee6cc4 Rework CFG edges to encode potentially unreachable edges, instead of just making them NULL.
This is to support some analyses, like -Wunreachable-code, that
will need to recover the original unprunned CFG edges in order
to suppress issues that aren't really bugs in practice.

There are two important changes here:

- AdjacentBlock replaces CFGBlock* for CFG successors/predecessors.
  This has the size of 2 pointers, instead of 1.  This is unlikely
  to have a significant memory impact on Sema since a single
  CFG usually exists at one time, but could impact the memory
  usage of the static analyzer.  This could possibly be optimized
  down to a single pointer with some cleverness.

- Predecessors can now contain null predecessors, which means
  some analyses doing a reverse traversal will need to take into
  account.  This already exists for successors, which contain
  successor slots for specific branch kinds (e.g., 'if') that
  expect a fixed number of successors, even if a branch is
  not reachable.

llvm-svn: 202325
2014-02-27 00:24:00 +00:00
Reid Kleckner c497f1d487 PR18962: Fix "Unable to find record layout information for type"
Clang is using llvm::StructType::isOpaque() as a way of signaling if
we've finished record type conversion in
CodeGenTypes::isRecordLayoutComplete().  However, Clang was setting the
body of the type before it finished laying out the type as a base type.
Laying out the %class.C.base LLVM type attempts to convert more types,
eventually recursively attempting to layout 'C' again, at which point we
would say that layout was complete, even though we were still in the
middle of it.

By not setting the body, we correctly signal that layout is not
complete, and things work as expected.

At some point, it might be worth refactoring this to avoid looking at
the LLVM IR types under construction.

llvm-svn: 202320
2014-02-27 00:03:39 +00:00
Alp Toker c535072d0d argument -> parameter terminology fixes for FunctionTypeInfo
This is a continuation of r199686.

llvm-svn: 202307
2014-02-26 22:27:52 +00:00
Rafael Espindola 554256ca56 Refactor linkage computation in CGObjCMac.cpp.
Before this patch the globals were created with the wrong linkage and patched
afterwards. From the comments it looks like something would complain about
having an internal GV with no initializer. At least in clang the verifier will
only run way after we set the initializer, so that is not a problem.

This patch should be a nop. It just figures out the linkage earlier and
converts the old calls to setLinkage to asserts. The only case where that is
not possible is when we first see a weak import that is then implemented. In
that case we have to change the linkage, but that is the only setLinkage left.

llvm-svn: 202305
2014-02-26 22:25:45 +00:00
Nico Rieck 8e9791f62c Sema: Definition of dllimport globals is not allowed
Upgrades the warning to an error and clarifies the message by treating the
definition as error instead of the attribute.

llvm-svn: 202300
2014-02-26 21:27:13 +00:00
Tim Northover b44e080dbb AArch64: use less cluttered intrinsic for vtbl/vtbx
The table is always 128-bit so there's no reason to specify it every time we
want the intrinsic.

llvm-svn: 202259
2014-02-26 11:55:15 +00:00
Tobias Grosser bd25bebf75 Fix typo
llvm-svn: 202254
2014-02-26 10:21:56 +00:00
NAKAMURA Takumi 9698686505 [CMake] Use LINK_LIBS instead of target_link_libraries().
llvm-svn: 202238
2014-02-26 06:41:29 +00:00
NAKAMURA Takumi 55a02eaa82 [CMake] Apply DEPENDS intrinsics_gen in clangCodeGen.
llvm-svn: 202237
2014-02-26 06:33:27 +00:00
Eric Christopher 0a1301fe25 80-col and bad line ending fixups.
llvm-svn: 202219
2014-02-26 02:49:36 +00:00
Richard Trieu 3bb8b56a5d PR16074, implement warnings to catch pointer to boolean true and pointer to
null comparison when the pointer is known to be non-null.

This catches the array to pointer decay, function to pointer decay and
address of variables.  This does not catch address of function since this
has been previously used to silence a warning.

Pointer to bool conversion is under -Wbool-conversion.
Pointer to null comparison is under -Wtautological-pointer-compare, a sub-group
of -Wtautological-compare.

void foo() {
  int arr[5];
  int x;
  // warn on these conditionals
  if (foo);
  if (arr);
  if (&x);
  if (foo == null);
  if (arr == null);
  if (&x == null);

  if (&foo);  // no warning
}

llvm-svn: 202216
2014-02-26 02:36:06 +00:00
Jordan Rose e359d0168f [analyzer] NonNullParamChecker: don't freak out about nested transparent_unions.
For now, just ignore them. Later, we could try looking through LazyCompoundVals,
but we at least shouldn't crash.

<rdar://problem/16153464>

llvm-svn: 202212
2014-02-26 01:20:19 +00:00
Richard Trieu 7eb0b2c181 Add -Wabsolute-value, warnings about absolute value functions.
The warnings fall into three groups.
1) Using an absolute value function of the wrong type, for instance, using the
int absolute value function when the argument is a floating point type.
2) Using the improper sized absolute value function, for instance, using abs
when the argument is a long long.  llabs should be used instead.

From these two cases, an implicit conversion will occur which may cause
unexpected behavior.  Where possible, suggest the proper absolute value
function to use, and which header to include if the function is not available.

3) Taking the absolute value of an unsigned value.  In addition to this warning,
suggest to remove the function call.  This usually indicates a logic error
since the programmer assumed negative values would have been possible.

llvm-svn: 202211
2014-02-26 01:17:28 +00:00
Adrian Prantl 800faef380 Address review comments for r202185, no functionality changes.
llvm-svn: 202208
2014-02-25 23:42:18 +00:00
Ted Kremenek c1b2875e69 Hoist culling of -Wunreachable-code from headers before we even run the analysis.
llvm-svn: 202200
2014-02-25 22:35:37 +00:00
Adrian Prantl d45ba2527c Debug info: Generate debug info for variadic functions.
Paired commit with LLVM.

rdar://problem/13690847

llvm-svn: 202185
2014-02-25 19:38:11 +00:00
Benjamin Kramer 2907b08219 Pretty Printer: Print constexpr and ref qualifiers. Don't print return types on destructors.
llvm-svn: 202181
2014-02-25 18:49:49 +00:00
Roman Divacky 9f77940fdc Pass the sparc architecture variant to the assembler.
llvm-svn: 202179
2014-02-25 18:45:49 +00:00
Hans Wennborg 7b0dcef072 clang-cl: use -fno-rtti by default
Generating RTTI in the MS ABI is currently not supported, and the failures
are confusing to users, so let's disable it by default for now.

llvm-svn: 202178
2014-02-25 18:36:22 +00:00
Roman Divacky b1ae3d4937 Give sparcv9 the ability to set the target cpu. Change it from accepting
-march which doesnt exist on sparc gcc to -mcpu. While here adjust a
few tests to not write an unused temporary file.

llvm-svn: 202177
2014-02-25 18:35:30 +00:00
Ben Langmuir 801272a98c Add a driver option -ivfsoverlay
Reads the description of a virtual filesystem from a file and overlays
it over the real file system.

llvm-svn: 202176
2014-02-25 18:23:47 +00:00
Reid Kleckner db673ca26a MS ABI: Just use getTypeInfoInChars to get the field size
This was changed to use manual desugaring and multiplication in r201832
and fixed for multi-dimensional arrays in r201917.  However, it breaks
down in the presence of typedefs.  Rather than attempting to handle all
the desugaring, just go back to calling the generic type info code.

This was discovered while compiling SIInstrWaits.cpp in the R600
backend.

llvm-svn: 202175
2014-02-25 18:08:48 +00:00
Benjamin Kramer 00e8a1915a Reapply "Pretty Printer: Fix printing of conversion operator decls and calls."
There were many additional tests that had the bad behavior baked in.

llvm-svn: 202174
2014-02-25 18:03:55 +00:00
Rafael Espindola 8e38871865 Revert "Pretty Printer: Fix printing of conversion operator decls and calls."
This reverts commit r202167.

It broke Analysis/auto-obj-dtors-cfg-output.cpp

llvm-svn: 202173
2014-02-25 17:39:16 +00:00
Rafael Espindola 303f8b06f8 Update for llvm api change.
llvm-svn: 202170
2014-02-25 17:30:40 +00:00
Benjamin Kramer 48f52e926d Pretty Printer: Fix printing of conversion operator decls and calls.
- Don't emit anything when we encounter a call to a conversion operator.
    "bar(a & b)" instead of "bar(a & b.operator int())"
  This preserves the semantics and is still idempotent if we print the AST multiple times.

- Properly print declarations of conversion operators.
    "explicit operator bool();" instead of "bool operator _Bool();"

PR18776.

llvm-svn: 202167
2014-02-25 17:26:26 +00:00
Tim Northover 2df47cedeb AArch64: use different type modifier in arm_neon.td
The 'f' modifier is designed for integer type arguments really (according to
its documentation). It's better to use the "half width, same number" modifier.

Should be no user-visible change.

llvm-svn: 202152
2014-02-25 13:53:01 +00:00
Christian Pirker 9b019ae899 Add AArch64 big endian Target (aarch64_be)
llvm-svn: 202151
2014-02-25 13:51:00 +00:00
Alexey Samsonov e65ceb9f16 Respect ToolChain::isPIEDefault() in constructing link job on Linux and FreeBSD.
Partially based on http://llvm-reviews.chandlerc.com/D2644 by Viktor Kutuzov.

llvm-svn: 202150
2014-02-25 13:26:03 +00:00
Alexey Samsonov ce8ab107ac Factor adding sanitizer linker flags into a separate function and make it less OS-specific
llvm-svn: 202148
2014-02-25 12:43:43 +00:00
Benjamin Kramer cdac761475 Sema: When merging objc string literals, give the result a constant array type.
Also assert that we never create non-array string literals again.

PR18939.

llvm-svn: 202147
2014-02-25 12:26:20 +00:00
Benjamin Kramer fc18842437 RewriteObjC: Factor string literal creation into a helper and make sure it gets a proper constant array type.
No change in output.

llvm-svn: 202146
2014-02-25 12:26:11 +00:00
Alexey Bataev 1319381686 Fix for Bug 18536 - Bad alignment in clang/AST/StmpOpenMP.h
llvm-svn: 202141
2014-02-25 11:25:38 +00:00
David Majnemer 19d7d5463f IRGen: Remove a stale comment
This comment survived the transition from ForceInline to InlineAlways,
fix it.

llvm-svn: 202133
2014-02-25 10:51:14 +00:00
David Majnemer 67e541e1c8 Attr: Remove ForceInline
The __forceinline keyword's semantics are now recast as AlwaysInline and
the kw___forceinline token has its language mode set for KEYMS.

This preserves the semantics of the previous implementation but with
less duplication of code.

llvm-svn: 202131
2014-02-25 09:53:29 +00:00
Ted Kremenek db07694102 Remove dead assignment reported by Gautier DI FOLCO.
llvm-svn: 202115
2014-02-25 05:58:54 +00:00
Ben Langmuir 47ff9ab1be Allow multi-component paths in VFS file nodes
This allows the 'name' field to contain a path, like

{ 'type': 'directory',
  'name': '/path/to/dir',
  'contents': [ ... ] }

which not only simplifies reading and writing these files (for humans),
but makes it possible to easily modify locations via textual
replacement, which would not have worked in the old scheme.

E.g. sed s:<ROOT>:<NEW ROOT>

llvm-svn: 202109
2014-02-25 04:34:14 +00:00
Alp Toker f45fa3dca5 Fix typos
llvm-svn: 202108
2014-02-25 04:21:44 +00:00
David Majnemer e385d89ce6 IRGen: Simplify alignment calculation in setBitFieldInfo
Take advantage of CharUnits::alignmentAtOffset instead of calculating it
by hand.

Differential Revision: http://llvm-reviews.chandlerc.com/D2862

llvm-svn: 202098
2014-02-25 01:20:15 +00:00
Reid Kleckner fab1e89de9 MS ABI: Return sret parameters when using inalloca
Previously the X86 backend would look for the sret attribute and handle
this for us.  inalloca takes that all away, so we have to do the return
ourselves now.

llvm-svn: 202097
2014-02-25 00:59:14 +00:00
David Majnemer 1d4db8f719 AST: Small code cleanup
Move the pointer to be adjacent to the variable instead of the type.

No functional change.

llvm-svn: 202089
2014-02-24 23:43:27 +00:00
David Majnemer 8b6bd571c8 Sema: Make getPreferredTypeAlign respect alignments specified with an aligned attribute on a typedef
When calculating the preferred alignment of a type, consider if a alignment
attribute came from a typedef declaration.  If one did, do not naturally align
the type.

Patch by Stephan Tolksdorf, with a little tweaking and an additional testcase by me.

llvm-svn: 202088
2014-02-24 23:34:17 +00:00
Ben Langmuir 97882e7b7f Pass through context for DiagHandler in VFS
This allows the unit tests to not use global state when checking
diagnostics.

llvm-svn: 202072
2014-02-24 20:56:37 +00:00
Richard Smith 5b2f7c5f60 If preprocessing results in a token with leading whitespace that was expanded
from a macro in column 0, ensure that we print whitespace before it in the -E
output. Patch by Harald van Dijk!

llvm-svn: 202070
2014-02-24 20:50:36 +00:00
Peter Collingbourne dec2c8657e Follow up to r201927: remove the Sema::InFunctionDeclarator field.
llvm-svn: 202069
2014-02-24 20:45:14 +00:00
Richard Smith f2baa70396 If the first token in a macro that appears at the start of a line expands to
nothing, be sure to inform the *next* token expanded from the macro that it is
now at the start of a line. Patch by Harald van Dijk!

llvm-svn: 202068
2014-02-24 20:45:00 +00:00
Fariborz Jahanian a7352db7b4 Objective-C. Remove an assertion which asserts
on correctly handled block layout IRGen. 
// rdar://16111839

llvm-svn: 202063
2014-02-24 19:10:37 +00:00
Roman Divacky f02c9944c8 Implement getDwarfEHStackPointer() and initDwarfEHRegSizeTable() for sparcv9.
llvm-svn: 202059
2014-02-24 18:46:27 +00:00
Richard Barton c9b5f35ec1 Implement -fno-short-wchar
llvm-svn: 202058
2014-02-24 18:43:28 +00:00
Rafael Espindola 4fbd373815 Update for llvm api change.
llvm-svn: 202053
2014-02-24 18:20:21 +00:00
Hans Wennborg 3d79154aec [Win32 ABI] Defer operator delete checks until vtable is marked used
We were previously checking at every destructor declaration, but that was a bit
excessive. Since the deleting destructor is emitted with the vtable, do the
check when the vtable is marked used.

Differential Revision: http://llvm-reviews.chandlerc.com/D2851

llvm-svn: 202046
2014-02-24 15:58:24 +00:00
Rafael Espindola 04a13befd8 Don't assume that F_None is the default. It is about to change.
llvm-svn: 202040
2014-02-24 15:06:52 +00:00
Alp Toker 7d2fea2fd6 Use a more conventional logical op instead of bitwise and
llvm-svn: 202006
2014-02-24 04:35:58 +00:00
Kevin Qin ad64f6d4e5 [AArch64] Change int64_t from 'long long int' to 'long int' for AArch64 target.
Most 64-bit targets define int64_t as long int, and AArch64 should
make same definition to follow LP64 model. In GNU tool chain, int64_t
is defined as long int for 64-bit target. So to get consistent with GNU,
it's better Changing int64_t from 'long long int' to 'long int',
otherwise clang will get different name mangling suffix compared with g++.

llvm-svn: 202004
2014-02-24 02:45:03 +00:00
Richard Smith 51bacfd9c7 Update __cplusplus to match the value in the C++14 DIS preview (D3937).
llvm-svn: 202003
2014-02-24 01:35:45 +00:00
Bob Wilson 8ab1691091 Do not put instrumentation counters before phis in ObjC for-in loops.
We still don't use the PGO to set branch weights for these loops, but at
least this keeps the compiler from crashing. <rdar://problem/16137778>

llvm-svn: 202002
2014-02-24 01:13:09 +00:00
Argyrios Kyrtzidis d3ba410356 [Index] Make the USRs more stable.
- Only include offsets with local (in function scope) symbols, where we don't encode scoping
- Only include the filename with non-system symbols. Presumably the system headers will not provide conflicting definitions.

rdar://15976823

llvm-svn: 201990
2014-02-23 18:23:29 +00:00
Benjamin Kramer ae852a68fe Sema: Simplify away one-iteration loops.
No functionality change.

llvm-svn: 201981
2014-02-23 14:34:50 +00:00
NAKAMURA Takumi e842e4b2f1 [CMake] Resurrect mis-dropped dependency to ClangDriverOptions since r201842.
llvm-svn: 201978
2014-02-23 13:44:09 +00:00
Alp Toker f2b6e79393 Fix crash when both ExpectAndConsume and ConsumeAnyToken emit diagnostics
The DiagnosticBuilder's lifetime in parser typo recovery was overlapping with
the subsequent consume which can itself emit PP diagnostics.

Patch by Olivier Goffart!

llvm-svn: 201965
2014-02-23 03:45:03 +00:00
Saleem Abdulrasool cfeb90d7a8 clang: add -f{no-,}integrate-as as consistent parameters
The integrated assembler is a feature.  This makes the new flags the default
option, and the previous versions aliases.  Ideally, at some point the aliases
would be entirely removed.

llvm-svn: 201963
2014-02-23 00:40:30 +00:00
Saleem Abdulrasool 42e4b5997a clang: forward -no-integrated-as from the driver
Forward the -no-integrated-as option to -cc1 rather than simply invoking the
appropriate tool.  This is useful since this option has been overloaded to
permit disabling of parsing inline assembly at the MC layer.

This re-applies the previous version of the patch with a renaming of the driver
option to the public name rather than the internal name (-target vs -triple).
The actual failure is fixed separately of an overly aggressive negative pattern
match in the MIPS driver tests.  It also fixes the incorrect test for targets
that have the integrated assembler disabled by default.

llvm-svn: 201960
2014-02-22 23:37:58 +00:00
Saleem Abdulrasool 59106827c4 Revert "clang: forward -no-integrated-as from the driver"
This seems to break a MIPS test.  Revert until I figure out the root cause.

llvm-svn: 201954
2014-02-22 22:24:00 +00:00
Saleem Abdulrasool 87a7fda237 clang: forward -no-integrated-as from the driver
Forward the -no-integrated-as option to -cc1 rather than simply invoking the
appropriate tool.  This is useful since this option has been overloaded to
permit disabling of parsing inline assembly at the MC layer.

llvm-svn: 201952
2014-02-22 21:50:09 +00:00
Nico Rieck 6047866232 Reorganize and improve semantic tests for dllexport/import
llvm-svn: 201947
2014-02-22 19:47:30 +00:00
Aaron Ballman 7c19ab17c7 Exposing the noduplicate attribute within Clang, which marks functions so that the optimizer does not duplicate code.
Patch thanks to Marcello Maggioni!

llvm-svn: 201941
2014-02-22 16:59:24 +00:00
Peter Collingbourne fa1d4e1067 Do not add enums to prototype scope in C++ modes.
The language forbids defining enums in prototypes, so this check is normally
redundant, but if an enum is defined during template instantiation it should
not be added to the prototype scope.

While at it, clean up the code that deals with tag definitions in prototype
scope and expand the visibility warning to cover the case where an anonymous
enum is defined.

Differential Revision: http://llvm-reviews.chandlerc.com/D2742

llvm-svn: 201927
2014-02-22 03:05:49 +00:00
Peter Collingbourne b8d17e7a3b Correctly set brace range for CXXConstructExprs formed by list initialization.
Differential Revision: http://llvm-reviews.chandlerc.com/D2711

llvm-svn: 201926
2014-02-22 02:59:41 +00:00
Ted Kremenek 438f8db6d5 Per feedback from Aaron Ballman, push cast-to-ObjCProtocolDecl inside handleObjCSuppresProtocolAttr().
llvm-svn: 201922
2014-02-22 01:06:05 +00:00
Warren Hunt 0dc28ea301 [_mm_prefetch] Returning previously deleted comment.
No functional change.  It's unclear if the word FIXME is relevant given 
that the macro behaves as intended.

llvm-svn: 201920
2014-02-22 00:47:24 +00:00
Ben Langmuir 090995122d Silence a warning from r201905
Avoid a warning about reaching the end of a non-void function after a
covered switch.

llvm-svn: 201919
2014-02-22 00:44:02 +00:00
David Majnemer 7a72601099 IRGen: Fix build breakage
MSVC allows extra-qualification on member functions, it lets you repeat
the class name on the method.

llvm-svn: 201918
2014-02-22 00:41:07 +00:00
Warren Hunt c85942038a [MS-ABI] Fix MSRecordLayout to handel MultiDimensionalArrays
A recent change caused multi-dimensional arrays not to be handled 
correctly, this patch fixes that.  Also, it adds a lit test for 
multi-dimensional arrays.

llvm-svn: 201917
2014-02-22 00:40:37 +00:00
Warren Hunt 0afa2d2f2b Fix two warnings introduced r201907
Unused variable is removed.  Construction order is changed to match 
declaration order.

llvm-svn: 201914
2014-02-22 00:22:15 +00:00
David Majnemer a64cb5a019 Sema: Don't crash when trying to instantiate a local class with an invalid base specifier
It was previously thought that Sema::InstantiateClass could not fail
from within this point in instantiate.

However, it can happen if the class is invalid some way (i.e. invalid
base specifier).

This fixes PR18907.

Differential Revision: http://llvm-reviews.chandlerc.com/D2850

llvm-svn: 201913
2014-02-22 00:17:46 +00:00
Ted Kremenek 204c3c50b9 [ObjC] Make attribute 'objc_protocol_requires_explicit_implementation' behave correctly with default property synthesis.
In particular, if we see an @property within the @interface of a class
conforming to a protocol with this attribute, we treat that as
if the implementation were available, per the rules of default
property synthesis.

llvm-svn: 201911
2014-02-22 00:02:03 +00:00
Warren Hunt fb00c88703 Complete Rewrite of CGRecordLayoutBuilder
CGRecordLayoutBuilder was aging, complex, multi-pass, and shows signs of 
existing before ASTRecordLayoutBuilder.  It redundantly performed many 
layout operations that are now performed by ASTRecordLayoutBuilder and 
asserted that the results were the same.  With the addition of support 
for the MS-ABI, such as placement of vbptrs, vtordisps, different 
bitfield layout and a variety of other features, CGRecordLayoutBuilder 
was growing unwieldy in its redundancy.

This patch re-architects CGRecordLayoutBuilder to not perform any 
redundant layout but rather, as directly as possible, lower an 
ASTRecordLayout to an llvm::type.  The new architecture is significantly 
smaller and simpler than the CGRecordLayoutBuilder and contains fewer 
ABI-specific code paths.  It's also one pass.

The architecture of the new system is described in the comments. For the 
most part, the new system simply takes all of the fields and bases from 
an ASTRecordLayout, sorts them, inserts padding and dumps a record. 
Bitfields, unions and primary virtual bases make this process a bit more 
complicated.  See the inline comments.

In addition, this patch updates a few lit tests due to the fact that the 
new system computes more accurate llvm types than CGRecordLayoutBuilder. 
Each change is commented individually in the review.

Differential Revision: http://llvm-reviews.chandlerc.com/D2795

llvm-svn: 201907
2014-02-21 23:49:50 +00:00
Ben Langmuir d51ba0b39f Add a VFSFromYAML class and a parser to create it
Provides a way to create a virtual file system using a YAML file that
supports mapping a file to a path on an 'external' file system. The
external file system will typically be the 'real' file system, but for
testing it can be changed.

A future patch will add a clang option to allow the user to specify such
a file and overlay it, but for now this code is only exercised by the
unit tests.

Differential Revision: http://llvm-reviews.chandlerc.com/D2835

llvm-svn: 201905
2014-02-21 23:39:37 +00:00
Warren Hunt 20e4a5d2af Reapply 201734 but with appropriate gcc compatibility
Because GCC incorrectly defines _mm_prefetch to take anything that casts 
to void*, people have started using that behavior.  The previous patch 
that made _mm_prefetch actually take a const char * broke compatibility 
with existing code.  This update to the patch leaves the macro that 
defines _mm_prefetch with the (void*) cast when _MSC_VER is not defined.

llvm-svn: 201901
2014-02-21 23:08:53 +00:00
Ted Kremenek 27cfe10df8 Add requirement that attribute 'objc_protocol_requires_explicit_implementation' can only be applied to protocol definitions.
llvm-svn: 201899
2014-02-21 22:49:04 +00:00
Joerg Sonnenberger 695fdb3bc2 Default to ARMv5e for NetBSD/EABI, ARMv4 for APCS.
llvm-svn: 201894
2014-02-21 21:53:33 +00:00
Aaron Ballman 9e9d184133 Adding role-based capability attributes that allow you to express role management: asserting a capability is held, acquiring a capability and releasing a capability. Also includes some skeleton documentation for these new attributes.
This functionality should be considered a WIP.

llvm-svn: 201890
2014-02-21 21:05:14 +00:00
Ted Kremenek 38882022af [ObjC] add support for properties in attribute 'objc_protocol_requires_explicit_implementation'.
llvm-svn: 201880
2014-02-21 19:41:39 +00:00