Commit Graph

3372 Commits

Author SHA1 Message Date
Richard Smith 4caa449ade Refactor: when exposing a definition in some module, provide listeners with the
module rather than requiring them to work it out themselves.

llvm-svn: 237416
2015-05-15 02:34:32 +00:00
Pirama Arumuga Nainar e9bcddd5cb Add flag to enable native half type
Summary:
r235215 enables support in LLVM for legalizing f16 type in the IR.  AArch64
already had support for this.  r235215 and some backend patches brought support
for ARM, X86, X86-64, Mips and Mips64.

This change exposes the LangOption 'NativeHalfType' in the command line, so the
backend legalization can be used if desired.  NativeHalfType is enabled for
OpenCL (current behavior) or if '-fnative-half-type' is set.

Reviewers: olista01, steven_wu, ab

Subscribers: cfe-commits, srhines, aemerson

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

llvm-svn: 237406
2015-05-14 23:44:18 +00:00
Paul Robinson fcdf3e9fe7 Break \# in a depfile the same way as gcc.
Backslash followed by # in a filename should have both characters
escaped, if you do it the way GNU Make wants.  GCC doesn't, so we do
it the way GCC does rather than the way GNU Make wants.

llvm-svn: 237304
2015-05-13 22:33:50 +00:00
Peter Collingbourne 470d94247d Make GNUInline consistent with whether we use traditional GNU inline semantics.
Previously we were setting LangOptions::GNUInline (which controls whether we
use traditional GNU inline semantics) if the language did not have the C99
feature flag set. The trouble with this is that C++ family languages also
do not have that flag set, so we ended up setting this flag in C++ modes
(and working around it in a few places downstream by also checking CPlusPlus).

The fix is to check whether the C89 flag is set for the target language,
rather than whether the C99 flag is cleared. This also lets us remove most
CPlusPlus checks. We continue to test CPlusPlus when deciding whether to
pre-define the __GNUC_GNU_INLINE__ macro for consistency with GCC.

There is a change in semantics in two other places
where we weren't checking both CPlusPlus and GNUInline
(FunctionDecl::doesDeclarationForceExternallyVisibleDefinition and
FunctionDecl::isInlineDefinitionExternallyVisible), but this change seems to
put us back into line with GCC's semantics (test case: test/CodeGen/inline.c).

While at it, forbid -fgnu89-inline in C++ modes, as GCC doesn't support it,
it didn't have any effect before, and supporting it just makes things more
complicated.

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

llvm-svn: 237299
2015-05-13 22:07:22 +00:00
Paul Robinson 64441def58 Fix dependency file escaping.
When writing a dependency (.d) file, if space or # is immediately
preceded by one or more backslashes, escape the backslashes as well as
the space or # character. Otherwise leave backslash alone.
This straddles the fence between BSD Make (which does no escaping at
all, and does not support space or # in filespecs) and GNU Make (which
does support escaping, but will fall back to the filespec as-written
if the escaping doesn't match an existing file).

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

llvm-svn: 237296
2015-05-13 21:18:15 +00:00
Nikola Smiljanic fb891fcef6 Fix misleading parameter name for PPCallbacks::FileSkipped.
Patch thanks to Vladimir Voskresensky.

llvm-svn: 237115
2015-05-12 11:48:05 +00:00
Peter Collingbourne bf59c34bfd Move sanitizer parser and group expander from Driver to Basic.
No functional change.

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

llvm-svn: 237056
2015-05-11 21:39:20 +00:00
Peter Collingbourne 3eea677f3a Unify sanitizer kind representation between the driver and the rest of the compiler.
No functional change.

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

llvm-svn: 237055
2015-05-11 21:39:14 +00:00
Daniel Marjamaki ecb0e1bc60 Refactor MacroInfo so range for loops can be used to iterate its tokens.
Differential Revision: http://reviews.llvm.org/D9079

llvm-svn: 236975
2015-05-11 08:25:54 +00:00
David Majnemer b710a938d6 Give isCompatibleWithMSVC a better interface
We now use an enum which maps the marketing name (almost always a year)
to the major version number.

llvm-svn: 236967
2015-05-11 03:57:49 +00:00
Artem Belevich 52cc487ba8 [cuda] Include GPU binary into host object file and generate init/deinit code.
- added -fcuda-include-gpubinary option to incorporate results of
  device-side compilation into host-side one.
- generate code to register GPU binaries and associated kernels
  with CUDA runtime and clean-up on exit.
- added test case for init/deinit code generation.

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

llvm-svn: 236765
2015-05-07 19:34:16 +00:00
Alexey Samsonov 3f3b3abe2b [SanitizerCoverage] Give clang-cc1 the power to precisly specify needed sanitizier coverage mode.
Summary:
The next step is to add user-friendly control over these options
to driver via -fsanitize-coverage= option.

Test Plan: regression test suite

Reviewers: kcc

Subscribers: cfe-commits

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

llvm-svn: 236756
2015-05-07 18:31:29 +00:00
Duncan P. N. Exon Smith 4a8212a488 Reapply "Frontend: Stop leaking when not -disable-free"
This reverts commit r236422, effectively reapplying r236419.  ASan
helped me diagnose the problem: the non-leaking logic would free the
ASTConsumer before freeing Sema whenever `isCurrentASTFile()`, causing a
use-after-free in `Sema::~Sema()`.

This version unconditionally frees Sema and the ASTContext before
freeing the ASTConsumer.  Without the fix, these were either being freed
before the ASTConsumer was freed or leaked after, but they were always
spiritually released so this isn't really a functionality change.

I ran all of check-clang with ASan locally this time, so I'm hoping
there aren't any more problems lurking.

Original commit message:

    Try again to plug a leak that's been around since at least r128011
    after coming across the FIXME.  Nico Weber tried something similar
    in r207065 but had to revert in r207070 due to a bot failure.

    The build failure isn't visible anymore so I'm not sure what went
    wrong.  I'm doing this slightly differently -- when not
    -disable-free I'm still resetting the members (just not leaking
    them) -- so maybe it will work out this time?  Tests pass locally,
    anyway.

