Skip to content

Commit

Permalink
Merge pull request #3 from ahueck/devel
Browse files Browse the repository at this point in the history
Create first major version based on improvements of branch devel
  • Loading branch information
ahueck committed Jul 17, 2015
2 parents 992fdce + 5709d0b commit f0620b7
Show file tree
Hide file tree
Showing 123 changed files with 2,660 additions and 2,704 deletions.
55 changes: 55 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
Language: Cpp
# BasedOnStyle: Google
AccessModifierOffset: -1
ConstructorInitializerIndentWidth: 4
AlignEscapedNewlinesLeft: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AlwaysBreakTemplateDeclarations: true
AlwaysBreakBeforeMultilineStrings: true
BreakBeforeBinaryOperators: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BinPackParameters: true
ColumnLimit: 120
BreakConstructorInitializersBeforeComma: true
DerivePointerBinding: true
ExperimentalAutoDetectBinPacking: false
IndentCaseLabels: true
MaxEmptyLinesToKeep: 1
KeepEmptyLinesAtTheStartOfBlocks: false
NamespaceIndentation: None
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakString: 1000
PenaltyBreakFirstLessLess: 120
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerBindsToType: true
SpacesBeforeTrailingComments: 2
Cpp11BracedListStyle: true
Standard: Auto
IndentWidth: 2
TabWidth: 4
UseTab: Never
BreakBeforeBraces: Attach
MaxEmptyLinesToKeep: 1
IndentFunctionDeclarationAfterType: true
SpacesInParentheses: false
SpacesInAngles: false
SpaceInEmptyParentheses: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: true
SpaceBeforeAssignmentOperators: true
ContinuationIndentWidth: 4
CommentPragmas: '^ IWYU pragma:'
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
SpaceBeforeParens: ControlStatements
...

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@

