aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/ASTUnit.cpp
AgeCommit message (Collapse)AuthorFilesLines
2021-06-29[clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine to ↵Melanie Blower1-1/+1
allow diagnostics on target-unsupported options Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D104729
2021-06-28Revert "[clang][PATCH][nfc] Refactor TargetInfo::adjust to pass ↵Melanie Blower1-1/+1
DiagnosticsEngine to allow diagnostics on target-unsupported options" This reverts commit 2dbe1c675fe94eeb7973dcc25b049d25f4ca4fa0. More buildbot failures
2021-06-28[clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine to ↵Melanie Blower1-1/+1
allow diagnostics on target-unsupported options Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D104729
2021-06-28Revert "[clang][PATCH][nfc] Refactor TargetInfo::adjust to pass ↵Melanie Blower1-1/+1
DiagnosticsEngine to allow diagnostics on target-unsupported options" This reverts commit 2c02b0c3f45414ac6c64583e006a26113c028304. buildbot fails
2021-06-28[clang][PATCH][nfc] Refactor TargetInfo::adjust to pass DiagnosticsEngine to ↵Melanie Blower1-1/+1
allow diagnostics on target-unsupported options Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D104729
2021-04-06[clang][clangd] Avoid inconsistent target creationoToToT1-27/+3
As proposed in D97109, I tried to make target creation consistent in `clang` and `clangd` by replacing the original procedure with a single function introduced in D97493. This also helps `clangd` works with CUDA, OpenMP, etc. Reviewed By: kadircet Differential Revision: https://reviews.llvm.org/D98128
2021-01-25Frontend: Take VFS and MainFileBuffer by reference in ↵Duncan P. N. Exon Smith1-2/+2
PrecompiledPreamble::CanReuse, NFC Clarify that `PrecompiledPreamble::CanReuse` requires non-null arguments for `VFS` and `MainFileBuffer`, taking them by reference instead of by pointer. Differential Revision: https://reviews.llvm.org/D91297
2021-01-21[ASTReader] Allow controlling separately whether validation should be ↵Argyrios Kyrtzidis1-2/+3
disabled for a PCH vs a module file This addresses an issue with how the PCH preable works, specifically: 1. When using a PCH/preamble the module hash changes and a different cache directory is used 2. When the preamble is used, PCH & PCM validation is disabled. Due to combination of #1 and #2, reparsing with preamble enabled can end up loading a stale module file before a header change and using it without updating it because validation is disabled and it doesn’t check that the header has changed and the module file is out-of-date. rdar://72611253 Differential Revision: https://reviews.llvm.org/D95159
2020-12-09Remove RemappedFiles param from ASTUnit::LoadFromASTFile, NFCDuncan P. N. Exon Smith1-6/+2
This parameter is always set to `None`. Remove it. Differential Revision: https://reviews.llvm.org/D90889
2020-12-08Frontend: Clarify logic for using the preamble in ASTUnit::CodeComplete, ↵Duncan P. N. Exon Smith1-17/+19
almost NFC Clarify the logic for using the preamble (and overriding the main file buffer) in `ASTUnit::CodeComplete` by factoring out a couple of lambdas (`getUniqueID` and `hasSameUniqueID`). While refactoring the logic, hoist the check for `Line > 1` and locally check if the filenames are equal (both to avoid unnecessary `stat` calls) and skip copying out the filenames to `std::string`. Besides fewer calls to `stat`, there's no functionality change here. Differential Revision: https://reviews.llvm.org/D91296
2020-12-03Frontend: Remove redundant call to CompilerInstance::setFileManager, NFCDuncan P. N. Exon Smith1-3/+0
`ASTUnit::Parse` sets up the `FileManager` earlier in the same function, ensuring `ASTUnit::getFileManager()` matches `Clang->getFileManager()`. Remove the later call to `setFileManager(getFileManager())` since it does nothing. Differential Revision: https://reviews.llvm.org/D90888
2020-11-17[Frontend] Add flag to allow PCM generation despite compiler errorsBen Barham1-2/+2
As with precompiled headers, it's useful for indexers to be able to continue through compiler errors in dependent modules. Resolves rdar://69816264 Reviewed By: akyrtzi Differential Revision: https://reviews.llvm.org/D91580
2020-11-13Frontend: Remove unused parameter from ↵Duncan P. N. Exon Smith1-4/+2
ASTUnit::LoadFromCompilerInvocationAction, NFC Drop `IncludeBriefCommentsInCodeCompletion` since it is always `false`. Differential Revision: https://reviews.llvm.org/D91295
2020-11-11Frontend: Change ComputePreambleBounds to take MemoryBufferRef, NFCDuncan P. N. Exon Smith1-3/+2
Avoid requiring an actual MemoryBuffer in ComputePreambleBounds, when a MemoryBufferRef will do just fine. Differential Revision: https://reviews.llvm.org/D90890
2020-10-22[clang][Frontend] Add missing error handlingLemonBoy1-14/+18
Some early errors during the ASTUnit creation were not transferred to the `FailedParseDiagnostic` so when the code in `LoadFromCommandLine` swaps its content with the content of `StoredDiagnostics` they cannot be retrieved by the user in any way. Reviewed By: andrewrk, dblaikie Differential Revision: https://reviews.llvm.org/D78658
2020-10-20clang/Frontend: Use MemoryBufferRef in FrontendInputFile (and remove ↵Duncan P. N. Exon Smith1-1/+1
SourceManager::getBuffer) In order to drop the final callers to `SourceManager::getBuffer`, change `FrontendInputFile` to use `Optional<MemoryBufferRef>`. Also updated the "unowned" version of `SourceManager::createFileID` to take a `MemoryBufferRef` (it now calls `MemoryBuffer::getMemBuffer`, which creates a `MemoryBuffer` that does not own the buffer data). Differential Revision: https://reviews.llvm.org/D89427
2020-04-28ASTUnit::FileDecls: Use unique_ptr to simplify memory managementDavid Blaikie1-3/+3
2020-01-28Make llvm::StringRef to std::string conversions explicit.Benjamin Kramer1-11/+15
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2019-11-22clang/Modules: Rename CompilerInstance::ModuleManager, NFCDuncan P. N. Exon Smith1-1/+1
Fix the confusing naming of `CompilerInstance::ModuleManager`. This is actually an instance of `ASTReader`, which contains an instance of `ModuleManager`. I have to assume there was a point in the past where they were just one class, but it's been pretty confusing for a while. I think it's time to fix it. The new name is `TheASTReader`; the annoying `The` prefix is so that we don't shadow the `ASTReader` class. I tried out `ASTRdr` but that seemed less clear, and this choice matches `ThePCHContainerOperations` just a couple of declarations below. Also rename `CompilerInstance::getModuleManager` and `CompilerInstance::createModuleManager` to `*ASTReader`, making some cases of `getModuleManager().getModuleManager()` a little more clear. https://reviews.llvm.org/D70583
2019-11-21clang/Modules: Move Serialization/Module.{h,cpp} to ModuleFile, NFCDuncan P. N. Exon Smith1-1/+1
Remove some cognitive load by renaming clang/Serialization/Module.h to clang/Serialization/ModuleFile.h, since it declares the ModuleFile class. This also makes editing a bit easier, since the basename of the file no long conflicts with clang/Basic/Module.h, which declares the Module class. Also move lib/Serialization/Module.cpp to lib/Serialization/ModuleFile.cpp.
2019-09-13[Support] Add overload writeFileAtomically(std::function Writer)Jan Korous1-15/+9
Differential Revision: https://reviews.llvm.org/D67424 llvm-svn: 371890
2019-08-27[preprocessor] Add an opportunity to retain excluded conditional blocksEvgeny Mankov1-0/+2
It is handy for clang tooling, for instance, in source to source transformation. Reviewers: vpykhtin (Valery Pykhtin), erichkeane (Erich Keane) Subscribers: rsmith (Richard Smith), akyrtzi (Argyrios Kyrtzidis) Tags: #clang Differential Revision: https://reviews.llvm.org/D66597 llvm-svn: 370123
2019-08-14[Clang] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere1-7/+7
Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368942
2019-08-07Replace non-recursive sys::Mutex users with std::mutexBenjamin Kramer1-5/+5
Also remove a use of sys::MutexImpl, that's just evil. No functionality change intended. llvm-svn: 368157
2019-08-05Move LangStandard*, InputKind::Language to BasicRainer Orth1-9/+10
This patch is a prerequisite for using LangStandard from Driver in https://reviews.llvm.org/D64793. It moves LangStandard* and InputKind::Language to Basic. It is mostly mechanical, with only a few changes of note: - enum Language has been changed into enum class Language : uint8_t to avoid a clash between OpenCL in enum Language and OpenCL in enum LangFeatures and not to increase the size of class InputKind. - Now that getLangStandardForName, which is currently unused, also checks both canonical and alias names, I've introduced a helper getLangKind which factors out a code pattern already used 3 times. The patch has been tested on x86_64-pc-solaris2.11, sparcv9-sun-solaris2.11, and x86_64-pc-linux-gnu. There's a companion patch for lldb which uses LangStandard.h (https://reviews.llvm.org/D65717). While polly includes isl which in turn uses InputKind::C, that part of the code isn't even built inside the llvm tree. I've posted a patch to allow for both InputKind::C and Language::C upstream (https://groups.google.com/forum/#!topic/isl-development/6oEvNWOSQFE). Differential Revision: https://reviews.llvm.org/D65562 llvm-svn: 367864
2019-08-01[clang] Adopt new FileManager error-returning APIsHarlan Haskins1-2/+2
Update the callers of FileManager::getFile and FileManager::getDirectory to handle the new llvm::ErrorOr-returning methods. Signed-off-by: Harlan Haskins <harlan@apple.com> llvm-svn: 367616
2019-07-18[ASTUnit] Fix a regression in cached completionsIlya Biryukov1-1/+0
Summary: After r345152 cached completions started adding namespaces after nested name specifiers, e.g. in `some_name::^` The CCC_Symbol indicates the completed item cannot be a namespace (it is described as being "a type, a function or a variable" in the comments). Therefore, 'nested specifier' completions should only be added from cache when the context is CCC_SymbolOrNewName (which roughly seems to indicate that a nested name specifier is allowed). Fixes https://bugs.llvm.org/show_bug.cgi?id=42646 Reviewers: kadircet, sammccall Reviewed By: kadircet, sammccall Subscribers: arphaman, nik, sammccall, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64918 llvm-svn: 366448
2019-07-03[Bitcode] Move Bitstream to a separate libraryFrancis Visoiu Mistrih1-1/+1
This moves Bitcode/Bitstream*, Bitcode/BitCodes.h to Bitstream/. This is needed to avoid a circular dependency when using the bitstream code for parsing optimization remarks. Since Bitcode uses Core for the IR part: libLLVMRemarks -> Bitcode -> Core and Core uses libLLVMRemarks to generate remarks (see IR/RemarkStreamer.cpp): Core -> libLLVMRemarks we need to separate the Bitstream and Bitcode part. For clang-doc, it seems that it doesn't need the whole bitcode layer, so I updated the CMake to only use the bitstream part. Differential Revision: https://reviews.llvm.org/D63899 llvm-svn: 365091
2019-07-03Change std::{lower,upper}_bound to llvm::{lower,upper}_bound or ↵Fangrui Song1-8/+8
llvm::partition_point. NFC llvm-svn: 365006
2019-06-26BitStream reader: propagate errorsJF Bastien1-3/+8
The bitstream reader handles errors poorly. This has two effects: * Bugs in file handling (especially modules) manifest as an "unexpected end of file" crash * Users of clang as a library end up aborting because the code unconditionally calls `report_fatal_error` The bitstream reader should be more resilient and return Expected / Error as soon as an error is encountered, not way late like it does now. This patch starts doing so and adopting the error handling where I think it makes sense. There's plenty more to do: this patch propagates errors to be minimally useful, and follow-ups will propagate them further and improve diagnostics. https://bugs.llvm.org/show_bug.cgi?id=42311 <rdar://problem/33159405> Differential Revision: https://reviews.llvm.org/D63518 llvm-svn: 364464
2019-06-11[libclang] Allow skipping warnings from all included filesNikolai Kosjar1-22/+46
Depending on the included files and the used warning flags, e.g. - Weverything, a huge number of warnings can be reported for included files. As processing that many diagnostics comes with a performance impact and not all clients are interested in those diagnostics, add a flag to skip them. Differential Revision: https://reviews.llvm.org/D48116 llvm-svn: 363067
2019-05-22[Frontend] Return an error on bad inputs to PrecompiledPreabmleIlya Biryukov1-0/+1
Summary: Instead of failing with assertions. Fixes a crash found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=12865 Reviewers: sammccall Reviewed By: sammccall Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62137 llvm-svn: 361376
2019-05-21[Preamble] Reuse preamble even if an unsaved file does not existNikolai Kosjar1-10/+12
When a preamble is created an unsaved file not existing on disk is already part of PrecompiledPreamble::FilesInPreamble. However, when checking whether the preamble can be re-used, a failed stat of such an unsaved file invalidated the preamble, which led to pointless and time consuming preamble regenerations on subsequent reparses. Do not require anymore that unsaved files should exist on disk. This avoids costly preamble invalidations depending on timing issues for the cases where the file on disk might be removed just to be regenerated a bit later. It also allows an IDE to provide in-memory files that might not exist on disk, e.g. because the build system hasn't generated those yet. Differential Revision: https://reviews.llvm.org/D41005 llvm-svn: 361226
2019-04-18[CodeComplete] Remove obsolete isOutputBinary().Sam McCall1-2/+1
Summary: It's never set to true. Its only effect would be to set stdout to binary mode. Hopefully we have better ways of doing this by now :-) Reviewers: hokein Subscribers: jkorous, arphaman, kadircet, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D60871 llvm-svn: 358696
2019-03-26Basic: Return a reference from FileManager::getVirtualFileSystem, NFCDuncan P. N. Exon Smith1-9/+10
FileManager constructs a VFS in its constructor if it isn't passed one, and there's no way to reset it. Make that contract clear by returning a reference from its accessor. https://reviews.llvm.org/D59388 llvm-svn: 357038
2019-03-26Frontend: Remove CompilerInstance::VirtualFileSystem, NFCDuncan P. N. Exon Smith1-16/+13
Remove CompilerInstance::VirtualFileSystem and CompilerInstance::setVirtualFileSystem, instead relying on the VFS in the FileManager. CompilerInstance and its clients already went to some trouble to make these match. Now they are guaranteed to match. As part of this, I added a VFS parameter (defaults to nullptr) to CompilerInstance::createFileManager, to avoid repeating construction logic in clients that just wanted to customize the VFS. https://reviews.llvm.org/D59377 llvm-svn: 357037
2019-03-09Modules: Rename MemoryBufferCache to InMemoryModuleCacheDuncan P. N. Exon Smith1-14/+14
Change MemoryBufferCache to InMemoryModuleCache, moving it from Basic to Serialization. Another patch will start using it to manage module build more explicitly, but this is split out because it's mostly mechanical. Because of the move to Serialization we can no longer abuse the Preprocessor to forward it to the ASTReader. Besides the rename and file move, that means Preprocessor::Preprocessor has one fewer parameter and ASTReader::ASTReader has one more. llvm-svn: 355777
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-4/+3
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2018-12-12Move PCHContainerOperations from Frontend to SerializationRichard Trieu1-1/+1
Fix a layering violation. Frontend depends on Serialization, so anything used by both should be in Serialization. llvm-svn: 348907
2018-10-30NFC: Remove the ObjC1/ObjC2 distinction from clang (and related projects)Erik Pilkington1-2/+2
We haven't supported compiling ObjC1 for a long time (and never will again), so there isn't any reason to keep these separate. This patch replaces LangOpts::ObjC1 and LangOpts::ObjC2 with LangOpts::ObjC. Differential revision: https://reviews.llvm.org/D53547 llvm-svn: 345637
2018-10-24[clang] Introduce new completion context typesKadir Cetinkaya1-5/+7
Summary: New name suggestions were being used in places where existing names should have been used, this patch tries to fix some of those situations. Reviewers: sammccall Reviewed By: sammccall Subscribers: arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53191 llvm-svn: 345152
2018-10-10Lift VFS from clang to llvm (NFC)Jonas Devlieghere1-13/+13
This patch moves the virtual file system form clang to llvm so it can be used by more projects. Concretely the patch: - Moves VirtualFileSystem.{h|cpp} from clang/Basic to llvm/Support. - Moves the corresponding unit test from clang to llvm. - Moves the vfs namespace from clang::vfs to llvm::vfs. - Formats the lines affected by this change, mostly this is the result of the added llvm namespace. RFC on the mailing list: http://lists.llvm.org/pipermail/llvm-dev/2018-October/126657.html Differential revision: https://reviews.llvm.org/D52783 llvm-svn: 344140
2018-09-18[CodeComplete] Add completions for filenames in #include directives.Sam McCall1-0/+1
Summary: The dir component ("somedir" in #include <somedir/fo...>) is considered fixed. We append "foo" to each directory on the include path, and then list its files. Completions are of the forms: #include <somedir/fo^ foo.h> fox/ The filter is set to the filename part ("fo"), so fuzzy matching can be applied to the filename only. No fancy scoring/priorities are set, and no information is added to CodeCompleteResult to make smart scoring possible. Could be in future. Reviewers: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D52076 llvm-svn: 342449
2018-08-30[CodeComplete] Report location of opening parens for signature helpIlya Biryukov1-2/+4
Summary: Used in clangd. Reviewers: sammccall Reviewed By: sammccall Subscribers: ioeric, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D51436 llvm-svn: 341063
2018-08-17[Preamble] Empty preamble is not an error.Haojian Wu1-1/+0
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 llvm-svn: 340029
2018-06-15[ASTImporter] Corrected diagnostic client handling in tests.Adam Balogh1-0/+6
ASTImporter tests may produce source file related warnings, the diagnostic client should be in correct state to handle it. Added 'beginSourceFile' to set the client state. Patch by: Balázs Kéri Differential Revision: https://reviews.llvm.org/D47445 llvm-svn: 334804
2018-06-06[Frontend] Honor UserFilesAreVolatile flag getting file buffer in ASTUnitIvan Donchevskii1-5/+6
Do not memory map the main file if the flag UserFilesAreVolatile is set to true in ASTUnit when calling FileSystem::getBufferForFile. Differential Revision: https://reviews.llvm.org/D47460 llvm-svn: 334070
2018-05-25Optionally add code completion results for arrow instead of dotIvan Donchevskii1-0/+1
Currently getting such completions requires source correction, reparsing and calling completion again. And if it shows no results and rollback is required then it costs one more reparse. With this change it's possible to get all results which can be later filtered to split changes which require correction. Differential Revision: https://reviews.llvm.org/D41537 llvm-svn: 333272
2018-05-17[libclang] Allow skipping function bodies in preamble onlyIvan Donchevskii1-3/+14
Second attempt. Fix line endings and warning. As an addition to CXTranslationUnit_SkipFunctionBodies, provide the new option CXTranslationUnit_LimitSkipFunctionBodiesToPreamble, which constraints the skipping of functions bodies to the preamble only. Function bodies in the main file are not affected if this option is set. Skipping function bodies only in the preamble is what clangd already does and the introduced flag implements it for libclang clients. Patch by Nikolai Kosjar. Differential Revision: https://reviews.llvm.org/D45815 llvm-svn: 332587
2018-05-17Revert https://reviews.llvm.org/D46050 and https://reviews.llvm.org/D45815Ivan Donchevskii1-47/+36
Windows line endings. Requires proper resubmission. llvm-svn: 332585