summaryrefslogtreecommitdiffstats
path: root/clang/tools
Commit message (Collapse)AuthorAgeFilesLines
...
* Convert comment to C-style to prevent warningSam Clegg2018-01-181-1/+1
| | | | llvm-svn: 322880
* Fix MSVC "uninitialized variable" warning.Simon Pilgrim2018-01-181-1/+4
| | | | llvm-svn: 322845
* [Index] Fix GCC warning again :-(Sam McCall2018-01-171-2/+2
| | | | llvm-svn: 322720
* [Index] Fix GCC warning. This is silly, but no llvm_unreachable and no C99.Sam McCall2018-01-171-1/+3
| | | | llvm-svn: 322672
* Squash -Wcovered-switch-default wairningSam McCall2018-01-161-2/+1
| | | | llvm-svn: 322549
* [libclang] Add PrintingPolicy for pretty printing declarationsJonathan Coe2018-01-163-6/+292
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Introduce clang_getCursorPrettyPrinted() for pretty printing declarations. Expose also PrintingPolicy, so the user gets more fine-grained control of the entities being printed. The already existing clang_getCursorDisplayName() is pretty limited - for example, it does not handle return types, parameter names or default arguments for function declarations. Addressing these issues in clang_getCursorDisplayName() would mean to duplicate existing code (e.g. clang::DeclPrinter), so rather expose new API to access the existing functionality. Reviewed By: jbcoe Subscribers: cfe-commits Tags: #clang Patch by nik (Nikolai Kosjar) Differential Revision: https://reviews.llvm.org/D39903 llvm-svn: 322540
* [Driver] Suggest valid integrated toolsBrian Gesiak2018-01-151-1/+2
| | | | | | | | | | | | | | | | | | | | | | Summary: There are only two valid integrated Clang driver tools: `-cc1` and `-cc1as`. If a user asks for an unknown tool, such as `-cc1asphalt`, an error message is displayed to indicate that there is no such tool, but the message doesn't indicate what the valid options are. Include the valid options in the error message. Test Plan: `check-clang` Reviewers: sepavloff, bkramer, phosek Reviewed By: bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D42004 llvm-svn: 322517
* [PCH] Serialize skipped preprocessor rangesCameron Desrochers2018-01-151-0/+3
| | | | | | | | The skipped preprocessor ranges are now serialized in the AST PCH file. This fixes, for example, libclang's clang_getSkippedRanges() returning zero ranges after reparsing a translation unit. Differential Revision: https://reviews.llvm.org/D20124 llvm-svn: 322503
* [Driver] Add "did you mean?" suggestions to -cc1asBrian Gesiak2018-01-131-1/+7
| | | | | | | | | | | | | | | | | | | | | | Summary: In https://reviews.llvm.org/D41733, the driver was modified such that, when a user provided a mispelled option such as `-hel`, it would suggest a valid option with a nearby edit distance: "did you mean '-help'?". Add these suggestions to invocations of `clang -cc1as` as well. Test Plan: `check-clang` Reviewers: v.g.vassilev, bruno Reviewed By: v.g.vassilev Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D42001 llvm-svn: 322445
* [CodeComplete] Add an option to omit results from the preamble.Sam McCall2018-01-122-0/+4
| | | | | | | | | | | | | | | | | | | | | | | Summary: Enumerating the contents of a namespace or global scope will omit any decls that aren't already loaded, instead of deserializing them from the PCH. This allows a fast hybrid code completion where symbols from headers are provided by an external index. (Sema already exposes the information needed to do a reasonabl job of filtering them). Clangd plans to implement this hybrid. This option is just a hint - callers still need to postfilter results if they want to *avoid* completing decls outside the main file. Reviewers: bkramer, ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D41989 llvm-svn: 322371
* [cmake] Delete redundant install command for clang-refactor.Don Hinton2018-01-101-2/+0
| | | | | | | | | | | | | Summary: Install targets for clang tools are controlled by CLANG_BUILD_TOOLS, and when OFF, cmake issues the following warning: WARNING: Target "clang-refactor" has EXCLUDE_FROM_ALL set and will not be built by default but an install rule has been provided for it. CMake does not define behavior for this case. Differential Revision: https://reviews.llvm.org/D41807 llvm-svn: 322147
* [index] Return when DC is null in handleReferenceFangrui Song2018-01-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: DC may sometimes be NULL and getContainerInfo(DC, Container) will dereference a null pointer. Default template arguments (the following example and many test files in https://github.com/nlohmann/json) may cause null pointer dereference. ```c++ template <typename> struct actor; template <template <typename> class Actor = actor> struct terminal; ``` In tools/libclang/CXIndexDataConsumer.cpp#L203 handleReference(ND, Loc, Cursor, dyn_cast_or_null<NamedDecl>(ASTNode.Parent), ASTNode.ContainerDC, ASTNode.OrigE, Kind); `dyn_cast_or_null<NamedDecl>(ASTNode.Parent)` is somehow a null pointer and in tools/libclang/CXIndexDataConsumer.cpp:935 ContainerInfo Container; getContainerInfo(DC, Container); The null DC is casted `ContInfo.cursor = getCursor(cast<Decl>(DC));` and SIGSEGV. ``` See discussions in https://github.com/jacobdufault/cquery/issues/219 https://github.com/jacobdufault/cquery/issues/192 Reviewers: akyrtzi, sammccall, yvvan Reviewed By: sammccall Subscribers: mehdi_amini, cfe-commits Differential Revision: https://reviews.llvm.org/D41575 llvm-svn: 322017
* [libclang] Support querying whether a declaration is invalidIvan Donchevskii2018-01-043-0/+12
| | | | | | | | | | | | | | This is useful for e.g. highlighting purposes in an IDE. Note: First version of this patch was reverted due to failing tests in opencl-types.cl with -target ppc64le-unknown-linux. These tests are adapted now. Patch by Nikolai Kosjar. Differential Revision: https://reviews.llvm.org/D40072 llvm-svn: 321794
* [libclang] Fix cursors for functions with trailing return typeIvan Donchevskii2018-01-031-3/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This one was rolled back as follow-up to the failing commit. Second try. For the function declaration auto foo5(Foo) -> Foo; the parameter tokens were mapped to cursors representing the FunctionDecl: Keyword: "auto" [1:1 - 1:5] FunctionDecl=test5:1:6 Identifier: "test5" [1:6 - 1:11] FunctionDecl=test5:1:6 Punctuation: "(" [1:11 - 1:12] FunctionDecl=test5:1:6 Identifier: "X" [1:12 - 1:13] FunctionDecl=test5:1:6 // Ops, not a TypeRef Punctuation: ")" [1:13 - 1:14] FunctionDecl=test5:1:6 Punctuation: "->" [1:15 - 1:17] FunctionDecl=test5:1:6 Identifier: "X" [1:18 - 1:19] TypeRef=struct X:7:8 Punctuation: ";" [1:19 - 1:20] Fix this by ensuring that the trailing return type is not visited as first. Patch by Nikolai Kosjar. Differential Revision: https://reviews.llvm.org/D40561 llvm-svn: 321709
* Revert r321697 "[libclang] Support querying whether a declaration is ↵Hans Wennborg2018-01-033-37/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | invalid" and follow-ups. This broke test/Index/opencl-types.cl on several buildbots: http://lab.llvm.org:8011/builders/clang-cmake-aarch64-lld/builds/3294 http://lab.llvm.org:8011/builders/clang-ppc64be-linux-multistage/builds/6498 http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/5239 > [libclang] Support querying whether a declaration is invalid > > This is useful for e.g. highlighting purposes in an IDE. > > Patch by Nikolai Kosjar. > > Differential Revision: https://reviews.llvm.org/D40072 Also reverting follow-ups that otherwise caused conflicts for the revert: r321700 "Fix line endings." r321701 "Fix more line endings." r321698 "[libclang] Fix cursors for functions with trailing return type" > For the function declaration > > auto foo5(Foo) -> Foo; > the parameter tokens were mapped to cursors representing the > FunctionDecl: > > Keyword: "auto" [1:1 - 1:5] FunctionDecl=test5:1:6 > Identifier: "test5" [1:6 - 1:11] FunctionDecl=test5:1:6 > Punctuation: "(" [1:11 - 1:12] FunctionDecl=test5:1:6 > Identifier: "X" [1:12 - 1:13] FunctionDecl=test5:1:6 // Ops, not a TypeRef > Punctuation: ")" [1:13 - 1:14] FunctionDecl=test5:1:6 > Punctuation: "->" [1:15 - 1:17] FunctionDecl=test5:1:6 > Identifier: "X" [1:18 - 1:19] TypeRef=struct X:7:8 > Punctuation: ";" [1:19 - 1:20] > > Fix this by ensuring that the trailing return type is not visited as > first. > > Patch by Nikolai Kosjar. > > Differential Revision: https://reviews.llvm.org/D40561 llvm-svn: 321708
* Fix line endings.Ivan Donchevskii2018-01-032-66/+66
| | | | llvm-svn: 321700
* [libclang] Fix cursors for functions with trailing return typeIvan Donchevskii2018-01-031-27/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | For the function declaration auto foo5(Foo) -> Foo; the parameter tokens were mapped to cursors representing the FunctionDecl: Keyword: "auto" [1:1 - 1:5] FunctionDecl=test5:1:6 Identifier: "test5" [1:6 - 1:11] FunctionDecl=test5:1:6 Punctuation: "(" [1:11 - 1:12] FunctionDecl=test5:1:6 Identifier: "X" [1:12 - 1:13] FunctionDecl=test5:1:6 // Ops, not a TypeRef Punctuation: ")" [1:13 - 1:14] FunctionDecl=test5:1:6 Punctuation: "->" [1:15 - 1:17] FunctionDecl=test5:1:6 Identifier: "X" [1:18 - 1:19] TypeRef=struct X:7:8 Punctuation: ";" [1:19 - 1:20] Fix this by ensuring that the trailing return type is not visited as first. Patch by Nikolai Kosjar. Differential Revision: https://reviews.llvm.org/D40561 llvm-svn: 321698
* [libclang] Support querying whether a declaration is invalidIvan Donchevskii2018-01-033-18/+30
| | | | | | | | | | This is useful for e.g. highlighting purposes in an IDE. Patch by Nikolai Kosjar. Differential Revision: https://reviews.llvm.org/D40072 llvm-svn: 321697
* [libclang] Add clang_getFileContents to libclang.exportsIvan Donchevskii2018-01-031-0/+1
| | | | | | | This is the follow up patch for rL319881 which introduced the function but did not put it into .exports file. llvm-svn: 321695
* Update clang cc1as for createMCAsmBackend change in r321692Alex Bradbury2018-01-031-3/+2
| | | | llvm-svn: 321693
* [Index] Reduce size of SymbolInfo struct.Sam McCall2017-12-231-3/+3
| | | | | | | | | | | | | | | | | | | | | Summary: This is currently 16 bytes, the patch reduces it to 4. (Building with clang on linux x84, I guess others are similar) The only subfield that might need a bigger type is SymbolPropertySet, I've moved it to the end of the struct so if it grows, SymbolInfo will only be 8 bytes. With a full index of namespace-scope symbols from the LLVM project (200k) loaded into clangd, this saves ~2MB of RAM. Reviewers: akyrtzi Subscribers: ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D41514 llvm-svn: 321411
* [libclang] Add support for checking abstractness of recordsAlex Lorenz2017-12-143-0/+14
| | | | | | | | | | | This patch allows checking whether a C++ record declaration is abstract through libclang and clang.cindex (Python). Patch by Johann Klähn! Differential Revision: https://reviews.llvm.org/D36952 llvm-svn: 320748
* [libclang] Record code-completion invocations to a temporary file whenAlex Lorenz2017-12-076-4/+41
| | | | | | | | | | | | | requested by client This is a follow up to r319702 which records parsing invocations. These files are not emitted by default, and the client has to specify the invocation emission path first. rdar://35322543 llvm-svn: 320085
* [Index] Add setPreprocessor member to IndexDataConsumer.Eric Liu2017-12-071-1/+1
| | | | | | | | | | | | | | | | Summary: This enables us to use information in Preprocessor when handling symbol occurrences. Reviewers: arphaman, hokein Reviewed By: hokein Subscribers: malaperle, cfe-commits Differential Revision: https://reviews.llvm.org/D40884 llvm-svn: 320030
* [clang] Add PRIVATE to target_link_librariesShoaib Meenai2017-12-061-0/+1
| | | | | | | Another follow-up to r319840. I'd done a test configure with LLVM_BUILD_STATIC, so I'm not sure why this didn't show up in that. llvm-svn: 319983
* [clang] Use PRIVATE in target_link_librariesShoaib Meenai2017-12-061-1/+1
| | | | | | | I'd missed this one in r319840 because I hadn't been configuring with an order file before. llvm-svn: 319950
* [CMake] Use PRIVATE in target_link_libraries for fuzzers.Matt Morehouse2017-12-063-1/+3
| | | | | | Several fuzzers were missed by r319840. llvm-svn: 319948
* [libclang] Add function to get the buffer for a fileErik Verbruggen2017-12-061-0/+21
| | | | | | | | | | This can be used by clients in conjunction with an offset returned by e.g. clang_getFileLocation. Now those clients do not need to also open/read the file. Differential Revision: https://reviews.llvm.org/D40643 llvm-svn: 319881
* [CMake] Use PRIVATE in target_link_libraries for executablesShoaib Meenai2017-12-0514-2/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We currently use target_link_libraries without an explicit scope specifier (INTERFACE, PRIVATE or PUBLIC) when linking executables. Dependencies added in this way apply to both the target and its dependencies, i.e. they become part of the executable's link interface and are transitive. Transitive dependencies generally don't make sense for executables, since you wouldn't normally be linking against an executable. This also causes issues for generating install export files when using LLVM_DISTRIBUTION_COMPONENTS. For example, clang has a lot of LLVM library dependencies, which are currently added as interface dependencies. If clang is in the distribution components but the LLVM libraries it depends on aren't (which is a perfectly legitimate use case if the LLVM libraries are being built static and there are therefore no run-time dependencies on them), CMake will complain about the LLVM libraries not being in export set when attempting to generate the install export file for clang. This is reasonable behavior on CMake's part, and the right thing is for LLVM's build system to explicitly use PRIVATE dependencies for executables. Unfortunately, CMake doesn't allow you to mix and match the keyword and non-keyword target_link_libraries signatures for a single target; i.e., if a single call to target_link_libraries for a particular target uses one of the INTERFACE, PRIVATE, or PUBLIC keywords, all other calls must also be updated to use those keywords. This means we must do this change in a single shot. I also fully expect to have missed some instances; I tested by enabling all the projects in the monorepo (except dragonegg), and configuring both with and without shared libraries, on both Darwin and Linux, but I'm planning to rely on the buildbots for other configurations (since it should be pretty easy to fix those). Even after this change, we still have a lot of target_link_libraries calls that don't specify a scope keyword, mostly for shared libraries. I'm thinking about addressing those in a follow-up, but that's a separate change IMO. Differential Revision: https://reviews.llvm.org/D40823 llvm-svn: 319840
* [libclang] Store unsaved file hashes when recording parsing invocationsAlex Lorenz2017-12-053-4/+24
| | | | | | | | | | | | Storing the contents of unsaved files is too expensive. Instead a hash is stored with a record invocation. When a reproducer is generated, Clang will compare the stored hashes to the new hashes to determine if the contents of a file has changed. This way we'll know when a reproducer was generated for a different source to the one that triggered the original crash. rdar://35322543 llvm-svn: 319729
* [libclang] Record parsing invocation to a temporary file when requestedAlex Lorenz2017-12-045-0/+99
| | | | | | | | | | | | | | | | | | by client This patch extends libclang by allowing it to record parsing operations to a temporary JSON file. The file is deleted after parsing succeeds. When a crash happens during parsing, the file is preserved and the client will be able to use it to generate a reproducer for the crash. These files are not emitted by default, and the client has to specify the invocation emission path first. rdar://35322543 Differential Revision: https://reviews.llvm.org/D40527 llvm-svn: 319702
* Now that C++17 is official (https://www.iso.org/standard/68564.html), start ↵Aaron Ballman2017-12-041-1/+1
| | | | | | changing the C++1z terminology over to C++17. NFC intended, these are all mechanical changes. llvm-svn: 319688
* Fix assume-filename handling in clang-format.elPhilipp Stephani2017-12-021-16/+29
| | | | | | | | | | | | | | | | | | | | | Summary: When 'buffer-file-name' is nil 'call-process-region' returned a segmentation fault error. This was a problem when using clang-format-buffer on an orgmode source code editing buffer. I fixed this problem by excluding the '-assume-filename' argument when 'buffer-file-name' is nil. To make it a bit more flexible I also added an optional argument, 'assume-file-name', to specify an assume-filename that overrides 'buffer-file-name'. Reviewers: klimek, djasper, phst, phi Reviewed By: phst, phi Subscribers: phi, jholewinski, mgorny, javed.absar, eraman, cfe-commits Differential Revision: https://reviews.llvm.org/D37903 llvm-svn: 319621
* [clang] Use add_llvm_install_targetsShoaib Meenai2017-11-302-10/+5
| | | | | | | | | | Use this function to create the install targets rather than doing so manually, which gains us the `-stripped` install targets to perform stripped installations. Differential Revision: https://reviews.llvm.org/D40675 llvm-svn: 319489
* [SourceLocations] Use stronger sort predicate to remove non-deterministic ↵Mandeep Singh Grang2017-11-291-2/+3
| | | | | | | | | | | | | | | | | | ordering Summary: This fixes the following failure uncovered by D39245: Clang :: Index/getcursor-preamble.m Reviewers: gbenyei, akyrtzi, bkramer, arphaman Reviewed By: arphaman Subscribers: arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D40618 llvm-svn: 319357
* Refactor functions PrintTemplateArgumentListSerge Pavlov2017-11-281-3/+3
| | | | | | | | | | | These functions were defined as static members of TemplateSpecializationType. Now they are moved to namespace level. Previously there were different implementations for lists containing TemplateArgument and TemplateArgumentLoc, now these implementations share the same code. This change is a result of refactoring patch D40508. NFC. llvm-svn: 319178
* [libclang] Fix cursors for in-class initializer of field declarationsBenjamin Kramer2017-11-151-0/+3
| | | | | | | | | | Fixes PR33745. Patch by Nikolai Kosjar! Differential Revision: https://reviews.llvm.org/D40027 llvm-svn: 318292
* [libclang] Allow crash recovery with LIBCLANG_NOTHREADSErik Verbruggen2017-11-143-28/+2
| | | | | | | | | | | Enabled crash recovery for some libclang operations on a calling thread even when LIBCLANG_NOTHREAD is specified. Previously it would only run under crash recovery if LIBCLANG_NOTHREAD is not set. Moved handling of LIBCLANG_NOTHREAD env variable into RunSafely from its call sites. llvm-svn: 318142
* [clang-refactor] Introduce a new rename rule for qualified symbolsHaojian Wu2017-11-081-40/+35
| | | | | | | | | | | | | | Summary: Prototype of a new rename rule for renaming qualified symbol. Reviewers: arphaman, ioeric, sammccall Reviewed By: arphaman, sammccall Subscribers: jklaehn, cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D39332 llvm-svn: 317672
* [clang-refactor] Use ClangTool more explicitly by making refaroing actions ↵Eric Liu2017-11-071-126/+192
| | | | | | | | | | | | | | | | AST frontend actions. Summary: This is a refactoring change. NFC Reviewers: arphaman, hokein Reviewed By: arphaman, hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D39675 llvm-svn: 317577
* [clang-diff] NFC: formatJohannes Altmanninger2017-11-051-3/+3
| | | | llvm-svn: 317434
* Move the libclang-headers project into the Misc folder on IDEs like Visual ↵Aaron Ballman2017-11-041-0/+1
| | | | | | Studio rather than leave it in the root directory. NFC. llvm-svn: 317417
* Fix clang-format CLion integration bug.Eric Liu2017-11-021-1/+1
| | | | | | | | | | | | | CLion's Sax parser threw this error: Failed to parse clang-format XML replacements. Input: <?xml version='1.0'?> <replacements xml:space='preserve' incomplete_format='true' line=89> [...] [org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 66; Open quote is expected for attribute "line" associated with an element type "replacements".] Patch by Justine Tunney (jart@google.com)! llvm-svn: 317205
* [libclang] Add dummy libclang-headers targetShoaib Meenai2017-11-021-0/+5
| | | | | | | | | | `LLVM_DISTRIBUTION_COMPONENTS` assumes that each component has both `component` and `install-component` targets. Add a dummy no-op target for `libclang-headers` to placate this check. Differential Revision: https://reviews.llvm.org/D39524 llvm-svn: 317188
* [clang-rename] Use add_clang_toolShoaib Meenai2017-11-021-3/+1
| | | | | | | | | | `add_clang_tool` includes a call to `add_clang_executable`, but it also sets up the install rule, and adds an `install-*` target. The latter is required for using `LLVM_DISTRIBUTION_COMPONENTS`. Differential Revision: https://reviews.llvm.org/D39522 llvm-svn: 317150
* [clang-refactor] Use add_clang_tool CMake templatePetr Hosek2017-10-251-1/+1
| | | | | | | | | This allows including clang-refactor in LLVM_DISTRIBUTION_COMPONENTS to build clang-refactor as part of the toolchain distribution. Differential Revision: https://reviews.llvm.org/D39266 llvm-svn: 316540
* [refactor] Initial outline of implementation of "extract function" refactoringAlex Lorenz2017-10-241-11/+54
| | | | | | | | | | | | | | | | | | | This commit adds an initial, skeleton outline of the "extract function" refactoring. The extracted function doesn't capture variables / rewrite code yet, it just basically does a simple copy-paste. The following initiation rules are specified: - extraction can only be done for executable code in a function/method/block. This means that you can't extract a global variable initialize into a function right now. - simple literals and references are not extractable. This commit also adds support for full source ranges to clang-refactor's test mode. Differential Revision: https://reviews.llvm.org/D38982 llvm-svn: 316465
* Reverting r316278 due to failing build bots.Aaron Ballman2017-10-211-1/+2
| | | | | | | http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/11896 http://lab.llvm.org:8011/builders/clang-s390x-linux/builds/12380 llvm-svn: 316279
* [libclang, bindings]: add spelling locationMasud Rahman2017-10-211-2/+1
| | | | | | | | | | | | | | | | | | o) Add a 'Location' class that represents the four properties of a physical location o) Enhance 'SourceLocation' to provide 'expansion' and 'spelling' locations, maintaining backwards compatibility with existing code by forwarding the four properties to 'expansion'. o) Update the implementation to use 'clang_getExpansionLocation' instead of the deprecated 'clang_getInstantiationLocation', which has been present since 2011. o) Update the implementation of 'clang_getSpellingLocation' to actually obtain spelling location instead of file location. llvm-svn: 316278
* [clang-refactor] Add "-Inplace" option to the commandline tool.Haojian Wu2017-10-201-6/+16
| | | | | | | | | | | | | | | | | Summary: Change clang-refactor default behavior to print the new code after refactoring (instead of editing the source files), which would make it easier to use and debug the refactoring action. Reviewers: arphaman, ioeric Reviewed By: arphaman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D39092 llvm-svn: 316212
OpenPOWER on IntegriCloud