summaryrefslogtreecommitdiffstats
path: root/clang/lib
Commit message (Collapse)AuthorAgeFilesLines
* [analyzer] Treat std::{move,forward} as casts in ExprMutationAnalyzer.Shuai Wang2018-09-171-2/+13
| | | | | | | | | | | | | | | Summary: This is a follow up of D52008 and should make the analyzer being able to handle perfect forwardings in real world cases where forwardings are done through multiple layers of function calls with `std::forward`. Fixes PR38891. Reviewers: lebedev.ri, JonasToth, george.karpenkov Subscribers: xazax.hun, szepet, a.sidorin, mikhail.ramalho, Szelethus, cfe-commits Differential Revision: https://reviews.llvm.org/D52120 llvm-svn: 342409
* [ASTImporter] Fix import of VarDecl initGabor Marton2018-09-171-53/+68
| | | | | | | | | | | | | | | | | | Summary: The init expression of a VarDecl is overwritten in the "To" context if we import a VarDecl without an init expression (and with a definition). Please refer to the added tests, especially InitAndDefinitionAreInDifferentTUs. This patch fixes the malfunction by importing the whole Decl chain similarly as we did that in case of FunctionDecls. We handle the init expression similarly to a definition, alas only one init expression will be in the merged ast. Reviewers: a_sidorin, xazax.hun, r.stahl, a.sidorin Subscribers: rnkovacs, dkrupp, cfe-commits Differential Revision: https://reviews.llvm.org/D51597 llvm-svn: 342384
* [OpenCL] Allow blocks to capture arrays in OpenCLAndrew Savonichev2018-09-171-2/+4
| | | | | | | | | | | | | | Summary: Patch by Egor Churaev Reviewers: Anastasia, yaxunl Reviewed By: Anastasia Subscribers: asavonic, bader, cfe-commits Differential Revision: https://reviews.llvm.org/D51722 llvm-svn: 342370
* Merge two attribute diagnostics into oneAndrew Savonichev2018-09-172-2/+3
| | | | | | | | | | | | | | | | | | Summary: Merged the recently added `err_attribute_argument_negative` diagnostic with existing `err_attribute_requires_positive_integer` diagnostic: the former allows only strictly positive integer, while the latter also allows zero. Reviewers: aaron.ballman Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D51853 llvm-svn: 342367
* [clang-Format] Fix indentation of member call after blockIlya Biryukov2018-09-172-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: before patch: > echo "test() {([]() -> {int b = 32;return 3;}).as("");});" | clang-format -style=Google ``` test() { ([]() -> { int b = 32; return 3; }) .as(); }); ``` after patch: > echo "test() {([]() -> {int b = 32;return 3;}).as("");});" | clang-format -style=Google ``` test() { ([]() -> { int b = 32; return 3; }).as(); }); ``` Patch by Anders Karlsson (ank)! Reviewers: klimek Reviewed By: klimek Subscribers: danilaml, acoomans, klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D45719 llvm-svn: 342363
* [NFC] Minor refactoring to setup the stage for supporting pointers in ↵Shuai Wang2018-09-161-43/+86
| | | | | | ExprMutationAnalyzer llvm-svn: 342353
* [NFC] cosmetic tweaks to ExprMutationAnalyzer to be more consistentShuai Wang2018-09-151-13/+12
| | | | | | especially considering future changes. llvm-svn: 342340
* [OPENMP] Move OMPClauseReader/Writer classes to ASTReader/Writer (NFC)Kelvin Li2018-09-154-1370/+1336
| | | | | | | | | | | | | | Move declarations for OMPClauseReader, OMPClauseWriter to ASTReader.h and ASTWriter.h and move implementation to ASTReader.cpp and ASTWriter.cpp. This change helps generalize the serialization of OpenMP clauses and will be used in the future implementation of new OpenMP directives (e.g. requires). Patch by Patrick Lyster Differential Revision: https://reviews.llvm.org/D52097 llvm-svn: 342322
* [analyzer] Further printing improvements: use declarations,George Karpenkov2018-09-155-15/+15
| | | | | | | | skip pointers whenever redundant, use unique prefixes. Differential Revision: https://reviews.llvm.org/D52114 llvm-svn: 342316
* Generate unique identifiers for Decl objectsGeorge Karpenkov2018-09-151-0/+7
| | | | | | | | | The generated identifier is stable across multiple runs, and can be a great visualization or debugging aide. Differential Revision: https://reviews.llvm.org/D52113 llvm-svn: 342315
* [analyzer] Generate and use stable identifiers for LocationContextGeorge Karpenkov2018-09-152-5/+5
| | | | | | | | | | Those are not created in the allocator. Since they are created fairly rarely, a counter overhead should not affect the memory consumption. Differential Revision: https://reviews.llvm.org/D51827 llvm-svn: 342314
* [analyzer] Dump reproducible identifiers for statements in exploded graph in ↵George Karpenkov2018-09-153-12/+17
| | | | | | | | store Differential Revision: https://reviews.llvm.org/D51826 llvm-svn: 342313
* [analyzer] Use correct end-of-line character when printing statements for ↵George Karpenkov2018-09-151-4/+7
| | | | | | | | | | exploded graph Prevents bad centering. Differential Revision: https://reviews.llvm.org/D51825 llvm-svn: 342312
* StmtPrinter: allow customizing the end-of-line characterGeorge Karpenkov2018-09-152-54/+57
| | | | | | Differential Revision: https://reviews.llvm.org/D51824 llvm-svn: 342311
* [analyzer] Dump unique identifiers for statements in exploded graphGeorge Karpenkov2018-09-151-18/+13
| | | | | | Differential Revision: https://reviews.llvm.org/D51823 llvm-svn: 342310
* Support generating unique identifiers for Stmt objectsGeorge Karpenkov2018-09-151-0/+8
| | | | | | | | | The generated identifiers are stable across multiple runs, and can be a great debug or visualization aid. Differential Revision: https://reviews.llvm.org/D51822 llvm-svn: 342309
* [analyzer] Skip printing duplicate nodes, even if nodes have multiple ↵George Karpenkov2018-09-151-1/+6
| | | | | | | | | | predecessors/successors Still generate a node, but leave the redundant field empty. Differential Revision: https://reviews.llvm.org/D51821 llvm-svn: 342308
* [modules] Don't bother creating a global module fragment when building aRichard Smith2018-09-151-1/+3
| | | | | | header module. llvm-svn: 342307
* [modules] Support use of -E on modules built from the command line.Richard Smith2018-09-153-10/+9
| | | | llvm-svn: 342306
* [modules] Driver support for precompiling a collection of files as a singleRichard Smith2018-09-155-36/+141
| | | | | | action. llvm-svn: 342305
* [modules] Frontend support for building a header module from a list ofRichard Smith2018-09-158-29/+139
| | | | | | headaer files. llvm-svn: 342304
* [analyzer] Handle forwarding reference better in ExprMutationAnalyzer.Shuai Wang2018-09-141-2/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: We used to treat an `Expr` mutated whenever it's passed as non-const reference argument to a function. This results in false positives in cases like this: ``` int x; std::vector<int> v; v.emplace_back(x); // `x` is passed as non-const reference to `emplace_back` ``` In theory the false positives can be suppressed with `v.emplace_back(std::as_const(x))` but that's considered overly verbose, inconsistent with existing code and spammy as diags. This diff handles such cases by following into the function definition and see whether the argument is mutated inside. Reviewers: lebedev.ri, JonasToth, george.karpenkov Subscribers: xazax.hun, szepet, a.sidorin, mikhail.ramalho, Szelethus, cfe-commits Differential Revision: https://reviews.llvm.org/D52008 llvm-svn: 342271
* Remove PseudoConstantAnalysisShuai Wang2018-09-143-234/+0
| | | | | | | | | | Summary: It's not used anywhere for years. The last usage is removed in https://reviews.llvm.org/rL198476 in 2014. Subscribers: mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D51946 llvm-svn: 342246
* [clang-cl] Fix PR38934: failing to dllexport class template member w/ ↵Hans Wennborg2018-09-141-0/+8
| | | | | | | | | | | | explicit instantiation and PCH The code in ASTContext::DeclMustBeEmitted was supposed to handle this, but didn't take into account that synthesized members such as operator= might not get marked as template specializations, because they're synthesized on the instantiation directly when handling the class-level dllexport attribute. llvm-svn: 342240
* [clang] Make sure attributes on member classes are applied properlyLouis Dionne2018-09-141-0/+6
| | | | | | | | | | | | | | | | | | | | | | | Summary: Attributes on member classes of class templates and member class templates of class templates are not currently instantiated. This was discovered by Richard Smith here: http://lists.llvm.org/pipermail/cfe-dev/2018-September/059291.html This commit makes sure that attributes are instantiated properly. This commit does not fix the broken behavior for member partial and explicit specializations of class templates. PR38913 Reviewers: rsmith Subscribers: dexonsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D51997 llvm-svn: 342238
* [VFS] vfs::directory_iterator yields path and file type instead of full StatusSam McCall2018-09-148-72/+63
| | | | | | | | | | | | | | | | | | | | | | | Summary: Most callers I can find are using only `getName()`. Type is used by the recursive iterator. Now we don't have to call stat() on every listed file (on most platforms). Exceptions are e.g. Solaris where readdir() doesn't include type information. On those platforms we'll still stat() - see D51918. The result is significantly faster (stat() can be slow). My motivation: this may allow us to improve clang IO on large TUs with long include search paths. Caching readdir() results may allow us to skip many stat() and open() operations on nonexistent files. Reviewers: bkramer Subscribers: fedor.sergeev, cfe-commits Differential Revision: https://reviews.llvm.org/D51921 llvm-svn: 342232
* [Driver] Fix missing MultiArch include dir on powerpcspeKristina Brooks2018-09-141-1/+2
| | | | | | | | | | | | On powerpc-linux-gnuspe, the header files are located in their own include directory named /usr/lib/powerpc-linux-gnuspe, so add this directory to PPCMultiarchIncludeDirs. Patch by glaubitz (John Paul Adrian Glaubitz) Differential Revision: https://reviews.llvm.org/D52066 llvm-svn: 342231
* [Tooling] JSONCompilationDatabasePlugin infers compile commands for missing ↵Sam McCall2018-09-141-1/+4
| | | | | | | | | | | | | | | | files Summary: See the existing InterpolatingCompilationDatabase for details on how this works. We've been using this in clangd for a while, the heuristics seem to work well. Reviewers: bkramer Subscribers: ilya-biryukov, ioeric, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D51729 llvm-svn: 342228
* [analyzer] Restore final on NeedsCastLocField. NFCIlya Biryukov2018-09-141-1/+1
| | | | | | To fix compiler warning about non-virtual dtor introduced in r342221. llvm-svn: 342225
* [analyzer][UninitializedObjectChecker] Support for nonloc::LocAsIntegerKristof Umann2018-09-142-14/+23
| | | | | | Differential Revision: https://reviews.llvm.org/D49437 llvm-svn: 342221
* [analyzer][UninitializedObjectChecker] New flag to ignore records based on ↵Kristof Umann2018-09-142-5/+39
| | | | | | | | | | | | | | | | | it's fields Based on a suggestion from @george.karpenkov. In some cases, structs are used as unions with a help of a tag/kind field. This patch adds a new string flag (a pattern), that is matched against the fields of a record, and should a match be found, the entire record is ignored. For more info refer to http://lists.llvm.org/pipermail/cfe-dev/2018-August/058906.html and to the responses to that, especially http://lists.llvm.org/pipermail/cfe-dev/2018-August/059215.html. Differential Revision: https://reviews.llvm.org/D51680 llvm-svn: 342220
* [analyzer][UninitializedObjectChecker] Refactored checker optionsKristof Umann2018-09-143-59/+63
| | | | | | | | | | | | | Since I plan to add a number of new flags, it made sense to encapsulate them in a new struct, in order not to pollute FindUninitializedFields's constructor with new boolean options with super long names. This revision practically reverts D50508, since FindUninitializedFields now accesses the pedantic flag anyways. Differential Revision: https://reviews.llvm.org/D51679 llvm-svn: 342219
* [analyzer][UninitializedObjectChecker] Correct dynamic type is acquired for ↵Kristof Umann2018-09-141-0/+8
| | | | | | | | record pointees Differential Revision: https://reviews.llvm.org/D50892 llvm-svn: 342217
* [analyzer][UninitializedObjectChecker] Updated commentsKristof Umann2018-09-143-74/+67
| | | | | | | | | | | | | Some of the comments are incorrect, imprecise, or simply nonexistent. Since I have a better grasp on how the analyzer works, it makes sense to update most of them in a single swoop. I tried not to flood the code with comments too much, this amount feels just right to me. Differential Revision: https://reviews.llvm.org/D51417 llvm-svn: 342215
* [analyzer][UninitializedObjectChecker] Fixed dereferencingKristof Umann2018-09-143-77/+86
| | | | | | | | | | iThis patch aims to fix derefencing, which has been debated for months now. Instead of working with SVals, the function now relies on TypedValueRegion. Differential Revision: https://reviews.llvm.org/D51057 llvm-svn: 342213
* [XRay][clang] Emit "never-instrument" attributeDean Michael Berris2018-09-142-15/+12
| | | | | | | | | | | | | | | | | | | | | | | Summary: Before this change, we only emit the XRay attributes in LLVM IR when the -fxray-instrument flag is provided. This may cause issues with thinlto when the final binary is being built/linked with -fxray-instrument, and the constitutent LLVM IR gets re-lowered with xray instrumentation. With this change, we can honour the "never-instrument "attributes provided in the source code and preserve those in the IR. This way, even in thinlto builds, we retain the attributes which say whether functions should never be XRay instrumented. This change addresses llvm.org/PR38922. Reviewers: mboerger, eizan Subscribers: mehdi_amini, dexonsmith, cfe-commits, llvm-commits Differential Revision: https://reviews.llvm.org/D52015 llvm-svn: 342200
* [ODRHash] Fix early exit that skipped code.Richard Trieu2018-09-141-3/+9
| | | | | | | | | | There is a bit of code at the end of AddDeclaration that should be run on every exit of the function. However, there was an early exit beforehand that could be triggered, which causes a small amount of data to skip the hashing, leading to false positive mismatch. Use a separate function so that this code is always run. llvm-svn: 342199
* [Sema] Remove location from implicit capture init exprVedant Kumar2018-09-131-6/+7
| | | | | | | | | | | | | | | | | | A lambda's closure is initialized when the lambda is declared. For implicit captures, the initialization code emitted from EmitLambdaExpr references source locations *within the lambda body* in the function containing the lambda. This results in a poor debugging experience: we step to the line containing the lambda, then into lambda, out again, over and over, until every capture's field is initialized. To improve stepping behavior, assign the starting location of the lambda to expressions which initialize an implicit capture within it. rdar://39807527 Differential Revision: https://reviews.llvm.org/D50927 llvm-svn: 342194
* Fix crash on call to __builtin_memcpy with a null pointer to anRichard Smith2018-09-132-8/+30
| | | | | | | | incomplete type. Also improve the diagnostics for similar situations. llvm-svn: 342192
* Diagnose likely typos in #include directives.Richard Smith2018-09-131-1/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: When someone writes #include "<some_file>" or #include " some_file " the compiler returns "file not fuond..." with fonts and quotes that may make it hard to see there are excess quotes or surprising bytes in the filename. Assuming that files are usually logically named and start and end with an alphanumeric character, we can check for the file's existence by stripping the non-alphanumeric leading or trailing characters. If the file is found, emit a non-fatal error with a FixItHint. Patch by Christy Lee! Reviewers: aaron.ballman, erikjv, rsmith Reviewed By: rsmith Subscribers: lebedev.ri, xbolva00, sammccall, modocache, erikjv, aaron.ballman, cfe-commits Differential Revision: https://reviews.llvm.org/D51333 llvm-svn: 342177
* Support -fno-omit-frame-pointer with -pg.Stephen Hines2018-09-131-1/+2
| | | | | | | | | | | | | | | | | | Summary: Previously, any instance of -fomit-frame-pointer would make it such that -pg was an invalid flag combination. If -fno-omit-frame-pointer is passed later on the command line (such that it actually takes effect), -pg should be allowed. Reviewers: nickdesaulniers Reviewed By: nickdesaulniers Subscribers: manojgupta, nickdesaulniers, cfe-commits, kongyi, chh, pirama Differential Revision: https://reviews.llvm.org/D51713 llvm-svn: 342165
* [NFC]Refactor MultiVersion Resolver Emission to combine typesErich Keane2018-09-133-93/+75
| | | | | | | | | Previously, both types (plus the future target-clones) of multiversioning had a separate ResolverOption structure and emission function. This patch combines the two, at the expense of a slightly more expensive sorting function. llvm-svn: 342152
* [OPENMP] Fix PR38903: Crash on instantiation of the non-dependentAlexey Bataev2018-09-137-62/+93
| | | | | | | | | | | declare reduction. If the declare reduction construct with the non-dependent type is defined in the template construct, the compiler might crash on the template instantition. Reworked the whole instantiation scheme for the declare reduction constructs to fix this problem correctly. llvm-svn: 342151
* Print correctly dependency paths on WindowsDavid Bolvansky2018-09-131-9/+13
| | | | | | | | | | | | | | | | | | | Summary: Before: main.o: main.c ../include/lib\test.h After: main.o: main.c ../include/lib/test.h Fixes PR38877 Reviewers: zturner Subscribers: xbolva00, cfe-commits Differential Revision: https://reviews.llvm.org/D51847 llvm-svn: 342139
* [AArch64] Enable return address signing for static ctorsOliver Stannard2018-09-131-0/+6
| | | | | | | | | | | Functions generated by clang and included in the .init_array section (such as static constructors) do not follow the usual code path for adding target-specific function attributes, so we have to add the return address signing attribute here too, as is currently done for the sanitisers. Differential revision: https://reviews.llvm.org/D51418 llvm-svn: 342126
* Fix MSVC "illegal conversion; more than one user-defined conversion has been ↵Simon Pilgrim2018-09-131-1/+1
| | | | | | implicitly applied" warning. NFCI. llvm-svn: 342125
* [clang-format] Wrapped block after case label should not be merged into one lineOwen Pan2018-09-131-0/+4
| | | | | | | | PR38854 Differential Revision: http://reviews.llvm.org/D51719 llvm-svn: 342116
* [AArch64] Support reserving x1-7 registers.Tri Vo2018-09-121-0/+21
| | | | | | | | | | | | | | Summary: Reserving registers x1-7 is used to support CONFIG_ARM64_LSE_ATOMICS in Linux kernel. This change adds support for reserving registers x1 through x7. Reviewers: javed.absar, efriedma, nickdesaulniers, srhines, phosek Reviewed By: nickdesaulniers Subscribers: manojgupta, jfb, cfe-commits, kristof.beyls Differential Revision: https://reviews.llvm.org/D48581 llvm-svn: 342100
* Remove dead code made unnecessary by r342018.Richard Smith2018-09-121-7/+0
| | | | llvm-svn: 342098
* Track definition merging on the canonical declaration even when localRichard Smith2018-09-124-28/+12
| | | | | | | | | | | | | | submodule visibility is disabled. Attempting to pick a specific declaration to make visible when the module containing the merged declaration becomes visible is error-prone, as we don't yet know which declaration we'll choose to be the definition when we are informed of the merging. This reinstates r342019, reverted in r342020. The regression previously observed after this commit was fixed in r342096. llvm-svn: 342097
OpenPOWER on IntegriCloud