clang  15.0.0git
SourceExtraction.h
Go to the documentation of this file.
1 //===--- SourceExtraction.cpp - Clang refactoring library -----------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_CLANG_TOOLING_REFACTORING_EXTRACT_SOURCEEXTRACTION_H
10 #define LLVM_CLANG_TOOLING_REFACTORING_EXTRACT_SOURCEEXTRACTION_H
11 
12 #include "clang/Basic/LLVM.h"
13 
14 namespace clang {
15 
16 class LangOptions;
17 class SourceManager;
18 class SourceRange;
19 class Stmt;
20 
21 namespace tooling {
22 
23 /// Determines which semicolons should be inserted during extraction.
25 public:
27  return IsNeededInExtractedFunction;
28  }
29 
30  bool isNeededInOriginalFunction() const { return IsNeededInOriginalFunction; }
31 
32  /// Returns the semicolon insertion policy that is needed for extraction of
33  /// the given statement from the given source range.
34  static ExtractionSemicolonPolicy compute(const Stmt *S,
35  SourceRange &ExtractedRange,
36  const SourceManager &SM,
37  const LangOptions &LangOpts);
38 
39 private:
40  ExtractionSemicolonPolicy(bool IsNeededInExtractedFunction,
41  bool IsNeededInOriginalFunction)
42  : IsNeededInExtractedFunction(IsNeededInExtractedFunction),
43  IsNeededInOriginalFunction(IsNeededInOriginalFunction) {}
44  bool IsNeededInExtractedFunction;
45  bool IsNeededInOriginalFunction;
46 };
47 
48 } // end namespace tooling
49 } // end namespace clang
50 
51 #endif // LLVM_CLANG_TOOLING_REFACTORING_EXTRACT_SOURCEEXTRACTION_H
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:210
clang::tooling::ExtractionSemicolonPolicy::isNeededInExtractedFunction
bool isNeededInExtractedFunction() const
Definition: SourceExtraction.h:26
clang::tooling::ExtractionSemicolonPolicy::compute
static ExtractionSemicolonPolicy compute(const Stmt *S, SourceRange &ExtractedRange, const SourceManager &SM, const LangOptions &LangOpts)
Returns the semicolon insertion policy that is needed for extraction of the given statement from the ...
Definition: SourceExtraction.cpp:72
clang::SourceManager
This class handles loading and caching of source files into memory.
Definition: SourceManager.h:627
clang::tooling::ExtractionSemicolonPolicy::isNeededInOriginalFunction
bool isNeededInOriginalFunction() const
Definition: SourceExtraction.h:30
clang::tooling::ExtractionSemicolonPolicy
Determines which semicolons should be inserted during extraction.
Definition: SourceExtraction.h:24
LLVM.h
clang::LangOptions
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:78
clang
Definition: CalledOnceCheck.h:17
clang::Stmt
Stmt - This represents one statement.
Definition: Stmt.h:69
SM
#define SM(sm)
Definition: Cuda.cpp:81