2006-06-25 05:31:03 +08:00
|
|
|
//===--- Pragma.cpp - Pragma registration and handling --------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 03:59:25 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2006-06-25 05:31:03 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2006-07-03 06:41:36 +08:00
|
|
|
// This file implements the PragmaHandler/PragmaTable interfaces and implements
|
|
|
|
// pragma related methods of the Preprocessor class.
|
2006-06-25 05:31:03 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "clang/Lex/Pragma.h"
|
2006-10-22 15:28:56 +08:00
|
|
|
#include "clang/Lex/HeaderSearch.h"
|
2009-01-17 02:59:23 +08:00
|
|
|
#include "clang/Lex/LiteralSupport.h"
|
2006-06-25 05:31:03 +08:00
|
|
|
#include "clang/Lex/Preprocessor.h"
|
2009-01-29 13:15:15 +08:00
|
|
|
#include "clang/Lex/LexDiagnostic.h"
|
2006-07-03 06:41:36 +08:00
|
|
|
#include "clang/Basic/FileManager.h"
|
|
|
|
#include "clang/Basic/SourceManager.h"
|
Add support for retrieving the Doxygen comment associated with a given
declaration in the AST.
The new ASTContext::getCommentForDecl function searches for a comment
that is attached to the given declaration, and returns that comment,
which may be composed of several comment blocks.
Comments are always available in an AST. However, to avoid harming
performance, we don't actually parse the comments. Rather, we keep the
source ranges of all of the comments within a large, sorted vector,
then lazily extract comments via a binary search in that vector only
when needed (which never occurs in a "normal" compile).
Comments are written to a precompiled header/AST file as a blob of
source ranges. That blob is only lazily loaded when one requests a
comment for a declaration (this never occurs in a "normal" compile).
The indexer testbed now supports comment extraction. When the
-point-at location points to a declaration with a Doxygen-style
comment, the indexer testbed prints the associated comment
block(s). See test/Index/comments.c for an example.
Some notes:
- We don't actually attempt to parse the comment blocks themselves,
beyond identifying them as Doxygen comment blocks to associate them
with a declaration.
- We won't find comment blocks that aren't adjacent to the
declaration, because we start our search based on the location of
the declaration.
- We don't go through the necessary hops to find, for example,
whether some redeclaration of a declaration has comments when our
current declaration does not. Similarly, we don't attempt to
associate a \param Foo marker in a function body comment with the
parameter named Foo (although that is certainly possible).
- Verification of my "no performance impact" claims is still "to be
done".
llvm-svn: 74704
2009-07-03 01:08:52 +08:00
|
|
|
#include <algorithm>
|
2006-06-25 05:31:03 +08:00
|
|
|
using namespace clang;
|
|
|
|
|
|
|
|
// Out-of-line destructor to provide a home for the class.
|
|
|
|
PragmaHandler::~PragmaHandler() {
|
|
|
|
}
|
|
|
|
|
2006-07-03 13:34:41 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// PragmaNamespace Implementation.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
|
|
PragmaNamespace::~PragmaNamespace() {
|
|
|
|
for (unsigned i = 0, e = Handlers.size(); i != e; ++i)
|
|
|
|
delete Handlers[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
/// FindHandler - Check to see if there is already a handler for the
|
|
|
|
/// specified name. If not, return the handler for the null identifier if it
|
|
|
|
/// exists, otherwise return null. If IgnoreNull is true (the default) then
|
|
|
|
/// the null handler isn't returned on failure to match.
|
2006-07-05 01:53:21 +08:00
|
|
|
PragmaHandler *PragmaNamespace::FindHandler(const IdentifierInfo *Name,
|
2006-07-03 13:34:41 +08:00
|
|
|
bool IgnoreNull) const {
|
|
|
|
PragmaHandler *NullHandler = 0;
|
|
|
|
for (unsigned i = 0, e = Handlers.size(); i != e; ++i) {
|
|
|
|
if (Handlers[i]->getName() == Name)
|
|
|
|
return Handlers[i];
|
|
|
|
|
|
|
|
if (Handlers[i]->getName() == 0)
|
|
|
|
NullHandler = Handlers[i];
|
|
|
|
}
|
|
|
|
return IgnoreNull ? 0 : NullHandler;
|
|
|
|
}
|
|
|
|
|
2008-10-05 03:17:46 +08:00
|
|
|
void PragmaNamespace::RemovePragmaHandler(PragmaHandler *Handler) {
|
|
|
|
for (unsigned i = 0, e = Handlers.size(); i != e; ++i) {
|
|
|
|
if (Handlers[i] == Handler) {
|
|
|
|
Handlers[i] = Handlers.back();
|
|
|
|
Handlers.pop_back();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
assert(0 && "Handler not registered in this namespace");
|
|
|
|
}
|
|
|
|
|
2007-07-21 00:59:19 +08:00
|
|
|
void PragmaNamespace::HandlePragma(Preprocessor &PP, Token &Tok) {
|
2006-06-25 05:31:03 +08:00
|
|
|
// Read the 'namespace' that the directive is in, e.g. STDC. Do not macro
|
|
|
|
// expand it, the user can have a STDC #define, that should not affect this.
|
|
|
|
PP.LexUnexpandedToken(Tok);
|
|
|
|
|
|
|
|
// Get the handler for this token. If there is no handler, ignore the pragma.
|
|
|
|
PragmaHandler *Handler = FindHandler(Tok.getIdentifierInfo(), false);
|
2009-04-20 05:10:26 +08:00
|
|
|
if (Handler == 0) {
|
|
|
|
PP.Diag(Tok, diag::warn_pragma_ignored);
|
|
|
|
return;
|
|
|
|
}
|
2006-06-25 05:31:03 +08:00
|
|
|
|
|
|
|
// Otherwise, pass it down.
|
|
|
|
Handler->HandlePragma(PP, Tok);
|
|
|
|
}
|
2006-07-03 06:41:36 +08:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Preprocessor Pragma Directive Handling.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
/// HandlePragmaDirective - The "#pragma" directive has been parsed. Lex the
|
|
|
|
/// rest of the pragma, passing it to the registered pragma handlers.
|
|
|
|
void Preprocessor::HandlePragmaDirective() {
|
|
|
|
++NumPragma;
|
|
|
|
|
|
|
|
// Invoke the first level of pragma handlers which reads the namespace id.
|
2007-07-21 00:59:19 +08:00
|
|
|
Token Tok;
|
2006-07-03 06:41:36 +08:00
|
|
|
PragmaHandlers->HandlePragma(*this, Tok);
|
|
|
|
|
|
|
|
// If the pragma handler didn't read the rest of the line, consume it now.
|
2009-06-18 13:55:53 +08:00
|
|
|
if (CurPPLexer && CurPPLexer->ParsingPreprocessorDirective)
|
2006-07-03 06:41:36 +08:00
|
|
|
DiscardUntilEndOfDirective();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Handle_Pragma - Read a _Pragma directive, slice it up, process it, then
|
|
|
|
/// return the first token after the directive. The _Pragma token has just
|
|
|
|
/// been read into 'Tok'.
|
2007-07-21 00:59:19 +08:00
|
|
|
void Preprocessor::Handle_Pragma(Token &Tok) {
|
2006-07-03 06:41:36 +08:00
|
|
|
// Remember the pragma token location.
|
|
|
|
SourceLocation PragmaLoc = Tok.getLocation();
|
|
|
|
|
|
|
|
// Read the '('.
|
|
|
|
Lex(Tok);
|
2008-11-18 15:59:24 +08:00
|
|
|
if (Tok.isNot(tok::l_paren)) {
|
|
|
|
Diag(PragmaLoc, diag::err__Pragma_malformed);
|
|
|
|
return;
|
|
|
|
}
|
2006-07-03 06:41:36 +08:00
|
|
|
|
|
|
|
// Read the '"..."'.
|
|
|
|
Lex(Tok);
|
2008-11-18 15:59:24 +08:00
|
|
|
if (Tok.isNot(tok::string_literal) && Tok.isNot(tok::wide_string_literal)) {
|
|
|
|
Diag(PragmaLoc, diag::err__Pragma_malformed);
|
|
|
|
return;
|
|
|
|
}
|
2006-07-03 06:41:36 +08:00
|
|
|
|
|
|
|
// Remember the string.
|
|
|
|
std::string StrVal = getSpelling(Tok);
|
|
|
|
|
|
|
|
// Read the ')'.
|
|
|
|
Lex(Tok);
|
2008-11-18 15:59:24 +08:00
|
|
|
if (Tok.isNot(tok::r_paren)) {
|
|
|
|
Diag(PragmaLoc, diag::err__Pragma_malformed);
|
|
|
|
return;
|
|
|
|
}
|
2006-07-03 06:41:36 +08:00
|
|
|
|
2009-02-16 04:52:18 +08:00
|
|
|
SourceLocation RParenLoc = Tok.getLocation();
|
|
|
|
|
2009-01-17 02:59:23 +08:00
|
|
|
// The _Pragma is lexically sound. Destringize according to C99 6.10.9.1:
|
|
|
|
// "The string literal is destringized by deleting the L prefix, if present,
|
|
|
|
// deleting the leading and trailing double-quotes, replacing each escape
|
|
|
|
// sequence \" by a double-quote, and replacing each escape sequence \\ by a
|
|
|
|
// single backslash."
|
2006-07-03 06:41:36 +08:00
|
|
|
if (StrVal[0] == 'L') // Remove L prefix.
|
|
|
|
StrVal.erase(StrVal.begin());
|
|
|
|
assert(StrVal[0] == '"' && StrVal[StrVal.size()-1] == '"' &&
|
|
|
|
"Invalid string token!");
|
|
|
|
|
|
|
|
// Remove the front quote, replacing it with a space, so that the pragma
|
|
|
|
// contents appear to have a space before them.
|
|
|
|
StrVal[0] = ' ';
|
|
|
|
|
2009-03-08 16:08:45 +08:00
|
|
|
// Replace the terminating quote with a \n.
|
2006-07-03 06:41:36 +08:00
|
|
|
StrVal[StrVal.size()-1] = '\n';
|
|
|
|
|
|
|
|
// Remove escaped quotes and escapes.
|
|
|
|
for (unsigned i = 0, e = StrVal.size(); i != e-1; ++i) {
|
|
|
|
if (StrVal[i] == '\\' &&
|
|
|
|
(StrVal[i+1] == '\\' || StrVal[i+1] == '"')) {
|
|
|
|
// \\ -> '\' and \" -> '"'.
|
|
|
|
StrVal.erase(StrVal.begin()+i);
|
|
|
|
--e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-19 13:01:18 +08:00
|
|
|
// Plop the string (including the newline and trailing null) into a buffer
|
|
|
|
// where we can lex it.
|
2009-01-27 03:29:26 +08:00
|
|
|
Token TmpTok;
|
|
|
|
TmpTok.startToken();
|
|
|
|
CreateString(&StrVal[0], StrVal.size(), TmpTok);
|
|
|
|
SourceLocation TokLoc = TmpTok.getLocation();
|
2006-07-03 06:41:36 +08:00
|
|
|
|
|
|
|
// Make and enter a lexer object so that we lex and expand the tokens just
|
|
|
|
// like any others.
|
2009-02-16 04:52:18 +08:00
|
|
|
Lexer *TL = Lexer::Create_PragmaLexer(TokLoc, PragmaLoc, RParenLoc,
|
2009-03-08 16:08:45 +08:00
|
|
|
StrVal.size(), *this);
|
2006-07-03 07:00:20 +08:00
|
|
|
|
|
|
|
EnterSourceFileWithLexer(TL, 0);
|
|
|
|
|
2006-07-03 06:41:36 +08:00
|
|
|
// With everything set up, lex this as a #pragma directive.
|
|
|
|
HandlePragmaDirective();
|
|
|
|
|
|
|
|
// Finally, return whatever came after the pragma directive.
|
|
|
|
return Lex(Tok);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// HandlePragmaOnce - Handle #pragma once. OnceTok is the 'once'.
|
|
|
|
///
|
2007-07-21 00:59:19 +08:00
|
|
|
void Preprocessor::HandlePragmaOnce(Token &OnceTok) {
|
2006-07-03 06:41:36 +08:00
|
|
|
if (isInPrimaryFile()) {
|
|
|
|
Diag(OnceTok, diag::pp_pragma_once_in_main_file);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the current file lexer we're looking at. Ignore _Pragma 'files' etc.
|
|
|
|
// Mark the file as a once-only file now.
|
2009-01-17 14:22:33 +08:00
|
|
|
HeaderInfo.MarkFileIncludeOnce(getCurrentFileLexer()->getFileEntry());
|
2006-07-03 06:41:36 +08:00
|
|
|
}
|
|
|
|
|
2007-12-20 03:38:36 +08:00
|
|
|
void Preprocessor::HandlePragmaMark() {
|
2008-11-20 06:21:33 +08:00
|
|
|
assert(CurPPLexer && "No current lexer?");
|
2009-06-15 13:02:34 +08:00
|
|
|
if (CurLexer)
|
|
|
|
CurLexer->ReadToEndOfLine();
|
|
|
|
else
|
|
|
|
CurPTHLexer->DiscardToEndOfLine();
|
2007-12-20 03:38:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-07-03 06:41:36 +08:00
|
|
|
/// HandlePragmaPoison - Handle #pragma GCC poison. PoisonTok is the 'poison'.
|
|
|
|
///
|
2007-07-21 00:59:19 +08:00
|
|
|
void Preprocessor::HandlePragmaPoison(Token &PoisonTok) {
|
|
|
|
Token Tok;
|
2006-07-20 12:31:52 +08:00
|
|
|
|
2006-07-03 06:41:36 +08:00
|
|
|
while (1) {
|
|
|
|
// Read the next token to poison. While doing this, pretend that we are
|
|
|
|
// skipping while reading the identifier to poison.
|
|
|
|
// This avoids errors on code like:
|
|
|
|
// #pragma GCC poison X
|
|
|
|
// #pragma GCC poison X
|
2008-11-18 09:12:54 +08:00
|
|
|
if (CurPPLexer) CurPPLexer->LexingRawMode = true;
|
2006-07-03 06:41:36 +08:00
|
|
|
LexUnexpandedToken(Tok);
|
2008-11-18 09:12:54 +08:00
|
|
|
if (CurPPLexer) CurPPLexer->LexingRawMode = false;
|
2006-07-03 06:41:36 +08:00
|
|
|
|
|
|
|
// If we reached the end of line, we're done.
|
2007-10-10 02:02:16 +08:00
|
|
|
if (Tok.is(tok::eom)) return;
|
2006-07-03 06:41:36 +08:00
|
|
|
|
|
|
|
// Can only poison identifiers.
|
2007-10-10 02:02:16 +08:00
|
|
|
if (Tok.isNot(tok::identifier)) {
|
2006-07-03 06:41:36 +08:00
|
|
|
Diag(Tok, diag::err_pp_invalid_poison);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-07-08 16:28:12 +08:00
|
|
|
// Look up the identifier info for the token. We disabled identifier lookup
|
|
|
|
// by saying we're skipping contents, so we need to do this manually.
|
|
|
|
IdentifierInfo *II = LookUpIdentifierInfo(Tok);
|
2006-07-03 06:41:36 +08:00
|
|
|
|
|
|
|
// Already poisoned.
|
|
|
|
if (II->isPoisoned()) continue;
|
|
|
|
|
|
|
|
// If this is a macro identifier, emit a warning.
|
2007-10-07 16:04:56 +08:00
|
|
|
if (II->hasMacroDefinition())
|
2006-07-03 06:41:36 +08:00
|
|
|
Diag(Tok, diag::pp_poisoning_existing_macro);
|
|
|
|
|
|
|
|
// Finally, poison it!
|
|
|
|
II->setIsPoisoned();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// HandlePragmaSystemHeader - Implement #pragma GCC system_header. We know
|
|
|
|
/// that the whole directive has been parsed.
|
2007-07-21 00:59:19 +08:00
|
|
|
void Preprocessor::HandlePragmaSystemHeader(Token &SysHeaderTok) {
|
2006-07-03 06:41:36 +08:00
|
|
|
if (isInPrimaryFile()) {
|
|
|
|
Diag(SysHeaderTok, diag::pp_pragma_sysheader_in_main_file);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the current file lexer we're looking at. Ignore _Pragma 'files' etc.
|
2008-11-20 09:45:11 +08:00
|
|
|
PreprocessorLexer *TheLexer = getCurrentFileLexer();
|
2006-07-03 06:41:36 +08:00
|
|
|
|
|
|
|
// Mark the file as a system header.
|
2009-01-17 14:22:33 +08:00
|
|
|
HeaderInfo.MarkFileSystemHeader(TheLexer->getFileEntry());
|
2006-07-03 06:41:36 +08:00
|
|
|
|
2009-06-15 13:02:34 +08:00
|
|
|
|
|
|
|
PresumedLoc PLoc = SourceMgr.getPresumedLoc(SysHeaderTok.getLocation());
|
|
|
|
unsigned FilenameLen = strlen(PLoc.getFilename());
|
|
|
|
unsigned FilenameID = SourceMgr.getLineTableFilenameID(PLoc.getFilename(),
|
|
|
|
FilenameLen);
|
|
|
|
|
|
|
|
// Emit a line marker. This will change any source locations from this point
|
|
|
|
// forward to realize they are in a system header.
|
|
|
|
// Create a line note with this information.
|
|
|
|
SourceMgr.AddLineNote(SysHeaderTok.getLocation(), PLoc.getLine(), FilenameID,
|
|
|
|
false, false, true, false);
|
|
|
|
|
2006-07-03 06:41:36 +08:00
|
|
|
// Notify the client, if desired, that we are in a new source file.
|
2006-11-21 12:09:30 +08:00
|
|
|
if (Callbacks)
|
2008-11-20 09:45:11 +08:00
|
|
|
Callbacks->FileChanged(SysHeaderTok.getLocation(),
|
2008-09-27 05:18:42 +08:00
|
|
|
PPCallbacks::SystemHeaderPragma, SrcMgr::C_System);
|
2006-07-03 06:41:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// HandlePragmaDependency - Handle #pragma GCC dependency "foo" blah.
|
|
|
|
///
|
2007-07-21 00:59:19 +08:00
|
|
|
void Preprocessor::HandlePragmaDependency(Token &DependencyTok) {
|
|
|
|
Token FilenameTok;
|
2008-11-18 09:12:54 +08:00
|
|
|
CurPPLexer->LexIncludeFilename(FilenameTok);
|
2006-07-03 06:41:36 +08:00
|
|
|
|
|
|
|
// If the token kind is EOM, the error has already been diagnosed.
|
2007-10-10 02:02:16 +08:00
|
|
|
if (FilenameTok.is(tok::eom))
|
2006-07-03 06:41:36 +08:00
|
|
|
return;
|
|
|
|
|
2006-10-30 13:58:32 +08:00
|
|
|
// Reserve a buffer to get the spelling.
|
2007-06-16 07:05:46 +08:00
|
|
|
llvm::SmallVector<char, 128> FilenameBuffer;
|
2006-10-30 13:58:32 +08:00
|
|
|
FilenameBuffer.resize(FilenameTok.getLength());
|
|
|
|
|
2007-07-23 12:15:27 +08:00
|
|
|
const char *FilenameStart = &FilenameBuffer[0];
|
|
|
|
unsigned Len = getSpelling(FilenameTok, FilenameStart);
|
|
|
|
const char *FilenameEnd = FilenameStart+Len;
|
|
|
|
bool isAngled = GetIncludeFilenameSpelling(FilenameTok.getLocation(),
|
2006-10-30 13:58:32 +08:00
|
|
|
FilenameStart, FilenameEnd);
|
|
|
|
// If GetIncludeFilenameSpelling set the start ptr to null, there was an
|
|
|
|
// error.
|
|
|
|
if (FilenameStart == 0)
|
|
|
|
return;
|
2006-07-03 06:41:36 +08:00
|
|
|
|
2006-10-18 13:34:33 +08:00
|
|
|
// Search include directories for this file.
|
2006-07-03 06:41:36 +08:00
|
|
|
const DirectoryLookup *CurDir;
|
2006-10-30 13:58:32 +08:00
|
|
|
const FileEntry *File = LookupFile(FilenameStart, FilenameEnd,
|
2006-10-30 13:38:06 +08:00
|
|
|
isAngled, 0, CurDir);
|
2008-11-18 16:02:48 +08:00
|
|
|
if (File == 0) {
|
|
|
|
Diag(FilenameTok, diag::err_pp_file_not_found)
|
|
|
|
<< std::string(FilenameStart, FilenameEnd);
|
|
|
|
return;
|
|
|
|
}
|
2006-07-03 06:41:36 +08:00
|
|
|
|
2009-01-17 14:22:33 +08:00
|
|
|
const FileEntry *CurFile = getCurrentFileLexer()->getFileEntry();
|
2006-07-03 06:41:36 +08:00
|
|
|
|
|
|
|
// If this file is older than the file it depends on, emit a diagnostic.
|
|
|
|
if (CurFile && CurFile->getModificationTime() < File->getModificationTime()) {
|
|
|
|
// Lex tokens at the end of the message and include them in the message.
|
|
|
|
std::string Message;
|
|
|
|
Lex(DependencyTok);
|
2007-10-10 02:02:16 +08:00
|
|
|
while (DependencyTok.isNot(tok::eom)) {
|
2006-07-03 06:41:36 +08:00
|
|
|
Message += getSpelling(DependencyTok) + " ";
|
|
|
|
Lex(DependencyTok);
|
|
|
|
}
|
|
|
|
|
|
|
|
Message.erase(Message.end()-1);
|
2008-11-18 16:02:48 +08:00
|
|
|
Diag(FilenameTok, diag::pp_out_of_date_dependency) << Message;
|
2006-07-03 06:41:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-16 16:21:25 +08:00
|
|
|
/// HandlePragmaComment - Handle the microsoft #pragma comment extension. The
|
|
|
|
/// syntax is:
|
|
|
|
/// #pragma comment(linker, "foo")
|
|
|
|
/// 'linker' is one of five identifiers: compiler, exestr, lib, linker, user.
|
|
|
|
/// "foo" is a string, which is fully macro expanded, and permits string
|
2009-03-17 19:39:38 +08:00
|
|
|
/// concatenation, embedded escape characters etc. See MSDN for more details.
|
2009-01-16 16:21:25 +08:00
|
|
|
void Preprocessor::HandlePragmaComment(Token &Tok) {
|
|
|
|
SourceLocation CommentLoc = Tok.getLocation();
|
|
|
|
Lex(Tok);
|
|
|
|
if (Tok.isNot(tok::l_paren)) {
|
|
|
|
Diag(CommentLoc, diag::err_pragma_comment_malformed);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Read the identifier.
|
|
|
|
Lex(Tok);
|
|
|
|
if (Tok.isNot(tok::identifier)) {
|
|
|
|
Diag(CommentLoc, diag::err_pragma_comment_malformed);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Verify that this is one of the 5 whitelisted options.
|
|
|
|
// FIXME: warn that 'exestr' is deprecated.
|
|
|
|
const IdentifierInfo *II = Tok.getIdentifierInfo();
|
|
|
|
if (!II->isStr("compiler") && !II->isStr("exestr") && !II->isStr("lib") &&
|
|
|
|
!II->isStr("linker") && !II->isStr("user")) {
|
|
|
|
Diag(Tok.getLocation(), diag::err_pragma_comment_unknown_kind);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-01-17 02:59:23 +08:00
|
|
|
// Read the optional string if present.
|
2009-01-16 16:21:25 +08:00
|
|
|
Lex(Tok);
|
2009-01-17 02:59:23 +08:00
|
|
|
std::string ArgumentString;
|
2009-01-16 16:21:25 +08:00
|
|
|
if (Tok.is(tok::comma)) {
|
2009-01-17 02:59:23 +08:00
|
|
|
Lex(Tok); // eat the comma.
|
2009-01-16 16:21:25 +08:00
|
|
|
|
|
|
|
// We need at least one string.
|
2009-04-20 07:16:58 +08:00
|
|
|
if (Tok.isNot(tok::string_literal)) {
|
2009-01-16 16:21:25 +08:00
|
|
|
Diag(Tok.getLocation(), diag::err_pragma_comment_malformed);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// String concatenation allows multiple strings, which can even come from
|
|
|
|
// macro expansion.
|
|
|
|
// "foo " "bar" "Baz"
|
2009-01-17 02:59:23 +08:00
|
|
|
llvm::SmallVector<Token, 4> StrToks;
|
2009-04-20 07:16:58 +08:00
|
|
|
while (Tok.is(tok::string_literal)) {
|
2009-01-17 02:59:23 +08:00
|
|
|
StrToks.push_back(Tok);
|
2009-01-16 16:21:25 +08:00
|
|
|
Lex(Tok);
|
2009-01-17 02:59:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Concatenate and parse the strings.
|
|
|
|
StringLiteralParser Literal(&StrToks[0], StrToks.size(), *this);
|
|
|
|
assert(!Literal.AnyWide && "Didn't allow wide strings in");
|
|
|
|
if (Literal.hadError)
|
|
|
|
return;
|
|
|
|
if (Literal.Pascal) {
|
|
|
|
Diag(StrToks[0].getLocation(), diag::err_pragma_comment_malformed);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ArgumentString = std::string(Literal.GetString(),
|
|
|
|
Literal.GetString()+Literal.GetStringLength());
|
2009-01-16 16:21:25 +08:00
|
|
|
}
|
|
|
|
|
2009-01-17 02:59:23 +08:00
|
|
|
// FIXME: If the kind is "compiler" warn if the string is present (it is
|
|
|
|
// ignored).
|
|
|
|
// FIXME: 'lib' requires a comment string.
|
|
|
|
// FIXME: 'linker' requires a comment string, and has a specific list of
|
|
|
|
// things that are allowable.
|
|
|
|
|
2009-01-16 16:21:25 +08:00
|
|
|
if (Tok.isNot(tok::r_paren)) {
|
|
|
|
Diag(Tok.getLocation(), diag::err_pragma_comment_malformed);
|
|
|
|
return;
|
|
|
|
}
|
2009-01-17 02:59:23 +08:00
|
|
|
Lex(Tok); // eat the r_paren.
|
2009-01-16 16:21:25 +08:00
|
|
|
|
|
|
|
if (Tok.isNot(tok::eom)) {
|
|
|
|
Diag(Tok.getLocation(), diag::err_pragma_comment_malformed);
|
|
|
|
return;
|
|
|
|
}
|
2009-01-17 02:59:23 +08:00
|
|
|
|
|
|
|
// If the pragma is lexically sound, notify any interested PPCallbacks.
|
2009-01-17 03:01:46 +08:00
|
|
|
if (Callbacks)
|
|
|
|
Callbacks->PragmaComment(CommentLoc, II, ArgumentString);
|
2009-01-16 16:21:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-07-03 06:41:36 +08:00
|
|
|
|
|
|
|
/// AddPragmaHandler - Add the specified pragma handler to the preprocessor.
|
|
|
|
/// If 'Namespace' is non-null, then it is a token required to exist on the
|
|
|
|
/// pragma line before the pragma string starts, e.g. "STDC" or "GCC".
|
|
|
|
void Preprocessor::AddPragmaHandler(const char *Namespace,
|
|
|
|
PragmaHandler *Handler) {
|
|
|
|
PragmaNamespace *InsertNS = PragmaHandlers;
|
|
|
|
|
|
|
|
// If this is specified to be in a namespace, step down into it.
|
|
|
|
if (Namespace) {
|
2006-07-05 01:53:21 +08:00
|
|
|
IdentifierInfo *NSID = getIdentifierInfo(Namespace);
|
2006-07-03 06:41:36 +08:00
|
|
|
|
|
|
|
// If there is already a pragma handler with the name of this namespace,
|
|
|
|
// we either have an error (directive with the same name as a namespace) or
|
|
|
|
// we already have the namespace to insert into.
|
|
|
|
if (PragmaHandler *Existing = PragmaHandlers->FindHandler(NSID)) {
|
|
|
|
InsertNS = Existing->getIfNamespace();
|
|
|
|
assert(InsertNS != 0 && "Cannot have a pragma namespace and pragma"
|
|
|
|
" handler with the same name!");
|
|
|
|
} else {
|
|
|
|
// Otherwise, this namespace doesn't exist yet, create and insert the
|
|
|
|
// handler for it.
|
|
|
|
InsertNS = new PragmaNamespace(NSID);
|
|
|
|
PragmaHandlers->AddPragma(InsertNS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check to make sure we don't already have a pragma for this identifier.
|
|
|
|
assert(!InsertNS->FindHandler(Handler->getName()) &&
|
|
|
|
"Pragma handler already exists for this identifier!");
|
|
|
|
InsertNS->AddPragma(Handler);
|
|
|
|
}
|
|
|
|
|
2008-10-05 03:17:46 +08:00
|
|
|
/// RemovePragmaHandler - Remove the specific pragma handler from the
|
|
|
|
/// preprocessor. If \arg Namespace is non-null, then it should be the
|
|
|
|
/// namespace that \arg Handler was added to. It is an error to remove
|
|
|
|
/// a handler that has not been registered.
|
|
|
|
void Preprocessor::RemovePragmaHandler(const char *Namespace,
|
|
|
|
PragmaHandler *Handler) {
|
|
|
|
PragmaNamespace *NS = PragmaHandlers;
|
|
|
|
|
|
|
|
// If this is specified to be in a namespace, step down into it.
|
|
|
|
if (Namespace) {
|
|
|
|
IdentifierInfo *NSID = getIdentifierInfo(Namespace);
|
|
|
|
PragmaHandler *Existing = PragmaHandlers->FindHandler(NSID);
|
|
|
|
assert(Existing && "Namespace containing handler does not exist!");
|
|
|
|
|
|
|
|
NS = Existing->getIfNamespace();
|
|
|
|
assert(NS && "Invalid namespace, registered as a regular pragma handler!");
|
|
|
|
}
|
|
|
|
|
|
|
|
NS->RemovePragmaHandler(Handler);
|
|
|
|
|
|
|
|
// If this is a non-default namespace and it is now empty, remove
|
|
|
|
// it.
|
|
|
|
if (NS != PragmaHandlers && NS->IsEmpty())
|
|
|
|
PragmaHandlers->RemovePragmaHandler(NS);
|
|
|
|
}
|
|
|
|
|
2006-07-03 06:41:36 +08:00
|
|
|
namespace {
|
2007-12-20 03:38:36 +08:00
|
|
|
/// PragmaOnceHandler - "#pragma once" marks the file as atomically included.
|
2006-07-03 06:41:36 +08:00
|
|
|
struct PragmaOnceHandler : public PragmaHandler {
|
2006-07-05 01:53:21 +08:00
|
|
|
PragmaOnceHandler(const IdentifierInfo *OnceID) : PragmaHandler(OnceID) {}
|
2007-07-21 00:59:19 +08:00
|
|
|
virtual void HandlePragma(Preprocessor &PP, Token &OnceTok) {
|
2009-04-14 13:07:49 +08:00
|
|
|
PP.CheckEndOfDirective("pragma once");
|
2006-07-03 06:41:36 +08:00
|
|
|
PP.HandlePragmaOnce(OnceTok);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2007-12-20 03:38:36 +08:00
|
|
|
/// PragmaMarkHandler - "#pragma mark ..." is ignored by the compiler, and the
|
|
|
|
/// rest of the line is not lexed.
|
|
|
|
struct PragmaMarkHandler : public PragmaHandler {
|
|
|
|
PragmaMarkHandler(const IdentifierInfo *MarkID) : PragmaHandler(MarkID) {}
|
|
|
|
virtual void HandlePragma(Preprocessor &PP, Token &MarkTok) {
|
|
|
|
PP.HandlePragmaMark();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// PragmaPoisonHandler - "#pragma poison x" marks x as not usable.
|
2006-07-03 06:41:36 +08:00
|
|
|
struct PragmaPoisonHandler : public PragmaHandler {
|
2006-07-05 01:53:21 +08:00
|
|
|
PragmaPoisonHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {}
|
2007-07-21 00:59:19 +08:00
|
|
|
virtual void HandlePragma(Preprocessor &PP, Token &PoisonTok) {
|
2006-07-03 06:41:36 +08:00
|
|
|
PP.HandlePragmaPoison(PoisonTok);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2007-12-20 03:38:36 +08:00
|
|
|
/// PragmaSystemHeaderHandler - "#pragma system_header" marks the current file
|
|
|
|
/// as a system header, which silences warnings in it.
|
2006-07-03 06:41:36 +08:00
|
|
|
struct PragmaSystemHeaderHandler : public PragmaHandler {
|
2006-07-05 01:53:21 +08:00
|
|
|
PragmaSystemHeaderHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {}
|
2007-07-21 00:59:19 +08:00
|
|
|
virtual void HandlePragma(Preprocessor &PP, Token &SHToken) {
|
2006-07-03 06:41:36 +08:00
|
|
|
PP.HandlePragmaSystemHeader(SHToken);
|
2009-04-14 13:07:49 +08:00
|
|
|
PP.CheckEndOfDirective("pragma");
|
2006-07-03 06:41:36 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
struct PragmaDependencyHandler : public PragmaHandler {
|
2006-07-05 01:53:21 +08:00
|
|
|
PragmaDependencyHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {}
|
2007-07-21 00:59:19 +08:00
|
|
|
virtual void HandlePragma(Preprocessor &PP, Token &DepToken) {
|
2006-07-03 06:41:36 +08:00
|
|
|
PP.HandlePragmaDependency(DepToken);
|
|
|
|
}
|
|
|
|
};
|
2009-01-16 16:21:25 +08:00
|
|
|
|
2009-04-20 07:16:58 +08:00
|
|
|
/// PragmaDiagnosticHandler - e.g. '#pragma GCC diagnostic ignored "-Wformat"'
|
2009-07-13 05:18:45 +08:00
|
|
|
/// Since clang's diagnostic supports extended functionality beyond GCC's
|
|
|
|
/// the constructor takes a clangMode flag to tell it whether or not to allow
|
|
|
|
/// clang's extended functionality, or whether to reject it.
|
2009-04-20 07:16:58 +08:00
|
|
|
struct PragmaDiagnosticHandler : public PragmaHandler {
|
2009-07-13 05:18:45 +08:00
|
|
|
private:
|
|
|
|
const bool ClangMode;
|
|
|
|
public:
|
|
|
|
PragmaDiagnosticHandler(const IdentifierInfo *ID,
|
|
|
|
const bool clangMode) : PragmaHandler(ID),
|
|
|
|
ClangMode(clangMode) {}
|
2009-04-20 07:16:58 +08:00
|
|
|
virtual void HandlePragma(Preprocessor &PP, Token &DiagToken) {
|
|
|
|
Token Tok;
|
|
|
|
PP.LexUnexpandedToken(Tok);
|
|
|
|
if (Tok.isNot(tok::identifier)) {
|
2009-07-13 05:18:45 +08:00
|
|
|
unsigned Diag = ClangMode ? diag::warn_pragma_diagnostic_clang_invalid
|
|
|
|
: diag::warn_pragma_diagnostic_gcc_invalid;
|
|
|
|
PP.Diag(Tok, Diag);
|
2009-04-20 07:16:58 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
IdentifierInfo *II = Tok.getIdentifierInfo();
|
|
|
|
|
|
|
|
diag::Mapping Map;
|
|
|
|
if (II->isStr("warning"))
|
|
|
|
Map = diag::MAP_WARNING;
|
|
|
|
else if (II->isStr("error"))
|
|
|
|
Map = diag::MAP_ERROR;
|
|
|
|
else if (II->isStr("ignored"))
|
|
|
|
Map = diag::MAP_IGNORE;
|
|
|
|
else if (II->isStr("fatal"))
|
|
|
|
Map = diag::MAP_FATAL;
|
2009-07-13 05:18:45 +08:00
|
|
|
else if (ClangMode) {
|
|
|
|
if (II->isStr("pop")) {
|
|
|
|
if(!PP.getDiagnostics().popMappings())
|
|
|
|
PP.Diag(Tok, diag::warn_pragma_diagnostic_clang_cannot_ppp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (II->isStr("push")) {
|
|
|
|
PP.getDiagnostics().pushMappings();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
PP.Diag(Tok, diag::warn_pragma_diagnostic_clang_invalid);
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
PP.Diag(Tok, diag::warn_pragma_diagnostic_gcc_invalid);
|
2009-04-20 07:16:58 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
PP.LexUnexpandedToken(Tok);
|
|
|
|
|
|
|
|
// We need at least one string.
|
|
|
|
if (Tok.isNot(tok::string_literal)) {
|
|
|
|
PP.Diag(Tok.getLocation(), diag::warn_pragma_diagnostic_invalid_token);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// String concatenation allows multiple strings, which can even come from
|
|
|
|
// macro expansion.
|
|
|
|
// "foo " "bar" "Baz"
|
|
|
|
llvm::SmallVector<Token, 4> StrToks;
|
|
|
|
while (Tok.is(tok::string_literal)) {
|
|
|
|
StrToks.push_back(Tok);
|
|
|
|
PP.LexUnexpandedToken(Tok);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Tok.isNot(tok::eom)) {
|
|
|
|
PP.Diag(Tok.getLocation(), diag::warn_pragma_diagnostic_invalid_token);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Concatenate and parse the strings.
|
|
|
|
StringLiteralParser Literal(&StrToks[0], StrToks.size(), PP);
|
|
|
|
assert(!Literal.AnyWide && "Didn't allow wide strings in");
|
|
|
|
if (Literal.hadError)
|
|
|
|
return;
|
|
|
|
if (Literal.Pascal) {
|
2009-07-13 05:18:45 +08:00
|
|
|
unsigned Diag = ClangMode ? diag::warn_pragma_diagnostic_clang_invalid
|
|
|
|
: diag::warn_pragma_diagnostic_gcc_invalid;
|
|
|
|
PP.Diag(Tok, Diag);
|
2009-04-20 07:16:58 +08:00
|
|
|
return;
|
|
|
|
}
|
2009-07-13 05:18:45 +08:00
|
|
|
|
2009-04-20 07:16:58 +08:00
|
|
|
std::string WarningName(Literal.GetString(),
|
|
|
|
Literal.GetString()+Literal.GetStringLength());
|
|
|
|
|
|
|
|
if (WarningName.size() < 3 || WarningName[0] != '-' ||
|
|
|
|
WarningName[1] != 'W') {
|
|
|
|
PP.Diag(StrToks[0].getLocation(),
|
|
|
|
diag::warn_pragma_diagnostic_invalid_option);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (PP.getDiagnostics().setDiagnosticGroupMapping(WarningName.c_str()+2,
|
|
|
|
Map))
|
|
|
|
PP.Diag(StrToks[0].getLocation(),
|
|
|
|
diag::warn_pragma_diagnostic_unknown_warning) << WarningName;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-01-16 16:21:25 +08:00
|
|
|
/// PragmaCommentHandler - "#pragma comment ...".
|
|
|
|
struct PragmaCommentHandler : public PragmaHandler {
|
|
|
|
PragmaCommentHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {}
|
|
|
|
virtual void HandlePragma(Preprocessor &PP, Token &CommentTok) {
|
|
|
|
PP.HandlePragmaComment(CommentTok);
|
|
|
|
}
|
|
|
|
};
|
2009-04-20 05:20:35 +08:00
|
|
|
|
|
|
|
// Pragma STDC implementations.
|
2009-04-20 05:50:08 +08:00
|
|
|
|
|
|
|
enum STDCSetting {
|
|
|
|
STDC_ON, STDC_OFF, STDC_DEFAULT, STDC_INVALID
|
|
|
|
};
|
|
|
|
|
|
|
|
static STDCSetting LexOnOffSwitch(Preprocessor &PP) {
|
|
|
|
Token Tok;
|
|
|
|
PP.LexUnexpandedToken(Tok);
|
|
|
|
|
|
|
|
if (Tok.isNot(tok::identifier)) {
|
|
|
|
PP.Diag(Tok, diag::ext_stdc_pragma_syntax);
|
|
|
|
return STDC_INVALID;
|
|
|
|
}
|
|
|
|
IdentifierInfo *II = Tok.getIdentifierInfo();
|
|
|
|
STDCSetting Result;
|
|
|
|
if (II->isStr("ON"))
|
|
|
|
Result = STDC_ON;
|
|
|
|
else if (II->isStr("OFF"))
|
|
|
|
Result = STDC_OFF;
|
|
|
|
else if (II->isStr("DEFAULT"))
|
|
|
|
Result = STDC_DEFAULT;
|
|
|
|
else {
|
|
|
|
PP.Diag(Tok, diag::ext_stdc_pragma_syntax);
|
|
|
|
return STDC_INVALID;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Verify that this is followed by EOM.
|
|
|
|
PP.LexUnexpandedToken(Tok);
|
|
|
|
if (Tok.isNot(tok::eom))
|
|
|
|
PP.Diag(Tok, diag::ext_stdc_pragma_syntax_eom);
|
|
|
|
return Result;
|
|
|
|
}
|
2009-04-20 05:20:35 +08:00
|
|
|
|
|
|
|
/// PragmaSTDC_FP_CONTRACTHandler - "#pragma STDC FP_CONTRACT ...".
|
|
|
|
struct PragmaSTDC_FP_CONTRACTHandler : public PragmaHandler {
|
|
|
|
PragmaSTDC_FP_CONTRACTHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {}
|
2009-04-20 05:25:37 +08:00
|
|
|
virtual void HandlePragma(Preprocessor &PP, Token &Tok) {
|
2009-04-20 05:50:08 +08:00
|
|
|
// We just ignore the setting of FP_CONTRACT. Since we don't do contractions
|
|
|
|
// at all, our default is OFF and setting it to ON is an optimization hint
|
|
|
|
// we can safely ignore. When we support -ffma or something, we would need
|
|
|
|
// to diagnose that we are ignoring FMA.
|
|
|
|
LexOnOffSwitch(PP);
|
2009-04-20 05:20:35 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// PragmaSTDC_FENV_ACCESSHandler - "#pragma STDC FENV_ACCESS ...".
|
|
|
|
struct PragmaSTDC_FENV_ACCESSHandler : public PragmaHandler {
|
|
|
|
PragmaSTDC_FENV_ACCESSHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {}
|
2009-04-20 05:25:37 +08:00
|
|
|
virtual void HandlePragma(Preprocessor &PP, Token &Tok) {
|
2009-04-20 05:55:32 +08:00
|
|
|
if (LexOnOffSwitch(PP) == STDC_ON)
|
|
|
|
PP.Diag(Tok, diag::warn_stdc_fenv_access_not_supported);
|
2009-04-20 05:20:35 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// PragmaSTDC_CX_LIMITED_RANGEHandler - "#pragma STDC CX_LIMITED_RANGE ...".
|
|
|
|
struct PragmaSTDC_CX_LIMITED_RANGEHandler : public PragmaHandler {
|
|
|
|
PragmaSTDC_CX_LIMITED_RANGEHandler(const IdentifierInfo *ID)
|
|
|
|
: PragmaHandler(ID) {}
|
2009-04-20 05:25:37 +08:00
|
|
|
virtual void HandlePragma(Preprocessor &PP, Token &Tok) {
|
2009-04-20 05:50:08 +08:00
|
|
|
LexOnOffSwitch(PP);
|
2009-04-20 05:20:35 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// PragmaSTDC_UnknownHandler - "#pragma STDC ...".
|
|
|
|
struct PragmaSTDC_UnknownHandler : public PragmaHandler {
|
|
|
|
PragmaSTDC_UnknownHandler() : PragmaHandler(0) {}
|
2009-04-20 05:25:37 +08:00
|
|
|
virtual void HandlePragma(Preprocessor &PP, Token &UnknownTok) {
|
2009-04-20 05:50:08 +08:00
|
|
|
// C99 6.10.6p2, unknown forms are not allowed.
|
2009-04-20 05:25:37 +08:00
|
|
|
PP.Diag(UnknownTok, diag::ext_stdc_pragma_ignored);
|
2009-04-20 05:20:35 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2006-07-03 06:41:36 +08:00
|
|
|
} // end anonymous namespace
|
|
|
|
|
|
|
|
|
|
|
|
/// RegisterBuiltinPragmas - Install the standard preprocessor pragmas:
|
|
|
|
/// #pragma GCC poison/system_header/dependency and #pragma once.
|
|
|
|
void Preprocessor::RegisterBuiltinPragmas() {
|
|
|
|
AddPragmaHandler(0, new PragmaOnceHandler(getIdentifierInfo("once")));
|
2007-12-20 03:38:36 +08:00
|
|
|
AddPragmaHandler(0, new PragmaMarkHandler(getIdentifierInfo("mark")));
|
2009-05-13 02:21:11 +08:00
|
|
|
|
|
|
|
// #pragma GCC ...
|
2006-07-03 06:41:36 +08:00
|
|
|
AddPragmaHandler("GCC", new PragmaPoisonHandler(getIdentifierInfo("poison")));
|
|
|
|
AddPragmaHandler("GCC", new PragmaSystemHeaderHandler(
|
|
|
|
getIdentifierInfo("system_header")));
|
|
|
|
AddPragmaHandler("GCC", new PragmaDependencyHandler(
|
|
|
|
getIdentifierInfo("dependency")));
|
2009-04-20 07:16:58 +08:00
|
|
|
AddPragmaHandler("GCC", new PragmaDiagnosticHandler(
|
2009-07-13 05:18:45 +08:00
|
|
|
getIdentifierInfo("diagnostic"),
|
|
|
|
false));
|
2009-05-13 02:21:11 +08:00
|
|
|
// #pragma clang ...
|
|
|
|
AddPragmaHandler("clang", new PragmaPoisonHandler(
|
|
|
|
getIdentifierInfo("poison")));
|
|
|
|
AddPragmaHandler("clang", new PragmaSystemHeaderHandler(
|
|
|
|
getIdentifierInfo("system_header")));
|
|
|
|
AddPragmaHandler("clang", new PragmaDependencyHandler(
|
|
|
|
getIdentifierInfo("dependency")));
|
|
|
|
AddPragmaHandler("clang", new PragmaDiagnosticHandler(
|
2009-07-13 05:18:45 +08:00
|
|
|
getIdentifierInfo("diagnostic"),
|
|
|
|
true));
|
2009-05-13 02:21:11 +08:00
|
|
|
|
2009-04-20 05:20:35 +08:00
|
|
|
AddPragmaHandler("STDC", new PragmaSTDC_FP_CONTRACTHandler(
|
|
|
|
getIdentifierInfo("FP_CONTRACT")));
|
|
|
|
AddPragmaHandler("STDC", new PragmaSTDC_FENV_ACCESSHandler(
|
|
|
|
getIdentifierInfo("FENV_ACCESS")));
|
|
|
|
AddPragmaHandler("STDC", new PragmaSTDC_CX_LIMITED_RANGEHandler(
|
|
|
|
getIdentifierInfo("CX_LIMITED_RANGE")));
|
|
|
|
AddPragmaHandler("STDC", new PragmaSTDC_UnknownHandler());
|
|
|
|
|
2009-01-16 16:21:25 +08:00
|
|
|
// MS extensions.
|
|
|
|
if (Features.Microsoft)
|
|
|
|
AddPragmaHandler(0, new PragmaCommentHandler(getIdentifierInfo("comment")));
|
2006-07-03 06:41:36 +08:00
|
|
|
}
|