clang 22.0.0git
SemaAVR.cpp
Go to the documentation of this file.
1//===------ SemaAVR.cpp ---------- AVR target-specific routines -----------===//
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//
9// This file implements semantic analysis functions specific to AVR.
10//
11//===----------------------------------------------------------------------===//
12
13#include "clang/Sema/SemaAVR.h"
14#include "clang/AST/DeclBase.h"
16#include "clang/Sema/Attr.h"
18#include "clang/Sema/Sema.h"
19
20namespace clang {
22
25 Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type)
27 return;
28 }
29
30 if (!AL.checkExactlyNumArgs(SemaRef, 0))
31 return;
32
33 // AVR interrupt handlers must have no parameter and be void type.
35 Diag(D->getLocation(), diag::warn_interrupt_signal_attribute_invalid)
36 << /*AVR*/ 3 << /*interrupt*/ 0 << 0;
37 return;
38 }
39 if (!getFunctionOrMethodResultType(D)->isVoidType()) {
40 Diag(D->getLocation(), diag::warn_interrupt_signal_attribute_invalid)
41 << /*AVR*/ 3 << /*interrupt*/ 0 << 1;
42 return;
43 }
44
45 handleSimpleAttribute<AVRInterruptAttr>(*this, D, AL);
46}
47
50 Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type)
52 return;
53 }
54
55 if (!AL.checkExactlyNumArgs(SemaRef, 0))
56 return;
57
58 // AVR signal handlers must have no parameter and be void type.
60 Diag(D->getLocation(), diag::warn_interrupt_signal_attribute_invalid)
61 << /*AVR*/ 3 << /*signal*/ 1 << 0;
62 return;
63 }
64 if (!getFunctionOrMethodResultType(D)->isVoidType()) {
65 Diag(D->getLocation(), diag::warn_interrupt_signal_attribute_invalid)
66 << /*AVR*/ 3 << /*signal*/ 1 << 1;
67 return;
68 }
69
70 handleSimpleAttribute<AVRSignalAttr>(*this, D, AL);
71}
72
73} // namespace clang
const Decl * D
This file declares semantic analysis functions specific to AVR.
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
ParsedAttr - Represents a syntactic attribute.
Definition: ParsedAttr.h:119
bool checkExactlyNumArgs(class Sema &S, unsigned Num) const
Check if the attribute has exactly as many args as Num.
Definition: ParsedAttr.cpp:288
SemaAVR(Sema &S)
Definition: SemaAVR.cpp:21
void handleSignalAttr(Decl *D, const ParsedAttr &AL)
Definition: SemaAVR.cpp:48
void handleInterruptAttr(Decl *D, const ParsedAttr &AL)
Definition: SemaAVR.cpp:23
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
Definition: SemaBase.cpp:61
Sema & SemaRef
Definition: SemaBase.h:40
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:850
The JSON file list parser is used to communicate input to InstallAPI.
@ ExpectedFunction
Definition: ParsedAttr.h:1075
QualType getFunctionOrMethodResultType(const Decl *D)
Definition: Attr.h:98
bool isFuncOrMethodForAttrSubject(const Decl *D)
isFuncOrMethodForAttrSubject - Return true if the given decl has function type (function or function-...
Definition: Attr.h:34
bool hasFunctionProto(const Decl *D)
hasFunctionProto - Return true if the given decl has a argument information.
Definition: Attr.h:55
unsigned getFunctionOrMethodNumParams(const Decl *D)
getFunctionOrMethodNumParams - Return number of function or method parameters.
Definition: Attr.h:64