Commit Graph

19 Commits

Author SHA1 Message Date
Alexandre Ganea 927ea8cf44 [Preamble] Fix incorrect usage of std::error_category
Differential Revision: https://reviews.llvm.org/D51380


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340929 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-29 14:28:04 +00:00
Haojian Wu 0e012984b0 [Preamble] Fix an undefined behavior when checking an empty preamble can be reused.
Summary: Passing nullptr to memcmp is UB.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D50967

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340403 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-22 12:34:04 +00:00
Haojian Wu b8333ea1b7 [Preamble] Empty preamble is not an error.
Summary:
Empty preamble is valid for source file which doesn't have any
preprocessor and #includes.

This patch makes clang treat an empty preamble as a normal preamble.

Check: ninja check-clang

A testcase is added in https://reviews.llvm.org/D50627.

Reviewers: ilya-biryukov

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D50628

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340029 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-17 14:25:10 +00:00
Ilya Biryukov d46ee151e6 [Preamble] Check system dependencies in preamble too
Summary:
PrecompiledPreamble hasn't checked if the system dependencies changed
before. This resulted in invalid preamble not being rebuilt if headers
that changed were found in -isystem include paths.

This pattern is sometimes used to avoid showing warnings in third
party code, so we want to correctly handle those cases.

Tested in clangd, see the follow-up patch.

Reviewers: sammccall, ioeric

Reviewed By: sammccall

Subscribers: omtcyfz, cfe-commits

Differential Revision: https://reviews.llvm.org/D48946

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@336528 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-09 09:07:01 +00:00
Nico Weber 3ffe6de5f1 s/LLVM_ON_WIN32/_WIN32/, clang
LLVM_ON_WIN32 is set exactly with MSVC and MinGW (but not Cygwin) in
HandleLLVMOptions.cmake, which is where _WIN32 defined too.  Just use the
default macro instead of a reinvented one.

See thread "Replacing LLVM_ON_WIN32 with just _WIN32" on llvm-dev and cfe-dev.
No intended behavior change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331069 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-27 19:11:14 +00:00
Ben Langmuir e403c97d4e [vfs] Don't bail out after a missing -ivfsoverlay file
This make -ivfsoverlay behave more like other fatal errors (e.g. missing
-include file) by skipping the missing file instead of bailing out of
the whole compilation. This makes it possible for libclang to still
provide some functionallity as well as to correctly produce the fatal
error diagnostic (previously we lost the diagnostic in libclang since
there was no TU to tie it to).

rdar://33385423

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328337 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-23 17:37:27 +00:00
Ilya Biryukov ca37e4fc6c [Frontend] Allow to use PrecompiledPreamble without calling CanReuse
Summary:
The new method 'OverridePreamble' allows to override the preamble of
any source file without checking if preamble bounds or dependencies
were changed.

This is used for completion in clangd.

Reviewers: bkramer, sammccall

Reviewed By: sammccall

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D41990

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322853 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-18 15:16:53 +00:00
Ilya Biryukov d3e23db50e Added helper to get size of PrecompiledPreamble
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321266 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-21 14:04:39 +00:00
Ilya Biryukov aacf253198 [clang] Add BeforeExecute method to PrecompiledPreamble
Summary: Adds BeforeExecute method to PrecompiledPreamble to be called
before Execute(). This method can be overriden.

Patch by William Enright.

Reviewers: malaperle, ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: arphaman, cfe-commits, ilya-biryukov

Differential Revision: https://reviews.llvm.org/D41365

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321189 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-20 16:48:56 +00:00
Ilya Biryukov 05461699ec [clang] Add PPCallbacks list to preprocessor when building a preacompiled preamble.
Summary:
Revision D38639 needs this commit in order to properly make open
definition calls on include statements work.

Patch by William Enright.

Reviewers: malaperle, krasimir, bkramer, ilya-biryukov

Reviewed By: malaperle, ilya-biryukov

Subscribers: cfe-commits, arphaman, ilya-biryukov

Differential Revision: https://reviews.llvm.org/D39375

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320804 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-15 11:27:51 +00:00
Ilya Biryukov e5081fa9ed Avoid copying the data of in-memory preambles
Summary: Preambles are large and we should avoid copying them.

Reviewers: bkramer, klimek

Reviewed By: bkramer

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D40302

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@318945 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-24 13:12:38 +00:00
Ilya Biryukov 1c15c4bdf6 Use llvm-config.h instead of config.h
To fix standalone builds broken by r318411 (config.h is private to llvm).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@318514 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-17 10:09:02 +00:00
Ilya Biryukov 5a8ee92d12 Allow to store precompiled preambles in memory.
Summary:
These preambles are built by ASTUnit and clangd. Previously, preambles
were always stored on disk.

In-memory preambles are routed back to the compiler as virtual files in
a custom VFS.

Interface of ASTUnit does not allow to use in-memory preambles, as
ASTUnit::CodeComplete receives FileManager as a parameter, so we can't
change VFS used by the compiler inside the CodeComplete method.

A follow-up commit will update clangd in clang-tools-extra to use
in-memory preambles.

Reviewers: klimek, sammccall, bkramer

Reviewed By: klimek

Subscribers: ioeric, cfe-commits

Differential Revision: https://reviews.llvm.org/D39842

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@318411 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-16 16:25:01 +00:00
Benjamin Kramer 54b80d1987 Create fewer copies of StringMaps. No functionality change intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316301 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-22 20:16:28 +00:00
Ilya Biryukov 5dbb2b9491 Set PreprocessorOpts.GeneratePreamble=true in PrecompiledPreamble.
Summary:
It was previsouly set only in ASTUnit, but it should be set for all client of
PrecompiledPreamble.

Reviewers: erikjv, bkramer, klimek

Reviewed By: bkramer

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D38617

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@315212 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-09 16:52:12 +00:00
Cameron Desrochers aacb703987 [PCH] Fixed preamble breaking with BOM presence (and particularly, fluctuating BOM presence)
This patch fixes broken preamble-skipping when the preamble region includes a byte order mark (BOM). Previously, parsing would fail if preamble PCH generation was enabled and a BOM was present.

This also fixes preamble invalidation when a BOM appears or disappears. This may seem to be an obscure edge case, but it happens regularly with IDEs that pass buffer overrides that never (or always) have a BOM, yet the underlying file from the initial parse that generated a PCH might (or might not) have a BOM.

I've included a test case for these scenarios.

Differential Revision: https://reviews.llvm.org/D37491

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@313796 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-20 19:03:37 +00:00
Ilya Biryukov ed88e83b5d Fixed a race condition in PrecompiledPreamble.
Summary:
Two PrecompiledPreambles, used in parallel on separate threads,
could be writing preamble to the same temporary file.

Reviewers: bkramer, krasimir, klimek

Reviewed By: klimek

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D36529

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@310618 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-10 16:10:40 +00:00
Haojian Wu 12b5e0baa2 Fix unused-variable compilation error.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305898 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-21 11:26:58 +00:00
Ilya Biryukov 864bf1d491 Moved code hanlding precompiled preamble out of the ASTUnit.
Reviewers: bkramer, krasimir, arphaman, akyrtzi, klimek

Reviewed By: klimek

Subscribers: mgorny, klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D34287

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305890 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-21 10:24:58 +00:00