Chandler Carruth | 55fc873 | 2012-12-04 09:13:33 +0000 | [diff] [blame] | 1 | //===--- Module.cpp - Describe a module -----------------------------------===// |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines the Module class, which describes a module in the source |
| 11 | // code. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | #include "clang/Basic/Module.h" |
| 15 | #include "clang/Basic/FileManager.h" |
Douglas Gregor | 51f564f | 2011-12-31 04:05:44 +0000 | [diff] [blame] | 16 | #include "clang/Basic/LangOptions.h" |
Douglas Gregor | e727d21 | 2012-01-30 06:38:25 +0000 | [diff] [blame] | 17 | #include "clang/Basic/TargetInfo.h" |
Argyrios Kyrtzidis | c1d2239 | 2013-03-13 21:13:43 +0000 | [diff] [blame] | 18 | #include "llvm/ADT/ArrayRef.h" |
Douglas Gregor | 51f564f | 2011-12-31 04:05:44 +0000 | [diff] [blame] | 19 | #include "llvm/ADT/SmallVector.h" |
| 20 | #include "llvm/ADT/StringSwitch.h" |
Chandler Carruth | 55fc873 | 2012-12-04 09:13:33 +0000 | [diff] [blame] | 21 | #include "llvm/Support/ErrorHandling.h" |
| 22 | #include "llvm/Support/raw_ostream.h" |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 23 | using namespace clang; |
| 24 | |
Douglas Gregor | b7a7819 | 2012-01-04 23:32:19 +0000 | [diff] [blame] | 25 | Module::Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent, |
| 26 | bool IsFramework, bool IsExplicit) |
Argyrios Kyrtzidis | e2ac16b | 2012-09-29 01:06:04 +0000 | [diff] [blame] | 27 | : Name(Name), DefinitionLoc(DefinitionLoc), Parent(Parent), |
| 28 | Umbrella(), ASTFile(0), IsAvailable(true), IsFromModuleFile(false), |
Douglas Gregor | a1f1fad | 2012-01-27 19:52:33 +0000 | [diff] [blame] | 29 | IsFramework(IsFramework), IsExplicit(IsExplicit), IsSystem(false), |
| 30 | InferSubmodules(false), InferExplicitSubmodules(false), |
Douglas Gregor | 970e441 | 2013-03-20 03:59:18 +0000 | [diff] [blame] | 31 | InferExportWildcard(false), ConfigMacrosExhaustive(false), |
| 32 | NameVisibility(Hidden) |
Douglas Gregor | b7a7819 | 2012-01-04 23:32:19 +0000 | [diff] [blame] | 33 | { |
| 34 | if (Parent) { |
| 35 | if (!Parent->isAvailable()) |
| 36 | IsAvailable = false; |
Douglas Gregor | 2f04f18 | 2012-02-02 18:42:48 +0000 | [diff] [blame] | 37 | if (Parent->IsSystem) |
| 38 | IsSystem = true; |
Douglas Gregor | b7a7819 | 2012-01-04 23:32:19 +0000 | [diff] [blame] | 39 | |
| 40 | Parent->SubModuleIndex[Name] = Parent->SubModules.size(); |
| 41 | Parent->SubModules.push_back(this); |
| 42 | } |
| 43 | } |
| 44 | |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 45 | Module::~Module() { |
Douglas Gregor | b7a7819 | 2012-01-04 23:32:19 +0000 | [diff] [blame] | 46 | for (submodule_iterator I = submodule_begin(), IEnd = submodule_end(); |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 47 | I != IEnd; ++I) { |
Douglas Gregor | b7a7819 | 2012-01-04 23:32:19 +0000 | [diff] [blame] | 48 | delete *I; |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 49 | } |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 50 | } |
| 51 | |
Douglas Gregor | 51f564f | 2011-12-31 04:05:44 +0000 | [diff] [blame] | 52 | /// \brief Determine whether a translation unit built using the current |
| 53 | /// language options has the given feature. |
Douglas Gregor | dc58aa7 | 2012-01-30 06:01:29 +0000 | [diff] [blame] | 54 | static bool hasFeature(StringRef Feature, const LangOptions &LangOpts, |
| 55 | const TargetInfo &Target) { |
Douglas Gregor | 51f564f | 2011-12-31 04:05:44 +0000 | [diff] [blame] | 56 | return llvm::StringSwitch<bool>(Feature) |
Douglas Gregor | e727d21 | 2012-01-30 06:38:25 +0000 | [diff] [blame] | 57 | .Case("altivec", LangOpts.AltiVec) |
Douglas Gregor | 51f564f | 2011-12-31 04:05:44 +0000 | [diff] [blame] | 58 | .Case("blocks", LangOpts.Blocks) |
| 59 | .Case("cplusplus", LangOpts.CPlusPlus) |
Richard Smith | 80ad52f | 2013-01-02 11:42:31 +0000 | [diff] [blame] | 60 | .Case("cplusplus11", LangOpts.CPlusPlus11) |
Douglas Gregor | 51f564f | 2011-12-31 04:05:44 +0000 | [diff] [blame] | 61 | .Case("objc", LangOpts.ObjC1) |
| 62 | .Case("objc_arc", LangOpts.ObjCAutoRefCount) |
Douglas Gregor | e727d21 | 2012-01-30 06:38:25 +0000 | [diff] [blame] | 63 | .Case("opencl", LangOpts.OpenCL) |
| 64 | .Case("tls", Target.isTLSSupported()) |
| 65 | .Default(Target.hasFeature(Feature)); |
Douglas Gregor | 51f564f | 2011-12-31 04:05:44 +0000 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | bool |
Douglas Gregor | dc58aa7 | 2012-01-30 06:01:29 +0000 | [diff] [blame] | 69 | Module::isAvailable(const LangOptions &LangOpts, const TargetInfo &Target, |
| 70 | StringRef &Feature) const { |
Douglas Gregor | 51f564f | 2011-12-31 04:05:44 +0000 | [diff] [blame] | 71 | if (IsAvailable) |
| 72 | return true; |
| 73 | |
| 74 | for (const Module *Current = this; Current; Current = Current->Parent) { |
| 75 | for (unsigned I = 0, N = Current->Requires.size(); I != N; ++I) { |
Douglas Gregor | dc58aa7 | 2012-01-30 06:01:29 +0000 | [diff] [blame] | 76 | if (!hasFeature(Current->Requires[I], LangOpts, Target)) { |
Douglas Gregor | 51f564f | 2011-12-31 04:05:44 +0000 | [diff] [blame] | 77 | Feature = Current->Requires[I]; |
| 78 | return false; |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | llvm_unreachable("could not find a reason why module is unavailable"); |
Douglas Gregor | 51f564f | 2011-12-31 04:05:44 +0000 | [diff] [blame] | 84 | } |
| 85 | |
Douglas Gregor | 0adaa88 | 2011-12-05 17:28:06 +0000 | [diff] [blame] | 86 | bool Module::isSubModuleOf(Module *Other) const { |
| 87 | const Module *This = this; |
| 88 | do { |
| 89 | if (This == Other) |
| 90 | return true; |
| 91 | |
| 92 | This = This->Parent; |
| 93 | } while (This); |
| 94 | |
| 95 | return false; |
| 96 | } |
| 97 | |
Douglas Gregor | 1e12368 | 2011-12-05 22:27:44 +0000 | [diff] [blame] | 98 | const Module *Module::getTopLevelModule() const { |
| 99 | const Module *Result = this; |
| 100 | while (Result->Parent) |
| 101 | Result = Result->Parent; |
| 102 | |
| 103 | return Result; |
| 104 | } |
| 105 | |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 106 | std::string Module::getFullModuleName() const { |
Dmitri Gribenko | cfa88f8 | 2013-01-12 19:30:44 +0000 | [diff] [blame] | 107 | SmallVector<StringRef, 2> Names; |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 108 | |
| 109 | // Build up the set of module names (from innermost to outermost). |
| 110 | for (const Module *M = this; M; M = M->Parent) |
| 111 | Names.push_back(M->Name); |
| 112 | |
| 113 | std::string Result; |
Dmitri Gribenko | cfa88f8 | 2013-01-12 19:30:44 +0000 | [diff] [blame] | 114 | for (SmallVector<StringRef, 2>::reverse_iterator I = Names.rbegin(), |
| 115 | IEnd = Names.rend(); |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 116 | I != IEnd; ++I) { |
| 117 | if (!Result.empty()) |
| 118 | Result += '.'; |
| 119 | |
| 120 | Result += *I; |
| 121 | } |
| 122 | |
| 123 | return Result; |
| 124 | } |
| 125 | |
Douglas Gregor | 10694ce | 2011-12-08 17:39:04 +0000 | [diff] [blame] | 126 | const DirectoryEntry *Module::getUmbrellaDir() const { |
| 127 | if (const FileEntry *Header = getUmbrellaHeader()) |
| 128 | return Header->getDir(); |
| 129 | |
| 130 | return Umbrella.dyn_cast<const DirectoryEntry *>(); |
| 131 | } |
| 132 | |
Argyrios Kyrtzidis | c1d2239 | 2013-03-13 21:13:43 +0000 | [diff] [blame] | 133 | ArrayRef<const FileEntry *> Module::getTopHeaders(FileManager &FileMgr) { |
| 134 | if (!TopHeaderNames.empty()) { |
| 135 | for (std::vector<std::string>::iterator |
| 136 | I = TopHeaderNames.begin(), E = TopHeaderNames.end(); I != E; ++I) { |
| 137 | if (const FileEntry *FE = FileMgr.getFile(*I)) |
| 138 | TopHeaders.insert(FE); |
| 139 | } |
| 140 | TopHeaderNames.clear(); |
| 141 | } |
| 142 | |
| 143 | return llvm::makeArrayRef(TopHeaders.begin(), TopHeaders.end()); |
| 144 | } |
| 145 | |
Douglas Gregor | dc58aa7 | 2012-01-30 06:01:29 +0000 | [diff] [blame] | 146 | void Module::addRequirement(StringRef Feature, const LangOptions &LangOpts, |
| 147 | const TargetInfo &Target) { |
Douglas Gregor | 51f564f | 2011-12-31 04:05:44 +0000 | [diff] [blame] | 148 | Requires.push_back(Feature); |
| 149 | |
| 150 | // If this feature is currently available, we're done. |
Douglas Gregor | dc58aa7 | 2012-01-30 06:01:29 +0000 | [diff] [blame] | 151 | if (hasFeature(Feature, LangOpts, Target)) |
Douglas Gregor | 51f564f | 2011-12-31 04:05:44 +0000 | [diff] [blame] | 152 | return; |
| 153 | |
| 154 | if (!IsAvailable) |
| 155 | return; |
| 156 | |
Dmitri Gribenko | cfa88f8 | 2013-01-12 19:30:44 +0000 | [diff] [blame] | 157 | SmallVector<Module *, 2> Stack; |
Douglas Gregor | 51f564f | 2011-12-31 04:05:44 +0000 | [diff] [blame] | 158 | Stack.push_back(this); |
| 159 | while (!Stack.empty()) { |
| 160 | Module *Current = Stack.back(); |
| 161 | Stack.pop_back(); |
| 162 | |
| 163 | if (!Current->IsAvailable) |
| 164 | continue; |
| 165 | |
| 166 | Current->IsAvailable = false; |
Douglas Gregor | b7a7819 | 2012-01-04 23:32:19 +0000 | [diff] [blame] | 167 | for (submodule_iterator Sub = Current->submodule_begin(), |
| 168 | SubEnd = Current->submodule_end(); |
Douglas Gregor | 51f564f | 2011-12-31 04:05:44 +0000 | [diff] [blame] | 169 | Sub != SubEnd; ++Sub) { |
Douglas Gregor | b7a7819 | 2012-01-04 23:32:19 +0000 | [diff] [blame] | 170 | if ((*Sub)->IsAvailable) |
| 171 | Stack.push_back(*Sub); |
Douglas Gregor | 51f564f | 2011-12-31 04:05:44 +0000 | [diff] [blame] | 172 | } |
| 173 | } |
| 174 | } |
| 175 | |
Douglas Gregor | b7a7819 | 2012-01-04 23:32:19 +0000 | [diff] [blame] | 176 | Module *Module::findSubmodule(StringRef Name) const { |
| 177 | llvm::StringMap<unsigned>::const_iterator Pos = SubModuleIndex.find(Name); |
| 178 | if (Pos == SubModuleIndex.end()) |
| 179 | return 0; |
| 180 | |
| 181 | return SubModules[Pos->getValue()]; |
| 182 | } |
| 183 | |
Dmitri Gribenko | cfa88f8 | 2013-01-12 19:30:44 +0000 | [diff] [blame] | 184 | static void printModuleId(raw_ostream &OS, const ModuleId &Id) { |
Douglas Gregor | af13bfc | 2011-12-02 18:58:38 +0000 | [diff] [blame] | 185 | for (unsigned I = 0, N = Id.size(); I != N; ++I) { |
| 186 | if (I) |
| 187 | OS << "."; |
| 188 | OS << Id[I].first; |
| 189 | } |
| 190 | } |
| 191 | |
Argyrios Kyrtzidis | 21a0004 | 2013-02-19 19:34:40 +0000 | [diff] [blame] | 192 | void Module::getExportedModules(SmallVectorImpl<Module *> &Exported) const { |
| 193 | bool AnyWildcard = false; |
| 194 | bool UnrestrictedWildcard = false; |
| 195 | SmallVector<Module *, 4> WildcardRestrictions; |
| 196 | for (unsigned I = 0, N = Exports.size(); I != N; ++I) { |
| 197 | Module *Mod = Exports[I].getPointer(); |
| 198 | if (!Exports[I].getInt()) { |
| 199 | // Export a named module directly; no wildcards involved. |
| 200 | Exported.push_back(Mod); |
| 201 | |
| 202 | continue; |
| 203 | } |
| 204 | |
| 205 | // Wildcard export: export all of the imported modules that match |
| 206 | // the given pattern. |
| 207 | AnyWildcard = true; |
| 208 | if (UnrestrictedWildcard) |
| 209 | continue; |
| 210 | |
| 211 | if (Module *Restriction = Exports[I].getPointer()) |
| 212 | WildcardRestrictions.push_back(Restriction); |
| 213 | else { |
| 214 | WildcardRestrictions.clear(); |
| 215 | UnrestrictedWildcard = true; |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | // If there were any wildcards, push any imported modules that were |
| 220 | // re-exported by the wildcard restriction. |
| 221 | if (!AnyWildcard) |
| 222 | return; |
| 223 | |
| 224 | for (unsigned I = 0, N = Imports.size(); I != N; ++I) { |
| 225 | Module *Mod = Imports[I]; |
| 226 | bool Acceptable = UnrestrictedWildcard; |
| 227 | if (!Acceptable) { |
| 228 | // Check whether this module meets one of the restrictions. |
| 229 | for (unsigned R = 0, NR = WildcardRestrictions.size(); R != NR; ++R) { |
| 230 | Module *Restriction = WildcardRestrictions[R]; |
| 231 | if (Mod == Restriction || Mod->isSubModuleOf(Restriction)) { |
| 232 | Acceptable = true; |
| 233 | break; |
| 234 | } |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | if (!Acceptable) |
| 239 | continue; |
| 240 | |
| 241 | Exported.push_back(Mod); |
| 242 | } |
| 243 | } |
| 244 | |
Dmitri Gribenko | cfa88f8 | 2013-01-12 19:30:44 +0000 | [diff] [blame] | 245 | void Module::print(raw_ostream &OS, unsigned Indent) const { |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 246 | OS.indent(Indent); |
| 247 | if (IsFramework) |
| 248 | OS << "framework "; |
| 249 | if (IsExplicit) |
| 250 | OS << "explicit "; |
Douglas Gregor | a1f1fad | 2012-01-27 19:52:33 +0000 | [diff] [blame] | 251 | OS << "module " << Name; |
Douglas Gregor | 51f564f | 2011-12-31 04:05:44 +0000 | [diff] [blame] | 252 | |
Douglas Gregor | a1f1fad | 2012-01-27 19:52:33 +0000 | [diff] [blame] | 253 | if (IsSystem) { |
| 254 | OS.indent(Indent + 2); |
| 255 | OS << " [system]"; |
| 256 | } |
| 257 | |
| 258 | OS << " {\n"; |
| 259 | |
Douglas Gregor | 51f564f | 2011-12-31 04:05:44 +0000 | [diff] [blame] | 260 | if (!Requires.empty()) { |
| 261 | OS.indent(Indent + 2); |
| 262 | OS << "requires "; |
| 263 | for (unsigned I = 0, N = Requires.size(); I != N; ++I) { |
| 264 | if (I) |
| 265 | OS << ", "; |
| 266 | OS << Requires[I]; |
| 267 | } |
| 268 | OS << "\n"; |
| 269 | } |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 270 | |
Douglas Gregor | 10694ce | 2011-12-08 17:39:04 +0000 | [diff] [blame] | 271 | if (const FileEntry *UmbrellaHeader = getUmbrellaHeader()) { |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 272 | OS.indent(Indent + 2); |
Douglas Gregor | 489ad43 | 2011-12-08 18:00:48 +0000 | [diff] [blame] | 273 | OS << "umbrella header \""; |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 274 | OS.write_escaped(UmbrellaHeader->getName()); |
| 275 | OS << "\"\n"; |
Douglas Gregor | 489ad43 | 2011-12-08 18:00:48 +0000 | [diff] [blame] | 276 | } else if (const DirectoryEntry *UmbrellaDir = getUmbrellaDir()) { |
| 277 | OS.indent(Indent + 2); |
| 278 | OS << "umbrella \""; |
| 279 | OS.write_escaped(UmbrellaDir->getName()); |
| 280 | OS << "\"\n"; |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 281 | } |
Douglas Gregor | 63a7268 | 2013-03-20 00:22:05 +0000 | [diff] [blame] | 282 | |
| 283 | if (!ConfigMacros.empty() || ConfigMacrosExhaustive) { |
| 284 | OS.indent(Indent + 2); |
| 285 | OS << "config_macros "; |
| 286 | if (ConfigMacrosExhaustive) |
Douglas Gregor | 970e441 | 2013-03-20 03:59:18 +0000 | [diff] [blame] | 287 | OS << "[exhaustive]"; |
Douglas Gregor | 63a7268 | 2013-03-20 00:22:05 +0000 | [diff] [blame] | 288 | for (unsigned I = 0, N = ConfigMacros.size(); I != N; ++I) { |
| 289 | if (I) |
| 290 | OS << ", "; |
| 291 | OS << ConfigMacros[I]; |
| 292 | } |
Douglas Gregor | 970e441 | 2013-03-20 03:59:18 +0000 | [diff] [blame] | 293 | OS << "\n"; |
Douglas Gregor | 63a7268 | 2013-03-20 00:22:05 +0000 | [diff] [blame] | 294 | } |
| 295 | |
Lawrence Crowl | bc3f628 | 2013-06-20 21:14:14 +0000 | [diff] [blame^] | 296 | for (unsigned I = 0, N = NormalHeaders.size(); I != N; ++I) { |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 297 | OS.indent(Indent + 2); |
| 298 | OS << "header \""; |
Lawrence Crowl | bc3f628 | 2013-06-20 21:14:14 +0000 | [diff] [blame^] | 299 | OS.write_escaped(NormalHeaders[I]->getName()); |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 300 | OS << "\"\n"; |
| 301 | } |
Douglas Gregor | 2b49d1f | 2012-10-15 06:28:11 +0000 | [diff] [blame] | 302 | |
| 303 | for (unsigned I = 0, N = ExcludedHeaders.size(); I != N; ++I) { |
| 304 | OS.indent(Indent + 2); |
| 305 | OS << "exclude header \""; |
| 306 | OS.write_escaped(ExcludedHeaders[I]->getName()); |
| 307 | OS << "\"\n"; |
| 308 | } |
Lawrence Crowl | bc3f628 | 2013-06-20 21:14:14 +0000 | [diff] [blame^] | 309 | |
| 310 | for (unsigned I = 0, N = PrivateHeaders.size(); I != N; ++I) { |
| 311 | OS.indent(Indent + 2); |
| 312 | OS << "private header \""; |
| 313 | OS.write_escaped(PrivateHeaders[I]->getName()); |
| 314 | OS << "\"\n"; |
| 315 | } |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 316 | |
Douglas Gregor | b7a7819 | 2012-01-04 23:32:19 +0000 | [diff] [blame] | 317 | for (submodule_const_iterator MI = submodule_begin(), MIEnd = submodule_end(); |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 318 | MI != MIEnd; ++MI) |
Douglas Gregor | b7a7819 | 2012-01-04 23:32:19 +0000 | [diff] [blame] | 319 | (*MI)->print(OS, Indent + 2); |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 320 | |
Douglas Gregor | af13bfc | 2011-12-02 18:58:38 +0000 | [diff] [blame] | 321 | for (unsigned I = 0, N = Exports.size(); I != N; ++I) { |
| 322 | OS.indent(Indent + 2); |
Douglas Gregor | f4ac17e | 2011-12-05 17:34:59 +0000 | [diff] [blame] | 323 | OS << "export "; |
| 324 | if (Module *Restriction = Exports[I].getPointer()) { |
| 325 | OS << Restriction->getFullModuleName(); |
| 326 | if (Exports[I].getInt()) |
| 327 | OS << ".*"; |
| 328 | } else { |
| 329 | OS << "*"; |
| 330 | } |
Douglas Gregor | af13bfc | 2011-12-02 18:58:38 +0000 | [diff] [blame] | 331 | OS << "\n"; |
| 332 | } |
| 333 | |
| 334 | for (unsigned I = 0, N = UnresolvedExports.size(); I != N; ++I) { |
| 335 | OS.indent(Indent + 2); |
| 336 | OS << "export "; |
| 337 | printModuleId(OS, UnresolvedExports[I].Id); |
Douglas Gregor | f4ac17e | 2011-12-05 17:34:59 +0000 | [diff] [blame] | 338 | if (UnresolvedExports[I].Wildcard) { |
| 339 | if (UnresolvedExports[I].Id.empty()) |
| 340 | OS << "*"; |
| 341 | else |
| 342 | OS << ".*"; |
| 343 | } |
Douglas Gregor | af13bfc | 2011-12-02 18:58:38 +0000 | [diff] [blame] | 344 | OS << "\n"; |
| 345 | } |
| 346 | |
Douglas Gregor | b6cbe51 | 2013-01-14 17:21:00 +0000 | [diff] [blame] | 347 | for (unsigned I = 0, N = LinkLibraries.size(); I != N; ++I) { |
| 348 | OS.indent(Indent + 2); |
| 349 | OS << "link "; |
| 350 | if (LinkLibraries[I].IsFramework) |
| 351 | OS << "framework "; |
| 352 | OS << "\""; |
| 353 | OS.write_escaped(LinkLibraries[I].Library); |
| 354 | OS << "\""; |
| 355 | } |
| 356 | |
Douglas Gregor | 906d66a | 2013-03-20 21:10:35 +0000 | [diff] [blame] | 357 | for (unsigned I = 0, N = UnresolvedConflicts.size(); I != N; ++I) { |
| 358 | OS.indent(Indent + 2); |
| 359 | OS << "conflict "; |
| 360 | printModuleId(OS, UnresolvedConflicts[I].Id); |
| 361 | OS << ", \""; |
| 362 | OS.write_escaped(UnresolvedConflicts[I].Message); |
| 363 | OS << "\"\n"; |
| 364 | } |
| 365 | |
| 366 | for (unsigned I = 0, N = Conflicts.size(); I != N; ++I) { |
| 367 | OS.indent(Indent + 2); |
| 368 | OS << "conflict "; |
| 369 | OS << Conflicts[I].Other->getFullModuleName(); |
| 370 | OS << ", \""; |
| 371 | OS.write_escaped(Conflicts[I].Message); |
| 372 | OS << "\"\n"; |
| 373 | } |
| 374 | |
Douglas Gregor | 1e12368 | 2011-12-05 22:27:44 +0000 | [diff] [blame] | 375 | if (InferSubmodules) { |
| 376 | OS.indent(Indent + 2); |
| 377 | if (InferExplicitSubmodules) |
| 378 | OS << "explicit "; |
| 379 | OS << "module * {\n"; |
| 380 | if (InferExportWildcard) { |
| 381 | OS.indent(Indent + 4); |
| 382 | OS << "export *\n"; |
| 383 | } |
| 384 | OS.indent(Indent + 2); |
| 385 | OS << "}\n"; |
| 386 | } |
| 387 | |
Douglas Gregor | 1a4761e | 2011-11-30 23:21:26 +0000 | [diff] [blame] | 388 | OS.indent(Indent); |
| 389 | OS << "}\n"; |
| 390 | } |
| 391 | |
| 392 | void Module::dump() const { |
| 393 | print(llvm::errs()); |
| 394 | } |
| 395 | |
| 396 | |