aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Parse/ParseDecl.cpp
AgeCommit message (Collapse)AuthorFilesLines
3 days[Sema] Keep attribute lists in the order the attributes were parsed (#162714)Henrik G. Olsson1-11/+11
This renames some attribute list related functions, to make callers think about whether they want to append or prepend to the list, instead of defaulting to prepending which is often not the desired behaviour (for the cases where it matters, sometimes we're just adding to an empty list). Then it adjusts some of these calls to append where they were previously prepending. This has the effect of making `err_attributes_are_not_compatible` consistent in emitting diagnostics as `<new-attr> and <existing-attr> are not compatible`, regardless of the syntax used to apply the attributes.
11 days[clang] Preserve `externs` following broken declarations (#161641)Alejandro Álvarez Ayllón1-0/+3
Treat them as namespaces: if they are at the beginning of the line, they are likely a good recovery point. For instance, in ```cpp 1.3.0 extern "C" { extern int foo(); extern "C++" { namespace bar { void baz(); }; } } namespace {} ``` Everything until `namespace`... is gone from the AST. Headers (like libc's C++ `math.h`) can be included from an `extern "C"` context, and they do an `extern "C++"` back again before including C++ headers (like `__type_traits`). However, a malformed declaration just before the include (as the orphan `1.3.0` in the example) causes everything from these standard headers to go missing. This patch updates the heuristic to try to recover from the first `extern` keyword seen, pretty much as it is done for `namespace`. CPP-4478
2025-09-17[clang][Parse] Use consistent Scope::ScopeFlags enum values (NFC) (#159275)Bruno De Fraine1-6/+7
Commit 438863a changed the underlying type of the Scope::ScopeFlags from int to unsigned. This triggers type mismatch warnings from specific compilers when the enum's values are combined in operations with integer literal 0. Regardless of these warnings, similar code in other places uses Scope::NoScope instead of literal 0. For consistency and to avoid these warnings, we change the uses of literal 0 to Scope::NoScope.
2025-09-15[clang] Allow attributes on first constructor argument in pre-C++11 (#157300)camc1-4/+3
Resolves GH-156809 Modifies decl parser to allow C++11 style [[attributes]] on the first argument in constructors in all C++ standards. They are already allowed on later arguments. --------- Co-authored-by: Shafik Yaghmour <shafik.yaghmour@intel.com>
2025-08-23[clang] Diagnose misplaced array bounds with non-identifier declarators. ↵keinflue1-2/+2
(#155064) ParseMisplacedBracketDeclarator assumed that declarators without associated identifier are ill-formed and already diagnosed previously. This didn't consider declarators using template-ids, constructors, destructors, conversion functions, etc. Fixes #147333.
2025-08-19[clang] Replace SmallSet with SmallPtrSet (NFC) (#154262)Kazu Hirata1-1/+1
This patch replaces SmallSet<T *, N> with SmallPtrSet<T *, N>. Note that SmallSet.h "redirects" SmallSet to SmallPtrSet for pointer element types: template <typename PointeeType, unsigned N> class SmallSet<PointeeType*, N> : public SmallPtrSet<PointeeType*, N> {}; We only have 30 instances that rely on this "redirection", with about half of them under clang/. Since the redirection doesn't improve readability, this patch replaces SmallSet with SmallPtrSet for pointer element types. I'm planning to remove the redirection eventually.
2025-08-18[Clang][Webassembly] Remove unrachable code in ParseTypeQualifierListOpt ↵Shafik Yaghmour1-1/+0
(#153729) Static analysis flagged this goto as unreachable and indeed it is, so removing it.
2025-08-05[HLSL][SPIRV] Add vk::binding attribute (#150957)Steven Perron1-1/+1
The vk::binding attribute allows users to explicitly set the set and binding for a resource in SPIR-V without chaning the "register" attribute, which will be used when targeting DXIL. Fixes https://github.com/llvm/llvm-project/issues/136894
2025-08-04[Clang] Initial support for P2841 (Variable template and concept template ↵Corentin Jabot1-1/+1
parameters) (#150823) This is a first pass at implementing [P2841R7](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2841r7.pdf). The implementation is far from complete; however, I'm aiming to do that in chunks, to make our lives easier. In particular, this does not implement - Subsumption - Mangling - Satisfaction checking is minimal as we should focus on #141776 first (note that I'm currently very stuck) FTM, release notes, status page, etc, will be updated once the feature is more mature. Given the state of the feature, it is not yet allowed in older language modes. Of note: - Mismatches between template template arguments and template template parameters are a bit wonky. This is addressed by #130603 - We use `UnresolvedLookupExpr` to model template-id. While this is pre-existing, I have been wondering if we want to introduce a different OverloadExpr subclass for that. I did not make the change in this patch.
2025-07-23[clang-repl] Always clean up scope and context for TopLevelStmtDecl (#150215)Devajith1-2/+1
This fixes an issue introduced by https://github.com/llvm/llvm-project/pull/84150, where failing to pop compound scope, function scope info, and decl context after a failed statement could lead to an inconsistent internal state.
2025-07-14[clang] NFC, avoid create a new FunctionTypeInfo object in the function call.Haojian Wu1-1/+1
FunctionTypeInfo is a large object, no need to create a new one for this case.
2025-07-08[clang] Consistently handle consteval constructors for variables. (#144970)Eli Friedman1-0/+1
443377a9d1a8d4a69a317a1a892184c59dd0aec6 handled simple variable definitions, but it didn't handle uninitialized variables with a consteval constructor, and it didn't handle template instantiation. Fixes #135281 .
2025-06-24[C23][Parser] Accept single variadic parameter function declarator in type ↵yronglin1-1/+2
name (#145362) Fixs: https://github.com/llvm/llvm-project/issues/145250. This PR makes clang accept single variadic parameter function declarator in type name. Eg. ```c int va_fn(...); // ok // As typeof() argument typeof(int(...))*fn_ptr = &va_fn; // ok // As _Generic association type int i = _Generic(typeof(va_fn), int(...):1); // ok ``` Signed-off-by: yronglin <yronglin777@gmail.com>
2025-06-15[Clang] add fix-it hints for unknown attributes (#141305)Oleksandr T.1-45/+51
This patch adds fix-it hints for unknown attribute names when Clang suggests a correction
2025-06-13Remove delayed typo expressions (#143423)Aaron Ballman1-25/+8
This removes the delayed typo correction functionality from Clang (regular typo correction still remains) due to fragility of the solution. An RFC was posted here: https://discourse.llvm.org/t/rfc-removing-support-for-delayed-typo-correction/86631 and while that RFC was asking for folks to consider stepping up to be maintainers, and we did have a few new contributors show some interest, experiments show that it's likely worth it to remove this functionality entirely and focus efforts on improving regular typo correction. This removal fixes ~20 open issues (quite possibly more), improves compile time performance by roughly .3-.4% (https://llvm-compile-time-tracker.com/?config=Overview&stat=instructions%3Au&remote=AaronBallman&sortBy=date), and does not appear to regress diagnostic behavior in a way we wouldn't find acceptable. Fixes #142457 Fixes #139913 Fixes #138850 Fixes #137867 Fixes #137860 Fixes #107840 Fixes #93308 Fixes #69470 Fixes #59391 Fixes #58172 Fixes #46215 Fixes #45915 Fixes #45891 Fixes #44490 Fixes #36703 Fixes #32903 Fixes #23312 Fixes #69874
2025-06-07[Clang][Parse][NFC] Use `llvm::function_ref<>` instead of ↵Yanzuo Liu1-5/+4
`std::optional<llvm::function_ref<>>` (#142906) There is no need to distinguish between null `optional` and null `function_ref` in this case.
2025-05-28[C] Fix parsing of [[clang::assume]] (#141747)Aaron Ballman1-2/+4
The assumption attribute is exposed with a Clang spelling, which means we support __attribute__((assume)) as well as [[clang::assume]] as spellings for the attribute. In C++, the [[clang::assume]] spelling worked as expected. In C, that spelling would emit an "unknown attribute ignored" diagnostic. This was happening because we were failing to pass in the scope name and source location when creating the attribute. In C++, this worked by chance because [[assume]] is a known attribute in C++. But in C, where there is thankfully no [[assume]] standard attribute, the lack of a scope meant we would set the attribute kind to "unknown".
2025-05-26[Parse] Remove unused includes (NFC) (#141524)Kazu Hirata1-3/+0
These are identified by misc-include-cleaner. I've filtered out those that break builds. Also, I'm staying away from llvm-config.h, config.h, and Compiler.h, which likely cause platform- or compiler-specific build failures.
2025-05-14[Clang] Remove workaround for libstdc++4.7 (#139693)cor3ntin1-3/+4
We document libstdc++4.8 as the minimum supported version, and we carried a hack for `include/tr1/hashtable.h` fixed in 4.7. Cleanup some libstdc++ compatibility comments.
2025-05-14[clang][NFC] Regroup declarations in `Parser` (#138511)Vlad Serebrennikov1-566/+0
Following the steps of #82217, this patch reorganizes declarations in `Parse.h`. Highlights are: 1) Declarations are grouped in the same fashion as in `Sema.h`. Table of contents is provided at the beginning of `Parser` class. `public` declaration go first, then `private` ones, but unlike `Sema`, most of the stuff in `Parser` is private. 2) Documentation has been moved from `.cpp` files to the header. Grammar was consistently put in `\verbatim` blocks to render nicely in Doxygen. 3) File has been formatted with clang-format, except for the grammar, because clang-format butchers it.
2025-05-03[clang][ptrauth] reject incorrectly placed ptrauth qualifier (#138376)Oliver Hunt1-4/+7
When parsing a function pointer typed field we use Parser::ParseTypeQualifierListOpt, but then drops subsequent type attributes and qualifiers unless explicitly handled. There is an existing solution for the _Atomic qualifier, and this PR simply extends that to __ptrauth for now. In future we may want to investigate a more robust mechanism to ensure type qualifiers are not silently dropped so that future type qualifiers do not suffer the same problem.
2025-05-02[C23] Implement WG14 N3037 (#132939)Aaron Ballman1-3/+4
This changes the type compatibility rules so that it is permitted to redefine tag types within the same TU so long as they are equivalent definitions. It is intentionally not being exposed as an extension in older C language modes. GCC does not do so and the feature doesn't seem compelling enough to warrant it.
2025-05-01[clang] Add scoped enum support to `StreamingDiagnostic` (#138089)Vlad Serebrennikov1-1/+1
This patch adds templated `operator<<` for diagnostics that pass scoped enums, saving people from `llvm::to_underlying()` clutter on the side of emitting the diagnostic. This eliminates 80 out of 220 usages of `llvm::to_underlying()` in Clang. I also backported `std::is_scoped_enum_v` from C++23.
2025-05-01[clang][NFC] Convert `Sema::NameClassificationKind` to scoped enumVlad Serebrennikov1-13/+13
2025-04-30[clang][NFC] Convert `Parser::CXX11AttributeKind` to scoped enumVlad Serebrennikov1-8/+13
2025-04-30[clang][NFC] Convert `Parser::CachedInitKind` to scoped enumVlad Serebrennikov1-1/+2
2025-04-30[clang][NFC] Convert `ParsedTemplateInfo::Kind` to scoped enumVlad Serebrennikov1-16/+17
2025-04-30[clang][NFC] Convert `Parser::ExtraSemiKind` to scoped enumVlad Serebrennikov1-1/+1
2025-04-19[clang] llvm::append_range (NFC) (#136440)Kazu Hirata1-1/+1
2025-04-17Reland [clang] Unify `SourceLocation` and `IdentifierInfo*` pair-like data ↵yronglin1-14/+14
structures to `IdentifierLoc` (#136077) This PR reland https://github.com/llvm/llvm-project/pull/135808, fixed some missed changes in LLDB. I found this issue when I working on https://github.com/llvm/llvm-project/pull/107168. Currently we have many similiar data structures like: - std::pair<IdentifierInfo *, SourceLocation>. - Element type of ModuleIdPath. - IdentifierLocPair. - IdentifierLoc. This PR unify these data structures to IdentifierLoc, moved IdentifierLoc definition to SourceLocation.h, and deleted other similer data structures. --------- Signed-off-by: yronglin <yronglin777@gmail.com>
2025-04-16Revert "[clang] Unify `SourceLocation` and `IdentifierInfo*` pair-like data ↵Michael Buch1-14/+14
structures to `IdentifierLoc`" (#135974) Reverts llvm/llvm-project#135808 Example from the LLDB macOS CI: https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/24084/execution/node/54/log/?consoleFull ``` /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp:360:49: error: no viable conversion from 'std::pair<clang::IdentifierInfo *, clang::SourceLocation>' to 'clang::ModuleIdPath' (aka 'ArrayRef<IdentifierLoc>') clang::Module *top_level_module = DoGetModule(clang_path.front(), false); ^~~~~~~~~~~~~~~~~~ /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:41:40: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'std::pair<clang::IdentifierInfo *, clang::SourceLocation>' to 'const llvm::ArrayRef<clang::IdentifierLoc> &' for 1st argument class LLVM_GSL_POINTER [[nodiscard]] ArrayRef { ^ /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:41:40: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'std::pair<clang::IdentifierInfo *, clang::SourceLocation>' to 'llvm::ArrayRef<clang::IdentifierLoc> &&' for 1st argument /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:70:18: note: candidate constructor not viable: no known conversion from 'std::pair<clang::IdentifierInfo *, clang::SourceLocation>' to 'std::nullopt_t' for 1st argument /*implicit*/ ArrayRef(std::nullopt_t) {} ```
2025-04-16[clang] Unify `SourceLocation` and `IdentifierInfo*` pair-like data ↵yronglin1-14/+14
structures to `IdentifierLoc` (#135808) I found this issue when I working on https://github.com/llvm/llvm-project/pull/107168. Currently we have many similiar data structures like: - `std::pair<IdentifierInfo *, SourceLocation>`. - Element type of `ModuleIdPath`. - `IdentifierLocPair`. - `IdentifierLoc`. This PR unify these data structures to `IdentifierLoc`, moved `IdentifierLoc` definition to SourceLocation.h, and deleted other similer data structures. --------- Signed-off-by: yronglin <yronglin777@gmail.com>
2025-04-15[PAC] Add support for __ptrauth type qualifier (#100830)Akira Hatanaka1-0/+52
The qualifier allows programmer to directly control how pointers are signed when they are stored in a particular variable. The qualifier takes three arguments: the signing key, a flag specifying whether address discrimination should be used, and a non-negative integer that is used for additional discrimination. ``` typedef void (*my_callback)(const void*); my_callback __ptrauth(ptrauth_key_process_dependent_code, 1, 0xe27a) callback; ``` Co-Authored-By: John McCall rjmccall@apple.com
2025-04-02Reapply "[Clang] [NFC] Introduce a helper for emitting compatibility ↵Sirraide1-5/+2
diagnostics (#132348)" (#134043) This reapplies #132348 with a fix to the python bindings tests, reverting https://github.com/llvm/llvm-project/commit/076397ff3217cf45fd08024dd7bcd2bc8fb229ab.
2025-04-02Revert "[Clang] [NFC] Introduce a helper for emitting compatibility ↵Sirraide1-2/+5
diagnostics" (#134036) Reverts llvm/llvm-project#132348 Some tests are failing and I still need to figure out what is going on here.
2025-04-02[Clang] [NFC] Introduce a helper for emitting compatibility diagnostics ↵Sirraide1-5/+2
(#132348) This is a follow-up to #132129. Currently, only `Parser` and `SemaBase` get a `DiagCompat()` helper; I’m planning to keep refactoring compatibility warnings and add more helpers to other classes as needed. I also refactored a single parser compat warning just to make sure everything works properly when diagnostics across multiple components (i.e. Sema and Parser in this case) are involved.
2025-03-21[OpenACC] Finish implementing 'routine' AST/Sema.erichkeane1-1/+3
This is the last item of the OpenACC 3.3 spec. It includes the implicit-name version of 'routine', plus significant refactorings to make the two work together. The implicit name version is represented as an attribute on the function call. This patch also implements the clauses for the implicit-name version, as well as the A.3.4 warning.
2025-03-19[Clang] Increase the default expression nesting limit (#132021)cor3ntin1-3/+2
This iterates on #104717 (which we had to revert) In a bid to increase our chances of success, we try to avoid blowing up the stack by - Using `runWithSufficientStackSpace` in ParseCompoundStatement - Reducing the size of `StmtVector` a bit - Reducing the size of `DeclsInGroup` a bit - Removing a few `ParsedAttributes` from the stacks in places where they are not strictly necessary. `ParsedAttributes` is a _huge_ object On a 64 bits system, the following stack size reductions are observed ``` ParseStatementOrDeclarationAfterAttributes: 344 -> 264 ParseStatementOrDeclaration: 520 -> 376 ParseCompoundStatementBody: 1080 -> 1016 ParseDeclaration: 264 -> 120 ``` Fixes #94728
2025-03-09[HLSL] Disallow virtual inheritance and functions (#127346)Chris B1-0/+4
This PR disallows virtual inheritance and virtual functions in HLSL.
2025-03-07[clang] Fix ASTWriter crash after merging named enums (#114240)Michael Jabbour1-1/+1
Clang already removes parsed enumerators when merging typedefs to anonymous enums. This is why the following example decl used to be handled correctly while merging, and ASTWriter behaves as expected: ```c typedef enum { Val } AnonEnum; ``` However, the mentioned mechanism didn't handle named enums. This leads to stale declarations in `IdResolver`, causing an assertion violation in ASTWriter ``Assertion `DeclIDs.contains(D) && "Declaration not emitted!"' failed`` when a module is being serialized with the following example merged enums: ```c typedef enum Enum1 { Val_A } Enum1; enum Enum2 { Val_B }; ``` The PR applies the same mechanism in the named enums case. Additionally, I dropped the call to `getLexicalDeclContext()->removeDecl` as it was causing a wrong odr-violation diagnostic with anonymous enums. Might be easier to to review commit by commit. Any feedback is appreciated. ### Context This fixes frontend crashes that were encountered when certain Objective-C modules are included on Xcode 16. For example, by running `CC=/path/to/clang-19 xcodebuild clean build` on a project that contains the following Objective-C file: ```c #include <os/atomic.h> int main() { return memory_order_relaxed; } ``` This crashes the parser in release, when ASTReader tries to load the enumerator declaration.
2025-02-14[clang-repl] fix error recovery while parsing completely fails (#127087)Vipul Cariappa1-1/+1
Fixes the following crash in clang-repl ```c++ clang-repl> try { throw 1; } catch { 0; } In file included from <<< inputs >>>:1: input_line_1:1:23: error: expected '(' 1 | try { throw 1; } catch { 0; } | ^ | ( clang-repl: /home/vipul-cariappa/Documents/Workspace/cpp-py/llvms/llvm-project-a/clang/lib/AST/DeclBase.cpp:1757: void clang::DeclContext::addHiddenDecl(clang::Decl*): Assertion `D->getLexicalDeclContext() == this && "Decl inserted into wrong lexical context"' failed. #0 0x000059b28459e6da llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/vipul-cariappa/Documents/Workspace/cpp-py/llvms/llvm-project-a/llvm/lib/Support/Unix/Signals.inc:804:22 #1 0x000059b28459eaed PrintStackTraceSignalHandler(void*) /home/vipul-cariappa/Documents/Workspace/cpp-py/llvms/llvm-project-a/llvm/lib/Support/Unix/Signals.inc:880:1 #2 0x000059b28459bf7f llvm::sys::RunSignalHandlers() /home/vipul-cariappa/Documents/Workspace/cpp-py/llvms/llvm-project-a/llvm/lib/Support/Signals.cpp:105:20 #3 0x000059b28459df8e SignalHandler(int, siginfo_t*, void*) /home/vipul-cariappa/Documents/Workspace/cpp-py/llvms/llvm-project-a/llvm/lib/Support/Unix/Signals.inc:418:13 #4 0x000077cdf444ea50 (/usr/lib/libc.so.6+0x42a50) #5 0x000077cdf44aee3b pthread_kill (/usr/lib/libc.so.6+0xa2e3b) #6 0x000077cdf444e928 raise (/usr/lib/libc.so.6+0x42928) #7 0x000077cdf443156c abort (/usr/lib/libc.so.6+0x2556c) #8 0x000077cdf44314d2 __assert_perror_fail (/usr/lib/libc.so.6+0x254d2) #9 0x000077cdf4444c56 (/usr/lib/libc.so.6+0x38c56) #10 0x000059b28495bfc4 clang::DeclContext::addHiddenDecl(clang::Decl*) /home/vipul-cariappa/Documents/Workspace/cpp-py/llvms/llvm-project-a/clang/lib/AST/DeclBase.cpp:1759:3 #11 0x000059b28495c0f5 clang::DeclContext::addDecl(clang::Decl*) /home/vipul-cariappa/Documents/Workspace/cpp-py/llvms/llvm-project-a/clang/lib/AST/DeclBase.cpp:1785:37 #12 0x000059b28773cc2a clang::Sema::ActOnStartTopLevelStmtDecl(clang::Scope*) /home/vipul-cariappa/Documents/Workspace/cpp-py/llvms/llvm-project-a/clang/lib/Sema/SemaDecl.cpp:20302:18 #13 0x000059b286f1efdf clang::Parser::ParseTopLevelStmtDecl() /home/vipul-cariappa/Documents/Workspace/cpp-py/llvms/llvm-project-a/clang/lib/Parse/ParseDecl.cpp:6024:62 #14 0x000059b286ef18ee clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) /home/vipul-cariappa/Documents/Workspace/cpp-py/llvms/llvm-project-a/clang/lib/Parse/Parser.cpp:1065:35 #15 0x000059b286ef0702 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) /home/vipul-cariappa/Documents/Workspace/cpp-py/llvms/llvm-project-a/clang/lib/Parse/Parser.cpp:758:36 #16 0x000059b28562dff2 clang::IncrementalParser::ParseOrWrapTopLevelDecl() /home/vipul-cariappa/Documents/Workspace/cpp-py/llvms/llvm-project-a/clang/lib/Interpreter/IncrementalParser.cpp:66:36 #17 0x000059b28562e5b7 clang::IncrementalParser::Parse(llvm::StringRef) /home/vipul-cariappa/Documents/Workspace/cpp-py/llvms/llvm-project-a/clang/lib/Interpreter/IncrementalParser.cpp:132:8 #18 0x000059b28561832b clang::Interpreter::Parse(llvm::StringRef) /home/vipul-cariappa/Documents/Workspace/cpp-py/llvms/llvm-project-a/clang/lib/Interpreter/Interpreter.cpp:570:8 #19 0x000059b285618cbd clang::Interpreter::ParseAndExecute(llvm::StringRef, clang::Value*) /home/vipul-cariappa/Documents/Workspace/cpp-py/llvms/llvm-project-a/clang/lib/Interpreter/Interpreter.cpp:649:8 #20 0x000059b2836f9343 main /home/vipul-cariappa/Documents/Workspace/cpp-py/llvms/llvm-project-a/clang/tools/clang-repl/ClangRepl.cpp:255:59 #21 0x000077cdf443388e (/usr/lib/libc.so.6+0x2788e) #22 0x000077cdf443394a __libc_start_main (/usr/lib/libc.so.6+0x2794a) #23 0x000059b2836f7965 _start (./bin/clang-repl+0x73b8965) fish: Job 1, './bin/clang-repl' terminated by signal SIGABRT (Abort) ``` With this change: ```c++ clang-repl> try { throw 1; } catch { 0; } In file included from <<< inputs >>>:1: input_line_1:1:23: error: expected '(' 1 | try { throw 1; } catch { 0; } | ^ | ( error: Parsing failed. clang-repl> 1; clang-repl> %quit ```
2025-01-29[Clang][P1061] Add stuctured binding packs (#121417)Jason Rice1-5/+28
This is an implementation of P1061 Structure Bindings Introduce a Pack without the ability to use packs outside of templates. There is a couple of ways the AST could have been sliced so let me know what you think. The only part of this change that I am unsure of is the serialization/deserialization stuff. I followed the implementation of other Exprs, but I do not really know how it is tested. Thank you for your time considering this. --------- Co-authored-by: Yanzuo Liu <zwuis@outlook.com>
2025-01-13[clang] Refactor attr diagnostics to use %select (#122473)Maksim Ivanov1-2/+3
A cleanup follow-up to #118501 and #118567.
2025-01-10[clang] Informative error for lifetimebound in decl-spec (#118567)Maksim Ivanov1-2/+8
Emit a bit more informative error when the `[[clang::lifetimebound]]` attribute is wrongly appearing on a decl-spec: ``` 'lifetimebound' attribute only applies to parameters and implicit object parameters ``` instead of: ``` 'lifetimebound' attribute cannot be applied to types ``` The new error is also consistent with the diagnostic emitted when the attribute is misplaced in other parts of a declarator.
2024-12-02[clang] Implement P3176R1: The Oxford variadic comma (#117524)antangelo1-0/+8
Emit a deprecation warning when a variadic parameter in a parameter-declaration-clause is not preceded by a comma for C++26.
2024-11-18[Parse] Remove ParseDiagnostic.h (#116496)Kazu Hirata1-1/+1
This patch removes clang/Parse/ParseDiagnostic.h because it just forwards to clang/Basic/DiagnosticParse.h.
2024-10-24[clang] Use {} instead of std::nullopt to initialize empty ArrayRef (#109399)Jay Foad1-4/+4
Follow up to #109133.
2024-10-02[Clang][NFC] Consolidate the parameter check for the `requires` expression ↵c8ef1-14/+1
parameter. (#110773) This patch is a follow-up to #109831. In the discussion, we agreed that having parameter checks scattered across different areas isn't ideal. Therefore, I suggest merging the check from #88974 into the void parameter check. This change won't impact functionality and will enhance maintainability.
2024-09-18[clang][C23] Claim N3030 Enhancements to Enumerations supported (#107260)Mariya Podchishchaeva1-3/+5
Clang already implemented functionality as an extension.
2024-09-12Reapply "[Clang][CWG1815] Support lifetime extension of temporary created by ↵yronglin1-1/+2
aggregate initialization using a default member initializer" (#108039) The PR reapply https://github.com/llvm/llvm-project/pull/97308. - Implement [CWG1815](https://wg21.link/CWG1815): Support lifetime extension of temporary created by aggregate initialization using a default member initializer. - Fix crash that introduced in https://github.com/llvm/llvm-project/pull/97308. In `InitListChecker::FillInEmptyInitForField`, when we enter rebuild-default-init context, we copy all the contents of the parent context to the current context, which will cause the `MaybeODRUseExprs` to be lost. But we don't need to copy the entire context, only the `DelayedDefaultInitializationContext` was required, which is used to build `SourceLocExpr`, etc. --------- Signed-off-by: yronglin <yronglin777@gmail.com>