aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests
AgeCommit message (Collapse)AuthorFilesLines
2024-06-10[Clang][Comments] Add argument parsing for @throw @throws @exception (#84726)hdoc1-1/+213
Doxygen allows for the `@throw`, `@throws`, and `@exception` commands to have an attached argument indicating the type being thrown. Currently, Clang's AST parsing doesn't support parsing out this argument from doc comments. The result is missing compatibility with Doxygen. This PR implements parsing of arguments for the `@throw`, `@throws`, and `@exception` commands. Each command can only have one argument, matching the semantics of Doxygen.
2024-06-10[clang-format] Fix a bug in indenting lambda trailing arrows (#94560)c8ef1-0/+16
Closes #94181
2024-06-10[clang][test] Update link for Arm clang-repl test disableDavid Spickett1-1/+1
The original bug is legitimate UB, but this is in the clang constant expression interpreter, not clang-repl. https://github.com/llvm/llvm-project/issues/94994 covers investigation of this specific bug in clang-repl.
2024-06-07[clang][test] Skip interpreter value test on Arm 32 bitDavid Spickett1-0/+4
https://github.com/llvm/llvm-project/pull/89811 caused this test to fail, somehow. I think it may not be at fault, but actually be exposing some existing undefined behaviour, see https://github.com/llvm/llvm-project/issues/94741. Skipping this for now to get the bots green again.
2024-06-07[clangd] Fix crash with null check for Token at Loc (#94528)Utkarsh Saxena1-2/+15
Fixes https://github.com/llvm/llvm-project/issues/94599
2024-06-06[clang-format]: Annotate colons found in inline assembly (#92617)Gedare Bloom1-4/+74
Short-circuit the parsing of tok::colon to label colons found within lines starting with asm as InlineASMColon. Fixes #92616. --------- Co-authored-by: Owen Pan <owenpiano@gmail.com>
2024-06-06[clang-format] Fix a bug in `AlignAfterOpenBracket: DontAlign` (#94561)Owen Pan1-0/+8
Fixes #94555.
2024-06-06[clang][Interp] Member Pointers (#91303)Timm Baeder1-0/+46
This adds a `MemberPointer` class along with a `PT_MemberPtr` primitive type. A `MemberPointer` has a `Pointer` Base as well as a `Decl*` (could be `ValueDecl*`?) decl it points to. For the actual logic, this mainly changes the way we handle `PtrMemOp`s in `VisitBinaryOperator`.
2024-06-05[clang-format] Don't format comments in SkipMacroDefinitionBody (#94425)Owen Pan1-1/+10
Fixes #94326.
2024-06-05Revert "Pass LangOpts from CompilerInstance to DependencyScanningWorker ↵Nishith Kumar M Shah2-71/+14
(#93753)" (#94488) This reverts commit 9862080b1cbf685c0d462b29596e3f7206d24aa2.
2024-06-05[ASTMatchers] forCallable should not erase binding on success (#89657)Marco Borgeaud1-0/+130
Do not erase Builder when the first check fails because it could succeed on the second stack frame. The problem was that `InnerMatcher.matches` erases the bindings when it returns false. The appropriate solution is to pass a copy of the bindings, similar to what `matchesFirstInRange` does.
2024-06-04[clang][dataflow] Propagate storage location of compound assignment ↵martinboehme1-0/+20
operators. (#94332) To avoid generating unnecessary values, we don't create a new value but instead leave it to the specific analysis to do this if desired.
2024-06-04[clang][ASTImport] fix issue on anonymous enum import (#93923)Qizhi Hu1-0/+40
Don't skip searching in `ToContext` during importing `EnumDecl`. And `IsStructuralMatch` in `StructralEquivalence` can make sure to determine whether the found result is match or not. --------- Co-authored-by: huqizhi <836744285@qq.com>
2024-06-04[clang][nullability] Propagate storage location / value of `++`/`--` ↵martinboehme1-0/+36
operators. (#94217) To avoid generating unnecessary values, we don't create a new value but instead leave it to the specific analysis to do this if desired.
2024-06-03[clang-format] Handle AttributeMacros in parseRecord() (#94189)Owen Pan1-0/+8
Fixes #94184.
2024-06-03Pass LangOpts from CompilerInstance to DependencyScanningWorker (#93753)Nishith Kumar M Shah2-14/+71
This commit fixes https://github.com/llvm/llvm-project/issues/88896 by passing LangOpts from the CompilerInstance to DependencyScanningWorker so that the original LangOpts are preserved/respected. This makes for more accurate parsing/lexing when certain language versions or features specific to versions are to be used.
2024-06-03remove goma support from clang (#93942)Takuto Ikuta1-1/+0
goma is deprecated and not maintained anymore. https://chromium.googlesource.com/infra/goma/client/
2024-06-02[clang-format][NFC] Add missing parens of __attribute in unit testsOwen Pan2-13/+13
2024-06-02[clang-format] Handle attributes before lambda return arrow (#94119)Owen Pan2-0/+7
Fixes #92657.
2024-05-30[clang-format] Insert a space between a keyword and a literal (#93632)Owen Pan1-0/+6
Fixes #93603.
2024-05-30[clang-repl] Fix SetUp in CodeCompletionTest fixture (#93816)Stefan Gränitz5-27/+13
And sort out some unused headers
2024-05-30[clang-repl] Introduce common fixture class in unittests (NFC) (#93816)Stefan Gränitz5-295/+186
Reduce code bloat by checking test requirements in a common test fixture
2024-05-30[clang-repl] Even more tests create the Interpreter and must check host JIT ↵Stefan Gränitz2-5/+13
support 2 (#84758)
2024-05-29[clang-format] Fix a regression in annotating class decl braces (#93657)Owen Pan1-0/+5
Fixes #93604.
2024-05-29[clang] Preserve Qualifiers and type sugar in TemplateNames (#93433)Matheus Izvekov1-7/+33
This patch improves the preservation of qualifiers and loss of type sugar in TemplateNames. This problem is analogous to https://reviews.llvm.org/D112374 and this patch takes a very similar approach to that patch, except the impact here is much lesser. When a TemplateName was written bare, without qualifications, we wouldn't produce a QualifiedTemplate which could be used to disambiguate it from a Canonical TemplateName. This had effects in the TemplateName printer, which had workarounds to deal with this, and wouldn't print the TemplateName as-written in most situations. There are also some related fixes to help preserve this type sugar along the way into diagnostics, so that this patch can be properly tested. - Fix dropping the template keyword. - Fix type deduction to preserve sugar in TST TemplateNames.
2024-05-28Fix build: [clang-repl] Even more tests create the Interpreter and must ↵Stefan Gränitz1-0/+8
check host JIT support (#84758) fea7399e97b73a3209fcbe3338d412069769a637 had removed the unused function that was still there when I tested.
2024-05-28[clang-repl] Even more tests create the Interpreter and must check host JIT ↵Stefan Gränitz2-0/+88
support (#84758)
2024-05-28[clang] Fix a warningKazu Hirata1-8/+0
This patch fixes: clang/unittests/Interpreter/IncrementalProcessingTest.cpp:39:13: error: unused function 'HostSupportsJit' [-Werror,-Wunused-function]
2024-05-28[clang-repl] Check host JIT support in all tests that create an Interpreter ↵Stefan Gränitz3-31/+82
(#84758)
2024-05-28[clang-repl] Set up executor implicitly to account for init PTUs (#84758)Stefan Gränitz1-88/+24
Until now the IncrExecutor was created lazily on the first execution request. In order to process the PTUs that come from initialization, we have to do it upfront implicitly.
2024-05-27[clang-format] Add LeftWithLastLine to AlignEscapedNewlines option (#93402)Owen Pan2-0/+22
Closes #92999.
2024-05-27[analyzer] Fix a test issue in mingw configurations (#92737)Martin Storsjö1-1/+1
On Windows, long is always 32 bit, thus one can't use long for casting pointers to integers, on 64 bit architectures. Instead use long long, which should be large enough. This avoids errors like "error: cast from pointer to smaller type 'long' loses information" in this testcase. This condition only seems to be an error in mingw mode; in MSVC mode (clang-cl), this is only a warning.
2024-05-25[clang] Revise IDE folder structure (#89743)Michael Kruse1-1/+1
Update the folder titles for targets in the monorepository that have not seen taken care of for some time. These are the folders that targets are organized in Visual Studio and XCode (`set_property(TARGET <target> PROPERTY FOLDER "<title>")`) when using the respective CMake's IDE generator. * Ensure that every target is in a folder * Use a folder hierarchy with each LLVM subproject as a top-level folder * Use consistent folder names between subprojects * When using target-creating functions from AddLLVM.cmake, automatically deduce the folder. This reduces the number of `set_property`/`set_target_property`, but are still necessary when `add_custom_target`, `add_executable`, `add_library`, etc. are used. A LLVM_SUBPROJECT_TITLE definition is used for that in each subproject's root CMakeLists.txt.
2024-05-23Fix an accidental escape sequence in a unit testAaron Ballman1-1/+1
This amends b49ce9c304b00dae49148b6a2f5f27965000206c
2024-05-23Fix more diagnostic wording for style; NFC (#93190)Aaron Ballman1-9/+10
This tries to fix all of the places where a diagnostic message starts with a capital letter (other than acroynyms or proper nouns) or ends with punctuation (other than a question mark). This is in support of a planned change to tablegen to start diagnosing incorrect diagnostic message styles.
2024-05-22[clang][AST] Fix end location of DeclarationNameInfo on instantiated methods ↵Balazs Benics1-0/+31
(#92654) Fixes #71161 [D64087](https://reviews.llvm.org/D64087) updated some locations of the instantiated method but forgot `DNLoc`. `FunctionDecl::getNameInfo()` constructs a `DeclarationNameInfo` using `Decl::Loc` as the beginning of the declaration name, and `FunctionDecl::DNLoc` to compute the end of the declaration name. The former was updated, but the latter was not, so `DeclarationName::getSourceRange()` would return a range where the end of the declaration name could come before its beginning. Patch by Alejandro Alvarez Ayllon Co-authored-by: steakhal CPP-5166 Co-authored-by: Alejandro Alvarez Ayllon <alejandro.alvarez@sonarsource.com>
2024-05-22[clang] NFCI: use TemplateArgumentLoc for NTTP DefaultArgument (#92852)Matheus Izvekov1-1/+1
This is an enabler for https://github.com/llvm/llvm-project/pull/92855 This allows an NTTP default argument to be set as an arbitrary TemplateArgument, not just an expression. This allows template parameter packs to have default arguments in the AST, even though the language proper doesn't support the syntax for it. This allows NTTP default arguments to be other kinds of arguments, like packs, integral constants, and such.
2024-05-22Reland "[clang] Enable sized deallocation by default in C++14 onwards" (#90373)Pengcheng Wang2-1/+44
Since C++14 has been released for about nine years and most standard libraries have implemented sized deallocation functions, it's time to make this feature default again. This is another try of https://reviews.llvm.org/D112921. The original commit cf5a8b4 was reverted by 2e5035a due to some failures (see #83774). Fixes #60061
2024-05-21[clang-format] Correctly annotate C++ alternative operators in C (#92880)Owen Pan2-0/+56
PR #90161 uncovered a bug that annotates C++ xor as UnaryOperator if followed by a binary operator. This patch fixes that and all other C++ alternative operator keywords when followed by a binary operator in C. Fixes #92688.
2024-05-21[clang] NFCI: use TemplateArgumentLoc for type-param DefaultArgument (#92854)Matheus Izvekov1-1/+1
This is an enabler for a future patch. This allows an type-parameter default argument to be set as an arbitrary TemplateArgument, not just a type. This allows template parameter packs to have default arguments in the AST, even though the language proper doesn't support the syntax for it. This will be used in a later patch which synthesizes template parameter lists with arbitrary default arguments taken from template specializations. There are a few places we used SubsType, because we only had a type, now we use SubstTemplateArgument. SubstTemplateArgument was missing arguments for setting Instantiation location and entity names. Adding those is needed so we don't regress in diagnostics.
2024-05-21[clang][Interp] Fix initializing zero-size arraysTimm Bäder1-2/+22
2024-05-21[clang-format] Fix a bug in formatting goto labels in macros (#92494)Owen Pan2-0/+21
Fixes #92300.
2024-05-20[clang-format][NFC] Remove redundnat llvm::, clang::, etc.Owen Pan25-146/+130
2024-05-20[Clang][Sema] Don't build CXXDependentScopeMemberExprs for potentially ↵Krystian Stasiowski1-2/+4
implicit class member access expressions (#92318) According to [expr.prim.id.general] p2: > If an _id-expression_ `E` denotes a non-static non-type member of some class `C` at a point where the current class is `X` and > - `E` is potentially evaluated or `C` is `X` or a base class of `X`, and > - `E` is not the _id-expression_ of a class member access expression, and > - if `E` is a _qualified-id_, `E` is not the un-parenthesized operand of the unary `&` operator, > > the _id-expression_ is transformed into a class member access expression using `(*this)` as the object expression. Consider the following: ``` struct A { void f0(); template<typename T> void f1(); }; template<typename T> struct B : T { auto g0() -> decltype(T::f0()); // ok auto g1() -> decltype(T::template f1<int>()); // error: call to non-static member function without an object argument }; template struct B<A>; ``` Clang incorrectly rejects the call to `f1` in the _trailing-return-type_ of `g1`. Furthermore, the following snippet results in a crash during codegen: ``` struct A { void f(); }; template<typename T> struct B : T { template<typename U> static void g(); template<> void g<int>() { return T::f(); // crash here } }; template struct B<A>; ``` This happens because we unconditionally build a `CXXDependentScopeMemberExpr` (with an implicit object expression) for `T::f` when parsing the template definition, even though we don't know whether `g` is an implicit object member function yet. This patch fixes these issues by instead building `DependentScopeDeclRefExpr`s for such expressions, and only transforming them into implicit class member access expressions during instantiation. Since we implemented the MS "unqualified lookup into dependent bases" extension by building an implicit class member access (and relying on the first component name of the _nested-name-specifier_ to be looked up in the context of the object expression during instantiation), we instead pre-append a fake _nested-name-specifier_ that refers to the injected-class-name of the enclosing class. This patch also refactors `Sema::BuildQualifiedDeclarationNameExpr` and `Sema::BuildQualifiedTemplateIdExpr`, streamlining their implementation and removing any redundant checks.
2024-05-19[clang-format][NFC] Clean up SortIncludesTest.cppOwen Pan1-972/+970
Wherever applicable, replace EXPECT_EQ with verifyFormat and std::string with StringRef. Also, change a raw string literal to a regular one.
2024-05-17[clang-query] Remove support for srcloc output (#92442)Aaron Ballman3-1702/+0
This functionality was added about three years ago, but has been in a significantly broken state since it was added. It has begun to cause a maintenance burden for work in Clang (largely due to the complexity of having two levels of code generation involved), and the original author is unable to help maintain it. Because it only worked under limited circumstances and because of the maintenance burden, it is being removed. If someone wishes to resurrect the functionality, they should hopefully be able to do so from this one commit. Fixes #82591
2024-05-17[analyzer][NFC] Require explicit matching mode for CallDescriptions (#92454)Donát Nagy6-39/+47
This commit deletes the "simple" constructor of `CallDescription` which did not require a `CallDescription::Mode` argument and always used the "wildcard" mode `CDM::Unspecified`. A few months ago, this vague matching mode was used by many checkers, which caused bugs like https://github.com/llvm/llvm-project/issues/81597 and https://github.com/llvm/llvm-project/issues/88181. Since then, my commits improved the available matching modes and ensured that all checkers explicitly specify the right matching mode. After those commits, the only remaining references to the "simple" constructor were some unit tests; this commit updates them to use an explicitly specified matching mode (often `CDM::SimpleFunc`). The mode `CDM::Unspecified` was not deleted in this commit because it's still a reasonable choice in `GenericTaintChecker` and a few unit tests.
2024-05-16[clang-format] Fix a regression in annotating struct braces (#92352)Owen Pan1-0/+5
Fixes #92350.
2024-05-16[clang-format] Don't always break before << between string literals (#92214)Owen Pan1-0/+11
Instead, leave the line wrapping as is. Fixes #43887. Fixes #44363.
2024-05-16[AST] RecursiveASTVisitor: Don't traverse the alias deduction guides in the ↵Haojian Wu1-0/+85
default mode. (#91454) By default (`shouldVisitImplicitCode()` returns `false`), RAV should not traverse AST nodes that are not spelled in the source code. Deduction guides for alias templates are always synthesized, so they should not be traversed. This is usually done by checking the implicit bit of the Decl. However, this doesn't work deduction guides that are synthesized from explicit user-defined deduction guides, as we must maintain the explicit bit to ensure correct overload resolution.