[PATCH] D30773: Make git-clang-format python 3 compatible
mgorny added inline comments. Comment at: tools/clang-format/git-clang-format:306 +try: +return to_string(bytes.decode('utf-8')) +except AttributeError: # 'str' object has no attribute 'decode'. EricWF wrote: > mgorny wrote: > > This logic looks really weird to me. What is the purpose of having both > > `to_string()` and `convert_string()`? Why do `to_bytes()` and `to_string()` > > use `isinstance()` to recognize types, and here you rely on exceptions? Why > > is `to_string()` called after decoding? > `to_string` is called after decoding because in python2 the result of > decoding is a `unicode` type, and we need to encode it a `str` type. Hense > to_string. No offense intended but this sounds really horrible. In modern Python, everything is either `bytes` or `unicode`. The difference basically is that `str` in py2 was pretty much `bytes` (except that `bytes` explicitly removes some operations that are unsuitable for bytestrings), and that `str` in py3 is equivalent to `unicode` before. So if you are specifically converting to `str`, it means that you want to have two distinct types in py2/py3. Which really sounds like you're doing something wrong. https://reviews.llvm.org/D30773 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30854: [ASTMatchers] Add ObjC matchers for fundamental decls
malcolm.parsons accepted this revision. malcolm.parsons added a comment. This revision is now accepted and ready to land. LGTM! https://reviews.llvm.org/D30854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r297555 - fix test coverage capture dirs
Author: ericwf Date: Fri Mar 10 23:28:09 2017 New Revision: 297555 URL: http://llvm.org/viewvc/llvm-project?rev=297555&view=rev Log: fix test coverage capture dirs Modified: libcxx/trunk/test/CMakeLists.txt Modified: libcxx/trunk/test/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/CMakeLists.txt?rev=297555&r1=297554&r2=297555&view=diff == --- libcxx/trunk/test/CMakeLists.txt (original) +++ libcxx/trunk/test/CMakeLists.txt Fri Mar 10 23:28:09 2017 @@ -77,7 +77,11 @@ endif() if (LIBCXX_GENERATE_COVERAGE) include(CodeCoverage) set(output_dir "${CMAKE_CURRENT_BINARY_DIR}/coverage") - set(capture_dirs "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx.dir/;${LIBCXX_LIB_CMAKEFILES_DIR}/cxx_experimental.dir/;${CMAKE_CURRENT_BINARY_DIR}") + set(capture_dirs + "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx_objects.dir/" + "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx.dir/" + "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx_experimental.dir/" + "${CMAKE_CURRENT_BINARY_DIR}") set(extract_dirs "${LIBCXX_SOURCE_DIR}/include;${LIBCXX_SOURCE_DIR}/src") setup_lcov_test_target_coverage("cxx" "${output_dir}" "${capture_dirs}" "${extract_dirs}") endif() ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30773: Make git-clang-format python 3 compatible
EricWF updated this revision to Diff 91452. EricWF marked an inline comment as done. EricWF added a comment. - rename variables so they don't conflict with type names. https://reviews.llvm.org/D30773 Files: tools/clang-format/git-clang-format Index: tools/clang-format/git-clang-format === --- tools/clang-format/git-clang-format +++ tools/clang-format/git-clang-format @@ -23,6 +23,7 @@ Requires Python 2.7 """ +from __future__ import print_function import argparse import collections import contextlib @@ -138,15 +139,15 @@ if opts.verbose >= 1: ignored_files.difference_update(changed_lines) if ignored_files: - print 'Ignoring changes in the following files (wrong extension):' + print('Ignoring changes in the following files (wrong extension):') for filename in ignored_files: -print ' ', filename +print('%s' % filename) if changed_lines: - print 'Running clang-format on the following files:' + print('Running clang-format on the following files:') for filename in changed_lines: -print ' ', filename +print('%s' % filename) if not changed_lines: -print 'no modified files to format' +print('no modified files to format') return # The computed diff outputs absolute paths, so we must cd before accessing # those files. @@ -163,20 +164,20 @@ binary=opts.binary, style=opts.style) if opts.verbose >= 1: -print 'old tree:', old_tree -print 'new tree:', new_tree +print('old tree: %s' % old_tree) +print('new tree: %s' % new_tree) if old_tree == new_tree: if opts.verbose >= 0: - print 'clang-format did not modify any files' + print('clang-format did not modify any files') elif opts.diff: print_diff(old_tree, new_tree) else: changed_files = apply_changes(old_tree, new_tree, force=opts.force, patch_mode=opts.patch) if (opts.verbose >= 0 and not opts.patch) or opts.verbose >= 1: - print 'changed files:' + print('changed files:') for filename in changed_files: -print ' ', filename +print('%s' % filename) def load_git_config(non_string_options=None): @@ -257,7 +258,7 @@ stdout, stderr = p.communicate() if p.returncode != 0: return None - return stdout.strip() + return convert_string(stdout.strip()) def compute_diff_and_extract_lines(commits, files): @@ -300,6 +301,7 @@ list of line `Range`s.""" matches = {} for line in patch_file: +line = convert_string(line) match = re.search(r'^\+\+\+\ [^/]+/(.*)', line) if match: filename = match.group(1).rstrip('\r\n') @@ -320,7 +322,7 @@ `allowed_extensions` must be a collection of lowercase file extensions, excluding the period.""" allowed_extensions = frozenset(allowed_extensions) - for filename in dictionary.keys(): + for filename in list(dictionary.keys()): base_ext = filename.rsplit('.', 1) if len(base_ext) == 1 or base_ext[1].lower() not in allowed_extensions: del dictionary[filename] @@ -345,7 +347,7 @@ Returns the object ID (SHA-1) of the created tree.""" def index_info_generator(): -for filename, line_ranges in changed_lines.iteritems(): +for filename, line_ranges in changed_lines.items(): if revision: git_metadata_cmd = ['git', 'ls-tree', '%s:%s' % (revision, os.path.dirname(filename)), @@ -356,6 +358,9 @@ mode = oct(int(stdout.split()[0], 8)) else: mode = oct(os.stat(filename).st_mode) + # Adjust python3 octal format so that it matches what git expects + if mode.startswith('0o'): + mode = '0' + mode[2:] blob_id = clang_format_to_blob(filename, line_ranges, revision=revision, binary=binary, @@ -376,7 +381,7 @@ with temporary_index_file(): p = subprocess.Popen(cmd, stdin=subprocess.PIPE) for line in input_lines: - p.stdin.write('%s\0' % line) + p.stdin.write(to_bytes('%s\0' % line)) p.stdin.close() if p.wait() != 0: die('`%s` failed' % ' '.join(cmd)) @@ -431,7 +436,7 @@ die('`%s` failed' % ' '.join(clang_format_cmd)) if git_show and git_show.wait() != 0: die('`%s` failed' % ' '.join(git_show_cmd)) - return stdout.rstrip('\r\n') + return convert_string(stdout).rstrip('\r\n') @contextlib.contextmanager @@ -488,10 +493,10 @@ if not force: unstaged_files = run('git', 'diff-files', '--name-status', *changed_files) if unstaged_files: - print >>sys.stderr, ('The following files would be modified but ' - 'have unstaged changes:')
Re: [PATCH] D30773: Make git-clang-format python 3 compatible
On Thu, Mar 9, 2017 at 9:36 AM, Nico Weber wrote: > Consider landing the obvious bits (print function, mostly) separately and > use this only for the interesting bits. > Sounds good. I just wanted to make sure I got the simple bits right as well. If this doesn't get reviewed in the next week I'll start landing bits separately as suggested. > > On Thu, Mar 9, 2017 at 11:10 AM, Michał Górny via Phabricator via > cfe-commits wrote: > >> mgorny added inline comments. >> >> >> >> Comment at: tools/clang-format/git-clang-format:293 >> >> +def to_bytes(str): >> +# Encode to UTF-8 to get binary data. >> >> Pretty much a nit but using variable names that match type names can be a >> bit confusing here. >> >> >> >> Comment at: tools/clang-format/git-clang-format:302 >> +return bytes >> +return to_bytes(bytes) >> + >> >> Shouldn't this be: >> >> return bytes.decode('utf-8') >> >> ? >> >> Otherwise, unless I'm missing something this function will always return >> the parameter [with no modifications], either in the first conditional if >> it's of `str` type, or in the conditional inside `to_bytes()` if it's of >> `bytes` type. >> >> >> >> Comment at: tools/clang-format/git-clang-format:306 >> +try: >> +return to_string(bytes.decode('utf-8')) >> +except AttributeError: # 'str' object has no attribute 'decode'. >> >> This logic looks really weird to me. What is the purpose of having both >> `to_string()` and `convert_string()`? Why do `to_bytes()` and `to_string()` >> use `isinstance()` to recognize types, and here you rely on exceptions? Why >> is `to_string()` called after decoding? >> >> >> >> Comment at: tools/clang-format/git-clang-format:310 >> +except UnicodeError: >> +return str(bytes) >> + >> >> I don't think this can ever succeed. If the argument is not valid utf8, >> it certainly won't be valid ASCII. >> >> >> >> Comment at: tools/clang-format/git-clang-format:323 >>for line in patch_file: >> -match = re.search(r'^\+\+\+\ [^/]+/(.*)', line) >> +match = re.search(to_bytes(r'^\+\+\+\ [^/]+/(.*)'), line) >> if match: >> >> Any reason not to use: >> >> br'^\+...' >> >> ? i.e. make it bytes immediately instead of converting. >> >> >> >> Comment at: tools/clang-format/git-clang-format:344 >> + keys_to_delete = [] >> + for filename in list(dictionary.keys()): >> +filename_cp = convert_string(bytes(filename)) >> >> Since you are using `keys_to_delete` now, you can remove the `list()`. >> >> >> >> Comment at: tools/clang-format/git-clang-format:348 >> if len(base_ext) == 1 or base_ext[1].lower() not in >> allowed_extensions: >> - del dictionary[filename] >> + keys_to_delete += [filename] >> + for key in keys_to_delete: >> >> Another nit. I think it'd be better to just append a single item instead >> of a list of 1 item ;-). >> >> keys_to_delete.append(filename) >> >> >> https://reviews.llvm.org/D30773 >> >> >> >> ___ >> cfe-commits mailing list >> cfe-commits@lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >> > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30773: Make git-clang-format python 3 compatible
EricWF marked 4 inline comments as done. EricWF added inline comments. Comment at: tools/clang-format/git-clang-format:293 +def to_bytes(str): +# Encode to UTF-8 to get binary data. These functions are all lifted directly from `lit/util.py` Comment at: tools/clang-format/git-clang-format:302 +return bytes +return to_bytes(bytes) + mgorny wrote: > Shouldn't this be: > > return bytes.decode('utf-8') > > ? > > Otherwise, unless I'm missing something this function will always return the > parameter [with no modifications], either in the first conditional if it's of > `str` type, or in the conditional inside `to_bytes()` if it's of `bytes` type. Nope. So in python3 this line will never be hit. but it will be in python2. Specifically `convert_string` calls `to_string(bytes.decode('utf-8'))`. Which in python2 calls `to_string` with the type `unicode`. We need to de-code the unicode into a string using `bytes.encode('utf-8')`. I agree it's a bit misleading that it's calling a function called `to_bytes` though. Comment at: tools/clang-format/git-clang-format:306 +try: +return to_string(bytes.decode('utf-8')) +except AttributeError: # 'str' object has no attribute 'decode'. mgorny wrote: > This logic looks really weird to me. What is the purpose of having both > `to_string()` and `convert_string()`? Why do `to_bytes()` and `to_string()` > use `isinstance()` to recognize types, and here you rely on exceptions? Why > is `to_string()` called after decoding? `to_string` is called after decoding because in python2 the result of decoding is a `unicode` type, and we need to encode it a `str` type. Hense to_string. Comment at: tools/clang-format/git-clang-format:323 for line in patch_file: -match = re.search(r'^\+\+\+\ [^/]+/(.*)', line) +match = re.search(to_bytes(r'^\+\+\+\ [^/]+/(.*)'), line) if match: mgorny wrote: > Any reason not to use: > > br'^\+...' > > ? i.e. make it bytes immediately instead of converting. I tried `rb'blah'` and that didn't work in python2. However this has since been removed. https://reviews.llvm.org/D30773 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30773: Make git-clang-format python 3 compatible
EricWF updated this revision to Diff 91449. EricWF added a comment. Add complete implementation. As far as I've tested this works perfectly in both python2 and python3. https://reviews.llvm.org/D30773 Files: tools/clang-format/git-clang-format Index: tools/clang-format/git-clang-format === --- tools/clang-format/git-clang-format +++ tools/clang-format/git-clang-format @@ -23,6 +23,7 @@ Requires Python 2.7 """ +from __future__ import print_function import argparse import collections import contextlib @@ -138,15 +139,15 @@ if opts.verbose >= 1: ignored_files.difference_update(changed_lines) if ignored_files: - print 'Ignoring changes in the following files (wrong extension):' + print('Ignoring changes in the following files (wrong extension):') for filename in ignored_files: -print ' ', filename +print('%s' % filename) if changed_lines: - print 'Running clang-format on the following files:' + print('Running clang-format on the following files:') for filename in changed_lines: -print ' ', filename +print('%s' % filename) if not changed_lines: -print 'no modified files to format' +print('no modified files to format') return # The computed diff outputs absolute paths, so we must cd before accessing # those files. @@ -163,20 +164,20 @@ binary=opts.binary, style=opts.style) if opts.verbose >= 1: -print 'old tree:', old_tree -print 'new tree:', new_tree +print('old tree: %s' % old_tree) +print('new tree: %s' % new_tree) if old_tree == new_tree: if opts.verbose >= 0: - print 'clang-format did not modify any files' + print('clang-format did not modify any files') elif opts.diff: print_diff(old_tree, new_tree) else: changed_files = apply_changes(old_tree, new_tree, force=opts.force, patch_mode=opts.patch) if (opts.verbose >= 0 and not opts.patch) or opts.verbose >= 1: - print 'changed files:' + print('changed files:') for filename in changed_files: -print ' ', filename +print('%s' % filename) def load_git_config(non_string_options=None): @@ -257,7 +258,7 @@ stdout, stderr = p.communicate() if p.returncode != 0: return None - return stdout.strip() + return convert_string(stdout.strip()) def compute_diff_and_extract_lines(commits, files): @@ -300,6 +301,7 @@ list of line `Range`s.""" matches = {} for line in patch_file: +line = convert_string(line) match = re.search(r'^\+\+\+\ [^/]+/(.*)', line) if match: filename = match.group(1).rstrip('\r\n') @@ -320,7 +322,7 @@ `allowed_extensions` must be a collection of lowercase file extensions, excluding the period.""" allowed_extensions = frozenset(allowed_extensions) - for filename in dictionary.keys(): + for filename in list(dictionary.keys()): base_ext = filename.rsplit('.', 1) if len(base_ext) == 1 or base_ext[1].lower() not in allowed_extensions: del dictionary[filename] @@ -345,7 +347,7 @@ Returns the object ID (SHA-1) of the created tree.""" def index_info_generator(): -for filename, line_ranges in changed_lines.iteritems(): +for filename, line_ranges in changed_lines.items(): if revision: git_metadata_cmd = ['git', 'ls-tree', '%s:%s' % (revision, os.path.dirname(filename)), @@ -356,6 +358,9 @@ mode = oct(int(stdout.split()[0], 8)) else: mode = oct(os.stat(filename).st_mode) + # Adjust python3 octal format so that it matches what git expects + if mode.startswith('0o'): + mode = '0' + mode[2:] blob_id = clang_format_to_blob(filename, line_ranges, revision=revision, binary=binary, @@ -376,7 +381,7 @@ with temporary_index_file(): p = subprocess.Popen(cmd, stdin=subprocess.PIPE) for line in input_lines: - p.stdin.write('%s\0' % line) + p.stdin.write(to_bytes('%s\0' % line)) p.stdin.close() if p.wait() != 0: die('`%s` failed' % ' '.join(cmd)) @@ -431,7 +436,7 @@ die('`%s` failed' % ' '.join(clang_format_cmd)) if git_show and git_show.wait() != 0: die('`%s` failed' % ' '.join(git_show_cmd)) - return stdout.rstrip('\r\n') + return convert_string(stdout).rstrip('\r\n') @contextlib.contextmanager @@ -488,10 +493,10 @@ if not force: unstaged_files = run('git', 'diff-files', '--name-status', *changed_files) if unstaged_files: - print >>sys.stderr, ('The following files would be modified but ' - 'have unstaged changes:'
[libcxx] r297553 - Change test coverage generation to use llvm-cov instead of gcov.
Author: ericwf Date: Fri Mar 10 21:24:18 2017 New Revision: 297553 URL: http://llvm.org/viewvc/llvm-project?rev=297553&view=rev Log: Change test coverage generation to use llvm-cov instead of gcov. Clang doesn't produce gcov compatible coverage files. This causes lcov to break because it uses gcov by default. This patch switches lcov to use llvm-cov as the gcov-tool. Unfortunatly llvm-cov doesn't provide a gcov like interface by default so it won't work with lcov. However `llvm-cov gcov` does. For this reason we generate 'llvm-cov-wrapper' script that always passes the gcov flag. Added: libcxx/trunk/cmake/Modules/HandleCompilerRT.cmake Modified: libcxx/trunk/CMakeLists.txt libcxx/trunk/cmake/Modules/CodeCoverage.cmake libcxx/trunk/lib/CMakeLists.txt Modified: libcxx/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=297553&r1=297552&r2=297553&view=diff == --- libcxx/trunk/CMakeLists.txt (original) +++ libcxx/trunk/CMakeLists.txt Fri Mar 10 21:24:18 2017 @@ -57,6 +57,7 @@ endif() # Setup CMake Options #=== include(CMakeDependentOption) +include(HandleCompilerRT) # Basic options --- option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." OFF) Modified: libcxx/trunk/cmake/Modules/CodeCoverage.cmake URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/CodeCoverage.cmake?rev=297553&r1=297552&r2=297553&view=diff == --- libcxx/trunk/cmake/Modules/CodeCoverage.cmake (original) +++ libcxx/trunk/cmake/Modules/CodeCoverage.cmake Fri Mar 10 21:24:18 2017 @@ -3,6 +3,11 @@ if (NOT CODE_COVERAGE_LCOV) message(FATAL_ERROR "Cannot find lcov...") endif() +find_program(CODE_COVERAGE_LLVM_COV llvm-cov) +if (NOT CODE_COVERAGE_LLVM_COV) + message(FATAL_ERROR "Cannot find llvm-cov...") +endif() + find_program(CODE_COVERAGE_GENHTML genhtml) if (NOT CODE_COVERAGE_GENHTML) message(FATAL_ERROR "Cannot find genhtml...") @@ -11,6 +16,14 @@ endif() set(CMAKE_CXX_FLAGS_COVERAGE "-g -O0 --coverage") function(setup_lcov_test_target_coverage target_name output_dir capture_dirs source_dirs) + if (NOT DEFINED LIBCXX_BINARY_DIR) +message(FATAL_ERROR "Variable must be set") + endif() + + set(GCOV_TOOL "${LIBCXX_BINARY_DIR}/llvm-cov-wrapper") + file(GENERATE OUTPUT ${GCOV_TOOL} +CONTENT "#!/usr/bin/env bash\n${CODE_COVERAGE_LLVM_COV} gcov \"$@\"\n") + file(MAKE_DIRECTORY ${output_dir}) set(CAPTURE_DIRS "") @@ -27,8 +40,9 @@ function(setup_lcov_test_target_coverage message(STATUS "Extract Directories: ${EXTRACT_DIRS}") add_custom_target(generate-lib${target_name}-coverage -COMMAND ${CODE_COVERAGE_LCOV} --capture ${CAPTURE_DIRS} -o test_coverage.info -COMMAND ${CODE_COVERAGE_LCOV} --extract test_coverage.info ${EXTRACT_DIRS} -o test_coverage.info +COMMAND chmod +x ${GCOV_TOOL} +COMMAND ${CODE_COVERAGE_LCOV} --gcov-tool ${GCOV_TOOL} --capture ${CAPTURE_DIRS} -o test_coverage.info +COMMAND ${CODE_COVERAGE_LCOV} --gcov-tool ${GCOV_TOOL} --extract test_coverage.info ${EXTRACT_DIRS} -o test_coverage.info COMMAND ${CODE_COVERAGE_GENHTML} --demangle-cpp test_coverage.info -o test_coverage COMMAND ${CMAKE_COMMAND} -E remove test_coverage.info WORKING_DIRECTORY ${output_dir} Added: libcxx/trunk/cmake/Modules/HandleCompilerRT.cmake URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/HandleCompilerRT.cmake?rev=297553&view=auto == --- libcxx/trunk/cmake/Modules/HandleCompilerRT.cmake (added) +++ libcxx/trunk/cmake/Modules/HandleCompilerRT.cmake Fri Mar 10 21:24:18 2017 @@ -0,0 +1,43 @@ +function(find_compiler_rt_library name dest) + if (NOT DEFINED LIBCXX_COMPILE_FLAGS) +message(FATAL_ERROR "LIBCXX_COMPILE_FLAGS must be defined when using this function") + endif() + set(dest "" PARENT_SCOPE) + set(CLANG_COMMAND ${CMAKE_CXX_COMPILER} ${LIBCXX_COMPILE_FLAGS} + "--rtlib=compiler-rt" "--print-libgcc-file-name") + execute_process( + COMMAND ${CLANG_COMMAND} + RESULT_VARIABLE HAD_ERROR + OUTPUT_VARIABLE LIBRARY_FILE + ) + string(STRIP "${LIBRARY_FILE}" LIBRARY_FILE) + string(REPLACE "builtins" "${name}" LIBRARY_FILE "${LIBRARY_FILE}") + if (NOT HAD_ERROR AND EXISTS "${LIBRARY_FILE}") +message(STATUS "Found compiler-rt library: ${LIBRARY_FILE}") +set(${dest} "${LIBRARY_FILE}" PARENT_SCOPE) + else() +message(STATUS "Failed to find compiler-rt library") + endif() +endfunction() + +function(find_compiler_rt_dir dest) + if (NOT DEFINED LIBCXX_COMPILE_FLAGS) +message(FATAL_ERROR "LIBCXX_COMPILE_FLAGS must be defined
r297547 - [coroutines] Fix diagnostics depending on the first coroutine statement.
Author: ericwf Date: Fri Mar 10 20:35:37 2017 New Revision: 297547 URL: http://llvm.org/viewvc/llvm-project?rev=297547&view=rev Log: [coroutines] Fix diagnostics depending on the first coroutine statement. Summary: Some coroutine diagnostics need to point to the location of the first coroutine keyword in the function, like when diagnosing a `return` inside a coroutine. Previously we did this by storing each *valid* coroutine statement in a list and select the first one to use in diagnostics. However if every coroutine statement is invalid we would have no location to point to. This patch fixes the storage of the first coroutine statement location, ensuring that it gets stored even when the resulting AST node would be invalid. This patch also removes the `CoroutineStmts` list in `FunctionScopeInfo` because it was unused. Reviewers: rsmith, GorNishanov, aaron.ballman Reviewed By: GorNishanov Subscribers: mehdi_amini, cfe-commits Differential Revision: https://reviews.llvm.org/D30776 Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h cfe/trunk/lib/Sema/ScopeInfo.cpp cfe/trunk/lib/Sema/SemaCoroutine.cpp cfe/trunk/lib/Sema/TreeTransform.h cfe/trunk/test/SemaCXX/coroutines.cpp Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ScopeInfo.h?rev=297547&r1=297546&r2=297547&view=diff == --- cfe/trunk/include/clang/Sema/ScopeInfo.h (original) +++ cfe/trunk/include/clang/Sema/ScopeInfo.h Fri Mar 10 20:35:37 2017 @@ -24,6 +24,7 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringSwitch.h" #include namespace clang { @@ -139,6 +140,14 @@ public: /// to build, the initial and final coroutine suspend points bool NeedsCoroutineSuspends : 1; + /// \brief An enumeration represeting the kind of the first coroutine statement + /// in the function. One of co_return, co_await, or co_yield. + unsigned char FirstCoroutineStmtKind : 2; + + /// First coroutine statement in the current function. + /// (ex co_return, co_await, co_yield) + SourceLocation FirstCoroutineStmtLoc; + /// First 'return' statement in the current function. SourceLocation FirstReturnLoc; @@ -166,11 +175,6 @@ public: /// \brief The initial and final coroutine suspend points. std::pair CoroutineSuspends; - /// \brief The list of coroutine control flow constructs (co_await, co_yield, - /// co_return) that occur within the function or block. Empty if and only if - /// this function or block is not (yet known to be) a coroutine. - SmallVector CoroutineStmts; - /// \brief The stack of currently active compound stamement scopes in the /// function. SmallVector CompoundScopes; @@ -384,6 +388,28 @@ public: (HasBranchProtectedScope && HasBranchIntoScope)); } + void setFirstCoroutineStmt(SourceLocation Loc, StringRef Keyword) { +assert(FirstCoroutineStmtLoc.isInvalid() && + "first coroutine statement location already set"); +FirstCoroutineStmtLoc = Loc; +FirstCoroutineStmtKind = llvm::StringSwitch(Keyword) +.Case("co_return", 0) +.Case("co_await", 1) +.Case("co_yield", 2); + } + + StringRef getFirstCoroutineStmtKeyword() const { +assert(FirstCoroutineStmtLoc.isValid() + && "no coroutine statement available"); +switch (FirstCoroutineStmtKind) { +case 0: return "co_return"; +case 1: return "co_await"; +case 2: return "co_yield"; +default: + llvm_unreachable("FirstCoroutineStmtKind has an invalid value"); +}; + } + void setNeedsCoroutineSuspends(bool value = true) { assert((!value || CoroutineSuspends.first == nullptr) && "we already have valid suspend points"); Modified: cfe/trunk/lib/Sema/ScopeInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/ScopeInfo.cpp?rev=297547&r1=297546&r2=297547&view=diff == --- cfe/trunk/lib/Sema/ScopeInfo.cpp (original) +++ cfe/trunk/lib/Sema/ScopeInfo.cpp Fri Mar 10 20:35:37 2017 @@ -40,13 +40,15 @@ void FunctionScopeInfo::Clear() { FirstCXXTryLoc = SourceLocation(); FirstSEHTryLoc = SourceLocation(); - SwitchStack.clear(); - Returns.clear(); + // Coroutine state + FirstCoroutineStmtLoc = SourceLocation(); CoroutinePromise = nullptr; NeedsCoroutineSuspends = true; CoroutineSuspends.first = nullptr; CoroutineSuspends.second = nullptr; - CoroutineStmts.clear(); + + SwitchStack.clear(); + Returns.clear(); ErrorTrap.reset(); PossiblyUnreachableDiags.clear(); WeakObjectUses.clear(); Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCoroutine.cpp?rev=297547&r1=297546&r2=297547&view=diff =
[PATCH] D30776: [coroutines] Fix diagnostics depending on the first coroutine statement.
EricWF updated this revision to Diff 91447. EricWF added a comment. Merge with master. https://reviews.llvm.org/D30776 Files: include/clang/Sema/ScopeInfo.h lib/Sema/ScopeInfo.cpp lib/Sema/SemaCoroutine.cpp lib/Sema/TreeTransform.h test/SemaCXX/coroutines.cpp Index: test/SemaCXX/coroutines.cpp === --- test/SemaCXX/coroutines.cpp +++ test/SemaCXX/coroutines.cpp @@ -162,11 +162,59 @@ return; // expected-error {{not allowed in coroutine}} } +void mixed_yield_invalid() { + co_yield blah; // expected-error {{use of undeclared identifier}} + // expected-note@-1 {{function is a coroutine due to use of 'co_yield'}} + return; // expected-error {{return statement not allowed in coroutine}} +} + +template +void mixed_yield_template(T) { + co_yield blah; // expected-error {{use of undeclared identifier}} + // expected-note@-1 {{function is a coroutine due to use of 'co_yield'}} + return; // expected-error {{return statement not allowed in coroutine}} +} + +template +void mixed_yield_template2(T) { + co_yield 42; + // expected-note@-1 {{function is a coroutine due to use of 'co_yield'}} + return; // expected-error {{return statement not allowed in coroutine}} +} + +template +void mixed_yield_template3(T v) { + co_yield blah(v); + // expected-note@-1 {{function is a coroutine due to use of 'co_yield'}} + return; // expected-error {{return statement not allowed in coroutine}} +} + void mixed_await() { co_await a; // expected-note {{use of 'co_await'}} return; // expected-error {{not allowed in coroutine}} } +void mixed_await_invalid() { + co_await 42; // expected-error {{'int' is not a structure or union}} + // expected-note@-1 {{function is a coroutine due to use of 'co_await'}} + return; // expected-error {{not allowed in coroutine}} +} + +template +void mixed_await_template(T) { + co_await 42; + // expected-note@-1 {{function is a coroutine due to use of 'co_await'}} + return; // expected-error {{not allowed in coroutine}} +} + +template +void mixed_await_template2(T v) { + co_await v; // expected-error {{'long' is not a structure or union}} + // expected-note@-1 {{function is a coroutine due to use of 'co_await'}} + return; // expected-error {{not allowed in coroutine}} +} +template void mixed_await_template2(long); // expected-note {{requested here}} + void only_coreturn(void_tag) { co_return; // OK } @@ -178,6 +226,33 @@ return; // expected-error {{not allowed in coroutine}} } +void mixed_coreturn_invalid(bool b) { + if (b) +co_return; // expected-note {{use of 'co_return'}} +// expected-error@-1 {{no member named 'return_void' in 'promise'}} + else +return; // expected-error {{not allowed in coroutine}} +} + +template +void mixed_coreturn_template(void_tag, bool b, T v) { + if (b) +co_return v; // expected-note {{use of 'co_return'}} +// expected-error@-1 {{no member named 'return_value' in 'promise_void'}} + else +return; // expected-error {{not allowed in coroutine}} +} +template void mixed_coreturn_template(void_tag, bool, int); // expected-note {{requested here}} + +template +void mixed_coreturn_template2(bool b, T) { + if (b) +co_return v; // expected-note {{use of 'co_return'}} +// expected-error@-1 {{use of undeclared identifier 'v'}} + else +return; // expected-error {{not allowed in coroutine}} +} + struct CtorDtor { CtorDtor() { co_yield 0; // expected-error {{'co_yield' cannot be used in a constructor}} Index: lib/Sema/TreeTransform.h === --- lib/Sema/TreeTransform.h +++ lib/Sema/TreeTransform.h @@ -6857,7 +6857,7 @@ ScopeInfo->NeedsCoroutineSuspends && ScopeInfo->CoroutineSuspends.first == nullptr && ScopeInfo->CoroutineSuspends.second == nullptr && - ScopeInfo->CoroutineStmts.empty() && "expected clean scope info"); + "expected clean scope info"); // Set that we have (possibly-invalid) suspend points before we do anything // that may fail. Index: lib/Sema/SemaCoroutine.cpp === --- lib/Sema/SemaCoroutine.cpp +++ lib/Sema/SemaCoroutine.cpp @@ -400,15 +400,19 @@ /// Check that this is a context in which a coroutine suspension can appear. static FunctionScopeInfo *checkCoroutineContext(Sema &S, SourceLocation Loc, -StringRef Keyword) { +StringRef Keyword, +bool IsImplicit = false) { if (!isValidCoroutineContext(S, Loc, Keyword)) return nullptr; assert(isa(S.CurContext) && "not in a function scope"); auto *ScopeInfo = S.getCurFunction(); assert(ScopeInfo && "missing function scope for function"); + if (ScopeInfo->FirstCoroutineStmtLoc.isInvalid() && !IsImplicit) +ScopeInf
[PATCH] D30775: [coroutines] Refactor SuspendExpr to create just one OpaqueValue (almost NFC)
This revision was automatically updated to reflect the committed changes. Closed by commit rL297541: [coroutines] Refactor SuspendExpr to create just one OpaqueValue (almost NFC) (authored by GorNishanov). Changed prior to commit: https://reviews.llvm.org/D30775?vs=91134&id=91442#toc Repository: rL LLVM https://reviews.llvm.org/D30775 Files: cfe/trunk/include/clang/AST/ExprCXX.h cfe/trunk/lib/Sema/SemaCoroutine.cpp Index: cfe/trunk/include/clang/AST/ExprCXX.h === --- cfe/trunk/include/clang/AST/ExprCXX.h +++ cfe/trunk/include/clang/AST/ExprCXX.h @@ -4123,16 +4123,18 @@ enum SubExpr { Common, Ready, Suspend, Resume, Count }; Stmt *SubExprs[SubExpr::Count]; + OpaqueValueExpr *OpaqueValue = nullptr; friend class ASTStmtReader; public: CoroutineSuspendExpr(StmtClass SC, SourceLocation KeywordLoc, Expr *Common, - Expr *Ready, Expr *Suspend, Expr *Resume) + Expr *Ready, Expr *Suspend, Expr *Resume, + OpaqueValueExpr *OpaqueValue) : Expr(SC, Resume->getType(), Resume->getValueKind(), Resume->getObjectKind(), Resume->isTypeDependent(), Resume->isValueDependent(), Common->isInstantiationDependent(), Common->containsUnexpandedParameterPack()), -KeywordLoc(KeywordLoc) { +KeywordLoc(KeywordLoc), OpaqueValue(OpaqueValue) { SubExprs[SubExpr::Common] = Common; SubExprs[SubExpr::Ready] = Ready; SubExprs[SubExpr::Suspend] = Suspend; @@ -4161,6 +4163,8 @@ Expr *getCommonExpr() const { return static_cast(SubExprs[SubExpr::Common]); } + /// \brief getOpaqueValue - Return the opaque value placeholder. + OpaqueValueExpr *getOpaqueValue() const { return OpaqueValue; } Expr *getReadyExpr() const { return static_cast(SubExprs[SubExpr::Ready]); @@ -4194,10 +4198,11 @@ friend class ASTStmtReader; public: CoawaitExpr(SourceLocation CoawaitLoc, Expr *Operand, Expr *Ready, - Expr *Suspend, Expr *Resume, bool IsImplicit = false) + Expr *Suspend, Expr *Resume, OpaqueValueExpr *OpaqueValue, + bool IsImplicit = false) : CoroutineSuspendExpr(CoawaitExprClass, CoawaitLoc, Operand, Ready, - Suspend, Resume) { - CoawaitBits.IsImplicit = IsImplicit; + Suspend, Resume, OpaqueValue) { +CoawaitBits.IsImplicit = IsImplicit; } CoawaitExpr(SourceLocation CoawaitLoc, QualType Ty, Expr *Operand, bool IsImplicit = false) @@ -4270,9 +4275,9 @@ friend class ASTStmtReader; public: CoyieldExpr(SourceLocation CoyieldLoc, Expr *Operand, Expr *Ready, - Expr *Suspend, Expr *Resume) + Expr *Suspend, Expr *Resume, OpaqueValueExpr *OpaqueValue) : CoroutineSuspendExpr(CoyieldExprClass, CoyieldLoc, Operand, Ready, - Suspend, Resume) {} + Suspend, Resume, OpaqueValue) {} CoyieldExpr(SourceLocation CoyieldLoc, QualType Ty, Expr *Operand) : CoroutineSuspendExpr(CoyieldExprClass, CoyieldLoc, Ty, Operand) {} CoyieldExpr(EmptyShell Empty) Index: cfe/trunk/lib/Sema/SemaCoroutine.cpp === --- cfe/trunk/lib/Sema/SemaCoroutine.cpp +++ cfe/trunk/lib/Sema/SemaCoroutine.cpp @@ -312,8 +312,9 @@ } struct ReadySuspendResumeResult { - bool IsInvalid; Expr *Results[3]; + OpaqueValueExpr *OpaqueValue; + bool IsInvalid; }; static ExprResult buildMemberCall(Sema &S, Expr *Base, SourceLocation Loc, @@ -336,8 +337,11 @@ /// expression. static ReadySuspendResumeResult buildCoawaitCalls(Sema &S, VarDecl *CoroPromise, SourceLocation Loc, Expr *E) { + OpaqueValueExpr *Operand = new (S.Context) + OpaqueValueExpr(Loc, E->getType(), VK_LValue, E->getObjectKind(), E); + // Assume invalid until we see otherwise. - ReadySuspendResumeResult Calls = {true, {}}; + ReadySuspendResumeResult Calls = {{}, Operand, /*IsInvalid=*/true}; ExprResult CoroHandleRes = buildCoroutineHandle(S, CoroPromise->getType(), Loc); if (CoroHandleRes.isInvalid()) @@ -347,9 +351,6 @@ const StringRef Funcs[] = {"await_ready", "await_suspend", "await_resume"}; MultiExprArg Args[] = {None, CoroHandle, None}; for (size_t I = 0, N = llvm::array_lengthof(Funcs); I != N; ++I) { -Expr *Operand = new (S.Context) OpaqueValueExpr( - Loc, E->getType(), VK_LValue, E->getObjectKind(), E); - ExprResult Result = buildMemberCall(S, Operand, Loc, Funcs[I], Args[I]); if (Result.isInvalid()) return Calls; @@ -556,8 +557,9 @@ if (RSS.IsInvalid) return ExprError(); - Expr *Res = new (Context) CoawaitExpr(Loc, E, RSS.Results[0], RSS.Results[1], -RSS.Results[2], IsImplicit); + Expr *Res = + new (Context) Coaw
r297541 - [coroutines] Refactor SuspendExpr to create just one OpaqueValue (almost NFC)
Author: gornishanov Date: Fri Mar 10 19:30:17 2017 New Revision: 297541 URL: http://llvm.org/viewvc/llvm-project?rev=297541&view=rev Log: [coroutines] Refactor SuspendExpr to create just one OpaqueValue (almost NFC) Summary: Create only one OpaqueValue for await_ready/await_suspend/await_resume. Store OpaqueValue used in the CoroutineSuspendExpr node, so that CodeGen does not have to hunt looking for it. Reviewers: rsmith, EricWF, aaron.ballman Reviewed By: EricWF Subscribers: mehdi_amini, cfe-commits Differential Revision: https://reviews.llvm.org/D30775 Modified: cfe/trunk/include/clang/AST/ExprCXX.h cfe/trunk/lib/Sema/SemaCoroutine.cpp Modified: cfe/trunk/include/clang/AST/ExprCXX.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=297541&r1=297540&r2=297541&view=diff == --- cfe/trunk/include/clang/AST/ExprCXX.h (original) +++ cfe/trunk/include/clang/AST/ExprCXX.h Fri Mar 10 19:30:17 2017 @@ -4123,16 +4123,18 @@ class CoroutineSuspendExpr : public Expr enum SubExpr { Common, Ready, Suspend, Resume, Count }; Stmt *SubExprs[SubExpr::Count]; + OpaqueValueExpr *OpaqueValue = nullptr; friend class ASTStmtReader; public: CoroutineSuspendExpr(StmtClass SC, SourceLocation KeywordLoc, Expr *Common, - Expr *Ready, Expr *Suspend, Expr *Resume) + Expr *Ready, Expr *Suspend, Expr *Resume, + OpaqueValueExpr *OpaqueValue) : Expr(SC, Resume->getType(), Resume->getValueKind(), Resume->getObjectKind(), Resume->isTypeDependent(), Resume->isValueDependent(), Common->isInstantiationDependent(), Common->containsUnexpandedParameterPack()), -KeywordLoc(KeywordLoc) { +KeywordLoc(KeywordLoc), OpaqueValue(OpaqueValue) { SubExprs[SubExpr::Common] = Common; SubExprs[SubExpr::Ready] = Ready; SubExprs[SubExpr::Suspend] = Suspend; @@ -4161,6 +4163,8 @@ public: Expr *getCommonExpr() const { return static_cast(SubExprs[SubExpr::Common]); } + /// \brief getOpaqueValue - Return the opaque value placeholder. + OpaqueValueExpr *getOpaqueValue() const { return OpaqueValue; } Expr *getReadyExpr() const { return static_cast(SubExprs[SubExpr::Ready]); @@ -4194,10 +4198,11 @@ class CoawaitExpr : public CoroutineSusp friend class ASTStmtReader; public: CoawaitExpr(SourceLocation CoawaitLoc, Expr *Operand, Expr *Ready, - Expr *Suspend, Expr *Resume, bool IsImplicit = false) + Expr *Suspend, Expr *Resume, OpaqueValueExpr *OpaqueValue, + bool IsImplicit = false) : CoroutineSuspendExpr(CoawaitExprClass, CoawaitLoc, Operand, Ready, - Suspend, Resume) { - CoawaitBits.IsImplicit = IsImplicit; + Suspend, Resume, OpaqueValue) { +CoawaitBits.IsImplicit = IsImplicit; } CoawaitExpr(SourceLocation CoawaitLoc, QualType Ty, Expr *Operand, bool IsImplicit = false) @@ -4270,9 +4275,9 @@ class CoyieldExpr : public CoroutineSusp friend class ASTStmtReader; public: CoyieldExpr(SourceLocation CoyieldLoc, Expr *Operand, Expr *Ready, - Expr *Suspend, Expr *Resume) + Expr *Suspend, Expr *Resume, OpaqueValueExpr *OpaqueValue) : CoroutineSuspendExpr(CoyieldExprClass, CoyieldLoc, Operand, Ready, - Suspend, Resume) {} + Suspend, Resume, OpaqueValue) {} CoyieldExpr(SourceLocation CoyieldLoc, QualType Ty, Expr *Operand) : CoroutineSuspendExpr(CoyieldExprClass, CoyieldLoc, Ty, Operand) {} CoyieldExpr(EmptyShell Empty) Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCoroutine.cpp?rev=297541&r1=297540&r2=297541&view=diff == --- cfe/trunk/lib/Sema/SemaCoroutine.cpp (original) +++ cfe/trunk/lib/Sema/SemaCoroutine.cpp Fri Mar 10 19:30:17 2017 @@ -312,8 +312,9 @@ static ExprResult buildCoroutineHandle(S } struct ReadySuspendResumeResult { - bool IsInvalid; Expr *Results[3]; + OpaqueValueExpr *OpaqueValue; + bool IsInvalid; }; static ExprResult buildMemberCall(Sema &S, Expr *Base, SourceLocation Loc, @@ -336,8 +337,11 @@ static ExprResult buildMemberCall(Sema & /// expression. static ReadySuspendResumeResult buildCoawaitCalls(Sema &S, VarDecl *CoroPromise, SourceLocation Loc, Expr *E) { + OpaqueValueExpr *Operand = new (S.Context) + OpaqueValueExpr(Loc, E->getType(), VK_LValue, E->getObjectKind(), E); + // Assume invalid until we see otherwise. - ReadySuspendResumeResult Calls = {true, {}}; + ReadySuspendResumeResult Calls = {{}, Operand, /*IsInvalid=*/true}; ExprResult CoroHandleRes = buildCoroutineHandle(S, C
[PATCH] D30776: [coroutines] Fix diagnostics depending on the first coroutine statement.
GorNishanov accepted this revision. GorNishanov added a comment. This revision is now accepted and ready to land. Alright, then. LGTM once more! https://reviews.llvm.org/D30776 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30854: [ASTMatchers] Add ObjC matchers for fundamental decls
kastiglione added a comment. I'd like to add more ObjC specific matcher functionality in follow up diffs. This diff is to to start somewhere, and get feedback. https://reviews.llvm.org/D30854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30854: [ASTMatchers] Add ObjC matchers for fundamental decls
kastiglione created this revision. This adds matchers for `ObjCProtocolDecl`, `ObjCCategoryDecl`, `ObjCMethodDecl`, `ObjCIvarDecl`, and `ObjCPropertyDecl`. These matchers complement the existing matcher for `ObjCInterfaceDecl`. https://reviews.llvm.org/D30854 Files: docs/LibASTMatchersReference.html include/clang/ASTMatchers/ASTMatchers.h lib/ASTMatchers/Dynamic/Registry.cpp unittests/ASTMatchers/ASTMatchersNodeTest.cpp unittests/ASTMatchers/ASTMatchersTest.h Index: unittests/ASTMatchers/ASTMatchersTest.h === --- unittests/ASTMatchers/ASTMatchersTest.h +++ unittests/ASTMatchers/ASTMatchersTest.h @@ -120,7 +120,7 @@ const T &AMatcher) { return matchesConditionally( Code, AMatcher, true, -"", FileContentMappings(), "input.m"); +"-fobjc-runtime=macosx", FileContentMappings(), "input.m"); } template @@ -148,7 +148,7 @@ const T &AMatcher) { return matchesConditionally( Code, AMatcher, false, -"", FileContentMappings(), "input.m"); +"-fobjc-runtime=macosx", FileContentMappings(), "input.m"); } Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp === --- unittests/ASTMatchers/ASTMatchersNodeTest.cpp +++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp @@ -1498,7 +1498,9 @@ // don't find ObjCMessageExpr where none are present EXPECT_TRUE(notMatchesObjC("", objcMessageExpr(anything(; - std::string Objc1String = + std::string ObjCString = +"#pragma clang diagnostic ignored \"-Wobjc-root-class\"\n" +"#pragma clang diagnostic ignored \"-Wobjc-method-access\"\n" "@interface Str " " - (Str *)uppercaseString:(Str *)str;" "@end " @@ -1513,32 +1515,73 @@ "} " "@end "; EXPECT_TRUE(matchesObjC( -Objc1String, +ObjCString, objcMessageExpr(anything(; EXPECT_TRUE(matchesObjC( -Objc1String, +ObjCString, objcMessageExpr(hasSelector("contents"; EXPECT_TRUE(matchesObjC( -Objc1String, +ObjCString, objcMessageExpr(matchesSelector("cont*"; EXPECT_FALSE(matchesObjC( -Objc1String, +ObjCString, objcMessageExpr(matchesSelector("?cont*"; EXPECT_TRUE(notMatchesObjC( -Objc1String, +ObjCString, objcMessageExpr(hasSelector("contents"), hasNullSelector(; EXPECT_TRUE(matchesObjC( -Objc1String, +ObjCString, objcMessageExpr(hasSelector("contents"), hasUnarySelector(; EXPECT_TRUE(matchesObjC( -Objc1String, +ObjCString, objcMessageExpr(hasSelector("contents"), numSelectorArgs(0; EXPECT_TRUE(matchesObjC( -Objc1String, +ObjCString, objcMessageExpr(matchesSelector("uppercase*"), argumentCountIs(0) ))); } +TEST(ObjCDeclMacher, CoreDecls) { + std::string ObjCString = +"#pragma clang diagnostic ignored \"-Wobjc-root-class\"\n" +"@protocol Proto " +"- (void)protoDidThing; " +"@end " +"@interface Thing " +"@property int enabled; " +"@end " +"@interface Thing (ABC) " +"- (void)abc_doThing; " +"@end " +"@implementation Thing " +"{ id _ivar; } " +"- (void)anything {} " +"@end " +; + + EXPECT_TRUE(matchesObjC( +ObjCString, +objcProtocolDecl(hasName("Proto"; + EXPECT_TRUE(matchesObjC( +ObjCString, +objcCategoryDecl(hasName("ABC"; + EXPECT_TRUE(matchesObjC( +ObjCString, +objcMethodDecl(hasName("protoDidThing"; + EXPECT_TRUE(matchesObjC( +ObjCString, +objcMethodDecl(hasName("abc_doThing"; + EXPECT_TRUE(matchesObjC( +ObjCString, +objcMethodDecl(hasName("anything"; + EXPECT_TRUE(matchesObjC( +ObjCString, +objcIvarDecl(hasName("_ivar"; + EXPECT_TRUE(matchesObjC( +ObjCString, +objcPropertyDecl(hasName("enabled"; +} + } // namespace ast_matchers } // namespace clang Index: lib/ASTMatchers/Dynamic/Registry.cpp === --- lib/ASTMatchers/Dynamic/Registry.cpp +++ lib/ASTMatchers/Dynamic/Registry.cpp @@ -360,6 +360,11 @@ REGISTER_MATCHER(numSelectorArgs); REGISTER_MATCHER(ofClass); REGISTER_MATCHER(objcInterfaceDecl); + REGISTER_MATCHER(objcProtocolDecl); + REGISTER_MATCHER(objcCategoryDecl); + REGISTER_MATCHER(objcMethodDecl); + REGISTER_MATCHER(objcIvarDecl); + REGISTER_MATCHER(objcPropertyDecl); REGISTER_MATCHER(objcMessageExpr); REGISTER_MATCHER(objcObjectPointerType); REGISTER_MATCHER(on); Index: include/clang/ASTMatchers/ASTMatchers.h === --- include/clang/ASTMatchers/ASTMatchers.h +++ include/clang/ASTMatchers/ASTMatchers.h @@ -1118,6 +1118,69 @@ Decl, ObjCInterfaceDecl> objcInterfaceDecl; +/// \brief Matches Objective-C protocol declarations. +/// +/// Example matches Foo
[PATCH] D30834: [x86] these aren't the undefs you're looking for (PR32176)
spatel added a comment. In https://reviews.llvm.org/D30834#698346, @craig.topper wrote: > Have you ran the tests all the way through to assembly and made sure we don't > regress? If we do regress, I wouldn't hold up fixing this, but we should at > least have bugs for what breaks. Yes - I spot-checked several of the shuffle cases, and we always catch those even at -O0. As noted in the PR, we get those in the backend or InstCombine if optimization is on. The AVX2 gathers regress (we have an xor for the dummy register operand), and of course the undef intrinsics themselves now have an xor. If you know where those undef intrinsics are intended to be used, I can try that too. There's no problem with the pcmpeqd example in the bug report. I'll file a new PR for the gathers once this goes in and link to PR32176. Comment at: lib/CodeGen/CGBuiltin.cpp:7384 case X86::BI__builtin_ia32_undef512: -return UndefValue::get(ConvertType(E->getType())); +// The x86 definition of "undef" is not the same as the LLVM definition +// (PR32176). We leave the exercise of optimizing away an unnecessary zero craig.topper wrote: > Do we want to leave a TODO here to maybe do something different when we have > freeze? Sure - I'll add that. https://reviews.llvm.org/D30834 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r297533 - Revert "Reapply [VFS] Ignore broken symlinks in the directory iterator."
Author: ributzka Date: Fri Mar 10 18:14:50 2017 New Revision: 297533 URL: http://llvm.org/viewvc/llvm-project?rev=297533&view=rev Log: Revert "Reapply [VFS] Ignore broken symlinks in the directory iterator." Still broken on Windows and SystemZ bot ... sorry for the noise. Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h cfe/trunk/lib/Basic/VirtualFileSystem.cpp cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=297533&r1=297532&r2=297533&view=diff == --- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original) +++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Fri Mar 10 18:14:50 2017 @@ -161,7 +161,7 @@ public: directory_iterator &increment(std::error_code &EC) { assert(Impl && "attempting to increment past end"); EC = Impl->increment(); -if (!Impl->CurrentEntry.isStatusKnown()) +if (EC || !Impl->CurrentEntry.isStatusKnown()) Impl.reset(); // Normalize the end iterator to Impl == nullptr. return *this; } Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=297533&r1=297532&r2=297533&view=diff == --- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original) +++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Fri Mar 10 18:14:50 2017 @@ -244,7 +244,8 @@ public: if (!EC && Iter != llvm::sys::fs::directory_iterator()) { llvm::sys::fs::file_status S; EC = Iter->status(S); - CurrentEntry = Status::copyWithNewName(S, Iter->path()); + if (!EC) +CurrentEntry = Status::copyWithNewName(S, Iter->path()); } } @@ -1855,7 +1856,7 @@ vfs::recursive_directory_iterator::recur std::error_code &EC) : FS(&FS_) { directory_iterator I = FS->dir_begin(Path, EC); - if (I != directory_iterator()) { + if (!EC && I != directory_iterator()) { State = std::make_shared(); State->push(I); } @@ -1868,6 +1869,8 @@ recursive_directory_iterator::increment( vfs::directory_iterator End; if (State->top()->isDirectory()) { vfs::directory_iterator I = FS->dir_begin(State->top()->getName(), EC); +if (EC) + return *this; if (I != End) { State->push(I); return *this; Modified: cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp?rev=297533&r1=297532&r2=297533&view=diff == --- cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp (original) +++ cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp Fri Mar 10 18:14:50 2017 @@ -305,22 +305,6 @@ struct ScopedDir { } operator StringRef() { return Path.str(); } }; - -struct ScopedLink { - SmallString<128> Path; - ScopedLink(const Twine &To, const Twine &From) { -Path = From.str(); -std::error_code EC = sys::fs::create_link(To, From); -if (EC) - Path = ""; -EXPECT_FALSE(EC); - } - ~ScopedLink() { -if (Path != "") - EXPECT_FALSE(llvm::sys::fs::remove(Path.str())); - } - operator StringRef() { return Path.str(); } -}; } // end anonymous namespace TEST(VirtualFileSystemTest, BasicRealFSIteration) { @@ -350,28 +334,6 @@ TEST(VirtualFileSystemTest, BasicRealFSI EXPECT_EQ(vfs::directory_iterator(), I); } -TEST(VirtualFileSystemTest, BrokenSymlinkRealFSIteration) { - ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/ true); - IntrusiveRefCntPtr FS = vfs::getRealFileSystem(); - - ScopedLink _a("no_such_file", TestDirectory + "/a"); - ScopedDir _b(TestDirectory + "/b"); - ScopedLink _c("no_such_file", TestDirectory + "/c"); - - std::error_code EC; - for (vfs::directory_iterator I = FS->dir_begin(Twine(TestDirectory), EC), E; - I != E; I.increment(EC)) { -// Skip broken symlinks. -if (EC == std::errc::no_such_file_or_directory) { - EC = std::error_code(); - continue; -} else if (EC) { - break; -} -EXPECT_TRUE(I->getName() == _b); - } -} - TEST(VirtualFileSystemTest, BasicRealFSRecursiveIteration) { ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/true); IntrusiveRefCntPtr FS = vfs::getRealFileSystem(); @@ -411,43 +373,6 @@ TEST(VirtualFileSystemTest, BasicRealFSR EXPECT_EQ(1, Counts[3]); // d } -TEST(VirtualFileSystemTest, BrokenSymlinkRealFSRecursiveIteration) { - ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/ true); - IntrusiveRefCntPtr FS = vfs::getRealFileSystem(); - - ScopedLink _a("no_such_file", TestDirectory + "/a"); - ScopedDir _b(TestDirectory + "/b"); - ScopedLink _ba("n
[libcxx] r297532 - Fix DoNotOptimize on MSVC
Author: ericwf Date: Fri Mar 10 18:07:08 2017 New Revision: 297532 URL: http://llvm.org/viewvc/llvm-project?rev=297532&view=rev Log: Fix DoNotOptimize on MSVC Modified: libcxx/trunk/test/support/test_macros.h Modified: libcxx/trunk/test/support/test_macros.h URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/test_macros.h?rev=297532&r1=297531&r2=297532&view=diff == --- libcxx/trunk/test/support/test_macros.h (original) +++ libcxx/trunk/test/support/test_macros.h Fri Mar 10 18:07:08 2017 @@ -188,9 +188,11 @@ inline void DoNotOptimize(Tp const& valu asm volatile("" : : "g"(value) : "memory"); } #else +#include template -inline void DoNotOptimize(Tp const&) { - // FIXME: Do something here... +inline void DoNotOptimize(Tp const& value) { + const volatile void* volatile = __builtin_addressof(value); + _ReadWriteBarrier(); } #endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r297531 - Adding debug output to investigate systemz bot issue.
Author: ributzka Date: Fri Mar 10 18:01:24 2017 New Revision: 297531 URL: http://llvm.org/viewvc/llvm-project?rev=297531&view=rev Log: Adding debug output to investigate systemz bot issue. Modified: cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp Modified: cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp?rev=297531&r1=297530&r2=297531&view=diff == --- cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp (original) +++ cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp Fri Mar 10 18:01:24 2017 @@ -436,6 +436,7 @@ TEST(VirtualFileSystemTest, BrokenSymlin EC = std::error_code(); continue; } else if (EC) { + outs() << "BrokenSymlinkRealFSRecursiveIteration EC: " << EC.message(); break; } Contents.push_back(I->getName()); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30834: [x86] these aren't the undefs you're looking for (PR32176)
craig.topper added a comment. Have you ran the tests all the way through to assembly and made sure we don't regress? If we do regress, I wouldn't hold up fixing this, but we should at least have bugs for what breaks. Comment at: lib/CodeGen/CGBuiltin.cpp:7384 case X86::BI__builtin_ia32_undef512: -return UndefValue::get(ConvertType(E->getType())); +// The x86 definition of "undef" is not the same as the LLVM definition +// (PR32176). We leave the exercise of optimizing away an unnecessary zero Do we want to leave a TODO here to maybe do something different when we have freeze? https://reviews.llvm.org/D30834 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r297528 - Reapply [VFS] Ignore broken symlinks in the directory iterator.
Author: ributzka Date: Fri Mar 10 16:49:04 2017 New Revision: 297528 URL: http://llvm.org/viewvc/llvm-project?rev=297528&view=rev Log: Reapply [VFS] Ignore broken symlinks in the directory iterator. Modified the tests to accept any iteration order. The VFS directory iterator and recursive directory iterator behave differently from the LLVM counterparts. Once the VFS iterators hit a broken symlink they immediately abort. The LLVM counterparts allow to recover from this issue by clearing the error code and skipping to the next entry. This change adds the same functionality to the VFS iterators. There should be no change in current behavior in the current CLANG source base, because all clients have loop exit conditions that also check the error code. This fixes rdar://problem/30934619. Differential Revision: https://reviews.llvm.org/D30768 Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h cfe/trunk/lib/Basic/VirtualFileSystem.cpp cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=297528&r1=297527&r2=297528&view=diff == --- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original) +++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Fri Mar 10 16:49:04 2017 @@ -161,7 +161,7 @@ public: directory_iterator &increment(std::error_code &EC) { assert(Impl && "attempting to increment past end"); EC = Impl->increment(); -if (EC || !Impl->CurrentEntry.isStatusKnown()) +if (!Impl->CurrentEntry.isStatusKnown()) Impl.reset(); // Normalize the end iterator to Impl == nullptr. return *this; } Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=297528&r1=297527&r2=297528&view=diff == --- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original) +++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Fri Mar 10 16:49:04 2017 @@ -244,8 +244,7 @@ public: if (!EC && Iter != llvm::sys::fs::directory_iterator()) { llvm::sys::fs::file_status S; EC = Iter->status(S); - if (!EC) -CurrentEntry = Status::copyWithNewName(S, Iter->path()); + CurrentEntry = Status::copyWithNewName(S, Iter->path()); } } @@ -1856,7 +1855,7 @@ vfs::recursive_directory_iterator::recur std::error_code &EC) : FS(&FS_) { directory_iterator I = FS->dir_begin(Path, EC); - if (!EC && I != directory_iterator()) { + if (I != directory_iterator()) { State = std::make_shared(); State->push(I); } @@ -1869,8 +1868,6 @@ recursive_directory_iterator::increment( vfs::directory_iterator End; if (State->top()->isDirectory()) { vfs::directory_iterator I = FS->dir_begin(State->top()->getName(), EC); -if (EC) - return *this; if (I != End) { State->push(I); return *this; Modified: cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp?rev=297528&r1=297527&r2=297528&view=diff == --- cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp (original) +++ cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp Fri Mar 10 16:49:04 2017 @@ -305,6 +305,22 @@ struct ScopedDir { } operator StringRef() { return Path.str(); } }; + +struct ScopedLink { + SmallString<128> Path; + ScopedLink(const Twine &To, const Twine &From) { +Path = From.str(); +std::error_code EC = sys::fs::create_link(To, From); +if (EC) + Path = ""; +EXPECT_FALSE(EC); + } + ~ScopedLink() { +if (Path != "") + EXPECT_FALSE(llvm::sys::fs::remove(Path.str())); + } + operator StringRef() { return Path.str(); } +}; } // end anonymous namespace TEST(VirtualFileSystemTest, BasicRealFSIteration) { @@ -334,6 +350,28 @@ TEST(VirtualFileSystemTest, BasicRealFSI EXPECT_EQ(vfs::directory_iterator(), I); } +TEST(VirtualFileSystemTest, BrokenSymlinkRealFSIteration) { + ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/ true); + IntrusiveRefCntPtr FS = vfs::getRealFileSystem(); + + ScopedLink _a("no_such_file", TestDirectory + "/a"); + ScopedDir _b(TestDirectory + "/b"); + ScopedLink _c("no_such_file", TestDirectory + "/c"); + + std::error_code EC; + for (vfs::directory_iterator I = FS->dir_begin(Twine(TestDirectory), EC), E; + I != E; I.increment(EC)) { +// Skip broken symlinks. +if (EC == std::errc::no_such_file_or_directory) { + EC = std::error_code(); + continue; +} else if (EC) { + break; +} +EXPECT_TRUE(I->getName() == _b); + } +} + TEST(VirtualFileSys
r297517 - Revert r297510 "[VFS] Ignore broken symlinks in the directory iterator."
Author: ributzka Date: Fri Mar 10 15:46:51 2017 New Revision: 297517 URL: http://llvm.org/viewvc/llvm-project?rev=297517&view=rev Log: Revert r297510 "[VFS] Ignore broken symlinks in the directory iterator." The tests are failing on one of the bots. Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h cfe/trunk/lib/Basic/VirtualFileSystem.cpp cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=297517&r1=297516&r2=297517&view=diff == --- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original) +++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Fri Mar 10 15:46:51 2017 @@ -161,7 +161,7 @@ public: directory_iterator &increment(std::error_code &EC) { assert(Impl && "attempting to increment past end"); EC = Impl->increment(); -if (!Impl->CurrentEntry.isStatusKnown()) +if (EC || !Impl->CurrentEntry.isStatusKnown()) Impl.reset(); // Normalize the end iterator to Impl == nullptr. return *this; } Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=297517&r1=297516&r2=297517&view=diff == --- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original) +++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Fri Mar 10 15:46:51 2017 @@ -244,7 +244,8 @@ public: if (!EC && Iter != llvm::sys::fs::directory_iterator()) { llvm::sys::fs::file_status S; EC = Iter->status(S); - CurrentEntry = Status::copyWithNewName(S, Iter->path()); + if (!EC) +CurrentEntry = Status::copyWithNewName(S, Iter->path()); } } @@ -1855,7 +1856,7 @@ vfs::recursive_directory_iterator::recur std::error_code &EC) : FS(&FS_) { directory_iterator I = FS->dir_begin(Path, EC); - if (I != directory_iterator()) { + if (!EC && I != directory_iterator()) { State = std::make_shared(); State->push(I); } @@ -1868,6 +1869,8 @@ recursive_directory_iterator::increment( vfs::directory_iterator End; if (State->top()->isDirectory()) { vfs::directory_iterator I = FS->dir_begin(State->top()->getName(), EC); +if (EC) + return *this; if (I != End) { State->push(I); return *this; Modified: cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp?rev=297517&r1=297516&r2=297517&view=diff == --- cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp (original) +++ cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp Fri Mar 10 15:46:51 2017 @@ -305,22 +305,6 @@ struct ScopedDir { } operator StringRef() { return Path.str(); } }; - -struct ScopedLink { - SmallString<128> Path; - ScopedLink(const Twine &To, const Twine &From) { -Path = From.str(); -std::error_code EC = sys::fs::create_link(To, From); -if (EC) - Path = ""; -EXPECT_FALSE(EC); - } - ~ScopedLink() { -if (Path != "") - EXPECT_FALSE(llvm::sys::fs::remove(Path.str())); - } - operator StringRef() { return Path.str(); } -}; } // end anonymous namespace TEST(VirtualFileSystemTest, BasicRealFSIteration) { @@ -350,35 +334,6 @@ TEST(VirtualFileSystemTest, BasicRealFSI EXPECT_EQ(vfs::directory_iterator(), I); } -TEST(VirtualFileSystemTest, BrokenSymlinkRealFSIteration) { - ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/ true); - IntrusiveRefCntPtr FS = vfs::getRealFileSystem(); - - ScopedLink _a("no_such_file", TestDirectory + "/a"); - ScopedDir _b(TestDirectory + "/b"); - ScopedLink _c("no_such_file", TestDirectory + "/c"); - - std::error_code EC; - vfs::directory_iterator I = FS->dir_begin(Twine(TestDirectory), EC); - EXPECT_TRUE(EC); - EXPECT_NE(vfs::directory_iterator(), I); - EC = std::error_code(); - EXPECT_TRUE(I->getName() == _a); - I.increment(EC); - EXPECT_FALSE(EC); - EXPECT_NE(vfs::directory_iterator(), I); - EXPECT_TRUE(I->getName() == _b); - I.increment(EC); - EXPECT_TRUE(EC); - EXPECT_NE(vfs::directory_iterator(), I); - EC = std::error_code(); - EXPECT_NE(vfs::directory_iterator(), I); - EXPECT_TRUE(I->getName() == _c); - I.increment(EC); - EXPECT_FALSE(EC); - EXPECT_EQ(vfs::directory_iterator(), I); -} - TEST(VirtualFileSystemTest, BasicRealFSRecursiveIteration) { ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/true); IntrusiveRefCntPtr FS = vfs::getRealFileSystem(); @@ -418,44 +373,6 @@ TEST(VirtualFileSystemTest, BasicRealFSR EXPECT_EQ(1, Counts[3]); // d } -TEST(VirtualFileSystemTest, BrokenSymlinkRealFSRecursiveIteration) { - S
r297467 - [clang-format] Add option to break before inheritance separation operator in class declaration.
Author: abpostelnicu Date: Fri Mar 10 09:10:37 2017 New Revision: 297467 URL: http://llvm.org/viewvc/llvm-project?rev=297467&view=rev Log: [clang-format] Add option to break before inheritance separation operator in class declaration. Differential Revision: https://reviews.llvm.org/D30487 Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst cfe/trunk/include/clang/Format/Format.h cfe/trunk/lib/Format/ContinuationIndenter.cpp cfe/trunk/lib/Format/Format.cpp cfe/trunk/lib/Format/FormatToken.h cfe/trunk/lib/Format/TokenAnnotator.cpp cfe/trunk/unittests/Format/FormatTest.cpp Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=297467&r1=297466&r2=297467&view=diff == --- cfe/trunk/docs/ClangFormatStyleOptions.rst (original) +++ cfe/trunk/docs/ClangFormatStyleOptions.rst Fri Mar 10 09:10:37 2017 @@ -528,6 +528,10 @@ the configuration (without a prefix: ``A +**BreakBeforeInheritanceComma** (``bool``) + If ``true``, in the class inheritance expression clang-format will + break before ``:`` and ``,`` if there is multiple inheritance. + **BreakBeforeTernaryOperators** (``bool``) If ``true``, ternary operators will be placed after line breaks. Modified: cfe/trunk/include/clang/Format/Format.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=297467&r1=297466&r2=297467&view=diff == --- cfe/trunk/include/clang/Format/Format.h (original) +++ cfe/trunk/include/clang/Format/Format.h Fri Mar 10 09:10:37 2017 @@ -422,6 +422,10 @@ struct FormatStyle { /// which should not be split into lines or otherwise changed. std::string CommentPragmas; + /// \brief If ``true``, in the class inheritance expression clang-format will + /// break before ``:`` and ``,`` if there is multiple inheritance. + bool BreakBeforeInheritanceComma; + /// \brief If the constructor initializers don't fit on a line, put each /// initializer on its own line. bool ConstructorInitializerAllOnOneLineOrOnePerLine; @@ -844,6 +848,7 @@ struct FormatStyle { BreakAfterJavaFieldAnnotations == R.BreakAfterJavaFieldAnnotations && BreakStringLiterals == R.BreakStringLiterals && ColumnLimit == R.ColumnLimit && CommentPragmas == R.CommentPragmas && + BreakBeforeInheritanceComma == R.BreakBeforeInheritanceComma && ConstructorInitializerAllOnOneLineOrOnePerLine == R.ConstructorInitializerAllOnOneLineOrOnePerLine && ConstructorInitializerIndentWidth == Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=297467&r1=297466&r2=297467&view=diff == --- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original) +++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Fri Mar 10 09:10:37 2017 @@ -57,8 +57,10 @@ static bool startsNextParameter(const Fo Style.BreakConstructorInitializersBeforeComma) return true; return Previous.is(tok::comma) && !Current.isTrailingComment() && - (Previous.isNot(TT_CtorInitializerComma) || - !Style.BreakConstructorInitializersBeforeComma); + ((Previous.isNot(TT_CtorInitializerComma) || + !Style.BreakConstructorInitializersBeforeComma) && + (Previous.isNot(TT_InheritanceComma) || + !Style.BreakBeforeInheritanceComma)); } ContinuationIndenter::ContinuationIndenter(const FormatStyle &Style, @@ -350,6 +352,11 @@ void ContinuationIndenter::addTokenOnCur Whitespaces.replaceWhitespace(Current, /*Newlines=*/0, Spaces, State.Column + Spaces); + // If "BreakBeforeInheritanceComma" mode, don't break within the inheritance + // declaration unless there is multiple inheritance. + if (Style.BreakBeforeInheritanceComma && Current.is(TT_InheritanceColon)) +State.Stack.back().NoLineBreak = true; + if (Current.is(TT_SelectorName) && !State.Stack.back().ObjCSelectorNameFound) { unsigned MinIndent = @@ -737,10 +744,11 @@ unsigned ContinuationIndenter::getNewLin if (PreviousNonComment && PreviousNonComment->is(tok::colon) && PreviousNonComment->isOneOf(TT_ObjCMethodExpr, TT_DictLiteral)) return ContinuationIndent; - if (NextNonComment->is(TT_CtorInitializerColon)) -return State.FirstIndent + Style.ConstructorInitializerIndentWidth; if (NextNonComment->is(TT_CtorInitializerComma)) return State.Stack.back().Indent; + if (NextNonComment->isOneOf(TT_CtorInitializerColon, TT_InheritanceColon, + TT_InheritanceComma)) +return State.FirstIndent + Style.ConstructorInitializerIndentWidth; if (Previ
r297511 - [VFS] Remove the Path variable from RealFSDirIter. NFC.
Author: ributzka Date: Fri Mar 10 15:23:29 2017 New Revision: 297511 URL: http://llvm.org/viewvc/llvm-project?rev=297511&view=rev Log: [VFS] Remove the Path variable from RealFSDirIter. NFC. This variable is set, but never used. Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=297511&r1=297510&r2=297511&view=diff == --- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original) +++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Fri Mar 10 15:23:29 2017 @@ -238,11 +238,9 @@ IntrusiveRefCntPtr vfs::getR namespace { class RealFSDirIter : public clang::vfs::detail::DirIterImpl { - std::string Path; llvm::sys::fs::directory_iterator Iter; public: - RealFSDirIter(const Twine &_Path, std::error_code &EC) - : Path(_Path.str()), Iter(Path, EC) { + RealFSDirIter(const Twine &Path, std::error_code &EC) : Iter(Path, EC) { if (!EC && Iter != llvm::sys::fs::directory_iterator()) { llvm::sys::fs::file_status S; EC = Iter->status(S); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r297510 - [VFS] Ignore broken symlinks in the directory iterator.
Author: ributzka Date: Fri Mar 10 15:23:27 2017 New Revision: 297510 URL: http://llvm.org/viewvc/llvm-project?rev=297510&view=rev Log: [VFS] Ignore broken symlinks in the directory iterator. The VFS directory iterator and recursive directory iterator behave differently from the LLVM counterparts. Once the VFS iterators hit a broken symlink they immediately abort. The LLVM counterparts allow to recover from this issue by clearing the error code and skipping to the next entry. This change adds the same functionality to the VFS iterators. There should be no change in current behavior in the current CLANG source base, because all clients have loop exit conditions that also check the error code. This fixes rdar://problem/30934619. Differential Revision: https://reviews.llvm.org/D30768 Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h cfe/trunk/lib/Basic/VirtualFileSystem.cpp cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=297510&r1=297509&r2=297510&view=diff == --- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original) +++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Fri Mar 10 15:23:27 2017 @@ -161,7 +161,7 @@ public: directory_iterator &increment(std::error_code &EC) { assert(Impl && "attempting to increment past end"); EC = Impl->increment(); -if (EC || !Impl->CurrentEntry.isStatusKnown()) +if (!Impl->CurrentEntry.isStatusKnown()) Impl.reset(); // Normalize the end iterator to Impl == nullptr. return *this; } Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=297510&r1=297509&r2=297510&view=diff == --- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original) +++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Fri Mar 10 15:23:27 2017 @@ -246,8 +246,7 @@ public: if (!EC && Iter != llvm::sys::fs::directory_iterator()) { llvm::sys::fs::file_status S; EC = Iter->status(S); - if (!EC) -CurrentEntry = Status::copyWithNewName(S, Iter->path()); + CurrentEntry = Status::copyWithNewName(S, Iter->path()); } } @@ -1858,7 +1857,7 @@ vfs::recursive_directory_iterator::recur std::error_code &EC) : FS(&FS_) { directory_iterator I = FS->dir_begin(Path, EC); - if (!EC && I != directory_iterator()) { + if (I != directory_iterator()) { State = std::make_shared(); State->push(I); } @@ -1871,8 +1870,6 @@ recursive_directory_iterator::increment( vfs::directory_iterator End; if (State->top()->isDirectory()) { vfs::directory_iterator I = FS->dir_begin(State->top()->getName(), EC); -if (EC) - return *this; if (I != End) { State->push(I); return *this; Modified: cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp?rev=297510&r1=297509&r2=297510&view=diff == --- cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp (original) +++ cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp Fri Mar 10 15:23:27 2017 @@ -305,6 +305,22 @@ struct ScopedDir { } operator StringRef() { return Path.str(); } }; + +struct ScopedLink { + SmallString<128> Path; + ScopedLink(const Twine &To, const Twine &From) { +Path = From.str(); +std::error_code EC = sys::fs::create_link(To, From); +if (EC) + Path = ""; +EXPECT_FALSE(EC); + } + ~ScopedLink() { +if (Path != "") + EXPECT_FALSE(llvm::sys::fs::remove(Path.str())); + } + operator StringRef() { return Path.str(); } +}; } // end anonymous namespace TEST(VirtualFileSystemTest, BasicRealFSIteration) { @@ -334,6 +350,35 @@ TEST(VirtualFileSystemTest, BasicRealFSI EXPECT_EQ(vfs::directory_iterator(), I); } +TEST(VirtualFileSystemTest, BrokenSymlinkRealFSIteration) { + ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/ true); + IntrusiveRefCntPtr FS = vfs::getRealFileSystem(); + + ScopedLink _a("no_such_file", TestDirectory + "/a"); + ScopedDir _b(TestDirectory + "/b"); + ScopedLink _c("no_such_file", TestDirectory + "/c"); + + std::error_code EC; + vfs::directory_iterator I = FS->dir_begin(Twine(TestDirectory), EC); + EXPECT_TRUE(EC); + EXPECT_NE(vfs::directory_iterator(), I); + EC = std::error_code(); + EXPECT_TRUE(I->getName() == _a); + I.increment(EC); + EXPECT_FALSE(EC); + EXPECT_NE(vfs::directory_iterator(), I); + EXPECT_TRUE(I->getName() == _b); + I.increment(EC); + EXPECT_TRUE(EC); + EXPECT_NE(vfs::directory_iterator(), I); + EC = std::e
[PATCH] D30775: [coroutines] Refactor SuspendExpr to create just one OpaqueValue (almost NFC)
EricWF accepted this revision. EricWF added a comment. This revision is now accepted and ready to land. This LGTM. https://reviews.llvm.org/D30775 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D30768: [PATCH][VFS] Ignore broken symlinks in the directory iterator.
Nevermind, I see you've fixed. Thanks :) On Fri, Mar 10, 2017 at 3:21 PM Eric Christopher wrote: > Looks like this is failing on a number of bots... > > On Fri, Mar 10, 2017 at 1:37 PM Juergen Ributzka via Phabricator via > cfe-commits wrote: > > ributzka added a comment. > > Thanks Bruno. Committed in r297510. > > > Repository: > rL LLVM > > https://reviews.llvm.org/D30768 > > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30776: [coroutines] Fix diagnostics depending on the first coroutine statement.
EricWF added a comment. In https://reviews.llvm.org/D30776#697258, @GorNishanov wrote: > In https://reviews.llvm.org/D30776#697233, @EricWF wrote: > > > Good to know. I'll update this tomorrow. > > > Well, that is just the thought. Possibly we can check for the types of > await_ready and await_suspend in BuildResolvedCoawaitExpr. Then, we don't > have to keep the vector of await/yield-expressions. I guess it depends on when we want the diagnostics to be issued. And I think emitting them as they are built makes the most sense. If we attempt to issue the diagnostics at the end of the body it may be too late. Do you still want me to put the vector back in now or when the need actually arises? https://reviews.llvm.org/D30776 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D30768: [PATCH][VFS] Ignore broken symlinks in the directory iterator.
Looks like this is failing on a number of bots... On Fri, Mar 10, 2017 at 1:37 PM Juergen Ributzka via Phabricator via cfe-commits wrote: > ributzka added a comment. > > Thanks Bruno. Committed in r297510. > > > Repository: > rL LLVM > > https://reviews.llvm.org/D30768 > > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r297530 - clang/test/SemaOpenCL/overload_addrspace_resolution.cl: Appease MS mangler to specify triple=x86_64-unknown.
Author: chapuni Date: Fri Mar 10 17:06:34 2017 New Revision: 297530 URL: http://llvm.org/viewvc/llvm-project?rev=297530&view=rev Log: clang/test/SemaOpenCL/overload_addrspace_resolution.cl: Appease MS mangler to specify triple=x86_64-unknown. Modified: cfe/trunk/test/SemaOpenCL/overload_addrspace_resolution.cl Modified: cfe/trunk/test/SemaOpenCL/overload_addrspace_resolution.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/overload_addrspace_resolution.cl?rev=297530&r1=297529&r2=297530&view=diff == --- cfe/trunk/test/SemaOpenCL/overload_addrspace_resolution.cl (original) +++ cfe/trunk/test/SemaOpenCL/overload_addrspace_resolution.cl Fri Mar 10 17:06:34 2017 @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -cl-std=CL2.0 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -cl-std=CL2.0 -emit-llvm -o - -triple x86_64-unknown-unknown %s | FileCheck %s void __attribute__((overloadable)) foo(global int *a, global int *b); void __attribute__((overloadable)) foo(generic int *a, generic int *b); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30837: [libcxx] Support for shared_ptr
EricWF requested changes to this revision. EricWF added a comment. This revision now requires changes to proceed. We can't just use an arbitrary allocator type for a number of reasons: - You just changed the type of the control block. That's ABI breaking. - `allocator` allocates ints, nothing else. - It may mean we don't select a valid user specialization of `allocator`. I'll play around to see if I can come up with another path forward to fix this. https://reviews.llvm.org/D30837 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30848: Implement DR 373 "Lookup on namespace qualified name in using-directive"
mgehre updated this revision to Diff 91424. mgehre added a comment. Added clang version to test and regenerated cxx_dr_status.html https://reviews.llvm.org/D30848 Files: include/clang/Parse/Parser.h include/clang/Sema/Sema.h lib/Parse/ParseDeclCXX.cpp lib/Parse/ParseExprCXX.cpp lib/Sema/SemaCXXScopeSpec.cpp test/CXX/drs/dr3xx.cpp www/cxx_dr_status.html Index: www/cxx_dr_status.html === --- www/cxx_dr_status.html +++ www/cxx_dr_status.html @@ -2279,7 +2279,7 @@ http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#373";>373 C++11 Lookup on namespace qualified name in using-directive -No +SVN http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#374";>374 Index: test/CXX/drs/dr3xx.cpp === --- test/CXX/drs/dr3xx.cpp +++ test/CXX/drs/dr3xx.cpp @@ -908,15 +908,14 @@ } } -namespace dr373 { // dr373: no - // FIXME: This is valid. - namespace X { int dr373; } // expected-note 2{{here}} +namespace dr373 { // dr373: 5 + namespace X { int dr373; } struct dr373 { // expected-note {{here}} void f() { - using namespace dr373::X; // expected-error {{no namespace named 'X' in 'dr373::dr373'}} + using namespace dr373::X; int k = dr373; // expected-error {{does not refer to a value}} - namespace Y = dr373::X; // expected-error {{no namespace named 'X' in 'dr373::dr373'}} + namespace Y = dr373::X; k = Y::dr373; } }; Index: lib/Sema/SemaCXXScopeSpec.cpp === --- lib/Sema/SemaCXXScopeSpec.cpp +++ lib/Sema/SemaCXXScopeSpec.cpp @@ -461,6 +461,7 @@ ///are allowed. The bool value pointed by this parameter is set to /// 'true' if the identifier is treated as if it was followed by ':', ///not '::'. +/// \param OnlyNamespace If true, only considers namespaces in lookup. /// /// This routine differs only slightly from ActOnCXXNestedNameSpecifier, in /// that it contains an extra parameter \p ScopeLookupResult, which provides @@ -473,15 +474,15 @@ /// scope if it *knows* that the result is correct. It should not return in a /// dependent context, for example. Nor will it extend \p SS with the scope /// specifier. -bool Sema::BuildCXXNestedNameSpecifier(Scope *S, - NestedNameSpecInfo &IdInfo, - bool EnteringContext, - CXXScopeSpec &SS, +bool Sema::BuildCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo, + bool EnteringContext, CXXScopeSpec &SS, NamedDecl *ScopeLookupResult, bool ErrorRecoveryLookup, - bool *IsCorrectedToColon) { + bool *IsCorrectedToColon, + bool OnlyNamespace) { LookupResult Found(*this, IdInfo.Identifier, IdInfo.IdentifierLoc, - LookupNestedNameSpecifierName); + OnlyNamespace ? LookupNamespaceName + : LookupNestedNameSpecifierName); QualType ObjectType = GetTypeFromParser(IdInfo.ObjectType); // Determine where to perform name lookup @@ -819,19 +820,17 @@ return true; } -bool Sema::ActOnCXXNestedNameSpecifier(Scope *S, - NestedNameSpecInfo &IdInfo, - bool EnteringContext, - CXXScopeSpec &SS, +bool Sema::ActOnCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo, + bool EnteringContext, CXXScopeSpec &SS, bool ErrorRecoveryLookup, - bool *IsCorrectedToColon) { + bool *IsCorrectedToColon, + bool OnlyNamespace) { if (SS.isInvalid()) return true; - return BuildCXXNestedNameSpecifier(S, IdInfo, - EnteringContext, SS, + return BuildCXXNestedNameSpecifier(S, IdInfo, EnteringContext, SS, /*ScopeLookupResult=*/nullptr, false, - IsCorrectedToColon); + IsCorrectedToColon, OnlyNamespace); } bool Sema::ActOnCXXNestedNameSpecifierDecltype(CXXScopeSpec &SS, Index: lib/Parse/ParseExprCXX.cpp === --- lib/Parse/ParseExprCXX.cpp +++ lib/Parse/ParseExprCXX.cpp @@ -141,13 +141,16 @@ /// filled in with the leading identifier in the last component of the /// nested-name-specifier, if any. /// +/// \param OnlyNamespace If true,
[PATCH] D30593: Add correct "-isystem"/"-isysroot" warning handling to static analysis' BugReporter.
kmarshall added a comment. NP, Anna. I filed a number of bugs for the false positives: - https://bugs.llvm.org/show_bug.cgi?id=32229 - https://bugs.llvm.org/show_bug.cgi?id=32232 - https://bugs.llvm.org/show_bug.cgi?id=32233 - https://bugs.llvm.org/show_bug.cgi?id=32234 - https://bugs.llvm.org/show_bug.cgi?id=32235 Repository: rL LLVM https://reviews.llvm.org/D30593 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30848: Implement DR 373 "Lookup on namespace qualified name in using-directive"
rsmith added inline comments. Comment at: test/CXX/drs/dr3xx.cpp:911 -namespace dr373 { // dr373: no - // FIXME: This is valid. - namespace X { int dr373; } // expected-note 2{{here}} +namespace dr373 { // dr373: yes + namespace X { int dr373; } This should say "dr373: 5" to indicate the first version of Clang with the fix. Comment at: www/cxx_dr_status.html:2282 Lookup on namespace qualified name in using-directive -No +Yes ... and this file should be regenerated so it lists the version. https://reviews.llvm.org/D30848 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30848: Implement DR 373 "Lookup on namespace qualified name in using-directive"
mgehre updated this revision to Diff 91418. mgehre added a comment. clang-format https://reviews.llvm.org/D30848 Files: include/clang/Parse/Parser.h include/clang/Sema/Sema.h lib/Parse/ParseDeclCXX.cpp lib/Parse/ParseExprCXX.cpp lib/Sema/SemaCXXScopeSpec.cpp test/CXX/drs/dr3xx.cpp www/cxx_dr_status.html Index: www/cxx_dr_status.html === --- www/cxx_dr_status.html +++ www/cxx_dr_status.html @@ -2279,7 +2279,7 @@ http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#373";>373 C++11 Lookup on namespace qualified name in using-directive -No +Yes http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#374";>374 Index: test/CXX/drs/dr3xx.cpp === --- test/CXX/drs/dr3xx.cpp +++ test/CXX/drs/dr3xx.cpp @@ -908,15 +908,14 @@ } } -namespace dr373 { // dr373: no - // FIXME: This is valid. - namespace X { int dr373; } // expected-note 2{{here}} +namespace dr373 { // dr373: yes + namespace X { int dr373; } struct dr373 { // expected-note {{here}} void f() { - using namespace dr373::X; // expected-error {{no namespace named 'X' in 'dr373::dr373'}} + using namespace dr373::X; int k = dr373; // expected-error {{does not refer to a value}} - namespace Y = dr373::X; // expected-error {{no namespace named 'X' in 'dr373::dr373'}} + namespace Y = dr373::X; k = Y::dr373; } }; Index: lib/Sema/SemaCXXScopeSpec.cpp === --- lib/Sema/SemaCXXScopeSpec.cpp +++ lib/Sema/SemaCXXScopeSpec.cpp @@ -461,6 +461,7 @@ ///are allowed. The bool value pointed by this parameter is set to /// 'true' if the identifier is treated as if it was followed by ':', ///not '::'. +/// \param OnlyNamespace If true, only considers namespaces in lookup. /// /// This routine differs only slightly from ActOnCXXNestedNameSpecifier, in /// that it contains an extra parameter \p ScopeLookupResult, which provides @@ -473,15 +474,15 @@ /// scope if it *knows* that the result is correct. It should not return in a /// dependent context, for example. Nor will it extend \p SS with the scope /// specifier. -bool Sema::BuildCXXNestedNameSpecifier(Scope *S, - NestedNameSpecInfo &IdInfo, - bool EnteringContext, - CXXScopeSpec &SS, +bool Sema::BuildCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo, + bool EnteringContext, CXXScopeSpec &SS, NamedDecl *ScopeLookupResult, bool ErrorRecoveryLookup, - bool *IsCorrectedToColon) { + bool *IsCorrectedToColon, + bool OnlyNamespace) { LookupResult Found(*this, IdInfo.Identifier, IdInfo.IdentifierLoc, - LookupNestedNameSpecifierName); + OnlyNamespace ? LookupNamespaceName + : LookupNestedNameSpecifierName); QualType ObjectType = GetTypeFromParser(IdInfo.ObjectType); // Determine where to perform name lookup @@ -819,19 +820,17 @@ return true; } -bool Sema::ActOnCXXNestedNameSpecifier(Scope *S, - NestedNameSpecInfo &IdInfo, - bool EnteringContext, - CXXScopeSpec &SS, +bool Sema::ActOnCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo, + bool EnteringContext, CXXScopeSpec &SS, bool ErrorRecoveryLookup, - bool *IsCorrectedToColon) { + bool *IsCorrectedToColon, + bool OnlyNamespace) { if (SS.isInvalid()) return true; - return BuildCXXNestedNameSpecifier(S, IdInfo, - EnteringContext, SS, + return BuildCXXNestedNameSpecifier(S, IdInfo, EnteringContext, SS, /*ScopeLookupResult=*/nullptr, false, - IsCorrectedToColon); + IsCorrectedToColon, OnlyNamespace); } bool Sema::ActOnCXXNestedNameSpecifierDecltype(CXXScopeSpec &SS, Index: lib/Parse/ParseExprCXX.cpp === --- lib/Parse/ParseExprCXX.cpp +++ lib/Parse/ParseExprCXX.cpp @@ -141,13 +141,16 @@ /// filled in with the leading identifier in the last component of the /// nested-name-specifier, if any. /// +/// \param OnlyNamespace If true, only considers namespaces in lookup. +/// /// \
[PATCH] D30848: Implement DR 373 "Lookup on namespace qualified name in using-directive"
mgehre created this revision. 3.4.6 [basic.lookup.udir] paragraph 1: In a using-directive or namespace-alias-definition, during the lookup for a namespace-name or for a name in a nested-name-specifier, only namespace names are considered. https://reviews.llvm.org/D30848 Files: include/clang/Parse/Parser.h include/clang/Sema/Sema.h lib/Parse/ParseDeclCXX.cpp lib/Parse/ParseExprCXX.cpp lib/Sema/SemaCXXScopeSpec.cpp test/CXX/drs/dr3xx.cpp www/cxx_dr_status.html Index: www/cxx_dr_status.html === --- www/cxx_dr_status.html +++ www/cxx_dr_status.html @@ -2279,7 +2279,7 @@ http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#373";>373 C++11 Lookup on namespace qualified name in using-directive -No +Yes http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#374";>374 Index: test/CXX/drs/dr3xx.cpp === --- test/CXX/drs/dr3xx.cpp +++ test/CXX/drs/dr3xx.cpp @@ -908,15 +908,14 @@ } } -namespace dr373 { // dr373: no - // FIXME: This is valid. - namespace X { int dr373; } // expected-note 2{{here}} +namespace dr373 { // dr373: yes + namespace X { int dr373; } struct dr373 { // expected-note {{here}} void f() { - using namespace dr373::X; // expected-error {{no namespace named 'X' in 'dr373::dr373'}} + using namespace dr373::X; int k = dr373; // expected-error {{does not refer to a value}} - namespace Y = dr373::X; // expected-error {{no namespace named 'X' in 'dr373::dr373'}} + namespace Y = dr373::X; k = Y::dr373; } }; Index: lib/Sema/SemaCXXScopeSpec.cpp === --- lib/Sema/SemaCXXScopeSpec.cpp +++ lib/Sema/SemaCXXScopeSpec.cpp @@ -461,6 +461,7 @@ ///are allowed. The bool value pointed by this parameter is set to /// 'true' if the identifier is treated as if it was followed by ':', ///not '::'. +/// \param OnlyNamespace If true, only considers namespaces in lookup. /// /// This routine differs only slightly from ActOnCXXNestedNameSpecifier, in /// that it contains an extra parameter \p ScopeLookupResult, which provides @@ -479,9 +480,15 @@ CXXScopeSpec &SS, NamedDecl *ScopeLookupResult, bool ErrorRecoveryLookup, - bool *IsCorrectedToColon) { + bool *IsCorrectedToColon, + bool OnlyNamespace) { + + Sema::LookupNameKind LNameKind = LookupNestedNameSpecifierName; + if (OnlyNamespace) +LNameKind = LookupNamespaceName; + LookupResult Found(*this, IdInfo.Identifier, IdInfo.IdentifierLoc, - LookupNestedNameSpecifierName); + LNameKind); QualType ObjectType = GetTypeFromParser(IdInfo.ObjectType); // Determine where to perform name lookup @@ -824,14 +831,16 @@ bool EnteringContext, CXXScopeSpec &SS, bool ErrorRecoveryLookup, - bool *IsCorrectedToColon) { + bool *IsCorrectedToColon, + bool OnlyNamespace) { if (SS.isInvalid()) return true; return BuildCXXNestedNameSpecifier(S, IdInfo, EnteringContext, SS, /*ScopeLookupResult=*/nullptr, false, - IsCorrectedToColon); + IsCorrectedToColon, + OnlyNamespace); } bool Sema::ActOnCXXNestedNameSpecifierDecltype(CXXScopeSpec &SS, Index: lib/Parse/ParseExprCXX.cpp === --- lib/Parse/ParseExprCXX.cpp +++ lib/Parse/ParseExprCXX.cpp @@ -141,13 +141,16 @@ /// filled in with the leading identifier in the last component of the /// nested-name-specifier, if any. /// +/// \param OnlyNamespace If true, only considers namespaces in lookup. +/// /// \returns true if there was an error parsing a scope specifier bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS, ParsedType ObjectType, bool EnteringContext, bool *MayBePseudoDestructor, bool IsTypename, -IdentifierInfo **LastII) { +IdentifierInfo **LastII, +bool OnlyNamespace) { assert(getLangOpts().CPlusPlus && "Call si
[PATCH] D30837: [libcxx] Support for shared_ptr
Quuxplusone added a comment. I notice that the Standard implies that std::unique_ptr will work only with *object types* T, and yet the "object" wording is missing from shared_ptr. > A unique pointer is an object that owns another *object* and manages that > other *object* through a pointer. > The shared_ptr class template stores a *pointer*, usually obtained via new. > shared_ptr implements semantics of shared ownership; the last remaining owner > of the pointer is responsible for destroying the object, *or otherwise > releasing the resources associated with the stored pointer.* So it does seem like shared_ptr should work and should store a T(*)(). And it does seem that unique_ptr should continue to not-work... but maybe there's a useful vendor extension or standards proposal to be made in that area. Comment at: include/memory:4209 { -typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; +typedef __shared_ptr_emplace<_Tp, allocator > _CntrlBlk; typedef allocator<_CntrlBlk> _Alloc2; IIUC, you don't need to touch make_shared. I doubt these changes are truly harmful, but I don't understand what meaning we're trying to assign to things like auto a = std::make_shared(); auto b = std::make_shared(myFunction); It seems like the effect of this change is just to mess with anyone who's explicitly specializing std::allocator to make its ::rebind member do something wacky. In which case I'd say they've got it coming to them... but the effect of this change doesn't seem relevant to the purpose described in your commit message. :) Comment at: test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp:49 +struct Result {}; +void resultDeletor(Result (*)()) {} +Result theFunction() { return Result(); } Could you plausibly make this void resultDeleter(Result (*f)()) { assert(f == theFunction); } for extra sanity checking? For super-duper checking, touch a global variable in `resultDeleter` so that you can verify that the deleter was actually called. This might reasonably be perceived as overkill. :) Comment at: test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp:72 +{ // https://bugs.llvm.org/show_bug.cgi?id=27566 + std::shared_ptr x(&theFunction, &resultDeletor); +} Presumably this should also compile without the explicit `&`s, right? Might be worth adding std::shared_ptr y(theFunction, resultDeleter); in addition to your existing test case, just to make sure that omitting the `&` doesn't mess up the template deduction somehow. IIUC, it would never make sense to write something like auto z = std::make_shared(theFunction); so that part doesn't need testing, right? https://reviews.llvm.org/D30837 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26953: clang-format: handle formatting on constexpr if
outcoldman added a comment. The actual problem is with that clang-format does not know anything about c++17 features, because it does not set it in lang options. Not sure if that will fix constexpr problem as well, but I could solve some other problems with tools/clang ✓ 13:45:12 ╰─ svn diff Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp (revision 297506) +++ lib/Format/Format.cpp (working copy) @@ -1893,6 +1893,7 @@ LangOpts.CPlusPlus = 1; LangOpts.CPlusPlus11 = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1; LangOpts.CPlusPlus14 = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1; + LangOpts.CPlusPlus1z = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1; LangOpts.LineComment = 1; bool AlternativeOperators = Style.IsCpp(); LangOpts.CXXOperatorNames = AlternativeOperators ? 1 : 0; https://reviews.llvm.org/D26953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30845: Fix array sizes where address space is not yet known
kzhuravl added a comment. I am not sure if this is the right way to fix it. https://reviews.llvm.org/D30845 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30845: Fix array sizes where address space is not yet known
kzhuravl created this revision. Herald added a subscriber: wdng. For variables in generic address spaces, for example: unsigned char V[6442450944]; ... the address space is not yet known when we get into *getConstantArrayType*, it is 0. AMDGCN target's address space 0 has 32 bits pointers, so when we call *getPointerWidth* with 0, the array size is trimmed to 32 bits, which is not right. https://reviews.llvm.org/D30845 Files: include/clang/Basic/TargetInfo.h lib/AST/ASTContext.cpp lib/Basic/Targets.cpp test/CodeGenOpenCL/amdgcn-large-globals.cl Index: test/CodeGenOpenCL/amdgcn-large-globals.cl === --- test/CodeGenOpenCL/amdgcn-large-globals.cl +++ test/CodeGenOpenCL/amdgcn-large-globals.cl @@ -0,0 +1,12 @@ +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -cl-std=CL2.0 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s + +// CHECK: @One = common local_unnamed_addr addrspace(1) global [6442450944 x i8] zeroinitializer, align 1 +unsigned char One[6442450944]; +// CHECK: @Two = common local_unnamed_addr addrspace(1) global [6442450944 x i32] zeroinitializer, align 4 +global unsigned int Two[6442450944]; + +kernel void large_globals(unsigned int id) { + One[id] = id; + Two[id + 1] = id + 1; +} Index: lib/Basic/Targets.cpp === --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -2084,6 +2084,10 @@ } } + uint64_t getPreferredPointerWidth(unsigned AddrSpace) const override { +return 64; + } + uint64_t getMaxPointerWidth() const override { return getTriple().getArch() == llvm::Triple::amdgcn ? 64 : 32; } Index: lib/AST/ASTContext.cpp === --- lib/AST/ASTContext.cpp +++ lib/AST/ASTContext.cpp @@ -2692,8 +2692,8 @@ // Convert the array size into a canonical width matching the pointer size for // the target. llvm::APInt ArySize(ArySizeIn); - ArySize = -ArySize.zextOrTrunc(Target->getPointerWidth(getTargetAddressSpace(EltTy))); + ArySize = ArySize.zextOrTrunc( + Target->getPreferredPointerWidth(getTargetAddressSpace(EltTy))); llvm::FoldingSetNodeID ID; ConstantArrayType::Profile(ID, EltTy, ArySize, ASM, IndexTypeQuals); Index: include/clang/Basic/TargetInfo.h === --- include/clang/Basic/TargetInfo.h +++ include/clang/Basic/TargetInfo.h @@ -296,6 +296,13 @@ return AddrSpace == 0 ? PointerAlign : getPointerAlignV(AddrSpace); } + /// \brief Return the "preferred" width of pointers on this target, for the + /// specified address space. This can be different from "getPointerWidth" in + /// cases where the final address space is not yet known. + virtual uint64_t getPreferredPointerWidth(unsigned AddrSpace) const { +return getPointerWidth(AddrSpace); + } + /// \brief Return the maximum width of pointers on this target. virtual uint64_t getMaxPointerWidth() const { return PointerWidth; Index: test/CodeGenOpenCL/amdgcn-large-globals.cl === --- test/CodeGenOpenCL/amdgcn-large-globals.cl +++ test/CodeGenOpenCL/amdgcn-large-globals.cl @@ -0,0 +1,12 @@ +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -cl-std=CL2.0 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s + +// CHECK: @One = common local_unnamed_addr addrspace(1) global [6442450944 x i8] zeroinitializer, align 1 +unsigned char One[6442450944]; +// CHECK: @Two = common local_unnamed_addr addrspace(1) global [6442450944 x i32] zeroinitializer, align 4 +global unsigned int Two[6442450944]; + +kernel void large_globals(unsigned int id) { + One[id] = id; + Two[id + 1] = id + 1; +} Index: lib/Basic/Targets.cpp === --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -2084,6 +2084,10 @@ } } + uint64_t getPreferredPointerWidth(unsigned AddrSpace) const override { +return 64; + } + uint64_t getMaxPointerWidth() const override { return getTriple().getArch() == llvm::Triple::amdgcn ? 64 : 32; } Index: lib/AST/ASTContext.cpp === --- lib/AST/ASTContext.cpp +++ lib/AST/ASTContext.cpp @@ -2692,8 +2692,8 @@ // Convert the array size into a canonical width matching the pointer size for // the target. llvm::APInt ArySize(ArySizeIn); - ArySize = -ArySize.zextOrTrunc(Target->getPointerWidth(getTargetAddressSpace(EltTy))); + ArySize = ArySize.zextOrTrunc( + Target->getPreferredPointerWidth(getTargetAddressSpace(EltTy))); llvm::FoldingSetNodeID ID; ConstantArrayType::Profile(ID, EltTy, ArySize, ASM, IndexTypeQuals); Index: include/clang/Basic/TargetInfo.h === ---
[PATCH] D30768: [PATCH][VFS] Ignore broken symlinks in the directory iterator.
ributzka added a comment. Thanks Bruno. Committed in r297510. Repository: rL LLVM https://reviews.llvm.org/D30768 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30768: [PATCH][VFS] Ignore broken symlinks in the directory iterator.
This revision was automatically updated to reflect the committed changes. Closed by commit rL297510: [VFS] Ignore broken symlinks in the directory iterator. (authored by ributzka). Changed prior to commit: https://reviews.llvm.org/D30768?vs=91371&id=91403#toc Repository: rL LLVM https://reviews.llvm.org/D30768 Files: cfe/trunk/include/clang/Basic/VirtualFileSystem.h cfe/trunk/lib/Basic/VirtualFileSystem.cpp cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp Index: cfe/trunk/include/clang/Basic/VirtualFileSystem.h === --- cfe/trunk/include/clang/Basic/VirtualFileSystem.h +++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h @@ -161,7 +161,7 @@ directory_iterator &increment(std::error_code &EC) { assert(Impl && "attempting to increment past end"); EC = Impl->increment(); -if (EC || !Impl->CurrentEntry.isStatusKnown()) +if (!Impl->CurrentEntry.isStatusKnown()) Impl.reset(); // Normalize the end iterator to Impl == nullptr. return *this; } Index: cfe/trunk/lib/Basic/VirtualFileSystem.cpp === --- cfe/trunk/lib/Basic/VirtualFileSystem.cpp +++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp @@ -246,8 +246,7 @@ if (!EC && Iter != llvm::sys::fs::directory_iterator()) { llvm::sys::fs::file_status S; EC = Iter->status(S); - if (!EC) -CurrentEntry = Status::copyWithNewName(S, Iter->path()); + CurrentEntry = Status::copyWithNewName(S, Iter->path()); } } @@ -1858,7 +1857,7 @@ std::error_code &EC) : FS(&FS_) { directory_iterator I = FS->dir_begin(Path, EC); - if (!EC && I != directory_iterator()) { + if (I != directory_iterator()) { State = std::make_shared(); State->push(I); } @@ -1871,8 +1870,6 @@ vfs::directory_iterator End; if (State->top()->isDirectory()) { vfs::directory_iterator I = FS->dir_begin(State->top()->getName(), EC); -if (EC) - return *this; if (I != End) { State->push(I); return *this; Index: cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp === --- cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp +++ cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp @@ -305,6 +305,22 @@ } operator StringRef() { return Path.str(); } }; + +struct ScopedLink { + SmallString<128> Path; + ScopedLink(const Twine &To, const Twine &From) { +Path = From.str(); +std::error_code EC = sys::fs::create_link(To, From); +if (EC) + Path = ""; +EXPECT_FALSE(EC); + } + ~ScopedLink() { +if (Path != "") + EXPECT_FALSE(llvm::sys::fs::remove(Path.str())); + } + operator StringRef() { return Path.str(); } +}; } // end anonymous namespace TEST(VirtualFileSystemTest, BasicRealFSIteration) { @@ -334,6 +350,35 @@ EXPECT_EQ(vfs::directory_iterator(), I); } +TEST(VirtualFileSystemTest, BrokenSymlinkRealFSIteration) { + ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/ true); + IntrusiveRefCntPtr FS = vfs::getRealFileSystem(); + + ScopedLink _a("no_such_file", TestDirectory + "/a"); + ScopedDir _b(TestDirectory + "/b"); + ScopedLink _c("no_such_file", TestDirectory + "/c"); + + std::error_code EC; + vfs::directory_iterator I = FS->dir_begin(Twine(TestDirectory), EC); + EXPECT_TRUE(EC); + EXPECT_NE(vfs::directory_iterator(), I); + EC = std::error_code(); + EXPECT_TRUE(I->getName() == _a); + I.increment(EC); + EXPECT_FALSE(EC); + EXPECT_NE(vfs::directory_iterator(), I); + EXPECT_TRUE(I->getName() == _b); + I.increment(EC); + EXPECT_TRUE(EC); + EXPECT_NE(vfs::directory_iterator(), I); + EC = std::error_code(); + EXPECT_NE(vfs::directory_iterator(), I); + EXPECT_TRUE(I->getName() == _c); + I.increment(EC); + EXPECT_FALSE(EC); + EXPECT_EQ(vfs::directory_iterator(), I); +} + TEST(VirtualFileSystemTest, BasicRealFSRecursiveIteration) { ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/true); IntrusiveRefCntPtr FS = vfs::getRealFileSystem(); @@ -373,6 +418,44 @@ EXPECT_EQ(1, Counts[3]); // d } +TEST(VirtualFileSystemTest, BrokenSymlinkRealFSRecursiveIteration) { + ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/ true); + IntrusiveRefCntPtr FS = vfs::getRealFileSystem(); + + ScopedLink _a("no_such_file", TestDirectory + "/a"); + ScopedDir _b(TestDirectory + "/b"); + ScopedLink _ba("no_such_file", TestDirectory + "/b/a"); + ScopedDir _bb(TestDirectory + "/b/b"); + ScopedLink _bc("no_such_file", TestDirectory + "/b/c"); + ScopedLink _c("no_such_file", TestDirectory + "/c"); + ScopedDir _d(TestDirectory + "/d"); + ScopedDir _dd(TestDirectory + "/d/d"); + ScopedDir _ddd(TestDirectory + "/d/d/d"); + ScopedLink _e("no_such_file", TestDirectory + "/e"); + + std::vector Contents; + std::error_code EC; + for (vfs::recur
[PATCH] D30768: [PATCH][VFS] Ignore broken symlinks in the directory iterator.
bruno accepted this revision. bruno added inline comments. This revision is now accepted and ready to land. Comment at: lib/Basic/VirtualFileSystem.cpp:1873 vfs::directory_iterator I = FS->dir_begin(State->top()->getName(), EC); -if (EC) +if (EC && EC != std::errc::no_such_file_or_directory) return *this; ributzka wrote: > bruno wrote: > > Can you add a comment explaining why you are doing it? I would prefer if we > > reset the `EC` state here than having the callers ignoring `EC` results. > If we reset the EC here, then the caller won't know that there was an issue. > The idea is that we still want the caller to check EC. It should be up to the > caller to decide how to act on this particular error. > > I guess since the caller has to check for the error anyway I could even > remove this check completely and not check EC at all here. Right, this should be fine with the latest changes and per discussions offline. LGTM https://reviews.llvm.org/D30768 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r297468 - [OpenCL] Fix type compatibility check and generic AS mangling.
Hello Anastasia, Added test fails on one of our new builders: Failing Tests (1): Clang :: SemaOpenCL/overload_addrspace_resolution.cl http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/23/steps/test-check-all/logs/stdio Please have a look at it? Thanks Galina On Fri, Mar 10, 2017 at 7:23 AM, Anastasia Stulova via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: stulova > Date: Fri Mar 10 09:23:07 2017 > New Revision: 297468 > > URL: http://llvm.org/viewvc/llvm-project?rev=297468&view=rev > Log: > [OpenCL] Fix type compatibility check and generic AS mangling. > > 1. Reimplemented conditional operator so that it checks > compatibility of unqualified pointees of the 2nd and > the 3rd operands (C99, OpenCL v2.0 6.5.15). > > Define QualTypes compatibility for OpenCL as following: > >- corresponding types are compatible (C99 6.7.3) >- CVR-qualifiers are equal (C99 6.7.3) >- address spaces are equal (implementation defined) > > 2. Added generic address space to Itanium mangling. > > Review: D30037 > > Patch by Dmitry Borisenkov! > > > Added: > cfe/trunk/test/SemaOpenCL/overload_addrspace_resolution.cl > Modified: > cfe/trunk/lib/AST/ASTContext.cpp > cfe/trunk/lib/AST/ItaniumMangle.cpp > cfe/trunk/lib/Sema/SemaExpr.cpp > cfe/trunk/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl > > Modified: cfe/trunk/lib/AST/ASTContext.cpp > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ > ASTContext.cpp?rev=297468&r1=297467&r2=297468&view=diff > > == > --- cfe/trunk/lib/AST/ASTContext.cpp (original) > +++ cfe/trunk/lib/AST/ASTContext.cpp Fri Mar 10 09:23:07 2017 > @@ -8066,15 +8066,6 @@ QualType ASTContext::mergeTypes(QualType >Qualifiers LQuals = LHSCan.getLocalQualifiers(); >Qualifiers RQuals = RHSCan.getLocalQualifiers(); >if (LQuals != RQuals) { > -if (getLangOpts().OpenCL) { > - if (LHSCan.getUnqualifiedType() != RHSCan.getUnqualifiedType() || > - LQuals.getCVRQualifiers() != RQuals.getCVRQualifiers()) > -return QualType(); > - if (LQuals.isAddressSpaceSupersetOf(RQuals)) > -return LHS; > - if (RQuals.isAddressSpaceSupersetOf(LQuals)) > -return RHS; > -} > // If any of these qualifiers are different, we have a type > // mismatch. > if (LQuals.getCVRQualifiers() != RQuals.getCVRQualifiers() || > @@ -8200,6 +8191,20 @@ QualType ASTContext::mergeTypes(QualType >LHSPointee = LHSPointee.getUnqualifiedType(); >RHSPointee = RHSPointee.getUnqualifiedType(); > } > +if (getLangOpts().OpenCL) { > + Qualifiers LHSPteeQual = LHSPointee.getQualifiers(); > + Qualifiers RHSPteeQual = RHSPointee.getQualifiers(); > + // Blocks can't be an expression in a ternary operator (OpenCL v2.0 > + // 6.12.5) thus the following check is asymmetric. > + if (!LHSPteeQual.isAddressSpaceSupersetOf(RHSPteeQual)) > +return QualType(); > + LHSPteeQual.removeAddressSpace(); > + RHSPteeQual.removeAddressSpace(); > + LHSPointee = > + QualType(LHSPointee.getTypePtr(), > LHSPteeQual.getAsOpaqueValue()); > + RHSPointee = > + QualType(RHSPointee.getTypePtr(), > RHSPteeQual.getAsOpaqueValue()); > +} > QualType ResultType = mergeTypes(LHSPointee, RHSPointee, > OfBlockPointer, > Unqualified); > if (ResultType.isNull()) return QualType(); > > Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ > ItaniumMangle.cpp?rev=297468&r1=297467&r2=297468&view=diff > > == > --- cfe/trunk/lib/AST/ItaniumMangle.cpp (original) > +++ cfe/trunk/lib/AST/ItaniumMangle.cpp Fri Mar 10 09:23:07 2017 > @@ -2159,10 +2159,12 @@ void CXXNameMangler::mangleQualifiers(Qu > } else { >switch (AS) { >default: llvm_unreachable("Not a language specific address space"); > - // ::= "CL" [ "global" | "local" | "constant" ] > + // ::= "CL" [ "global" | "local" | "constant | > + //"generic" ] >case LangAS::opencl_global: ASString = "CLglobal"; break; >case LangAS::opencl_local:ASString = "CLlocal";break; >case LangAS::opencl_constant: ASString = "CLconstant"; break; > + case LangAS::opencl_generic: ASString = "CLgeneric"; break; >// ::= "CU" [ "device" | "constant" | "shared" ] >case LangAS::cuda_device: ASString = "CUdevice"; break; >case LangAS::cuda_constant: ASString = "CUconstant"; break; > > Modified: cfe/trunk/lib/Sema/SemaExpr.cpp > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/ > SemaExpr.cpp?rev=297468&r1=297467&r2=297468&view=diff > > ===
[PATCH] D27387: [libc++] Add a key function for bad_function_call
smeenai added a comment. Ping. https://reviews.llvm.org/D27387 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30837: [libcxx] Support for shared_ptr
erik.pilkington updated this revision to Diff 91385. erik.pilkington added a comment. This new patch replaces the allocator from `allocator` to `allocator`, I didn't realize `allocator` was deprecated. Thanks, Erik https://reviews.llvm.org/D30837 Files: include/memory test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp Index: test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp === --- test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp +++ test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp @@ -45,6 +45,9 @@ virtual ~Foo() = default; }; +struct Result {}; +void resultDeletor(Result (*)()) {} +Result theFunction() { return Result(); } int main() { @@ -65,7 +68,9 @@ std::shared_ptr p2 = std::make_shared(); assert(p2.get()); } - +{ // https://bugs.llvm.org/show_bug.cgi?id=27566 + std::shared_ptr x(&theFunction, &resultDeletor); +} #if TEST_STD_VER >= 11 nc = globalMemCounter.outstanding_new; { Index: include/memory === --- include/memory +++ include/memory @@ -3884,8 +3884,7 @@ } } -_LIBCPP_INLINE_VISIBILITY -void __enable_weak_this(const volatile void*, const volatile void*) _NOEXCEPT {} +_LIBCPP_INLINE_VISIBILITY void __enable_weak_this(...) _NOEXCEPT {} template friend class _LIBCPP_TEMPLATE_VIS shared_ptr; template friend class _LIBCPP_TEMPLATE_VIS weak_ptr; @@ -3916,8 +3915,8 @@ : __ptr_(__p) { unique_ptr<_Yp> __hold(__p); -typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; -__cntrl_ = new _CntrlBlk(__p, default_delete<_Yp>(), allocator<_Yp>()); +typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator > _CntrlBlk; +__cntrl_ = new _CntrlBlk(__p, default_delete<_Yp>(), allocator()); __hold.release(); __enable_weak_this(__p, __p); } @@ -3932,8 +3931,8 @@ try { #endif // _LIBCPP_NO_EXCEPTIONS -typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk; -__cntrl_ = new _CntrlBlk(__p, __d, allocator<_Yp>()); +typedef __shared_ptr_pointer<_Yp*, _Dp, allocator > _CntrlBlk; +__cntrl_ = new _CntrlBlk(__p, __d, allocator()); __enable_weak_this(__p, __p); #ifndef _LIBCPP_NO_EXCEPTIONS } @@ -3954,8 +3953,8 @@ try { #endif // _LIBCPP_NO_EXCEPTIONS -typedef __shared_ptr_pointer > _CntrlBlk; -__cntrl_ = new _CntrlBlk(__p, __d, allocator<_Tp>()); +typedef __shared_ptr_pointer > _CntrlBlk; +__cntrl_ = new _CntrlBlk(__p, __d, allocator()); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) @@ -4094,8 +4093,8 @@ typename enable_if::value, __nat>::type) : __ptr_(__r.get()) { -typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; -__cntrl_ = new _CntrlBlk(__r.get(), default_delete<_Yp>(), allocator<_Yp>()); +typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator > _CntrlBlk; +__cntrl_ = new _CntrlBlk(__r.get(), default_delete<_Yp>(), allocator()); __enable_weak_this(__r.get(), __r.get()); __r.release(); } @@ -4123,8 +4122,8 @@ else #endif { -typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk; -__cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), allocator<_Yp>()); +typedef __shared_ptr_pointer<_Yp*, _Dp, allocator > _CntrlBlk; +__cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), allocator()); __enable_weak_this(__r.get(), __r.get()); } __r.release(); @@ -4154,8 +4153,8 @@ { typedef __shared_ptr_pointer<_Yp*, reference_wrapper::type>, - allocator<_Yp> > _CntrlBlk; -__cntrl_ = new _CntrlBlk(__r.get(), ref(__r.get_deleter()), allocator<_Yp>()); + allocator > _CntrlBlk; +__cntrl_ = new _CntrlBlk(__r.get(), ref(__r.get_deleter()), allocator()); __enable_weak_this(__r.get(), __r.get()); } __r.release(); @@ -4168,12 +4167,13 @@ shared_ptr<_Tp> shared_ptr<_Tp>::make_shared(_Args&& ...__args) { -typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk; +typedef __shared_ptr_emplace<_Tp, allocator > _CntrlBlk; typedef allocator<_CntrlBlk> _A2; typedef __allocator_destructor<_A2> _D2; _A2 __a2; unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); -::new(__hold2.get()) _CntrlBlk(__a2, _VSTD::forward<_Args>(__args)...); +::new(__hold2.get()) _CntrlBlk(allocator(), +
[PATCH] D30283: [ubsan] Reduce alignment checking of C++ object pointers
vsk added a reviewer: rsmith. vsk added a comment. Ping. I appreciate that there are a lot of test changes to sift through here -- please let me know if I can make the patch easier to review in any way. https://reviews.llvm.org/D30283 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30841: [clang-tidy] readability-misleading-indentation: fix chained if
fgross created this revision. Herald added a subscriber: JDevlieghere. Fixed erroneously flagging of chained if statements when styled like this: if (cond) { } else if (cond) { } else { } https://reviews.llvm.org/D30841 Files: clang-tidy/readability/MisleadingIndentationCheck.cpp clang-tidy/readability/MisleadingIndentationCheck.h test/clang-tidy/readability-misleading-indentation.cpp Index: test/clang-tidy/readability-misleading-indentation.cpp === --- test/clang-tidy/readability-misleading-indentation.cpp +++ test/clang-tidy/readability-misleading-indentation.cpp @@ -76,5 +76,31 @@ { } + if(cond1) { + } + else if (cond2) { + } + else { + } + + if(cond1) { + } + else if (cond2) { + } + else { + } + // CHECK-MESSAGES: :[[@LINE-2]]:8: warning: different indentation for 'if' and corresponding 'else' [readability-misleading-indentation] + + if (cond1) { +if (cond1) { +} +else if (cond2) { +} +else { +} + } + else if (cond2) { + } + BLOCK } Index: clang-tidy/readability/MisleadingIndentationCheck.h === --- clang-tidy/readability/MisleadingIndentationCheck.h +++ clang-tidy/readability/MisleadingIndentationCheck.h @@ -11,6 +11,7 @@ #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_MISLEADING_INDENTATION_H #include "../ClangTidy.h" +#include namespace clang { namespace tidy { @@ -32,6 +33,10 @@ private: void danglingElseCheck(const SourceManager &SM, const IfStmt *If); void missingBracesCheck(const SourceManager &SM, const CompoundStmt *CStmt); + + /// Key: Chained If + /// Value: Preceding If + std::map ChainedIfs; }; } // namespace readability Index: clang-tidy/readability/MisleadingIndentationCheck.cpp === --- clang-tidy/readability/MisleadingIndentationCheck.cpp +++ clang-tidy/readability/MisleadingIndentationCheck.cpp @@ -25,10 +25,20 @@ if (IfLoc.isMacroID() || ElseLoc.isMacroID()) return; + if (const auto *ChainedIf = dyn_cast(If->getElse())) { +if (SM.getExpansionLineNumber(ElseLoc) == +SM.getExpansionLineNumber(ChainedIf->getIfLoc())) + ChainedIfs.emplace(ChainedIf, If); + } + if (SM.getExpansionLineNumber(If->getThen()->getLocEnd()) == SM.getExpansionLineNumber(ElseLoc)) return; + for (auto Iter = ChainedIfs.find(If); Iter != ChainedIfs.end(); + Iter = ChainedIfs.find(Iter->second)) +IfLoc = Iter->second->getIfLoc(); + if (SM.getExpansionColumnNumber(IfLoc) != SM.getExpansionColumnNumber(ElseLoc)) diag(ElseLoc, "different indentation for 'if' and corresponding 'else'"); Index: test/clang-tidy/readability-misleading-indentation.cpp === --- test/clang-tidy/readability-misleading-indentation.cpp +++ test/clang-tidy/readability-misleading-indentation.cpp @@ -76,5 +76,31 @@ { } + if(cond1) { + } + else if (cond2) { + } + else { + } + + if(cond1) { + } + else if (cond2) { + } + else { + } + // CHECK-MESSAGES: :[[@LINE-2]]:8: warning: different indentation for 'if' and corresponding 'else' [readability-misleading-indentation] + + if (cond1) { +if (cond1) { +} +else if (cond2) { +} +else { +} + } + else if (cond2) { + } + BLOCK } Index: clang-tidy/readability/MisleadingIndentationCheck.h === --- clang-tidy/readability/MisleadingIndentationCheck.h +++ clang-tidy/readability/MisleadingIndentationCheck.h @@ -11,6 +11,7 @@ #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_MISLEADING_INDENTATION_H #include "../ClangTidy.h" +#include namespace clang { namespace tidy { @@ -32,6 +33,10 @@ private: void danglingElseCheck(const SourceManager &SM, const IfStmt *If); void missingBracesCheck(const SourceManager &SM, const CompoundStmt *CStmt); + + /// Key: Chained If + /// Value: Preceding If + std::map ChainedIfs; }; } // namespace readability Index: clang-tidy/readability/MisleadingIndentationCheck.cpp === --- clang-tidy/readability/MisleadingIndentationCheck.cpp +++ clang-tidy/readability/MisleadingIndentationCheck.cpp @@ -25,10 +25,20 @@ if (IfLoc.isMacroID() || ElseLoc.isMacroID()) return; + if (const auto *ChainedIf = dyn_cast(If->getElse())) { +if (SM.getExpansionLineNumber(ElseLoc) == +SM.getExpansionLineNumber(ChainedIf->getIfLoc())) + ChainedIfs.emplace(ChainedIf, If); + } + if (SM.getExpansionLineNumber(If->getThen()->getLocEnd()) == SM.getExpansionLineNumber(ElseLoc)) return; + for (auto Iter = ChainedIfs.find(If); Iter != ChainedIfs.end(); + Iter = ChainedIfs.find(Iter->second)) +IfLoc = Iter->second->
r297497 - Attempt to fix Windows buildbot.
Author: gkistanova Date: Fri Mar 10 13:34:15 2017 New Revision: 297497 URL: http://llvm.org/viewvc/llvm-project?rev=297497&view=rev Log: Attempt to fix Windows buildbot. Modified: cfe/trunk/test/Modules/dependency-dump-dependent-module.m cfe/trunk/test/Modules/dependency-dump.m Modified: cfe/trunk/test/Modules/dependency-dump-dependent-module.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/dependency-dump-dependent-module.m?rev=297497&r1=297496&r2=297497&view=diff == --- cfe/trunk/test/Modules/dependency-dump-dependent-module.m (original) +++ cfe/trunk/test/Modules/dependency-dump-dependent-module.m Fri Mar 10 13:34:15 2017 @@ -1,6 +1,8 @@ // When a module depends on another, check that we dump the dependency header // files for both. +// REQUIRES: shell + // RUN: rm -rf %t // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -module-dependency-dir %t/vfs -F %S/Inputs -I %S/Inputs -verify %s // expected-no-diagnostics Modified: cfe/trunk/test/Modules/dependency-dump.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/dependency-dump.m?rev=297497&r1=297496&r2=297497&view=diff == --- cfe/trunk/test/Modules/dependency-dump.m (original) +++ cfe/trunk/test/Modules/dependency-dump.m Fri Mar 10 13:34:15 2017 @@ -1,6 +1,8 @@ // Check that we can dump all of the headers a module depends on, and a VFS map // for the same. +// REQUIRES: shell + // RUN: rm -rf %t // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -module-dependency-dir %t/vfs -F %S/Inputs -I %S/Inputs -verify %s // expected-no-diagnostics ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24921: [cfe] [Headers] Fix inttypes.h macros visibility in C++ with C99-compliant libc
mgorny added a comment. Ping II. https://reviews.llvm.org/D24921 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29542: [TargetInfo] Adjust x86-32 atomic support to the CPU used
mgorny marked 5 inline comments as done. mgorny added a comment. A gentle ping. https://reviews.llvm.org/D29542 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29851: [clang-tools-extra] [test] Fix test dependencies when using installed tools
mgorny added a comment. PIng. Repository: rL LLVM https://reviews.llvm.org/D29851 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30155: [clang-tools-extra] [test] Fix clang library dir in LD_LIBRARY_PATH For stand-alone build
mgorny added a comment. Ping. Repository: rL LLVM https://reviews.llvm.org/D30155 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26796: [Driver] Use arch type to find compiler-rt libraries (on Linux)
mgorny added a comment. Another ping. Since 4.0.0 final has been tagged, I think we should get back to working on this. @compnerd, any suggestion how to proceed here? https://reviews.llvm.org/D26796 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30762: [ubsan] Add a nullability sanitizer
vsk updated this revision to Diff 91382. vsk marked 4 inline comments as done. vsk added a comment. - Rework documentation, add better code comments, and tighten up some check lines. https://reviews.llvm.org/D30762 Files: docs/UndefinedBehaviorSanitizer.rst include/clang/Basic/Sanitizers.def lib/CodeGen/CGCall.cpp lib/CodeGen/CGDecl.cpp lib/CodeGen/CGExprScalar.cpp lib/CodeGen/CodeGenFunction.cpp lib/CodeGen/CodeGenFunction.h lib/Driver/SanitizerArgs.cpp lib/Driver/ToolChain.cpp test/CodeGenObjC/ubsan-nonnull-and-nullability.m test/CodeGenObjC/ubsan-nullability.m Index: test/CodeGenObjC/ubsan-nullability.m === --- /dev/null +++ test/CodeGenObjC/ubsan-nullability.m @@ -0,0 +1,182 @@ +// REQUIRES: asserts +// RUN: %clang_cc1 -x objective-c -emit-llvm -triple x86_64-apple-macosx10.10.0 -fsanitize=nullability-arg,nullability-assign,nullability-return -w %s -o - | FileCheck %s + +// CHECK: [[NONNULL_RV_LOC1:@.*]] = private unnamed_addr global {{.*}} i32 109, i32 1 {{.*}} i32 100, i32 6 +// CHECK: [[NONNULL_ARG_LOC:@.*]] = private unnamed_addr global {{.*}} i32 204, i32 15 {{.*}} i32 190, i32 23 +// CHECK: [[NONNULL_ASSIGN1_LOC:@.*]] = private unnamed_addr global {{.*}} i32 305, i32 9 +// CHECK: [[NONNULL_ASSIGN2_LOC:@.*]] = private unnamed_addr global {{.*}} i32 405, i32 10 +// CHECK: [[NONNULL_ASSIGN3_LOC:@.*]] = private unnamed_addr global {{.*}} i32 505, i32 10 +// CHECK: [[NONNULL_INIT1_LOC:@.*]] = private unnamed_addr global {{.*}} i32 604, i32 25 +// CHECK: [[NONNULL_INIT2_LOC1:@.*]] = private unnamed_addr global {{.*}} i32 707, i32 26 +// CHECK: [[NONNULL_INIT2_LOC2:@.*]] = private unnamed_addr global {{.*}} i32 707, i32 29 +// CHECK: [[NONNULL_RV_LOC2:@.*]] = private unnamed_addr global {{.*}} i32 817, i32 1 {{.*}} i32 800, i32 6 + +#define NULL ((void *)0) + +// CHECK-LABEL: define i32* @nonnull_retval1 +#line 100 +int *_Nonnull nonnull_retval1(int *p) { + // CHECK: br i1 true, label %[[NULL:.*]], label %[[NONULL:.*]], !nosanitize + // CHECK: [[NULL]]: + // CHECK: [[ICMP:%.*]] = icmp ne i32* {{.*}}, null, !nosanitize + // CHECK-NEXT: br i1 [[ICMP]], {{.*}}, !nosanitize + // CHECK: call void @__ubsan_handle_nonnull_return{{.*}}[[NONNULL_RV_LOC1]] + return p; + // CHECK: [[NONULL]]: + // CHECK-NEXT: ret i32* +} + +#line 190 +void nonnull_arg(int *_Nonnull p) {} + +// CHECK-LABEL: define void @call_func_with_nonnull_arg +#line 200 +void call_func_with_nonnull_arg(int *_Nonnull p) { + // CHECK: [[ICMP:%.*]] = icmp ne i32* {{.*}}, null, !nosanitize + // CHECK-NEXT: br i1 [[ICMP]], {{.*}}, !nosanitize + // CHECK: call void @__ubsan_handle_nonnull_arg{{.*}}[[NONNULL_ARG_LOC]] + nonnull_arg(p); +} + +// CHECK-LABEL: define void @nonnull_assign1 +#line 300 +void nonnull_assign1(int *p) { + // CHECK: [[ICMP:%.*]] = icmp ne i32* {{.*}}, null, !nosanitize + // CHECK-NEXT: br i1 [[ICMP]], {{.*}}, !nosanitize + // CHECK: call void @__ubsan_handle_type_mismatch{{.*}}[[NONNULL_ASSIGN1_LOC]] + int *_Nonnull local; + local = p; +} + +// CHECK-LABEL: define void @nonnull_assign2 +#line 400 +void nonnull_assign2(int *p) { + // CHECK: [[ICMP:%.*]] = icmp ne i32* %{{.*}}, null, !nosanitize + // CHECK-NEXT: br i1 [[ICMP]], {{.*}}, !nosanitize + // CHECK: call void @__ubsan_handle_type_mismatch{{.*}}[[NONNULL_ASSIGN2_LOC]] + int *_Nonnull arr[1]; + arr[0] = p; +} + +struct S1 { + int *_Nonnull mptr; +}; + +// CHECK-LABEL: define void @nonnull_assign3 +#line 500 +void nonnull_assign3(int *p) { + // CHECK: [[ICMP:%.*]] = icmp ne i32* %{{.*}}, null, !nosanitize + // CHECK-NEXT: br i1 [[ICMP]], {{.*}}, !nosanitize + // CHECK: call void @__ubsan_handle_type_mismatch{{.*}}[[NONNULL_ASSIGN3_LOC]] + struct S1 s; + s.mptr = p; +} + +// CHECK-LABEL: define void @nonnull_init1 +#line 600 +void nonnull_init1(int *p) { + // CHECK: [[ICMP:%.*]] = icmp ne i32* %{{.*}}, null, !nosanitize + // CHECK-NEXT: br i1 [[ICMP]], {{.*}}, !nosanitize + // CHECK: call void @__ubsan_handle_type_mismatch{{.*}}[[NONNULL_INIT1_LOC]] + int *_Nonnull local = p; +} + +// CHECK-LABEL: define void @nonnull_init2 +#line 700 +void nonnull_init2(int *p) { + // CHECK: [[ICMP:%.*]] = icmp ne i32* %{{.*}}, null, !nosanitize + // CHECK-NEXT: br i1 [[ICMP]], {{.*}}, !nosanitize + // CHECK: call void @__ubsan_handle_type_mismatch{{.*}}[[NONNULL_INIT2_LOC1]] + // CHECK: [[ICMP:%.*]] = icmp ne i32* %{{.*}}, null, !nosanitize + // CHECK-NEXT: br i1 [[ICMP]], {{.*}}, !nosanitize + // CHECK: call void @__ubsan_handle_type_mismatch{{.*}}[[NONNULL_INIT2_LOC2]] + int *_Nonnull arr[] = {p, p}; +} + +// CHECK-LABEL: define i32* @nonnull_retval2 +#line 800 +int *_Nonnull nonnull_retval2(int *_Nonnull arg1, //< Test this. + int *_Nonnull arg2, //< Test this. + int *_Nullable arg3, //< Don't test the rest. + int *arg4, + int arg5, ...) { +
[PATCH] D30762: [ubsan] Add a nullability sanitizer
vsk marked 9 inline comments as done. vsk added a comment. The plan is to start off with -fsanitize=nullability, and then create a nullability-pedantic group later if it's really necessary. I think I've addressed all of the inline comments, and will upload a new diff shortly. Comment at: docs/UndefinedBehaviorSanitizer.rst:101 + ``-fsanitize=nullability-assign``, and the argument check with + ``-fsanitize=nullability-arg``. While violating nullability rules does + not result in undefined behavior, it is often unintentional, so UBSan zaks.anna wrote: > vsk wrote: > > zaks.anna wrote: > > > Have you investigated if -fsanitize=nullability-arg is too noisy? I think > > > we should somehow "recommend" return and assignment check to most users. > > > This is not clear from the help and options provided. The main concern > > > here is that someone would try -fsanitize=nullability, see a ton of > > > warnings they don't care about and think that the whole check is too > > > noisy. > > > > > > I cannot come up with a great solution. Options that come into mind are: > > > - Drop "arg" check completely. > > > - Remove arg from the nullability group. > > > - Have 2 groups for nullability. > > > > > > We can also wait for concrete data before making a decision here and > > > address this in subsequent commits. > > The nullability-arg check was not noisy on a small sample (n=4) of > > Apple-internal projects. I only collected 11 diagnostics in total, all of > > which seemed actionable. I.e the issues were not isolated to system > > headers: the project code actually did violate arg nullability. Based on > > what I've seen so far, I'd like to start off with including the arg check > > in a "nullability-full" group. If arg check noisiness becomes an issue, > > then I'd like to create a new "nullability-partial" group with just the > > return/assignment checks. > > > > TL;DR: let's rename -fsanitize=nullability to -fsanitize=nullability-full, > > keep the arg check, and introduce a nullability-partial group later if we > > need to. Wdyt? > > > > > Keeping things as is and introducing a new group if this becomes a problem > sounds good to me. You could use "nullability" and "nullability-pedantic". > That way you do not need to change the name and get to use "nullability". Sgtm. Comment at: docs/UndefinedBehaviorSanitizer.rst:141 - ``-fsanitize=undefined``: All of the checks listed above other than - ``unsigned-integer-overflow``. + ``unsigned-integer-overflow`` and ``nullability``. - ``-fsanitize=undefined-trap``: Deprecated alias of filcab wrote: > ```... and the ``nullability`` group.``` I define the group after the 'undefined' group, so I used a slightly different spelling. Comment at: lib/CodeGen/CGDecl.cpp:1907 + + // Skip the return value nullability check if the nullability preconditions + // are broken. zaks.anna wrote: > I would add a comment explaining why this is needed, similar to what you > included in the commit message: > "One point of note is that the nullability-return check is only allowed > to kick in if all arguments to the function satisfy their nullability > preconditions. This makes it necessary to emit some null checks in the > function body itself." > > Maybe even rename CanCheckRetValNullability into > RetValNullabilityPrecondition. I like this more than "CanCheck" because it's > just a precondition value. You check if it is satisfied (evaluates to true or > false) later when it's used in a branch. I added the comment and did the rename. I like 'RetValNullabilityPrecondition'. Comment at: test/CodeGenObjC/ubsan-nullability.m:114 + // CHECK: [[NONULL]]: + // CHECK: ret i32* +} filcab wrote: > `CHECK-NEXT`? I've promoted all the existing 'CHECK' lines to 'CHECK-NEXT's where possible. https://reviews.llvm.org/D30762 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30837: [libcxx] Support for shared_ptr
halyavin added a comment. But std::allocator is deprecated in C++17. I don't know a good solution, I just used int as an arbitrary type when I faced similar problem. https://reviews.llvm.org/D30837 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30183: Add -iframeworkwithsysroot compiler option
bruno accepted this revision. bruno added a comment. This revision is now accepted and ready to land. Hi Alex, Thanks for taking a look a this. LGTM Repository: rL LLVM https://reviews.llvm.org/D30183 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D15031: CFG: Add CFGElement for automatic variables that leave the scope
mgehre added a comment. I'm sorry for the long delay! Regarding " I think it would also be good to (eventually) add CFGElements marking when the storage duration for underlying storage ends.": From what I understand, this only differs from the end of lifetime in case of objects with non-trivial destructors, where the lifetime ends before the destructor is called and the storage duration ends afterwards. In which case is this difference important to the static analyzer? Accessing an object after its lifetime ended is already UB, so the static analyzer could warn on this, even before the storage duration for underlying storage ends. https://reviews.llvm.org/D15031 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D15031: CFG: Add CFGElement for automatic variables that leave the scope
mgehre updated this revision to Diff 91378. mgehre marked an inline comment as done. mgehre added a comment. Handle back-patches gotos and add test case Turned LocalScope::const_iterator::shared_parent from O(N^2) into O(N) time The combination with AddImplicitDtors will be added in a separate patch https://reviews.llvm.org/D15031 Files: include/clang/Analysis/AnalysisContext.h include/clang/Analysis/CFG.h include/clang/StaticAnalyzer/Core/AnalyzerOptions.h lib/Analysis/AnalysisDeclContext.cpp lib/Analysis/CFG.cpp lib/StaticAnalyzer/Core/AnalysisManager.cpp lib/StaticAnalyzer/Core/AnalyzerOptions.cpp lib/StaticAnalyzer/Core/ExprEngine.cpp lib/StaticAnalyzer/Core/PathDiagnostic.cpp test/Analysis/analyzer-config.c test/Analysis/analyzer-config.cpp test/Analysis/lifetime-cfg-output.cpp Index: test/Analysis/lifetime-cfg-output.cpp === --- /dev/null +++ test/Analysis/lifetime-cfg-output.cpp @@ -0,0 +1,783 @@ +// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -analyze -analyzer-checker=debug.DumpCFG -analyzer-config cfg-lifetime=true -analyzer-config cfg-implicit-dtors=false %s > %t 2>&1 +// RUN: FileCheck --input-file=%t %s + +extern bool UV; +class A { +public: + // CHECK: [B2 (ENTRY)] + // CHECK-NEXT:Succs (1): B1 + // CHECK: [B1] + // CHECK-NEXT:1: true + // CHECK-NEXT:2: UV + // CHECK-NEXT:3: [B1.2] = [B1.1] + // CHECK-NEXT:Preds (1): B2 + // CHECK-NEXT:Succs (1): B0 + // CHECK: [B0 (EXIT)] + // CHECK-NEXT:Preds (1): B1 + A() { +UV = true; + } + // CHECK: [B3 (ENTRY)] + // CHECK-NEXT:Succs (1): B2 + // CHECK: [B1] + // CHECK-NEXT:1: 0 + // CHECK-NEXT:2: this + // CHECK-NEXT:3: [B1.2]->p + // CHECK-NEXT:4: [B1.3] (ImplicitCastExpr, LValueToRValue, int *) + // CHECK-NEXT:5: *[B1.4] + // CHECK-NEXT:6: [B1.5] = [B1.1] + // CHECK-NEXT:Preds (1): B2 + // CHECK-NEXT:Succs (1): B0 + // CHECK: [B2] + // CHECK-NEXT:1: this + // CHECK-NEXT:2: [B2.1]->p + // CHECK-NEXT:3: [B2.2] (ImplicitCastExpr, LValueToRValue, int *) + // CHECK-NEXT:4: [B2.3] (ImplicitCastExpr, PointerToBoolean, _Bool) + // CHECK-NEXT:T: if [B2.4] + // CHECK-NEXT:Preds (1): B3 + // CHECK-NEXT:Succs (2): B1 B0 + // CHECK: [B0 (EXIT)] + // CHECK-NEXT:Preds (2): B1 B2 + ~A() { +if (p) + *p = 0; + } + // CHECK: [B2 (ENTRY)] + // CHECK-NEXT:Succs (1): B1 + // CHECK: [B1] + // CHECK-NEXT:1: 1 + // CHECK-NEXT:2: return [B1.1]; + // CHECK-NEXT:Preds (1): B2 + // CHECK-NEXT:Succs (1): B0 + // CHECK: [B0 (EXIT)] + // CHECK-NEXT:Preds (1): B1 + operator int() const { return 1; } + int *p; +}; + +// CHECK: [B2 (ENTRY)] +// CHECK-NEXT:Succs (1): B1 +// CHECK: [B1] +// CHECK-NEXT:1: (CXXConstructExpr, class A) +// CHECK-NEXT:2: A a; +// CHECK-NEXT:3: a +// CHECK-NEXT:4: [B1.3] (ImplicitCastExpr, NoOp, const class A) +// CHECK-NEXT:5: const A &b = a; +// CHECK-NEXT:6: A() (CXXConstructExpr, class A) +// CHECK-NEXT:7: [B1.6] (BindTemporary) +// CHECK-NEXT:8: [B1.7] (ImplicitCastExpr, NoOp, const class A) +// CHECK-NEXT:9: [B1.8] +// CHECK-NEXT: 10: const A &c = A(); +// CHECK-NEXT: 11: [B1.10] (Lifetime ends) +// CHECK-NEXT: 12: [B1.2] (Lifetime ends) +// CHECK-NEXT: 13: [B1.5] (Lifetime ends) +// CHECK-NEXT:Preds (1): B2 +// CHECK-NEXT:Succs (1): B0 +// CHECK: [B0 (EXIT)] +// CHECK-NEXT:Preds (1): B1 +void test_const_ref() { + A a; + const A &b = a; + const A &c = A(); +} + +// CHECK: [B2 (ENTRY)] +// CHECK-NEXT: Succs (1): B1 +// CHECK: [B1] +// CHECK-NEXT:1: (CXXConstructExpr, class A [2]) +// CHECK-NEXT:2: A a[2]; +// CHECK-NEXT:3: (CXXConstructExpr, class A [0]) +// CHECK-NEXT:4: A b[0]; +// lifetime of a ends when its destructors are run +// CHECK-NEXT:5: [B1.2] (Lifetime ends) +// lifetime of b ends when its storage duration ends +// CHECK-NEXT:6: [B1.4] (Lifetime ends) +// CHECK-NEXT:Preds (1): B2 +// CHECK-NEXT:Succs (1): B0 +// CHECK: [B0 (EXIT)] +// CHECK-NEXT: Preds (1): B1 +void test_array() { + A a[2]; + A b[0]; +} + +// CHECK: [B2 (ENTRY)] +// CHECK-NEXT: Succs (1): B1 +// CHECK: [B1] +// CHECK-NEXT:1: (CXXConstructExpr, class A) +// CHECK-NEXT:2: A a; +// CHECK-NEXT:3: (CXXConstructExpr, class A) +// CHECK-NEXT:4: A c; +// CHECK-NEXT:5: (CXXConstructExpr, class A) +// CHECK-NEXT:6: A d; +// CHECK-NEXT:7: [B1.6] (Lifetime ends) +// CHECK-NEXT:8: [B1.4] (Lifetime ends) +// CHECK-NEXT:9: (CXXConstructExpr, class A) +// CHECK-NEXT: 10: A b; +// CHECK-NEXT: 11: [B1.10] (Lifetime ends) +// CHECK-NEXT: 12: [B1.2] (Lifetime ends) +// CHECK-NEXT:Preds (1): B2 +// CHECK-NEXT:Succs (1): B0 +// CHECK: [B0 (EXIT)] +// CHECK-NEXT:
[PATCH] D30837: [libcxx] Support for shared_ptr
erik.pilkington created this revision. This patch adds support for `shared_ptr` types, so that the following works: void Func(); void Del(void (*)()) std::shared_ptr x(Func, Del); Where previously this would fail to compile. In PR27566, the use case described for this was a shared pointer to a dynamically loaded function, which seems reasonable enough to me. Both libstdc++ and MSVC support this use case as well, and I didn't notice any wording in the standard that disallowed it. This patch has 2 parts: 1. Don't try to instantiate an `allocator` 2. Fix `__enable_weak_this()` dummy overload to work with function pointers. Number 1 is accomplished by passing in `allocator` into `__shared_ptr_pointer` or `__shared_ptr_emplace` when no allocator was passed to the constructor of the `shared_ptr`, I believe this is correct because in this case the allocator is only used for a rebind, so any instantiation of std::allocator would work fine. This is my first libc++ patch, so take it with a grain of salt! Thanks for taking a look, Erik https://reviews.llvm.org/D30837 Files: include/memory test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp Index: test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp === --- test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp +++ test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp @@ -45,6 +45,9 @@ virtual ~Foo() = default; }; +struct Result {}; +void resultDeletor(Result (*)()) {} +Result theFunction() { return Result(); } int main() { @@ -65,7 +68,9 @@ std::shared_ptr p2 = std::make_shared(); assert(p2.get()); } - +{ // https://bugs.llvm.org/show_bug.cgi?id=27566 + std::shared_ptr x(&theFunction, &resultDeletor); +} #if TEST_STD_VER >= 11 nc = globalMemCounter.outstanding_new; { Index: include/memory === --- include/memory +++ include/memory @@ -3884,8 +3884,7 @@ } } -_LIBCPP_INLINE_VISIBILITY -void __enable_weak_this(const volatile void*, const volatile void*) _NOEXCEPT {} +_LIBCPP_INLINE_VISIBILITY void __enable_weak_this(...) _NOEXCEPT {} template friend class _LIBCPP_TEMPLATE_VIS shared_ptr; template friend class _LIBCPP_TEMPLATE_VIS weak_ptr; @@ -3916,8 +3915,8 @@ : __ptr_(__p) { unique_ptr<_Yp> __hold(__p); -typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; -__cntrl_ = new _CntrlBlk(__p, default_delete<_Yp>(), allocator<_Yp>()); +typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator > _CntrlBlk; +__cntrl_ = new _CntrlBlk(__p, default_delete<_Yp>(), allocator()); __hold.release(); __enable_weak_this(__p, __p); } @@ -3932,8 +3931,8 @@ try { #endif // _LIBCPP_NO_EXCEPTIONS -typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk; -__cntrl_ = new _CntrlBlk(__p, __d, allocator<_Yp>()); +typedef __shared_ptr_pointer<_Yp*, _Dp, allocator > _CntrlBlk; +__cntrl_ = new _CntrlBlk(__p, __d, allocator()); __enable_weak_this(__p, __p); #ifndef _LIBCPP_NO_EXCEPTIONS } @@ -3954,8 +3953,8 @@ try { #endif // _LIBCPP_NO_EXCEPTIONS -typedef __shared_ptr_pointer > _CntrlBlk; -__cntrl_ = new _CntrlBlk(__p, __d, allocator<_Tp>()); +typedef __shared_ptr_pointer > _CntrlBlk; +__cntrl_ = new _CntrlBlk(__p, __d, allocator()); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) @@ -4094,8 +4093,8 @@ typename enable_if::value, __nat>::type) : __ptr_(__r.get()) { -typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; -__cntrl_ = new _CntrlBlk(__r.get(), default_delete<_Yp>(), allocator<_Yp>()); +typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator > _CntrlBlk; +__cntrl_ = new _CntrlBlk(__r.get(), default_delete<_Yp>(), allocator()); __enable_weak_this(__r.get(), __r.get()); __r.release(); } @@ -4123,8 +4122,8 @@ else #endif { -typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk; -__cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), allocator<_Yp>()); +typedef __shared_ptr_pointer<_Yp*, _Dp, allocator > _CntrlBlk; +__cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), allocator()); __enable_weak_this(__r.get(), __r.get()); } __r.release(); @@ -4154,8 +4153,8 @@ { typedef __shared_ptr_pointer<_Yp*, reference_wrapper::type>, - allocator<_Yp> > _CntrlBlk; -
[PATCH] D30830: [OpenCL] Fix extension guards for atomic functions
jprice added a comment. Thanks - could you commit this on my behalf please? https://reviews.llvm.org/D30830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30693: [mips][msa] Remove range checks for non-immediate sld.[bhwd] instructions
This revision was automatically updated to reflect the committed changes. Closed by commit rL297485: [mips][msa] Remove range checks for non-immediate sld.[bhwd] instructions (authored by petarj). Changed prior to commit: https://reviews.llvm.org/D30693?vs=91158&id=91372#toc Repository: rL LLVM https://reviews.llvm.org/D30693 Files: cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/test/CodeGen/builtins-mips-msa-error.c cfe/trunk/test/CodeGen/builtins-mips-msa.c Index: cfe/trunk/lib/Sema/SemaChecking.cpp === --- cfe/trunk/lib/Sema/SemaChecking.cpp +++ cfe/trunk/lib/Sema/SemaChecking.cpp @@ -1619,28 +1619,24 @@ case Mips::BI__builtin_msa_copy_u_b: case Mips::BI__builtin_msa_insve_b: case Mips::BI__builtin_msa_splati_b: i = 1; l = 0; u = 15; break; - case Mips::BI__builtin_msa_sld_b: case Mips::BI__builtin_msa_sldi_b: i = 2; l = 0; u = 15; break; // These intrinsics take an unsigned 3 bit immediate. case Mips::BI__builtin_msa_copy_s_h: case Mips::BI__builtin_msa_copy_u_h: case Mips::BI__builtin_msa_insve_h: case Mips::BI__builtin_msa_splati_h: i = 1; l = 0; u = 7; break; - case Mips::BI__builtin_msa_sld_h: case Mips::BI__builtin_msa_sldi_h: i = 2; l = 0; u = 7; break; // These intrinsics take an unsigned 2 bit immediate. case Mips::BI__builtin_msa_copy_s_w: case Mips::BI__builtin_msa_copy_u_w: case Mips::BI__builtin_msa_insve_w: case Mips::BI__builtin_msa_splati_w: i = 1; l = 0; u = 3; break; - case Mips::BI__builtin_msa_sld_w: case Mips::BI__builtin_msa_sldi_w: i = 2; l = 0; u = 3; break; // These intrinsics take an unsigned 1 bit immediate. case Mips::BI__builtin_msa_copy_s_d: case Mips::BI__builtin_msa_copy_u_d: case Mips::BI__builtin_msa_insve_d: case Mips::BI__builtin_msa_splati_d: i = 1; l = 0; u = 1; break; - case Mips::BI__builtin_msa_sld_d: case Mips::BI__builtin_msa_sldi_d: i = 2; l = 0; u = 1; break; // Memory offsets and immediate loads. // These intrinsics take a signed 10 bit immediate. Index: cfe/trunk/test/CodeGen/builtins-mips-msa.c === --- cfe/trunk/test/CodeGen/builtins-mips-msa.c +++ cfe/trunk/test/CodeGen/builtins-mips-msa.c @@ -699,6 +699,11 @@ v4i32_r = __msa_sld_w(v4i32_r, v4i32_a, 3); // CHECK: call <4 x i32> @llvm.mips.sld.w( v2i64_r = __msa_sld_d(v2i64_r, v2i64_a, 1); // CHECK: call <2 x i64> @llvm.mips.sld.d( + v16i8_r = __msa_sld_b(v16i8_r, v16i8_a, 16); // CHECK: call <16 x i8> @llvm.mips.sld.b( + v8i16_r = __msa_sld_h(v8i16_r, v8i16_a, 8); // CHECK: call <8 x i16> @llvm.mips.sld.h( + v4i32_r = __msa_sld_w(v4i32_r, v4i32_a, 4); // CHECK: call <4 x i32> @llvm.mips.sld.w( + v2i64_r = __msa_sld_d(v2i64_r, v2i64_a, 2); // CHECK: call <2 x i64> @llvm.mips.sld.d( + v16i8_r = __msa_sldi_b(v16i8_r, v16i8_a, 7); // CHECK: call <16 x i8> @llvm.mips.sldi.b( v8i16_r = __msa_sldi_h(v8i16_r, v8i16_a, 3); // CHECK: call <8 x i16> @llvm.mips.sldi.h( v4i32_r = __msa_sldi_w(v4i32_r, v4i32_a, 2); // CHECK: call <4 x i32> @llvm.mips.sldi.w( Index: cfe/trunk/test/CodeGen/builtins-mips-msa-error.c === --- cfe/trunk/test/CodeGen/builtins-mips-msa-error.c +++ cfe/trunk/test/CodeGen/builtins-mips-msa-error.c @@ -162,11 +162,6 @@ v8i16_r = __msa_shf_h(v8i16_a, 256); // CHECK: warning: argument should be a value from 0 to 255}} v4i32_r = __msa_shf_w(v4i32_a, 256); // CHECK: warning: argument should be a value from 0 to 255}} - v16i8_r = __msa_sld_b(v16i8_r, v16i8_a, 16); // expected-error {{argument should be a value from 0 to 15}} - v8i16_r = __msa_sld_h(v8i16_r, v8i16_a, 8); // expected-error {{argument should be a value from 0 to 7}} - v4i32_r = __msa_sld_w(v4i32_r, v4i32_a, 4); // expected-error {{argument should be a value from 0 to 3}} - v2i64_r = __msa_sld_d(v2i64_r, v2i64_a, 2); // expected-error {{argument should be a value from 0 to 1}} - v16i8_r = __msa_sldi_b(v16i8_r, v16i8_a, 16); // expected-error {{argument should be a value from 0 to 15}} v8i16_r = __msa_sldi_h(v8i16_r, v8i16_a, 8); // expected-error {{argument should be a value from 0 to 7}} v4i32_r = __msa_sldi_w(v4i32_r, v4i32_a, 4); // expected-error {{argument should be a value from 0 to 3}} @@ -358,11 +353,6 @@ v8i16_r = __msa_shf_h(v8i16_a, -1);// CHECK: warning: argument should be a value from 0 to 255}} v4i32_r = __msa_shf_w(v4i32_a, -1);// CHECK: warning: argument should be a value from 0 to 255}} - v16i8_r = __msa_sld_b(v16i8_r, v16i8_a, -17); // expected-error {{argument should be a value from 0 to 15}} - v8i16_r = __msa_sld_h(v8i16_r, v8i16_a, -8); // expected-error {{argument should be a value from 0 to 7}} - v4i32_r = __msa_sld_w(v4i32_r, v4i32_a, -4);
r297485 - [mips][msa] Remove range checks for non-immediate sld.[bhwd] instructions
Author: petarj Date: Fri Mar 10 11:51:01 2017 New Revision: 297485 URL: http://llvm.org/viewvc/llvm-project?rev=297485&view=rev Log: [mips][msa] Remove range checks for non-immediate sld.[bhwd] instructions Removes immediate range checks for these instructions, since they have GPR rt as their input operand. Patch by Stefan Maksimovic. Differential Revision: https://reviews.llvm.org/D30693 Modified: cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/test/CodeGen/builtins-mips-msa-error.c cfe/trunk/test/CodeGen/builtins-mips-msa.c Modified: cfe/trunk/lib/Sema/SemaChecking.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=297485&r1=297484&r2=297485&view=diff == --- cfe/trunk/lib/Sema/SemaChecking.cpp (original) +++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Mar 10 11:51:01 2017 @@ -1619,28 +1619,24 @@ bool Sema::CheckMipsBuiltinFunctionCall( case Mips::BI__builtin_msa_copy_u_b: case Mips::BI__builtin_msa_insve_b: case Mips::BI__builtin_msa_splati_b: i = 1; l = 0; u = 15; break; - case Mips::BI__builtin_msa_sld_b: case Mips::BI__builtin_msa_sldi_b: i = 2; l = 0; u = 15; break; // These intrinsics take an unsigned 3 bit immediate. case Mips::BI__builtin_msa_copy_s_h: case Mips::BI__builtin_msa_copy_u_h: case Mips::BI__builtin_msa_insve_h: case Mips::BI__builtin_msa_splati_h: i = 1; l = 0; u = 7; break; - case Mips::BI__builtin_msa_sld_h: case Mips::BI__builtin_msa_sldi_h: i = 2; l = 0; u = 7; break; // These intrinsics take an unsigned 2 bit immediate. case Mips::BI__builtin_msa_copy_s_w: case Mips::BI__builtin_msa_copy_u_w: case Mips::BI__builtin_msa_insve_w: case Mips::BI__builtin_msa_splati_w: i = 1; l = 0; u = 3; break; - case Mips::BI__builtin_msa_sld_w: case Mips::BI__builtin_msa_sldi_w: i = 2; l = 0; u = 3; break; // These intrinsics take an unsigned 1 bit immediate. case Mips::BI__builtin_msa_copy_s_d: case Mips::BI__builtin_msa_copy_u_d: case Mips::BI__builtin_msa_insve_d: case Mips::BI__builtin_msa_splati_d: i = 1; l = 0; u = 1; break; - case Mips::BI__builtin_msa_sld_d: case Mips::BI__builtin_msa_sldi_d: i = 2; l = 0; u = 1; break; // Memory offsets and immediate loads. // These intrinsics take a signed 10 bit immediate. Modified: cfe/trunk/test/CodeGen/builtins-mips-msa-error.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-mips-msa-error.c?rev=297485&r1=297484&r2=297485&view=diff == --- cfe/trunk/test/CodeGen/builtins-mips-msa-error.c (original) +++ cfe/trunk/test/CodeGen/builtins-mips-msa-error.c Fri Mar 10 11:51:01 2017 @@ -162,11 +162,6 @@ void test(void) { v8i16_r = __msa_shf_h(v8i16_a, 256); // CHECK: warning: argument should be a value from 0 to 255}} v4i32_r = __msa_shf_w(v4i32_a, 256); // CHECK: warning: argument should be a value from 0 to 255}} - v16i8_r = __msa_sld_b(v16i8_r, v16i8_a, 16); // expected-error {{argument should be a value from 0 to 15}} - v8i16_r = __msa_sld_h(v8i16_r, v8i16_a, 8); // expected-error {{argument should be a value from 0 to 7}} - v4i32_r = __msa_sld_w(v4i32_r, v4i32_a, 4); // expected-error {{argument should be a value from 0 to 3}} - v2i64_r = __msa_sld_d(v2i64_r, v2i64_a, 2); // expected-error {{argument should be a value from 0 to 1}} - v16i8_r = __msa_sldi_b(v16i8_r, v16i8_a, 16); // expected-error {{argument should be a value from 0 to 15}} v8i16_r = __msa_sldi_h(v8i16_r, v8i16_a, 8); // expected-error {{argument should be a value from 0 to 7}} v4i32_r = __msa_sldi_w(v4i32_r, v4i32_a, 4); // expected-error {{argument should be a value from 0 to 3}} @@ -358,11 +353,6 @@ void test(void) { v8i16_r = __msa_shf_h(v8i16_a, -1);// CHECK: warning: argument should be a value from 0 to 255}} v4i32_r = __msa_shf_w(v4i32_a, -1);// CHECK: warning: argument should be a value from 0 to 255}} - v16i8_r = __msa_sld_b(v16i8_r, v16i8_a, -17); // expected-error {{argument should be a value from 0 to 15}} - v8i16_r = __msa_sld_h(v8i16_r, v8i16_a, -8); // expected-error {{argument should be a value from 0 to 7}} - v4i32_r = __msa_sld_w(v4i32_r, v4i32_a, -4); // expected-error {{argument should be a value from 0 to 3}} - v2i64_r = __msa_sld_d(v2i64_r, v2i64_a, -2); // expected-error {{argument should be a value from 0 to 1}} - v16i8_r = __msa_sldi_b(v16i8_r, v16i8_a, -17); // expected-error {{argument should be a value from 0 to 15}} v8i16_r = __msa_sldi_h(v8i16_r, v8i16_a, -8); // expected-error {{argument should be a value from 0 to 7}} v4i32_r = __msa_sldi_w(v4i32_r, v4i32_a, -4); // expected-error {{argument should be a value from 0 to 3}} Modified: cfe/trunk/test/CodeGen/builtins-mi
[PATCH] D30768: [PATCH][VFS] Ignore broken symlinks in the directory iterator.
ributzka updated this revision to Diff 91371. ributzka added a comment. Remove the EC check completely. https://reviews.llvm.org/D30768 Files: include/clang/Basic/VirtualFileSystem.h lib/Basic/VirtualFileSystem.cpp unittests/Basic/VirtualFileSystemTest.cpp Index: unittests/Basic/VirtualFileSystemTest.cpp === --- unittests/Basic/VirtualFileSystemTest.cpp +++ unittests/Basic/VirtualFileSystemTest.cpp @@ -305,6 +305,22 @@ } operator StringRef() { return Path.str(); } }; + +struct ScopedLink { + SmallString<128> Path; + ScopedLink(const Twine &To, const Twine &From) { +Path = From.str(); +std::error_code EC = sys::fs::create_link(To, From); +if (EC) + Path = ""; +EXPECT_FALSE(EC); + } + ~ScopedLink() { +if (Path != "") + EXPECT_FALSE(llvm::sys::fs::remove(Path.str())); + } + operator StringRef() { return Path.str(); } +}; } // end anonymous namespace TEST(VirtualFileSystemTest, BasicRealFSIteration) { @@ -334,6 +350,35 @@ EXPECT_EQ(vfs::directory_iterator(), I); } +TEST(VirtualFileSystemTest, BrokenSymlinkRealFSIteration) { + ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/ true); + IntrusiveRefCntPtr FS = vfs::getRealFileSystem(); + + ScopedLink _a("no_such_file", TestDirectory + "/a"); + ScopedDir _b(TestDirectory + "/b"); + ScopedLink _c("no_such_file", TestDirectory + "/c"); + + std::error_code EC; + vfs::directory_iterator I = FS->dir_begin(Twine(TestDirectory), EC); + EXPECT_TRUE(EC); + EXPECT_NE(vfs::directory_iterator(), I); + EC = std::error_code(); + EXPECT_TRUE(I->getName() == _a); + I.increment(EC); + EXPECT_FALSE(EC); + EXPECT_NE(vfs::directory_iterator(), I); + EXPECT_TRUE(I->getName() == _b); + I.increment(EC); + EXPECT_TRUE(EC); + EXPECT_NE(vfs::directory_iterator(), I); + EC = std::error_code(); + EXPECT_NE(vfs::directory_iterator(), I); + EXPECT_TRUE(I->getName() == _c); + I.increment(EC); + EXPECT_FALSE(EC); + EXPECT_EQ(vfs::directory_iterator(), I); +} + TEST(VirtualFileSystemTest, BasicRealFSRecursiveIteration) { ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/true); IntrusiveRefCntPtr FS = vfs::getRealFileSystem(); @@ -373,6 +418,44 @@ EXPECT_EQ(1, Counts[3]); // d } +TEST(VirtualFileSystemTest, BrokenSymlinkRealFSRecursiveIteration) { + ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/ true); + IntrusiveRefCntPtr FS = vfs::getRealFileSystem(); + + ScopedLink _a("no_such_file", TestDirectory + "/a"); + ScopedDir _b(TestDirectory + "/b"); + ScopedLink _ba("no_such_file", TestDirectory + "/b/a"); + ScopedDir _bb(TestDirectory + "/b/b"); + ScopedLink _bc("no_such_file", TestDirectory + "/b/c"); + ScopedLink _c("no_such_file", TestDirectory + "/c"); + ScopedDir _d(TestDirectory + "/d"); + ScopedDir _dd(TestDirectory + "/d/d"); + ScopedDir _ddd(TestDirectory + "/d/d/d"); + ScopedLink _e("no_such_file", TestDirectory + "/e"); + + std::vector Contents; + std::error_code EC; + for (vfs::recursive_directory_iterator I(*FS, Twine(TestDirectory), EC), E; + I != E; I.increment(EC)) { +// Skip broken symlinks. +if (EC == std::errc::no_such_file_or_directory) { + EC = std::error_code(); + continue; +} else if (EC) { + break; +} +Contents.push_back(I->getName()); + } + + // Check contents. + EXPECT_EQ(5U, Contents.size()); + EXPECT_TRUE(Contents[0] == _b); + EXPECT_TRUE(Contents[1] == _bb); + EXPECT_TRUE(Contents[2] == _d); + EXPECT_TRUE(Contents[3] == _dd); + EXPECT_TRUE(Contents[4] == _ddd); +} + template static void checkContents(DirIter I, ArrayRef ExpectedOut) { std::error_code EC; Index: lib/Basic/VirtualFileSystem.cpp === --- lib/Basic/VirtualFileSystem.cpp +++ lib/Basic/VirtualFileSystem.cpp @@ -246,8 +246,7 @@ if (!EC && Iter != llvm::sys::fs::directory_iterator()) { llvm::sys::fs::file_status S; EC = Iter->status(S); - if (!EC) -CurrentEntry = Status::copyWithNewName(S, Iter->path()); + CurrentEntry = Status::copyWithNewName(S, Iter->path()); } } @@ -1858,7 +1857,7 @@ std::error_code &EC) : FS(&FS_) { directory_iterator I = FS->dir_begin(Path, EC); - if (!EC && I != directory_iterator()) { + if (I != directory_iterator()) { State = std::make_shared(); State->push(I); } @@ -1871,8 +1870,6 @@ vfs::directory_iterator End; if (State->top()->isDirectory()) { vfs::directory_iterator I = FS->dir_begin(State->top()->getName(), EC); -if (EC) - return *this; if (I != End) { State->push(I); return *this; Index: include/clang/Basic/VirtualFileSystem.h === --- include/clang/Basic/VirtualFileSystem.h +++ include/clang/Basic/VirtualFileSystem.h @
[PATCH] D30834: [x86] these aren't the undefs you're looking for (PR32176)
spatel created this revision. Herald added a subscriber: mcrosier. x86 has undef SSE/AVX intrinsics that should represent a bogus register operand. This is not the same as LLVM's undef value which can take on multiple bit patterns. There are better solutions / follow-ups to this discussed here: https://bugs.llvm.org/show_bug.cgi?id=32176 ...but this should prevent miscompiles with a one-line code change. https://reviews.llvm.org/D30834 Files: lib/CodeGen/CGBuiltin.cpp test/CodeGen/avx-builtins.c test/CodeGen/avx2-builtins.c test/CodeGen/avx512bw-builtins.c test/CodeGen/avx512dq-builtins.c test/CodeGen/avx512f-builtins.c test/CodeGen/avx512vl-builtins.c test/CodeGen/avx512vldq-builtins.c test/CodeGen/sse-builtins.c test/CodeGen/sse2-builtins.c Index: test/CodeGen/sse2-builtins.c === --- test/CodeGen/sse2-builtins.c +++ test/CodeGen/sse2-builtins.c @@ -1455,13 +1455,13 @@ __m128d test_mm_undefined_pd() { // CHECK-LABEL: @test_mm_undefined_pd - // CHECK: ret <2 x double> undef + // CHECK: ret <2 x double> zeroinitializer return _mm_undefined_pd(); } __m128i test_mm_undefined_si128() { // CHECK-LABEL: @test_mm_undefined_si128 - // CHECK: ret <2 x i64> undef + // CHECK: ret <2 x i64> zeroinitializer return _mm_undefined_si128(); } Index: test/CodeGen/sse-builtins.c === --- test/CodeGen/sse-builtins.c +++ test/CodeGen/sse-builtins.c @@ -802,7 +802,7 @@ __m128 test_mm_undefined_ps() { // CHECK-LABEL: @test_mm_undefined_ps - // CHECK: ret <4 x float> undef + // CHECK: ret <4 x float> zeroinitializer return _mm_undefined_ps(); } Index: test/CodeGen/avx512vldq-builtins.c === --- test/CodeGen/avx512vldq-builtins.c +++ test/CodeGen/avx512vldq-builtins.c @@ -996,40 +996,40 @@ __m128d test_mm256_extractf64x2_pd(__m256d __A) { // CHECK-LABEL: @test_mm256_extractf64x2_pd - // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> undef, <2 x i32> + // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> zeroinitializer, <2 x i32> return _mm256_extractf64x2_pd(__A, 1); } __m128d test_mm256_mask_extractf64x2_pd(__m128d __W, __mmask8 __U, __m256d __A) { // CHECK-LABEL: @test_mm256_mask_extractf64x2_pd - // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> undef, <2 x i32> + // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> zeroinitializer, <2 x i32> // CHECK: select <2 x i1> %{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}} return _mm256_mask_extractf64x2_pd(__W, __U, __A, 1); } __m128d test_mm256_maskz_extractf64x2_pd(__mmask8 __U, __m256d __A) { // CHECK-LABEL: @test_mm256_maskz_extractf64x2_pd - // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> undef, <2 x i32> + // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> zeroinitializer, <2 x i32> // CHECK: select <2 x i1> %{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}} return _mm256_maskz_extractf64x2_pd(__U, __A, 1); } __m128i test_mm256_extracti64x2_epi64(__m256i __A) { // CHECK-LABEL: @test_mm256_extracti64x2_epi64 - // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> undef, <2 x i32> + // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> zeroinitializer, <2 x i32> return _mm256_extracti64x2_epi64(__A, 1); } __m128i test_mm256_mask_extracti64x2_epi64(__m128i __W, __mmask8 __U, __m256i __A) { // CHECK-LABEL: @test_mm256_mask_extracti64x2_epi64 - // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> undef, <2 x i32> + // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> zeroinitializer, <2 x i32> // CHECK: select <2 x i1> %{{.*}}, <2 x i64> %{{.*}}, <2 x i64> %{{.*}} return _mm256_mask_extracti64x2_epi64(__W, __U, __A, 1); } __m128i test_mm256_maskz_extracti64x2_epi64(__mmask8 __U, __m256i __A) { // CHECK-LABEL: @test_mm256_maskz_extracti64x2_epi64 - // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> undef, <2 x i32> + // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> zeroinitializer, <2 x i32> // CHECK: select <2 x i1> %{{.*}}, <2 x i64> %{{.*}}, <2 x i64> %{{.*}} return _mm256_maskz_extracti64x2_epi64(__U, __A, 1); } Index: test/CodeGen/avx512vl-builtins.c === --- test/CodeGen/avx512vl-builtins.c +++ test/CodeGen/avx512vl-builtins.c @@ -5008,56 +5008,56 @@ __m128d test_mm_mask_permute_pd(__m128d __W, __mmask8 __U, __m128d __X) { // CHECK-LABEL: @test_mm_mask_permute_pd - // CHECK: shufflevector <2 x double> %{{.*}}, <2 x double> undef, <2 x i32> + // CHECK: shufflevector <2 x double> %{{.*}}, <2 x double> zeroinitializer, <2 x i32> // CHECK: select <2 x i1> %{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}} return _mm_mask_permute_pd(__W, __U, __X, 1); } __m128d test_mm_maskz_permute_pd(__m
[PATCH] D28136: [OpenCL] Implement as_type operator as alias of __builtin_astype.
bader added a comment. > Why do you think this is a bug? It seems to follow standard behavior in C to > promote char to int if required. Just like if you would have a C code: > > int as_int(int i); > void foo() { > char src = 1; > int dst = as_int(src); > } > > > This code would complie and the same exactly IR would be generated. as_type is defined to be used for bit re-interpretation. (see 6.2.4.2 Reinterpreting Types Using as_type() and as_typen()). In this sense, it's exactly matches __bultin_astype built-in function. Here are a few relevant OpenCL C language specification quotes from 6.2.4 section: > All data types described in tables 6.1 and 6.2 (except bool, half and void) > may be also reinterpreted as another data type of **the same size** using the > as_type() operator for scalar data types and the as_typen() operator for > vector data types. > The usual type promotion for function arguments shall not be performed. > It is an error to use as_type() or as_typen() operator to reinterpret data to > a type of a different number of bytes. So, aliasing as_type to __builtin_astype provides these checks, whereas we can't do it for overloadable as_type function declarations. I also would like to address your original concerns: > The main issue is after preprocessing the header the original function name > is no longer available in diagnostics reported. Actually diagnostics is able to provide a hint to exact code location in the header file where as_ is defined as macro, so user gets correct name of the operator in diagnostics as far as I know. > The spec defines as_type as a builtin function and not a macro. To be precise, spec defines as_type as an operator. So, the best way to implement it would be to add a language support of such operator, but AFAIK aliasing to __bulitin_astype via macro is sufficient enough for OpenCL use cases. > Additionally your patch would allow as_type to be used with extra type (not > only those defined in spec). Not sure I get this. We defined limited set of as_* functions - only for types from tables 6.1 and 6.2 as specified by specification, so if OpenCL developer will try to call as_(type2), which is not defined in the header, compiler will report en error about calling undeclared function. > Also I don't see the problem to implement as_type with just simply calling a > builtin. It should be inlined later anyways. Yes, but this solution will not give us error checking as pre-processor solution. Does it make sense? https://reviews.llvm.org/D28136 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30810: Preserve vec3 type.
jaykang10 added a comment. In https://reviews.llvm.org/D30810#697760, @Anastasia wrote: > Could you please add your test here (probably goes to test/CodeGenOpenCL)? Oops! I am so sorry. I missed it. I have updated it. https://reviews.llvm.org/D30810 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30810: Preserve vec3 type.
jaykang10 updated this revision to Diff 91355. jaykang10 added a comment. Changed help text for option and Added test file. https://reviews.llvm.org/D30810 Files: include/clang/Driver/CC1Options.td include/clang/Frontend/CodeGenOptions.def lib/CodeGen/CGExpr.cpp lib/Frontend/CompilerInvocation.cpp test/CodeGenOpenCL/preserve_vec3.cl Index: test/CodeGenOpenCL/preserve_vec3.cl === --- /dev/null +++ test/CodeGenOpenCL/preserve_vec3.cl @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown -preserve-vec3-type | FileCheck %s + +typedef float float3 __attribute__((ext_vector_type(3))); +typedef float float4 __attribute__((ext_vector_type(4))); + +void kernel foo(global float3 *a, global float3 *b) { + // CHECK: %[[LOAD_A:.*]] = load <3 x float>, <3 x float> addrspace(1)* %a + // CHECK: store <3 x float> %[[LOAD_A]], <3 x float> addrspace(1)* %b + *b = *a; +} Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -713,6 +713,7 @@ } } + Opts.PreserveVec3Type = Args.hasArg(OPT_fpreserve_vec3_type); Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions); Opts.XRayInstrumentFunctions = Args.hasArg(OPT_fxray_instrument); Opts.XRayInstructionThreshold = Index: lib/CodeGen/CGExpr.cpp === --- lib/CodeGen/CGExpr.cpp +++ lib/CodeGen/CGExpr.cpp @@ -1368,26 +1368,28 @@ QualType TBAABaseType, uint64_t TBAAOffset, bool isNontemporal) { - // For better performance, handle vector loads differently. - if (Ty->isVectorType()) { -const llvm::Type *EltTy = Addr.getElementType(); - -const auto *VTy = cast(EltTy); - -// Handle vectors of size 3 like size 4 for better performance. -if (VTy->getNumElements() == 3) { - - // Bitcast to vec4 type. - llvm::VectorType *vec4Ty = llvm::VectorType::get(VTy->getElementType(), - 4); - Address Cast = Builder.CreateElementBitCast(Addr, vec4Ty, "castToVec4"); - // Now load value. - llvm::Value *V = Builder.CreateLoad(Cast, Volatile, "loadVec4"); - - // Shuffle vector to get vec3. - V = Builder.CreateShuffleVector(V, llvm::UndefValue::get(vec4Ty), - {0, 1, 2}, "extractVec"); - return EmitFromMemory(V, Ty); + if (!CGM.getCodeGenOpts().PreserveVec3Type) { +// For better performance, handle vector loads differently. +if (Ty->isVectorType()) { + const llvm::Type *EltTy = Addr.getElementType(); + + const auto *VTy = cast(EltTy); + + // Handle vectors of size 3 like size 4 for better performance. + if (VTy->getNumElements() == 3) { + +// Bitcast to vec4 type. +llvm::VectorType *vec4Ty = +llvm::VectorType::get(VTy->getElementType(), 4); +Address Cast = Builder.CreateElementBitCast(Addr, vec4Ty, "castToVec4"); +// Now load value. +llvm::Value *V = Builder.CreateLoad(Cast, Volatile, "loadVec4"); + +// Shuffle vector to get vec3. +V = Builder.CreateShuffleVector(V, llvm::UndefValue::get(vec4Ty), +{0, 1, 2}, "extractVec"); +return EmitFromMemory(V, Ty); + } } } @@ -1456,23 +1458,24 @@ bool isNontemporal) { // Handle vectors differently to get better performance. - if (Ty->isVectorType()) { -llvm::Type *SrcTy = Value->getType(); -auto *VecTy = cast(SrcTy); -// Handle vec3 special. -if (VecTy->getNumElements() == 3) { - // Our source is a vec3, do a shuffle vector to make it a vec4. - llvm::Constant *Mask[] = {Builder.getInt32(0), Builder.getInt32(1), -Builder.getInt32(2), -llvm::UndefValue::get(Builder.getInt32Ty())}; - llvm::Value *MaskV = llvm::ConstantVector::get(Mask); - Value = Builder.CreateShuffleVector(Value, - llvm::UndefValue::get(VecTy), - MaskV, "extractVec"); - SrcTy = llvm::VectorType::get(VecTy->getElementType(), 4); -} -if (Addr.getElementType() != SrcTy) { - Addr = Builder.CreateElementBitCast(Addr, SrcTy, "storetmp"); + if (!CGM.getCodeGenOpts().PreserveVec3Type) { +if (Ty->isVectorType()) { + llvm::Type *SrcTy = Value->getType(); + auto *VecTy = cast(SrcTy); + // Handle vec3 special. + if (VecTy->getNumElements() == 3) { +// Our source is a vec3, do a shuffle vector to make it a vec4. +llvm::Constant *Mask[] = {Builder.getIn
[PATCH] D30831: [ASTImporter] Import fix of GCCAsmStmts w/ missing symbolic operands
gerazo created this revision. Do not drop the import of the whole function just because an asm statement in it has some missing symbolic names. https://reviews.llvm.org/D30831 Files: lib/AST/ASTImporter.cpp test/ASTMerge/asm/Inputs/asm-function.cpp test/ASTMerge/asm/test.cpp Index: test/ASTMerge/asm/test.cpp === --- test/ASTMerge/asm/test.cpp +++ test/ASTMerge/asm/test.cpp @@ -4,4 +4,5 @@ void testAsmImport() { asmFunc(12, 42); + asmFunc2(42); } Index: test/ASTMerge/asm/Inputs/asm-function.cpp === --- test/ASTMerge/asm/Inputs/asm-function.cpp +++ test/ASTMerge/asm/Inputs/asm-function.cpp @@ -9,3 +9,13 @@ res = bigres; return res; } + +int asmFunc2(int i) { + int res; + asm ("mov %1, %0 \t\n" + "inc %0 " + : "=r" (res) + : "r" (i) + : "cc"); + return res; +} Index: lib/AST/ASTImporter.cpp === --- lib/AST/ASTImporter.cpp +++ lib/AST/ASTImporter.cpp @@ -5218,14 +5218,14 @@ SmallVector Names; for (unsigned I = 0, E = S->getNumOutputs(); I != E; I++) { IdentifierInfo *ToII = Importer.Import(S->getOutputIdentifier(I)); -if (!ToII) - return nullptr; +// ToII is nullptr when no symbolic name is given for output operand +// see ParseStmtAsm::ParseAsmOperandsOpt Names.push_back(ToII); } for (unsigned I = 0, E = S->getNumInputs(); I != E; I++) { IdentifierInfo *ToII = Importer.Import(S->getInputIdentifier(I)); -if (!ToII) - return nullptr; +// ToII is nullptr when no symbolic name is given for input operand +// see ParseStmtAsm::ParseAsmOperandsOpt Names.push_back(ToII); } Index: test/ASTMerge/asm/test.cpp === --- test/ASTMerge/asm/test.cpp +++ test/ASTMerge/asm/test.cpp @@ -4,4 +4,5 @@ void testAsmImport() { asmFunc(12, 42); + asmFunc2(42); } Index: test/ASTMerge/asm/Inputs/asm-function.cpp === --- test/ASTMerge/asm/Inputs/asm-function.cpp +++ test/ASTMerge/asm/Inputs/asm-function.cpp @@ -9,3 +9,13 @@ res = bigres; return res; } + +int asmFunc2(int i) { + int res; + asm ("mov %1, %0 \t\n" + "inc %0 " + : "=r" (res) + : "r" (i) + : "cc"); + return res; +} Index: lib/AST/ASTImporter.cpp === --- lib/AST/ASTImporter.cpp +++ lib/AST/ASTImporter.cpp @@ -5218,14 +5218,14 @@ SmallVector Names; for (unsigned I = 0, E = S->getNumOutputs(); I != E; I++) { IdentifierInfo *ToII = Importer.Import(S->getOutputIdentifier(I)); -if (!ToII) - return nullptr; +// ToII is nullptr when no symbolic name is given for output operand +// see ParseStmtAsm::ParseAsmOperandsOpt Names.push_back(ToII); } for (unsigned I = 0, E = S->getNumInputs(); I != E; I++) { IdentifierInfo *ToII = Importer.Import(S->getInputIdentifier(I)); -if (!ToII) - return nullptr; +// ToII is nullptr when no symbolic name is given for input operand +// see ParseStmtAsm::ParseAsmOperandsOpt Names.push_back(ToII); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30792: Use callback for internalizing linked symbols.
mehdi_amini added a comment. Off topic, but since this is a rev lock change with LLVM, you can to all of in a single revision with: http://llvm.org/docs/GettingStarted.html#for-developers-to-work-with-a-git-monorepo Repository: rL LLVM https://reviews.llvm.org/D30792 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30733: [Driver] Add arch-specific rpath for libc++
jroelofs added a comment. I'll also add that we had a BOF at EuroLLVM 2014, where this got support from the community and people generally thought it was a good plan... Just needed someone to follow through with it. We (wearing my CodeSourcery hat) said we would do so, but have been making slow progress on it since then. Now that we've got more time to work on our arm bare-metal toolchain, I expect that to pick up... sorry it has taken so long :/ https://reviews.llvm.org/D30733 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30830: [OpenCL] Fix extension guards for atomic functions
Anastasia accepted this revision. Anastasia added a comment. This revision is now accepted and ready to land. LGTM! This bit was poorly tested initially as there were simply too many things. I am wondering if we could improve these bits slowly by extending further lib/Headers/opencl-c.h. https://reviews.llvm.org/D30830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28136: [OpenCL] Implement as_type operator as alias of __builtin_astype.
Anastasia added a comment. In https://reviews.llvm.org/D28136#697673, @echuraev wrote: > In https://reviews.llvm.org/D28136#634356, @Anastasia wrote: > > > This has been discussed during the initial review for the header: > > > > http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160425/157187.html > > > > The main issue is after preprocessing the header the original function name > > is no longer available in diagnostics reported. The spec defines as_type as > > a builtin function and not a macro. Additionally your patch would allow > > as_type to be used with extra type (not only those defined in spec). Also I > > don't see the problem to implement as_type with just simply calling a > > builtin. It should be inlined later anyways. > > > I think that this patch is really necessary because in some cases previous > implementation doesn't give a diagnostic. Please see test case that I have > added to this review. With current implementation //char// variable will be > cast to //int//. You can see the following part of llvm ir: > > %0 = load i8, i8* %src, align 1 > %conv = sext i8 %0 to i32 > %call = call i32 @_Z6as_inti(i32 %conv) #2 > > > So there is a bug and we didn't get error that the size of char isn't equal > to size of int. Program is compiled without any problems. > If as_type functions will be defined in macro then we will have the > following message: > > error: invalid reinterpretation: sizes of 'float' and 'char' must match > int dst = as_int( src ); > ^~~ > ././llvm/tools/clang/lib/Headers/opencl-c-common.h:6615:21: note: expanded > from macro 'as_int' > #define as_int(x) __builtin_astype((x), int) > ^~~~ > Why do you think this is a bug? It seems to follow standard behavior in C to promote char to int if required. Just like if you would have a C code: int as_int(int i); void foo() { char src = 1; int dst = as_int(src); } This code would complie and the same exactly IR would be generated. https://reviews.llvm.org/D28136 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30830: [OpenCL] Fix extension guards for atomic functions
jprice created this revision. https://reviews.llvm.org/D30830 Files: lib/Headers/opencl-c.h Index: lib/Headers/opencl-c.h === --- lib/Headers/opencl-c.h +++ lib/Headers/opencl-c.h @@ -14395,10 +14395,10 @@ #if defined(cl_khr_global_int32_base_atomics) int __ovld atom_xchg(volatile __global int *p, int val); -int __ovld atom_xchg(volatile __local int *p, int val); +unsigned int __ovld atom_xchg(volatile __global unsigned int *p, unsigned int val); #endif #if defined(cl_khr_local_int32_base_atomics) -unsigned int __ovld atom_xchg(volatile __global unsigned int *p, unsigned int val); +int __ovld atom_xchg(volatile __local int *p, int val); unsigned int __ovld atom_xchg(volatile __local unsigned int *p, unsigned int val); #endif @@ -14515,8 +14515,6 @@ #if defined(cl_khr_int64_extended_atomics) long __ovld atom_min(volatile __global long *p, long val); unsigned long __ovld atom_min(volatile __global unsigned long *p, unsigned long val); -#endif -#if defined(cl_khr_local_int32_extended_atomics) long __ovld atom_min(volatile __local long *p, long val); unsigned long __ovld atom_min(volatile __local unsigned long *p, unsigned long val); #endif Index: lib/Headers/opencl-c.h === --- lib/Headers/opencl-c.h +++ lib/Headers/opencl-c.h @@ -14395,10 +14395,10 @@ #if defined(cl_khr_global_int32_base_atomics) int __ovld atom_xchg(volatile __global int *p, int val); -int __ovld atom_xchg(volatile __local int *p, int val); +unsigned int __ovld atom_xchg(volatile __global unsigned int *p, unsigned int val); #endif #if defined(cl_khr_local_int32_base_atomics) -unsigned int __ovld atom_xchg(volatile __global unsigned int *p, unsigned int val); +int __ovld atom_xchg(volatile __local int *p, int val); unsigned int __ovld atom_xchg(volatile __local unsigned int *p, unsigned int val); #endif @@ -14515,8 +14515,6 @@ #if defined(cl_khr_int64_extended_atomics) long __ovld atom_min(volatile __global long *p, long val); unsigned long __ovld atom_min(volatile __global unsigned long *p, unsigned long val); -#endif -#if defined(cl_khr_local_int32_extended_atomics) long __ovld atom_min(volatile __local long *p, long val); unsigned long __ovld atom_min(volatile __local unsigned long *p, unsigned long val); #endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30733: [Driver] Add arch-specific rpath for libc++
jroelofs added a comment. In https://reviews.llvm.org/D30733#697313, @Hahnfeld wrote: > In https://reviews.llvm.org/D30733#697108, @jroelofs wrote: > > > As I said on https://reviews.llvm.org/D30214, it is inappropriate to be > > installing libc++ in the resource directory... please **do not** do that. > > > Can you give reason for that? libc++ is not version-locked to the compiler, however that directory is. I understand you want to solve your problem, but I think we (as a community) need to take a step back and look at the implications of decisions like this... and having thought through this, I think this is not a wise choice if we value long term support. Yes, this plan /could/ work for a given individual release, but I think it does not scale to use cases where the libs have been chosen by some external constraint. For example, user code built against an old version of libc++: sometimes it's ok to upgrade the compiler, but often you're stuck with a particular version of the libraries because some other software was built against them. > I can understand that header files are independent of the target architecture > but how do you handle multiple binary libraries for let's say 32 and 64 bit? Arch + multilib suffixed directories solves this problem. > This was the main motivation for the OpenMP runtime in > http://lists.llvm.org/pipermail/openmp-dev/2016-December/001612.html, please > also see My objection isn't to putting the libs in a directory that contains the arch name / multilib name, but rather it is to having that directory be a child of lib/clang/$version/{lib, include}. > https://bugs.llvm.org//show_bug.cgi?id=31300. I don't think `libc++` would be > any different here. > > Additionally, my main motiviation was for `libunwind` as explained here: > http://lists.llvm.org/pipermail/cfe-dev/2017-January/052512.html > On that thread multiple people suggested to use an extra directory for > runtime libraries, @rnk and @mgorny listed as reviewers for this patch. And I disagree. The only things that belong in clang's resource directory are the builtins, sanitizer libs, and maybe the OpenMP libs (assuming they're tied to a particular compiler version, and don't have a stable API/ABI). > If `libunwind` goes there and is added together with `libc++`, we need to add > the rpath here. And what's the reason against installing `libc++` in the same > path then? IMNSHO, libunwind does not belong in the resource directory either. Concrete suggestion (and maybe we ought to discus this more widely on cfe-dev in RFC form): create a new directory not tied to the compiler version, and place non version locked libraries there. One way that could look is something like: lib/clang/SDKs/$vendor/$platform/$abi/$arch/{lib/$multilib, include} with, for example: lib └── clang └── SDKs ├── apple │ └── darwin15 │ ├── fat │ ├── powerpc │ └── x86_64 └── ubuntu10 └── linux └── gnueabi ├── arm └── x86_64 ├── lib └── lib64 (I don't want to get in the weeds bike-shedding the specific details of this layout just yet, so take this as a general idea with room for flexibility, and a small amount of hand-waving) representing the layout for a cross compiler with SDKs for: - ppc darwin - x86_64 darwin - fat library containing several darwin targets - arm linux - x86_64 linux, with both -m32 and -m64 multilibs With this strategy, now you can have say clang-4.0 installed on your system, along with some libraries that came with it. Now if you've built things against those libs, and upgrade your clang version, you are not tied to the new libc++ that comes with it, as you would be with libc++ placed in the resource dir. https://reviews.llvm.org/D30733 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30810: Preserve vec3 type.
Anastasia added a comment. Could you please add your test here (probably goes to test/CodeGenOpenCL)? Comment at: include/clang/Driver/CC1Options.td:661 +def fpreserve_vec3_type : Flag<["-"], "fpreserve-vec3-type">, + HelpText<"Preserve 3-component vector type operations">; + Can we drop "operations"? https://reviews.llvm.org/D30810 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r297468 - [OpenCL] Fix type compatibility check and generic AS mangling.
Author: stulova Date: Fri Mar 10 09:23:07 2017 New Revision: 297468 URL: http://llvm.org/viewvc/llvm-project?rev=297468&view=rev Log: [OpenCL] Fix type compatibility check and generic AS mangling. 1. Reimplemented conditional operator so that it checks compatibility of unqualified pointees of the 2nd and the 3rd operands (C99, OpenCL v2.0 6.5.15). Define QualTypes compatibility for OpenCL as following: - corresponding types are compatible (C99 6.7.3) - CVR-qualifiers are equal (C99 6.7.3) - address spaces are equal (implementation defined) 2. Added generic address space to Itanium mangling. Review: D30037 Patch by Dmitry Borisenkov! Added: cfe/trunk/test/SemaOpenCL/overload_addrspace_resolution.cl Modified: cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/AST/ItaniumMangle.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl Modified: cfe/trunk/lib/AST/ASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=297468&r1=297467&r2=297468&view=diff == --- cfe/trunk/lib/AST/ASTContext.cpp (original) +++ cfe/trunk/lib/AST/ASTContext.cpp Fri Mar 10 09:23:07 2017 @@ -8066,15 +8066,6 @@ QualType ASTContext::mergeTypes(QualType Qualifiers LQuals = LHSCan.getLocalQualifiers(); Qualifiers RQuals = RHSCan.getLocalQualifiers(); if (LQuals != RQuals) { -if (getLangOpts().OpenCL) { - if (LHSCan.getUnqualifiedType() != RHSCan.getUnqualifiedType() || - LQuals.getCVRQualifiers() != RQuals.getCVRQualifiers()) -return QualType(); - if (LQuals.isAddressSpaceSupersetOf(RQuals)) -return LHS; - if (RQuals.isAddressSpaceSupersetOf(LQuals)) -return RHS; -} // If any of these qualifiers are different, we have a type // mismatch. if (LQuals.getCVRQualifiers() != RQuals.getCVRQualifiers() || @@ -8200,6 +8191,20 @@ QualType ASTContext::mergeTypes(QualType LHSPointee = LHSPointee.getUnqualifiedType(); RHSPointee = RHSPointee.getUnqualifiedType(); } +if (getLangOpts().OpenCL) { + Qualifiers LHSPteeQual = LHSPointee.getQualifiers(); + Qualifiers RHSPteeQual = RHSPointee.getQualifiers(); + // Blocks can't be an expression in a ternary operator (OpenCL v2.0 + // 6.12.5) thus the following check is asymmetric. + if (!LHSPteeQual.isAddressSpaceSupersetOf(RHSPteeQual)) +return QualType(); + LHSPteeQual.removeAddressSpace(); + RHSPteeQual.removeAddressSpace(); + LHSPointee = + QualType(LHSPointee.getTypePtr(), LHSPteeQual.getAsOpaqueValue()); + RHSPointee = + QualType(RHSPointee.getTypePtr(), RHSPteeQual.getAsOpaqueValue()); +} QualType ResultType = mergeTypes(LHSPointee, RHSPointee, OfBlockPointer, Unqualified); if (ResultType.isNull()) return QualType(); Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=297468&r1=297467&r2=297468&view=diff == --- cfe/trunk/lib/AST/ItaniumMangle.cpp (original) +++ cfe/trunk/lib/AST/ItaniumMangle.cpp Fri Mar 10 09:23:07 2017 @@ -2159,10 +2159,12 @@ void CXXNameMangler::mangleQualifiers(Qu } else { switch (AS) { default: llvm_unreachable("Not a language specific address space"); - // ::= "CL" [ "global" | "local" | "constant" ] + // ::= "CL" [ "global" | "local" | "constant | + //"generic" ] case LangAS::opencl_global: ASString = "CLglobal"; break; case LangAS::opencl_local:ASString = "CLlocal";break; case LangAS::opencl_constant: ASString = "CLconstant"; break; + case LangAS::opencl_generic: ASString = "CLgeneric"; break; // ::= "CU" [ "device" | "constant" | "shared" ] case LangAS::cuda_device: ASString = "CUdevice"; break; case LangAS::cuda_constant: ASString = "CUconstant"; break; Modified: cfe/trunk/lib/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=297468&r1=297467&r2=297468&view=diff == --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) +++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Mar 10 09:23:07 2017 @@ -6335,92 +6335,98 @@ static QualType checkConditionalPointerC Qualifiers lhQual = lhptee.getQualifiers(); Qualifiers rhQual = rhptee.getQualifiers(); + unsigned ResultAddrSpace = 0; + unsigned LAddrSpace = lhQual.getAddressSpace(); + unsigned RAddrSpace = rhQual.getAddressSpace(); + if (S.getLangOpts().OpenCL) { +// OpenCL v1.1 s6.5 - Conversion between pointers to distinct address +// spaces is disallowed. +if (lhQual.isAddressSpaceSupersetOf(rhQual)) + Resul
[PATCH] D30487: ClangFormat - Add option to break before inheritance separation operator in class declaration
This revision was automatically updated to reflect the committed changes. Closed by commit rL297467: [clang-format] Add option to break before inheritance separation operator in… (authored by Abpostelnicu). Changed prior to commit: https://reviews.llvm.org/D30487?vs=91335&id=91344#toc Repository: rL LLVM https://reviews.llvm.org/D30487 Files: cfe/trunk/docs/ClangFormatStyleOptions.rst cfe/trunk/include/clang/Format/Format.h cfe/trunk/lib/Format/ContinuationIndenter.cpp cfe/trunk/lib/Format/Format.cpp cfe/trunk/lib/Format/FormatToken.h cfe/trunk/lib/Format/TokenAnnotator.cpp cfe/trunk/unittests/Format/FormatTest.cpp Index: cfe/trunk/unittests/Format/FormatTest.cpp === --- cfe/trunk/unittests/Format/FormatTest.cpp +++ cfe/trunk/unittests/Format/FormatTest.cpp @@ -1029,6 +1029,17 @@ verifyFormat("class ::A::B {};"); } +TEST_F(FormatTest, BreakBeforeInheritanceComma) { + FormatStyle StyleWithInheritanceBreak = getLLVMStyle(); + StyleWithInheritanceBreak.BreakBeforeInheritanceComma = true; + + verifyFormat("class MyClass : public X {};", StyleWithInheritanceBreak); + verifyFormat("class MyClass\n" + ": public X\n" + ", public Y {};", + StyleWithInheritanceBreak); +} + TEST_F(FormatTest, FormatsVariableDeclarationsAfterStructOrClass) { verifyFormat("class A {\n} a, b;"); verifyFormat("struct A {\n} a, b;"); @@ -8582,6 +8593,7 @@ CHECK_PARSE_BOOL(BreakBeforeTernaryOperators); CHECK_PARSE_BOOL(BreakConstructorInitializersBeforeComma); CHECK_PARSE_BOOL(BreakStringLiterals); + CHECK_PARSE_BOOL(BreakBeforeInheritanceComma) CHECK_PARSE_BOOL(ConstructorInitializerAllOnOneLineOrOnePerLine); CHECK_PARSE_BOOL(DerivePointerAlignment); CHECK_PARSE_BOOL_FIELD(DerivePointerAlignment, "DerivePointerBinding"); Index: cfe/trunk/docs/ClangFormatStyleOptions.rst === --- cfe/trunk/docs/ClangFormatStyleOptions.rst +++ cfe/trunk/docs/ClangFormatStyleOptions.rst @@ -528,6 +528,10 @@ +**BreakBeforeInheritanceComma** (``bool``) + If ``true``, in the class inheritance expression clang-format will + break before ``:`` and ``,`` if there is multiple inheritance. + **BreakBeforeTernaryOperators** (``bool``) If ``true``, ternary operators will be placed after line breaks. Index: cfe/trunk/include/clang/Format/Format.h === --- cfe/trunk/include/clang/Format/Format.h +++ cfe/trunk/include/clang/Format/Format.h @@ -422,6 +422,10 @@ /// which should not be split into lines or otherwise changed. std::string CommentPragmas; + /// \brief If ``true``, in the class inheritance expression clang-format will + /// break before ``:`` and ``,`` if there is multiple inheritance. + bool BreakBeforeInheritanceComma; + /// \brief If the constructor initializers don't fit on a line, put each /// initializer on its own line. bool ConstructorInitializerAllOnOneLineOrOnePerLine; @@ -844,6 +848,7 @@ BreakAfterJavaFieldAnnotations == R.BreakAfterJavaFieldAnnotations && BreakStringLiterals == R.BreakStringLiterals && ColumnLimit == R.ColumnLimit && CommentPragmas == R.CommentPragmas && + BreakBeforeInheritanceComma == R.BreakBeforeInheritanceComma && ConstructorInitializerAllOnOneLineOrOnePerLine == R.ConstructorInitializerAllOnOneLineOrOnePerLine && ConstructorInitializerIndentWidth == Index: cfe/trunk/lib/Format/TokenAnnotator.cpp === --- cfe/trunk/lib/Format/TokenAnnotator.cpp +++ cfe/trunk/lib/Format/TokenAnnotator.cpp @@ -676,6 +676,8 @@ case tok::comma: if (Contexts.back().InCtorInitializer) Tok->Type = TT_CtorInitializerComma; + else if (Contexts.back().InInheritanceList) +Tok->Type = TT_InheritanceComma; else if (Contexts.back().FirstStartOfName && (Contexts.size() == 1 || Line.startsWith(tok::kw_for))) { Contexts.back().FirstStartOfName->PartOfMultiVariableDeclStmt = true; @@ -945,6 +947,7 @@ bool CanBeExpression = true; bool InTemplateArgument = false; bool InCtorInitializer = false; +bool InInheritanceList = false; bool CaretFound = false; bool IsForEachMacro = false; }; @@ -1004,6 +1007,9 @@ Current.Previous->is(TT_CtorInitializerColon)) { Contexts.back().IsExpression = true; Contexts.back().InCtorInitializer = true; +} else if (Current.Previous && + Current.Previous->is(TT_InheritanceColon)) { + Contexts.back().InInheritanceList = true; } else if (Current.isOneOf(tok::r_paren, tok::greater, tok::comma)) { for (FormatToken *Previous = Current.Previous; Previous && Previous->isOneOf(tok::star, tok::amp); @@
[PATCH] D30643: [OpenCL] Extended diagnostics for atomic initialization
Anastasia added inline comments. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:8263 +def err_atomic_init_addressspace : Error< + "initialization of atomic variables is restricted to variables in global address space">; def err_atomic_init_constant : Error< echuraev wrote: > Anastasia wrote: > > Could we combine this error diag with the one below? I guess they are > > semantically very similar apart from one is about initialization and > > another is about assignment? > I'm not sure that it is a good idea to combine these errors. For example, if > developer had declared a variable non-constant and not in global address > space he would have got the same message for both errors. And it can be > difficult to determine what the exact problem is. He can fix one of the > problems but he will still get the same error. Well, I don't actually see that we check for constant anywhere so it's also OK if you want to drop this bit. Although I think the original intension of this message as I understood was to provide the most complete hint. My concern is that these two errors seem to be reporting nearly the same issue and ideally we would like to keep diagnostic list as small as possible. This also makes the file more concise and messages more consistent. https://reviews.llvm.org/D30643 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29944: libclang: Print namespaces for typedefs and type aliases
This revision was automatically updated to reflect the committed changes. Closed by commit rL297465: Print nested name specifiers for typedefs and type aliases (authored by arphaman). Changed prior to commit: https://reviews.llvm.org/D29944?vs=88376&id=91342#toc Repository: rL LLVM https://reviews.llvm.org/D29944 Files: cfe/trunk/lib/AST/TypePrinter.cpp cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp cfe/trunk/test/CXX/drs/dr2xx.cpp cfe/trunk/test/CXX/drs/dr5xx.cpp cfe/trunk/test/Index/annotate-nested-name-specifier.cpp cfe/trunk/test/Index/file-refs.cpp cfe/trunk/test/Index/print-type.cpp cfe/trunk/test/Index/recursive-cxx-member-calls.cpp cfe/trunk/test/Layout/ms-x86-basic-layout.cpp cfe/trunk/test/Misc/diag-template-diffing.cpp cfe/trunk/test/Modules/odr_hash.cpp cfe/trunk/test/SemaCXX/attr-noreturn.cpp cfe/trunk/test/SemaCXX/calling-conv-compat.cpp cfe/trunk/test/SemaCXX/cxx0x-initializer-aggregates.cpp cfe/trunk/test/SemaCXX/cxx1y-contextual-conversion-tweaks.cpp cfe/trunk/test/SemaCXX/enum-scoped.cpp cfe/trunk/test/SemaCXX/nested-name-spec.cpp cfe/trunk/test/SemaCXX/pseudo-destructors.cpp cfe/trunk/test/SemaObjCXX/arc-templates.mm cfe/trunk/test/SemaTemplate/member-access-ambig.cpp cfe/trunk/test/SemaTemplate/typename-specifier.cpp Index: cfe/trunk/test/SemaTemplate/member-access-ambig.cpp === --- cfe/trunk/test/SemaTemplate/member-access-ambig.cpp +++ cfe/trunk/test/SemaTemplate/member-access-ambig.cpp @@ -48,7 +48,7 @@ typedef int (A::*P); template struct S : T { void f() { - P(&T::X) // expected-error {{cannot cast from type 'int *' to member pointer type 'P'}} + P(&T::X) // expected-error {{cannot cast from type 'int *' to member pointer type 'AddrOfMember::P'}} == &A::X; } }; Index: cfe/trunk/test/SemaTemplate/typename-specifier.cpp === --- cfe/trunk/test/SemaTemplate/typename-specifier.cpp +++ cfe/trunk/test/SemaTemplate/typename-specifier.cpp @@ -102,7 +102,7 @@ template struct E { typedef typename T::foo foo; - typedef typename foo::bar bar; // expected-error {{type 'foo' (aka 'double') cannot be used prior to '::' because it has no members}} + typedef typename foo::bar bar; // expected-error {{type 'E::foo' (aka 'double') cannot be used prior to '::' because it has no members}} }; struct F { Index: cfe/trunk/test/Index/print-type.cpp === --- cfe/trunk/test/Index/print-type.cpp +++ cfe/trunk/test/Index/print-type.cpp @@ -17,15 +17,16 @@ Bar(outer::Foo* foo) { } typedef int FooType; + using AliasType = double; int *p; int *f(int *p, char *x, FooType z) { const FooType w = z; return p + z; } typedef double OtherType; typedef int ArrayType[5]; Baz baz; - Qux> qux; + Qux, FooType> qux; }; } @@ -87,91 +88,92 @@ // CHECK: NamespaceRef=outer:1:11 [type=] [typekind=Invalid] [isPOD=0] // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0] // CHECK: CompoundStmt= [type=] [typekind=Invalid] [isPOD=0] -// CHECK: TypedefDecl=FooType:19:15 (Definition) [type=FooType] [typekind=Typedef] [canonicaltype=int] [canonicaltypekind=Int] [isPOD=1] -// CHECK: FieldDecl=p:20:8 (Definition) [type=int *] [typekind=Pointer] [isPOD=1] [pointeetype=int] [pointeekind=Int] -// CHECK: CXXMethod=f:21:8 (Definition) [type=int *(int *, char *, FooType){{.*}}] [typekind=FunctionProto] [canonicaltype=int *(int *, char *, int){{.*}}] [canonicaltypekind=FunctionProto] [resulttype=int *] [resulttypekind=Pointer] [args= [int *] [Pointer] [char *] [Pointer] [FooType] [Typedef]] [isPOD=0] -// CHECK: ParmDecl=p:21:15 (Definition) [type=int *] [typekind=Pointer] [isPOD=1] [pointeetype=int] [pointeekind=Int] -// CHECK: ParmDecl=x:21:24 (Definition) [type=char *] [typekind=Pointer] [isPOD=1] [pointeetype=char] [pointeekind=Char_{{[US]}}] -// CHECK: ParmDecl=z:21:35 (Definition) [type=FooType] [typekind=Typedef] [canonicaltype=int] [canonicaltypekind=Int] [isPOD=1] -// CHECK: TypeRef=FooType:19:15 [type=FooType] [typekind=Typedef] [canonicaltype=int] [canonicaltypekind=Int] [isPOD=1] +// CHECK: TypedefDecl=FooType:19:15 (Definition) [type=outer::inner::Bar::FooType] [typekind=Typedef] [canonicaltype=int] [canonicaltypekind=Int] [isPOD=1] +// CHECK: TypeAliasDecl=AliasType:20:9 (Definition) [type=outer::inner::Bar::AliasType] [typekind=Typedef] [canonicaltype=double] [canonicaltypekind=Double] [isPOD=1] +// CHECK: FieldDecl=p:21:8 (Definition) [type=int *] [typekind=Pointer] [isPOD=1] [pointeetype=int] [pointeekind=Int] +// CHECK: CXXMethod=f:22:8 (Definition) [type=int *(int *, char *, outer::inner::Bar::FooType){{.*}}] [typekind=FunctionProto] [canonicaltype=int *(int *, char *, int){{.*}}] [canonicaltypekind=FunctionProto] [resulttype=int *] [resulttypekind=Pointe
r297465 - Print nested name specifiers for typedefs and type aliases
Author: arphaman Date: Fri Mar 10 09:04:58 2017 New Revision: 297465 URL: http://llvm.org/viewvc/llvm-project?rev=297465&view=rev Log: Print nested name specifiers for typedefs and type aliases Printing typedefs or type aliases using clang_getTypeSpelling() is missing the namespace they are defined in. This is in contrast to other types that always yield the full typename including namespaces. Patch by Michael Reiher! Differential Revision: https://reviews.llvm.org/D29944 Modified: cfe/trunk/lib/AST/TypePrinter.cpp cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp cfe/trunk/test/CXX/drs/dr2xx.cpp cfe/trunk/test/CXX/drs/dr5xx.cpp cfe/trunk/test/Index/annotate-nested-name-specifier.cpp cfe/trunk/test/Index/file-refs.cpp cfe/trunk/test/Index/print-type.cpp cfe/trunk/test/Index/recursive-cxx-member-calls.cpp cfe/trunk/test/Layout/ms-x86-basic-layout.cpp cfe/trunk/test/Misc/diag-template-diffing.cpp cfe/trunk/test/Modules/odr_hash.cpp cfe/trunk/test/SemaCXX/attr-noreturn.cpp cfe/trunk/test/SemaCXX/calling-conv-compat.cpp cfe/trunk/test/SemaCXX/cxx0x-initializer-aggregates.cpp cfe/trunk/test/SemaCXX/cxx1y-contextual-conversion-tweaks.cpp cfe/trunk/test/SemaCXX/enum-scoped.cpp cfe/trunk/test/SemaCXX/nested-name-spec.cpp cfe/trunk/test/SemaCXX/pseudo-destructors.cpp cfe/trunk/test/SemaObjCXX/arc-templates.mm cfe/trunk/test/SemaTemplate/member-access-ambig.cpp cfe/trunk/test/SemaTemplate/typename-specifier.cpp Modified: cfe/trunk/lib/AST/TypePrinter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypePrinter.cpp?rev=297465&r1=297464&r2=297465&view=diff == --- cfe/trunk/lib/AST/TypePrinter.cpp (original) +++ cfe/trunk/lib/AST/TypePrinter.cpp Fri Mar 10 09:04:58 2017 @@ -96,7 +96,7 @@ namespace { static bool canPrefixQualifiers(const Type *T, bool &NeedARCStrongQualifier); void spaceBeforePlaceHolder(raw_ostream &OS); -void printTypeSpec(const NamedDecl *D, raw_ostream &OS); +void printTypeSpec(NamedDecl *D, raw_ostream &OS); void printBefore(const Type *ty, Qualifiers qs, raw_ostream &OS); void printBefore(QualType T, raw_ostream &OS); @@ -798,7 +798,14 @@ void TypePrinter::printFunctionNoProtoAf printAfter(T->getReturnType(), OS); } -void TypePrinter::printTypeSpec(const NamedDecl *D, raw_ostream &OS) { +void TypePrinter::printTypeSpec(NamedDecl *D, raw_ostream &OS) { + + // Compute the full nested-name-specifier for this type. + // In C, this will always be empty except when the type + // being printed is anonymous within other Record. + if (!Policy.SuppressScope) +AppendScope(D->getDeclContext(), OS); + IdentifierInfo *II = D->getIdentifier(); OS << II->getName(); spaceBeforePlaceHolder(OS); Modified: cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp?rev=297465&r1=297464&r2=297465&view=diff == --- cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp (original) +++ cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp Fri Mar 10 09:04:58 2017 @@ -192,7 +192,7 @@ namespace InhCtor { // FIXME: Consider reusing the same diagnostic between dependent and non-dependent contexts typedef int I; struct UsingInt { -using I::I; // expected-error {{'I' (aka 'int') is not a class, namespace, or enumeration}} +using I::I; // expected-error {{'InhCtor::I' (aka 'int') is not a class, namespace, or enumeration}} }; template struct UsingIntTemplate { using T::T; // expected-error {{type 'int' cannot be used prior to '::' because it has no members}} Modified: cfe/trunk/test/CXX/drs/dr2xx.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr2xx.cpp?rev=297465&r1=297464&r2=297465&view=diff == --- cfe/trunk/test/CXX/drs/dr2xx.cpp (original) +++ cfe/trunk/test/CXX/drs/dr2xx.cpp Fri Mar 10 09:04:58 2017 @@ -1014,7 +1014,7 @@ namespace dr294 { // dr294: no namespace dr295 { // dr295: 3.7 typedef int f(); - const f g; // expected-warning {{'const' qualifier on function type 'f' (aka 'int ()') has no effect}} + const f g; // expected-warning {{'const' qualifier on function type 'dr295::f' (aka 'int ()') has no effect}} f &r = g; template struct X { const T &f; @@ -1022,10 +1022,10 @@ namespace dr295 { // dr295: 3.7 X x = {g}; typedef int U(); - typedef const U U; // expected-warning {{'const' qualifier on function type 'U' (aka 'int ()') has no effect}} + typedef const U U; // expected-warning {{'const' qualifier on function type 'dr295::U' (aka 'int ()') has no effect}}
r297461 - [analyzer] Extend block in critical section check with C11 and Pthread APIs.
Author: xazax Date: Fri Mar 10 08:50:12 2017 New Revision: 297461 URL: http://llvm.org/viewvc/llvm-project?rev=297461&view=rev Log: [analyzer] Extend block in critical section check with C11 and Pthread APIs. Patch by Zoltan Daniel Torok! Differential Revision: https://reviews.llvm.org/D29567 Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp cfe/trunk/test/Analysis/block-in-critical-section.cpp cfe/trunk/www/analyzer/alpha_checks.html Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp?rev=297461&r1=297460&r2=297461&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp Fri Mar 10 08:50:12 2017 @@ -29,7 +29,9 @@ namespace { class BlockInCriticalSectionChecker : public Checker { - CallDescription LockFn, UnlockFn, SleepFn, GetcFn, FgetsFn, ReadFn, RecvFn; + CallDescription LockFn, UnlockFn, SleepFn, GetcFn, FgetsFn, ReadFn, RecvFn, + PthreadLockFn, PthreadTryLockFn, PthreadUnlockFn, + MtxLock, MtxTimedLock, MtxTryLock, MtxUnlock; std::unique_ptr BlockInCritSectionBugType; @@ -40,6 +42,10 @@ class BlockInCriticalSectionChecker : pu public: BlockInCriticalSectionChecker(); + bool isBlockingFunction(const CallEvent &Call) const; + bool isLockFunction(const CallEvent &Call) const; + bool isUnlockFunction(const CallEvent &Call) const; + void checkPreCall(const CallEvent &Call, CheckerContext &C) const; /// Process unlock. @@ -55,34 +61,69 @@ REGISTER_TRAIT_WITH_PROGRAMSTATE(MutexCo BlockInCriticalSectionChecker::BlockInCriticalSectionChecker() : LockFn("lock"), UnlockFn("unlock"), SleepFn("sleep"), GetcFn("getc"), - FgetsFn("fgets"), ReadFn("read"), RecvFn("recv") { + FgetsFn("fgets"), ReadFn("read"), RecvFn("recv"), + PthreadLockFn("pthread_mutex_lock"), + PthreadTryLockFn("pthread_mutex_trylock"), + PthreadUnlockFn("pthread_mutex_unlock"), + MtxLock("mtx_lock"), + MtxTimedLock("mtx_timedlock"), + MtxTryLock("mtx_trylock"), + MtxUnlock("mtx_unlock") { // Initialize the bug type. BlockInCritSectionBugType.reset( new BugType(this, "Call to blocking function in critical section", "Blocking Error")); } +bool BlockInCriticalSectionChecker::isBlockingFunction(const CallEvent &Call) const { + if (Call.isCalled(SleepFn) + || Call.isCalled(GetcFn) + || Call.isCalled(FgetsFn) + || Call.isCalled(ReadFn) + || Call.isCalled(RecvFn)) { +return true; + } + return false; +} + +bool BlockInCriticalSectionChecker::isLockFunction(const CallEvent &Call) const { + if (Call.isCalled(LockFn) + || Call.isCalled(PthreadLockFn) + || Call.isCalled(PthreadTryLockFn) + || Call.isCalled(MtxLock) + || Call.isCalled(MtxTimedLock) + || Call.isCalled(MtxTryLock)) { +return true; + } + return false; +} + +bool BlockInCriticalSectionChecker::isUnlockFunction(const CallEvent &Call) const { + if (Call.isCalled(UnlockFn) + || Call.isCalled(PthreadUnlockFn) + || Call.isCalled(MtxUnlock)) { +return true; + } + return false; +} + void BlockInCriticalSectionChecker::checkPreCall(const CallEvent &Call, CheckerContext &C) const { } void BlockInCriticalSectionChecker::checkPostCall(const CallEvent &Call, CheckerContext &C) const { - if (!Call.isCalled(LockFn) - && !Call.isCalled(SleepFn) - && !Call.isCalled(GetcFn) - && !Call.isCalled(FgetsFn) - && !Call.isCalled(ReadFn) - && !Call.isCalled(RecvFn) - && !Call.isCalled(UnlockFn)) + if (!isBlockingFunction(Call) + && !isLockFunction(Call) + && !isUnlockFunction(Call)) return; ProgramStateRef State = C.getState(); unsigned mutexCount = State->get(); - if (Call.isCalled(UnlockFn) && mutexCount > 0) { + if (isUnlockFunction(Call) && mutexCount > 0) { State = State->set(--mutexCount); C.addTransition(State); - } else if (Call.isCalled(LockFn)) { + } else if (isLockFunction(Call)) { State = State->set(++mutexCount); C.addTransition(State); } else if (mutexCount > 0) { @@ -97,8 +138,11 @@ void BlockInCriticalSectionChecker::repo if (!ErrNode) return; - auto R = llvm::make_unique(*BlockInCritSectionBugType, - "A blocking function %s is called inside a critical section.", ErrNode); + std::string msg; + llvm::raw_string_ostream os(msg); + os << "Call to blocking function '" << Call.getCalleeIdentifier()->getName() + << "' inside of critical section"; + auto R = llvm::make_unique(*BlockInCr
[PATCH] D30487: ClangFormat - Add option to break before inheritance separation operator in class declaration
Abpostelnicu updated this revision to Diff 91335. Abpostelnicu marked an inline comment as done. Abpostelnicu added a comment. Fixed two spell errors. Repository: rL LLVM https://reviews.llvm.org/D30487 Files: docs/ClangFormatStyleOptions.rst include/clang/Format/Format.h lib/Format/ContinuationIndenter.cpp lib/Format/Format.cpp lib/Format/FormatToken.h lib/Format/TokenAnnotator.cpp unittests/Format/FormatTest.cpp Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -1029,6 +1029,17 @@ verifyFormat("class ::A::B {};"); } +TEST_F(FormatTest, BreakBeforeInheritanceComma) { + FormatStyle StyleWithInheritanceBreak = getLLVMStyle(); + StyleWithInheritanceBreak.BreakBeforeInheritanceComma = true; + + verifyFormat("class MyClass : public X {};", StyleWithInheritanceBreak); + verifyFormat("class MyClass\n" + ": public X\n" + ", public Y {};", + StyleWithInheritanceBreak); +} + TEST_F(FormatTest, FormatsVariableDeclarationsAfterStructOrClass) { verifyFormat("class A {\n} a, b;"); verifyFormat("struct A {\n} a, b;"); @@ -8582,6 +8593,7 @@ CHECK_PARSE_BOOL(BreakBeforeTernaryOperators); CHECK_PARSE_BOOL(BreakConstructorInitializersBeforeComma); CHECK_PARSE_BOOL(BreakStringLiterals); + CHECK_PARSE_BOOL(BreakBeforeInheritanceComma) CHECK_PARSE_BOOL(ConstructorInitializerAllOnOneLineOrOnePerLine); CHECK_PARSE_BOOL(DerivePointerAlignment); CHECK_PARSE_BOOL_FIELD(DerivePointerAlignment, "DerivePointerBinding"); Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -676,6 +676,8 @@ case tok::comma: if (Contexts.back().InCtorInitializer) Tok->Type = TT_CtorInitializerComma; + else if (Contexts.back().InInheritanceList) +Tok->Type = TT_InheritanceComma; else if (Contexts.back().FirstStartOfName && (Contexts.size() == 1 || Line.startsWith(tok::kw_for))) { Contexts.back().FirstStartOfName->PartOfMultiVariableDeclStmt = true; @@ -945,6 +947,7 @@ bool CanBeExpression = true; bool InTemplateArgument = false; bool InCtorInitializer = false; +bool InInheritanceList = false; bool CaretFound = false; bool IsForEachMacro = false; }; @@ -1004,6 +1007,9 @@ Current.Previous->is(TT_CtorInitializerColon)) { Contexts.back().IsExpression = true; Contexts.back().InCtorInitializer = true; +} else if (Current.Previous && + Current.Previous->is(TT_InheritanceColon)) { + Contexts.back().InInheritanceList = true; } else if (Current.isOneOf(tok::r_paren, tok::greater, tok::comma)) { for (FormatToken *Previous = Current.Previous; Previous && Previous->isOneOf(tok::star, tok::amp); @@ -2474,6 +2480,10 @@ Style.BreakConstructorInitializersBeforeComma && !Style.ConstructorInitializerAllOnOneLineOrOnePerLine) return true; + // Break only if we have multiple inheritance. + if (Style.BreakBeforeInheritanceComma && + Right.is(TT_InheritanceComma)) + return true; if (Right.is(tok::string_literal) && Right.TokenText.startswith("R\"")) // Raw string literals are special wrt. line breaks. The author has made a // deliberate choice and might have aligned the contents of the string @@ -2653,6 +2663,10 @@ if (Right.is(TT_CtorInitializerComma) && Style.BreakConstructorInitializersBeforeComma) return true; + if (Left.is(TT_InheritanceComma) && Style.BreakBeforeInheritanceComma) +return false; + if (Right.is(TT_InheritanceComma) && Style.BreakBeforeInheritanceComma) +return true; if ((Left.is(tok::greater) && Right.is(tok::greater)) || (Left.is(tok::less) && Right.is(tok::less))) return false; Index: lib/Format/FormatToken.h === --- lib/Format/FormatToken.h +++ lib/Format/FormatToken.h @@ -48,6 +48,7 @@ TYPE(FunctionTypeLParen) \ TYPE(ImplicitStringLiteral) \ TYPE(InheritanceColon) \ + TYPE(InheritanceComma) \ TYPE(InlineASMBrace) \ TYPE(InlineASMColon) \ TYPE(JavaAnnotation) \ Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -298,6 +298,8 @@ IO.mapOptional("BreakStringLiterals", Style.BreakStringLiterals); IO.mapOptional("ColumnLimit", Style.ColumnLimit); IO.mapOptional("CommentPragmas", Style.CommentPragmas); +IO.mapOptional("BreakBeforeInheritanceComma", + Style.BreakBeforeInheritanceComma); IO.mapOptional("ConstructorInitializerAllOnOneLineOrOnePerLine", Style.ConstructorInitializerAllOnOneLineOrOnePerLine); IO.
[PATCH] D29944: libclang: Print namespaces for typedefs and type aliases
arphaman added a comment. In https://reviews.llvm.org/D29944#697587, @redm123 wrote: > I guess so. I don't think I'm allowed to commit. So I would appreciate it. Sure, I will commit it right now. > Which release version would that be in? 4.1 I guess? It will be in the next major release: 5.0 (After 4.0 LLVM switched to a different versioning system where major released will now go from 4.0 to 5.0, etc. instead of 4.0 to 4.1, etc.). > Thanks for your help! https://reviews.llvm.org/D29944 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: Patch for Bug 30413, including test case
Hi Akira, Thank you very much! Please let me know if I need to take any further steps beyond this email to cfe-commits in order for the patch and the unit test to be committed. Thanks, David > On Mar 9, 2017, at 4:46 PM, Akira Hatanaka wrote: > > Hi David, > > The patch looks good to me. > >> On Mar 9, 2017, at 1:01 PM, Lobron, David wrote: >> >> Hi Akira, >> >>> My concern is that the patch changes the encoding of @encode(id) >>> on Darwin, which I think isn’t what you are trying to fix. If you compile >>> the following code with command “clang -cc1 -triple x86_64-apple-macosx”, >>> the type encoding changes after applying the patch. >>> >>> const char *foo() { >>> return @encode(id); >>> } >>> >>> It seems like you can fix your problem without affecting Darwin by passing >>> an extra argument to getObjCEncodingForType, just like >>> CGObjCCommonMac::GetMethodVarType does. >> >> Ah, thanks- I understand now. Yes, this change seems a lot safer, and I >> verified that it passes my test. I've attached my new patch file, and I've >> also attached the test again. Please let me know if this works for you or >> if you think it needs any additional work. >> >> --David >> >> > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30822: [clang-format] Indent the same amount a sequence of string literals
krasimir abandoned this revision. krasimir added a comment. this is nonsense https://reviews.llvm.org/D30822 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30487: ClangFormat - Add option to break before inheritance separation operator in class declaration
kimgr added a comment. A few more 'inhertiance' left, otherwise spelling looks good to me :-) Comment at: lib/Format/TokenAnnotator.cpp:679 Tok->Type = TT_CtorInitializerComma; + else if (Contexts.back().InInhertianceList) +Tok->Type = TT_InheritanceComma; This still says 'Inhertiance' Comment at: lib/Format/TokenAnnotator.cpp:950 bool InCtorInitializer = false; +bool InInhertianceList = false; bool CaretFound = false; 'Inhertiance' Repository: rL LLVM https://reviews.llvm.org/D30487 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30487: ClangFormat - Add option to break before inheritance separation operator in class declaration
Abpostelnicu updated this revision to Diff 91334. Repository: rL LLVM https://reviews.llvm.org/D30487 Files: docs/ClangFormatStyleOptions.rst include/clang/Format/Format.h lib/Format/ContinuationIndenter.cpp lib/Format/Format.cpp lib/Format/FormatToken.h lib/Format/TokenAnnotator.cpp unittests/Format/FormatTest.cpp Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -1029,6 +1029,17 @@ verifyFormat("class ::A::B {};"); } +TEST_F(FormatTest, BreakBeforeInheritanceComma) { + FormatStyle StyleWithInheritanceBreak = getLLVMStyle(); + StyleWithInheritanceBreak.BreakBeforeInheritanceComma = true; + + verifyFormat("class MyClass : public X {};", StyleWithInheritanceBreak); + verifyFormat("class MyClass\n" + ": public X\n" + ", public Y {};", + StyleWithInheritanceBreak); +} + TEST_F(FormatTest, FormatsVariableDeclarationsAfterStructOrClass) { verifyFormat("class A {\n} a, b;"); verifyFormat("struct A {\n} a, b;"); @@ -8582,6 +8593,7 @@ CHECK_PARSE_BOOL(BreakBeforeTernaryOperators); CHECK_PARSE_BOOL(BreakConstructorInitializersBeforeComma); CHECK_PARSE_BOOL(BreakStringLiterals); + CHECK_PARSE_BOOL(BreakBeforeInheritanceComma) CHECK_PARSE_BOOL(ConstructorInitializerAllOnOneLineOrOnePerLine); CHECK_PARSE_BOOL(DerivePointerAlignment); CHECK_PARSE_BOOL_FIELD(DerivePointerAlignment, "DerivePointerBinding"); Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -676,6 +676,8 @@ case tok::comma: if (Contexts.back().InCtorInitializer) Tok->Type = TT_CtorInitializerComma; + else if (Contexts.back().InInhertianceList) +Tok->Type = TT_InheritanceComma; else if (Contexts.back().FirstStartOfName && (Contexts.size() == 1 || Line.startsWith(tok::kw_for))) { Contexts.back().FirstStartOfName->PartOfMultiVariableDeclStmt = true; @@ -945,6 +947,7 @@ bool CanBeExpression = true; bool InTemplateArgument = false; bool InCtorInitializer = false; +bool InInhertianceList = false; bool CaretFound = false; bool IsForEachMacro = false; }; @@ -1004,6 +1007,9 @@ Current.Previous->is(TT_CtorInitializerColon)) { Contexts.back().IsExpression = true; Contexts.back().InCtorInitializer = true; +} else if (Current.Previous && + Current.Previous->is(TT_InheritanceColon)) { + Contexts.back().InInhertianceList = true; } else if (Current.isOneOf(tok::r_paren, tok::greater, tok::comma)) { for (FormatToken *Previous = Current.Previous; Previous && Previous->isOneOf(tok::star, tok::amp); @@ -2474,6 +2480,10 @@ Style.BreakConstructorInitializersBeforeComma && !Style.ConstructorInitializerAllOnOneLineOrOnePerLine) return true; + // Break only if we have multiple inheritance. + if (Style.BreakBeforeInheritanceComma && + Right.is(TT_InheritanceComma)) + return true; if (Right.is(tok::string_literal) && Right.TokenText.startswith("R\"")) // Raw string literals are special wrt. line breaks. The author has made a // deliberate choice and might have aligned the contents of the string @@ -2653,6 +2663,10 @@ if (Right.is(TT_CtorInitializerComma) && Style.BreakConstructorInitializersBeforeComma) return true; + if (Left.is(TT_InheritanceComma) && Style.BreakBeforeInheritanceComma) +return false; + if (Right.is(TT_InheritanceComma) && Style.BreakBeforeInheritanceComma) +return true; if ((Left.is(tok::greater) && Right.is(tok::greater)) || (Left.is(tok::less) && Right.is(tok::less))) return false; Index: lib/Format/FormatToken.h === --- lib/Format/FormatToken.h +++ lib/Format/FormatToken.h @@ -48,6 +48,7 @@ TYPE(FunctionTypeLParen) \ TYPE(ImplicitStringLiteral) \ TYPE(InheritanceColon) \ + TYPE(InheritanceComma) \ TYPE(InlineASMBrace) \ TYPE(InlineASMColon) \ TYPE(JavaAnnotation) \ Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -298,6 +298,8 @@ IO.mapOptional("BreakStringLiterals", Style.BreakStringLiterals); IO.mapOptional("ColumnLimit", Style.ColumnLimit); IO.mapOptional("CommentPragmas", Style.CommentPragmas); +IO.mapOptional("BreakBeforeInheritanceComma", + Style.BreakBeforeInheritanceComma); IO.mapOptional("ConstructorInitializerAllOnOneLineOrOnePerLine", Style.ConstructorInitializerAllOnOneLineOrOnePerLine); IO.mapOptional("ConstructorInitializerIndentWidth", @@ -521,6 +523,7 @@ fals
[PATCH] D28136: [OpenCL] Implement as_type operator as alias of __builtin_astype.
echuraev added a comment. In https://reviews.llvm.org/D28136#634356, @Anastasia wrote: > This has been discussed during the initial review for the header: > http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160425/157187.html > > The main issue is after preprocessing the header the original function name > is no longer available in diagnostics reported. The spec defines as_type as a > builtin function and not a macro. Additionally your patch would allow as_type > to be used with extra type (not only those defined in spec). Also I don't see > the problem to implement as_type with just simply calling a builtin. It > should be inlined later anyways. I think that this patch is really necessary because in some cases previous implementation doesn't give a diagnostic. Please see test case that I have added to this review. With current implementation //char// variable will be cast to //int//. You can see the following part of llvm ir: %0 = load i8, i8* %src, align 1 %conv = sext i8 %0 to i32 %call = call i32 @_Z6as_inti(i32 %conv) #2 So there is a bug and we didn't get error that the size of char isn't equal to size of int. Program is compiled without any problems. If as_type functions will be defined in macro then we will have the following message: error: invalid reinterpretation: sizes of 'float' and 'char' must match int dst = as_int( src ); ^~~ ././llvm/tools/clang/lib/Headers/opencl-c-common.h:6615:21: note: expanded from macro 'as_int' #define as_int(x) __builtin_astype((x), int) ^~~~ https://reviews.llvm.org/D28136 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30798: [analyzer] Turn suppress-c++-stdlib on by default
a.sidorin added a comment. I have no any objection on this change. Repository: rL LLVM https://reviews.llvm.org/D30798 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30798: [analyzer] Turn suppress-c++-stdlib on by default
NoQ added a comment. I'd like to clarify that in case of path-sensitive analysis there are actually three warning classes to consider. 1. Warnings that reside completely in system headers and indicate bugs in system headers, most likely falsely. 2. Warnings that originate from the main file and indicate misuse of system header APIs, likely correctly. 3. Warnings that originate from the main file, but still indicate bugs in system headers, because the part of the path that stays in the main file is irrelevant to the warning. This change suppresses 3, and as a side effect we suppress 1, because discriminating between 1 and 3 is hard* . We never needed to suppress 2, because they're never created to begin with: AnalysisConsumer doesn't consider header-only functions for top-level analysis. __ // * I think that actually such discrimination is curious and probably worth investigating. We could try to see which symbols (originating from where) participate in the equation that expresses the invariant violation of which causes the warning. We could potentially improve our suppressions greatly (maybe even make them non-hackish) and probably avoid the common problems with inlining this way. Just brainstorming. Repository: rL LLVM https://reviews.llvm.org/D30798 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30487: ClangFormat - Add option to break before inheritance separation operator in class declaration
Abpostelnicu added inline comments. Comment at: lib/Format/ContinuationIndenter.cpp:355 + if (Current.is(TT_InheritanceColon)) +State.Stack.back().NoLineBreak = true; djasper wrote: > Can you leave a comment here: > > // Don't break within the inheritance declaration unless the ":" is on a > new line. I've modified the comment since this should be valid only if Style.BreakBeforeInheritanceComma is set to true otherwise we would be in the strange case where the input where the input is: ``` class A : public B, public C {} ``` And this would be translated to something like: ``` class A : public B, public C {} ``` Repository: rL LLVM https://reviews.llvm.org/D30487 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30487: ClangFormat - Add option to break before inheritance separation operator in class declaration
djasper added inline comments. Comment at: lib/Format/TokenAnnotator.cpp:2666 return true; + if (Left.is(TT_InheritanceComma) && + Style.BreakBeforeInheritanceComma) Do these now fit on one line? Repository: rL LLVM https://reviews.llvm.org/D30487 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30487: ClangFormat - Add option to break before inheritance separation operator in class declaration
Abpostelnicu updated this revision to Diff 91330. Abpostelnicu marked an inline comment as done. Repository: rL LLVM https://reviews.llvm.org/D30487 Files: docs/ClangFormatStyleOptions.rst include/clang/Format/Format.h lib/Format/ContinuationIndenter.cpp lib/Format/Format.cpp lib/Format/FormatToken.h lib/Format/TokenAnnotator.cpp unittests/Format/FormatTest.cpp Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -1029,6 +1029,17 @@ verifyFormat("class ::A::B {};"); } +TEST_F(FormatTest, BreakBeforeInheritanceComma) { + FormatStyle StyleWithInheritanceBreak = getLLVMStyle(); + StyleWithInheritanceBreak.BreakBeforeInheritanceComma = true; + + verifyFormat("class MyClass : public X {};", StyleWithInheritanceBreak); + verifyFormat("class MyClass\n" + ": public X\n" + ", public Y {};", + StyleWithInheritanceBreak); +} + TEST_F(FormatTest, FormatsVariableDeclarationsAfterStructOrClass) { verifyFormat("class A {\n} a, b;"); verifyFormat("struct A {\n} a, b;"); @@ -8582,6 +8593,7 @@ CHECK_PARSE_BOOL(BreakBeforeTernaryOperators); CHECK_PARSE_BOOL(BreakConstructorInitializersBeforeComma); CHECK_PARSE_BOOL(BreakStringLiterals); + CHECK_PARSE_BOOL(BreakBeforeInheritanceComma) CHECK_PARSE_BOOL(ConstructorInitializerAllOnOneLineOrOnePerLine); CHECK_PARSE_BOOL(DerivePointerAlignment); CHECK_PARSE_BOOL_FIELD(DerivePointerAlignment, "DerivePointerBinding"); Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -676,6 +676,8 @@ case tok::comma: if (Contexts.back().InCtorInitializer) Tok->Type = TT_CtorInitializerComma; + else if (Contexts.back().InInhertianceList) +Tok->Type = TT_InheritanceComma; else if (Contexts.back().FirstStartOfName && (Contexts.size() == 1 || Line.startsWith(tok::kw_for))) { Contexts.back().FirstStartOfName->PartOfMultiVariableDeclStmt = true; @@ -945,6 +947,7 @@ bool CanBeExpression = true; bool InTemplateArgument = false; bool InCtorInitializer = false; +bool InInhertianceList = false; bool CaretFound = false; bool IsForEachMacro = false; }; @@ -1004,6 +1007,9 @@ Current.Previous->is(TT_CtorInitializerColon)) { Contexts.back().IsExpression = true; Contexts.back().InCtorInitializer = true; +} else if (Current.Previous && + Current.Previous->is(TT_InheritanceColon)) { + Contexts.back().InInhertianceList = true; } else if (Current.isOneOf(tok::r_paren, tok::greater, tok::comma)) { for (FormatToken *Previous = Current.Previous; Previous && Previous->isOneOf(tok::star, tok::amp); @@ -2474,6 +2480,10 @@ Style.BreakConstructorInitializersBeforeComma && !Style.ConstructorInitializerAllOnOneLineOrOnePerLine) return true; + // Break only if we have multiple inheritance. + if (Style.BreakBeforeInheritanceComma && + Right.is(TT_InheritanceComma)) + return true; if (Right.is(tok::string_literal) && Right.TokenText.startswith("R\"")) // Raw string literals are special wrt. line breaks. The author has made a // deliberate choice and might have aligned the contents of the string @@ -2653,6 +2663,12 @@ if (Right.is(TT_CtorInitializerComma) && Style.BreakConstructorInitializersBeforeComma) return true; + if (Left.is(TT_InheritanceComma) && + Style.BreakBeforeInheritanceComma) +return false; + if (Right.is(TT_InheritanceComma) && + Style.BreakBeforeInheritanceComma) +return true; if ((Left.is(tok::greater) && Right.is(tok::greater)) || (Left.is(tok::less) && Right.is(tok::less))) return false; Index: lib/Format/FormatToken.h === --- lib/Format/FormatToken.h +++ lib/Format/FormatToken.h @@ -48,6 +48,7 @@ TYPE(FunctionTypeLParen) \ TYPE(ImplicitStringLiteral) \ TYPE(InheritanceColon) \ + TYPE(InheritanceComma) \ TYPE(InlineASMBrace) \ TYPE(InlineASMColon) \ TYPE(JavaAnnotation) \ Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -298,6 +298,8 @@ IO.mapOptional("BreakStringLiterals", Style.BreakStringLiterals); IO.mapOptional("ColumnLimit", Style.ColumnLimit); IO.mapOptional("CommentPragmas", Style.CommentPragmas); +IO.mapOptional("BreakBeforeInheritanceComma", + Style.BreakBeforeInheritanceComma); IO.mapOptional("ConstructorInitializerAllOnOneLineOrOnePerLine", Style.ConstructorInitializerAllOnOneLineOrOnePerLine); IO.mapOptional("ConstructorInitializerIndentW
[PATCH] D28136: [OpenCL] Implement as_type operator as alias of __builtin_astype.
echuraev updated this revision to Diff 91327. https://reviews.llvm.org/D28136 Files: lib/Headers/opencl-c.h test/SemaOpenCL/as_type.cl Index: test/SemaOpenCL/as_type.cl === --- test/SemaOpenCL/as_type.cl +++ test/SemaOpenCL/as_type.cl @@ -1,7 +1,4 @@ -// RUN: %clang_cc1 %s -emit-llvm -triple spir-unknown-unknown -o - -verify -fsyntax-only - -typedef __attribute__(( ext_vector_type(3) )) char char3; -typedef __attribute__(( ext_vector_type(16) )) char char16; +// RUN: %clang_cc1 %s -emit-llvm -triple spir-unknown-unknown -finclude-default-header -o - -verify -fsyntax-only char3 f1(char16 x) { return __builtin_astype(x, char3); // expected-error{{invalid reinterpretation: sizes of 'char3' (vector of 3 'char' values) and 'char16' (vector of 16 'char' values) must match}} @@ -11,3 +8,7 @@ return __builtin_astype(x, char16); // expected-error{{invalid reinterpretation: sizes of 'char16' (vector of 16 'char' values) and 'int' must match}} } +void foo() { +char src = 1; +int dst = as_int(src); // expected-error{{invalid reinterpretation: sizes of 'int' and 'char' must match}} +} Index: lib/Headers/opencl-c.h === --- lib/Headers/opencl-c.h +++ lib/Headers/opencl-c.h @@ -6584,777 +6584,85 @@ * OpenCL v1.1/1.2/2.0 s6.2.4.2 - as_type operators * Reinterprets a data type as another data type of the same size */ -char __ovld __cnfn as_char(char); -char __ovld __cnfn as_char(uchar); - -char2 __ovld __cnfn as_char2(char2); -char2 __ovld __cnfn as_char2(uchar2); -char2 __ovld __cnfn as_char2(short); -char2 __ovld __cnfn as_char2(ushort); - -char3 __ovld __cnfn as_char3(char3); -char3 __ovld __cnfn as_char3(char4); -char3 __ovld __cnfn as_char3(uchar3); -char3 __ovld __cnfn as_char3(uchar4); -char3 __ovld __cnfn as_char3(short2); -char3 __ovld __cnfn as_char3(ushort2); -char3 __ovld __cnfn as_char3(int); -char3 __ovld __cnfn as_char3(uint); -char3 __ovld __cnfn as_char3(float); - -char4 __ovld __cnfn as_char4(char3); -char4 __ovld __cnfn as_char4(char4); -char4 __ovld __cnfn as_char4(uchar3); -char4 __ovld __cnfn as_char4(uchar4); -char4 __ovld __cnfn as_char4(short2); -char4 __ovld __cnfn as_char4(ushort2); -char4 __ovld __cnfn as_char4(int); -char4 __ovld __cnfn as_char4(uint); -char4 __ovld __cnfn as_char4(float); - -char8 __ovld __cnfn as_char8(char8); -char8 __ovld __cnfn as_char8(uchar8); -char8 __ovld __cnfn as_char8(short3); -char8 __ovld __cnfn as_char8(short4); -char8 __ovld __cnfn as_char8(ushort3); -char8 __ovld __cnfn as_char8(ushort4); -char8 __ovld __cnfn as_char8(int2); -char8 __ovld __cnfn as_char8(uint2); -char8 __ovld __cnfn as_char8(long); -char8 __ovld __cnfn as_char8(ulong); -char8 __ovld __cnfn as_char8(float2); - -char16 __ovld __cnfn as_char16(char16); -char16 __ovld __cnfn as_char16(uchar16); -char16 __ovld __cnfn as_char16(short8); -char16 __ovld __cnfn as_char16(ushort8); -char16 __ovld __cnfn as_char16(int3); -char16 __ovld __cnfn as_char16(int4); -char16 __ovld __cnfn as_char16(uint3); -char16 __ovld __cnfn as_char16(uint4); -char16 __ovld __cnfn as_char16(long2); -char16 __ovld __cnfn as_char16(ulong2); -char16 __ovld __cnfn as_char16(float3); -char16 __ovld __cnfn as_char16(float4); - -uchar __ovld __cnfn as_uchar(char); -uchar __ovld __cnfn as_uchar(uchar); - -uchar2 __ovld __cnfn as_uchar2(char2); -uchar2 __ovld __cnfn as_uchar2(uchar2); -uchar2 __ovld __cnfn as_uchar2(short); -uchar2 __ovld __cnfn as_uchar2(ushort); - -uchar3 __ovld __cnfn as_uchar3(char3); -uchar3 __ovld __cnfn as_uchar3(char4); -uchar3 __ovld __cnfn as_uchar3(uchar3); -uchar3 __ovld __cnfn as_uchar3(uchar4); -uchar3 __ovld __cnfn as_uchar3(short2); -uchar3 __ovld __cnfn as_uchar3(ushort2); -uchar3 __ovld __cnfn as_uchar3(int); -uchar3 __ovld __cnfn as_uchar3(uint); -uchar3 __ovld __cnfn as_uchar3(float); - -uchar4 __ovld __cnfn as_uchar4(char3); -uchar4 __ovld __cnfn as_uchar4(char4); -uchar4 __ovld __cnfn as_uchar4(uchar3); -uchar4 __ovld __cnfn as_uchar4(uchar4); -uchar4 __ovld __cnfn as_uchar4(short2); -uchar4 __ovld __cnfn as_uchar4(ushort2); -uchar4 __ovld __cnfn as_uchar4(int); -uchar4 __ovld __cnfn as_uchar4(uint); -uchar4 __ovld __cnfn as_uchar4(float); - -uchar8 __ovld __cnfn as_uchar8(char8); -uchar8 __ovld __cnfn as_uchar8(uchar8); -uchar8 __ovld __cnfn as_uchar8(short3); -uchar8 __ovld __cnfn as_uchar8(short4); -uchar8 __ovld __cnfn as_uchar8(ushort3); -uchar8 __ovld __cnfn as_uchar8(ushort4); -uchar8 __ovld __cnfn as_uchar8(int2); -uchar8 __ovld __cnfn as_uchar8(uint2); -uchar8 __ovld __cnfn as_uchar8(long); -uchar8 __ovld __cnfn as_uchar8(ulong); -uchar8 __ovld __cnfn as_uchar8(float2); - -uchar16 __ovld __cnfn as_uchar16(char16); -uchar16 __ovld __cnfn as_uchar16(uchar16); -uchar16 __ovld __cnfn as_uchar16(short8); -uchar16 __ovld __cnfn as_uchar16(ushort8); -uchar16 __ovld __cnfn as_uchar16(int3); -uchar16 __ovld __cnfn as_uchar16(int4); -uchar1
[PATCH] D30798: [analyzer] Turn suppress-c++-stdlib on by default
xazax.hun added a comment. In https://reviews.llvm.org/D30798#697115, @zaks.anna wrote: > I've committed the change, but would very much appreciate community feedback > here if if there is any! I agree with the change. Users are usually not interested in the results from the standard library, and since the standard library supposed to be well tested, it is very unlikely that the analyzer could find a true positive there. One side effect would be the suppression of results that materialize due to the misuse of those APIs. Repository: rL LLVM https://reviews.llvm.org/D30798 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r297455 - [clang-format] Use a reference in loop variable; NFC
Author: krasimir Date: Fri Mar 10 07:09:29 2017 New Revision: 297455 URL: http://llvm.org/viewvc/llvm-project?rev=297455&view=rev Log: [clang-format] Use a reference in loop variable; NFC Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=297455&r1=297454&r2=297455&view=diff == --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original) +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Fri Mar 10 07:09:29 2017 @@ -2155,7 +2155,7 @@ static bool continuesLineComment(const F // Scan for '{//'. If found, use the column of '{' as a min column for line // comment section continuation. const FormatToken *PreviousToken = nullptr; - for (const UnwrappedLineNode Node : Line.Tokens) { + for (const UnwrappedLineNode &Node : Line.Tokens) { if (PreviousToken && PreviousToken->is(tok::l_brace) && isLineComment(*Node.Tok)) { MinColumnToken = PreviousToken; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29944: libclang: Print namespaces for typedefs and type aliases
redm123 added a comment. I guess so. I don't think I'm allowed to commit. So I would appreciate it. Which release version would that be in? 4.1 I guess? Thanks for your help! https://reviews.llvm.org/D29944 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30582: [Driver] Restructure handling of -ffast-math and similar options
john.brawn updated this revision to Diff 91311. john.brawn added a comment. Rebase on top of recent driver changes. Repository: rL LLVM https://reviews.llvm.org/D30582 Files: lib/Driver/ToolChains/Clang.cpp test/Driver/fast-math.c Index: test/Driver/fast-math.c === --- test/Driver/fast-math.c +++ test/Driver/fast-math.c @@ -148,20 +148,35 @@ // // One umbrella flag is *really* weird and also changes the semantics of the // program by adding a special preprocessor macro. Check that the frontend flag -// modeling this semantic change is provided. Also check that the semantic -// impact remains even if every optimization is disabled. +// modeling this semantic change is provided. Also check that the flag is not +// present if any of the optimization is disabled. // RUN: %clang -### -ffast-math -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-FAST-MATH %s // RUN: %clang -### -fno-fast-math -ffast-math -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-FAST-MATH %s -// RUN: %clang -### -ffast-math -fno-finite-math-only \ -// RUN: -fno-unsafe-math-optimizations -fmath-errno -c %s 2>&1 \ +// RUN: %clang -### -funsafe-math-optimizations -ffinite-math-only \ +// RUN: -fno-math-errno -ffp-contract=fast -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-FAST-MATH %s +// RUN: %clang -### -fhonor-infinities -fhonor-nans -fno-math-errno \ +// RUN: -fassociative-math -freciprocal-math -fno-signed-zeros \ +// RUN: -fno-trapping-math -ffp-contract=fast -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-FAST-MATH %s // CHECK-FAST-MATH: "-cc1" // CHECK-FAST-MATH: "-ffast-math" +// CHECK-FAST-MATH: "-ffinite-math-only" // // RUN: %clang -### -ffast-math -fno-fast-math -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-NO-FAST-MATH %s +// RUN: %clang -### -ffast-math -fno-finite-math-only -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NO-FAST-MATH %s +// RUN: %clang -### -ffast-math -fno-unsafe-math-optimizations -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NO-FAST-MATH %s +// RUN: %clang -### -ffast-math -fmath-errno -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NO-FAST-MATH %s +// RUN: %clang -### -ffast-math -ffp-contract=on -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NO-FAST-MATH %s +// RUN: %clang -### -ffast-math -ffp-contract=off -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NO-FAST-MATH %s // CHECK-NO-FAST-MATH: "-cc1" // CHECK-NO-FAST-MATH-NOT: "-ffast-math" // @@ -179,6 +194,7 @@ // RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s // CHECK-NO-NO-INFS: "-cc1" // CHECK-NO-NO-INFS-NOT: "-menable-no-infs" +// CHECK-NO-NO-INFS-NOT: "-ffinite-math-only" // CHECK-NO-NO-INFS: "-o" // // RUN: %clang -### -fno-honor-nans -fhonor-nans -c %s 2>&1 \ @@ -193,6 +209,7 @@ // RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s // CHECK-NO-NO-NANS: "-cc1" // CHECK-NO-NO-NANS-NOT: "-menable-no-nans" +// CHECK-NO-NO-NANS-NOT: "-ffinite-math-only" // CHECK-NO-NO-NANS: "-o" // // RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \ Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -2301,98 +2301,129 @@ if (Args.hasArg(options::OPT_fsplit_stack)) CmdArgs.push_back("-split-stacks"); - // If -Ofast is the optimization level, then -ffast-math should be enabled. - // This alias option is being used to simplify the getLastArg logic. - OptSpecifier FastMathAliasOption = - OFastEnabled ? options::OPT_Ofast : options::OPT_ffast_math; - // Handle various floating point optimization flags, mapping them to the - // appropriate LLVM code generation flags. The pattern for all of these is to - // default off the codegen optimizations, and if any flag enables them and no - // flag disables them after the flag enabling them, enable the codegen - // optimization. This is complicated by several "umbrella" flags. - if (Arg *A = Args.getLastArg( - options::OPT_ffast_math, FastMathAliasOption, - options::OPT_fno_fast_math, options::OPT_ffinite_math_only, - options::OPT_fno_finite_math_only, options::OPT_fhonor_infinities, - options::OPT_fno_honor_infinities)) -if (A->getOption().getID() != options::OPT_fno_fast_math && -A->getOption().getID() != options::OPT_fno_finite_math_only && -A->getOption().getID() != options::OPT_fhonor_infinities) - CmdArgs.push_back("-menable-no-infs"); - if (Arg *A = Args.getLastArg( - options::OPT_ffast_math, FastMathAliasOption, - options::OPT_fno_fast_math, options::OPT_ffinite_math_only, - options::OPT_fno_finite_math_only, options::OPT_fhonor_nans, - options::OPT_fno_honor_nans)) -if (A->getOption().getID() != options::OPT_fno_fast_math && -