[llvm-branch-commits] [cfe-branch] r128026 - in /cfe/branches/release_29: ./ include/clang/Sema/Sema.h lib/Sema/SemaDecl.cpp lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaExprCXX.cpp lib/Sema/SemaTemplateDeduction.cpp test/SemaCXX/auto-subst-failure.cpp test/SemaCXX/warn-unreachable.cpp tools/libclang/CIndex.cpp

Bill Wendling isanbard at gmail.com
Mon Mar 21 14:32:22 PDT 2011


Author: void
Date: Mon Mar 21 16:32:22 2011
New Revision: 128026

URL: http://llvm.org/viewvc/llvm-project?rev=128026&view=rev
Log:
--- Merging r127811 into '.':
A    test/SemaCXX/auto-subst-failure.cpp
U    include/clang/Sema/Sema.h
U    lib/Sema/SemaDeclCXX.cpp
U    lib/Sema/SemaExprCXX.cpp
U    lib/Sema/SemaDecl.cpp
U    lib/Sema/SemaTemplateDeduction.cpp
--- Merging r127971 into '.':
U    tools/libclang/CIndex.cpp


Added:
    cfe/branches/release_29/test/SemaCXX/auto-subst-failure.cpp
      - copied unchanged from r127811, cfe/trunk/test/SemaCXX/auto-subst-failure.cpp
Modified:
    cfe/branches/release_29/   (props changed)
    cfe/branches/release_29/include/clang/Sema/Sema.h
    cfe/branches/release_29/lib/Sema/SemaDecl.cpp
    cfe/branches/release_29/lib/Sema/SemaDeclCXX.cpp
    cfe/branches/release_29/lib/Sema/SemaExprCXX.cpp
    cfe/branches/release_29/lib/Sema/SemaTemplateDeduction.cpp
    cfe/branches/release_29/test/SemaCXX/warn-unreachable.cpp   (props changed)
    cfe/branches/release_29/tools/libclang/CIndex.cpp

Propchange: cfe/branches/release_29/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Mar 21 16:32:22 2011
@@ -1,2 +1,2 @@
-/cfe/trunk:127283,127308,127326,127373,127405,127460,127507,127512,127541,127543,127563,127580,127582-127583,127622-127623,127737-127738,127806,127980
+/cfe/trunk:127283,127308,127326,127373,127405,127460,127507,127512,127541,127543,127563,127580,127582-127583,127622-127623,127736-127738,127806,127811,127971,127980
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/release_29/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_29/include/clang/Sema/Sema.h?rev=128026&r1=128025&r2=128026&view=diff
==============================================================================
--- cfe/branches/release_29/include/clang/Sema/Sema.h (original)
+++ cfe/branches/release_29/include/clang/Sema/Sema.h Mon Mar 21 16:32:22 2011
@@ -3856,7 +3856,8 @@
                           FunctionDecl *&Specialization,
                           sema::TemplateDeductionInfo &Info);
 
-  bool DeduceAutoType(QualType AutoType, Expr *Initializer, QualType &Result);
+  bool DeduceAutoType(TypeSourceInfo *AutoType, Expr *Initializer,
+                      TypeSourceInfo *&Result);
 
   FunctionTemplateDecl *getMoreSpecializedTemplate(FunctionTemplateDecl *FT1,
                                                    FunctionTemplateDecl *FT2,

Modified: cfe/branches/release_29/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_29/lib/Sema/SemaDecl.cpp?rev=128026&r1=128025&r2=128026&view=diff
==============================================================================
--- cfe/branches/release_29/lib/Sema/SemaDecl.cpp (original)
+++ cfe/branches/release_29/lib/Sema/SemaDecl.cpp Mon Mar 21 16:32:22 2011
@@ -4640,15 +4640,17 @@
 
   // C++0x [decl.spec.auto]p6. Deduce the type which 'auto' stands in for.
   if (TypeMayContainAuto && VDecl->getType()->getContainedAutoType()) {
-    QualType DeducedType;
-    if (!DeduceAutoType(VDecl->getType(), Init, DeducedType)) {
+    TypeSourceInfo *DeducedType = 0;
+    if (!DeduceAutoType(VDecl->getTypeSourceInfo(), Init, DeducedType))
       Diag(VDecl->getLocation(), diag::err_auto_var_deduction_failure)
         << VDecl->getDeclName() << VDecl->getType() << Init->getType()
         << Init->getSourceRange();
+    if (!DeducedType) {
       RealDecl->setInvalidDecl();
       return;
     }
-    VDecl->setType(DeducedType);
+    VDecl->setTypeSourceInfo(DeducedType);
+    VDecl->setType(DeducedType->getType());
 
     // If this is a redeclaration, check that the type we just deduced matches
     // the previously declared type.

Modified: cfe/branches/release_29/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_29/lib/Sema/SemaDeclCXX.cpp?rev=128026&r1=128025&r2=128026&view=diff
==============================================================================
--- cfe/branches/release_29/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/branches/release_29/lib/Sema/SemaDeclCXX.cpp Mon Mar 21 16:32:22 2011
@@ -6046,15 +6046,17 @@
     }
 
     Expr *Init = Exprs.get()[0];
-    QualType DeducedType;
-    if (!DeduceAutoType(VDecl->getType(), Init, DeducedType)) {
+    TypeSourceInfo *DeducedType = 0;
+    if (!DeduceAutoType(VDecl->getTypeSourceInfo(), Init, DeducedType))
       Diag(VDecl->getLocation(), diag::err_auto_var_deduction_failure)
         << VDecl->getDeclName() << VDecl->getType() << Init->getType()
         << Init->getSourceRange();
+    if (!DeducedType) {
       RealDecl->setInvalidDecl();
       return;
     }
-    VDecl->setType(DeducedType);
+    VDecl->setTypeSourceInfo(DeducedType);
+    VDecl->setType(DeducedType->getType());
 
     // If this is a redeclaration, check that the type we just deduced matches
     // the previously declared type.

Modified: cfe/branches/release_29/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_29/lib/Sema/SemaExprCXX.cpp?rev=128026&r1=128025&r2=128026&view=diff
==============================================================================
--- cfe/branches/release_29/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/branches/release_29/lib/Sema/SemaExprCXX.cpp Mon Mar 21 16:32:22 2011
@@ -848,16 +848,18 @@
                             diag::err_auto_new_ctor_multiple_expressions)
                        << AllocType << TypeRange);
     }
