diff options
Diffstat (limited to 'clang/include')
-rw-r--r-- | clang/include/clang/Basic/DiagnosticParseKinds.td | 4 | ||||
-rw-r--r-- | clang/include/clang/Basic/SourceManager.h | 20 | ||||
-rw-r--r-- | clang/include/clang/Parse/Parser.h | 3 |
3 files changed, 26 insertions, 1 deletions
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td index a5057c9d320..9811bab2936 100644 --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -20,7 +20,9 @@ def warn_file_asm_volatile : Warning< let CategoryName = "Parse Issue" in { -def ext_empty_source_file : Extension<"ISO C forbids an empty source file">; +def ext_empty_translation_unit : Extension< + "ISO C requires a translation unit to contain at least one declaration.">, + InGroup<DiagGroup<"empty-translation-unit">>; def warn_cxx98_compat_top_level_semi : Warning< "extra ';' outside of a function is incompatible with C++98">, InGroup<CXX98CompatPedantic>, DefaultIgnore; diff --git a/clang/include/clang/Basic/SourceManager.h b/clang/include/clang/Basic/SourceManager.h index 3164f874f15..f7fb1f52314 100644 --- a/clang/include/clang/Basic/SourceManager.h +++ b/clang/include/clang/Basic/SourceManager.h @@ -584,6 +584,9 @@ class SourceManager : public RefCountedBase<SourceManager> { /// \brief The file ID for the precompiled preamble there is one. FileID PreambleFileID; + /// \brief The file ID for the preprocessor's predefines. + FileID PredefinesFileID; + // Statistics for -print-stats. mutable unsigned NumLinearScans, NumBinaryProbes; @@ -628,6 +631,14 @@ public: MainFileID = createFileIDForMemBuffer(Buffer); return MainFileID; } + + /// \brief Create the FileID for a memory buffer that contains the + /// preprocessor's predefines. + FileID createPredefinesFileIDForMemBuffer(const llvm::MemoryBuffer *Buffer) { + assert(PredefinesFileID.isInvalid() && "PredefinesFileID already set!"); + PredefinesFileID = createFileIDForMemBuffer(Buffer); + return PredefinesFileID; + } //===--------------------------------------------------------------------===// // MainFileID creation and querying methods. @@ -636,6 +647,9 @@ public: /// getMainFileID - Returns the FileID of the main source file. FileID getMainFileID() const { return MainFileID; } + /// \brief Returns the FileID of the preprocessor predefines buffer. + FileID getPredefinesFileID() const { return PredefinesFileID; } + /// createMainFileID - Create the FileID for the main source file. FileID createMainFileID(const FileEntry *SourceFile, SrcMgr::CharacteristicKind Kind = SrcMgr::C_User) { @@ -1113,6 +1127,12 @@ public: return getFileID(Loc) == getMainFileID(); } + /// isFromPredefines - Returns true if the provided SourceLocation is + /// within the processor's predefines buffer. + bool isFromPredefines(SourceLocation Loc) const { + return getFileID(Loc) == getPredefinesFileID(); + } + /// isInSystemHeader - Returns if a SourceLocation is in a system header. bool isInSystemHeader(SourceLocation Loc) const { return getFileCharacteristic(Loc) != SrcMgr::C_User; diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h index 07d63209011..2222e781e80 100644 --- a/clang/include/clang/Parse/Parser.h +++ b/clang/include/clang/Parse/Parser.h @@ -730,6 +730,9 @@ private: public: DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID); DiagnosticBuilder Diag(const Token &Tok, unsigned DiagID); + DiagnosticBuilder Diag(unsigned DiagID) { + return Diag(Tok, DiagID); + } private: void SuggestParentheses(SourceLocation Loc, unsigned DK, |