llvm-svn: 236424
2015-05-04 14:59:20 +00:00
Duncan P. N. Exon Smith 20f0b01a92 Revert "Frontend: Stop leaking when not -disable-free"
This reverts commit r236419, since it caused some bots to fail.  On:

http://lab.llvm.org:8011/builders/clang-hexagon-elf/builds/26124
http://bb.pgr.jp/builders/cmake-clang-x86_64-linux/builds/35086

these tests:

FAIL: Clang::import-decl.cpp
FAIL: Clang::floating-literal.c
FAIL: Clang::x86_64-linux-android.c

fail with this output:

Command Output (stderr):
--
Stack dump:
0.  Program arguments: /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.obj/Release+Asserts/bin/clang -cc1 -internal-isystem /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.obj/Release+Asserts/bin/../lib/clang/3.7.0/include -nostdsysteminc -ast-print -x ast -
/var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.obj/tools/clang/test/Modules/Output/import-decl.cpp.script: line 3:  9665 Segmentation fault      (core dumped) /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.obj/Release+Asserts/bin/clang -cc1 -internal-isystem /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.obj/Release+Asserts/bin/../lib/clang/3.7.0/include -nostdsysteminc -ast-print -x ast - < /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.obj/tools/clang/test/Modules/Output/import-decl.cpp.tmp.ast
      9666 Done                    | /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.obj/Release+Asserts/bin/FileCheck /var/lib/buildbot/slaves/hexagon-build-03/clang-hexagon-elf/llvm.src/tools/clang/test/Modules/import-decl.cpp

--

llvm-svn: 236422
2015-05-04 13:01:42 +00:00
Duncan P. N. Exon Smith fa4de125c9 Frontend: Stop leaking when not -disable-free
Try again to plug a leak that's been around since at least r128011 after
coming across the FIXME.  Nico Weber tried something similar in r207065
but had to revert in r207070 due to a bot failure.

The build failure isn't visible anymore so I'm not sure what went wrong.
I'm doing this slightly differently -- when not -disable-free I'm still
resetting the members (just not leaking them) -- so maybe it will work
out this time?  Tests pass locally, anyway.

llvm-svn: 236419
2015-05-04 12:36:56 +00:00
Richard Smith 36bd40df72 Switch PPCallbacks to take the new MacroDefinition instead of MacroDirective*, in order to preserve full information on module macro expansion.
llvm-svn: 236404
2015-05-04 03:15:40 +00:00
Richard Smith 66a8186ed4 Rename MacroDefinition -> MacroDefinitionRecord, Preprocessor::MacroDefinition -> MacroDefinition.
clang::MacroDefinition now models the currently-defined value of a macro. The
previous MacroDefinition type, which represented a record of a macro definition
directive for a detailed preprocessing record, is now called MacroDefinitionRecord.

llvm-svn: 236400
2015-05-04 02:25:31 +00:00
Richard Smith ee977933f7 [modules] Add -fmodules-local-submodule-visibility flag.
This flag specifies that the normal visibility rules should be used even for
local submodules (submodules of the currently-being-built module). Thus names
will only be visible if a header / module that declares them has actually been
included / imported, and not merely because a submodule that happened to be
built earlier declared those names. This also removes the need to modularize
bottom-up: textually-included headers will be included into every submodule
that includes them, since their include guards will not leak between modules.

So far, this only governs visibility of macros, not of declarations, so is not
ready for real use yet.

