aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests
AgeCommit message (Collapse)Author
2020-12-09Revert "[clang][cli] CompilerInvocationTest: add tests for boolean options"Jan Svoboda
Differential Revision of original patch: https://reviews.llvm.org/D92774
2020-12-09[clang][cli] CompilerInvocationTest: add tests for boolean optionsJan Svoboda
Add more tests of the command line marshalling infrastructure. The new tests now make a "round-trip": from arguments, to CompilerInvocation instance to arguments again in a single test case. The TODOs are resolved in a follow-up patch. Depends on D92830. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D92774
2020-12-09[clang][cli] CompilerInvocationTest: join and add test casesJan Svoboda
Depends on D92829. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D92830
2020-12-09[clang][cli] CompilerInvocationTest: check arg parsing does not produce ↵Jan Svoboda
diagnostics Depends on D92828. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D92829
2020-12-09[clang][cli] CompilerInvocationTest: remove unnecessary command line argumentsJan Svoboda
Depends on D92827. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D92828
2020-12-09[clang][cli] CompilerInvocationTest: split enum test into twoJan Svoboda
Depends on D92826. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D92827
2020-12-09[clang][cli] CompilerInvocationTest: rename member variable in fixtureJan Svoboda
Depends on D92825. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D92826
2020-12-09[clang][cli] CompilerInvocationTest: join two test fixtures into oneJan Svoboda
Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D92825
2020-12-08Basic: Add hashing support for FileEntryRef and DirectoryEntryRefDuncan P. N. Exon Smith
Allow hashing FileEntryRef and DirectoryEntryRef via `hash_value`, and use that to implement `DenseMapInfo`. This hash should be equal whenever the entry is the same (the name used to reference it is not relevant). Also add `DirectoryEntryRef::isSameRef` to simplify the implementation and facilitate testing. Differential Revision: https://reviews.llvm.org/D92627
2020-12-07[libTooling] Add `describe` combinator for formatting AST nodes for diagnostics.Yitzhak Mandelbaum
This new stencil combinator is intended for use in diagnostics and the like. Differential Revision: https://reviews.llvm.org/D92658
2020-12-07Add ability to load a FixedCompilationDatabase from a buffer.Sam McCall
Previously, loading one from a file meant allowing the library to do the IO. Clangd would prefer to do such IO itself (e.g. to allow caching). Differential Revision: https://reviews.llvm.org/D92640
2020-12-05[clang-format] Add option for case sensitive regexes for sorted includesmydeveloperday
I think the title says everything. Reviewed By: MyDeveloperDay Patch By: HazardyKnusperkeks Differential Revision: https://reviews.llvm.org/D91507
2020-12-05[clang-format] [NFC] keep clang-format tests clang-format cleanmydeveloperday
I use several of the clang-format clean directories as a test suite, this one had got slightly out of wack in a prior commit Reviewed By: HazardyKnusperkeks Differential Revision: https://reviews.llvm.org/D92666
2020-12-04[Tooling] JSONCompilationDatabase::loadFromBuffer retains the buffer, copy it.Sam McCall
This function doesn't seem to be used in-tree outside tests. However clangd wants to use it soon, and having the CDB be self-contained seems reasonable. Differential Revision: https://reviews.llvm.org/D92646
2020-12-04[clang-format] Improve clang-formats handling of conceptsmydeveloperday
This is a starting point to improve the handling of concepts in clang-format. There is currently no real formatting of concepts and this can lead to some odd formatting, e.g. Reviewed By: mitchell-stellar, miscco, curdeius Differential Revision: https://reviews.llvm.org/D79773
2020-12-03[Clang][Sema] Attempt to fix CTAD faulty copy of non-local typedefsGabor Marton
http://lists.llvm.org/pipermail/cfe-dev/2020-November/067252.html Differential Revision: https://reviews.llvm.org/D92101
2020-12-03[clang-format] De-duplicate includes with leading or trailing whitespace.Marek Kurdej
This fixes PR46555 (https://bugs.llvm.org/show_bug.cgi?id=46555). Reviewed By: MyDeveloperDay Differential Revision: https://reviews.llvm.org/D88296
2020-12-01s/instantate/instantiate/ throughout. NFCI.Arthur O'Dwyer
The static_assert in "libcxx/include/memory" was the main offender here, but then I figured I might as well `git grep -i instantat` and fix all the instances I found. One was in user-facing HTML documentation; the rest were in comments or tests.
2020-12-01[clang-format] Add new option PenaltyIndentedWhitespaceMark Nauwelaerts
Reviewed By: MyDeveloperDay Differential Revision: https://reviews.llvm.org/D90534
2020-12-01[clang][cli] Port Frontend option flags to new option parsing systemJan Svoboda
Depends on D91861. Reviewed By: dexonsmith Original patch by Daniel Grumberg. Differential Revision: https://reviews.llvm.org/D83697
2020-12-01[clang][cli] Split DefaultAnyOf into a default value and ImpliedByAnyOfJan Svoboda
This makes the options API composable, allows boolean flags to imply non-boolean values and makes the code more logical (IMO). Differential Revision: https://reviews.llvm.org/D91861
2020-11-30Remove dead code added in ac49500cd0484e1b2dcf37fa4c0dade6f113c2c9, NFCDuncan P. N. Exon Smith
This was a copy/paste bug; `M0` is never referenced later.
2020-11-30FileManager: Add FileEntryRef::getDir, returning DirectoryEntryRefDuncan P. N. Exon Smith
Add `FileEntryRef::getDir`, which returns a `DirectoryEntryRef`. This includes a few changes: - Customize `OptionalStorage` so that `Optional<DirectoryEntryRef>` is pointer-sized (like the change made to `Optional<FileEntryRef>`). Factored out a common class, `FileMgr::MapEntryOptionalStorage`, to reduce the code duplication. - Store an `Optional<DirectoryEntryRef>` in `FileEntryRef::MapValue`. This is set if and only if `MapValue` has a real `FileEntry`. - Change `FileManager::getFileRef` and `getVirtualFileRef` to use `getDirectoryRef` and store it in the `StringMap` for `FileEntryRef`. Differential Revision: https://reviews.llvm.org/D90484
2020-11-30[libTooling] Remove deprecated Clang Transformer declarationsYitzhak Mandelbaum
A number of declarations were leftover after the move from `clang::tooling` to `clang::transformer`. This patch removes those declarations and upgrades the handful of references to the deprecated declarations. Differential Revision: https://reviews.llvm.org/D92340
2020-11-30[ASTImporter] Support import of CXXDeductionGuideDeclGabor Marton
CXXDeductionGuideDecl is a FunctionDecl, but its constructor should be called appropriately, at least to set the kind variable properly. Differential Revision: https://reviews.llvm.org/D92109
2020-11-27[ASTImporter] Import the default argument of NonTypeTemplateParmDeclRaphael Isemann
The test case isn't using the AST matchers for all checks as there doesn't seem to be support for matching NonTypeTemplateParmDecl default arguments. Otherwise this is simply importing the default arguments. Reviewed By: martong Differential Revision: https://reviews.llvm.org/D92106
2020-11-26[ASTImporter] Import the default argument of TemplateTypeParmDeclRaphael Isemann
The test case isn't using the AST matchers for all checks as there doesn't seem to be support for matching TemplateTypeParmDecl default arguments. Otherwise this is simply importing the default arguments. Also updates several LLDB tests that now as intended omit the default template arguments of several std templates. Reviewed By: martong Differential Revision: https://reviews.llvm.org/D92103
2020-11-26[ASTImporter] Import the default argument of TemplateTemplateParmDeclRaphael Isemann
Same idea as in D92103 and D92106, but I realised after creating those reviews that there are also TemplateTemplateParmDecls that can have default arguments, so here's hopefully the last patch for default template arguments. Reviewed By: martong Differential Revision: https://reviews.llvm.org/D92119
2020-11-24[ASTImporter] Make the Import() return value consistent with the map of ↵Raphael Isemann
imported decls when merging ClassTemplateSpecializationDecls When importing a `ClassTemplateSpecializationDecl` definition into a TU with a matching `ClassTemplateSpecializationDecl` definition and a more recent forward decl, the ASTImporter currently will call `MapImported()` for the definitions, but will return the forward declaration from the `ASTImporter::Import()` call. This is triggering some assertions in LLDB when we try to fully import some DeclContexts before we delete the 'From' AST. The returned 'To' Decl before this patch is just the most recent forward decl but that's not the Decl with the definition to which the ASTImporter will import the child declarations. This patch just changes that the ASTImporter returns the definition that the imported Decl was merged with instead of the found forward declaration. Reviewed By: martong Differential Revision: https://reviews.llvm.org/D92016
2020-11-23Update mode used in traverse() examplesStephen Kelly
traverse() predates the IgnoreUnlessSpelledInSource mode. Update example and test code to use the newer mode. Differential Revision: https://reviews.llvm.org/D91917
2020-11-23Remove automatic traversal from forEach matcherStephen Kelly
Differential Revision: https://reviews.llvm.org/D91916
2020-11-20Don’t break before nested block param when prior param is not a blockSamuel Giddins
Add ScopedTrace to verify methods in FormatTestObjC Add tests from D17700 Reviewed By: keith, kastiglione Differential Revision: https://reviews.llvm.org/D91669
2020-11-20[libTooling] Update Transformer's `node` combinator to include the trailing ↵Yitzhak Mandelbaum
semicolon for decls. Currently, `node` only includes the semicolon for (some) statements. However, declarations have the same issue of (potentially) trailing semicolons, so `node` should behave the same for them. Differential Revision: https://reviews.llvm.org/D91872
2020-11-18Remove unportable testStephen Kelly
The default content of translation unit varies too much between platforms.
2020-11-17[Transformer] Split ForStmt test into twoStephen Kelly
It is apparently not possible to have two rewrites in one gtest function because atomic changes in the test harness accumulate.
2020-11-17Comment out new test while I figure out what is wrong with itStephen Kelly
2020-11-17[AST] Update matchers to be traverse-awareStephen Kelly
Don't match Stmt or Decl nodes not spelled in the source when using TK_IgnoreUnlessSpelledInSource. This prevents accidental modification of source code at incorrect locations. Differential Revision: https://reviews.llvm.org/D90984
2020-11-17[AST] Ignore implicit nodes in IgnoreUnlessSpelledInSource modeStephen Kelly
Update the ASTNodeTraverser to dump only nodes spelled in source. There are only a few which need to be handled, but Decl nodes for which isImplicit() is true are handled together. Update the RAV instances used in ASTMatchFinder to ignore the nodes too. As with handling of template instantiations, it is necessary to allow the RAV to process the implicit nodes because they need to be visitable before the first traverse() matcher is encountered. An exception to this is in the MatchChildASTVisitor, because we sometimes wish to make a node matchable but make its children not-matchable. This is the case for defaulted CXXMethodDecls for example. Extend TransformerTests to illustrate the kinds of problems that can arise when performing source code rewriting due to matching implicit nodes. This change accounts for handling nodes not spelled in source when using direct matching of nodes, and when using the has() and hasDescendant() matchers. Other matchers such as cxxRecordDecl(hasMethod(cxxMethodDecl())) still succeed for compiler-generated methods for example after this change. Updating the implementations of hasMethod() and other matchers is for a follow-up patch. Differential Revision: https://reviews.llvm.org/D90982
2020-11-16Reland "Move the test compiler setup in a common place. NFCI"Vassil Vassilev
Original commit message: " Move the test compiler setup in a common place. NFCI This patch reduces the copy paste in the unittest/CodeGen folder by moving the common compiler setup phase in a header file. Differential revision: https://reviews.llvm.org/D91061 " This patch includes a fix for the memory leaks pointed out by @vitalybuka
2020-11-16Revert "Move the test compiler setup in a common place. NFCI"Vitaly Buka
There is memory leaks This reverts commit 23cc838099e10b13a32e54105f4db0f1b7e3a842. This reverts commit 888d06dfb8b55c4fd41fa4febe22c6fc4111c118.
2020-11-14Add forgotten in 888d06d file.Vassil Vassilev
2020-11-14Move the test compiler setup in a common place. NFCIVassil Vassilev
This patch reduces the copy paste in the unittest/CodeGen folder by moving the common compiler setup phase in a header file. Differential revision: https://reviews.llvm.org/D91061
2020-11-11[clang-format] do not break before @tags in JS commentsKrasimir Georgiev
In JavaScript breaking before a `@tag` in a comment puts it on a new line, and machinery that parses these comments will fail to understand such comments. This adapts clang-format to not break before `@`. Similar functionality exists for not breaking before `{`. Reviewed By: mprobst Differential Revision: https://reviews.llvm.org/D91078
2020-11-10clang-format: [JS] support new assignment operators.Martin Probst
Before: a && = b; After: a &&= b; These operators are new additions in ES2021. Differential Revision: https://reviews.llvm.org/D91132
2020-11-09Port some floating point options to new option marshalling infrastructureJan Svoboda
This ports a number of OpenCL and fast-math flags for floating point over to the new marshalling infrastructure. As part of this, `Opt{In,Out}FFlag` were enhanced to allow other flags to imply them, via `DefaultAnyOf<>`. For example: ``` defm signed_zeros : OptOutFFlag<"signed-zeros", ..., "LangOpts->NoSignedZero", DefaultAnyOf<[cl_no_signed_zeros, menable_unsafe_fp_math]>>; ``` defines `-fsigned-zeros` (`false`) and `-fno-signed-zeros` (`true`) linked to the keypath `LangOpts->NoSignedZero`, defaulting to `false`, but set to `true` implicitly if one of `-cl-no-signed-zeros` or `-menable-unsafe-fp-math` is on. Note that the initial patch was written Daniel Grumberg. Differential Revision: https://reviews.llvm.org/D82756
2020-11-09[clang] Simplify buildSyntaxTree APIKirill Bobyrev
Follow-up on https://reviews.llvm.org/D88553#inline-837013 Reviewed By: sammccall Differential Revision: https://reviews.llvm.org/D90672
2020-11-09Fix use of directly-nested traverse() matchersStephen Kelly
2020-11-09Fix trailing whitespaceStephen Kelly
My editor keeps on changing this and I keep having to revert it.
2020-11-09[clang-format] avoid introducing multiline commentsKrasimir Georgiev
In C++ with -Werror=comment, multiline comments are not allowed. clang-format could accidentally introduce multiline comments when reflowing. This adapts clang-format to not introduce multiline comments by not allowing a break after `\`. Note that this does not apply to comment lines that already are multiline comments, such as comments in macros. Reviewed By: sammccall Differential Revision: https://reviews.llvm.org/D90949
2020-11-07Fix dumping of explicit template specializationsStephen Kelly
This was missing from commit 7efe07a1 (Traverse-ignore explicit template instantiations, 2020-11-06).