From ab1dbce5a4e74adc589d518af5b924e4d02ba4f3 Mon Sep 17 00:00:00 2001 From: Stephane Chauveau Date: Thu, 8 Feb 2018 14:40:07 +0100 Subject: [PATCH] [flang] after clang-format Original-commit: flang-compiler/f18@7e464a7c3315b9dfc6db2861145d7e3455652548 Reviewed-on: https://github.com/flang-compiler/f18/pull/6 Tree-same-pre-rewrite: false --- flang/.gitignore | 1 + flang/CMakeLists.txt | 508 ++++++++++++++++++++++++++++++-- flang/include/flang/Basic/LLVM.h | 92 +++--- flang/include/flang/Basic/Version.h | 80 ++--- flang/include/flang/Sema/Scope.h | 47 +++ flang/include/flang/Sema/Sema.h | 37 ++- flang/lib/CMakeLists.txt | 1 + flang/lib/Sema/CMakeLists.txt | 5 +- flang/lib/Sema/Scope.cpp | 30 ++ flang/lib/Sema/Sema.cpp | 48 +++ flang/tools/flang-info/CMakeLists.txt | 1 + flang/tools/flang-info/FlangInfo.cpp | 11 +- flang/utils/TableGen/TableGenBackends.h | 16 +- 13 files changed, 734 insertions(+), 143 deletions(-) diff --git a/flang/.gitignore b/flang/.gitignore index 4c1751e..974d37a 100644 --- a/flang/.gitignore +++ b/flang/.gitignore @@ -8,3 +8,4 @@ CMakeCache.txt CMakeFiles/* cmake_install.cmake formatted +CLANG diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt index 13fbff4..adf5ecf 100644 --- a/flang/CMakeLists.txt +++ b/flang/CMakeLists.txt @@ -1,23 +1,485 @@ -cmake_minimum_required(VERSION 3.9.0) - -set(GCC /home/sw/thirdparty/gcc/gcc-7.3.0/linux86-64/redhat) -set(CMAKE_CXX_COMPILER "${GCC}/bin/g++") -set(CMAKE_INSTALL_RPATH "${GCC}/lib64") -set(CMAKE_BUILD_WITH_INSTALL_RPATH true) - -project(f18) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++17") - -set(SOURCES - tools/f18/f18.cc - lib/parser/char-buffer.cc - lib/parser/idioms.cc - lib/parser/message.cc - lib/parser/parse-tree.cc - lib/parser/position.cc - lib/parser/preprocessor.cc - lib/parser/prescan.cc - lib/parser/source.cc -) -add_executable(f18 ${SOURCES}) -add_executable(type-test lib/semantics/type.cc lib/semantics/attr.cc lib/parser/idioms.cc) +cmake_minimum_required(VERSION 3.4.3) + +# If we are not building as a part of LLVM, build FLANG as an +# standalone project, using LLVM as an external library: +if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) + project(FLANG) + + # Rely on llvm-config. + set(CONFIG_OUTPUT) + find_program(LLVM_CONFIG "llvm-config") + if(LLVM_CONFIG) + message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}") + set(CONFIG_COMMAND ${LLVM_CONFIG} + "--assertion-mode" + "--bindir" + "--libdir" + "--includedir" + "--prefix" + "--src-root" + "--cmakedir") + execute_process( + COMMAND ${CONFIG_COMMAND} + RESULT_VARIABLE HAD_ERROR + OUTPUT_VARIABLE CONFIG_OUTPUT + ) + if(NOT HAD_ERROR) + string(REGEX REPLACE + "[ \t]*[\r\n]+[ \t]*" ";" + CONFIG_OUTPUT ${CONFIG_OUTPUT}) + else() + string(REPLACE ";" " " CONFIG_COMMAND_STR "${CONFIG_COMMAND}") + message(STATUS "${CONFIG_COMMAND_STR}") + message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}") + endif() + else() + message(FATAL_ERROR "llvm-config not found -- ${LLVM_CONFIG}") + endif() + + list(GET CONFIG_OUTPUT 0 ENABLE_ASSERTIONS) + list(GET CONFIG_OUTPUT 1 TOOLS_BINARY_DIR) + list(GET CONFIG_OUTPUT 2 LIBRARY_DIR) + list(GET CONFIG_OUTPUT 3 INCLUDE_DIR) + list(GET CONFIG_OUTPUT 4 LLVM_OBJ_ROOT) + list(GET CONFIG_OUTPUT 5 MAIN_SRC_DIR) + list(GET CONFIG_OUTPUT 6 LLVM_CONFIG_CMAKE_PATH) + + if(NOT MSVC_IDE) + set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS} + CACHE BOOL "Enable assertions") + # Assertions should follow llvm-config's. + mark_as_advanced(LLVM_ENABLE_ASSERTIONS) + endif() + + set(LLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to llvm/bin") + set(LLVM_LIBRARY_DIR ${LIBRARY_DIR} CACHE PATH "Path to llvm/lib") + set(LLVM_MAIN_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Path to llvm/include") + set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree") + set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree") + + # Normalize LLVM_CMAKE_PATH. --cmakedir might contain backslashes. + # CMake assumes slashes as PATH. + file(TO_CMAKE_PATH ${LLVM_CONFIG_CMAKE_PATH} LLVM_CMAKE_PATH) + + find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR} + NO_DEFAULT_PATH) + + set(LLVMCONFIG_FILE "${LLVM_CMAKE_PATH}/LLVMConfig.cmake") + if(EXISTS ${LLVMCONFIG_FILE}) + list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}") + include(${LLVMCONFIG_FILE}) + else() + message(FATAL_ERROR "Not found: ${LLVMCONFIG_FILE}") + endif() + + # They are used as destination of target generators. + set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin) + set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX}) + if(WIN32 OR CYGWIN) + # DLL platform -- put DLLs into bin. + set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) + else() + set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) + endif() + + option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON) + option(LLVM_INSTALL_TOOLCHAIN_ONLY + "Only include toolchain files in the 'install' target." OFF) + + option(LLVM_FORCE_USE_OLD_HOST_TOOLCHAIN + "Set to ON to force using an old, unsupported host toolchain." OFF) + option(FLANG_ENABLE_BOOTSTRAP "Generate the flang bootstrap target" OFF) + + include(AddLLVM) + include(TableGen) + include(HandleLLVMOptions) + include(VersionFromVCS) + + set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}") + + if (NOT DEFINED LLVM_INCLUDE_TESTS) + set(LLVM_INCLUDE_TESTS ON) + endif() + + include_directories("${LLVM_BINARY_DIR}/include" "${LLVM_MAIN_INCLUDE_DIR}") + link_directories("${LLVM_LIBRARY_DIR}") + + set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) + set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} ) + set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} ) + + if(LLVM_INCLUDE_TESTS) + set(Python_ADDITIONAL_VERSIONS 2.7) + include(FindPythonInterp) + if(NOT PYTHONINTERP_FOUND) + message(FATAL_ERROR +"Unable to find Python interpreter, required for builds and testing. + +Please install Python or specify the PYTHON_EXECUTABLE CMake variable.") + endif() + + if( ${PYTHON_VERSION_STRING} VERSION_LESS 2.7 ) + message(FATAL_ERROR "Python 2.7 or newer is required") + endif() + + # Check prebuilt llvm/utils. + if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX} + AND EXISTS ${LLVM_TOOLS_BINARY_DIR}/count${CMAKE_EXECUTABLE_SUFFIX} + AND EXISTS ${LLVM_TOOLS_BINARY_DIR}/not${CMAKE_EXECUTABLE_SUFFIX}) + set(LLVM_UTILS_PROVIDED ON) + endif() + + if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py) + # Note: path not really used, except for checking if lit was found + set(LLVM_LIT ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py) + if(NOT LLVM_UTILS_PROVIDED) + add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/FileCheck utils/FileCheck) + add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/count utils/count) + add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/not utils/not) + set(LLVM_UTILS_PROVIDED ON) + set(FLANG_TEST_DEPS FileCheck count not) + endif() + set(UNITTEST_DIR ${LLVM_MAIN_SRC_DIR}/utils/unittest) + if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h + AND NOT EXISTS ${LLVM_LIBRARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX} + AND EXISTS ${UNITTEST_DIR}/CMakeLists.txt) + add_subdirectory(${UNITTEST_DIR} utils/unittest) + endif() + else() + # Seek installed Lit. + find_program(LLVM_LIT + NAMES llvm-lit lit.py lit + PATHS "${LLVM_MAIN_SRC_DIR}/utils/lit" + DOC "Path to lit.py") + endif() + + if(LLVM_LIT) + # Define the default arguments to use with 'lit', and an option for the user + # to override. + set(LIT_ARGS_DEFAULT "-sv") + if (MSVC OR XCODE) + set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar") + endif() + set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit") + + # On Win32 hosts, provide an option to specify the path to the GnuWin32 tools. + if( WIN32 AND NOT CYGWIN ) + set(LLVM_LIT_TOOLS_DIR "" CACHE PATH "Path to GnuWin32 tools") + endif() + else() + set(LLVM_INCLUDE_TESTS OFF) + endif() + endif() + + set( FLANG_BUILT_STANDALONE 1 ) + set(BACKEND_PACKAGE_STRING "LLVM ${LLVM_PACKAGE_VERSION}") +else() + set(BACKEND_PACKAGE_STRING "${PACKAGE_STRING}") +endif() + +# Make sure that our source directory is on the current cmake module path so that +# we can include cmake files from this directory. +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") + +find_package(LibXml2 2.5.3 QUIET) +if (LIBXML2_FOUND) + set(FLANG_HAVE_LIBXML 1) +endif() + +#!! find_package(Z3 4.5) + +include(CheckIncludeFile) +check_include_file(sys/resource.h FLANG_HAVE_RLIMITS) + +set(FLANG_RESOURCE_DIR "" CACHE STRING + "Relative directory from the FLANG binary to its resource files.") + +set(C_INCLUDE_DIRS "" CACHE STRING + "Colon separated list of directories flang will search for headers.") + +set(GCC_INSTALL_PREFIX "" CACHE PATH "Directory where gcc is installed." ) +set(DEFAULT_SYSROOT "" CACHE PATH + "Default to all compiler invocations for --sysroot=." ) + +set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id to ld") + +set(ENABLE_X86_RELAX_RELOCATIONS OFF CACHE BOOL + "enable x86 relax relocations by default") + +set(FLANG_DEFAULT_LINKER "" CACHE STRING + "Default linker to use (linker name or absolute path, empty for platform default)") + +set(FLANG_DEFAULT_CXX_STDLIB "" CACHE STRING + "Default C++ stdlib to use (\"libstdc++\" or \"libc++\", empty for platform default") +if (NOT(FLANG_DEFAULT_CXX_STDLIB STREQUAL "" OR + FLANG_DEFAULT_CXX_STDLIB STREQUAL "libstdc++" OR + FLANG_DEFAULT_CXX_STDLIB STREQUAL "libc++")) + message(WARNING "Resetting default C++ stdlib to use platform default") + set(FLANG_DEFAULT_CXX_STDLIB "" CACHE STRING + "Default C++ stdlib to use (\"libstdc++\" or \"libc++\", empty for platform default" FORCE) +endif() + +set(FLANG_DEFAULT_RTLIB "" CACHE STRING + "Default runtime library to use (\"libgcc\" or \"compiler-rt\", empty for platform default)") +if (NOT(FLANG_DEFAULT_RTLIB STREQUAL "" OR + FLANG_DEFAULT_RTLIB STREQUAL "libgcc" OR + FLANG_DEFAULT_RTLIB STREQUAL "compiler-rt")) + message(WARNING "Resetting default rtlib to use platform default") + set(FLANG_DEFAULT_RTLIB "" CACHE STRING + "Default runtime library to use (\"libgcc\" or \"compiler-rt\", empty for platform default)" FORCE) +endif() + +set(FLANG_DEFAULT_OPENMP_RUNTIME "libomp" CACHE STRING + "Default OpenMP runtime used by -fopenmp.") + +set(FLANG_VENDOR ${PACKAGE_VENDOR} CACHE STRING + "Vendor-specific text for showing with version information.") + +if( FLANG_VENDOR ) + add_definitions( -DFLANG_VENDOR="${FLANG_VENDOR} " ) +endif() + +set(FLANG_REPOSITORY_STRING "" CACHE STRING + "Vendor-specific text for showing the repository the source is taken from.") + +if(FLANG_REPOSITORY_STRING) + add_definitions(-DFLANG_REPOSITORY_STRING="${FLANG_REPOSITORY_STRING}") +endif() + +set(FLANG_VENDOR_UTI "org.llvm.flang" CACHE STRING + "Vendor-specific uti.") + +# The libdir suffix must exactly match whatever LLVM's configuration used. +set(FLANG_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}") + +set(FLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) +set(FLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) + +if( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE ) + message(FATAL_ERROR "In-source builds are not allowed. CMake would overwrite " +"the makefiles distributed with LLVM. Please create a directory and run cmake " +"from there, passing the path to this source directory as the last argument. " +"This process created the file `CMakeCache.txt' and the directory " +"`CMakeFiles'. Please delete them.") +endif() + +if( NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR ) + file(GLOB_RECURSE + tablegenned_files_on_include_dir + "${FLANG_SOURCE_DIR}/include/flang/*.inc") + if( tablegenned_files_on_include_dir ) + message(FATAL_ERROR "Apparently there is a previous in-source build, " +"probably as the result of running `configure' and `make' on " +"${FLANG_SOURCE_DIR}. This may cause problems. The suspicious files are:\n" +"${tablegenned_files_on_include_dir}\nPlease clean the source directory.") + endif() +endif() + +# If FLANG_VERSION_* is specified, use it, if not use LLVM_VERSION_*. +if(NOT DEFINED FLANG_VERSION_MAJOR) + set(FLANG_VERSION_MAJOR ${LLVM_VERSION_MAJOR}) +endif() +if(NOT DEFINED FLANG_VERSION_MINOR) + set(FLANG_VERSION_MINOR ${LLVM_VERSION_MINOR}) +endif() +if(NOT DEFINED FLANG_VERSION_PATCHLEVEL) + set(FLANG_VERSION_PATCHLEVEL ${LLVM_VERSION_PATCH}) +endif() +# Unlike PACKAGE_VERSION, FLANG_VERSION does not include LLVM_VERSION_SUFFIX. +set(FLANG_VERSION "${FLANG_VERSION_MAJOR}.${FLANG_VERSION_MINOR}.${FLANG_VERSION_PATCHLEVEL}") +message(STATUS "FLANG version: ${FLANG_VERSION}") + +# Configure the Version.inc file. +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/include/flang/Basic/Version.inc.in + ${CMAKE_CURRENT_BINARY_DIR}/include/flang/Basic/Version.inc) + +# Add appropriate flags for GCC +if (LLVM_COMPILER_IS_GCC_COMPATIBLE) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common -Woverloaded-virtual") + if (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "FLANG") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing") + endif () + + # Enable -pedantic for FLANG even if it's not enabled for LLVM. + if (NOT LLVM_ENABLE_PEDANTIC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wno-long-long") + endif () + + check_cxx_compiler_flag("-Werror -Wnested-anon-types" CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG) + if( CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG ) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types" ) + endif() +endif () + +# Determine HOST_LINK_VERSION on Darwin. +set(HOST_LINK_VERSION) +if (APPLE) + set(LD_V_OUTPUT) + execute_process( + COMMAND sh -c "${CMAKE_LINKER} -v 2>&1 | head -1" + RESULT_VARIABLE HAD_ERROR + OUTPUT_VARIABLE LD_V_OUTPUT + ) + if (NOT HAD_ERROR) + if ("${LD_V_OUTPUT}" MATCHES ".*ld64-([0-9.]+).*") + string(REGEX REPLACE ".*ld64-([0-9.]+).*" "\\1" HOST_LINK_VERSION ${LD_V_OUTPUT}) + elseif ("${LD_V_OUTPUT}" MATCHES "[^0-9]*([0-9.]+).*") + string(REGEX REPLACE "[^0-9]*([0-9.]+).*" "\\1" HOST_LINK_VERSION ${LD_V_OUTPUT}) + endif() + else() + message(FATAL_ERROR "${CMAKE_LINKER} failed with status ${HAD_ERROR}") + endif() +endif() + +include(CMakeParseArguments) +include(AddFlang) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +include_directories(BEFORE + ${CMAKE_CURRENT_BINARY_DIR}/include + ${CMAKE_CURRENT_SOURCE_DIR}/include + ) + +#!! if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) +#!! +#!! install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/flang +#!! DESTINATION include +#!! FILES_MATCHING +#!! PATTERN "CMakeFiles" EXCLUDE +#!! PATTERN "*.inc" +#!! PATTERN "*.h" +#!! ) +#!! +#!! install(PROGRAMS utils/bash-autocomplete.sh +#!! DESTINATION share/flang +#!! ) +#!! endif() + +add_definitions( -D_GNU_SOURCE ) + +option(FLANG_BUILD_TOOLS + "Build the FLANG tools. If OFF, just generate build targets." ON) + +option(FLANG_ENABLE_ARCMT "Build ARCMT." ON) +#!!option(FLANG_ENABLE_STATIC_ANALYZER "Build static analyzer." ON) +#!! +#!!option(FLANG_ANALYZER_BUILD_Z3 +#!! "Build the static analyzer with the Z3 constraint manager." OFF) +#!! +#!!if(NOT FLANG_ENABLE_STATIC_ANALYZER AND (FLANG_ENABLE_ARCMT OR FLANG_ANALYZER_BUILD_Z3)) +#!! message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT or Z3") +#!!endif() +#!! +#!!if(FLANG_ANALYZER_BUILD_Z3) +#!! if(Z3_FOUND) +#!! set(FLANG_ANALYZER_WITH_Z3 1) +#!! else() +#!! message(FATAL_ERROR "Cannot find Z3 header file or shared library") +#!! endif() +#!!endif() +#!! +#!!if(FLANG_ENABLE_ARCMT) +#!! set(FLANG_ENABLE_OBJC_REWRITER ON) +#!!endif() + +# FLANG version information +set(FLANG_EXECUTABLE_VERSION + "${FLANG_VERSION_MAJOR}.${FLANG_VERSION_MINOR}" CACHE STRING + "Version number that will be placed into the flang executable, in the form XX.YY") +set(LIBFLANG_LIBRARY_VERSION + "${FLANG_VERSION_MAJOR}.${FLANG_VERSION_MINOR}" CACHE STRING + "Version number that will be placed into the libflang library , in the form XX.YY") +mark_as_advanced(FLANG_EXECUTABLE_VERSION LIBFLANG_LIBRARY_VERSION) + +option(FLANG_INCLUDE_TESTS + "Generate build targets for the FLANG unit tests." + ${LLVM_INCLUDE_TESTS}) + +add_subdirectory(utils/TableGen) + +add_subdirectory(include) + +# All targets below may depend on all tablegen'd files. +get_property(FLANG_TABLEGEN_TARGETS GLOBAL PROPERTY FLANG_TABLEGEN_TARGETS) +list(APPEND LLVM_COMMON_DEPENDS ${FLANG_TABLEGEN_TARGETS}) + +add_subdirectory(lib) +add_subdirectory(tools) +#!! add_subdirectory(runtime) + +#!! option(FLANG_BUILD_EXAMPLES "Build FLANG example programs by default." OFF) +#!! add_subdirectory(examples) + +if(APPLE) + # this line is needed as a cleanup to ensure that any CMakeCaches with the old + # default value get updated to the new default. + if(FLANG_ORDER_FILE STREQUAL "") + unset(FLANG_ORDER_FILE CACHE) + unset(FLANG_ORDER_FILE) + endif() + + + set(FLANG_ORDER_FILE ${CMAKE_CURRENT_BINARY_DIR}/flang.order CACHE FILEPATH + "Order file to use when compiling flang in order to improve startup time (Darwin Only - requires ld64).") + + if(NOT EXISTS ${FLANG_ORDER_FILE}) + string(FIND "${FLANG_ORDER_FILE}" "${CMAKE_CURRENT_BINARY_DIR}" PATH_START) + if(PATH_START EQUAL 0) + file(WRITE ${FLANG_ORDER_FILE} "\n") + else() + message(FATAL_ERROR "Specified order file '${FLANG_ORDER_FILE}' does not exist.") + endif() + endif() +endif() + + +#!! if( FLANG_INCLUDE_TESTS ) +#!! if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include/gtest/gtest.h) +#!! add_subdirectory(unittests) +#!! list(APPEND FLANG_TEST_DEPS FlangUnitTests) +#!! list(APPEND FLANG_TEST_PARAMS +#!! flang_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/test/Unit/lit.site.cfg +#!! ) +#!! endif() +#!! add_subdirectory(test) +#!! +#!! if(FLANG_BUILT_STANDALONE) +#!! # Add a global check rule now that all subdirectories have been traversed +#!! # and we know the total set of lit testsuites. +#!! get_property(LLVM_LIT_TESTSUITES GLOBAL PROPERTY LLVM_LIT_TESTSUITES) +#!! get_property(LLVM_LIT_PARAMS GLOBAL PROPERTY LLVM_LIT_PARAMS) +#!! get_property(LLVM_LIT_DEPENDS GLOBAL PROPERTY LLVM_LIT_DEPENDS) +#!! get_property(LLVM_LIT_EXTRA_ARGS GLOBAL PROPERTY LLVM_LIT_EXTRA_ARGS) +#!! add_lit_target(check-all +#!! "Running all regression tests" +#!! ${LLVM_LIT_TESTSUITES} +#!! PARAMS ${LLVM_LIT_PARAMS} +#!! DEPENDS ${LLVM_LIT_DEPENDS} +#!! ARGS ${LLVM_LIT_EXTRA_ARGS} +#!! ) +#!! endif() +#!! add_subdirectory(utils/perf-training) +#!! endif() + +#!! option(FLANG_INCLUDE_DOCS "Generate build targets for the FLANG docs." +#!! ${LLVM_INCLUDE_DOCS}) +#!! if( FLANG_INCLUDE_DOCS ) +#!! add_subdirectory(docs) +#!! endif() + +add_subdirectory(cmake/modules) + +if(FLANG_STAGE) + message(STATUS "Setting current flang stage to: ${FLANG_STAGE}") +endif() + + +#if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION) +# add_subdirectory(utils/FlangVisualizers) +#endif() + +configure_file( + ${FLANG_SOURCE_DIR}/include/flang/Config/config.h.cmake + ${FLANG_BINARY_DIR}/include/flang/Config/config.h) \ No newline at end of file diff --git a/flang/include/flang/Basic/LLVM.h b/flang/include/flang/Basic/LLVM.h index 00ebcc3..7c3a9d7 100644 --- a/flang/include/flang/Basic/LLVM.h +++ b/flang/include/flang/Basic/LLVM.h @@ -25,59 +25,57 @@ #include "llvm/ADT/None.h" namespace llvm { - // ADT's. - class StringRef; - class Twine; - template class ArrayRef; - template class MutableArrayRef; - template class OwningArrayRef; - template class SmallString; - template class SmallVector; - template class SmallVectorImpl; - template class Optional; +// ADT's. +class StringRef; +class Twine; +template class ArrayRef; +template class MutableArrayRef; +template class OwningArrayRef; +template class SmallString; +template class SmallVector; +template class SmallVectorImpl; +template class Optional; - template - struct SaveAndRestore; +template struct SaveAndRestore; - // Reference counting. - template class IntrusiveRefCntPtr; - template struct IntrusiveRefCntPtrInfo; - template class RefCountedBase; - - class raw_ostream; - class raw_pwrite_stream; - // TODO: DenseMap, ... -} +// Reference counting. +template class IntrusiveRefCntPtr; +template struct IntrusiveRefCntPtrInfo; +template class RefCountedBase; +class raw_ostream; +class raw_pwrite_stream; +// TODO: DenseMap, ... +} // namespace llvm namespace flang { - // Casting operators. - using llvm::isa; - using llvm::cast; - using llvm::dyn_cast; - using llvm::dyn_cast_or_null; - using llvm::cast_or_null; - - // ADT's. - using llvm::None; - using llvm::Optional; - using llvm::StringRef; - using llvm::Twine; - using llvm::ArrayRef; - using llvm::MutableArrayRef; - using llvm::OwningArrayRef; - using llvm::SmallString; - using llvm::SmallVector; - using llvm::SmallVectorImpl; - using llvm::SaveAndRestore; +// Casting operators. +using llvm::cast; +using llvm::cast_or_null; +using llvm::dyn_cast; +using llvm::dyn_cast_or_null; +using llvm::isa; + +// ADT's. +using llvm::ArrayRef; +using llvm::MutableArrayRef; +using llvm::None; +using llvm::Optional; +using llvm::OwningArrayRef; +using llvm::SaveAndRestore; +using llvm::SmallString; +using llvm::SmallVector; +using llvm::SmallVectorImpl; +using llvm::StringRef; +using llvm::Twine; - // Reference counting. - using llvm::IntrusiveRefCntPtr; - using llvm::IntrusiveRefCntPtrInfo; - using llvm::RefCountedBase; +// Reference counting. +using llvm::IntrusiveRefCntPtr; +using llvm::IntrusiveRefCntPtrInfo; +using llvm::RefCountedBase; - using llvm::raw_ostream; - using llvm::raw_pwrite_stream; -} // end namespace flang. +using llvm::raw_ostream; +using llvm::raw_pwrite_stream; +} // end namespace flang. #endif diff --git a/flang/include/flang/Basic/Version.h b/flang/include/flang/Basic/Version.h index 8475c1e..1e6cb9d 100644 --- a/flang/include/flang/Basic/Version.h +++ b/flang/include/flang/Basic/Version.h @@ -20,43 +20,43 @@ #include "llvm/ADT/StringRef.h" namespace flang { - /// \brief Retrieves the repository path (e.g., Subversion path) that - /// identifies the particular Flang branch, tag, or trunk from which this - /// Flang was built. - std::string getFlangRepositoryPath(); - - /// \brief Retrieves the repository path from which LLVM was built. - /// - /// This supports LLVM residing in a separate repository from flang. - std::string getLLVMRepositoryPath(); - - /// \brief Retrieves the repository revision number (or identifer) from which - /// this Flang was built. - std::string getFlangRevision(); - - /// \brief Retrieves the repository revision number (or identifer) from which - /// LLVM was built. - /// - /// If Flang and LLVM are in the same repository, this returns the same - /// string as getFlangRevision. - std::string getLLVMRevision(); - - /// \brief Retrieves the full repository version that is an amalgamation of - /// the information in getFlangRepositoryPath() and getFlangRevision(). - std::string getFlangFullRepositoryVersion(); - - /// \brief Retrieves a string representing the complete flang version, - /// which includes the flang version number, the repository version, - /// and the vendor tag. - std::string getFlangFullVersion(); - - /// \brief Like getFlangFullVersion(), but with a custom tool name. - std::string getFlangToolFullVersion(llvm::StringRef ToolName); - - /// \brief Retrieves a string representing the complete flang version suitable - /// for use in the CPP __VERSION__ macro, which includes the flang version - /// number, the repository version, and the vendor tag. - std::string getFlangFullCPPVersion(); -} - -#endif // LLVM_FLANG_BASIC_VERSION_H +/// \brief Retrieves the repository path (e.g., Subversion path) that +/// identifies the particular Flang branch, tag, or trunk from which this +/// Flang was built. +std::string getFlangRepositoryPath(); + +/// \brief Retrieves the repository path from which LLVM was built. +/// +/// This supports LLVM residing in a separate repository from flang. +std::string getLLVMRepositoryPath(); + +/// \brief Retrieves the repository revision number (or identifer) from which +/// this Flang was built. +std::string getFlangRevision(); + +/// \brief Retrieves the repository revision number (or identifer) from which +/// LLVM was built. +/// +/// If Flang and LLVM are in the same repository, this returns the same +/// string as getFlangRevision. +std::string getLLVMRevision(); + +/// \brief Retrieves the full repository version that is an amalgamation of +/// the information in getFlangRepositoryPath() and getFlangRevision(). +std::string getFlangFullRepositoryVersion(); + +/// \brief Retrieves a string representing the complete flang version, +/// which includes the flang version number, the repository version, +/// and the vendor tag. +std::string getFlangFullVersion(); + +/// \brief Like getFlangFullVersion(), but with a custom tool name. +std::string getFlangToolFullVersion(llvm::StringRef ToolName); + +/// \brief Retrieves a string representing the complete flang version suitable +/// for use in the CPP __VERSION__ macro, which includes the flang version +/// number, the repository version, and the vendor tag. +std::string getFlangFullCPPVersion(); +} // namespace flang + +#endif // LLVM_FLANG_BASIC_VERSION_H diff --git a/flang/include/flang/Sema/Scope.h b/flang/include/flang/Sema/Scope.h index e69de29..1515df4 100644 --- a/flang/include/flang/Sema/Scope.h +++ b/flang/include/flang/Sema/Scope.h @@ -0,0 +1,47 @@ +//===--- Scope.h - Information about a semantic context -----*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines FunctionScopeInfo and its subclasses, which contain +// information about a single function, block, lambda, or method body. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_FLANG_SEMA_SCOPEINFO_H +#define LLVM_FLANG_SEMA_SCOPEINFO_H + +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/SmallSet.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringSwitch.h" +#include + +namespace flang { + +namespace sema { + +/// \brief Contains information about the PROGRAM statement currently +/// being parsed. +class ProgramScope { +public: + ProgramScope(); + // TO BE IMPLEMETED +}; + +/// \brief Contains information about the PROGRAM statement currently +/// being parsed. +class FunctionScope { +public: + FunctionScope(); + // TO BE IMPLEMETED +}; + +} // end namespace sema +} // end namespace flang + +#endif diff --git a/flang/include/flang/Sema/Sema.h b/flang/include/flang/Sema/Sema.h index c801de9..2318740 100644 --- a/flang/include/flang/Sema/Sema.h +++ b/flang/include/flang/Sema/Sema.h @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// This file defines the Sema class, which performs semantic analysis +// This file defines the Sema class, which performs semantic analysis // for Fortran. // //===----------------------------------------------------------------------===// @@ -28,33 +28,32 @@ #include #include -namespace llvm { - // Put here the required forward declarations for LLVM - class APSInt; - template struct DenseMapInfo; - template class DenseSet; - class SmallBitVector; - class InlineAsmIdentifierInfo; -} +namespace llvm { +// Put here the required forward declarations for LLVM +class APSInt; +template struct DenseMapInfo; +template class DenseSet; +class SmallBitVector; +class InlineAsmIdentifierInfo; +} // namespace llvm namespace flang { - // Put here the required forward declarations for flang - class SourceLocation; - +// Put here the required forward declarations for flang +class SourceLocation; + namespace sema { - // Put here the forward declarations of the inner classes of the Sema library - class ProgramScope; - class FunctionScope; -} // end namespace flang::sema +// Put here the forward declarations of the inner classes of the Sema library +class ProgramScope; +class FunctionScope; +} // namespace sema /// Sema - This implements semantic analysis for Fortran class Sema { public: Sema(); -}; // end class Sema +}; // end class Sema -} // end namespace flang +} // end namespace flang #endif - diff --git a/flang/lib/CMakeLists.txt b/flang/lib/CMakeLists.txt index 39e3698..31c9019 100644 --- a/flang/lib/CMakeLists.txt +++ b/flang/lib/CMakeLists.txt @@ -1 +1,2 @@ add_subdirectory(Basic) +add_subdirectory(Sema) diff --git a/flang/lib/Sema/CMakeLists.txt b/flang/lib/Sema/CMakeLists.txt index 11e5b9f..32581cb 100644 --- a/flang/lib/Sema/CMakeLists.txt +++ b/flang/lib/Sema/CMakeLists.txt @@ -6,11 +6,12 @@ if (MSVC) set_source_files_properties(SemaExpr.cpp PROPERTIES COMPILE_FLAGS /bigobj) endif() -add_clang_library(clangSema +add_flang_library(flangSema Scope.cpp Sema.cpp SemaExpr.cpp LINK_LIBS - clangBasic + flangBasic ) + diff --git a/flang/lib/Sema/Scope.cpp b/flang/lib/Sema/Scope.cpp index e69de29..a7a2dbb 100644 --- a/flang/lib/Sema/Scope.cpp +++ b/flang/lib/Sema/Scope.cpp @@ -0,0 +1,30 @@ +//===- Scope.cpp - Lexical scope information --------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements the Scope class, which is used for recording +// information about a lexical scope. +// +//===----------------------------------------------------------------------===// + +#include "flang/Sema/Scope.h" + +using namespace flang; +using namespace sema; + +ProgramScope::ProgramScope() +{ +} + +FunctionScope::FunctionScope() +{ +} + + + + diff --git a/flang/lib/Sema/Sema.cpp b/flang/lib/Sema/Sema.cpp index e69de29..63ab7aa 100644 --- a/flang/lib/Sema/Sema.cpp +++ b/flang/lib/Sema/Sema.cpp @@ -0,0 +1,48 @@ +//===--- Sema.cpp - Semantic Analysis Implementation ------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements the actions class which performs semantic analysis +// out of a parse stream. +// +//===----------------------------------------------------------------------===// + +#include "flang/Basic/Version.h" +#include "flang/Sema/Scope.h" + +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/SmallSet.h" + +using namespace flang; +using namespace sema; + + +//===- Scope.cpp - Lexical scope information --------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements the Scope class, which is used for recording +// information about a lexical scope. +// +//===----------------------------------------------------------------------===// + +#include "flang/Sema/Sema.h" + +using namespace flang; +using namespace sema; + +Sema::Sema() +{ +} + + diff --git a/flang/tools/flang-info/CMakeLists.txt b/flang/tools/flang-info/CMakeLists.txt index dd22236..c9af2e9 100644 --- a/flang/tools/flang-info/CMakeLists.txt +++ b/flang/tools/flang-info/CMakeLists.txt @@ -10,6 +10,7 @@ add_flang_executable(flang-info target_link_libraries(flang-info flangBasic + flangSema ) install(TARGETS flang-info diff --git a/flang/tools/flang-info/FlangInfo.cpp b/flang/tools/flang-info/FlangInfo.cpp index 3dd2738..060968d 100644 --- a/flang/tools/flang-info/FlangInfo.cpp +++ b/flang/tools/flang-info/FlangInfo.cpp @@ -11,13 +11,14 @@ // It will eventually disapear. // // -// PLEASE DO NOT REPORT CODING STYLE VIOLATIONS ON THAT FILE! +// PLEASE DO NOT REPORT CODING STYLE VIOLATIONS ON THAT FILE! // THIS IS A TEMPORARY PLAYGROUND! // // //===----------------------------------------------------------------------===// #include "flang/Basic/Version.h" +#include "flang/Sema/Sema.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Option/OptTable.h" @@ -31,11 +32,15 @@ using namespace flang; #include int main(int argc, const char **argv) { - + std::cout << "Flang Repository = '" << getFlangRepositoryPath() << "'\n"; std::cout << "Flang Version = '" << getFlangFullVersion() << "'\n"; std::cout << "LLVM Repository = '" << getLLVMRepositoryPath() << "'\n"; - return 1 ; +#if 1 + Sema sema; +#endif + + return 1; } diff --git a/flang/utils/TableGen/TableGenBackends.h b/flang/utils/TableGen/TableGenBackends.h index e7cde6c..9fd1adc 100644 --- a/flang/utils/TableGen/TableGenBackends.h +++ b/flang/utils/TableGen/TableGenBackends.h @@ -19,19 +19,18 @@ #include namespace llvm { - class raw_ostream; - class RecordKeeper; -} +class raw_ostream; +class RecordKeeper; +} // namespace llvm -using llvm::raw_ostream; using llvm::RecordKeeper; +using llvm::raw_ostream; namespace flang { - // Used by FlangDiagnosticsEmitter.cpp -void EmitFlangDiagsDefs(RecordKeeper &Records, raw_ostream &OS, - const std::string &Component); +void EmitFlangDiagsDefs( + RecordKeeper &Records, raw_ostream &OS, const std::string &Component); void EmitFlangDiagGroups(RecordKeeper &Records, raw_ostream &OS); void EmitFlangDiagsIndexName(RecordKeeper &Records, raw_ostream &OS); void EmitFlangDiagDocs(RecordKeeper &Records, raw_ostream &OS); @@ -39,7 +38,6 @@ void EmitFlangDiagDocs(RecordKeeper &Records, raw_ostream &OS); // Used by FlangOptionDocEmitter.cpp void EmitFlangOptDocs(RecordKeeper &Records, raw_ostream &OS); - -} // end namespace flang +} // end namespace flang #endif -- 2.7.4