blob: 654d4606a9599824c57fef109bc29c378e96893d [file] [log] [blame]
Chris Lattnerb8761832006-06-24 21:31:03 +00001//===--- Pragma.cpp - Pragma registration and handling --------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner5b12ab82007-12-29 19:59:25 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Chris Lattnerb8761832006-06-24 21:31:03 +00007//
8//===----------------------------------------------------------------------===//
9//
Chris Lattnerb694ba72006-07-02 22:41:36 +000010// This file implements the PragmaHandler/PragmaTable interfaces and implements
11// pragma related methods of the Preprocessor class.
Chris Lattnerb8761832006-06-24 21:31:03 +000012//
13//===----------------------------------------------------------------------===//
14
15#include "clang/Lex/Pragma.h"
Chris Lattner07b019a2006-10-22 07:28:56 +000016#include "clang/Lex/HeaderSearch.h"
Chris Lattner262d4e32009-01-16 18:59:23 +000017#include "clang/Lex/LiteralSupport.h"
Chris Lattnerb8761832006-06-24 21:31:03 +000018#include "clang/Lex/Preprocessor.h"
Chris Lattner60f36222009-01-29 05:15:15 +000019#include "clang/Lex/LexDiagnostic.h"
Chris Lattnerb694ba72006-07-02 22:41:36 +000020#include "clang/Basic/FileManager.h"
21#include "clang/Basic/SourceManager.h"
Douglas Gregorc6d5edd2009-07-02 17:08:52 +000022#include <algorithm>
Chris Lattnerb8761832006-06-24 21:31:03 +000023using namespace clang;
24
25// Out-of-line destructor to provide a home for the class.
26PragmaHandler::~PragmaHandler() {
27}
28
Chris Lattner2e155302006-07-03 05:34:41 +000029//===----------------------------------------------------------------------===//
30// PragmaNamespace Implementation.
31//===----------------------------------------------------------------------===//
32
33
34PragmaNamespace::~PragmaNamespace() {
35 for (unsigned i = 0, e = Handlers.size(); i != e; ++i)
36 delete Handlers[i];
37}
38
39/// FindHandler - Check to see if there is already a handler for the
40/// specified name. If not, return the handler for the null identifier if it
41/// exists, otherwise return null. If IgnoreNull is true (the default) then
42/// the null handler isn't returned on failure to match.
Chris Lattnerc79f6fb2006-07-04 17:53:21 +000043PragmaHandler *PragmaNamespace::FindHandler(const IdentifierInfo *Name,
Chris Lattner2e155302006-07-03 05:34:41 +000044 bool IgnoreNull) const {
45 PragmaHandler *NullHandler = 0;
46 for (unsigned i = 0, e = Handlers.size(); i != e; ++i) {
Mike Stump11289f42009-09-09 15:08:12 +000047 if (Handlers[i]->getName() == Name)
Chris Lattner2e155302006-07-03 05:34:41 +000048 return Handlers[i];
Mike Stump11289f42009-09-09 15:08:12 +000049
Chris Lattner2e155302006-07-03 05:34:41 +000050 if (Handlers[i]->getName() == 0)
51 NullHandler = Handlers[i];
52 }
53 return IgnoreNull ? 0 : NullHandler;
54}
55
Daniel Dunbar40596532008-10-04 19:17:46 +000056void PragmaNamespace::RemovePragmaHandler(PragmaHandler *Handler) {
57 for (unsigned i = 0, e = Handlers.size(); i != e; ++i) {
58 if (Handlers[i] == Handler) {
59 Handlers[i] = Handlers.back();
60 Handlers.pop_back();
61 return;
62 }
63 }
64 assert(0 && "Handler not registered in this namespace");
65}
66
Chris Lattner146762e2007-07-20 16:59:19 +000067void PragmaNamespace::HandlePragma(Preprocessor &PP, Token &Tok) {
Chris Lattnerb8761832006-06-24 21:31:03 +000068 // Read the 'namespace' that the directive is in, e.g. STDC. Do not macro
69 // expand it, the user can have a STDC #define, that should not affect this.
70 PP.LexUnexpandedToken(Tok);
Mike Stump11289f42009-09-09 15:08:12 +000071
Chris Lattnerb8761832006-06-24 21:31:03 +000072 // Get the handler for this token. If there is no handler, ignore the pragma.
73 PragmaHandler *Handler = FindHandler(Tok.getIdentifierInfo(), false);
Chris Lattner21656f22009-04-19 21:10:26 +000074 if (Handler == 0) {
75 PP.Diag(Tok, diag::warn_pragma_ignored);
76 return;
77 }
Mike Stump11289f42009-09-09 15:08:12 +000078
Chris Lattnerb8761832006-06-24 21:31:03 +000079 // Otherwise, pass it down.
80 Handler->HandlePragma(PP, Tok);
81}
Chris Lattnerb694ba72006-07-02 22:41:36 +000082
Chris Lattnerb694ba72006-07-02 22:41:36 +000083//===----------------------------------------------------------------------===//
84// Preprocessor Pragma Directive Handling.
85//===----------------------------------------------------------------------===//
86
87/// HandlePragmaDirective - The "#pragma" directive has been parsed. Lex the
88/// rest of the pragma, passing it to the registered pragma handlers.
89void Preprocessor::HandlePragmaDirective() {
90 ++NumPragma;
Mike Stump11289f42009-09-09 15:08:12 +000091
Chris Lattnerb694ba72006-07-02 22:41:36 +000092 // Invoke the first level of pragma handlers which reads the namespace id.
Chris Lattner146762e2007-07-20 16:59:19 +000093 Token Tok;
Chris Lattnerb694ba72006-07-02 22:41:36 +000094 PragmaHandlers->HandlePragma(*this, Tok);
Mike Stump11289f42009-09-09 15:08:12 +000095
Chris Lattnerb694ba72006-07-02 22:41:36 +000096 // If the pragma handler didn't read the rest of the line, consume it now.
Chris Lattnere7e65942009-06-18 05:55:53 +000097 if (CurPPLexer && CurPPLexer->ParsingPreprocessorDirective)
Chris Lattnerb694ba72006-07-02 22:41:36 +000098 DiscardUntilEndOfDirective();
99}
100
101/// Handle_Pragma - Read a _Pragma directive, slice it up, process it, then
102/// return the first token after the directive. The _Pragma token has just
103/// been read into 'Tok'.
Chris Lattner146762e2007-07-20 16:59:19 +0000104void Preprocessor::Handle_Pragma(Token &Tok) {
Chris Lattnerb694ba72006-07-02 22:41:36 +0000105 // Remember the pragma token location.
106 SourceLocation PragmaLoc = Tok.getLocation();
Mike Stump11289f42009-09-09 15:08:12 +0000107
Chris Lattnerb694ba72006-07-02 22:41:36 +0000108 // Read the '('.
109 Lex(Tok);
Chris Lattner907dfe92008-11-18 07:59:24 +0000110 if (Tok.isNot(tok::l_paren)) {
111 Diag(PragmaLoc, diag::err__Pragma_malformed);
112 return;
113 }
Chris Lattnerb694ba72006-07-02 22:41:36 +0000114
115 // Read the '"..."'.
116 Lex(Tok);
Chris Lattner907dfe92008-11-18 07:59:24 +0000117 if (Tok.isNot(tok::string_literal) && Tok.isNot(tok::wide_string_literal)) {
118 Diag(PragmaLoc, diag::err__Pragma_malformed);
119 return;
120 }
Mike Stump11289f42009-09-09 15:08:12 +0000121
Chris Lattnerb694ba72006-07-02 22:41:36 +0000122 // Remember the string.
123 std::string StrVal = getSpelling(Tok);
Chris Lattnerb694ba72006-07-02 22:41:36 +0000124
125 // Read the ')'.
126 Lex(Tok);
Chris Lattner907dfe92008-11-18 07:59:24 +0000127 if (Tok.isNot(tok::r_paren)) {
128 Diag(PragmaLoc, diag::err__Pragma_malformed);
129 return;
130 }
Mike Stump11289f42009-09-09 15:08:12 +0000131
Chris Lattner9dc9c202009-02-15 20:52:18 +0000132 SourceLocation RParenLoc = Tok.getLocation();
Mike Stump11289f42009-09-09 15:08:12 +0000133
Chris Lattner262d4e32009-01-16 18:59:23 +0000134 // The _Pragma is lexically sound. Destringize according to C99 6.10.9.1:
135 // "The string literal is destringized by deleting the L prefix, if present,
136 // deleting the leading and trailing double-quotes, replacing each escape
137 // sequence \" by a double-quote, and replacing each escape sequence \\ by a
138 // single backslash."
Chris Lattnerb694ba72006-07-02 22:41:36 +0000139 if (StrVal[0] == 'L') // Remove L prefix.
140 StrVal.erase(StrVal.begin());
141 assert(StrVal[0] == '"' && StrVal[StrVal.size()-1] == '"' &&
142 "Invalid string token!");
Mike Stump11289f42009-09-09 15:08:12 +0000143
Chris Lattnerb694ba72006-07-02 22:41:36 +0000144 // Remove the front quote, replacing it with a space, so that the pragma
145 // contents appear to have a space before them.
146 StrVal[0] = ' ';
Mike Stump11289f42009-09-09 15:08:12 +0000147
Chris Lattnerfa217bd2009-03-08 08:08:45 +0000148 // Replace the terminating quote with a \n.
Chris Lattnerb694ba72006-07-02 22:41:36 +0000149 StrVal[StrVal.size()-1] = '\n';
Mike Stump11289f42009-09-09 15:08:12 +0000150
Chris Lattnerb694ba72006-07-02 22:41:36 +0000151 // Remove escaped quotes and escapes.
152 for (unsigned i = 0, e = StrVal.size(); i != e-1; ++i) {
153 if (StrVal[i] == '\\' &&
154 (StrVal[i+1] == '\\' || StrVal[i+1] == '"')) {
155 // \\ -> '\' and \" -> '"'.
156 StrVal.erase(StrVal.begin()+i);
157 --e;
158 }
159 }
Mike Stump11289f42009-09-09 15:08:12 +0000160
Chris Lattnerf918bf72006-07-19 05:01:18 +0000161 // Plop the string (including the newline and trailing null) into a buffer
162 // where we can lex it.
Chris Lattner5a7971e2009-01-26 19:29:26 +0000163 Token TmpTok;
164 TmpTok.startToken();
165 CreateString(&StrVal[0], StrVal.size(), TmpTok);
166 SourceLocation TokLoc = TmpTok.getLocation();
Chris Lattnerb694ba72006-07-02 22:41:36 +0000167
Chris Lattnerb694ba72006-07-02 22:41:36 +0000168 // Make and enter a lexer object so that we lex and expand the tokens just
169 // like any others.
Chris Lattner9dc9c202009-02-15 20:52:18 +0000170 Lexer *TL = Lexer::Create_PragmaLexer(TokLoc, PragmaLoc, RParenLoc,
Chris Lattnerfa217bd2009-03-08 08:08:45 +0000171 StrVal.size(), *this);
Chris Lattner98a53122006-07-02 23:00:20 +0000172
173 EnterSourceFileWithLexer(TL, 0);
174
Chris Lattnerb694ba72006-07-02 22:41:36 +0000175 // With everything set up, lex this as a #pragma directive.
176 HandlePragmaDirective();
Mike Stump11289f42009-09-09 15:08:12 +0000177
Chris Lattnerb694ba72006-07-02 22:41:36 +0000178 // Finally, return whatever came after the pragma directive.
179 return Lex(Tok);
180}
181
182
183
184/// HandlePragmaOnce - Handle #pragma once. OnceTok is the 'once'.
185///
Chris Lattner146762e2007-07-20 16:59:19 +0000186void Preprocessor::HandlePragmaOnce(Token &OnceTok) {
Chris Lattnerb694ba72006-07-02 22:41:36 +0000187 if (isInPrimaryFile()) {
188 Diag(OnceTok, diag::pp_pragma_once_in_main_file);
189 return;
190 }
Mike Stump11289f42009-09-09 15:08:12 +0000191
Chris Lattnerb694ba72006-07-02 22:41:36 +0000192 // Get the current file lexer we're looking at. Ignore _Pragma 'files' etc.
Chris Lattnerb694ba72006-07-02 22:41:36 +0000193 // Mark the file as a once-only file now.
Chris Lattnerd32480d2009-01-17 06:22:33 +0000194 HeaderInfo.MarkFileIncludeOnce(getCurrentFileLexer()->getFileEntry());
Chris Lattnerb694ba72006-07-02 22:41:36 +0000195}
196
Chris Lattnerc2383312007-12-19 19:38:36 +0000197void Preprocessor::HandlePragmaMark() {
Ted Kremenek76c34412008-11-19 22:21:33 +0000198 assert(CurPPLexer && "No current lexer?");
Chris Lattnerd9efb6e2009-06-15 05:02:34 +0000199 if (CurLexer)
200 CurLexer->ReadToEndOfLine();
201 else
202 CurPTHLexer->DiscardToEndOfLine();
Chris Lattnerc2383312007-12-19 19:38:36 +0000203}
204
205
Chris Lattnerb694ba72006-07-02 22:41:36 +0000206/// HandlePragmaPoison - Handle #pragma GCC poison. PoisonTok is the 'poison'.
207///
Chris Lattner146762e2007-07-20 16:59:19 +0000208void Preprocessor::HandlePragmaPoison(Token &PoisonTok) {
209 Token Tok;
Chris Lattner538d7f32006-07-20 04:31:52 +0000210
Chris Lattnerb694ba72006-07-02 22:41:36 +0000211 while (1) {
212 // Read the next token to poison. While doing this, pretend that we are
213 // skipping while reading the identifier to poison.
214 // This avoids errors on code like:
215 // #pragma GCC poison X
216 // #pragma GCC poison X
Ted Kremenek551c82a2008-11-18 01:12:54 +0000217 if (CurPPLexer) CurPPLexer->LexingRawMode = true;
Chris Lattnerb694ba72006-07-02 22:41:36 +0000218 LexUnexpandedToken(Tok);
Ted Kremenek551c82a2008-11-18 01:12:54 +0000219 if (CurPPLexer) CurPPLexer->LexingRawMode = false;
Mike Stump11289f42009-09-09 15:08:12 +0000220
Chris Lattnerb694ba72006-07-02 22:41:36 +0000221 // If we reached the end of line, we're done.
Chris Lattner98c1f7c2007-10-09 18:02:16 +0000222 if (Tok.is(tok::eom)) return;
Mike Stump11289f42009-09-09 15:08:12 +0000223
Chris Lattnerb694ba72006-07-02 22:41:36 +0000224 // Can only poison identifiers.
Chris Lattner98c1f7c2007-10-09 18:02:16 +0000225 if (Tok.isNot(tok::identifier)) {
Chris Lattnerb694ba72006-07-02 22:41:36 +0000226 Diag(Tok, diag::err_pp_invalid_poison);
227 return;
228 }
Mike Stump11289f42009-09-09 15:08:12 +0000229
Chris Lattnercefc7682006-07-08 08:28:12 +0000230 // Look up the identifier info for the token. We disabled identifier lookup
231 // by saying we're skipping contents, so we need to do this manually.
232 IdentifierInfo *II = LookUpIdentifierInfo(Tok);
Mike Stump11289f42009-09-09 15:08:12 +0000233
Chris Lattnerb694ba72006-07-02 22:41:36 +0000234 // Already poisoned.
235 if (II->isPoisoned()) continue;
Mike Stump11289f42009-09-09 15:08:12 +0000236
Chris Lattnerb694ba72006-07-02 22:41:36 +0000237 // If this is a macro identifier, emit a warning.
Chris Lattner259716a2007-10-07 08:04:56 +0000238 if (II->hasMacroDefinition())
Chris Lattnerb694ba72006-07-02 22:41:36 +0000239 Diag(Tok, diag::pp_poisoning_existing_macro);
Mike Stump11289f42009-09-09 15:08:12 +0000240
Chris Lattnerb694ba72006-07-02 22:41:36 +0000241 // Finally, poison it!
242 II->setIsPoisoned();
243 }
244}
245
246/// HandlePragmaSystemHeader - Implement #pragma GCC system_header. We know
247/// that the whole directive has been parsed.
Chris Lattner146762e2007-07-20 16:59:19 +0000248void Preprocessor::HandlePragmaSystemHeader(Token &SysHeaderTok) {
Chris Lattnerb694ba72006-07-02 22:41:36 +0000249 if (isInPrimaryFile()) {
250 Diag(SysHeaderTok, diag::pp_pragma_sysheader_in_main_file);
251 return;
252 }
Mike Stump11289f42009-09-09 15:08:12 +0000253
Chris Lattnerb694ba72006-07-02 22:41:36 +0000254 // Get the current file lexer we're looking at. Ignore _Pragma 'files' etc.
Ted Kremenek300590b2008-11-20 01:45:11 +0000255 PreprocessorLexer *TheLexer = getCurrentFileLexer();
Mike Stump11289f42009-09-09 15:08:12 +0000256
Chris Lattnerb694ba72006-07-02 22:41:36 +0000257 // Mark the file as a system header.
Chris Lattnerd32480d2009-01-17 06:22:33 +0000258 HeaderInfo.MarkFileSystemHeader(TheLexer->getFileEntry());
Mike Stump11289f42009-09-09 15:08:12 +0000259
260
Chris Lattnerd9efb6e2009-06-15 05:02:34 +0000261 PresumedLoc PLoc = SourceMgr.getPresumedLoc(SysHeaderTok.getLocation());
262 unsigned FilenameLen = strlen(PLoc.getFilename());
263 unsigned FilenameID = SourceMgr.getLineTableFilenameID(PLoc.getFilename(),
264 FilenameLen);
Mike Stump11289f42009-09-09 15:08:12 +0000265
Chris Lattnerd9efb6e2009-06-15 05:02:34 +0000266 // Emit a line marker. This will change any source locations from this point
267 // forward to realize they are in a system header.
268 // Create a line note with this information.
269 SourceMgr.AddLineNote(SysHeaderTok.getLocation(), PLoc.getLine(), FilenameID,
270 false, false, true, false);
Mike Stump11289f42009-09-09 15:08:12 +0000271
Chris Lattnerb694ba72006-07-02 22:41:36 +0000272 // Notify the client, if desired, that we are in a new source file.
Chris Lattnerb8d6d5a2006-11-21 04:09:30 +0000273 if (Callbacks)
Ted Kremenek300590b2008-11-20 01:45:11 +0000274 Callbacks->FileChanged(SysHeaderTok.getLocation(),
Chris Lattnerb03dc762008-09-26 21:18:42 +0000275 PPCallbacks::SystemHeaderPragma, SrcMgr::C_System);
Chris Lattnerb694ba72006-07-02 22:41:36 +0000276}
277
278/// HandlePragmaDependency - Handle #pragma GCC dependency "foo" blah.
279///
Chris Lattner146762e2007-07-20 16:59:19 +0000280void Preprocessor::HandlePragmaDependency(Token &DependencyTok) {
281 Token FilenameTok;
Ted Kremenek551c82a2008-11-18 01:12:54 +0000282 CurPPLexer->LexIncludeFilename(FilenameTok);
Chris Lattnerb694ba72006-07-02 22:41:36 +0000283
284 // If the token kind is EOM, the error has already been diagnosed.
Chris Lattner98c1f7c2007-10-09 18:02:16 +0000285 if (FilenameTok.is(tok::eom))
Chris Lattnerb694ba72006-07-02 22:41:36 +0000286 return;
Mike Stump11289f42009-09-09 15:08:12 +0000287
Chris Lattnerc07ba1f2006-10-30 05:58:32 +0000288 // Reserve a buffer to get the spelling.
Chris Lattnerd081f8c2010-01-10 01:35:12 +0000289 llvm::SmallString<128> FilenameBuffer;
Benjamin Kramer0a1abd42010-02-27 13:44:12 +0000290 llvm::StringRef Filename = getSpelling(FilenameTok, FilenameBuffer);
Mike Stump11289f42009-09-09 15:08:12 +0000291
Chris Lattnerd081f8c2010-01-10 01:35:12 +0000292 bool isAngled =
293 GetIncludeFilenameSpelling(FilenameTok.getLocation(), Filename);
Chris Lattnerc07ba1f2006-10-30 05:58:32 +0000294 // If GetIncludeFilenameSpelling set the start ptr to null, there was an
295 // error.
Chris Lattnerd081f8c2010-01-10 01:35:12 +0000296 if (Filename.empty())
Chris Lattnerc07ba1f2006-10-30 05:58:32 +0000297 return;
Mike Stump11289f42009-09-09 15:08:12 +0000298
Chris Lattner59a9ebd2006-10-18 05:34:33 +0000299 // Search include directories for this file.
Chris Lattnerb694ba72006-07-02 22:41:36 +0000300 const DirectoryLookup *CurDir;
Chris Lattnerfde85352010-01-22 00:14:44 +0000301 const FileEntry *File = LookupFile(Filename, isAngled, 0, CurDir);
Chris Lattner97b8e842008-11-18 08:02:48 +0000302 if (File == 0) {
Chris Lattnerd081f8c2010-01-10 01:35:12 +0000303 Diag(FilenameTok, diag::err_pp_file_not_found) << Filename;
Chris Lattner97b8e842008-11-18 08:02:48 +0000304 return;
305 }
Mike Stump11289f42009-09-09 15:08:12 +0000306
Chris Lattnerd32480d2009-01-17 06:22:33 +0000307 const FileEntry *CurFile = getCurrentFileLexer()->getFileEntry();
Chris Lattnerb694ba72006-07-02 22:41:36 +0000308
309 // If this file is older than the file it depends on, emit a diagnostic.
310 if (CurFile && CurFile->getModificationTime() < File->getModificationTime()) {
311 // Lex tokens at the end of the message and include them in the message.
312 std::string Message;
313 Lex(DependencyTok);
Chris Lattner98c1f7c2007-10-09 18:02:16 +0000314 while (DependencyTok.isNot(tok::eom)) {
Chris Lattnerb694ba72006-07-02 22:41:36 +0000315 Message += getSpelling(DependencyTok) + " ";
316 Lex(DependencyTok);
317 }
Mike Stump11289f42009-09-09 15:08:12 +0000318
Chris Lattnerb694ba72006-07-02 22:41:36 +0000319 Message.erase(Message.end()-1);
Chris Lattner97b8e842008-11-18 08:02:48 +0000320 Diag(FilenameTok, diag::pp_out_of_date_dependency) << Message;
Chris Lattnerb694ba72006-07-02 22:41:36 +0000321 }
322}
323
Chris Lattner2ff698d2009-01-16 08:21:25 +0000324/// HandlePragmaComment - Handle the microsoft #pragma comment extension. The
325/// syntax is:
326/// #pragma comment(linker, "foo")
327/// 'linker' is one of five identifiers: compiler, exestr, lib, linker, user.
328/// "foo" is a string, which is fully macro expanded, and permits string
Gabor Greif31a082f2009-03-17 11:39:38 +0000329/// concatenation, embedded escape characters etc. See MSDN for more details.
Chris Lattner2ff698d2009-01-16 08:21:25 +0000330void Preprocessor::HandlePragmaComment(Token &Tok) {
331 SourceLocation CommentLoc = Tok.getLocation();
332 Lex(Tok);
333 if (Tok.isNot(tok::l_paren)) {
334 Diag(CommentLoc, diag::err_pragma_comment_malformed);
335 return;
336 }
Mike Stump11289f42009-09-09 15:08:12 +0000337
Chris Lattner2ff698d2009-01-16 08:21:25 +0000338 // Read the identifier.
339 Lex(Tok);
340 if (Tok.isNot(tok::identifier)) {
341 Diag(CommentLoc, diag::err_pragma_comment_malformed);
342 return;
343 }
Mike Stump11289f42009-09-09 15:08:12 +0000344
Chris Lattner2ff698d2009-01-16 08:21:25 +0000345 // Verify that this is one of the 5 whitelisted options.
346 // FIXME: warn that 'exestr' is deprecated.
347 const IdentifierInfo *II = Tok.getIdentifierInfo();
Mike Stump11289f42009-09-09 15:08:12 +0000348 if (!II->isStr("compiler") && !II->isStr("exestr") && !II->isStr("lib") &&
Chris Lattner2ff698d2009-01-16 08:21:25 +0000349 !II->isStr("linker") && !II->isStr("user")) {
350 Diag(Tok.getLocation(), diag::err_pragma_comment_unknown_kind);
351 return;
352 }
Mike Stump11289f42009-09-09 15:08:12 +0000353
Chris Lattner262d4e32009-01-16 18:59:23 +0000354 // Read the optional string if present.
Chris Lattner2ff698d2009-01-16 08:21:25 +0000355 Lex(Tok);
Chris Lattner262d4e32009-01-16 18:59:23 +0000356 std::string ArgumentString;
Chris Lattner2ff698d2009-01-16 08:21:25 +0000357 if (Tok.is(tok::comma)) {
Chris Lattner262d4e32009-01-16 18:59:23 +0000358 Lex(Tok); // eat the comma.
Chris Lattner2ff698d2009-01-16 08:21:25 +0000359
360 // We need at least one string.
Chris Lattner504af112009-04-19 23:16:58 +0000361 if (Tok.isNot(tok::string_literal)) {
Chris Lattner2ff698d2009-01-16 08:21:25 +0000362 Diag(Tok.getLocation(), diag::err_pragma_comment_malformed);
363 return;
364 }
365
366 // String concatenation allows multiple strings, which can even come from
367 // macro expansion.
368 // "foo " "bar" "Baz"
Chris Lattner262d4e32009-01-16 18:59:23 +0000369 llvm::SmallVector<Token, 4> StrToks;
Chris Lattner504af112009-04-19 23:16:58 +0000370 while (Tok.is(tok::string_literal)) {
Chris Lattner262d4e32009-01-16 18:59:23 +0000371 StrToks.push_back(Tok);
Chris Lattner2ff698d2009-01-16 08:21:25 +0000372 Lex(Tok);
Chris Lattner262d4e32009-01-16 18:59:23 +0000373 }
374
375 // Concatenate and parse the strings.
376 StringLiteralParser Literal(&StrToks[0], StrToks.size(), *this);
377 assert(!Literal.AnyWide && "Didn't allow wide strings in");
378 if (Literal.hadError)
379 return;
380 if (Literal.Pascal) {
381 Diag(StrToks[0].getLocation(), diag::err_pragma_comment_malformed);
382 return;
383 }
384
385 ArgumentString = std::string(Literal.GetString(),
386 Literal.GetString()+Literal.GetStringLength());
Chris Lattner2ff698d2009-01-16 08:21:25 +0000387 }
Mike Stump11289f42009-09-09 15:08:12 +0000388
Chris Lattner262d4e32009-01-16 18:59:23 +0000389 // FIXME: If the kind is "compiler" warn if the string is present (it is
390 // ignored).
391 // FIXME: 'lib' requires a comment string.
392 // FIXME: 'linker' requires a comment string, and has a specific list of
393 // things that are allowable.
Mike Stump11289f42009-09-09 15:08:12 +0000394
Chris Lattner2ff698d2009-01-16 08:21:25 +0000395 if (Tok.isNot(tok::r_paren)) {
396 Diag(Tok.getLocation(), diag::err_pragma_comment_malformed);
397 return;
398 }
Chris Lattner262d4e32009-01-16 18:59:23 +0000399 Lex(Tok); // eat the r_paren.
Chris Lattner2ff698d2009-01-16 08:21:25 +0000400
401 if (Tok.isNot(tok::eom)) {
402 Diag(Tok.getLocation(), diag::err_pragma_comment_malformed);
403 return;
404 }
Mike Stump11289f42009-09-09 15:08:12 +0000405
Chris Lattner262d4e32009-01-16 18:59:23 +0000406 // If the pragma is lexically sound, notify any interested PPCallbacks.
Chris Lattnerf49775d2009-01-16 19:01:46 +0000407 if (Callbacks)
408 Callbacks->PragmaComment(CommentLoc, II, ArgumentString);
Chris Lattner2ff698d2009-01-16 08:21:25 +0000409}
410
411
412
Chris Lattnerb694ba72006-07-02 22:41:36 +0000413
414/// AddPragmaHandler - Add the specified pragma handler to the preprocessor.
415/// If 'Namespace' is non-null, then it is a token required to exist on the
416/// pragma line before the pragma string starts, e.g. "STDC" or "GCC".
Mike Stump11289f42009-09-09 15:08:12 +0000417void Preprocessor::AddPragmaHandler(const char *Namespace,
Chris Lattnerb694ba72006-07-02 22:41:36 +0000418 PragmaHandler *Handler) {
419 PragmaNamespace *InsertNS = PragmaHandlers;
Mike Stump11289f42009-09-09 15:08:12 +0000420
Chris Lattnerb694ba72006-07-02 22:41:36 +0000421 // If this is specified to be in a namespace, step down into it.
422 if (Namespace) {
Chris Lattnerc79f6fb2006-07-04 17:53:21 +0000423 IdentifierInfo *NSID = getIdentifierInfo(Namespace);
Mike Stump11289f42009-09-09 15:08:12 +0000424
Chris Lattnerb694ba72006-07-02 22:41:36 +0000425 // If there is already a pragma handler with the name of this namespace,
426 // we either have an error (directive with the same name as a namespace) or
427 // we already have the namespace to insert into.
428 if (PragmaHandler *Existing = PragmaHandlers->FindHandler(NSID)) {
429 InsertNS = Existing->getIfNamespace();
430 assert(InsertNS != 0 && "Cannot have a pragma namespace and pragma"
431 " handler with the same name!");
432 } else {
433 // Otherwise, this namespace doesn't exist yet, create and insert the
434 // handler for it.
435 InsertNS = new PragmaNamespace(NSID);
436 PragmaHandlers->AddPragma(InsertNS);
437 }
438 }
Mike Stump11289f42009-09-09 15:08:12 +0000439
Chris Lattnerb694ba72006-07-02 22:41:36 +0000440 // Check to make sure we don't already have a pragma for this identifier.
441 assert(!InsertNS->FindHandler(Handler->getName()) &&
442 "Pragma handler already exists for this identifier!");
443 InsertNS->AddPragma(Handler);
444}
445
Daniel Dunbar40596532008-10-04 19:17:46 +0000446/// RemovePragmaHandler - Remove the specific pragma handler from the
447/// preprocessor. If \arg Namespace is non-null, then it should be the
448/// namespace that \arg Handler was added to. It is an error to remove
449/// a handler that has not been registered.
450void Preprocessor::RemovePragmaHandler(const char *Namespace,
451 PragmaHandler *Handler) {
452 PragmaNamespace *NS = PragmaHandlers;
Mike Stump11289f42009-09-09 15:08:12 +0000453
Daniel Dunbar40596532008-10-04 19:17:46 +0000454 // If this is specified to be in a namespace, step down into it.
455 if (Namespace) {
456 IdentifierInfo *NSID = getIdentifierInfo(Namespace);
457 PragmaHandler *Existing = PragmaHandlers->FindHandler(NSID);
458 assert(Existing && "Namespace containing handler does not exist!");
459
460 NS = Existing->getIfNamespace();
461 assert(NS && "Invalid namespace, registered as a regular pragma handler!");
462 }
463
464 NS->RemovePragmaHandler(Handler);
Mike Stump11289f42009-09-09 15:08:12 +0000465
Daniel Dunbar40596532008-10-04 19:17:46 +0000466 // If this is a non-default namespace and it is now empty, remove
467 // it.
468 if (NS != PragmaHandlers && NS->IsEmpty())
469 PragmaHandlers->RemovePragmaHandler(NS);
470}
471
Chris Lattnerb694ba72006-07-02 22:41:36 +0000472namespace {
Chris Lattnerc2383312007-12-19 19:38:36 +0000473/// PragmaOnceHandler - "#pragma once" marks the file as atomically included.
Chris Lattnerb694ba72006-07-02 22:41:36 +0000474struct PragmaOnceHandler : public PragmaHandler {
Chris Lattnerc79f6fb2006-07-04 17:53:21 +0000475 PragmaOnceHandler(const IdentifierInfo *OnceID) : PragmaHandler(OnceID) {}
Chris Lattner146762e2007-07-20 16:59:19 +0000476 virtual void HandlePragma(Preprocessor &PP, Token &OnceTok) {
Chris Lattnerce2ab6f2009-04-14 05:07:49 +0000477 PP.CheckEndOfDirective("pragma once");
Chris Lattnerb694ba72006-07-02 22:41:36 +0000478 PP.HandlePragmaOnce(OnceTok);
479 }
480};
481
Chris Lattnerc2383312007-12-19 19:38:36 +0000482/// PragmaMarkHandler - "#pragma mark ..." is ignored by the compiler, and the
483/// rest of the line is not lexed.
484struct PragmaMarkHandler : public PragmaHandler {
485 PragmaMarkHandler(const IdentifierInfo *MarkID) : PragmaHandler(MarkID) {}
486 virtual void HandlePragma(Preprocessor &PP, Token &MarkTok) {
487 PP.HandlePragmaMark();
488 }
489};
490
491/// PragmaPoisonHandler - "#pragma poison x" marks x as not usable.
Chris Lattnerb694ba72006-07-02 22:41:36 +0000492struct PragmaPoisonHandler : public PragmaHandler {
Chris Lattnerc79f6fb2006-07-04 17:53:21 +0000493 PragmaPoisonHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {}
Chris Lattner146762e2007-07-20 16:59:19 +0000494 virtual void HandlePragma(Preprocessor &PP, Token &PoisonTok) {
Chris Lattnerb694ba72006-07-02 22:41:36 +0000495 PP.HandlePragmaPoison(PoisonTok);
496 }
497};
498
Chris Lattnerc2383312007-12-19 19:38:36 +0000499/// PragmaSystemHeaderHandler - "#pragma system_header" marks the current file
500/// as a system header, which silences warnings in it.
Chris Lattnerb694ba72006-07-02 22:41:36 +0000501struct PragmaSystemHeaderHandler : public PragmaHandler {
Chris Lattnerc79f6fb2006-07-04 17:53:21 +0000502 PragmaSystemHeaderHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {}
Chris Lattner146762e2007-07-20 16:59:19 +0000503 virtual void HandlePragma(Preprocessor &PP, Token &SHToken) {
Chris Lattnerb694ba72006-07-02 22:41:36 +0000504 PP.HandlePragmaSystemHeader(SHToken);
Chris Lattnerce2ab6f2009-04-14 05:07:49 +0000505 PP.CheckEndOfDirective("pragma");
Chris Lattnerb694ba72006-07-02 22:41:36 +0000506 }
507};
508struct PragmaDependencyHandler : public PragmaHandler {
Chris Lattnerc79f6fb2006-07-04 17:53:21 +0000509 PragmaDependencyHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {}
Chris Lattner146762e2007-07-20 16:59:19 +0000510 virtual void HandlePragma(Preprocessor &PP, Token &DepToken) {
Chris Lattnerb694ba72006-07-02 22:41:36 +0000511 PP.HandlePragmaDependency(DepToken);
512 }
513};
Mike Stump11289f42009-09-09 15:08:12 +0000514
Chris Lattner504af112009-04-19 23:16:58 +0000515/// PragmaDiagnosticHandler - e.g. '#pragma GCC diagnostic ignored "-Wformat"'
Chris Lattnerfb42a182009-07-12 21:18:45 +0000516/// Since clang's diagnostic supports extended functionality beyond GCC's
517/// the constructor takes a clangMode flag to tell it whether or not to allow
518/// clang's extended functionality, or whether to reject it.
Chris Lattner504af112009-04-19 23:16:58 +0000519struct PragmaDiagnosticHandler : public PragmaHandler {
Chris Lattnerfb42a182009-07-12 21:18:45 +0000520private:
521 const bool ClangMode;
522public:
523 PragmaDiagnosticHandler(const IdentifierInfo *ID,
524 const bool clangMode) : PragmaHandler(ID),
525 ClangMode(clangMode) {}
Chris Lattner504af112009-04-19 23:16:58 +0000526 virtual void HandlePragma(Preprocessor &PP, Token &DiagToken) {
527 Token Tok;
528 PP.LexUnexpandedToken(Tok);
529 if (Tok.isNot(tok::identifier)) {
Chris Lattnerfb42a182009-07-12 21:18:45 +0000530 unsigned Diag = ClangMode ? diag::warn_pragma_diagnostic_clang_invalid
531 : diag::warn_pragma_diagnostic_gcc_invalid;
532 PP.Diag(Tok, Diag);
Chris Lattner504af112009-04-19 23:16:58 +0000533 return;
534 }
535 IdentifierInfo *II = Tok.getIdentifierInfo();
Mike Stump11289f42009-09-09 15:08:12 +0000536
Chris Lattner504af112009-04-19 23:16:58 +0000537 diag::Mapping Map;
538 if (II->isStr("warning"))
539 Map = diag::MAP_WARNING;
540 else if (II->isStr("error"))
541 Map = diag::MAP_ERROR;
542 else if (II->isStr("ignored"))
543 Map = diag::MAP_IGNORE;
544 else if (II->isStr("fatal"))
545 Map = diag::MAP_FATAL;
Chris Lattnerfb42a182009-07-12 21:18:45 +0000546 else if (ClangMode) {
547 if (II->isStr("pop")) {
Mike Stump11289f42009-09-09 15:08:12 +0000548 if (!PP.getDiagnostics().popMappings())
Chris Lattnerfb42a182009-07-12 21:18:45 +0000549 PP.Diag(Tok, diag::warn_pragma_diagnostic_clang_cannot_ppp);
550 return;
551 }
552
553 if (II->isStr("push")) {
554 PP.getDiagnostics().pushMappings();
Mike Stump11289f42009-09-09 15:08:12 +0000555 return;
Chris Lattnerfb42a182009-07-12 21:18:45 +0000556 }
557
558 PP.Diag(Tok, diag::warn_pragma_diagnostic_clang_invalid);
559 return;
560 } else {
561 PP.Diag(Tok, diag::warn_pragma_diagnostic_gcc_invalid);
Chris Lattner504af112009-04-19 23:16:58 +0000562 return;
563 }
Mike Stump11289f42009-09-09 15:08:12 +0000564
Chris Lattner504af112009-04-19 23:16:58 +0000565 PP.LexUnexpandedToken(Tok);
566
567 // We need at least one string.
568 if (Tok.isNot(tok::string_literal)) {
569 PP.Diag(Tok.getLocation(), diag::warn_pragma_diagnostic_invalid_token);
570 return;
571 }
Mike Stump11289f42009-09-09 15:08:12 +0000572
Chris Lattner504af112009-04-19 23:16:58 +0000573 // String concatenation allows multiple strings, which can even come from
574 // macro expansion.
575 // "foo " "bar" "Baz"
576 llvm::SmallVector<Token, 4> StrToks;
577 while (Tok.is(tok::string_literal)) {
578 StrToks.push_back(Tok);
579 PP.LexUnexpandedToken(Tok);
580 }
Mike Stump11289f42009-09-09 15:08:12 +0000581
Chris Lattner504af112009-04-19 23:16:58 +0000582 if (Tok.isNot(tok::eom)) {
583 PP.Diag(Tok.getLocation(), diag::warn_pragma_diagnostic_invalid_token);
584 return;
585 }
Mike Stump11289f42009-09-09 15:08:12 +0000586
Chris Lattner504af112009-04-19 23:16:58 +0000587 // Concatenate and parse the strings.
588 StringLiteralParser Literal(&StrToks[0], StrToks.size(), PP);
589 assert(!Literal.AnyWide && "Didn't allow wide strings in");
590 if (Literal.hadError)
591 return;
592 if (Literal.Pascal) {
Chris Lattnerfb42a182009-07-12 21:18:45 +0000593 unsigned Diag = ClangMode ? diag::warn_pragma_diagnostic_clang_invalid
594 : diag::warn_pragma_diagnostic_gcc_invalid;
595 PP.Diag(Tok, Diag);
Chris Lattner504af112009-04-19 23:16:58 +0000596 return;
597 }
Chris Lattnerfb42a182009-07-12 21:18:45 +0000598
Chris Lattner504af112009-04-19 23:16:58 +0000599 std::string WarningName(Literal.GetString(),
600 Literal.GetString()+Literal.GetStringLength());
601
602 if (WarningName.size() < 3 || WarningName[0] != '-' ||
603 WarningName[1] != 'W') {
604 PP.Diag(StrToks[0].getLocation(),
605 diag::warn_pragma_diagnostic_invalid_option);
606 return;
607 }
Mike Stump11289f42009-09-09 15:08:12 +0000608
Chris Lattner504af112009-04-19 23:16:58 +0000609 if (PP.getDiagnostics().setDiagnosticGroupMapping(WarningName.c_str()+2,
610 Map))
611 PP.Diag(StrToks[0].getLocation(),
612 diag::warn_pragma_diagnostic_unknown_warning) << WarningName;
613 }
614};
Mike Stump11289f42009-09-09 15:08:12 +0000615
Chris Lattner2ff698d2009-01-16 08:21:25 +0000616/// PragmaCommentHandler - "#pragma comment ...".
617struct PragmaCommentHandler : public PragmaHandler {
618 PragmaCommentHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {}
619 virtual void HandlePragma(Preprocessor &PP, Token &CommentTok) {
620 PP.HandlePragmaComment(CommentTok);
621 }
622};
Mike Stump11289f42009-09-09 15:08:12 +0000623
Chris Lattner958ee042009-04-19 21:20:35 +0000624// Pragma STDC implementations.
Chris Lattner02ef4e32009-04-19 21:50:08 +0000625
626enum STDCSetting {
627 STDC_ON, STDC_OFF, STDC_DEFAULT, STDC_INVALID
628};
Mike Stump11289f42009-09-09 15:08:12 +0000629
Chris Lattner02ef4e32009-04-19 21:50:08 +0000630static STDCSetting LexOnOffSwitch(Preprocessor &PP) {
631 Token Tok;
632 PP.LexUnexpandedToken(Tok);
633
634 if (Tok.isNot(tok::identifier)) {
635 PP.Diag(Tok, diag::ext_stdc_pragma_syntax);
636 return STDC_INVALID;
637 }
638 IdentifierInfo *II = Tok.getIdentifierInfo();
639 STDCSetting Result;
640 if (II->isStr("ON"))
641 Result = STDC_ON;
642 else if (II->isStr("OFF"))
643 Result = STDC_OFF;
644 else if (II->isStr("DEFAULT"))
645 Result = STDC_DEFAULT;
646 else {
647 PP.Diag(Tok, diag::ext_stdc_pragma_syntax);
648 return STDC_INVALID;
649 }
650
651 // Verify that this is followed by EOM.
652 PP.LexUnexpandedToken(Tok);
653 if (Tok.isNot(tok::eom))
654 PP.Diag(Tok, diag::ext_stdc_pragma_syntax_eom);
655 return Result;
656}
Mike Stump11289f42009-09-09 15:08:12 +0000657
Chris Lattner958ee042009-04-19 21:20:35 +0000658/// PragmaSTDC_FP_CONTRACTHandler - "#pragma STDC FP_CONTRACT ...".
659struct PragmaSTDC_FP_CONTRACTHandler : public PragmaHandler {
660 PragmaSTDC_FP_CONTRACTHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {}
Chris Lattnera0b1f762009-04-19 21:25:37 +0000661 virtual void HandlePragma(Preprocessor &PP, Token &Tok) {
Chris Lattner02ef4e32009-04-19 21:50:08 +0000662 // We just ignore the setting of FP_CONTRACT. Since we don't do contractions
663 // at all, our default is OFF and setting it to ON is an optimization hint
664 // we can safely ignore. When we support -ffma or something, we would need
665 // to diagnose that we are ignoring FMA.
666 LexOnOffSwitch(PP);
Chris Lattner958ee042009-04-19 21:20:35 +0000667 }
668};
Mike Stump11289f42009-09-09 15:08:12 +0000669
Chris Lattner958ee042009-04-19 21:20:35 +0000670/// PragmaSTDC_FENV_ACCESSHandler - "#pragma STDC FENV_ACCESS ...".
671struct PragmaSTDC_FENV_ACCESSHandler : public PragmaHandler {
672 PragmaSTDC_FENV_ACCESSHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {}
Chris Lattnera0b1f762009-04-19 21:25:37 +0000673 virtual void HandlePragma(Preprocessor &PP, Token &Tok) {
Chris Lattnerdf222682009-04-19 21:55:32 +0000674 if (LexOnOffSwitch(PP) == STDC_ON)
675 PP.Diag(Tok, diag::warn_stdc_fenv_access_not_supported);
Chris Lattner958ee042009-04-19 21:20:35 +0000676 }
677};
Mike Stump11289f42009-09-09 15:08:12 +0000678
Chris Lattner958ee042009-04-19 21:20:35 +0000679/// PragmaSTDC_CX_LIMITED_RANGEHandler - "#pragma STDC CX_LIMITED_RANGE ...".
680struct PragmaSTDC_CX_LIMITED_RANGEHandler : public PragmaHandler {
681 PragmaSTDC_CX_LIMITED_RANGEHandler(const IdentifierInfo *ID)
682 : PragmaHandler(ID) {}
Chris Lattnera0b1f762009-04-19 21:25:37 +0000683 virtual void HandlePragma(Preprocessor &PP, Token &Tok) {
Chris Lattner02ef4e32009-04-19 21:50:08 +0000684 LexOnOffSwitch(PP);
Chris Lattner958ee042009-04-19 21:20:35 +0000685 }
686};
Mike Stump11289f42009-09-09 15:08:12 +0000687
Chris Lattner958ee042009-04-19 21:20:35 +0000688/// PragmaSTDC_UnknownHandler - "#pragma STDC ...".
689struct PragmaSTDC_UnknownHandler : public PragmaHandler {
690 PragmaSTDC_UnknownHandler() : PragmaHandler(0) {}
Chris Lattnera0b1f762009-04-19 21:25:37 +0000691 virtual void HandlePragma(Preprocessor &PP, Token &UnknownTok) {
Chris Lattner02ef4e32009-04-19 21:50:08 +0000692 // C99 6.10.6p2, unknown forms are not allowed.
Chris Lattnera0b1f762009-04-19 21:25:37 +0000693 PP.Diag(UnknownTok, diag::ext_stdc_pragma_ignored);
Chris Lattner958ee042009-04-19 21:20:35 +0000694 }
695};
Mike Stump11289f42009-09-09 15:08:12 +0000696
Chris Lattnerb694ba72006-07-02 22:41:36 +0000697} // end anonymous namespace
698
699
700/// RegisterBuiltinPragmas - Install the standard preprocessor pragmas:
701/// #pragma GCC poison/system_header/dependency and #pragma once.
702void Preprocessor::RegisterBuiltinPragmas() {
703 AddPragmaHandler(0, new PragmaOnceHandler(getIdentifierInfo("once")));
Chris Lattnerc2383312007-12-19 19:38:36 +0000704 AddPragmaHandler(0, new PragmaMarkHandler(getIdentifierInfo("mark")));
Mike Stump11289f42009-09-09 15:08:12 +0000705
Chris Lattnerb61448d2009-05-12 18:21:11 +0000706 // #pragma GCC ...
Chris Lattnerb694ba72006-07-02 22:41:36 +0000707 AddPragmaHandler("GCC", new PragmaPoisonHandler(getIdentifierInfo("poison")));
708 AddPragmaHandler("GCC", new PragmaSystemHeaderHandler(
709 getIdentifierInfo("system_header")));
710 AddPragmaHandler("GCC", new PragmaDependencyHandler(
711 getIdentifierInfo("dependency")));
Chris Lattner504af112009-04-19 23:16:58 +0000712 AddPragmaHandler("GCC", new PragmaDiagnosticHandler(
Chris Lattnerfb42a182009-07-12 21:18:45 +0000713 getIdentifierInfo("diagnostic"),
714 false));
Chris Lattnerb61448d2009-05-12 18:21:11 +0000715 // #pragma clang ...
716 AddPragmaHandler("clang", new PragmaPoisonHandler(
717 getIdentifierInfo("poison")));
718 AddPragmaHandler("clang", new PragmaSystemHeaderHandler(
719 getIdentifierInfo("system_header")));
720 AddPragmaHandler("clang", new PragmaDependencyHandler(
721 getIdentifierInfo("dependency")));
722 AddPragmaHandler("clang", new PragmaDiagnosticHandler(
Chris Lattnerfb42a182009-07-12 21:18:45 +0000723 getIdentifierInfo("diagnostic"),
724 true));
Chris Lattnerb61448d2009-05-12 18:21:11 +0000725
Chris Lattner958ee042009-04-19 21:20:35 +0000726 AddPragmaHandler("STDC", new PragmaSTDC_FP_CONTRACTHandler(
727 getIdentifierInfo("FP_CONTRACT")));
728 AddPragmaHandler("STDC", new PragmaSTDC_FENV_ACCESSHandler(
729 getIdentifierInfo("FENV_ACCESS")));
730 AddPragmaHandler("STDC", new PragmaSTDC_CX_LIMITED_RANGEHandler(
731 getIdentifierInfo("CX_LIMITED_RANGE")));
732 AddPragmaHandler("STDC", new PragmaSTDC_UnknownHandler());
Mike Stump11289f42009-09-09 15:08:12 +0000733
Chris Lattner2ff698d2009-01-16 08:21:25 +0000734 // MS extensions.
735 if (Features.Microsoft)
736 AddPragmaHandler(0, new PragmaCommentHandler(getIdentifierInfo("comment")));
Chris Lattnerb694ba72006-07-02 22:41:36 +0000737}