From: Chris Lattner Date: Wed, 10 Oct 2007 17:48:53 +0000 (+0000) Subject: resolve a fixme, by moving __builtin_va_list to a more logical X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d19144b244f86227fcc2b0da794929fe83968dd5;p=clang resolve a fixme, by moving __builtin_va_list to a more logical place and making it correctly parameterized on the target. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42830 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Lex/Preprocessor.cpp b/Lex/Preprocessor.cpp index 7deea40548..78e4496a5d 100644 --- a/Lex/Preprocessor.cpp +++ b/Lex/Preprocessor.cpp @@ -376,6 +376,12 @@ static void InitializePredefinedMacros(Preprocessor &PP, Buf.insert(Buf.end(), IDTypedef, IDTypedef+strlen(IDTypedef)); } + // Add __builtin_va_list typedef. + { + const char *VAList = PP.getTargetInfo().getVAListDeclaration(); + Buf.insert(Buf.end(), VAList, VAList+strlen(VAList)); + Buf.push_back('\n'); + } // Get the target #defines. PP.getTargetInfo().getTargetDefines(Buf); diff --git a/Parse/Parser.cpp b/Parse/Parser.cpp index fc5c4ae4f7..543aed8855 100644 --- a/Parse/Parser.cpp +++ b/Parse/Parser.cpp @@ -230,25 +230,6 @@ void Parser::Initialize() { EnterScope(Scope::DeclScope); Actions.ActOnTranslationUnitScope(Tok.getLocation(), CurScope); - // Install builtin types. - // TODO: Move this someplace more useful. - { - const char *Dummy; - - //__builtin_va_list - DeclSpec DS; - bool Error = DS.SetStorageClassSpec(DeclSpec::SCS_typedef, SourceLocation(), - Dummy); - - // TODO: add a 'TST_builtin' type? - Error |= DS.SetTypeSpecType(DeclSpec::TST_int, SourceLocation(), Dummy); - assert(!Error && "Error setting up __builtin_va_list!"); - - Declarator D(DS, Declarator::FileContext); - D.SetIdentifier(PP.getIdentifierInfo("__builtin_va_list"),SourceLocation()); - Actions.ActOnDeclarator(CurScope, D, 0); - } - if (Tok.is(tok::eof) && !getLang().CPlusPlus) // Empty source file is an extension in C Diag(Tok, diag::ext_empty_source_file); diff --git a/clang.xcodeproj/project.pbxproj b/clang.xcodeproj/project.pbxproj index 0db725b41a..b5cf88f72c 100644 --- a/clang.xcodeproj/project.pbxproj +++ b/clang.xcodeproj/project.pbxproj @@ -237,7 +237,7 @@ 84AF36A00CB17A3B00C820A5 /* DeclObjC.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = DeclObjC.h; path = clang/AST/DeclObjC.h; sourceTree = ""; }; 84D9A8870C1A57E100AC7ABC /* AttributeList.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = AttributeList.cpp; path = Parse/AttributeList.cpp; sourceTree = ""; }; 84D9A88B0C1A581300AC7ABC /* AttributeList.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = AttributeList.h; path = clang/Parse/AttributeList.h; sourceTree = ""; }; - 8DD76F6C0486A84900D96B5E /* clang */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = clang; sourceTree = BUILT_PRODUCTS_DIR; }; + 8DD76F6C0486A84900D96B5E /* clang */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = clang; sourceTree = BUILT_PRODUCTS_DIR; }; DE01DA480B12ADA300AC22CE /* PPCallbacks.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PPCallbacks.h; sourceTree = ""; }; DE06756B0C051CFE00EBBFD8 /* ParseExprCXX.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = ParseExprCXX.cpp; path = Parse/ParseExprCXX.cpp; sourceTree = ""; }; DE06B73D0A8307640050E87E /* LangOptions.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = LangOptions.h; sourceTree = ""; }; diff --git a/include/clang/Basic/TargetInfo.h b/include/clang/Basic/TargetInfo.h index d0b0434d85..e161e65ef3 100644 --- a/include/clang/Basic/TargetInfo.h +++ b/include/clang/Basic/TargetInfo.h @@ -183,6 +183,12 @@ public: void getTargetBuiltins(const Builtin::Info *&Records, unsigned &NumRecords, std::vector &NonPortableBuiltins) const; + /// getVAListDeclaration - Return the declaration to use for + /// __builtin_va_list, which is target-specific. + const char *getVAListDeclaration() const { + // FIXME: dispatch to target impl. + return "typedef int __builtin_va_list;"; + } ///===---- Some helper methods ------------------------------------------===// unsigned getCharWidth(SourceLocation Loc) {