llvm-svn: 236350
2015-05-01 21:22:17 +00:00
Yunzhong Gao eba323ab44 Fix a few line endings. NFC.
llvm-svn: 236301
2015-05-01 02:04:32 +00:00
Richard Smith a7e2cc684f [modules] Start moving the module visibility information off the Module itself.
It has no place there; it's not a property of the Module, and it makes
restoring the visibility set when we leave a submodule more difficult.

llvm-svn: 236300
2015-05-01 01:53:09 +00:00
Justin Bogner a71e681792 InstrProf: Support for setting profile output from command line
This change is the third of 3 patches to add support for specifying
the profile output from the command line via -fprofile-instr-generate=<path>,
where the specified output path/file will be overridden by the
LLVM_PROFILE_FILE environment variable.

This patch adds the necessary support to the clang frontend, and adds a
new test.

The compiler-rt and llvm parts are r236055 and r236288, respectively.

Patch by Teresa Johnson. Thanks!

llvm-svn: 236289
2015-04-30 23:49:42 +00:00
Richard Smith 20e883e59b [modules] Stop trying to fake up a linear MacroDirective history.
Modules builds fundamentally have a non-linear macro history. In the interest
of better source fidelity, represent the macro definition information
faithfully: we have a linear macro directive history within each module, and at
any point we have a unique "latest" local macro directive and a collection of
visible imported directives. This also removes the attendent complexity of
attempting to create a correct MacroDirective history (which we got wrong
in the general case).

No functionality change intended.

llvm-svn: 236176
2015-04-29 23:20:19 +00:00
Sean Callanan 61ea0571ac Implemented support for testing the ASTImporter's
ability to generate code that CodeGen likes.  Test
cases can use this functionality by calling

// RUN: %clang_cc1 -emit-obj -o /dev/null -ast-merge %t.1.ast -ast-merge %t.2.ast %s

