Cleanup and test C++ default arguments. Improvements include:

  - Diagnose attempts to add default arguments to templates (or member
    functions of templates) after the initial declaration (DR217).
  - Improve diagnostics when a default argument is redefined. Now, the
    note will always point at the place where the default argument was
    previously defined, rather than pointing to the most recent
    declaration of the function.

llvm-svn: 81548
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 1693642..8fd6ebf 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -98,15 +98,25 @@
   return getType();
 }
 
-void VarDecl::setInit(ASTContext &C, Expr *I) {
-    if (EvaluatedStmt *Eval = Init.dyn_cast<EvaluatedStmt *>()) {
-      Eval->~EvaluatedStmt();
-      C.Deallocate(Eval);
-    }
+SourceRange ParmVarDecl::getDefaultArgRange() const {
+  if (const Expr *E = getInit())
+    return E->getSourceRange();
+  
+  if (const Expr *E = getUninstantiatedDefaultArg())
+    return E->getSourceRange();
+    
+  return SourceRange();
+}
 
-    Init = I;
+void VarDecl::setInit(ASTContext &C, Expr *I) {
+  if (EvaluatedStmt *Eval = Init.dyn_cast<EvaluatedStmt *>()) {
+    Eval->~EvaluatedStmt();
+    C.Deallocate(Eval);
   }
 
+  Init = I;
+}
+
 bool VarDecl::isExternC(ASTContext &Context) const {
   if (!Context.getLangOptions().CPlusPlus)
     return (getDeclContext()->isTranslationUnit() &&