Chris Lattner | 1e27fe1 | 2006-10-14 07:06:20 +0000 | [diff] [blame] | 1 | //===--- TargetInfo.cpp - Information about Target machine ----------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by Chris Lattner and is distributed under |
| 6 | // the University of Illinois Open Source License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements the TargetInfo and TargetInfoImpl interfaces. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "clang/Basic/TargetInfo.h" |
| 15 | #include "clang/Basic/Diagnostic.h" |
| 16 | using namespace llvm; |
| 17 | using namespace clang; |
| 18 | |
| 19 | /// DiagnoseNonPortability - When a use of a non-portable target feature is |
| 20 | /// used, this method emits the diagnostic and marks the translation unit as |
| 21 | /// non-portable. |
| 22 | void TargetInfo::DiagnoseNonPortability(SourceLocation Loc, unsigned DiagKind) { |
| 23 | NonPortable = true; |
| 24 | if (Diag) Diag->Report(Loc, DiagKind); |
| 25 | } |
| 26 | |
| 27 | |
| 28 | /// ComputeWCharWidth - Determine the width of the wchar_t type for the primary |
| 29 | /// target, diagnosing whether this is non-portable across the secondary |
| 30 | /// targets. |
| 31 | void TargetInfo::ComputeWCharWidth(SourceLocation Loc) { |
| 32 | WCharWidth = PrimaryTarget->getWCharWidth(); |
| 33 | |
| 34 | // Check whether this is portable across the secondary targets if the T-U is |
| 35 | // portable so far. |
| 36 | for (unsigned i = 0, e = SecondaryTargets.size(); i != e; ++i) |
| 37 | if (SecondaryTargets[i]->getWCharWidth() != WCharWidth) |
| 38 | return DiagnoseNonPortability(Loc, diag::port_wchar_t); |
| 39 | } |
| 40 | |