]> granicus.if.org Git - clang/commitdiff
Clean up -fixit output slightly
authorDouglas Gregor <dgregor@apple.com>
Thu, 2 Apr 2009 03:14:12 +0000 (03:14 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 2 Apr 2009 03:14:12 +0000 (03:14 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68278 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/FixItRewriter.cpp
lib/Sema/SemaDecl.cpp

index a53d1e56d14c1ce8e8fb82b12dd9ed9bfb6b9259..33ab0b7c99b30a241cb9992ef4d3995f555d1522 100644 (file)
@@ -57,8 +57,9 @@ bool FixItRewriter::WriteFixedFile(const std::string &InFileName,
     OutFile = &llvm::outs();
   } else {
     llvm::sys::Path Path(InFileName);
+    std::string Suffix = Path.getSuffix();
     Path.eraseSuffix();
-    Path.appendSuffix("cpp");
+    Path.appendSuffix("fixit." + Suffix);
     std::string Err;
     OutFile = new llvm::raw_fd_ostream(Path.toString().c_str(), 
                                        // set binary mode (critical for Windoze)
index f67b417ddd1dd163cffca7c342d528a9bbdb692b..7cf44bf6acd12c98a15b2e7874d8235a057c4dce 100644 (file)
@@ -2706,11 +2706,12 @@ void Sema::ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D,
   // Verify 6.9.1p6: 'every identifier in the identifier list shall be declared'
   // for a K&R function.
   if (!FTI.hasPrototype) {
-    for (unsigned i = 0, e = FTI.NumArgs; i != e; ++i) {
+    for (int i = FTI.NumArgs; i != 0; /* decrement in loop */) {
+      --i;
       if (FTI.ArgInfo[i].Param == 0) {
-        std::string Code = "int ";
+        std::string Code = "  int ";
         Code += FTI.ArgInfo[i].Ident->getName();
-        Code += ";\n ";
+        Code += ";\n";
         Diag(FTI.ArgInfo[i].IdentLoc, diag::ext_param_not_declared)
           << FTI.ArgInfo[i].Ident
           << CodeModificationHint::CreateInsertion(LocAfterDecls, Code);