llvm-svn: 236011
2015-04-28 18:24:12 +00:00
Paul Robinson d7214a7651 Support generating NMake/Jom-style depfiles.
NMake is a Make-like builder that comes with Microsoft Visual Studio.
Jom (https://wiki.qt.io/Jom) is an NMake-compatible build tool.
Dependency files for NMake/Jom need to use double-quotes to wrap
filespecs containing special characters, instead of the backslash
escapes that GNU Make wants.

Adds the -MV option, which specifies to use double-quotes as needed
instead of backslash escapes when writing the dependency file.

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

llvm-svn: 235903
2015-04-27 18:14:32 +00:00
Richard Smith b8b2ed6529 [modules] Determine the set of macros exported by a submodule at the end of that submodule.
Previously we'd defer this determination until writing the AST, which doesn't
allow us to use this information when building other submodules of the same
module. This change also allows us to use a uniform mechanism for writing
module macro records, independent of whether they are local or imported.

llvm-svn: 235614
2015-04-23 18:18:26 +00:00
Eli Bendersky 4bdc50eccb Create a frontend flag to disable CUDA cross-target call checks
For CUDA source, Sema checks that the targets of call expressions make sense
(e.g. a host function can't call a device function).

Adding a flag that lets us skip this check. Motivation: for source-to-source
translation tools that have to accept code that's not strictly kosher CUDA but
is still accepted by nvcc. The source-to-source translation tool can then fix
the code and leave calls that are semantically valid for the actual compilation
stage.

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

llvm-svn: 235049
2015-04-15 22:27:06 +00:00
Duncan P. N. Exon Smith bb61825cd5 uselistorder: -mllvm -preserve-bc-use-list-order => -emit-llvm-uselists
Stop relying on `cl::opt` to pass along the driver's decision to
preserve use-lists.  Create a new `-cc1` option called
`-emit-llvm-uselists` that does the right thing (when -emit-llvm-bc).
Note that despite its generic name, it *doesn't* do the right thing when
-emit-llvm (LLVM assembly) yet.  I'll hook that up soon.

This doesn't really change the behaviour of the driver.  The default is
still to preserve use-lists for `clang -emit-llvm` and `clang
-save-temps`, and nothing else.  But it stops relying on global state
(and also is a nicer interface for hackers using `clang -cc1`).

llvm-svn: 234962
2015-04-15 01:16:18 +00:00
Rafael Espindola 2f16bc1095 Use raw_pwrite_stream in clang.
This is a small improvement to -emit-pth and allows llvm to start requiring it.

llvm-svn: 234897
2015-04-14 15:15:49 +00:00
Rafael Espindola 463d4dd6c6 Bring r234620 back now that llvm is fixed.
LLVM can now detect if a fd is seekable on windows.

Original commit message:

Actually check if lseek works instead of using a filename based heuristic.

llvm-svn: 234738
2015-04-13 11:14:39 +00:00
NAKAMURA Takumi 5594d7926d Reformat.
llvm-svn: 234731
2015-04-13 08:43:40 +00:00
NAKAMURA Takumi 90a4877e31 Revert r234620 and others, "Actually check if lseek works instead of using a filename based heuristic." It was affected by r234615, which was reverted in r234721.
r234620, "Actually check if lseek works instead of using a filename based heuristic."
  r234621, "Testcase for the previous commit."
  r234718, "Suppress clang/test/PCH/emit-pth.c on win32, for now while investigating."

llvm-svn: 234730
2015-04-13 08:43:31 +00:00
Alexander Kornienko 34eb20725d Use 'override/final' instead of 'virtual' for overridden methods
Summary:
The patch is generated using clang-tidy misc-use-override check.

This command was used:

  tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py \
    -checks='-*,misc-use-override' -header-filter='llvm|clang' -j=32 -fix

Reviewers: dblaikie

Reviewed By: dblaikie

Subscribers: klimek, cfe-commits

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

llvm-svn: 234678
2015-04-11 02:00:23 +00:00
Ahmed Bougacha 256a869d31 [Driver] Properly support -mglobal-merge using explicit options.
Follow-up to r234666.  With this, the -m[no-]global-merge options
have the expected behavior. Previously, -mglobal-merge was ignored,
and there was no way of enabling the optimization.

llvm-svn: 234668
2015-04-11 00:10:44 +00:00
Rafael Espindola d7e306fbcc Actually check if lseek works instead of using a filename based heuristic.
llvm-svn: 234620
2015-04-10 18:16:30 +00:00
Reid Kleckner 0aa128e219 [Frontend] Close open file handles before renaming output files
The placement of the 'delete' call that was removed in the unique_ptr
migration in r234597 was not an accident. The raw_ostream has to be
destroyed before you do the rename on Windows, otherwise you get
ERROR_ACCESS_DENIED. We can still use unique_ptr, we just need to do a
manual reset().

Also, range-for-loop-ify this code.

llvm-svn: 234612
2015-04-10 17:27:58 +00:00
Rafael Espindola c80a40661c Return std::unique_ptr to avoid a release and recreate.
llvm-svn: 234598
2015-04-10 14:30:43 +00:00
Rafael Espindola 269ec0f470 Use a std::unique_ptr to make it easier to see who owns the stream.
llvm-svn: 234597
2015-04-10 14:11:52 +00:00
Rafael Espindola bfd25d4d8a Return a pointer instead of having a pointer outparam and a bool return.
llvm-svn: 234592
2015-04-10 13:14:31 +00:00
Rafael Espindola 47de149565 Return a pointer instead of having a pointer outparam and a bool return.
llvm-svn: 234590
2015-04-10 12:54:53 +00:00
Fariborz Jahanian f8e68e230b [Objective-C modern translation]. Patch to fix type of
objc_msgSend's first argument to "Class" because
objc_getClass is passed. rdar://20477025

llvm-svn: 234520
2015-04-09 18:36:50 +00:00
Sanjay Patel 359b105745 Process the -freciprocal-math optimization flag (PR20912)
The driver currently accepts but ignores the -freciprocal-math flag.
This patch passes the flag through and enables 'arcp' fast-math-flag
generation in IR.

Note that this change does not actually enable the optimization for
any target. The reassociation optimization that this flag specifies
was implemented by http://reviews.llvm.org/D6334 :
http://llvm.org/viewvc/llvm-project?view=revision&revision=222510

Because the optimization is done in the backend rather than IR,
the backend must be modified to understand instruction-level
fast-math-flags or a new function-level attribute must be created.

Also note that -freciprocal-math is independent of any target-specific
usage of reciprocal estimate hardware instructions. That requires
its own flag ('-mrecip').

https://llvm.org/bugs/show_bug.cgi?id=20912

llvm-svn: 234493
2015-04-09 15:03:23 +00:00
Derek Schuff 6ab52fabcf Add driver support for Native Client SDK
Add Tool and ToolChain support for clang to target the NaCl OS using the NaCl
SDK for x86-32, x86-64 and ARM.

Includes nacltools::Assemble and Link which are derived from gnutools. They
are similar to Linux but different enought that they warrant their own class.
Also includes a NaCl_TC in ToolChains derived from Generic_ELF with library
and include paths suitable for an SDK and independent of the system tools.

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

llvm-svn: 233594
2015-03-30 20:31:33 +00:00
Chandler Carruth ff8d943cb8 [Modules] Don't compute a modules cache path if we're not using modules!
Notably, this prevents us from doing *tons* of work to compute the
modules hash, including trying to read a darwin specific plist file off
of the system. There is a lot that needs cleaning up below this layer
too.

llvm-svn: 233462
2015-03-28 01:10:44 +00:00
Richard Smith 65ebb4ac8a [modules] If we reach a definition of a class for which we already have a
non-visible definition, skip the new definition and make the old one visible
instead of trying to parse it again and failing horribly. C++'s ODR allows
us to assume that the two definitions are identical.

llvm-svn: 233250
2015-03-26 04:09:53 +00:00
Chandler Carruth 580dd296fa [Modules] Stop creating timestamps for the modules cache and trying to
prune it when we have disabled implicit module generation and thus are
not using any cached modules.

Also update a test of explicitly generated modules to pass this CC1 flag
correctly.

This fixes an issue where Clang was dropping files into the source tree
while running its tests.

llvm-svn: 233117
2015-03-24 21:44:25 +00:00
Aaron Ballman f4cb2be05a Track the source location of the dot or arrow operator in a MemberExpr.
Patch by Joe Ranieri!

llvm-svn: 233085
2015-03-24 15:07:53 +00:00
Richard Smith c2bb81860b [modules] Deserialize CXXCtorInitializer list for a constructor lazily.
Previously we'd deserialize the list of mem-initializers for a constructor when
we deserialized the declaration of the constructor. That could trigger a
significant amount of unnecessary work (pulling in all base classes
recursively, for a start) and was causing problems for the modules buildbot due
to cyclic deserializations. We now deserialize these on demand.

This creates a certain amount of duplication with the handling of
CXXBaseSpecifiers; I'll look into reducing that next.

llvm-svn: 233052
2015-03-24 06:36:48 +00:00
David Majnemer c371ff048d MS ABI: Implement driver-level support for thread-safe statics
Decide whether or not to use thread-safe statics depending on whether or
not we have an explicit request from the driver.  If we don't have an
explicit request, infer which behavior to use depending on the
compatibility version we are targeting.

N.B. CodeGen support is still ongoing.

llvm-svn: 232906
2015-03-22 08:39:22 +00:00
Reid Kleckner 7ffc3fbb2f C++14: Disable sized deallocation by default due to ABI breakage
There are no widely deployed standard libraries providing sized
deallocation functions, so we have to punt and ask the user if they want
us to use sized deallocation. In the future, when such libraries are
deployed, we can teach the driver to detect them and enable this
feature.

N3536 claimed that a weak thunk from sized to unsized deallocation could
be emitted to avoid breaking backwards compatibility with standard
libraries not providing sized deallocation. However, this approach and
other variations don't work in practice.

With the weak function approach, the thunk has to have default
visibility in order to ensure that it is overridden by other DSOs
providing sized deallocation. Weak, default visibility symbols are
particularly expensive on MachO, so John McCall was considering
disabling this feature by default on Darwin. It also changes behavior
ELF linking behavior, causing certain otherwise unreferenced object
files from an archive to be pulled into the link.

Our second approach was to use an extern_weak function declaration and
do an inline conditional branch at the deletion call site. This doesn't
work because extern_weak only works on MachO if you have some archive
providing the default value of the extern_weak symbol. Arranging to
provide such an archive has the same challenges as providing the symbol
in the standard library. Not to mention that extern_weak doesn't really
work on COFF.

Reviewers: rsmith, rjmccall

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

llvm-svn: 232788
2015-03-20 00:31:07 +00:00
Artem Belevich f3d3db65de Remove .CUDAIsDevice flags from CodeGenOpts as it's already
available in LangOpts.

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

llvm-svn: 232749
2015-03-19 18:58:18 +00:00
Artem Belevich 83a6dcc470 Ensure that we still parse preprocessed CUDA files as CUDA when we use
-save-temps option.

Summary: Fixes PR22926.

Review: http://reviews.llvm.org/D8383
llvm-svn: 232737
2015-03-19 17:32:06 +00:00
Yaron Keren 92e1b62d45 Remove many superfluous SmallString::str() calls.
Now that SmallString is a first-class citizen, most SmallString::str()
calls are not required. This patch removes a whole bunch of them, yet
there are lots more.

There are two use cases where str() is really needed:
1) To use one of StringRef member functions which is not available in
SmallString.
2) To convert to std::string, as StringRef implicitly converts while 
SmallString do not. We may wish to change this, but it may introduce
ambiguity.

