1 //===--- Pragma.cpp - Pragma registration and handling --------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the PragmaHandler/PragmaTable interfaces and implements
11 // pragma related methods of the Preprocessor class.
13 //===----------------------------------------------------------------------===//
15 #include "clang/Lex/Pragma.h"
16 #include "clang/Basic/FileManager.h"
17 #include "clang/Basic/SourceManager.h"
18 #include "clang/Lex/HeaderSearch.h"
19 #include "clang/Lex/LexDiagnostic.h"
20 #include "clang/Lex/LiteralSupport.h"
21 #include "clang/Lex/MacroInfo.h"
22 #include "clang/Lex/Preprocessor.h"
23 #include "llvm/ADT/STLExtras.h"
24 #include "llvm/ADT/StringSwitch.h"
25 #include "llvm/Support/CrashRecoveryContext.h"
26 #include "llvm/Support/ErrorHandling.h"
28 using namespace clang;
30 #include "llvm/Support/raw_ostream.h"
32 // Out-of-line destructor to provide a home for the class.
33 PragmaHandler::~PragmaHandler() {
36 //===----------------------------------------------------------------------===//
37 // EmptyPragmaHandler Implementation.
38 //===----------------------------------------------------------------------===//
40 EmptyPragmaHandler::EmptyPragmaHandler() {}
42 void EmptyPragmaHandler::HandlePragma(Preprocessor &PP,
43 PragmaIntroducerKind Introducer,
46 //===----------------------------------------------------------------------===//
47 // PragmaNamespace Implementation.
48 //===----------------------------------------------------------------------===//
50 PragmaNamespace::~PragmaNamespace() {
51 for (llvm::StringMap<PragmaHandler*>::iterator
52 I = Handlers.begin(), E = Handlers.end(); I != E; ++I)
56 /// FindHandler - Check to see if there is already a handler for the
57 /// specified name. If not, return the handler for the null identifier if it
58 /// exists, otherwise return null. If IgnoreNull is true (the default) then
59 /// the null handler isn't returned on failure to match.
60 PragmaHandler *PragmaNamespace::FindHandler(StringRef Name,
61 bool IgnoreNull) const {
62 if (PragmaHandler *Handler = Handlers.lookup(Name))
64 return IgnoreNull ? 0 : Handlers.lookup(StringRef());
67 void PragmaNamespace::AddPragma(PragmaHandler *Handler) {
68 assert(!Handlers.lookup(Handler->getName()) &&
69 "A handler with this name is already registered in this namespace");
70 llvm::StringMapEntry<PragmaHandler *> &Entry =
71 Handlers.GetOrCreateValue(Handler->getName());
72 Entry.setValue(Handler);
75 void PragmaNamespace::RemovePragmaHandler(PragmaHandler *Handler) {
76 assert(Handlers.lookup(Handler->getName()) &&
77 "Handler not registered in this namespace");
78 Handlers.erase(Handler->getName());
81 void PragmaNamespace::HandlePragma(Preprocessor &PP,
82 PragmaIntroducerKind Introducer,
84 // Read the 'namespace' that the directive is in, e.g. STDC. Do not macro
85 // expand it, the user can have a STDC #define, that should not affect this.
86 PP.LexUnexpandedToken(Tok);
88 // Get the handler for this token. If there is no handler, ignore the pragma.
89 PragmaHandler *Handler
90 = FindHandler(Tok.getIdentifierInfo() ? Tok.getIdentifierInfo()->getName()
92 /*IgnoreNull=*/false);
94 PP.Diag(Tok, diag::warn_pragma_ignored);
98 // Otherwise, pass it down.
99 Handler->HandlePragma(PP, Introducer, Tok);
102 //===----------------------------------------------------------------------===//
103 // Preprocessor Pragma Directive Handling.
104 //===----------------------------------------------------------------------===//
106 /// HandlePragmaDirective - The "\#pragma" directive has been parsed. Lex the
107 /// rest of the pragma, passing it to the registered pragma handlers.
108 void Preprocessor::HandlePragmaDirective(SourceLocation IntroducerLoc,
109 PragmaIntroducerKind Introducer) {
111 Callbacks->PragmaDirective(IntroducerLoc, Introducer);
118 // Invoke the first level of pragma handlers which reads the namespace id.
120 PragmaHandlers->HandlePragma(*this, Introducer, Tok);
122 // If the pragma handler didn't read the rest of the line, consume it now.
123 if ((CurTokenLexer && CurTokenLexer->isParsingPreprocessorDirective())
124 || (CurPPLexer && CurPPLexer->ParsingPreprocessorDirective))
125 DiscardUntilEndOfDirective();
129 /// \brief Helper class for \see Preprocessor::Handle_Pragma.
130 class LexingFor_PragmaRAII {
132 bool InMacroArgPreExpansion;
138 LexingFor_PragmaRAII(Preprocessor &PP, bool InMacroArgPreExpansion,
140 : PP(PP), InMacroArgPreExpansion(InMacroArgPreExpansion),
141 Failed(false), OutTok(Tok) {
142 if (InMacroArgPreExpansion) {
144 PP.EnableBacktrackAtThisPos();
148 ~LexingFor_PragmaRAII() {
149 if (InMacroArgPreExpansion) {
151 PP.CommitBacktrackedTokens();
165 /// Handle_Pragma - Read a _Pragma directive, slice it up, process it, then
166 /// return the first token after the directive. The _Pragma token has just
167 /// been read into 'Tok'.
168 void Preprocessor::Handle_Pragma(Token &Tok) {
170 // This works differently if we are pre-expanding a macro argument.
171 // In that case we don't actually "activate" the pragma now, we only lex it
172 // until we are sure it is lexically correct and then we backtrack so that
173 // we activate the pragma whenever we encounter the tokens again in the token
174 // stream. This ensures that we will activate it in the correct location
175 // or that we will ignore it if it never enters the token stream, e.g:
178 // #define INACTIVE(x) EMPTY(x)
179 // INACTIVE(_Pragma("clang diagnostic ignored \"-Wconversion\""))
181 LexingFor_PragmaRAII _PragmaLexing(*this, InMacroArgPreExpansion, Tok);
183 // Remember the pragma token location.
184 SourceLocation PragmaLoc = Tok.getLocation();
188 if (Tok.isNot(tok::l_paren)) {
189 Diag(PragmaLoc, diag::err__Pragma_malformed);
190 return _PragmaLexing.failed();
195 if (!tok::isStringLiteral(Tok.getKind())) {
196 Diag(PragmaLoc, diag::err__Pragma_malformed);
197 // Skip this token, and the ')', if present.
198 if (Tok.isNot(tok::r_paren))
200 if (Tok.is(tok::r_paren))
202 return _PragmaLexing.failed();
205 if (Tok.hasUDSuffix()) {
206 Diag(Tok, diag::err_invalid_string_udl);
207 // Skip this token, and the ')', if present.
209 if (Tok.is(tok::r_paren))
211 return _PragmaLexing.failed();
214 // Remember the string.
219 if (Tok.isNot(tok::r_paren)) {
220 Diag(PragmaLoc, diag::err__Pragma_malformed);
221 return _PragmaLexing.failed();
224 if (InMacroArgPreExpansion)
227 SourceLocation RParenLoc = Tok.getLocation();
228 std::string StrVal = getSpelling(StrTok);
230 // The _Pragma is lexically sound. Destringize according to C11 6.10.9.1:
231 // "The string literal is destringized by deleting any encoding prefix,
232 // deleting the leading and trailing double-quotes, replacing each escape
233 // sequence \" by a double-quote, and replacing each escape sequence \\ by a
234 // single backslash."
235 if (StrVal[0] == 'L' || StrVal[0] == 'U' ||
236 (StrVal[0] == 'u' && StrVal[1] != '8'))
237 StrVal.erase(StrVal.begin());
238 else if (StrVal[0] == 'u')
239 StrVal.erase(StrVal.begin(), StrVal.begin() + 2);
241 if (StrVal[0] == 'R') {
242 // FIXME: C++11 does not specify how to handle raw-string-literals here.
243 // We strip off the 'R', the quotes, the d-char-sequences, and the parens.
244 assert(StrVal[1] == '"' && StrVal[StrVal.size() - 1] == '"' &&
245 "Invalid raw string token!");
247 // Measure the length of the d-char-sequence.
248 unsigned NumDChars = 0;
249 while (StrVal[2 + NumDChars] != '(') {
250 assert(NumDChars < (StrVal.size() - 5) / 2 &&
251 "Invalid raw string token!");
254 assert(StrVal[StrVal.size() - 2 - NumDChars] == ')');
256 // Remove 'R " d-char-sequence' and 'd-char-sequence "'. We'll replace the
258 StrVal.erase(0, 2 + NumDChars);
259 StrVal.erase(StrVal.size() - 1 - NumDChars);
261 assert(StrVal[0] == '"' && StrVal[StrVal.size()-1] == '"' &&
262 "Invalid string token!");
264 // Remove escaped quotes and escapes.
265 unsigned ResultPos = 1;
266 for (unsigned i = 1, e = StrVal.size() - 1; i != e; ++i) {
267 // Skip escapes. \\ -> '\' and \" -> '"'.
268 if (StrVal[i] == '\\' && i + 1 < e &&
269 (StrVal[i + 1] == '\\' || StrVal[i + 1] == '"'))
271 StrVal[ResultPos++] = StrVal[i];
273 StrVal.erase(StrVal.begin() + ResultPos, StrVal.end() - 1);
276 // Remove the front quote, replacing it with a space, so that the pragma
277 // contents appear to have a space before them.
280 // Replace the terminating quote with a \n.
281 StrVal[StrVal.size()-1] = '\n';
283 // Plop the string (including the newline and trailing null) into a buffer
284 // where we can lex it.
287 CreateString(StrVal, TmpTok);
288 SourceLocation TokLoc = TmpTok.getLocation();
290 // Make and enter a lexer object so that we lex and expand the tokens just
292 Lexer *TL = Lexer::Create_PragmaLexer(TokLoc, PragmaLoc, RParenLoc,
293 StrVal.size(), *this);
295 EnterSourceFileWithLexer(TL, 0);
297 // With everything set up, lex this as a #pragma directive.
298 HandlePragmaDirective(PragmaLoc, PIK__Pragma);
300 // Finally, return whatever came after the pragma directive.
304 /// HandleMicrosoft__pragma - Like Handle_Pragma except the pragma text
305 /// is not enclosed within a string literal.
306 void Preprocessor::HandleMicrosoft__pragma(Token &Tok) {
307 // Remember the pragma token location.
308 SourceLocation PragmaLoc = Tok.getLocation();
312 if (Tok.isNot(tok::l_paren)) {
313 Diag(PragmaLoc, diag::err__Pragma_malformed);
317 // Get the tokens enclosed within the __pragma(), as well as the final ')'.
318 SmallVector<Token, 32> PragmaToks;
321 while (Tok.isNot(tok::eof)) {
322 PragmaToks.push_back(Tok);
323 if (Tok.is(tok::l_paren))
325 else if (Tok.is(tok::r_paren) && NumParens-- == 0)
330 if (Tok.is(tok::eof)) {
331 Diag(PragmaLoc, diag::err_unterminated___pragma);
335 PragmaToks.front().setFlag(Token::LeadingSpace);
337 // Replace the ')' with an EOD to mark the end of the pragma.
338 PragmaToks.back().setKind(tok::eod);
340 Token *TokArray = new Token[PragmaToks.size()];
341 std::copy(PragmaToks.begin(), PragmaToks.end(), TokArray);
343 // Push the tokens onto the stack.
344 EnterTokenStream(TokArray, PragmaToks.size(), true, true);
346 // With everything set up, lex this as a #pragma directive.
347 HandlePragmaDirective(PragmaLoc, PIK___pragma);
349 // Finally, return whatever came after the pragma directive.
353 /// HandlePragmaOnce - Handle \#pragma once. OnceTok is the 'once'.
355 void Preprocessor::HandlePragmaOnce(Token &OnceTok) {
356 if (isInPrimaryFile()) {
357 Diag(OnceTok, diag::pp_pragma_once_in_main_file);
361 // Get the current file lexer we're looking at. Ignore _Pragma 'files' etc.
362 // Mark the file as a once-only file now.
363 HeaderInfo.MarkFileIncludeOnce(getCurrentFileLexer()->getFileEntry());
366 void Preprocessor::HandlePragmaMark() {
367 assert(CurPPLexer && "No current lexer?");
369 CurLexer->ReadToEndOfLine();
371 CurPTHLexer->DiscardToEndOfLine();
375 /// HandlePragmaPoison - Handle \#pragma GCC poison. PoisonTok is the 'poison'.
377 void Preprocessor::HandlePragmaPoison(Token &PoisonTok) {
381 // Read the next token to poison. While doing this, pretend that we are
382 // skipping while reading the identifier to poison.
383 // This avoids errors on code like:
384 // #pragma GCC poison X
385 // #pragma GCC poison X
386 if (CurPPLexer) CurPPLexer->LexingRawMode = true;
387 LexUnexpandedToken(Tok);
388 if (CurPPLexer) CurPPLexer->LexingRawMode = false;
390 // If we reached the end of line, we're done.
391 if (Tok.is(tok::eod)) return;
393 // Can only poison identifiers.
394 if (Tok.isNot(tok::raw_identifier)) {
395 Diag(Tok, diag::err_pp_invalid_poison);
399 // Look up the identifier info for the token. We disabled identifier lookup
400 // by saying we're skipping contents, so we need to do this manually.
401 IdentifierInfo *II = LookUpIdentifierInfo(Tok);
404 if (II->isPoisoned()) continue;
406 // If this is a macro identifier, emit a warning.
407 if (II->hasMacroDefinition())
408 Diag(Tok, diag::pp_poisoning_existing_macro);
410 // Finally, poison it!
413 II->setChangedSinceDeserialization();
417 /// HandlePragmaSystemHeader - Implement \#pragma GCC system_header. We know
418 /// that the whole directive has been parsed.
419 void Preprocessor::HandlePragmaSystemHeader(Token &SysHeaderTok) {
420 if (isInPrimaryFile()) {
421 Diag(SysHeaderTok, diag::pp_pragma_sysheader_in_main_file);
425 // Get the current file lexer we're looking at. Ignore _Pragma 'files' etc.
426 PreprocessorLexer *TheLexer = getCurrentFileLexer();
428 // Mark the file as a system header.
429 HeaderInfo.MarkFileSystemHeader(TheLexer->getFileEntry());
432 PresumedLoc PLoc = SourceMgr.getPresumedLoc(SysHeaderTok.getLocation());
433 if (PLoc.isInvalid())
436 unsigned FilenameID = SourceMgr.getLineTableFilenameID(PLoc.getFilename());
438 // Notify the client, if desired, that we are in a new source file.
440 Callbacks->FileChanged(SysHeaderTok.getLocation(),
441 PPCallbacks::SystemHeaderPragma, SrcMgr::C_System);
443 // Emit a line marker. This will change any source locations from this point
444 // forward to realize they are in a system header.
445 // Create a line note with this information.
446 SourceMgr.AddLineNote(SysHeaderTok.getLocation(), PLoc.getLine()+1,
447 FilenameID, /*IsEntry=*/false, /*IsExit=*/false,
448 /*IsSystem=*/true, /*IsExternC=*/false);
451 /// HandlePragmaDependency - Handle \#pragma GCC dependency "foo" blah.
453 void Preprocessor::HandlePragmaDependency(Token &DependencyTok) {
455 CurPPLexer->LexIncludeFilename(FilenameTok);
457 // If the token kind is EOD, the error has already been diagnosed.
458 if (FilenameTok.is(tok::eod))
461 // Reserve a buffer to get the spelling.
462 SmallString<128> FilenameBuffer;
463 bool Invalid = false;
464 StringRef Filename = getSpelling(FilenameTok, FilenameBuffer, &Invalid);
469 GetIncludeFilenameSpelling(FilenameTok.getLocation(), Filename);
470 // If GetIncludeFilenameSpelling set the start ptr to null, there was an
472 if (Filename.empty())
475 // Search include directories for this file.
476 const DirectoryLookup *CurDir;
477 const FileEntry *File = LookupFile(FilenameTok.getLocation(), Filename,
478 isAngled, 0, CurDir, NULL, NULL, NULL);
480 if (!SuppressIncludeNotFoundError)
481 Diag(FilenameTok, diag::err_pp_file_not_found) << Filename;
485 const FileEntry *CurFile = getCurrentFileLexer()->getFileEntry();
487 // If this file is older than the file it depends on, emit a diagnostic.
488 if (CurFile && CurFile->getModificationTime() < File->getModificationTime()) {
489 // Lex tokens at the end of the message and include them in the message.
492 while (DependencyTok.isNot(tok::eod)) {
493 Message += getSpelling(DependencyTok) + " ";
497 // Remove the trailing ' ' if present.
498 if (!Message.empty())
499 Message.erase(Message.end()-1);
500 Diag(FilenameTok, diag::pp_out_of_date_dependency) << Message;
504 /// ParsePragmaPushOrPopMacro - Handle parsing of pragma push_macro/pop_macro.
505 /// Return the IdentifierInfo* associated with the macro to push or pop.
506 IdentifierInfo *Preprocessor::ParsePragmaPushOrPopMacro(Token &Tok) {
507 // Remember the pragma token location.
508 Token PragmaTok = Tok;
512 if (Tok.isNot(tok::l_paren)) {
513 Diag(PragmaTok.getLocation(), diag::err_pragma_push_pop_macro_malformed)
514 << getSpelling(PragmaTok);
518 // Read the macro name string.
520 if (Tok.isNot(tok::string_literal)) {
521 Diag(PragmaTok.getLocation(), diag::err_pragma_push_pop_macro_malformed)
522 << getSpelling(PragmaTok);
526 if (Tok.hasUDSuffix()) {
527 Diag(Tok, diag::err_invalid_string_udl);
531 // Remember the macro string.
532 std::string StrVal = getSpelling(Tok);
536 if (Tok.isNot(tok::r_paren)) {
537 Diag(PragmaTok.getLocation(), diag::err_pragma_push_pop_macro_malformed)
538 << getSpelling(PragmaTok);
542 assert(StrVal[0] == '"' && StrVal[StrVal.size()-1] == '"' &&
543 "Invalid string token!");
545 // Create a Token from the string.
547 MacroTok.startToken();
548 MacroTok.setKind(tok::raw_identifier);
549 CreateString(StringRef(&StrVal[1], StrVal.size() - 2), MacroTok);
551 // Get the IdentifierInfo of MacroToPushTok.
552 return LookUpIdentifierInfo(MacroTok);
555 /// \brief Handle \#pragma push_macro.
559 /// #pragma push_macro("macro")
561 void Preprocessor::HandlePragmaPushMacro(Token &PushMacroTok) {
562 // Parse the pragma directive and get the macro IdentifierInfo*.
563 IdentifierInfo *IdentInfo = ParsePragmaPushOrPopMacro(PushMacroTok);
564 if (!IdentInfo) return;
566 // Get the MacroInfo associated with IdentInfo.
567 MacroInfo *MI = getMacroInfo(IdentInfo);
570 // Allow the original MacroInfo to be redefined later.
571 MI->setIsAllowRedefinitionsWithoutWarning(true);
574 // Push the cloned MacroInfo so we can retrieve it later.
575 PragmaPushMacroInfo[IdentInfo].push_back(MI);
578 /// \brief Handle \#pragma pop_macro.
582 /// #pragma pop_macro("macro")
584 void Preprocessor::HandlePragmaPopMacro(Token &PopMacroTok) {
585 SourceLocation MessageLoc = PopMacroTok.getLocation();
587 // Parse the pragma directive and get the macro IdentifierInfo*.
588 IdentifierInfo *IdentInfo = ParsePragmaPushOrPopMacro(PopMacroTok);
589 if (!IdentInfo) return;
591 // Find the vector<MacroInfo*> associated with the macro.
592 llvm::DenseMap<IdentifierInfo*, std::vector<MacroInfo*> >::iterator iter =
593 PragmaPushMacroInfo.find(IdentInfo);
594 if (iter != PragmaPushMacroInfo.end()) {
595 // Forget the MacroInfo currently associated with IdentInfo.
596 if (MacroDirective *CurrentMD = getMacroDirective(IdentInfo)) {
597 MacroInfo *MI = CurrentMD->getMacroInfo();
598 if (MI->isWarnIfUnused())
599 WarnUnusedMacroLocs.erase(MI->getDefinitionLoc());
600 appendMacroDirective(IdentInfo, AllocateUndefMacroDirective(MessageLoc));
603 // Get the MacroInfo we want to reinstall.
604 MacroInfo *MacroToReInstall = iter->second.back();
606 if (MacroToReInstall) {
607 // Reinstall the previously pushed macro.
608 appendDefMacroDirective(IdentInfo, MacroToReInstall, MessageLoc,
609 /*isImported=*/false);
612 // Pop PragmaPushMacroInfo stack.
613 iter->second.pop_back();
614 if (iter->second.size() == 0)
615 PragmaPushMacroInfo.erase(iter);
617 Diag(MessageLoc, diag::warn_pragma_pop_macro_no_push)
618 << IdentInfo->getName();
622 void Preprocessor::HandlePragmaIncludeAlias(Token &Tok) {
623 // We will either get a quoted filename or a bracketed filename, and we
624 // have to track which we got. The first filename is the source name,
625 // and the second name is the mapped filename. If the first is quoted,
626 // the second must be as well (cannot mix and match quotes and brackets).
628 // Get the open paren
630 if (Tok.isNot(tok::l_paren)) {
631 Diag(Tok, diag::warn_pragma_include_alias_expected) << "(";
635 // We expect either a quoted string literal, or a bracketed name
636 Token SourceFilenameTok;
637 CurPPLexer->LexIncludeFilename(SourceFilenameTok);
638 if (SourceFilenameTok.is(tok::eod)) {
639 // The diagnostic has already been handled
643 StringRef SourceFileName;
644 SmallString<128> FileNameBuffer;
645 if (SourceFilenameTok.is(tok::string_literal) ||
646 SourceFilenameTok.is(tok::angle_string_literal)) {
647 SourceFileName = getSpelling(SourceFilenameTok, FileNameBuffer);
648 } else if (SourceFilenameTok.is(tok::less)) {
649 // This could be a path instead of just a name
650 FileNameBuffer.push_back('<');
652 if (ConcatenateIncludeName(FileNameBuffer, End))
653 return; // Diagnostic already emitted
654 SourceFileName = FileNameBuffer.str();
656 Diag(Tok, diag::warn_pragma_include_alias_expected_filename);
659 FileNameBuffer.clear();
661 // Now we expect a comma, followed by another include name
663 if (Tok.isNot(tok::comma)) {
664 Diag(Tok, diag::warn_pragma_include_alias_expected) << ",";
668 Token ReplaceFilenameTok;
669 CurPPLexer->LexIncludeFilename(ReplaceFilenameTok);
670 if (ReplaceFilenameTok.is(tok::eod)) {
671 // The diagnostic has already been handled
675 StringRef ReplaceFileName;
676 if (ReplaceFilenameTok.is(tok::string_literal) ||
677 ReplaceFilenameTok.is(tok::angle_string_literal)) {
678 ReplaceFileName = getSpelling(ReplaceFilenameTok, FileNameBuffer);
679 } else if (ReplaceFilenameTok.is(tok::less)) {
680 // This could be a path instead of just a name
681 FileNameBuffer.push_back('<');
683 if (ConcatenateIncludeName(FileNameBuffer, End))
684 return; // Diagnostic already emitted
685 ReplaceFileName = FileNameBuffer.str();
687 Diag(Tok, diag::warn_pragma_include_alias_expected_filename);
691 // Finally, we expect the closing paren
693 if (Tok.isNot(tok::r_paren)) {
694 Diag(Tok, diag::warn_pragma_include_alias_expected) << ")";
698 // Now that we have the source and target filenames, we need to make sure
699 // they're both of the same type (angled vs non-angled)
700 StringRef OriginalSource = SourceFileName;
702 bool SourceIsAngled =
703 GetIncludeFilenameSpelling(SourceFilenameTok.getLocation(),
705 bool ReplaceIsAngled =
706 GetIncludeFilenameSpelling(ReplaceFilenameTok.getLocation(),
708 if (!SourceFileName.empty() && !ReplaceFileName.empty() &&
709 (SourceIsAngled != ReplaceIsAngled)) {
712 DiagID = diag::warn_pragma_include_alias_mismatch_angle;
714 DiagID = diag::warn_pragma_include_alias_mismatch_quote;
716 Diag(SourceFilenameTok.getLocation(), DiagID)
723 // Now we can let the include handler know about this mapping
724 getHeaderSearchInfo().AddIncludeAlias(OriginalSource, ReplaceFileName);
727 /// AddPragmaHandler - Add the specified pragma handler to the preprocessor.
728 /// If 'Namespace' is non-null, then it is a token required to exist on the
729 /// pragma line before the pragma string starts, e.g. "STDC" or "GCC".
730 void Preprocessor::AddPragmaHandler(StringRef Namespace,
731 PragmaHandler *Handler) {
732 PragmaNamespace *InsertNS = PragmaHandlers;
734 // If this is specified to be in a namespace, step down into it.
735 if (!Namespace.empty()) {
736 // If there is already a pragma handler with the name of this namespace,
737 // we either have an error (directive with the same name as a namespace) or
738 // we already have the namespace to insert into.
739 if (PragmaHandler *Existing = PragmaHandlers->FindHandler(Namespace)) {
740 InsertNS = Existing->getIfNamespace();
741 assert(InsertNS != 0 && "Cannot have a pragma namespace and pragma"
742 " handler with the same name!");
744 // Otherwise, this namespace doesn't exist yet, create and insert the
746 InsertNS = new PragmaNamespace(Namespace);
747 PragmaHandlers->AddPragma(InsertNS);
751 // Check to make sure we don't already have a pragma for this identifier.
752 assert(!InsertNS->FindHandler(Handler->getName()) &&
753 "Pragma handler already exists for this identifier!");
754 InsertNS->AddPragma(Handler);
757 /// RemovePragmaHandler - Remove the specific pragma handler from the
758 /// preprocessor. If \arg Namespace is non-null, then it should be the
759 /// namespace that \arg Handler was added to. It is an error to remove
760 /// a handler that has not been registered.
761 void Preprocessor::RemovePragmaHandler(StringRef Namespace,
762 PragmaHandler *Handler) {
763 PragmaNamespace *NS = PragmaHandlers;
765 // If this is specified to be in a namespace, step down into it.
766 if (!Namespace.empty()) {
767 PragmaHandler *Existing = PragmaHandlers->FindHandler(Namespace);
768 assert(Existing && "Namespace containing handler does not exist!");
770 NS = Existing->getIfNamespace();
771 assert(NS && "Invalid namespace, registered as a regular pragma handler!");
774 NS->RemovePragmaHandler(Handler);
776 // If this is a non-default namespace and it is now empty, remove
778 if (NS != PragmaHandlers && NS->IsEmpty()) {
779 PragmaHandlers->RemovePragmaHandler(NS);
784 bool Preprocessor::LexOnOffSwitch(tok::OnOffSwitch &Result) {
786 LexUnexpandedToken(Tok);
788 if (Tok.isNot(tok::identifier)) {
789 Diag(Tok, diag::ext_on_off_switch_syntax);
792 IdentifierInfo *II = Tok.getIdentifierInfo();
794 Result = tok::OOS_ON;
795 else if (II->isStr("OFF"))
796 Result = tok::OOS_OFF;
797 else if (II->isStr("DEFAULT"))
798 Result = tok::OOS_DEFAULT;
800 Diag(Tok, diag::ext_on_off_switch_syntax);
804 // Verify that this is followed by EOD.
805 LexUnexpandedToken(Tok);
806 if (Tok.isNot(tok::eod))
807 Diag(Tok, diag::ext_pragma_syntax_eod);
812 /// PragmaOnceHandler - "\#pragma once" marks the file as atomically included.
813 struct PragmaOnceHandler : public PragmaHandler {
814 PragmaOnceHandler() : PragmaHandler("once") {}
815 virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
817 PP.CheckEndOfDirective("pragma once");
818 PP.HandlePragmaOnce(OnceTok);
822 /// PragmaMarkHandler - "\#pragma mark ..." is ignored by the compiler, and the
823 /// rest of the line is not lexed.
824 struct PragmaMarkHandler : public PragmaHandler {
825 PragmaMarkHandler() : PragmaHandler("mark") {}
826 virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
828 PP.HandlePragmaMark();
832 /// PragmaPoisonHandler - "\#pragma poison x" marks x as not usable.
833 struct PragmaPoisonHandler : public PragmaHandler {
834 PragmaPoisonHandler() : PragmaHandler("poison") {}
835 virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
837 PP.HandlePragmaPoison(PoisonTok);
841 /// PragmaSystemHeaderHandler - "\#pragma system_header" marks the current file
842 /// as a system header, which silences warnings in it.
843 struct PragmaSystemHeaderHandler : public PragmaHandler {
844 PragmaSystemHeaderHandler() : PragmaHandler("system_header") {}
845 virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
847 PP.HandlePragmaSystemHeader(SHToken);
848 PP.CheckEndOfDirective("pragma");
851 struct PragmaDependencyHandler : public PragmaHandler {
852 PragmaDependencyHandler() : PragmaHandler("dependency") {}
853 virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
855 PP.HandlePragmaDependency(DepToken);
859 struct PragmaDebugHandler : public PragmaHandler {
860 PragmaDebugHandler() : PragmaHandler("__debug") {}
861 virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
864 PP.LexUnexpandedToken(Tok);
865 if (Tok.isNot(tok::identifier)) {
866 PP.Diag(Tok, diag::warn_pragma_diagnostic_invalid);
869 IdentifierInfo *II = Tok.getIdentifierInfo();
871 if (II->isStr("assert")) {
872 llvm_unreachable("This is an assertion!");
873 } else if (II->isStr("crash")) {
875 } else if (II->isStr("parser_crash")) {
877 Crasher.setKind(tok::annot_pragma_parser_crash);
878 PP.EnterToken(Crasher);
879 } else if (II->isStr("llvm_fatal_error")) {
880 llvm::report_fatal_error("#pragma clang __debug llvm_fatal_error");
881 } else if (II->isStr("llvm_unreachable")) {
882 llvm_unreachable("#pragma clang __debug llvm_unreachable");
883 } else if (II->isStr("overflow_stack")) {
884 DebugOverflowStack();
885 } else if (II->isStr("handle_crash")) {
886 llvm::CrashRecoveryContext *CRC =llvm::CrashRecoveryContext::GetCurrent();
889 } else if (II->isStr("captured")) {
892 PP.Diag(Tok, diag::warn_pragma_debug_unexpected_command)
896 PPCallbacks *Callbacks = PP.getPPCallbacks();
898 Callbacks->PragmaDebug(Tok.getLocation(), II->getName());
901 void HandleCaptured(Preprocessor &PP) {
902 // Skip if emitting preprocessed output.
903 if (PP.isPreprocessedOutput())
907 PP.LexUnexpandedToken(Tok);
909 if (Tok.isNot(tok::eod)) {
910 PP.Diag(Tok, diag::ext_pp_extra_tokens_at_eol)
911 << "pragma clang __debug captured";
915 SourceLocation NameLoc = Tok.getLocation();
916 Token *Toks = PP.getPreprocessorAllocator().Allocate<Token>(1);
918 Toks->setKind(tok::annot_pragma_captured);
919 Toks->setLocation(NameLoc);
921 PP.EnterTokenStream(Toks, 1, /*DisableMacroExpansion=*/true,
922 /*OwnsTokens=*/false);
925 // Disable MSVC warning about runtime stack overflow.
927 #pragma warning(disable : 4717)
929 void DebugOverflowStack() {
930 DebugOverflowStack();
933 #pragma warning(default : 4717)
938 /// PragmaDiagnosticHandler - e.g. '\#pragma GCC diagnostic ignored "-Wformat"'
939 struct PragmaDiagnosticHandler : public PragmaHandler {
941 const char *Namespace;
943 explicit PragmaDiagnosticHandler(const char *NS) :
944 PragmaHandler("diagnostic"), Namespace(NS) {}
945 virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
947 SourceLocation DiagLoc = DiagToken.getLocation();
949 PP.LexUnexpandedToken(Tok);
950 if (Tok.isNot(tok::identifier)) {
951 PP.Diag(Tok, diag::warn_pragma_diagnostic_invalid);
954 IdentifierInfo *II = Tok.getIdentifierInfo();
955 PPCallbacks *Callbacks = PP.getPPCallbacks();
958 if (II->isStr("warning"))
959 Map = diag::MAP_WARNING;
960 else if (II->isStr("error"))
961 Map = diag::MAP_ERROR;
962 else if (II->isStr("ignored"))
963 Map = diag::MAP_IGNORE;
964 else if (II->isStr("fatal"))
965 Map = diag::MAP_FATAL;
966 else if (II->isStr("pop")) {
967 if (!PP.getDiagnostics().popMappings(DiagLoc))
968 PP.Diag(Tok, diag::warn_pragma_diagnostic_cannot_pop);
970 Callbacks->PragmaDiagnosticPop(DiagLoc, Namespace);
972 } else if (II->isStr("push")) {
973 PP.getDiagnostics().pushMappings(DiagLoc);
975 Callbacks->PragmaDiagnosticPush(DiagLoc, Namespace);
978 PP.Diag(Tok, diag::warn_pragma_diagnostic_invalid);
982 PP.LexUnexpandedToken(Tok);
983 SourceLocation StringLoc = Tok.getLocation();
985 std::string WarningName;
986 if (!PP.FinishLexStringLiteral(Tok, WarningName, "pragma diagnostic",
987 /*MacroExpansion=*/false))
990 if (Tok.isNot(tok::eod)) {
991 PP.Diag(Tok.getLocation(), diag::warn_pragma_diagnostic_invalid_token);
995 if (WarningName.size() < 3 || WarningName[0] != '-' ||
996 WarningName[1] != 'W') {
997 PP.Diag(StringLoc, diag::warn_pragma_diagnostic_invalid_option);
1001 if (PP.getDiagnostics().setDiagnosticGroupMapping(WarningName.substr(2),
1003 PP.Diag(StringLoc, diag::warn_pragma_diagnostic_unknown_warning)
1006 Callbacks->PragmaDiagnostic(DiagLoc, Namespace, Map, WarningName);
1010 // Returns -1 on failure.
1011 static int LexSimpleInt(Preprocessor &PP, Token &Tok) {
1012 assert(Tok.is(tok::numeric_constant));
1013 SmallString<8> IntegerBuffer;
1014 bool NumberInvalid = false;
1015 StringRef Spelling = PP.getSpelling(Tok, IntegerBuffer, &NumberInvalid);
1018 NumericLiteralParser Literal(Spelling, Tok.getLocation(), PP);
1019 if (Literal.hadError || !Literal.isIntegerLiteral() || Literal.hasUDSuffix())
1021 llvm::APInt APVal(32, 0);
1022 if (Literal.GetIntegerValue(APVal))
1025 return int(APVal.getLimitedValue(INT_MAX));
1028 /// "\#pragma warning(...)". MSVC's diagnostics do not map cleanly to clang's
1029 /// diagnostics, so we don't really implement this pragma. We parse it and
1030 /// ignore it to avoid -Wunknown-pragma warnings.
1031 struct PragmaWarningHandler : public PragmaHandler {
1032 PragmaWarningHandler() : PragmaHandler("warning") {}
1034 virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
1036 // Parse things like:
1039 // warning(disable : 1 2 3 ; error : 4 5 6 ; suppress : 7 8 9)
1040 SourceLocation DiagLoc = Tok.getLocation();
1041 PPCallbacks *Callbacks = PP.getPPCallbacks();
1044 if (Tok.isNot(tok::l_paren)) {
1045 PP.Diag(Tok, diag::warn_pragma_warning_expected) << "(";
1050 IdentifierInfo *II = Tok.getIdentifierInfo();
1052 PP.Diag(Tok, diag::warn_pragma_warning_spec_invalid);
1056 if (II->isStr("push")) {
1057 // #pragma warning( push[ ,n ] )
1060 if (Tok.is(tok::comma)) {
1062 if (Tok.is(tok::numeric_constant))
1063 Level = LexSimpleInt(PP, Tok);
1064 if (Level < 0 || Level > 4) {
1065 PP.Diag(Tok, diag::warn_pragma_warning_push_level);
1070 Callbacks->PragmaWarningPush(DiagLoc, Level);
1071 } else if (II->isStr("pop")) {
1072 // #pragma warning( pop )
1075 Callbacks->PragmaWarningPop(DiagLoc);
1077 // #pragma warning( warning-specifier : warning-number-list
1078 // [; warning-specifier : warning-number-list...] )
1080 II = Tok.getIdentifierInfo();
1082 PP.Diag(Tok, diag::warn_pragma_warning_spec_invalid);
1086 // Figure out which warning specifier this is.
1087 StringRef Specifier = II->getName();
1088 bool SpecifierValid =
1089 llvm::StringSwitch<bool>(Specifier)
1090 .Cases("1", "2", "3", "4", true)
1091 .Cases("default", "disable", "error", "once", "suppress", true)
1093 if (!SpecifierValid) {
1094 PP.Diag(Tok, diag::warn_pragma_warning_spec_invalid);
1098 if (Tok.isNot(tok::colon)) {
1099 PP.Diag(Tok, diag::warn_pragma_warning_expected) << ":";
1103 // Collect the warning ids.
1104 SmallVector<int, 4> Ids;
1106 while (Tok.is(tok::numeric_constant)) {
1107 int Id = LexSimpleInt(PP, Tok);
1109 PP.Diag(Tok, diag::warn_pragma_warning_expected_number);
1115 Callbacks->PragmaWarning(DiagLoc, Specifier, Ids);
1117 // Parse the next specifier if there is a semicolon.
1118 if (Tok.isNot(tok::semi))
1124 if (Tok.isNot(tok::r_paren)) {
1125 PP.Diag(Tok, diag::warn_pragma_warning_expected) << ")";
1130 if (Tok.isNot(tok::eod))
1131 PP.Diag(Tok, diag::ext_pp_extra_tokens_at_eol) << "pragma warning";
1135 /// PragmaIncludeAliasHandler - "\#pragma include_alias("...")".
1136 struct PragmaIncludeAliasHandler : public PragmaHandler {
1137 PragmaIncludeAliasHandler() : PragmaHandler("include_alias") {}
1138 virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
1139 Token &IncludeAliasTok) {
1140 PP.HandlePragmaIncludeAlias(IncludeAliasTok);
1144 /// PragmaMessageHandler - Handle the microsoft and gcc \#pragma message
1145 /// extension. The syntax is:
1147 /// #pragma message(string)
1149 /// OR, in GCC mode:
1151 /// #pragma message string
1153 /// string is a string, which is fully macro expanded, and permits string
1154 /// concatenation, embedded escape characters, etc... See MSDN for more details.
1155 /// Also handles \#pragma GCC warning and \#pragma GCC error which take the same
1156 /// form as \#pragma message.
1157 struct PragmaMessageHandler : public PragmaHandler {
1159 const PPCallbacks::PragmaMessageKind Kind;
1160 const StringRef Namespace;
1162 static const char* PragmaKind(PPCallbacks::PragmaMessageKind Kind,
1163 bool PragmaNameOnly = false) {
1165 case PPCallbacks::PMK_Message:
1166 return PragmaNameOnly ? "message" : "pragma message";
1167 case PPCallbacks::PMK_Warning:
1168 return PragmaNameOnly ? "warning" : "pragma warning";
1169 case PPCallbacks::PMK_Error:
1170 return PragmaNameOnly ? "error" : "pragma error";
1172 llvm_unreachable("Unknown PragmaMessageKind!");
1176 PragmaMessageHandler(PPCallbacks::PragmaMessageKind Kind,
1177 StringRef Namespace = StringRef())
1178 : PragmaHandler(PragmaKind(Kind, true)), Kind(Kind), Namespace(Namespace) {}
1180 virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
1182 SourceLocation MessageLoc = Tok.getLocation();
1184 bool ExpectClosingParen = false;
1185 switch (Tok.getKind()) {
1187 // We have a MSVC style pragma message.
1188 ExpectClosingParen = true;
1192 case tok::string_literal:
1193 // We have a GCC style pragma message, and we just read the string.
1196 PP.Diag(MessageLoc, diag::err_pragma_message_malformed) << Kind;
1200 std::string MessageString;
1201 if (!PP.FinishLexStringLiteral(Tok, MessageString, PragmaKind(Kind),
1202 /*MacroExpansion=*/true))
1205 if (ExpectClosingParen) {
1206 if (Tok.isNot(tok::r_paren)) {
1207 PP.Diag(Tok.getLocation(), diag::err_pragma_message_malformed) << Kind;
1210 PP.Lex(Tok); // eat the r_paren.
1213 if (Tok.isNot(tok::eod)) {
1214 PP.Diag(Tok.getLocation(), diag::err_pragma_message_malformed) << Kind;
1218 // Output the message.
1219 PP.Diag(MessageLoc, (Kind == PPCallbacks::PMK_Error)
1220 ? diag::err_pragma_message
1221 : diag::warn_pragma_message) << MessageString;
1223 // If the pragma is lexically sound, notify any interested PPCallbacks.
1224 if (PPCallbacks *Callbacks = PP.getPPCallbacks())
1225 Callbacks->PragmaMessage(MessageLoc, Namespace, Kind, MessageString);
1229 /// PragmaPushMacroHandler - "\#pragma push_macro" saves the value of the
1230 /// macro on the top of the stack.
1231 struct PragmaPushMacroHandler : public PragmaHandler {
1232 PragmaPushMacroHandler() : PragmaHandler("push_macro") {}
1233 virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
1234 Token &PushMacroTok) {
1235 PP.HandlePragmaPushMacro(PushMacroTok);
1240 /// PragmaPopMacroHandler - "\#pragma pop_macro" sets the value of the
1241 /// macro to the value on the top of the stack.
1242 struct PragmaPopMacroHandler : public PragmaHandler {
1243 PragmaPopMacroHandler() : PragmaHandler("pop_macro") {}
1244 virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
1245 Token &PopMacroTok) {
1246 PP.HandlePragmaPopMacro(PopMacroTok);
1250 // Pragma STDC implementations.
1252 /// PragmaSTDC_FENV_ACCESSHandler - "\#pragma STDC FENV_ACCESS ...".
1253 struct PragmaSTDC_FENV_ACCESSHandler : public PragmaHandler {
1254 PragmaSTDC_FENV_ACCESSHandler() : PragmaHandler("FENV_ACCESS") {}
1255 virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
1257 tok::OnOffSwitch OOS;
1258 if (PP.LexOnOffSwitch(OOS))
1260 if (OOS == tok::OOS_ON)
1261 PP.Diag(Tok, diag::warn_stdc_fenv_access_not_supported);
1265 /// PragmaSTDC_CX_LIMITED_RANGEHandler - "\#pragma STDC CX_LIMITED_RANGE ...".
1266 struct PragmaSTDC_CX_LIMITED_RANGEHandler : public PragmaHandler {
1267 PragmaSTDC_CX_LIMITED_RANGEHandler()
1268 : PragmaHandler("CX_LIMITED_RANGE") {}
1269 virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
1271 tok::OnOffSwitch OOS;
1272 PP.LexOnOffSwitch(OOS);
1276 /// PragmaSTDC_UnknownHandler - "\#pragma STDC ...".
1277 struct PragmaSTDC_UnknownHandler : public PragmaHandler {
1278 PragmaSTDC_UnknownHandler() {}
1279 virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
1280 Token &UnknownTok) {
1281 // C99 6.10.6p2, unknown forms are not allowed.
1282 PP.Diag(UnknownTok, diag::ext_stdc_pragma_ignored);
1286 /// PragmaARCCFCodeAuditedHandler -
1287 /// \#pragma clang arc_cf_code_audited begin/end
1288 struct PragmaARCCFCodeAuditedHandler : public PragmaHandler {
1289 PragmaARCCFCodeAuditedHandler() : PragmaHandler("arc_cf_code_audited") {}
1290 virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
1292 SourceLocation Loc = NameTok.getLocation();
1297 // Lex the 'begin' or 'end'.
1298 PP.LexUnexpandedToken(Tok);
1299 const IdentifierInfo *BeginEnd = Tok.getIdentifierInfo();
1300 if (BeginEnd && BeginEnd->isStr("begin")) {
1302 } else if (BeginEnd && BeginEnd->isStr("end")) {
1305 PP.Diag(Tok.getLocation(), diag::err_pp_arc_cf_code_audited_syntax);
1309 // Verify that this is followed by EOD.
1310 PP.LexUnexpandedToken(Tok);
1311 if (Tok.isNot(tok::eod))
1312 PP.Diag(Tok, diag::ext_pp_extra_tokens_at_eol) << "pragma";
1314 // The start location of the active audit.
1315 SourceLocation BeginLoc = PP.getPragmaARCCFCodeAuditedLoc();
1317 // The start location we want after processing this.
1318 SourceLocation NewLoc;
1321 // Complain about attempts to re-enter an audit.
1322 if (BeginLoc.isValid()) {
1323 PP.Diag(Loc, diag::err_pp_double_begin_of_arc_cf_code_audited);
1324 PP.Diag(BeginLoc, diag::note_pragma_entered_here);
1328 // Complain about attempts to leave an audit that doesn't exist.
1329 if (!BeginLoc.isValid()) {
1330 PP.Diag(Loc, diag::err_pp_unmatched_end_of_arc_cf_code_audited);
1333 NewLoc = SourceLocation();
1336 PP.setPragmaARCCFCodeAuditedLoc(NewLoc);
1340 /// \brief Handle "\#pragma region [...]"
1344 /// #pragma region [optional name]
1345 /// #pragma endregion [optional comment]
1349 /// <a href="http://msdn.microsoft.com/en-us/library/b6xkz944(v=vs.80).aspx">editor-only</a>
1350 /// pragma, just skipped by compiler.
1351 struct PragmaRegionHandler : public PragmaHandler {
1352 PragmaRegionHandler(const char *pragma) : PragmaHandler(pragma) { }
1354 virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
1356 // #pragma region: endregion matches can be verified
1357 // __pragma(region): no sense, but ignored by msvc
1358 // _Pragma is not valid for MSVC, but there isn't any point
1359 // to handle a _Pragma differently.
1363 } // end anonymous namespace
1366 /// RegisterBuiltinPragmas - Install the standard preprocessor pragmas:
1367 /// \#pragma GCC poison/system_header/dependency and \#pragma once.
1368 void Preprocessor::RegisterBuiltinPragmas() {
1369 AddPragmaHandler(new PragmaOnceHandler());
1370 AddPragmaHandler(new PragmaMarkHandler());
1371 AddPragmaHandler(new PragmaPushMacroHandler());
1372 AddPragmaHandler(new PragmaPopMacroHandler());
1373 AddPragmaHandler(new PragmaMessageHandler(PPCallbacks::PMK_Message));
1376 AddPragmaHandler("GCC", new PragmaPoisonHandler());
1377 AddPragmaHandler("GCC", new PragmaSystemHeaderHandler());
1378 AddPragmaHandler("GCC", new PragmaDependencyHandler());
1379 AddPragmaHandler("GCC", new PragmaDiagnosticHandler("GCC"));
1380 AddPragmaHandler("GCC", new PragmaMessageHandler(PPCallbacks::PMK_Warning,
1382 AddPragmaHandler("GCC", new PragmaMessageHandler(PPCallbacks::PMK_Error,
1384 // #pragma clang ...
1385 AddPragmaHandler("clang", new PragmaPoisonHandler());
1386 AddPragmaHandler("clang", new PragmaSystemHeaderHandler());
1387 AddPragmaHandler("clang", new PragmaDebugHandler());
1388 AddPragmaHandler("clang", new PragmaDependencyHandler());
1389 AddPragmaHandler("clang", new PragmaDiagnosticHandler("clang"));
1390 AddPragmaHandler("clang", new PragmaARCCFCodeAuditedHandler());
1392 AddPragmaHandler("STDC", new PragmaSTDC_FENV_ACCESSHandler());
1393 AddPragmaHandler("STDC", new PragmaSTDC_CX_LIMITED_RANGEHandler());
1394 AddPragmaHandler("STDC", new PragmaSTDC_UnknownHandler());
1397 if (LangOpts.MicrosoftExt) {
1398 AddPragmaHandler(new PragmaWarningHandler());
1399 AddPragmaHandler(new PragmaIncludeAliasHandler());
1400 AddPragmaHandler(new PragmaRegionHandler("region"));
1401 AddPragmaHandler(new PragmaRegionHandler("endregion"));