[cfe-commits] r42857 - in /cfe/trunk: AST/ASTContext.cpp AST/Builtins.cpp Sema/SemaDecl.cpp include/clang/AST/ASTContext.h include/clang/AST/Builtins.def

Anders Carlsson andersca at mac.com
Wed Oct 10 18:00:42 PDT 2007


Author: andersca
Date: Wed Oct 10 20:00:40 2007
New Revision: 42857

URL: http://llvm.org/viewvc/llvm-project?rev=42857&view=rev
Log:
Add __builtin_va_start to the list of builtins, make __builtin_va_list available to builtin functions.


Modified:
    cfe/trunk/AST/ASTContext.cpp
    cfe/trunk/AST/Builtins.cpp
    cfe/trunk/Sema/SemaDecl.cpp
    cfe/trunk/include/clang/AST/ASTContext.h
    cfe/trunk/include/clang/AST/Builtins.def

Modified: cfe/trunk/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/ASTContext.cpp?rev=42857&r1=42856&r2=42857&view=diff

==============================================================================
--- cfe/trunk/AST/ASTContext.cpp (original)
+++ cfe/trunk/AST/ASTContext.cpp Wed Oct 10 20:00:40 2007
@@ -830,3 +830,11 @@
   
   return getTagDeclType(CFConstantStringTypeDecl);
 }
+
+void ASTContext::setBuiltinVaListType(QualType T)
+{
+  assert(BuiltinVaListType.isNull() && "__builtin_va_list type already set!");
+    
+  BuiltinVaListType = T;
+}
+

Modified: cfe/trunk/AST/Builtins.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Builtins.cpp?rev=42857&r1=42856&r2=42857&view=diff

==============================================================================
--- cfe/trunk/AST/Builtins.cpp (original)
+++ cfe/trunk/AST/Builtins.cpp Wed Oct 10 20:00:40 2007
@@ -133,6 +133,9 @@
   case 'F':
     Type = Context.getCFConstantStringType();
     break;
+  case 'V':
+    Type = Context.getBuiltinVaListType();
+    break;
   }
   
   Done = false;

Modified: cfe/trunk/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDecl.cpp?rev=42857&r1=42856&r2=42857&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/Sema/SemaDecl.cpp Wed Oct 10 20:00:40 2007
@@ -137,7 +137,16 @@
                                       Scope *S) {
   Builtin::ID BID = (Builtin::ID)bid;
 
-  QualType R = Context.BuiltinInfo.GetBuiltinType(BID, Context);
+  if (BID == Builtin::BI__builtin_va_start &&
+      Context.getBuiltinVaListType().isNull()) {
+    IdentifierInfo *VaIdent = &Context.Idents.get("__builtin_va_list");
+    ScopedDecl *VaDecl = LookupScopedDecl(VaIdent, Decl::IDNS_Ordinary, 
+                                          SourceLocation(), TUScope);
+    TypedefDecl *VaTypedef = cast<TypedefDecl>(VaDecl);
+    Context.setBuiltinVaListType(Context.getTypedefType(VaTypedef));
+  }
+  
+  QualType R = Context.BuiltinInfo.GetBuiltinType(BID, Context);  
   FunctionDecl *New = new FunctionDecl(SourceLocation(), II, R,
                                        FunctionDecl::Extern, false, 0);
   

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=42857&r1=42856&r2=42857&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Wed Oct 10 20:00:40 2007
@@ -41,6 +41,11 @@
   llvm::FoldingSet<ObjcQualifiedInterfaceType> ObjcQualifiedInterfaceTypes;
   llvm::DenseMap<const RecordDecl*, const RecordLayout*> RecordLayoutInfo;
   RecordDecl *CFConstantStringTypeDecl;
+    
+  /// BuiltinVaListType - built-in va list type.
+  /// This is initially null and set by Sema::LazilyCreateBuiltin when
+  /// a builtin that takes a valist is encountered.
+  QualType BuiltinVaListType;
 public:
   
   SourceManager &SourceMgr;
@@ -145,6 +150,9 @@
   // getCFConstantStringType - Return the type used for constant CFStrings. 
   QualType getCFConstantStringType(); 
   
+  void setBuiltinVaListType(QualType T);
+  QualType getBuiltinVaListType() const { return BuiltinVaListType; }
+    
   //===--------------------------------------------------------------------===//
   //                         Type Sizing and Analysis
   //===--------------------------------------------------------------------===//

Modified: cfe/trunk/include/clang/AST/Builtins.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Builtins.def?rev=42857&r1=42856&r2=42857&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Builtins.def (original)
+++ cfe/trunk/include/clang/AST/Builtins.def Wed Oct 10 20:00:40 2007
@@ -30,6 +30,7 @@
 //  f -> float
 //  d -> double
 //  F -> constant CFString
+//  V -> __builtin_va_list
 //  . -> "...".  This may only occur at the end of the function list.
 //
 // Types maybe prefixed with the following modifiers:
@@ -58,5 +59,6 @@
 BUILTIN(__builtin_constant_p, "UsUs", "nc")
 BUILTIN(__builtin_classify_type, "i.", "nc")
 BUILTIN(__builtin___CFStringMakeConstantString, "FC*cC*", "nc")
+BUILTIN(__builtin_va_start, "vV.", "nc")
 
 #undef BUILTIN





More information about the cfe-commits mailing list