1 //===--- SourceExtraction.cpp - Clang refactoring library -----------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef LLVM_CLANG_LIB_TOOLING_REFACTORING_EXTRACT_SOURCE_EXTRACTION_H 11 #define LLVM_CLANG_LIB_TOOLING_REFACTORING_EXTRACT_SOURCE_EXTRACTION_H 12 13 #include "clang/Basic/LLVM.h" 14 15 namespace clang { 16 17 class LangOptions; 18 class SourceManager; 19 class SourceRange; 20 class Stmt; 21 22 namespace tooling { 23 24 /// Determines which semicolons should be inserted during extraction. 25 class ExtractionSemicolonPolicy { 26 public: isNeededInExtractedFunction()27 bool isNeededInExtractedFunction() const { 28 return IsNeededInExtractedFunction; 29 } 30 isNeededInOriginalFunction()31 bool isNeededInOriginalFunction() const { return IsNeededInOriginalFunction; } 32 33 /// Returns the semicolon insertion policy that is needed for extraction of 34 /// the given statement from the given source range. 35 static ExtractionSemicolonPolicy compute(const Stmt *S, 36 SourceRange &ExtractedRange, 37 const SourceManager &SM, 38 const LangOptions &LangOpts); 39 40 private: ExtractionSemicolonPolicy(bool IsNeededInExtractedFunction,bool IsNeededInOriginalFunction)41 ExtractionSemicolonPolicy(bool IsNeededInExtractedFunction, 42 bool IsNeededInOriginalFunction) 43 : IsNeededInExtractedFunction(IsNeededInExtractedFunction), 44 IsNeededInOriginalFunction(IsNeededInOriginalFunction) {} 45 bool IsNeededInExtractedFunction; 46 bool IsNeededInOriginalFunction; 47 }; 48 49 } // end namespace tooling 50 } // end namespace clang 51 52 #endif // LLVM_CLANG_LIB_TOOLING_REFACTORING_EXTRACT_SOURCE_EXTRACTION_H 53