blob: bee6af3f4cfddef17188725e238c0c13b25ed965 [file] [log] [blame]
Daniel Dunbarfcdd8fe2008-10-04 19:21:03 +00001//===---- ParserPragmas.h - Language specific pragmas -----------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines #pragma handlers for language specific pragmas.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_PARSE_PARSEPRAGMA_H
15#define LLVM_CLANG_PARSE_PARSEPRAGMA_H
16
17#include "clang/Lex/Pragma.h"
18
19namespace clang {
John McCallf312b1e2010-08-26 23:41:50 +000020 class Sema;
Ted Kremenek4726d032009-03-23 22:28:25 +000021 class Parser;
Daniel Dunbarfcdd8fe2008-10-04 19:21:03 +000022
Daniel Dunbarcbb98ed2010-07-31 19:17:07 +000023class PragmaAlignHandler : public PragmaHandler {
John McCallf312b1e2010-08-26 23:41:50 +000024 Sema &Actions;
Daniel Dunbarcbb98ed2010-07-31 19:17:07 +000025public:
John McCallf312b1e2010-08-26 23:41:50 +000026 explicit PragmaAlignHandler(Sema &A) : PragmaHandler("align"), Actions(A) {}
Daniel Dunbarcbb98ed2010-07-31 19:17:07 +000027
Douglas Gregor80c60f72010-09-09 22:45:38 +000028 virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
29 Token &FirstToken);
Daniel Dunbarcbb98ed2010-07-31 19:17:07 +000030};
31
Eli Friedmanaa8b0d12010-08-05 06:57:20 +000032class PragmaGCCVisibilityHandler : public PragmaHandler {
John McCallf312b1e2010-08-26 23:41:50 +000033 Sema &Actions;
Eli Friedmanaa8b0d12010-08-05 06:57:20 +000034public:
John McCallf312b1e2010-08-26 23:41:50 +000035 explicit PragmaGCCVisibilityHandler(Sema &A) : PragmaHandler("visibility"),
36 Actions(A) {}
Eli Friedmanaa8b0d12010-08-05 06:57:20 +000037
Douglas Gregor80c60f72010-09-09 22:45:38 +000038 virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
39 Token &FirstToken);
Eli Friedmanaa8b0d12010-08-05 06:57:20 +000040};
41
Daniel Dunbar861800c2010-05-26 23:29:06 +000042class PragmaOptionsHandler : public PragmaHandler {
John McCallf312b1e2010-08-26 23:41:50 +000043 Sema &Actions;
Daniel Dunbar861800c2010-05-26 23:29:06 +000044public:
John McCallf312b1e2010-08-26 23:41:50 +000045 explicit PragmaOptionsHandler(Sema &A) : PragmaHandler("options"),
46 Actions(A) {}
Daniel Dunbar861800c2010-05-26 23:29:06 +000047
Douglas Gregor80c60f72010-09-09 22:45:38 +000048 virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
49 Token &FirstToken);
Daniel Dunbar861800c2010-05-26 23:29:06 +000050};
51
Daniel Dunbarfcdd8fe2008-10-04 19:21:03 +000052class PragmaPackHandler : public PragmaHandler {
John McCallf312b1e2010-08-26 23:41:50 +000053 Sema &Actions;
Daniel Dunbarfcdd8fe2008-10-04 19:21:03 +000054public:
John McCallf312b1e2010-08-26 23:41:50 +000055 explicit PragmaPackHandler(Sema &A) : PragmaHandler("pack"),
56 Actions(A) {}
Mike Stump1eb44332009-09-09 15:08:12 +000057
Douglas Gregor80c60f72010-09-09 22:45:38 +000058 virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
59 Token &FirstToken);
Daniel Dunbarfcdd8fe2008-10-04 19:21:03 +000060};
Mike Stump1eb44332009-09-09 15:08:12 +000061
Ted Kremenek4726d032009-03-23 22:28:25 +000062class PragmaUnusedHandler : public PragmaHandler {
John McCallf312b1e2010-08-26 23:41:50 +000063 Sema &Actions;
Ted Kremenek4726d032009-03-23 22:28:25 +000064 Parser &parser;
65public:
John McCallf312b1e2010-08-26 23:41:50 +000066 PragmaUnusedHandler(Sema &A, Parser& p)
Argyrios Kyrtzidis9b36c3f2010-07-13 09:07:17 +000067 : PragmaHandler("unused"), Actions(A), parser(p) {}
Mike Stump1eb44332009-09-09 15:08:12 +000068
Douglas Gregor80c60f72010-09-09 22:45:38 +000069 virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
70 Token &FirstToken);
Mike Stump1eb44332009-09-09 15:08:12 +000071};
Daniel Dunbarfcdd8fe2008-10-04 19:21:03 +000072
Eli Friedman99914792009-06-05 00:49:58 +000073class PragmaWeakHandler : public PragmaHandler {
John McCallf312b1e2010-08-26 23:41:50 +000074 Sema &Actions;
Eli Friedman99914792009-06-05 00:49:58 +000075public:
John McCallf312b1e2010-08-26 23:41:50 +000076 explicit PragmaWeakHandler(Sema &A)
Argyrios Kyrtzidis9b36c3f2010-07-13 09:07:17 +000077 : PragmaHandler("weak"), Actions(A) {}
Mike Stump1eb44332009-09-09 15:08:12 +000078
Douglas Gregor80c60f72010-09-09 22:45:38 +000079 virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
80 Token &FirstToken);
Eli Friedman99914792009-06-05 00:49:58 +000081};
82
Peter Collingbournef315fa82011-02-14 01:42:53 +000083class PragmaOpenCLExtensionHandler : public PragmaHandler {
84 Sema &Actions;
85 Parser &parser;
86public:
87 PragmaOpenCLExtensionHandler(Sema &S, Parser& p) :
88 PragmaHandler("EXTENSION"), Actions(S), parser(p) {}
89 virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
90 Token &FirstToken);
91};
92
93
Peter Collingbourne321b8172011-02-14 01:42:35 +000094class PragmaFPContractHandler : public PragmaHandler {
95 Sema &Actions;
96 Parser &parser;
97public:
98 PragmaFPContractHandler(Sema &S, Parser& p) :
99 PragmaHandler("FP_CONTRACT"), Actions(S), parser(p) {}
100 virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
101 Token &FirstToken);
102};
103
104
Daniel Dunbarfcdd8fe2008-10-04 19:21:03 +0000105} // end namespace clang
106
107#endif