-    QualType DeducedType;
-    if (!DeduceAutoType(AllocType, ConstructorArgs.get()[0], DeducedType))
+    TypeSourceInfo *DeducedType = 0;
+    if (!DeduceAutoType(AllocTypeInfo, ConstructorArgs.get()[0], DeducedType))
       return ExprError(Diag(StartLoc, diag::err_auto_new_deduction_failure)
                        << AllocType
                        << ConstructorArgs.get()[0]->getType()
                        << TypeRange
                        << ConstructorArgs.get()[0]->getSourceRange());
+    if (!DeducedType)
+      return ExprError();
 
-    AllocType = DeducedType;
-    AllocTypeInfo = Context.getTrivialTypeSourceInfo(AllocType, StartLoc);
+    AllocTypeInfo = DeducedType;
+    AllocType = AllocTypeInfo->getType();
   }
   
   // Per C++0x [expr.new]p5, the type being constructed may be a

Modified: cfe/branches/release_29/lib/Sema/SemaTemplateDeduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_29/lib/Sema/SemaTemplateDeduction.cpp?rev=128026&r1=128025&r2=128026&view=diff
==============================================================================
--- cfe/branches/release_29/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/branches/release_29/lib/Sema/SemaTemplateDeduction.cpp Mon Mar 21 16:32:22 2011
@@ -3003,11 +3003,14 @@
 ///
 /// \param Result if type deduction was successful, this will be set to the
 /// deduced type. This may still contain undeduced autos if the type is
-/// dependent.
+/// dependent. This will be set to null if deduction succeeded, but auto
+/// substitution failed; the appropriate diagnostic will already have been
+/// produced in that case.
 ///
 /// \returns true if deduction succeeded, false if it failed.
 bool
-Sema::DeduceAutoType(QualType Type, Expr *Init, QualType &Result) {
+Sema::DeduceAutoType(TypeSourceInfo *Type, Expr *Init,
+                     TypeSourceInfo *&Result) {
   if (Init->isTypeDependent()) {
     Result = Type;
     return true;
@@ -3025,8 +3028,10 @@
   FixedSizeTemplateParameterList<1> TemplateParams(Loc, Loc, &TemplParamPtr,
                                                    Loc);
 
-  QualType FuncParam =
+  TypeSourceInfo *FuncParamInfo =
     SubstituteAutoTransform(*this, TemplArg).TransformType(Type);
+  assert(FuncParamInfo && "substituting template parameter for 'auto' failed");
+  QualType FuncParam = FuncParamInfo->getType();
 
   // Deduce type of TemplParam in Func(Init)
   llvm::SmallVector<DeducedTemplateArgument, 1> Deduced;

Propchange: cfe/branches/release_29/test/SemaCXX/warn-unreachable.cpp
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Mar 21 16:32:22 2011
@@ -1 +1 @@
-/cfe/trunk/test/SemaCXX/warn-unreachable.cpp:121961,127283,127308,127326,127373,127405,127460,127507,127512,127541,127543,127563,127580,127582-127583,127622-127623,127737-127738,127806,127980
+/cfe/trunk/test/SemaCXX/warn-unreachable.cpp:121961,127283,127308,127326,127373,127405,127460,127507,127512,127541,127543,127563,127580,127582-127583,127622-127623,127736-127738,127806,127811,127971,127980

Modified: cfe/branches/release_29/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_29/tools/libclang/CIndex.cpp?rev=128026&r1=128025&r2=128026&view=diff
==============================================================================
--- cfe/branches/release_29/tools/libclang/CIndex.cpp (original)
+++ cfe/branches/release_29/tools/libclang/CIndex.cpp Mon Mar 21 16:32:22 2011
@@ -2382,12 +2382,6 @@
   }
 
   llvm::SmallVector<const char *, 16> Args;
-
-  // The 'source_filename' argument is optional.  If the caller does not
-  // specify it then it is assumed that the source file is specified
-  // in the actual argument list.
-  if (source_filename)
-    Args.push_back(source_filename);
   
   // Since the Clang C library is primarily used by batch tools dealing with
   // (often very broken) source code, where spell-checking can have a
@@ -2408,6 +2402,14 @@
   Args.insert(Args.end(), command_line_args,
               command_line_args + num_command_line_args);
 
+  // The 'source_filename' argument is optional.  If the caller does not
+  // specify it then it is assumed that the source file is specified
+  // in the actual argument list.
+  // Put the source file after command_line_args otherwise if '-x' flag is
+  // present it will be unused.
+  if (source_filename)
+    Args.push_back(source_filename);
+
   // Do we need the detailed preprocessing record?
   if (options & CXTranslationUnit_DetailedPreprocessingRecord) {
     Args.push_back("-Xclang");





More information about the llvm-branch-commits mailing list