llvm-svn: 232622
2015-03-18 10:17:07 +00:00
Richard Smith 7f330cdb31 Make module files passed to a module build via -fmodule-file= available to
consumers of that module.

Previously, such a file would only be available if the module happened to
actually import something from that module.

llvm-svn: 232583
2015-03-18 01:42:29 +00:00
Michael Zolotukhin c888dd0cb8 Add fveclib option.
Review: http://reviews.llvm.org/D8097
llvm-svn: 232533
2015-03-17 20:03:11 +00:00
Justin Bogner 4e46237c6d GCOV: Expose the -coverage-exit-block-before-body flag in clang -cc1
This exposes the optional exit block placement logic from r232438 as a
clang -cc1 option. There is a test on the llvm side, but there isn't
really a way to inspect the gcov options from clang to test it here as
well.

llvm-svn: 232439
2015-03-16 23:52:21 +00:00
Chandler Carruth 0d745bcf66 [modules] Teach the AST reader to handle the case of importing a module
with a subset of the existing target CPU features or mismatched CPU
names.

While we can't check that the CPU name used to build the module will end
up being able to codegen correctly for the translation unit, we actually
check that the imported features are a subset of the existing features.

While here, rewrite the code to use std::set_difference and have it
diagnose all of the differences found.

Test case added which walks the set relationships and ensures we
diagnose all the right cases and accept the others.

