blob: b4eb4fbb16ab5191371e605d93a454dfbb9609e6 [file] [log] [blame]
Chris Lattner1e27fe12006-10-14 07:06:20 +00001//===--- 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"
16using namespace llvm;
17using 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.
22void 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.
31void 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