# Build folder
build/*

# bin folder
bin/*
30 changes: 29 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,30 @@
language: C++

compiler:
- gcc

before_install:
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
- wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | sudo apt-key add -
- echo "deb http://llvm.org/apt/precise/ llvm-toolchain-precise-3.5 main" | sudo tee -a /etc/apt/sources.list
- echo "deb-src http://llvm.org/apt/precise/ llvm-toolchain-precise-3.5 main" | sudo tee -a /etc/apt/sources.list
- sudo apt-get update -qq

install:
- sudo apt-get install gcc-4.8 g++-4.8
- sudo apt-get install zlib1g-dev libxml2-dev libedit-dev clang-3.5 libclang-common-3.5-dev libclang-3.5-dev libclang1-3.5 libllvm-3.5-ocaml-dev libllvm3.5 llvm-3.5 llvm-3.5-dev llvm-3.5-runtime

before_script:
- mkdir build
- cd build

script:
- 'echo "successfull build"'
- cmake -DCMAKE_CXX_COMPILER=g++-4.8 -DMAKE_TEST=TRUE -DLOG_LEVEL=0 ..
- make
- cd .. && chmod +x unit_tests.sh
- ./unit_tests.sh

branches:
only:
- master
- devel
74 changes: 17 additions & 57 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,84 +11,44 @@ include_directories(${PROJECT_SOURCE_DIR}/include)

set(LSOURCES
src/core/Application.cpp
src/core/AbstractModule.cpp
src/core/ModuleContext.cpp
src/core/ASTMatcherModule.cpp
src/core/module/AbstractModule.cpp
src/core/module/ModuleContext.cpp
src/core/module/ASTMatcherModule.cpp
src/core/AbstractModuleConsumer.cpp
src/core/AbstractFactory.cpp
src/core/ConsoleReporter.cpp

src/core/JSONConfiguration.cpp

src/core/configuration/JSONConfiguration.cpp
include/external/IncludeDirectives.cpp
include/external/ReplacementHandling.cpp

src/core/TransformationHandler.cpp
src/core/IssueHandler.cpp
src/core/issue/IssueHandler.cpp
src/core/reporting/ConsoleReporter.cpp
src/core/reporting/CSVReporter.cpp
src/core/transformation/TransformationHandler.cpp
)

set(LHEADERS
include/core/Application.h
include/core/AbstractModule.h
include/core/ModuleContext.h
include/core/AbstractModuleConsumer.h
include/core/ASTVisitorModule.h
include/core/ASTMatcherModule.h
include/core/AbstractFactory.h
include/core/Configuration.h
include/core/IFactory.h
include/core/Module.h
include/core/Issue.h
include/core/IssueReporter.h
include/core/ConsoleReporter.h

include/core/JSONConfiguration.h
include/core/TransformationUtil.h

include/core/TransformationHandler.h
include/core/IssueHandler.h
)

set(PSOURCES
src/AnalyzerFactory.cpp
src/ModuleConsumer.cpp

src/modules/ImplicitCondition.cpp
src/modules/ImplicitConditionMatcher.cpp
src/modules/ImplicitCastVisitor.cpp
src/modules/FieldDeclCollector.cpp
src/modules/UnionMatcher.cpp
src/modules/ExplicitCast.cpp
src/modules/ExplicitCastVisitor.cpp
src/modules/ConditionalAssgnMatcher.cpp
src/modules/ImplicitConversion.cpp
src/modules/ExplicitConstructor.cpp
src/modules/AllImplicitConversion.cpp
src/modules/GlobalScope.cpp
)

set(PHEADERS
include/AnalyzerFactory.h
include/ModuleConsumer.h

include/modules/ImplicitCondition.h
include/modules/ImplicitConditionMatcher.h
include/modules/ImplicitCastVisitor.h
include/modules/FieldDeclCollector.h
include/modules/UnionMatcher.h
include/modules/ExplicitCast.h
include/modules/ExplicitCastVisitor.h
include/modules/ConditionalAssgnMatcher.h
include/modules/ImplicitConversion.h
include/modules/ExplicitConstructor.h
include/modules/AllImplicitConversion.h
)

add_library(libopov ${LSOURCES} ${LHEADERS})
target_link_libraries(libopov "${TOOLCHAIN_LINK_LIB}")
add_library(stdimpl ${PSOURCES} ${PHEADERS})
add_library(libopov ${LSOURCES})
target_link_libraries(libopov ${TOOLCHAIN_LINK_LIB})
add_library(stdimpl ${PSOURCES})
target_link_libraries(stdimpl libopov)

add_executable(find-type${EXE_SUFFIX} src/main.cpp src/OpOvApp.cpp)
target_link_libraries(find-type${EXE_SUFFIX} "${TOOLCHAIN_LINK_LIB}" libopov stdimpl)
target_link_libraries(find-type${EXE_SUFFIX} stdimpl)

add_subdirectory(test)
if(MAKE_TEST)
message(STATUS "Requested generation of tests.")
add_subdirectory(test)
endif()
74 changes: 53 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,79 @@
## opovlint
[![Build Status](https://travis-ci.org/ahueck/opovlint.svg?branch=master)](https://travis-ci.org/ahueck/opovlint)

OO-Lint (opovlint)
===========

This is a project for linting operator overloads in C++. It is implemented as
a Clang-tool.
a Clang tool.


Disclaimer
------------

## Disclaimer
The status of this software is alpha level.

The status of this software is pre-alpha level and not ready for public usage.

## License
License
------------

Distributed under the MIT License. For details refer to file "LICENSE"
Distributed under the MIT License. For details refer to the [LICENSE file](LICENSE)


## Motivation
Motivation
------------

Operator Overloading allows for the semantic augmentation of existing codes
The basic arithmetic type in a code is replaced by a user-defined type
Type change (in theory this just works):
typedef scalar double -> typedef scalar userdef_double
Operator Overloading allows for the semantic augmentation of existing codes.
The basic arithmetic type in a code is replaced by a user-defined type.

*Type change* (in theory this just works):
- typedef **double** scalar; -> typedef **userdef_double** scalar;

However, several coding patterns are not compatible with user-defined classes
and result in compile time errors
- Implicit Conversions
“At most one user-defined conversion [...] is implicitly
applied to a single value.” – §12.3-4, C++03 Standard
- “At most one user-defined conversion [...] is implicitly
applied to a single value.” – [§12.3-4, C++03 Standard]
- Subset:
- Boolean Conversions: i.e., conditional statements
- Unions
Incompatible with complex data classes (§9.5-1, C++03 Standard)
- Incompatible with complex data classes [§9.5-1, C++03 Standard]
- Explicit Conversions
Cast operation from a user-defined type to a built-in often not possible
- Cast operation from a user-defined type to a built-in is often not possible
- etc.


## Goal
Goal
------------

Provide developers of (numerical) codes with static code analysis
o avoid problematic coding patterns
to avoid problematic coding patterns

For legacy numerical codes:
- Flag potential problematic code locations
- Ideally autocorrect them
- Flag potential problematic code locations
- Ideally autocorrect them


Installation
------------

The tool is developed and tested on Linux.
For Ubuntu/Dabian, refer to the [Travis CI file](.travis.yml) for guidance.

### Prerequisites

1. C++ Compiler with C++11 support (gcc version >= 4.8)
2. Cmake (version >=2.8)
3. Clang/LLVM in Version 3.5.0. Newer versions might not work due to the changing API.
The build system relies on the presence of the **llvm-config**(-3.5 -3.6 -3.7) binary.
If it can't be found, set the cmake variable ${LLVM_ROOT_DIR} to point to the
respective bin/ folder where llvm-config is located.

### Build the OO-Lint tool

In the root folder of the project:

## Installation
mkdir build && cd build/
cmake -DCMAKE_BUILD_TYPE=Release ..
make

TBD
The binary should be created in the project bin/ folder.
Loading

0 comments on commit f0620b7

Please sign in to comment.