No functional change for implicit modules here, just better diagnostics.

llvm-svn: 232248
2015-03-14 04:47:43 +00:00
Ed Schouten 2b60d1eee5 Fix up default header paths for CloudABI.
CloudABI is a pure cross compilation target. This means that we should
not add /usr/include and /usr/local/include. Instead, headers are stored
in $sysroot/$triple/include.

The method of going back to the sysroot (by using "../../..") is also
used in this function for some of the other environments (e.g., MinGW).

llvm-svn: 231913
2015-03-11 08:46:01 +00:00
Richard Smith f81340096d [modules] Don't clobber a destructor's operator delete when adding another one;
move the operator delete updating into a separate update record so we can cope
with updating another module's destructor's operator delete.

llvm-svn: 231735
2015-03-10 01:41:22 +00:00
Argyrios Kyrtzidis f0b4cd1ed3 [ASTUnit] Fix crash when trying to load a module file via ASTUnit::LoadFromASTFile.
rdar://19997358

llvm-svn: 231060
2015-03-03 08:04:19 +00:00
Bob Wilson b111ec94b3 Add clang support for Objective-C application extensions.
This adds the -fapplication-extension option, along with the
ios_app_extension and macosx_app_extension availability attributes.
Patch by Ted Kremenek

llvm-svn: 230989
2015-03-02 19:01:14 +00:00
Benjamin Kramer 33335df819 Add missing include.
llvm-svn: 230910
2015-03-01 21:36:40 +00:00
Richard Smith 37bd29a5e6 Give better diagnostics when -fmodule-file= finds a bad file: if the file is
found indirectly, explain how we got there, and distinguish between 'file not
found' and 'file found but invalid'.

llvm-svn: 230839
2015-02-28 03:09:52 +00:00
Eric Christopher 8213f7f87d Fix a [-Werror,-Wreorder] initialization ordering error.
llvm-svn: 230589
2015-02-26 00:29:54 +00:00
Reid Kleckner 1df0fea593 Add -fuse-line-directive flag to control usage of #line with -E
Currently -fms-extensions controls this behavior, which doesn't make
much sense. It means we can't identify what is and isn't a system header
when compiling our own preprocessed output, because #line doesn't
represent this information.

If someone is feeding Clang's preprocessed output to another compiler,
they can use this flag.

Fixes PR20553.

Reviewers: rsmith

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

llvm-svn: 230587
2015-02-26 00:17:25 +00:00
Richard Smith ebdfc00995 Remove some unused includes of llvm/IR headers from parts of Clang that really
shouldn't depend on LLVM IR.

llvm-svn: 230586
2015-02-26 00:01:03 +00:00
Richard Smith 8cebe37fe9 [modules] Even if we already have a definition of a class, loading in another
one can give us more lookup results (due to implicit special members). Be sure
to complete the redecl chain for every kind of DeclContext before performing a
lookup into it, rather than only doing so for NamespaceDecls.

llvm-svn: 230558
2015-02-25 22:20:13 +00:00
Adrian Prantl cbc368c5b5 Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."
llvm-svn: 230454
2015-02-25 02:44:04 +00:00
Adrian Prantl 8bf7af3de8 Wrap clang module files in a Mach-O, ELF, or COFF container.
This is a necessary prerequisite for debugging with modules.
The .pcm files become containers that hold the serialized AST which allows
us to store debug information in the module file that can be shared by all
object files that were built importing the module.

This reapplies r230044 with a fixed configure+make build and updated
dependencies and testcase requirements. Over the last iteration this
version adds
- missing target requirements for testcases that specify an x86 triple,
- a missing clangCodeGen.a dependency to libClang.a in the make build.

rdar://problem/19104245

llvm-svn: 230423
2015-02-25 01:31:45 +00:00
Richard Smith 5638c1146e [modules] Fix a bug that would result in a build with P paths through a module
graph with M modules to take O(P) time, not just O(M) time, when using explicit
module builds.

llvm-svn: 230412
2015-02-25 00:56:02 +00:00
Jacques Pienaar a50178c23e CUDA: Add option to allow host device functions to call host functions
Commiting code from review http://reviews.llvm.org/D7841

llvm-svn: 230385
2015-02-24 21:45:33 +00:00
Adrian Prantl a39924a1f8 Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."
This reverts commit r230305.
Off to fix another round of missing dependencies on various platforms.

