Debian Codegraph @

clang_delta/ReplaceFunctionDefWithDecl.h

raw symbols SCIP
1 //===----------------------------------------------------------------------===//
2 //
3 // Copyright (c) 2012, 2013, 2014, 2019 The University of Utah
4 // All rights reserved.
5 //
6 // This file is distributed under the University of Illinois Open Source
7 // License. See the file COPYING for details.
8 //
9 //===----------------------------------------------------------------------===//
10
11 #ifndef REPLACE_FUNCTION_DEF_WITH_DECL_H
12 #define REPLACE_FUNCTION_DEF_WITH_DECL_H
13
14 #include <string>
15 #include "llvm/ADT/SmallVector.h"
16 #include "Transformation.h"
17
18 namespace clang {
19 class DeclGroupRef;
20 class ASTContext;
21 class FunctionDecl;
22 class CXXConstructorDecl;
23 class FunctionTemplateDecl;
24 class SourceLocation;
25 }
26
27 class ReplaceFunctionDefWithDeclCollectionVisitor;
28
29 class ReplaceFunctionDefWithDecl : public Transformation {
30 friend class ReplaceFunctionDefWithDeclCollectionVisitor;
31
32 public:
33
34 // enable rewriting multiple instances
35 ReplaceFunctionDefWithDecl(const char *TransName, const char *Desc)
36 : Transformation(TransName, Desc, /*MultipleRewrites=*/true),
37 CollectionVisitor(NULL),
38 TheFunctionDef(NULL)
39 { }
40
41 ~ReplaceFunctionDefWithDecl();
42
43 private:
44
45 typedef llvm::SmallVector<const clang::FunctionDecl *, 500>
46 FunctionDeclVector;
47
48 virtual void Initialize(clang::ASTContext &context);
49
50 virtual void HandleTranslationUnit(clang::ASTContext &Ctx);
51
52 void addOneFunctionDef(const clang::FunctionDecl *FD);
53
54 void rewriteOneFunctionDef(const clang::FunctionDecl *FD);
55
56 void removeCtorInitializers(const clang::CXXConstructorDecl *Ctor);
57
58 unsigned getNumWrittenInitializers(const clang::CXXConstructorDecl *Ctor);
59
60 bool hasValidOuterLocStart(const clang::FunctionTemplateDecl *FTD,
61 const clang::FunctionDecl *FD);
62
63 void removeStringBeforeTypeIdentifier(const clang::SourceLocation &StartLoc,
64 const clang::SourceLocation &EndLoc);
65
66 bool removeOneInlineKeyword(const std::string &LeadingInlineStr,
67 const std::string &InlineStr,
68 const std::string &Str,
69 const clang::SourceLocation &StartLoc);
70
71 bool removeInlineKeyword(const std::string &InlineStr,
72 const std::string &Str,
73 const clang::SourceLocation &StartLoc);
74
75 void removeInlineKeywordFromOneFunctionDecl(const clang::FunctionDecl *FD);
76
77 void removeInlineKeywordFromFunctionDecls(const clang::FunctionDecl *FD);
78
79 void doRewriting();
80
81 FunctionDeclVector AllValidFunctionDefs;
82
83 ReplaceFunctionDefWithDeclCollectionVisitor *CollectionVisitor;
84
85 const clang::FunctionDecl *TheFunctionDef;
86
87 // Unimplemented
88 ReplaceFunctionDefWithDecl(void);
89
90 ReplaceFunctionDefWithDecl(const ReplaceFunctionDefWithDecl &);
91
92 void operator=(const ReplaceFunctionDefWithDecl &);
93 };
94 #endif
95