xref: /freebsd/contrib/llvm-project/clang/include/clang/Sema/SemaSwift.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
1 //===----- SemaSwift.h --- Swift language-specific routines ---*- C++ -*---===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 /// \file
9 /// This file declares semantic analysis functions specific to Swift.
10 ///
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_CLANG_SEMA_SEMASWIFT_H
14 #define LLVM_CLANG_SEMA_SEMASWIFT_H
15 
16 #include "clang/AST/Attr.h"
17 #include "clang/Basic/LLVM.h"
18 #include "clang/Basic/SourceLocation.h"
19 #include "clang/Sema/SemaBase.h"
20 #include "llvm/ADT/StringRef.h"
21 
22 namespace clang {
23 class AttributeCommonInfo;
24 class Decl;
25 class ParsedAttr;
26 class SwiftNameAttr;
27 
28 class SemaSwift : public SemaBase {
29 public:
30   SemaSwift(Sema &S);
31 
32   SwiftNameAttr *mergeNameAttr(Decl *D, const SwiftNameAttr &SNA,
33                                StringRef Name);
34 
35   void handleAttrAttr(Decl *D, const ParsedAttr &AL);
36   void handleAsyncAttr(Decl *D, const ParsedAttr &AL);
37   void handleBridge(Decl *D, const ParsedAttr &AL);
38   void handleError(Decl *D, const ParsedAttr &AL);
39   void handleAsyncError(Decl *D, const ParsedAttr &AL);
40   void handleName(Decl *D, const ParsedAttr &AL);
41   void handleAsyncName(Decl *D, const ParsedAttr &AL);
42   void handleNewType(Decl *D, const ParsedAttr &AL);
43 
44   /// Do a check to make sure \p Name looks like a legal argument for the
45   /// swift_name attribute applied to decl \p D.  Raise a diagnostic if the name
46   /// is invalid for the given declaration.
47   ///
48   /// \p AL is used to provide caret diagnostics in case of a malformed name.
49   ///
50   /// \returns true if the name is a valid swift name for \p D, false otherwise.
51   bool DiagnoseName(Decl *D, StringRef Name, SourceLocation Loc,
52                     const ParsedAttr &AL, bool IsAsync);
53   void AddParameterABIAttr(Decl *D, const AttributeCommonInfo &CI,
54                            ParameterABI abi);
55 };
56 
57 } // namespace clang
58 
59 #endif // LLVM_CLANG_SEMA_SEMASWIFT_H
60