llvm-svn: 230309
2015-02-24 05:14:17 +00:00
Adrian Prantl fc360dc30b Wrap clang module files in a Mach-O, ELF, or COFF container.
This is a necessary prerequisite for debugging with modules.
The .pcm files become containers that hold the serialized AST which allows
us to store debug information in the module file that can be shared by all
object files that were built importing the module.

rdar://problem/19104245

This reapplies r230044 with a fixed configure+make build and updated
dependencies. Take 3.

llvm-svn: 230305
2015-02-24 04:25:59 +00:00
Ed Schouten 4992099b42 Add C11 *_DECIMAL_DIG.
Before C11 there was only the DECIMAL_DIG definition. As of C11, we now
have one definition per floating point type (e.g. DBL_DECIMAL_DIG).
Change the existing code to define the new versions. To remain backward
compatible, define __DECIMAL_DIG__ as __LDBL_DECIMAL_DIG__.

Also update the tests. It seems that some of the existing test vectors
were incorrect. Change all tests for __DECIMAL_DIG__ to expect
__LDBL_DECIMAL_DIG__. Add tests for *_DECIMAL_DIG for FreeBSD/amd64, as
I happen to have such a system laying around. I've validated that the
values are in sync with <float.h>.

llvm-svn: 230207
2015-02-23 09:12:31 +00:00
Adrian Prantl 67fbfa3773 Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."
This reverts commit 230099.

The Linux configure+make build variant still needs some work.

llvm-svn: 230103
2015-02-21 00:29:14 +00:00
Adrian Prantl f2b0cd91eb Wrap clang module files in a Mach-O, ELF, or COFF container.
This is a necessary prerequisite for debugging with modules.
The .pcm files become containers that hold the serialized AST which allows
us to store debug information in the module file that can be shared by all
object files that were built importing the module.

rdar://problem/19104245

This reapplies r230044 with a fixed configure+make build and updated
dependencies. Take 2.

llvm-svn: 230089
2015-02-20 23:34:26 +00:00
Adrian Prantl 690b2f7746 Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."
This reverts commit r230067.

Investigating another batch of problems found by the bots.

llvm-svn: 230073
2015-02-20 22:12:19 +00:00
Adrian Prantl b59bc1a528 Wrap clang module files in a Mach-O, ELF, or COFF container.
This is a necessary prerequisite for debugging with modules.
The .pcm files become containers that hold the serialized AST which allows
us to store debug information in the module file that can be shared by all
object files that were built importing the module.

rdar://problem/19104245

This reapplies r230044 with a fixed configure+make build and updated
dependencies.

llvm-svn: 230067
2015-02-20 21:53:12 +00:00
Adrian Prantl a4f522fa19 Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."
This reverts commit r230044 while dealing with buildbot breakage.

Conflicts:
	test/Modules/module_container.m

llvm-svn: 230052
2015-02-20 20:00:27 +00:00
Adrian Prantl c4091aa74e Wrap clang module files in a Mach-O, ELF, or COFF container.
This is a necessary prerequisite for debugging with modules.
The .pcm files become containers that hold the serialized AST which allows
us to store debug information in the module file that can be shared by all
object files that were built importing the module.

rdar://problem/19104245

llvm-svn: 230044
2015-02-20 19:44:52 +00:00
Rafael Espindola 6b07a1c6ee Add -funique-section-names and -fno-unique-section-names options.
For now -funique-section-names is the default, so no change in default behavior.

The total .o size in a build of llvm and clang goes from 241687775 to 230649031
bytes if -fno-unique-section-names is used.

llvm-svn: 230031
2015-02-20 18:08:57 +00:00
Manuel Klimek d2e8b04d61 Add -fno-implicit-modules.
If this flag is set, we error out when a module build is required. This is
useful in environments where all required modules are passed via -fmodule-file.

llvm-svn: 230006
2015-02-20 11:44:41 +00:00
Larisse Voufo 89088232b2 Add -fno-sized-deallocation option for completeness of fix in r229241 in documentation in r229818.
llvm-svn: 229950
2015-02-20 02:07:22 +00:00
Ben Langmuir d89dc561c7 Revert "Mangle the IsSystem bit into the .pcm file name"
While I investigate some possible problems with this patch.

This reverts commit r228966

llvm-svn: 229910
2015-02-19 20:23:22 +00:00
Argyrios Kyrtzidis bd0b651bd2 [PCH/Modules] Check that the specific module cache path the PCH was built with, is the same as
the one in the current compiler invocation. If they differ reject the PCH.

This protects against the badness occurring from getting modules loaded from different module caches (see crashes).

rdar://19889860

llvm-svn: 229909
2015-02-19 20:12:20 +00:00
Ben Langmuir 07236733be Revert adding hostname to module hash
I didn't realize how easily the hostname could change - for example just
changing wireless networks seems to prompt it in some cases.

