OLD | NEW |
1 //===-- FrontendActions.h - Useful Frontend Actions -------------*- C++ -*-===// | 1 //===-- FrontendActions.h - Useful Frontend Actions -------------*- C++ -*-===// |
2 // | 2 // |
3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 | 9 |
10 #ifndef LLVM_CLANG_REWRITE_FRONTENDACTIONS_H | 10 #ifndef LLVM_CLANG_REWRITE_FRONTENDACTIONS_H |
11 #define LLVM_CLANG_REWRITE_FRONTENDACTIONS_H | 11 #define LLVM_CLANG_REWRITE_FRONTENDACTIONS_H |
12 | 12 |
13 #include "clang/Frontend/FrontendAction.h" | 13 #include "clang/Frontend/FrontendAction.h" |
| 14 |
| 15 #include "clang/Frontend/CompilerInstance.h" |
14 #include <string> | 16 #include <string> |
15 #include <vector> | 17 #include <vector> |
16 | 18 |
| 19 #include <sys/stat.h> |
| 20 |
17 namespace clang { | 21 namespace clang { |
18 class FixItRewriter; | 22 class FixItRewriter; |
19 class FixItOptions; | 23 class FixItOptions; |
20 | 24 |
21 //===----------------------------------------------------------------------===// | 25 //===----------------------------------------------------------------------===// |
22 // AST Consumer Actions | 26 // AST Consumer Actions |
23 //===----------------------------------------------------------------------===// | 27 //===----------------------------------------------------------------------===// |
24 | 28 |
25 class HTMLPrintAction : public ASTFrontendAction { | 29 class HTMLPrintAction : public ASTFrontendAction { |
26 protected: | 30 protected: |
(...skipping 30 matching lines...) Expand all Loading... |
57 class RewriteMacrosAction : public PreprocessorFrontendAction { | 61 class RewriteMacrosAction : public PreprocessorFrontendAction { |
58 protected: | 62 protected: |
59 void ExecuteAction(); | 63 void ExecuteAction(); |
60 }; | 64 }; |
61 | 65 |
62 class RewriteTestAction : public PreprocessorFrontendAction { | 66 class RewriteTestAction : public PreprocessorFrontendAction { |
63 protected: | 67 protected: |
64 void ExecuteAction(); | 68 void ExecuteAction(); |
65 }; | 69 }; |
66 | 70 |
| 71 class RewriteScopedRefptrAction : public ASTFrontendAction { |
| 72 protected: |
| 73 virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, |
| 74 llvm::StringRef InFile); |
| 75 |
| 76 #if 0 |
| 77 // doh, this is called before the rewriter finishes. so this isn't just hacky, i
t's wrong too |
| 78 virtual void EndSourceFileAction() { |
| 79 //fprintf(stderr, "done with %s, %s\n", getCurrentFile().c_str(), getCompilerIns
tance().getFrontendOpts().OutputFile.c_str()); |
| 80 //HACK |
| 81 if (getCompilerInstance().getDiagnostics().getNumErrors() == 0) { |
| 82 |
| 83 struct stat s; |
| 84 |
| 85 stat(getCompilerInstance().getFrontendOpts().OutputFile.c_str(), &s); |
| 86 |
| 87 if (!s.st_size) return; |
| 88 |
| 89 rename(getCompilerInstance().getFrontendOpts().OutputFile.c_str(), |
| 90 getCurrentFile().c_str()); |
| 91 } else { |
| 92 fprintf(stderr, "had errors; not copying file.\n"); |
| 93 } |
| 94 } |
| 95 #endif |
| 96 }; |
| 97 |
67 } // end namespace clang | 98 } // end namespace clang |
68 | 99 |
69 #endif | 100 #endif |
OLD | NEW |