From 22dc378630569fd22552b5c0cad62469f7c3e594 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 4 Aug 2006 04:44:06 +0000 Subject: [PATCH] Split LangOptions out into its own header llvm-svn: 38806 --- clang/clang.xcodeproj/project.pbxproj | 4 ++ clang/include/clang/Basic/LangOptions.h | 50 +++++++++++++++++++++++++ clang/include/clang/Lex/Lexer.h | 28 +------------- 3 files changed, 55 insertions(+), 27 deletions(-) create mode 100644 clang/include/clang/Basic/LangOptions.h diff --git a/clang/clang.xcodeproj/project.pbxproj b/clang/clang.xcodeproj/project.pbxproj index 0cd0651e5a74..b9e8bd0f19b4 100644 --- a/clang/clang.xcodeproj/project.pbxproj +++ b/clang/clang.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + DE06B73E0A8307640050E87E /* LangOptions.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE06B73D0A8307640050E87E /* LangOptions.h */; }; DE1F22030A7D852A00FBF588 /* Parser.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE1F22020A7D852A00FBF588 /* Parser.h */; }; DE1F22200A7D879000FBF588 /* ParserActions.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE1F221F0A7D879000FBF588 /* ParserActions.h */; }; DE1F24700A7DC99000FBF588 /* Actions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE1F246D0A7DC99000FBF588 /* Actions.cpp */; }; @@ -96,6 +97,7 @@ DE1F22030A7D852A00FBF588 /* Parser.h in CopyFiles */, DE1F22200A7D879000FBF588 /* ParserActions.h in CopyFiles */, DE1F24820A7DCD3800FBF588 /* Declarations.h in CopyFiles */, + DE06B73E0A8307640050E87E /* LangOptions.h in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 1; }; @@ -103,6 +105,7 @@ /* Begin PBXFileReference section */ 8DD76F6C0486A84900D96B5E /* clang */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = clang; sourceTree = BUILT_PRODUCTS_DIR; }; + DE06B73D0A8307640050E87E /* LangOptions.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = LangOptions.h; sourceTree = ""; }; DE1F22020A7D852A00FBF588 /* Parser.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Parser.h; path = clang/Parse/Parser.h; sourceTree = ""; }; DE1F221F0A7D879000FBF588 /* ParserActions.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ParserActions.h; path = clang/Parse/ParserActions.h; sourceTree = ""; }; DE1F246D0A7DC99000FBF588 /* Actions.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = Actions.cpp; path = Parse/Actions.cpp; sourceTree = ""; }; @@ -244,6 +247,7 @@ DED7D7310A524295003AD0FB /* Diagnostic.h */, DED7D7320A524295003AD0FB /* DiagnosticKinds.def */, DED7D7330A524295003AD0FB /* FileManager.h */, + DE06B73D0A8307640050E87E /* LangOptions.h */, DED7D7340A524295003AD0FB /* SourceBuffer.h */, DED7D7350A524295003AD0FB /* SourceLocation.h */, DED7D7360A524295003AD0FB /* SourceManager.h */, diff --git a/clang/include/clang/Basic/LangOptions.h b/clang/include/clang/Basic/LangOptions.h new file mode 100644 index 000000000000..8b662e6352d2 --- /dev/null +++ b/clang/include/clang/Basic/LangOptions.h @@ -0,0 +1,50 @@ +//===--- LangOptions.h - C Language Family Language Options -----*- C++ -*-===// +// +// 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 defines the LangOptions interface. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_LANGOPTIONS_H +#define LLVM_CLANG_LANGOPTIONS_H + +namespace llvm { +namespace clang { + +/// LangOptions - This class keeps track of the various options that can be +/// enabled, which controls the dialect of C that is accepted. +struct LangOptions { + unsigned Trigraphs : 1; // Trigraphs in source files. + unsigned BCPLComment : 1; // BCPL-style // comments. + unsigned DollarIdents : 1; // '$' allowed in identifiers. + unsigned Digraphs : 1; // When added to C? C99? + unsigned HexFloats : 1; // C99 Hexadecimal float constants. + unsigned C99 : 1; // C99 Support + unsigned Microsoft : 1; // Microsoft extensions. + unsigned CPlusPlus : 1; // C++ Support + unsigned CPPMinMax : 1; // C++ ?= tokens. + unsigned NoExtensions : 1; // All extensions are disabled, strict mode. + + unsigned ObjC1 : 1; // Objective C 1 support enabled. + unsigned ObjC2 : 1; // Objective C 2 support enabled. + + unsigned KeepComments : 1; // Keep comments ("-C") mode. + unsigned KeepMacroComments : 1; // Keep macro-exp comments ("-CC") mode. + + LangOptions() { + Trigraphs = BCPLComment = DollarIdents = Digraphs = ObjC1 = ObjC2 = 0; + C99 = Microsoft = CPlusPlus = CPPMinMax = NoExtensions = 0; + KeepComments = KeepMacroComments = 0; + } +}; + +} // end namespace clang +} // end namespace llvm + +#endif diff --git a/clang/include/clang/Lex/Lexer.h b/clang/include/clang/Lex/Lexer.h index cd7c5a9fe2de..c507222fa852 100644 --- a/clang/include/clang/Lex/Lexer.h +++ b/clang/include/clang/Lex/Lexer.h @@ -16,6 +16,7 @@ #include "clang/Lex/LexerToken.h" #include "clang/Lex/MultipleIncludeOpt.h" +#include "clang/Basic/LangOptions.h" #include #include @@ -25,33 +26,6 @@ class Diagnostic; class Preprocessor; class SourceBuffer; -struct LangOptions { - unsigned Trigraphs : 1; // Trigraphs in source files. - unsigned BCPLComment : 1; // BCPL-style // comments. - unsigned DollarIdents : 1; // '$' allowed in identifiers. - unsigned Digraphs : 1; // When added to C? C99? - unsigned HexFloats : 1; // C99 Hexadecimal float constants. - unsigned C99 : 1; // C99 Support - unsigned Microsoft : 1; // Microsoft extensions. - unsigned CPlusPlus : 1; // C++ Support - unsigned CPPMinMax : 1; // C++ ?= tokens. - unsigned NoExtensions : 1; // All extensions are disabled, strict mode. - - unsigned ObjC1 : 1; // Objective C 1 support enabled. - unsigned ObjC2 : 1; // Objective C 2 support enabled. - - unsigned KeepComments : 1; // Keep comments ("-C") mode. - unsigned KeepMacroComments : 1; // Keep macro-exp comments ("-CC") mode. - - LangOptions() { - Trigraphs = BCPLComment = DollarIdents = Digraphs = ObjC1 = ObjC2 = 0; - C99 = Microsoft = CPlusPlus = CPPMinMax = NoExtensions = 0; - KeepComments = KeepMacroComments = 0; - } -}; - - - /// Lexer - This provides a simple interface that turns a text buffer into a /// stream of tokens. This provides no support for file reading or buffering, /// or buffering/seeking of tokens, only forward lexing is supported. It relies