Users can always set their own local module cache path to avoid this.

This reverts commits r228592, 228594, 228601 and 228613.
rdar://19287368

llvm-svn: 229815
2015-02-19 04:03:57 +00:00
Larisse Voufo e990a3f60c Rename flags and options to match current naming: from -fdef-sized-delete to -fdefine-sized-deallocation, and from DefaultSizedDelete to DefineSizedDeallocation.
llvm-svn: 229597
2015-02-18 01:04:10 +00:00
Larisse Voufo 5526f4f094 Revise the implementation logic of sized deallocation: Do not automatically generate weak definitions of the sized operator delete (in terms of unsized operator delete). Instead, provide the funcitonality via a new compiler flag, -fdef-sized-delete.
The current implementation causes link-time ODR violations when the delete symbols are exported into the dynamic table.

llvm-svn: 229241
2015-02-14 05:42:57 +00:00
David Majnemer a5b195a1dc Revert "Revert r229082 for a bit, it caused PR22577."
This reverts commit r229123.  It was a red herring, the bug was present
without r229082.

llvm-svn: 229205
2015-02-14 01:35:12 +00:00
Nico Weber 7ce96b853d Revert r229082 for a bit, it caused PR22577.
llvm-svn: 229123
2015-02-13 16:27:00 +00:00
David Majnemer abc482effc MS ABI: Implement /volatile:ms
The /volatile:ms semantics turn volatile loads and stores into atomic
acquire and release operations.  This distinction is important because
volatile memory operations do not form a happens-before relationship
with non-atomic memory.  This means that a volatile store is not
sufficient for implementing a mutex unlock routine.

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

llvm-svn: 229082
2015-02-13 07:55:47 +00:00
Ben Langmuir 18dd78a8fd Mangle the IsSystem bit into the .pcm file name
When mangling the module map path into a .pcm file name, also mangle the
IsSystem bit, which can also depend on the header search paths. For
example, the user may change from -I to -isystem.  This can affect
diagnostics in the importing TU.

llvm-svn: 228966
2015-02-12 21:51:31 +00:00
Vasileios Kalintiris ea50312b84 [mips] Partially revert r223927: Removing __SIZEOF_INT128__ macro for MIPS64
Partially revert r223927 because LLVM gained support for 128-bit integers
in r227089. Modify and keep the tests that verify the definition of the
macro __SIZEOF_INT128__ for MIPS64 BE & LE in the preprocessor.

llvm-svn: 228918
2015-02-12 11:36:56 +00:00
Ben Langmuir 541c202be8 Be more conservative about gethostname()'s truncating behaviour
Don't assume it will provide an error or null-terminate the string on
truncation, since POSIX doesn't guarantee either behaviour (although
Linux and Darwin at least will do the 'right thing').

llvm-svn: 228613
2015-02-09 21:55:44 +00:00
Ben Langmuir 1daf480146 Diagnose timeouts in the LockFileManager and delete the dead lock file
If the lock file manager times out, we should give an error rather than
silently trying to load the existing module.  And delete the
(presumably) dead lock file, since it will otherwise prevent progress in
future invokations. This is unsound since we have no way to prove that
the lock file we are deleting is the same one we timed out on, but since
the lock is only to avoid excessive rebuilding anyway it should be okay.
Depends on llvm r228603.

llvm-svn: 228604
2015-02-09 20:35:13 +00:00
Ben Langmuir 9be5d1ece8 Update r228592 for when gethostname() returns an error
If gethostname() is not successful, just skip adding the hostname to the
module hash.  And don't bother setting hostname[255] = 0, since if
gethostname() is successful, it will be null-terminated already (and if
it's not successful we don't read the string now.

llvm-svn: 228601
2015-02-09 20:13:11 +00:00
Ben Langmuir 521954e813 Add missing include from r228592
llvm-svn: 228594
2015-02-09 19:30:29 +00:00
Ben Langmuir d072eea5d6 Add the hostname to the module hash to avoid sharing between hosts
Sharing between hosts will cause problems for the LockFileManager, which
can timeout waiting for a process that has already died.

llvm-svn: 228592
2015-02-09 19:23:08 +00:00
Benjamin Kramer a401b9b267 ASTUnit: Fix a name clash in GCC builds.
Should fix the build. Looks like GCC 4.9 is using different scoping rules for
range-based for loops.

llvm-svn: 228424
2015-02-06 18:58:04 +00:00
Benjamin Kramer 6a96ae5ecb ASTUnit: Use range-based for loops.
llvm-svn: 228420
2015-02-06 18:36:04 +00:00
Benjamin Kramer b4ef66832d Update APIs that return a pair of iterators to return an iterator_range instead.
Convert uses of those APIs into ranged for loops. NFC.

llvm-svn: 228404
2015-02-06 17:25:10 +00:00