Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/tsar/Support/DiagnosticKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ def note_assert_no_macro : Note<"macro found">;

def warn_rename_macro_prevent : Warning<"macro prevent renaming">;

def warn_splitdeclaration_macro_prevent : Warning<"macro prevent splitting">;
def warn_parm_var_decl_split_prevent : Warning<"local parm variable declarations are not splitted">
def warn_pointers_to_constants_split_prevent : Warning<"declarations of pointers to constants are not splitted">

def warn_propagate_macro_prevent : Warning<"macro prevent expression propagation">;
def warn_disable_propagate_in_include : Warning<"disable expression propagation in header file">;
def warn_disable_propagate : Warning<"disable expression propagation">;
Expand Down
2 changes: 2 additions & 0 deletions include/tsar/Support/Directives.td
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ def NoInline : Clause<"noinline", Transform>;

def Propagate : Clause<"propagate", Transform>;

def SplitDeclaration : Clause<"splitdeclaration", Transform>;

def Rename : Clause<"rename", Transform>;

def LoopInterchange : Clause<"interchange", Transform,
Expand Down
7 changes: 7 additions & 0 deletions include/tsar/Transform/Clang/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,12 @@ void initializeClangLoopReversePass(PassRegistry &Registry);

/// Create a pass to reverse loop.
ModulePass *createClangLoopReverse();

/// Creates a pass for splitting variable declarations into single ones.
llvm::ModulePass * createClangSplitDeclsPass();

/// Initializes a pass for splitting variable declarations into single ones.
void initializeClangSplitDeclsPassPass(PassRegistry &Registry);

}
#endif//TSAR_CLANG_TRANSFORM_PASSES_H
61 changes: 61 additions & 0 deletions include/tsar/Transform/Clang/SplitDecls.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//===- MyFirstPass.h - Source-level Renaming of Local Objects -- *- C++ -*-===//
//
// Traits Static Analyzer (SAPFOR)
//
// Copyright 2018 DVM System Group
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//===----------------------------------------------------------------------===//
//
// This file declares a pass to perform renaming of objects into a specified
// scope. The goal of this transformation is to ensure that there is no
// different objects with the same name at a specified scope. The transformation
// also guaranties that names of objects declared in a specified scope do not
// match any name from other scopes.
//
//===----------------------------------------------------------------------===//
#ifndef TSAR_CLANG_SPLIT_DECLS_H
#define TSAR_CLANG_SPLIT_DECLS_H

#include "tsar/Transform/Clang/Passes.h"
#include <bcl/utility.h>
#include <llvm/Pass.h>

#include "tsar/Analysis/Clang/GlobalInfoExtractor.h"
#include <clang/AST/RecursiveASTVisitor.h>
#include <clang/AST/TypeLoc.h>
#include <llvm/ADT/BitmaskEnum.h>
#include <llvm/ADT/DenseMapInfo.h>
#include <llvm/ADT/StringMap.h>
#include <llvm/ADT/StringSet.h>
#include <map>
#include <memory>
#include <vector>

namespace llvm {
/// This pass separates variable declaration statements that contain multiple
/// variable declarations at once into single declarations.
class ClangSplitDeclsPass : public ModulePass, private bcl::Uncopyable {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно перенести объявление прохода в .cpp файл, а .h файл вообще удалить. Т.к. проход преобразования, не может быть запрошен из другого прохода, то и интерфейс его стоит скрыть внутри .cpp файлы, оставив видимыми наружу только функции initialize... и create... объявленные в Passes.h.

public:
static char ID;

ClangSplitDeclsPass() : ModulePass(ID) {
initializeClangSplitDeclsPassPass(*PassRegistry::getPassRegistry());
}

bool runOnModule(Module &M) override;
void getAnalysisUsage(AnalysisUsage &AU) const override;
};
}
#endif//TSAR_CLANG_SPLIT_DECLS_H
2 changes: 1 addition & 1 deletion lib/Transform/Clang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ set(TRANSFORM_SOURCES Passes.cpp ExprPropagation.cpp Inline.cpp RenameLocal.cpp
DeadDeclsElimination.cpp Format.cpp OpenMPAutoPar.cpp DVMHWriter.cpp
SharedMemoryAutoPar.cpp DVMHDirecitves.cpp DVMHSMAutoPar.cpp
DVMHDataTransferIPO.cpp StructureReplacement.cpp LoopInterchange.cpp
LoopReversal.cpp)
LoopReversal.cpp SplitDecls.cpp)

if(MSVC_IDE)
file(GLOB_RECURSE TRANSFORM_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
Expand Down
1 change: 1 addition & 0 deletions lib/Transform/Clang/Passes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ void llvm::initializeClangTransform(PassRegistry &Registry) {
initializeDVMHDataTransferIPOPassPass(Registry);
initializeClangLoopInterchangePass(Registry);
initializeClangLoopReversePass(Registry);
initializeClangSplitDeclsPassPass(Registry);
}
Loading