Let ASTContext hold target info, since it's useful

llvm-svn: 39162
This commit is contained in:
Chris Lattner
2006-11-10 06:34:16 +00:00
parent cb6a382b67
commit ddc135e593
4 changed files with 27 additions and 5 deletions

22
clang/AST/ASTContext.cpp Normal file
View File

@@ -0,0 +1,22 @@
//===--- ASTContext.cpp - Context to hold long-lived AST nodes ------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the ASTContext interface.
//
//===----------------------------------------------------------------------===//
#include "clang/AST/ASTContext.h"
#include "clang/Lex/Preprocessor.h"
using namespace llvm;
using namespace clang;
ASTContext::ASTContext(Preprocessor &pp)
: PP(pp), Target(pp.getTargetInfo()) {
}

View File

@@ -75,8 +75,7 @@ Sema::ParseStringExpr(const LexerToken *StringToks, unsigned NumStringToks) {
// query the target. As such, wchar_tByteWidth is only valid if AnyWide=true.
unsigned wchar_tByteWidth = ~0U;
if (AnyWide)
wchar_tByteWidth =
Context.PP.getTargetInfo().getWCharWidth(StringToks[0].getLocation());
wchar_tByteWidth =Context.Target.getWCharWidth(StringToks[0].getLocation());
// The output buffer size needs to be large enough to hold wide characters.
// This is a worst-case assumption which basically corresponds to L"" "long".

View File

@@ -75,8 +75,7 @@ Sema::ParseStringExpr(const LexerToken *StringToks, unsigned NumStringToks) {
// query the target. As such, wchar_tByteWidth is only valid if AnyWide=true.
unsigned wchar_tByteWidth = ~0U;
if (AnyWide)
wchar_tByteWidth =
Context.PP.getTargetInfo().getWCharWidth(StringToks[0].getLocation());
wchar_tByteWidth =Context.Target.getWCharWidth(StringToks[0].getLocation());
// The output buffer size needs to be large enough to hold wide characters.
// This is a worst-case assumption which basically corresponds to L"" "long".

View File

@@ -17,14 +17,16 @@
namespace llvm {
namespace clang {
class Preprocessor;
class TargetInfo;
/// ASTContext - This class holds long-lived AST nodes (such as types and
/// decls) that can be referred to throughout the semantic analysis of a file.
class ASTContext {
public:
Preprocessor &PP;
TargetInfo &Target;
ASTContext(Preprocessor &pp) : PP(pp) {}
ASTContext(Preprocessor &pp);