├── CPP2D
├── CustomPrinters.h
├── CustomPrinters.cpp
├── CustomPrinters
│ ├── boost_port.cpp
│ ├── c_stdlib_port.cpp
│ └── cpp_stdlib_port.cpp
├── Options.cpp
├── Spliter.h
├── Options.h
├── CPP2DFrontendAction.h
├── CPP2DFrontendAction.cpp
├── CPP2DConsumer.h
├── CPP2DTools.h
├── CMakeLists.txt
├── CPP2DConsumer.cpp
├── CPP2DTools.cpp
├── CPP2D.vcxproj.user
├── CPP2D.cpp
├── CPP2DPPHandling.h
├── CPP2D.vcxproj.filters
├── MatchContainer.h
├── MatchContainer.cpp
├── CPP2DPPHandling.cpp
├── CPP2D.vcxproj
└── DPrinter.h
├── CPP2D_UT_CPP
├── CMakeLists.txt
├── stdlib_testsuite.h
├── template_testsuite.h
├── CPP2D_UT_CPP.vcxproj.user
├── test.h
├── main.cpp
├── framework.cpp
├── framework.h
├── comment.cpp
├── CPP2D_UT_CPP.vcxproj.filters
├── template_testsuite.cpp
├── CPP2D_UT_CPP.vcxproj
├── stdlib_testsuite.cpp
└── test.cpp
├── CMakeLists.txt
├── .gitignore
├── LICENSE_1_0.txt
├── .travis.yml
├── appveyor.yml
├── CPP2D.sln
├── cpp_std.d
└── README.md
/CPP2D/CustomPrinters.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lhamot/CPP2D/HEAD/CPP2D/CustomPrinters.h
--------------------------------------------------------------------------------
/CPP2D/CustomPrinters.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lhamot/CPP2D/HEAD/CPP2D/CustomPrinters.cpp
--------------------------------------------------------------------------------
/CPP2D_UT_CPP/CMakeLists.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lhamot/CPP2D/HEAD/CPP2D_UT_CPP/CMakeLists.txt
--------------------------------------------------------------------------------
/CPP2D_UT_CPP/stdlib_testsuite.h:
--------------------------------------------------------------------------------
1 | #include "framework.h"
2 |
3 | void stdlib_register(TestFrameWork& tf);
--------------------------------------------------------------------------------
/CPP2D/CustomPrinters/boost_port.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lhamot/CPP2D/HEAD/CPP2D/CustomPrinters/boost_port.cpp
--------------------------------------------------------------------------------
/CPP2D_UT_CPP/template_testsuite.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lhamot/CPP2D/HEAD/CPP2D_UT_CPP/template_testsuite.h
--------------------------------------------------------------------------------
/CPP2D/CustomPrinters/c_stdlib_port.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lhamot/CPP2D/HEAD/CPP2D/CustomPrinters/c_stdlib_port.cpp
--------------------------------------------------------------------------------
/CPP2D/CustomPrinters/cpp_stdlib_port.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lhamot/CPP2D/HEAD/CPP2D/CustomPrinters/cpp_stdlib_port.cpp
--------------------------------------------------------------------------------
/CPP2D/Options.cpp:
--------------------------------------------------------------------------------
1 | #include "Options.h"
2 |
3 | Options& Options::getInstance()
4 | {
5 | static Options instance;
6 | return instance;
7 | }
8 |
--------------------------------------------------------------------------------
/CPP2D_UT_CPP/CPP2D_UT_CPP.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/CPP2D_UT_CPP/test.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2016 Loïc HAMOT
3 | //
4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 | //
7 | #pragma once
8 |
9 | #include "framework.h"
10 |
11 | void test_register(TestFrameWork& tf);
12 |
--------------------------------------------------------------------------------
/CPP2D/Spliter.h:
--------------------------------------------------------------------------------
1 | #include
2 | #include "DPrinter.h"
3 |
4 | struct Spliter
5 | {
6 | DPrinter& printer;
7 | std::string const str;
8 | bool first = true;
9 |
10 | Spliter(DPrinter& pr, std::string const& s) : printer(pr), str(s) {}
11 |
12 | void split()
13 | {
14 | if(first)
15 | first = false;
16 | else
17 | printer.stream() << str;
18 | }
19 | };
20 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.6)
2 |
3 | project(cpp2d)
4 |
5 | if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
6 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -fno-rtti")
7 | endif()
8 |
9 | find_package(LLVM 6 REQUIRED)
10 | include_directories(${LLVM_INCLUDE_DIRS})
11 | link_directories(${LLVM_LIBRARY_DIRS})
12 |
13 | add_subdirectory(CPP2D)
14 | add_subdirectory(CPP2D_UT_CPP)
15 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.suo
2 | /CPP2D/x64/Debug
3 | /CPP2D/x64/Release
4 | *.patch
5 | /x64/Debug
6 | /x64/Release
7 | /AStyle.exe
8 | *.opensdf
9 | *.sdf
10 | /format.bat
11 | /todo.txt
12 | /CPP2D_UT_CPP/x64/Debug
13 | /CPP2D_UT_CPP/x64/Release
14 | /doc
15 | /*.vsp
16 | /*.psess
17 | /compile_commands.json
18 | /CPP2D_UT_CPP/*.tmp
19 | /garbage
20 | /CPP2D.VC.db
21 | /*.opendb
22 | /CPP2D_UT_CPP/compile_commands.json
23 | /build
24 | /CPP2D_UT_D
25 |
--------------------------------------------------------------------------------
/CPP2D/Options.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | struct TypeOptions
7 | {
8 | //! Semantic of an object (Value or Reference)
9 | enum Semantic
10 | {
11 | Value, //!< Like **D** struct and everything in C++
12 | Reference, //!< Garbage collected like **D** class
13 | AssocArray, //!< Special case for hashmap. Created without new, but reference semantic.
14 | };
15 |
16 | std::string name;
17 | Semantic semantic;
18 | };
19 |
20 | struct Options
21 | {
22 | std::unordered_map types;
23 |
24 | static Options& getInstance();
25 | };
26 |
27 |
--------------------------------------------------------------------------------
/CPP2D_UT_CPP/main.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2016 Loïc HAMOT
3 | //
4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 | //
7 | #include "framework.h"
8 | #include "test.h"
9 | #include "stdlib_testsuite.h"
10 | #include "template_testsuite.h"
11 |
12 | int main(
13 | int argc, char** argv
14 | )
15 | {
16 | int argvCount = argc;
17 | CHECK(argvCount > 0);
18 | CHECK(argv[0] != nullptr);
19 |
20 | TestFrameWork testFrameWork;
21 | test_register(testFrameWork);
22 | stdlib_register(testFrameWork);
23 | template_register(testFrameWork);
24 | testFrameWork.run();
25 |
26 | testFrameWork.print_results();
27 |
28 | return 0;
29 | }
--------------------------------------------------------------------------------
/CPP2D/CPP2DFrontendAction.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2016 Loïc HAMOT
3 | //
4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 | //
7 | #pragma once
8 |
9 | #include
10 |
11 | #pragma warning(push, 0)
12 | #include "clang/Frontend/FrontendActions.h"
13 | #pragma warning(pop)
14 |
15 | namespace clang
16 | {
17 | class CompilerInstance;
18 | }
19 |
20 | class CPP2DPPHandling;
21 |
22 | //! Implement clang::ASTFrontendAction to create the CPP2DConsumer
23 | class CPP2DFrontendAction : public clang::ASTFrontendAction
24 | {
25 | public:
26 | //! Create the CPP2DConsumer
27 | std::unique_ptr CreateASTConsumer(
28 | clang::CompilerInstance& Compiler,
29 | llvm::StringRef InFile
30 | ) override;
31 |
32 | //! Add the CPP2DPPHandling (PPCallbacks) to the Preprocessor
33 | bool BeginSourceFileAction(clang::CompilerInstance& ci) override;
34 |
35 | private:
36 | CPP2DPPHandling* ppHandlingPtr = nullptr;
37 | };
38 |
--------------------------------------------------------------------------------
/CPP2D/CPP2DFrontendAction.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2016 Loïc HAMOT
3 | //
4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 | //
7 |
8 | #include "CPP2DFrontendAction.h"
9 |
10 | #include
11 |
12 | #pragma warning(push, 0)
13 | #include
14 | #include
15 | #pragma warning(pop)
16 |
17 | #include "CPP2DConsumer.h"
18 | #include "CPP2DPPHandling.h"
19 |
20 | using namespace clang;
21 |
22 | std::unique_ptr CPP2DFrontendAction::CreateASTConsumer(
23 | clang::CompilerInstance& Compiler,
24 | llvm::StringRef InFile
25 | )
26 | {
27 | auto consumer = std::make_unique(Compiler, InFile);
28 | consumer->setPPCallBack(ppHandlingPtr);
29 | return std::move(consumer);
30 | }
31 |
32 | bool CPP2DFrontendAction::BeginSourceFileAction(CompilerInstance& ci)
33 | {
34 | Preprocessor& pp = ci.getPreprocessor();
35 | auto ppHandling = std::make_unique(pp.getSourceManager(), pp, getCurrentFile());
36 | ppHandlingPtr = ppHandling.get();
37 | pp.addPPCallbacks(std::move(ppHandling));
38 | return true;
39 | }
40 |
41 |
--------------------------------------------------------------------------------
/CPP2D_UT_CPP/framework.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2016 Loïc HAMOT
3 | //
4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 | //
7 | #include
8 | #include "framework.h"
9 |
10 | unsigned int testCount = 0;
11 |
12 | void check(bool ok, char const* message, int line, char const* file)
13 | {
14 | ++testCount;
15 | if (!ok)
16 | {
17 | //printf(message);
18 | printf("%s ->Failed at line %u, in file %s\n", message, line, file);
19 | }
20 | }
21 |
22 | void TestSuite::run() const noexcept
23 | {
24 | for (TestCase const& testcase : testCases)
25 | {
26 | try
27 | {
28 | testcase();
29 | }
30 | catch (std::exception& ex)
31 | {
32 | printf("%s", ex.what());
33 | }
34 | }
35 | }
36 |
37 | void TestSuite::addTestCase(TestCase testCase)
38 | {
39 | testCases.push_back(testCase);
40 | }
41 |
42 | void TestFrameWork::run() const noexcept
43 | {
44 | for (std::unique_ptr const& suite : testSuites)
45 | suite->run();
46 | }
47 |
48 | void TestFrameWork::print_results()
49 | {
50 | printf("%u tests\n", testCount);
51 | }
52 |
53 | void TestFrameWork::addTestSuite(std::unique_ptr&& testSuite)
54 | {
55 | testSuites.emplace_back(std::move(testSuite));
56 | }
57 |
58 |
--------------------------------------------------------------------------------
/CPP2D/CPP2DConsumer.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2016 Loïc HAMOT
3 | //
4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 | //
7 | #pragma once
8 |
9 | #pragma warning(push, 0)
10 | #include
11 | #pragma warning(disable: 4265)
12 | #include
13 | #pragma warning(pop)
14 |
15 | #include "MatchContainer.h"
16 | #include "DPrinter.h"
17 |
18 | namespace clang
19 | {
20 | class CompilerInstance;
21 | }
22 |
23 | class CPP2DPPHandling;
24 |
25 | //! Implement clang::ASTConsumer to call the DPrinter
26 | class CPP2DConsumer : public clang::ASTConsumer
27 | {
28 | public:
29 | explicit CPP2DConsumer(
30 | clang::CompilerInstance& compiler,
31 | llvm::StringRef inFile
32 | );
33 |
34 | //! Print imports, mixins, and finaly call the DPrinter on the translationUnit
35 | void HandleTranslationUnit(clang::ASTContext& context) override;
36 |
37 | void setPPCallBack(CPP2DPPHandling* cb)
38 | {
39 | ppcallbackPtr = cb;
40 | }
41 |
42 | private:
43 | clang::CompilerInstance& compiler;
44 | MatchContainer receiver;
45 | clang::ast_matchers::MatchFinder finder;
46 | std::unique_ptr finderConsumer;
47 | std::string inFile;
48 | DPrinter visitor;
49 | CPP2DPPHandling* ppcallbackPtr = nullptr;
50 | };
51 |
52 |
--------------------------------------------------------------------------------
/LICENSE_1_0.txt:
--------------------------------------------------------------------------------
1 | Boost Software License - Version 1.0 - August 17th, 2003
2 |
3 | Permission is hereby granted, free of charge, to any person or organization
4 | obtaining a copy of the software and accompanying documentation covered by
5 | this license (the "Software") to use, reproduce, display, distribute,
6 | execute, and transmit the Software, and to prepare derivative works of the
7 | Software, and to permit third-parties to whom the Software is furnished to
8 | do so, all subject to the following:
9 |
10 | The copyright notices in the Software and this entire statement, including
11 | the above license grant, this restriction and the following disclaimer,
12 | must be included in all copies of the Software, in whole or in part, and
13 | all derivative works of the Software, unless such copies or derivative
14 | works are solely in the form of machine-executable object code generated by
15 | a source language processor.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 | DEALINGS IN THE SOFTWARE.
24 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: C++
2 | sudo: false
3 | dist: trusty
4 | addons:
5 | apt:
6 | update: true
7 | sources:
8 | - llvm-toolchain-trusty-6.0
9 | - ubuntu-toolchain-r-test
10 | packages:
11 | - cmake
12 | - libclang-6.0-dev
13 | - llvm-6.0-dev
14 | - gcc-4.9
15 | - g++-4.9
16 | - curl
17 |
18 | install:
19 | - curl -fsS https://dlang.org/install.sh | bash -s ldc
20 | - source ~/dlang/ldc-1.12.0/activate
21 | - export CC="gcc-4.9"
22 | - export CPP="g++-4.9"
23 | - export CXX="g++-4.9"
24 | - export LD="g++-4.9"
25 |
26 | script:
27 | - mkdir -p build
28 | - cd build
29 | - cmake .. -DCMAKE_PREFIX_PATH=/usr/lib/llvm-6.0 -DCMAKE_EXPORT_COMPILE_COMMANDS=OFF
30 | - make
31 | - cmake .. -DCMAKE_PREFIX_PATH=/usr/lib/llvm-6.0 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
32 | - ln -s $PWD/compile_commands.json ../CPP2D_UT_CPP
33 | - cd ../CPP2D_UT_CPP
34 | - ../build/CPP2D/cpp2d stdlib_testsuite.cpp template_testsuite.cpp test.cpp framework.cpp main.cpp comment.cpp -macro-expr=UT_MACRO_EXPR/nn -macro-expr=CHECK/e -macro-expr=CHECK_EQUAL/ee -macro-expr=UT_MACRO/eee -macro-stmt=UT_MACRO_STMT -macro-stmt=UT_MACRO_STMT_CLASS/ntne
35 | - mkdir ../CPP2D_UT_D
36 | - cp ../build/CPP2D_UT_CPP/*.d ../CPP2D_UT_D
37 | - cd ../CPP2D_UT_D
38 | - ldc2 -m64 -ofCPP2D_UT_D ../cpp_std.d template_testsuite.d main.d framework.d test.d stdlib_testsuite.d comment.d
39 | - ../build/CPP2D_UT_CPP/CPP2D_UT_CPP
40 | - ./CPP2D_UT_D
41 |
--------------------------------------------------------------------------------
/CPP2D/CPP2DTools.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2016 Loïc HAMOT
3 | //
4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 | //
7 | #pragma once
8 | #include
9 |
10 | namespace clang
11 | {
12 | class ASTContext;
13 | class Stmt;
14 | class Decl;
15 | class SourceLocation;
16 | }
17 |
18 | namespace CPP2DTools
19 | {
20 | //! Get the name of the file pointed by sl
21 | const char* getFile(clang::SourceManager const& sourceManager, clang::SourceLocation const& sl);
22 | //! Get the name of the file pointed by s
23 | const char* getFile(clang::SourceManager const& sourceManager, clang::Stmt const* s);
24 | //! Get the name of the file pointed by d
25 | const char* getFile(clang::SourceManager const& sourceManager, clang::Decl const* d);
26 | //! @return true if the file is the header of the module (the matching header of the cpp)
27 | bool checkFilename(std::string const& modulename, char const* filepath_str);
28 | //! @return true if the file of d is in the header of the module
29 | bool checkFilename(clang::SourceManager const& sourceManager,
30 | std::string const& modulename,
31 | clang::Decl const* d);
32 |
33 | //! @brief Replace the ocurances of search in subject, by replace
34 | //! @return subject with the replaced strings.
35 | std::string replaceString(std::string subject,
36 | const std::string& search,
37 | const std::string& replace);
38 |
39 | }
--------------------------------------------------------------------------------
/CPP2D/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.6)
2 |
3 | project(cpp2d)
4 |
5 | # Executable declaration
6 | add_executable(
7 | cpp2d
8 | CPP2D.cpp
9 | CPP2DConsumer.cpp
10 | CPP2DFrontendAction.cpp
11 | CPP2DPPHandling.cpp
12 | CPP2DTools.cpp
13 | DPrinter.cpp
14 | MatchContainer.cpp
15 | CustomPrinters.cpp
16 | Options.cpp
17 | CustomPrinters/boost_port.cpp
18 | CustomPrinters/c_stdlib_port.cpp
19 | CustomPrinters/cpp_stdlib_port.cpp
20 | )
21 |
22 | target_link_libraries(cpp2d
23 | clangFrontend
24 | clangSerialization
25 | clangDriver
26 | clangParse
27 | clangSema
28 | clangAnalysis
29 | clangAST
30 | clangBasic
31 | clangEdit
32 | clangLex
33 | clangTooling
34 | clangASTMatchers
35 | )
36 |
37 | target_link_libraries(cpp2d
38 | LLVMX86AsmParser # MC, MCParser, Support, X86Desc, X86Info
39 | LLVMX86Desc # MC, Support, X86AsmPrinter, X86Info
40 | LLVMX86AsmPrinter # MC, Support, X86Utils
41 | LLVMX86Info # MC, Support, Target
42 | LLVMX86Utils # Core, Support
43 | LLVMipo
44 | LLVMScalarOpts
45 | LLVMInstCombine
46 | LLVMTransformUtils
47 | LLVMAnalysis
48 | LLVMTarget
49 | LLVMOption # Support
50 | LLVMMCParser # MC, Support
51 | LLVMMC # Object, Support
52 | LLVMObject # BitReader, Core, Support
53 | LLVMBitReader # Core, Support
54 | LLVMCore # Support
55 | LLVMProfileData
56 | LLVMSupport
57 | LLVMDemangle
58 | LLVMBinaryFormat # Needed under windows
59 | )
60 |
61 | if(CMAKE_COMPILER_IS_GNUCXX)
62 | target_link_libraries(cpp2d rt dl tinfo pthread z m)
63 | endif()
64 |
65 | if(CMAKE_SYSTEM_NAME MATCHES "Windows")
66 | target_link_libraries(cpp2d
67 | version.lib
68 | )
69 | endif()
70 |
--------------------------------------------------------------------------------
/CPP2D/CPP2DConsumer.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2016 Loïc HAMOT
3 | //
4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 | //
7 |
8 | #include "CPP2DConsumer.h"
9 | #include "CPP2DPPHandling.h"
10 |
11 | #include
12 | #include
13 |
14 | #pragma warning(push, 0)
15 | #include
16 | #include
17 | #include
18 | #pragma warning(pop)
19 |
20 | CPP2DConsumer::CPP2DConsumer(
21 | clang::CompilerInstance& compiler,
22 | llvm::StringRef inFile
23 | )
24 | : compiler(compiler)
25 | , finder(receiver.getMatcher())
26 | , finderConsumer(finder.newASTConsumer())
27 | , inFile(inFile.str())
28 | , visitor(&compiler.getASTContext(), receiver, inFile)
29 | {
30 | }
31 |
32 | void CPP2DConsumer::HandleTranslationUnit(clang::ASTContext& context)
33 | {
34 | //Find_Includes
35 | CPP2DPPHandling& ppcallback = *ppcallbackPtr;
36 | auto& incs = ppcallback.getIncludes();
37 |
38 | finderConsumer->HandleTranslationUnit(context);
39 | visitor.setIncludes(incs);
40 | visitor.TraverseTranslationUnitDecl(context.getTranslationUnitDecl());
41 |
42 | std::string modulename = llvm::sys::path::stem(inFile).str();
43 | std::ofstream file(modulename + ".d");
44 | std::string new_modulename;
45 | std::replace_copy(std::begin(modulename), std::end(modulename),
46 | std::back_inserter(new_modulename), '-', '_'); //Replace illegal characters
47 | if(new_modulename != modulename) // When filename has some illegal characters
48 | file << "module " << new_modulename << ';';
49 | for(auto const& import : visitor.getExternIncludes())
50 | {
51 | file << "import " << import.first << "; //";
52 | for(auto const& type : import.second)
53 | file << type << " ";
54 | file << std::endl;
55 | }
56 | file << "\n\n";
57 | for(auto const& code : ppcallback.getInsertedBeforeDecls())
58 | file << code << '\n';
59 | file << visitor.getDCode();
60 | }
61 |
--------------------------------------------------------------------------------
/CPP2D_UT_CPP/framework.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2016 Loïc HAMOT
3 | //
4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 | //
7 | #pragma once
8 |
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 |
15 | extern unsigned int testCount;
16 |
17 | void check(bool ok, char const* message, int line, char const* file);
18 |
19 | template
20 | void check_equal(A a, B b, char const* astr, char const* bstr, int line, char const* file)
21 | {
22 | ++testCount;
23 | if (a != b)
24 | {
25 | std::cout << astr << " == " << bstr << " ->Failed at line " << line << ", in file " << file
26 | << ", because " << a << " != " << b << '\n';
27 | }
28 | }
29 |
30 | #define CHECK(COND) check(COND, #COND, __LINE__, __FILE__)
31 | #define CHECK_EQUAL(A, B) check_equal(A, B, #A, #B, __LINE__, __FILE__)
32 |
33 | typedef void(*TestCase)(); //!< One small test independant of others
34 |
35 | //! Store some related test cases, and run them
36 | class TestSuite
37 | {
38 | TestSuite(TestSuite const&) = delete;
39 | TestSuite& operator=(TestSuite const&) = delete;
40 |
41 | std::vector testCases;
42 |
43 | public:
44 | TestSuite() = default;
45 |
46 | //! Run all test cases
47 | void run() const noexcept;
48 |
49 | //! @brief Add a test cases
50 | //! @pre TestCase != nullptr
51 | void addTestCase(TestCase testCase);
52 | };
53 |
54 | //! Store all test suites, and run them
55 | class TestFrameWork
56 | {
57 | TestFrameWork(TestFrameWork const&) = delete;
58 | TestFrameWork& operator=(TestFrameWork const&) = delete;
59 |
60 | std::vector > testSuites;
61 |
62 | public:
63 | TestFrameWork() = default;
64 |
65 | //! Run all test suites
66 | void run() const noexcept;
67 |
68 | //! @brief Print a report to std output
69 | //! @pre TestFrameWork::run has been called
70 | void print_results();
71 |
72 | //! @brief Add a test suite
73 | //! @pre testSuite != nullptr
74 | void addTestSuite(std::unique_ptr&& testSuite);
75 | };
76 |
77 |
--------------------------------------------------------------------------------
/appveyor.yml:
--------------------------------------------------------------------------------
1 | install:
2 | # Install curl
3 | - PATH=C:\Program Files\Git\mingw64\bin;%PATH%
4 | - cd %APPVEYOR_BUILD_FOLDER%
5 | - cd ..
6 | - mkdir deps
7 | - cd deps
8 | # Install llvm
9 | - curl -o llvm-6.0.1.7z http://www.nogane.net/owncloud/index.php/s/qdUscYbcXtHQTqG/download
10 | - 7z x llvm-6.0.1.7z
11 | # Install dmd
12 | - curl -o dmd.2.081.1.windows.7z http://downloads.dlang.org/releases/2018/dmd.2.081.1.windows.7z
13 | - 7z x dmd.2.081.1.windows.7z
14 | - PATH=%APPVEYOR_BUILD_FOLDER%/../deps/dmd2/windows/bin;%PATH%
15 | # Build CPP2D
16 | - cd %APPVEYOR_BUILD_FOLDER%
17 | - mkdir -p build
18 | - cd build
19 | - cmake -G "Visual Studio 14 2015 Win64" .. -DCMAKE_SYSTEM_VERSION=6.1 -DCMAKE_PREFIX_PATH=%APPVEYOR_BUILD_FOLDER%/../deps/llvm-6.0.1 -DCMAKE_EXPORT_COMPILE_COMMANDS=OFF
20 |
21 | platform: x64
22 |
23 | configuration: Release
24 |
25 | build:
26 | project: build/CPP2D.sln
27 | parallel: true
28 |
29 | test_script:
30 | - cd ..\CPP2D_UT_CPP
31 | - ..\build\CPP2D\Release\cpp2d.exe stdlib_testsuite.cpp template_testsuite.cpp test.cpp framework.cpp main.cpp comment.cpp -macro-expr=UT_MACRO_EXPR/nn -macro-expr=CHECK/e -macro-expr=CHECK_EQUAL/ee -macro-expr=UT_MACRO/eee -macro-stmt=UT_MACRO_STMT -macro-stmt=UT_MACRO_STMT_CLASS/ntne
32 | - mkdir ..\CPP2D_UT_D
33 | - copy *.d ..\CPP2D_UT_D
34 | - cd ..\CPP2D_UT_D
35 | - dmd -ofCPP2D_UT_D ../cpp_std.d template_testsuite.d main.d framework.d test.d stdlib_testsuite.d comment.d
36 | - ..\build\CPP2D_UT_CPP\Release\CPP2D_UT_CPP
37 | - .\CPP2D_UT_D
38 |
39 | artifacts:
40 | - path: build\CPP2D\Release\cpp2d.exe
41 | name: cpp2d
42 |
43 | before_deploy:
44 | - cd %APPVEYOR_BUILD_FOLDER%
45 | - cd ..
46 | - mkdir export
47 | - copy %APPVEYOR_BUILD_FOLDER%\build\CPP2D\Release\cpp2d.exe export
48 |
49 | deploy:
50 | provider: GitHub
51 | name: production
52 | artifact: build\CPP2D\Release\cpp2d.exe
53 | draft: true
54 | prerelease: false
55 | auth_token:
56 | secure: shGtrmloOL+jiGtSauloOo4irhao45Ei0THf2VPepuIkqLxMpS0P5PEu4lsm8b/5
57 | on:
58 | branch: master # release from master branch only
59 | appveyor_repo_tag: false # deploy on tag push only
60 |
61 |
--------------------------------------------------------------------------------
/CPP2D_UT_CPP/comment.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2016 Loïc HAMOT
3 | //
4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 | //
7 |
8 | // Check for #ifdef #endif
9 |
10 | #define MULTI_LINE \
11 | int i = 45; \
12 | int j = 72;
13 |
14 | #define FEATURE_A
15 |
16 | #ifdef FEATURE_A
17 | const int FeatureA = 1;
18 | #else
19 | const int FeatureA = 0;
20 | #endif
21 |
22 | static_assert(FeatureA == 1, "FEATURE_A is not defined??");
23 |
24 | // Check for #if
25 |
26 | #define FEATURE_B
27 |
28 | #if defined(FEATURE_B)
29 | const int FeatureB = 1;
30 | #else
31 | const int FeatureB = 0;
32 | #endif
33 |
34 | static_assert(FeatureB, "FEATURE_B is not defined??");
35 |
36 | // Check for #else
37 |
38 | #if defined(FEATURE_C)
39 | const int FeatureC = 1;
40 | #else
41 | const int FeatureC = 0;
42 | #endif
43 |
44 | static_assert(FeatureC == 0, "FEATURE_C is defined??");
45 |
46 | // Check for #elif
47 |
48 | #if defined(FEATURE_D)
49 | const int FeatureD = 1;
50 | #elif defined(FEATURE_B)
51 | const int FeatureD = 2;
52 | #else
53 | const int FeatureD = 3;
54 | #endif
55 |
56 | static_assert(FeatureD == 2, "FEATURE_D is defined??");
57 |
58 | void func4845(
59 | int aaaa
60 | , int bbbb //hhhh!
61 | , int cccc = 45 //iii!
62 | , char const* dddd = "ffffgggg" //jjjj!
63 | , char const* uuuu = "ojftfs", //xkdtrt!
64 | int eeee = 13
65 | )
66 | {
67 | }
68 |
69 | int func2(int asdflkhds, int bateau)
70 | {
71 | /*
72 | gdf
73 | dslksdgfjn
74 | gdfg
75 | */
76 | int a = asdflkhds;
77 | /*
78 | sdgfdfhfgj
79 | */
80 | return a;
81 | /*
82 | - 1:
83 | - 2
84 | - 3
85 | */
86 | }
87 |
88 | // Comment!
89 | int func3()
90 | {
91 | //ABCDEF1
92 | int a = 0;
93 | //ABCDEF2
94 | return a;
95 | //ABCDEF3
96 | }
97 |
98 | // Comment!
99 | int func4()
100 | {
101 | #ifdef ABCDEF4
102 | assert(false);
103 | #endif
104 | int a = 0;
105 | #ifdef ABCDEF5
106 | assert(false);
107 | #endif
108 | return a;
109 | #ifdef ABCDEF6
110 | assert(false);
111 | #endif
112 | }
113 |
114 | /*
115 | Flub
116 | */
--------------------------------------------------------------------------------
/CPP2D_UT_CPP/CPP2D_UT_CPP.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | Fichiers sources
23 |
24 |
25 | Fichiers sources
26 |
27 |
28 | Fichiers sources
29 |
30 |
31 | Fichiers sources
32 |
33 |
34 | Fichiers sources
35 |
36 |
37 | Fichiers sources
38 |
39 |
40 |
41 |
42 | Fichiers d%27en-tête
43 |
44 |
45 | Fichiers sources
46 |
47 |
48 | Fichiers d%27en-tête
49 |
50 |
51 | Fichiers d%27en-tête
52 |
53 |
54 |
--------------------------------------------------------------------------------
/CPP2D.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CPP2D", "CPP2D\CPP2D.vcxproj", "{F60FFC9A-3941-4F21-81E0-7E23E54E8F93}"
7 | EndProject
8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CPP2D_UT_CPP", "CPP2D_UT_CPP\CPP2D_UT_CPP.vcxproj", "{1981F516-28E6-4905-B4E8-BD38982CBCE8}"
9 | EndProject
10 | Global
11 | GlobalSection(Performance) = preSolution
12 | HasPerformanceSessions = true
13 | EndGlobalSection
14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
15 | Debug|x64 = Debug|x64
16 | Debug|x86 = Debug|x86
17 | Release|x64 = Release|x64
18 | Release|x86 = Release|x86
19 | EndGlobalSection
20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
21 | {F60FFC9A-3941-4F21-81E0-7E23E54E8F93}.Debug|x64.ActiveCfg = Debug|x64
22 | {F60FFC9A-3941-4F21-81E0-7E23E54E8F93}.Debug|x64.Build.0 = Debug|x64
23 | {F60FFC9A-3941-4F21-81E0-7E23E54E8F93}.Debug|x86.ActiveCfg = Debug|Win32
24 | {F60FFC9A-3941-4F21-81E0-7E23E54E8F93}.Debug|x86.Build.0 = Debug|Win32
25 | {F60FFC9A-3941-4F21-81E0-7E23E54E8F93}.Release|x64.ActiveCfg = Release|x64
26 | {F60FFC9A-3941-4F21-81E0-7E23E54E8F93}.Release|x64.Build.0 = Release|x64
27 | {F60FFC9A-3941-4F21-81E0-7E23E54E8F93}.Release|x86.ActiveCfg = Release|Win32
28 | {F60FFC9A-3941-4F21-81E0-7E23E54E8F93}.Release|x86.Build.0 = Release|Win32
29 | {1981F516-28E6-4905-B4E8-BD38982CBCE8}.Debug|x64.ActiveCfg = Debug|x64
30 | {1981F516-28E6-4905-B4E8-BD38982CBCE8}.Debug|x64.Build.0 = Debug|x64
31 | {1981F516-28E6-4905-B4E8-BD38982CBCE8}.Debug|x86.ActiveCfg = Debug|Win32
32 | {1981F516-28E6-4905-B4E8-BD38982CBCE8}.Debug|x86.Build.0 = Debug|Win32
33 | {1981F516-28E6-4905-B4E8-BD38982CBCE8}.Release|x64.ActiveCfg = Release|x64
34 | {1981F516-28E6-4905-B4E8-BD38982CBCE8}.Release|x64.Build.0 = Release|x64
35 | {1981F516-28E6-4905-B4E8-BD38982CBCE8}.Release|x86.ActiveCfg = Release|Win32
36 | {1981F516-28E6-4905-B4E8-BD38982CBCE8}.Release|x86.Build.0 = Release|Win32
37 | EndGlobalSection
38 | GlobalSection(SolutionProperties) = preSolution
39 | HideSolutionNode = FALSE
40 | EndGlobalSection
41 | EndGlobal
42 |
--------------------------------------------------------------------------------
/CPP2D_UT_CPP/template_testsuite.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2016 Loïc HAMOT
3 | //
4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 | //
7 | //
8 | // Copyright (c) 2016 Loïc HAMOT
9 | //
10 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
11 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
12 | //
13 | #include "framework.h"
14 | #include
15 | #include
16 |
17 | template
18 | auto sum(T value)
19 | {
20 | return value;
21 | }
22 |
23 | template
24 | auto sum(T const& value, Args const&... args)
25 | {
26 | return value + sum(args...);
27 | }
28 |
29 |
30 | void check_variadic_tmpl()
31 | {
32 | CHECK(sum(1, 0.5f, 0.25) == 1.75);
33 | }
34 |
35 | struct S
36 | {
37 | int val;
38 | };
39 |
40 | static S StatStruct = { 42 };
41 |
42 | S const& ret_ref()
43 | {
44 | return StatStruct;
45 | }
46 |
47 | template
48 | S const& ret_ref_tmpl()
49 | {
50 | return StatStruct;
51 | }
52 |
53 | template
54 | void check_return_ref_tmpl()
55 | {
56 | auto const& a = ret_ref_tmpl();
57 | CHECK_EQUAL(a.val, 43);
58 | StatStruct.val = 44;
59 | CHECK_EQUAL(a.val, 44);
60 |
61 | CHECK(std::min(2, 3) == 2);
62 | CHECK(std::min(T(2), T(3)) == 2);
63 | }
64 |
65 | void check_return_ref()
66 | {
67 | auto const& a = ret_ref();
68 | CHECK_EQUAL(a.val, 42);
69 | StatStruct.val = 43;
70 | CHECK_EQUAL(a.val, 43);
71 | }
72 |
73 | struct QA
74 | {
75 | struct B
76 | {
77 |
78 | };
79 | };
80 |
81 | template
82 | struct QC;
83 |
84 | template<>
85 | struct QC
86 | {
87 | static const int U = 18;
88 | };
89 |
90 | void check_qualifier()
91 | {
92 | CHECK_EQUAL(QC::U, 18);
93 | }
94 |
95 |
96 | void template_register(TestFrameWork& tf)
97 | {
98 | auto ts = std::make_unique();
99 |
100 | ts->addTestCase(check_variadic_tmpl);
101 |
102 | ts->addTestCase(check_return_ref);
103 |
104 | ts->addTestCase(check_qualifier);
105 |
106 | ts->addTestCase(check_return_ref_tmpl);
107 |
108 | tf.addTestSuite(std::move(ts));
109 | }
--------------------------------------------------------------------------------
/CPP2D/CPP2DTools.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2016 Loïc HAMOT
3 | //
4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 | //
7 |
8 | #pragma warning(push, 0)
9 | #pragma warning(disable: 4548)
10 | #include
11 | #include
12 | #pragma warning(pop)
13 |
14 | using namespace llvm;
15 | using namespace clang;
16 |
17 |
18 | namespace CPP2DTools
19 | {
20 |
21 | const char* getFile(clang::SourceManager const& sourceManager, clang::SourceLocation const& sl)
22 | {
23 | if(sl.isValid() == false)
24 | return "";
25 | clang::FullSourceLoc fsl = FullSourceLoc(sl, sourceManager).getExpansionLoc();
26 | auto& mgr = fsl.getManager();
27 | if(clang::FileEntry const* f = mgr.getFileEntryForID(fsl.getFileID()))
28 | return f->getName().data();
29 | else
30 | return nullptr;
31 | }
32 |
33 |
34 | const char* getFile(clang::SourceManager const& sourceManager, Stmt const* d)
35 | {
36 | return getFile(sourceManager, d->getLocStart());
37 | }
38 |
39 | const char* getFile(clang::SourceManager const& sourceManager, Decl const* d)
40 | {
41 | return getFile(sourceManager, d->getLocation());
42 | }
43 |
44 | bool checkFilename(std::string const& modulename, char const* filepath_str)
45 | {
46 | if(filepath_str == nullptr)
47 | return false;
48 | std::string filepath = filepath_str;
49 | if(filepath.size() < 12)
50 | return false;
51 | else
52 | {
53 | StringRef const filename = llvm::sys::path::filename(filepath);
54 | static char const* exts[] = { ".h", ".hpp", ".cpp", ".cxx", ".c" };
55 | auto iter = std::find_if(std::begin(exts), std::end(exts), [&](auto && ext)
56 | {
57 | return filename == (modulename + ext);
58 | });
59 | return iter != std::end(exts);
60 | }
61 | }
62 |
63 | bool checkFilename(clang::SourceManager const& sourceManager,
64 | std::string const& modulename,
65 | clang::Decl const* d)
66 | {
67 | return checkFilename(modulename, getFile(sourceManager, d));
68 | }
69 |
70 | std::string replaceString(std::string subject,
71 | const std::string& search,
72 | const std::string& replace)
73 | {
74 | size_t pos = 0;
75 | while((pos = subject.find(search, pos)) != std::string::npos)
76 | {
77 | subject.replace(pos, search.length(), replace);
78 | pos += replace.length();
79 | }
80 | return subject;
81 | }
82 |
83 | } //CPP2DTools
--------------------------------------------------------------------------------
/CPP2D/CPP2D.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | I:\C\CPP2D\CPP2D_UT_CPP\main.cpp I:\C\CPP2D\CPP2D_UT_CPP\framework.cpp I:\C\CPP2D\CPP2D_UT_CPP\test.cpp -macro-expr=UT_MACRO_EXPR/nn -macro-expr=CHECK/e -macro-expr=UT_MACRO/eee -macro-stmt=UT_MACRO_STMT -macro-stmt=UT_MACRO_STMT_CLASS/ntne -- -fms-extensions -fms-compatibility
5 | WindowsLocalDebugger
6 | I:\C\CPP2D_UT_D\CPP2D_UT_D
7 |
8 |
9 | I:\C\CPP2D\CPP2D_UT_CPP\main.cpp I:\C\CPP2D\CPP2D_UT_CPP\framework.cpp I:\C\CPP2D\CPP2D_UT_CPP\test.cpp -macro-expr=UT_MACRO_EXPR/nn -macro-expr=CHECK/e -macro-expr=UT_MACRO/eee -macro-stmt=UT_MACRO_STMT -macro-stmt=UT_MACRO_STMT_CLASS/ntne -- -fms-extensions -fms-compatibility
10 | WindowsLocalDebugger
11 | I:\C\CPP2D_UT_D\CPP2D_UT_D
12 |
13 |
14 | C:\C\CPP2D\CPP2D_UT_CPP\comment.cpp C:\C\CPP2D\CPP2D_UT_CPP\framework.cpp C:\C\CPP2D\CPP2D_UT_CPP\main.cpp C:\C\CPP2D\CPP2D_UT_CPP\template_testsuite.cpp C:\C\CPP2D\CPP2D_UT_CPP\stdlib_testsuite.cpp C:\C\CPP2D\CPP2D_UT_CPP\test.cpp -macro-expr=UT_MACRO_EXPR/nn -macro-expr=CHECK/e -macro-expr=CHECK_EQUAL/ee -macro-expr=UT_MACRO/eee -macro-stmt=UT_MACRO_STMT -macro-stmt=UT_MACRO_STMT_CLASS/ntne -- -fms-extensions -fms-compatibility
15 | WindowsLocalDebugger
16 | C:\C\CPP2D_UT_D\source
17 |
18 |
19 | C:\C\CPP2D\CPP2D_UT_CPP\comment.cpp C:\C\CPP2D\CPP2D_UT_CPP\framework.cpp C:\C\CPP2D\CPP2D_UT_CPP\main.cpp C:\C\CPP2D\CPP2D_UT_CPP\template_testsuite.cpp C:\C\CPP2D\CPP2D_UT_CPP\stdlib_testsuite.cpp C:\C\CPP2D\CPP2D_UT_CPP\test.cpp -macro-expr=UT_MACRO_EXPR/nn -macro-expr=CHECK/e -macro-expr=CHECK_EQUAL/ee -macro-expr=UT_MACRO/eee -macro-stmt=UT_MACRO_STMT -macro-stmt=UT_MACRO_STMT_CLASS/ntne -- -fms-extensions -fms-compatibility
20 | WindowsLocalDebugger
21 | C:\C\CPP2D_UT_D\source
22 |
23 |
--------------------------------------------------------------------------------
/CPP2D/CPP2D.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2016 Loïc HAMOT
3 | //
4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 | //
7 |
8 | #pragma warning(push, 0)
9 | #pragma warning(disable: 4548)
10 | #include "clang/Tooling/CommonOptionsParser.h"
11 | #include "clang/Tooling/Tooling.h"
12 | #pragma warning(pop)
13 |
14 | #include
15 | #include
16 |
17 | #include "CPP2DFrontendAction.h"
18 |
19 | using namespace clang::tooling;
20 | using namespace llvm;
21 | using namespace clang;
22 |
23 | cl::OptionCategory cpp2dCategory("cpp2d options");
24 |
25 | cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage);
26 |
27 | cl::list MacroAsExpr(
28 | "macro-expr",
29 | cl::desc("This macro will not be expanded and will be migrated expecting an expression"),
30 | cl::cat(cpp2dCategory),
31 | cl::ZeroOrMore);
32 |
33 | cl::list MacroAsStmt(
34 | "macro-stmt",
35 | cl::desc("This macro will not be expanded and will be migrated expecting statments"),
36 | cl::cat(cpp2dCategory),
37 | cl::ZeroOrMore);
38 |
39 |
40 | //! Used to add fake options to the compiler
41 | //! - For example : -fno-delayed-template-parsing
42 | class CPP2DCompilationDatabase : public clang::tooling::CompilationDatabase
43 | {
44 | clang::tooling::CompilationDatabase& sourceCDB;
45 |
46 | public:
47 | CPP2DCompilationDatabase(clang::tooling::CompilationDatabase& sourceCDB_)
48 | : sourceCDB(sourceCDB_)
49 | {
50 | }
51 |
52 | std::vector getCompileCommands(StringRef FilePath) const override
53 | {
54 | std::vector result = sourceCDB.getCompileCommands(FilePath);
55 | for(CompileCommand& cc : result)
56 | {
57 | cc.CommandLine.push_back("-fno-delayed-template-parsing");
58 | cc.CommandLine.push_back("-ferror-limit=999999");
59 | cc.CommandLine.push_back("-Wno-builtin-macro-redefined");
60 | cc.CommandLine.push_back("-Wno-unused-value");
61 | cc.CommandLine.push_back("-DCPP2D");
62 | }
63 | return result;
64 | }
65 |
66 | std::vector getAllFiles() const override { return sourceCDB.getAllFiles(); }
67 |
68 | std::vector getAllCompileCommands() const override
69 | {
70 | assert(false && "Unexpected call to function CPP2DCompilationDatabase::getAllCompileCommands");
71 | return sourceCDB.getAllCompileCommands();
72 | }
73 | };
74 |
75 | int main(int argc, char const** argv)
76 | {
77 | std::vector argv_vect;
78 | std::copy(argv, argv + static_cast(argc), std::back_inserter(argv_vect));
79 | argv_vect.insert(std::begin(argv_vect) + 1, "-macro-expr=assert/e");
80 | argc = static_cast(argv_vect.size());
81 | CommonOptionsParser OptionsParser(argc, argv_vect.data(), cpp2dCategory);
82 | CPP2DCompilationDatabase compilationDatabase(OptionsParser.getCompilations());
83 | ClangTool Tool(
84 | compilationDatabase,
85 | OptionsParser.getSourcePathList());
86 | return Tool.run(newFrontendActionFactory().get());
87 | }
88 |
--------------------------------------------------------------------------------
/CPP2D/CPP2DPPHandling.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2016 Loïc HAMOT
3 | //
4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 | //
7 | #pragma once
8 |
9 | #pragma warning(push, 0)
10 | #include
11 | #include
12 | #pragma warning(pop)
13 |
14 | #include
15 |
16 | namespace clang
17 | {
18 | class ASTContext;
19 | }
20 |
21 | //! Extract includes and transform macros
22 | class CPP2DPPHandling : public clang::PPCallbacks
23 | {
24 | public:
25 | CPP2DPPHandling(clang::SourceManager& sourceManager,
26 | clang::Preprocessor& pp,
27 | llvm::StringRef inFile);
28 |
29 | //! Fill the list of included files (includes_in_file)
30 | void InclusionDirective(
31 | clang::SourceLocation, //hash_loc,
32 | const clang::Token&, //include_token,
33 | llvm::StringRef file_name,
34 | bool, //is_angled,
35 | clang::CharSourceRange, //filename_range,
36 | const clang::FileEntry*, //file,
37 | llvm::StringRef, //search_path,
38 | llvm::StringRef, //relative_path,
39 | const clang::Module* //imported
40 | ) override;
41 |
42 | //! Transform macro definition by calling TransformMacroExpr or TransformMacroStmt
43 | void MacroDefined(const clang::Token& MacroNameTok, const clang::MacroDirective* MD) override;
44 |
45 | //! Get include list
46 | std::set const& getIncludes() const;
47 | //! Get macros to add in the D code
48 | std::set const& getInsertedBeforeDecls() const;
49 |
50 | private:
51 | //! Add or replace a macro definition in the clang::Preprocessor
52 | void inject_macro(
53 | clang::MacroDirective const* MD,
54 | std::string const& name,
55 | std::string const& new_macro);
56 |
57 | //! Options passed by the user about a specific macro
58 | struct MacroInfo
59 | {
60 | std::string name; //!< Macro name
61 | std::string argType; //!< e:expression n:name t:type
62 | std::string cppReplace; //!< override the macro, in C++ code
63 | };
64 | //! @brief Transform macro definition if tagged by -macro-expr option
65 | //! + Add the D mixin version in the list add_before_decl
66 | void TransformMacroExpr(clang::Token const& MacroNameTok,
67 | clang::MacroDirective const* MD,
68 | CPP2DPPHandling::MacroInfo const& args);
69 | //! @brief Transform macro definition if tagged by -macro-stmt option
70 | //! + Add the D mixin version in the list add_before_decl
71 | void TransformMacroStmt(clang::Token const& MacroNameTok,
72 | clang::MacroDirective const* MD,
73 | CPP2DPPHandling::MacroInfo const& args);
74 |
75 | clang::SourceManager& sourceManager;
76 | clang::Preprocessor& pp;
77 | llvm::StringRef inFile;
78 | llvm::StringRef modulename;
79 | std::map macro_expr;
80 | std::map macro_stmt;
81 |
82 | std::set includes_in_file;
83 | std::set add_before_decl;
84 |
85 | std::string predefines;
86 | std::set new_macros;
87 | };
--------------------------------------------------------------------------------
/CPP2D/CPP2D.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 | {c9043405-1f6f-43e7-9a06-6f2f16c20117}
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | Fichiers sources
26 |
27 |
28 | Fichiers sources
29 |
30 |
31 | Fichiers sources
32 |
33 |
34 | Fichiers sources
35 |
36 |
37 | Fichiers sources
38 |
39 |
40 | Fichiers sources
41 |
42 |
43 | Fichiers sources
44 |
45 |
46 | Fichiers sources
47 |
48 |
49 | Fichiers sources\CustomPrinters
50 |
51 |
52 | Fichiers sources\CustomPrinters
53 |
54 |
55 | Fichiers sources\CustomPrinters
56 |
57 |
58 | Fichiers sources
59 |
60 |
61 |
62 |
63 | Fichiers d%27en-tête
64 |
65 |
66 | Fichiers d%27en-tête
67 |
68 |
69 | Fichiers d%27en-tête
70 |
71 |
72 | Fichiers d%27en-tête
73 |
74 |
75 | Fichiers d%27en-tête
76 |
77 |
78 | Fichiers d%27en-tête
79 |
80 |
81 | Fichiers d%27en-tête
82 |
83 |
84 | Fichiers d%27en-tête
85 |
86 |
87 | Fichiers d%27en-tête
88 |
89 |
90 |
--------------------------------------------------------------------------------
/cpp_std.d:
--------------------------------------------------------------------------------
1 | import std.container.rbtree;
2 | import std.container.array;
3 | import std.typecons;
4 | import std.stdio;
5 | import std.conv;
6 |
7 | //****************************** map *****************************************
8 | alias pair(K, V) = Tuple!(K, "key", V, "value");
9 | alias map(K, V, alias less = "a[0] < b[0]") = RedBlackTree!(pair!(K, V), less, false);
10 | alias multimap(K, V, alias less = "a < b") = RedBlackTree!(pair!(K, V), less, true);
11 |
12 |
13 | //************************** boost::serialization ****************************
14 |
15 | template class_version(T)
16 | {
17 | immutable(int) class_version = 0;
18 | }
19 |
20 | template class_version(T: double)
21 | {
22 | immutable(int) class_version = 6;
23 | }
24 |
25 | //************************** std::vector **************************************
26 |
27 | struct allocator(T){}
28 |
29 | alias vector(T, A = allocator!T) = Array!T;
30 |
31 | //************************** std::set **************************************
32 |
33 | struct set(T, alias less = "a < b", A = allocator!T)
34 | {
35 | RedBlackTree!(T, less) data = new RedBlackTree!(T, less);
36 |
37 | auto length() {return data.length;}
38 |
39 | this()(auto this)
40 | {
41 | data = data.dup;
42 | }
43 | }
44 |
45 |
46 | //************************** unordered_map **************************************
47 |
48 | struct unordered_map(K, V)
49 | {
50 | V[K] ptr;
51 | }
52 |
53 | //************************* cpp-like lambda helper ****************************
54 |
55 | struct toFunctor(alias F)
56 | {
57 | this(int){}
58 | auto ref opCall(Args...)(auto ref Args args)
59 | {
60 | return F(args);
61 | }
62 | }
63 |
64 | //************************* default ctor helper ****************************
65 |
66 | struct DefaultCtorArgType{};
67 | static DefaultCtorArgType DefaultCtorArg;
68 |
69 | // ********************** std::move ****************************************
70 |
71 | auto move(T)(auto ref T ptr) if(is(T == struct))
72 | {
73 | auto newPtr = ptr;
74 | ptr = T.init;
75 | return newPtr;
76 | }
77 |
78 | auto move(T)(auto ref T ptr) if(is(T == class))
79 | {
80 | auto newPtr = ptr;
81 | ptr = null;
82 | return newPtr;
83 | }
84 |
85 | // ******************************** *********************************
86 |
87 | auto make_pair(A, B)(auto ref A a, auto ref B b)
88 | {
89 | //return Tuple!(A, "key", B, "value")(a, b);
90 | return pair!(A, B)(a, b);
91 | }
92 |
93 | // ******************************* other **************************************
94 |
95 | struct Ref(T)
96 | {
97 | T* ptr;
98 |
99 | this(U)(auto ref U other)
100 | {
101 | ptr = &other;
102 | }
103 |
104 | ref T opCast()
105 | {
106 | return *ptr;
107 | }
108 |
109 | bool opBinary(string op, U)(auto ref U other)
110 | {
111 | return mixin("*ptr" ~ op ~ "other");
112 | }
113 |
114 | bool opBinary(string op, U = Ref!U)(auto ref Ref!U other)
115 | {
116 | return mixin("*ptr" ~ op ~ "*other.ptr");
117 | }
118 |
119 | alias ptr this;
120 | }
121 |
122 | auto makeRef(T)(ref auto T val)
123 | {
124 | return Ref!T(val);
125 | }
126 |
127 | //************************* iostream ******************************************
128 |
129 | struct OStream
130 | {
131 | File file;
132 |
133 | ref OStream opBinary(string op = "<<", T)(auto ref T arg)
134 | {
135 | file.write(arg);
136 | return this;
137 | }
138 | }
139 |
140 |
141 | enum ios_base
142 | {
143 | in_ = 1,
144 | out_ = 2
145 | }
146 |
147 | struct Stringstream
148 | {
149 | string data;
150 |
151 | this(ios_base mode){}
152 |
153 | this(string str, int mode = 3){data = str;}
154 |
155 | ref Stringstream opBinary(string op = "<<", T)(auto ref T arg)
156 | {
157 | data ~= to!string(arg);
158 | return this;
159 | }
160 |
161 | string str()
162 | {
163 | return data;
164 | }
165 | }
166 |
167 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CPP2D
2 | (Clang based) C++ to D language converter
3 |
4 | ## Objective
5 | The goal is to take a C++ project and convert all the source code to D language.
6 |
7 | ## License
8 |
9 | Copyright Loïc HAMOT, 2016
10 |
11 | Distributed under the Boost Software License, Version 1.0.
12 |
13 | See ./LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt
14 |
15 | ## Continuous integration
16 |
17 | * Ubuntu
18 |
19 | [](https://travis-ci.org/lhamot/CPP2D)
20 |
21 | * Windows
22 |
23 | [](https://ci.appveyor.com/project/lhamot/cpp2d)
24 |
25 | ## Already handled C++ features
26 |
27 | Majority of C++ code is already convertible to D.
28 |
29 | A not exhaustive list:
30 | * class
31 | * constructor/destructor
32 | * virtual
33 | * abstract
34 | * override
35 | * initialization list
36 | * call base constructor
37 | * Operator overloading
38 | * member
39 | * free
40 | * left or right
41 | * Template
42 | * function
43 | * function specialization
44 | * class
45 | * class/struct specialization
46 | * class/struct partial specialization
47 | * arrays
48 | * static
49 | * dynamic
50 | * std::vector (partially)
51 | * std::array (partially)
52 | * preprocessor
53 | * function-like macro
54 | * declaration-like macro
55 | * simple #ifdef/else/endif
56 |
57 | Some samples here : https://github.com/lhamot/CPP2D/wiki/Conversion-samples
58 |
59 | ## Requirements
60 | * cmake >= 2.6
61 | * Tested with **gcc** 4.8.4 (**Ubuntu** 14.04.3), **Visual Studio** 2015 (**Windows** 7 & 10), and **clang** (**macOS** 10.14)
62 | * Tested with **LLVM/clang** **6.0.1**
63 |
64 | ## How to install it?
65 | 1. Install **clang** : http://clang.llvm.org/get_started.html
66 | 2. Check out **CPP2D** from : https://github.com/lhamot/CPP2D.git
67 | 3. Run **cmake** in the root directory of **CPP2D**
68 | 1. Set the build type if needed (Debug;Release;MinSizeRel;RelWithDebInfo)
69 | 2. Set the path to **LLVM** using **CMAKE_PREFIX_PATH**.
70 | 4. Generate
71 | 4. Run **make**
72 |
73 | ## How to use it?
74 | **Be aware than this project is far to be finished. Do not expect a fully working D project immediately. That you can expect is a great help to the conversion of your project, doing all the simple repetitive job, which is not so bad.**
75 |
76 | CPP2D work like any clang tools. This could help you:
77 | - http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html
78 |
79 | There is two way to use CPP2D:
80 |
81 | ### 1. Without compilation database
82 | 1. Go to the destination directory (D project)
83 | 2. Call ```CPP2D.exe [options] [... ] -- [compiler options]```
84 | - The double dashes are needed to inform cpp2d you don't need a compilation database
85 | - `````` are C++ source files
86 | - [compiler options] are options forwarded to the compiler, like includes path, preprocessor definitions and so on.
87 | - [options] can be **-macro-stmt** and **-macro-exec** which are for macro handling
88 |
89 | ### 2. With compilation database
90 | It seems to be impossible to generate a compilation database under windows...
91 |
92 | If you are not under windows, and you are using cmake to compile your project:
93 | - Add this code in your(s) CMakeFiles.txt
94 | ```cmake
95 | if(CMAKE_EXPORT_COMPILE_COMMANDS STREQUAL "ON")
96 | include_directories(${LLVM_PATH}/lib/clang/3.9.0/include)
97 | endif()
98 | ```
99 | ```sh
100 | # Go to project build directory
101 | $ cd project/build/directory
102 | # Run cmake, asking it to generate a compilation database
103 | $ cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON path/to/project/sources
104 | # You will obtain a compilation database
105 | # Link it to the source project
106 | $ ln -s $PWD/compile_commands.json path/to/project/source/
107 | # Convert files, calling cpp2d
108 | $ cd path/to/project/source
109 | $ project/build/directory/CPP2D/cpp2d source1.cpp source2.cpp source3.cpp
110 | # You will find D files in the project/build/directory
111 | # You also need to copy the cpp_std.d file to your D source directory
112 | $ cp project/build/directory/CPP2D/cpp_std.d dproject/source
113 | ```
114 |
115 | Need for more documentation? You can search here :
116 | - http://eli.thegreenplace.net/2014/05/21/compilation-databases-for-clang-based-tools
117 |
118 | ## Future of the project?
119 | Small C++ project are almost fully convertible to **D**, but many things have to be done for the bigger ones.
120 |
121 | ### Main missing features are:
122 | * Better macro handling
123 | * Namespace/Module handling
124 | * External library handling, and specifically the stdlib
125 | * Variadic template
126 | * Not tried to do yet
127 | * Better conservation of comments
128 | * Porting constness
129 | * Hard because **D** containers seem to not be const correct
130 | * Handling const ref function argument
131 | * Hard because, unlike in **C++**, in **D** we can't pass a rvalue to a const ref parameter
132 |
133 | ### Other possible enhancements
134 |
135 | * CMake : Create a cmake to compile a project linked to **LLVM**/**clang** in a cross-platform way seems to be not straightforward. If you can enhance my CMakeLists, please do it!
136 | * Clang integration : Maybe there is a better way to integrate **CPP2D** with **clang**, like make it a real clang tool, in clang/tools, or clang/tools/extra.
137 |
138 | ## Want to try?
139 | - http://nogane.net/cpp2d
140 |
141 | ## Want to help?
142 | I would be happy to get some help on this project. If you are interested, do not hesitate to :
143 | - Reach us on the mailing list: https://groups.google.com/forum/#!forum/cpp2d
144 | - Contact me at loic.hamot@yahoo.fr
145 | - Or just checkout and enjoy ;)
146 |
--------------------------------------------------------------------------------
/CPP2D/MatchContainer.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2016 Loïc HAMOT
3 | //
4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 | //
7 | #pragma once
8 |
9 | #include
10 | #include
11 |
12 | #pragma warning(push, 0)
13 | #pragma warning(disable: 4265)
14 | #include
15 | #pragma warning(pop)
16 |
17 | class DPrinter;
18 |
19 | namespace clang
20 | {
21 | class Stmt;
22 | class Decl;
23 | class Type;
24 | }
25 |
26 | //! Store matchers and receive the callbacks when the are find
27 | //!
28 | //! Find some paterns in the source which are hard to finc while parsing
29 | //! Permit the excecution of custom matcher and custom printer in order to
30 | //! translate external library usages
31 | class MatchContainer : public clang::ast_matchers::MatchFinder::MatchCallback
32 | {
33 | public:
34 | //! Generate all ASTMatchers
35 | clang::ast_matchers::MatchFinder getMatcher();
36 |
37 | //! Hash traits (std::hash) of this record. [recordname] -> method
38 | std::unordered_map hashTraits;
39 | //! @brief Free operators (left) of this record. [recordname] -> operator
40 | //! @remark The record appear on the left side
41 | std::unordered_multimap freeOperator;
42 | //! @brief Free operators (right) of this record. [recordname] -> operator
43 | //! @remark The record appear on the right side
44 | std::unordered_multimap freeOperatorRight;
45 |
46 | typedef std::function StmtPrinter; //!< Custom Stmt printer
47 | typedef std::function DeclPrinter; //!< Custom Decl printer
48 | typedef std::function TypePrinter; //!< Custom Type printer
49 |
50 |
51 | StmtPrinter getPrinter(clang::Stmt const*) const; //!< Get the custom printer for this statment
52 | DeclPrinter getPrinter(clang::Decl const*) const; //!< Get the custom printer for this decl
53 | TypePrinter getPrinter(clang::Type const*) const; //!< Get the custom printer for this type
54 |
55 | //! Get the nth template argument of type tmplType
56 | static clang::TemplateArgument const* getTemplateTypeArgument(
57 | clang::Expr const* tmplType,
58 | size_t nth);
59 |
60 | //! Change the name of a C++ type
61 | void rewriteType(
62 | clang::ast_matchers::MatchFinder& finder,
63 | std::string const& oldName, //!< Old type name in C++ (no regex)
64 | std::string const& newName, //!< New type name in D
65 | std::string const& newImport //!< import to get this type in **D**
66 | );
67 |
68 | //! Custom print a method call
69 | void methodPrinter(
70 | std::string const& className, //!< Class of this method (no regex)
71 | std::string const& methodName, //!< Metod name (no regex)
72 | StmtPrinter const& printer //!< Custom printer
73 | );
74 |
75 | //! Custom print a global function call
76 | void globalFuncPrinter(
77 | std::string const& funcName, //!< Function name (regex)
78 | StmtPrinter const& printer //!< Custom printer
79 | );
80 |
81 | //! Custom print a template type
82 | void tmplTypePrinter(
83 | std::string const& name, //!< Type name (regex)
84 | DeclPrinter const& printMapDecl //!< Custom printer
85 | );
86 |
87 | //! Custom print a member call
88 | void memberPrinter(
89 | clang::ast_matchers::MatchFinder& finder,
90 | std::string const& regexpr, //!< Fully qualified member name (regex)
91 | StmtPrinter const& printer //!< Custom printer
92 | );
93 |
94 | //! Custom print an operator call
95 | void operatorCallPrinter(
96 | clang::ast_matchers::MatchFinder& finder,
97 | std::string const& classRegexpr, //!< class name (regex)
98 | std::string const& op, //!< operator (like "==")
99 | StmtPrinter const& printer //!< Custom printer
100 | );
101 |
102 | //! Port a C standard library function to D
103 | void cFuncPrinter(
104 | std::string const& lib, //!< include name
105 | std::string const& func //!< function name (no regex)
106 | );
107 |
108 | //! clang::Stmt which match. [clang::Stmt] -> matchername
109 | std::unordered_multimap stmtTags;
110 | //! clang::Stmt which match. [clang::Decl] -> matchername
111 | std::unordered_multimap declTags;
112 | //! clang::Stmt which match. [clang::Type] -> matchername
113 | std::unordered_multimap typeTags;
114 |
115 | typedef std::unordered_map ClassPrinter;
116 | //! How to print a call to this method. methodPrinters[method_name][class_name] => printer
117 | std::unordered_map methodPrinters;
118 |
119 | std::unordered_map globalFuncPrinters;
120 |
121 | std::unordered_map customTypePrinters;
122 |
123 | //! Custom printer for clang::Type matchers. [matchername] -> printer
124 | std::unordered_map typePrinters;
125 | //! Custom printer for clang::Stmt matchers. [matchername] -> printer
126 | std::unordered_map stmtPrinters;
127 | //! Custom printer for clang::Decl matchers. [matchername] -> printer
128 | std::unordered_map declPrinters;
129 |
130 | //! Function excecuted when a clang::Stmt match. [matchername] -> function
131 | std::unordered_map> onStmtMatch;
132 | //! Function excecuted when a clang::Decl match. [matchername] -> function
133 | std::unordered_map> onDeclMatch;
134 | //! Function excecuted when a clang::Type match. [matchername] -> function
135 | std::unordered_map> onTypeMatch;
136 |
137 | private:
138 | //! When match is find, excecute on*Match or add the node to *Tags
139 | void run(clang::ast_matchers::MatchFinder::MatchResult const& Result) override;
140 | };
--------------------------------------------------------------------------------
/CPP2D_UT_CPP/CPP2D_UT_CPP.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | {1981F516-28E6-4905-B4E8-BD38982CBCE8}
23 | Win32Proj
24 | CPP2D_UT_CPP
25 | 8.1
26 |
27 |
28 |
29 | Application
30 | true
31 | v140
32 | Unicode
33 |
34 |
35 | Application
36 | false
37 | v140
38 | true
39 | Unicode
40 |
41 |
42 | Application
43 | true
44 | v140
45 | Unicode
46 |
47 |
48 | Application
49 | false
50 | v140
51 | true
52 | Unicode
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | true
74 |
75 |
76 | true
77 |
78 |
79 | false
80 |
81 |
82 | false
83 |
84 |
85 |
86 |
87 |
88 | Level3
89 | Disabled
90 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
91 | 4996;4702;4714;
92 |
93 |
94 | Console
95 | true
96 |
97 |
98 |
99 |
100 |
101 |
102 | Level3
103 | Disabled
104 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
105 | 4996;4702;4714;
106 |
107 |
108 | Console
109 | true
110 |
111 |
112 |
113 |
114 | Level3
115 |
116 |
117 | MaxSpeed
118 | true
119 | true
120 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
121 | 4996;4702;4714;
122 |
123 |
124 | Console
125 | true
126 | true
127 | true
128 |
129 |
130 |
131 |
132 | Level3
133 |
134 |
135 | MaxSpeed
136 | true
137 | true
138 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
139 | 4996;4702;4714;
140 |
141 |
142 | Console
143 | true
144 | true
145 | true
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
--------------------------------------------------------------------------------
/CPP2D_UT_CPP/stdlib_testsuite.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2016 Loïc HAMOT
3 | //
4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 | //
7 | #include
8 | #include
9 | #include