diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-01-27 19:52:33 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-01-27 19:52:33 +0000 |
commit | a1f1fad8b60e1cb9d21a40a37f2e03150bcbeb6f (patch) | |
tree | 45e2eb4952da7a5bf21f923d188d30e242f72bd8 /include | |
parent | e4b92761b43ced611c417ae478568610f1ad7b1e (diff) |
Introduce module attributes into the module map grammar, along with a
single attribute ("system") that allows us to mark a module as being a
"system" module. Each of the headers that makes up a system module is
considered to be a system header, so that we (for example) suppress
warnings there.
If a module is being inferred for a framework, and that framework
directory is within a system frameworks directory, infer it as a
system framework.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149143 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/clang/Basic/DiagnosticLexKinds.td | 5 | ||||
-rw-r--r-- | include/clang/Basic/Module.h | 9 | ||||
-rw-r--r-- | include/clang/Basic/SourceManager.h | 5 | ||||
-rw-r--r-- | include/clang/Frontend/CompilerInstance.h | 13 | ||||
-rw-r--r-- | include/clang/Frontend/FrontendOptions.h | 7 | ||||
-rw-r--r-- | include/clang/Lex/HeaderSearch.h | 6 | ||||
-rw-r--r-- | include/clang/Lex/ModuleMap.h | 2 |
7 files changed, 34 insertions, 13 deletions
diff --git a/include/clang/Basic/DiagnosticLexKinds.td b/include/clang/Basic/DiagnosticLexKinds.td index 936a72e8e7..3a564c4aa8 100644 --- a/include/clang/Basic/DiagnosticLexKinds.td +++ b/include/clang/Basic/DiagnosticLexKinds.td @@ -391,6 +391,8 @@ def err_mmap_expected_module_name : Error<"expected module name">; def err_mmap_expected_lbrace : Error<"expected '{' to start module '%0'">; def err_mmap_expected_rbrace : Error<"expected '}'">; def note_mmap_lbrace_match : Note<"to match this '{'">; +def err_mmap_expected_rsquare : Error<"expected ']' to close attribute">; +def note_mmap_lsquare_match : Note<"to match this ']'">; def err_mmap_expected_member : Error< "expected umbrella, header, submodule, or module export">; def err_mmap_expected_header : Error<"expected a header name after '%0'">; @@ -429,6 +431,9 @@ def err_mmap_explicit_top_level : Error< def err_mmap_nested_submodule_id : Error< "qualified module name can only be used to define modules at the top level">; def err_mmap_expected_feature : Error<"expected a feature name">; +def err_mmap_expected_attribute : Error<"expected an attribute name">; +def warn_mmap_unknown_attribute : Warning<"unknown attribute '%0'">, + InGroup<IgnoredAttributes>; def warn_auto_module_import : Warning< "treating #%select{include|import|include_next|__include_macros}0 as an " diff --git a/include/clang/Basic/Module.h b/include/clang/Basic/Module.h index 19292950f5..e75f43e0e9 100644 --- a/include/clang/Basic/Module.h +++ b/include/clang/Basic/Module.h @@ -86,6 +86,10 @@ public: /// \brief Whether this is an explicit submodule. unsigned IsExplicit : 1; + /// \brief Whether this is a "system" module (which assumes that all + /// headers in it are system headers). + unsigned IsSystem : 1; + /// \brief Whether we should infer submodules for this module based on /// the headers. /// @@ -154,10 +158,11 @@ public: bool IsFramework) : Name(Name), DefinitionLoc(DefinitionLoc), Parent(0), Umbrella(), IsAvailable(true), IsFromModuleFile(false), IsFramework(IsFramework), - IsExplicit(false), InferSubmodules(false), InferExplicitSubmodules(false), + IsExplicit(false), IsSystem(false), + InferSubmodules(false), InferExplicitSubmodules(false), InferExportWildcard(false), NameVisibility(Hidden) { } - /// \brief Construct a new module or submodule. + /// \brief Construct a new module or submodule. Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent, bool IsFramework, bool IsExplicit); diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h index 038b8c65d0..848ae70308 100644 --- a/include/clang/Basic/SourceManager.h +++ b/include/clang/Basic/SourceManager.h @@ -618,9 +618,10 @@ public: FileID getMainFileID() const { return MainFileID; } /// createMainFileID - Create the FileID for the main source file. - FileID createMainFileID(const FileEntry *SourceFile) { + FileID createMainFileID(const FileEntry *SourceFile, + SrcMgr::CharacteristicKind Kind = SrcMgr::C_User) { assert(MainFileID.isInvalid() && "MainFileID already set!"); - MainFileID = createFileID(SourceFile, SourceLocation(), SrcMgr::C_User); + MainFileID = createFileID(SourceFile, SourceLocation(), Kind); return MainFileID; } diff --git a/include/clang/Frontend/CompilerInstance.h b/include/clang/Frontend/CompilerInstance.h index b488cde6e6..1e5994fc58 100644 --- a/include/clang/Frontend/CompilerInstance.h +++ b/include/clang/Frontend/CompilerInstance.h @@ -11,6 +11,7 @@ #define LLVM_CLANG_FRONTEND_COMPILERINSTANCE_H_ #include "clang/Frontend/CompilerInvocation.h" +#include "clang/Basic/SourceManager.h" #include "clang/Lex/ModuleLoader.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" @@ -627,17 +628,19 @@ public: /// as the main file. /// /// \return True on success. - bool InitializeSourceManager(StringRef InputFile); + bool InitializeSourceManager(StringRef InputFile, + SrcMgr::CharacteristicKind Kind = SrcMgr::C_User); /// InitializeSourceManager - Initialize the source manager to set InputFile /// as the main file. /// /// \return True on success. static bool InitializeSourceManager(StringRef InputFile, - DiagnosticsEngine &Diags, - FileManager &FileMgr, - SourceManager &SourceMgr, - const FrontendOptions &Opts); + SrcMgr::CharacteristicKind Kind, + DiagnosticsEngine &Diags, + FileManager &FileMgr, + SourceManager &SourceMgr, + const FrontendOptions &Opts); /// } diff --git a/include/clang/Frontend/FrontendOptions.h b/include/clang/Frontend/FrontendOptions.h index 08c683e2da..f18fdebba7 100644 --- a/include/clang/Frontend/FrontendOptions.h +++ b/include/clang/Frontend/FrontendOptions.h @@ -76,9 +76,12 @@ struct FrontendInputFile { /// \brief The kind of input, e.g., C source, AST file, LLVM IR. InputKind Kind; + /// \brief Whether we're dealing with a 'system' input (vs. a 'user' input). + bool IsSystem; + FrontendInputFile() : Kind(IK_None) { } - FrontendInputFile(StringRef File, InputKind Kind) - : File(File.str()), Kind(Kind) { } + FrontendInputFile(StringRef File, InputKind Kind, bool IsSystem = false) + : File(File.str()), Kind(Kind), IsSystem(IsSystem) { } }; /// FrontendOptions - Options for controlling the behavior of the frontend. diff --git a/include/clang/Lex/HeaderSearch.h b/include/clang/Lex/HeaderSearch.h index 10242fa264..f61f2adc5b 100644 --- a/include/clang/Lex/HeaderSearch.h +++ b/include/clang/Lex/HeaderSearch.h @@ -401,9 +401,13 @@ public: /// /// \param Dir The framework directory (e.g., ModuleName.framework). /// + /// \param IsSystem Whether the framework directory is part of the system + /// frameworks. + /// /// \returns The module, if found; otherwise, null. Module *getFrameworkModule(StringRef Name, - const DirectoryEntry *Dir); + const DirectoryEntry *Dir, + bool IsSystem); /// \brief Retrieve the module map. ModuleMap &getModuleMap() { return ModMap; } diff --git a/include/clang/Lex/ModuleMap.h b/include/clang/Lex/ModuleMap.h index b017a05e97..64358c83e5 100644 --- a/include/clang/Lex/ModuleMap.h +++ b/include/clang/Lex/ModuleMap.h @@ -159,7 +159,7 @@ public: /// framework directory. Module *inferFrameworkModule(StringRef ModuleName, const DirectoryEntry *FrameworkDir, - Module *Parent); + bool IsSystem, Module *Parent); /// \brief Retrieve the module map file containing the definition of the given /// module. |