[PATCH] D37001: [clang-diff] Use data collectors for node comparison
johannes added inline comments. Comment at: lib/Tooling/ASTDiff/ASTDiff.cpp:537 + +#include "../../AST/DeclDataCollectors.inc" + arphaman wrote: > I didn't realize that you're including files from within `lib`. That's not > ideal. You should add a pre-commit that moves the *.inc files over to > include/AST (and marks them as textual in Clang's `module.modulemap`). Then > you should include them using the clang/AST path. I tried moving StmtDataCollectors.inc to and adding `+ textual header "AST/StmtDataCollectors.inc" ` in the modulemap, then I get some CMake errors, not sure why. It might make sense to tablegen it like the other .inc files. https://reviews.llvm.org/D37001 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30691: [analyzer] Support for naive cross translational unit analysis
danielmarjamaki accepted this revision. danielmarjamaki added inline comments. This revision is now accepted and ready to land. Comment at: tools/scan-build-py/libscanbuild/analyze.py:165 +with open(filename, 'r') as in_file: +for line in in_file: +yield line whisperity wrote: > danielmarjamaki wrote: > > I believe you can write: > > > > for line in open(filename, 'r'): > Do we want to rely on the interpreter implementation on when the file is > closed. > > If > > ``` > for line in open(filename, 'r'): > something() > ``` > > is used, the file handle will be closed based on garbage collection rules. > Having this handle disposed after the iteration is true for the stock CPython > implementation, but it is still nontheless an implementation specific > approach. > > Whereas using `with` will explicitly close the file handle on the spot, no > matter what. ok I did not know that. feel free to ignore my comment. Comment at: tools/scan-build-py/libscanbuild/analyze.py:172 +extern_fns_map_file = os.path.join(ctudir, CTU_FUNCTION_MAP_FILENAME) +with open(extern_fns_map_file, 'w') as out_file: +for mangled_name, ast_file in mangled_ast_pairs: whisperity wrote: > danielmarjamaki wrote: > > this 'with' seems redundant. I suggest an assignment and then less > > indentation will be needed below > I don't seem to understand what do you want to assign to what. I did not consider the garbage collection. I assumed that out_file would Always be closed when it Went out of scope and then this would require less indentation: out_file = open(extern_fns_map_file, 'w') for mangled_name, ast_file in mangled_ast_pairs: out_file.write('%s %s\n' % (mangled_name, ast_file)) Comment at: tools/scan-build-py/libscanbuild/analyze.py:223 +ctu_config = get_ctu_config(args) +if ctu_config.collect: +shutil.rmtree(ctu_config.dir, ignore_errors=True) danielmarjamaki wrote: > not a big deal but I would use early exits in this function with "not a big deal" I mean; feel free to ignore my comment if you want to have it this way. https://reviews.llvm.org/D30691 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r312316 - [refactor] Use a RefactoringResultConsumer instead of tagged refactoring
Author: arphaman Date: Fri Sep 1 02:16:02 2017 New Revision: 312316 URL: http://llvm.org/viewvc/llvm-project?rev=312316&view=rev Log: [refactor] Use a RefactoringResultConsumer instead of tagged refactoring rule classes This commit changes the way that the refactoring results are produced. Instead of using different `RefactoringActionRule` subclasses for each result type, Clang now use a single `RefactoringResultConsumer`. This was suggested by Manuel in https://reviews.llvm.org/D36075. Differential Revision: https://reviews.llvm.org/D37291 Added: cfe/trunk/include/clang/Tooling/Refactoring/RefactoringResultConsumer.h Modified: cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRules.h cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp Modified: cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h?rev=312316&r1=312315&r2=312316&view=diff == --- cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h (original) +++ cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h Fri Sep 1 02:16:02 2017 @@ -11,52 +11,25 @@ #define LLVM_CLANG_TOOLING_REFACTOR_REFACTORING_ACTION_RULE_H #include "clang/Basic/LLVM.h" -#include "clang/Tooling/Refactoring/AtomicChange.h" -#include "llvm/Support/Error.h" #include namespace clang { namespace tooling { +class RefactoringResultConsumer; class RefactoringRuleContext; /// A common refactoring action rule interface. class RefactoringActionRule { public: - enum RuleKind { SourceChangeRefactoringRuleKind }; - - RuleKind getRuleKind() const { return Kind; } - virtual ~RefactoringActionRule() {} -protected: - RefactoringActionRule(RuleKind Kind) : Kind(Kind) {} - -private: - RuleKind Kind; -}; - -/// A type of refactoring action rule that produces source replacements in the -/// form of atomic changes. -/// -/// This action rule is typically used for local refactorings that replace -/// source in a single AST unit. -class SourceChangeRefactoringRule : public RefactoringActionRule { -public: - SourceChangeRefactoringRule() - : RefactoringActionRule(SourceChangeRefactoringRuleKind) {} - - /// Initiates and performs a refactoring action that modifies the sources. + /// Initiates and performs a specific refactoring action. /// - /// The specific rule must return an llvm::Error with a DiagnosticError - /// payload or None when the refactoring action couldn't be initiated/ - /// performed, or \c AtomicChanges when the action was performed successfully. - virtual Expected> - createSourceReplacements(RefactoringRuleContext &Context) = 0; - - static bool classof(const RefactoringActionRule *Rule) { -return Rule->getRuleKind() == SourceChangeRefactoringRuleKind; - } + /// The specific rule will invoke an appropriate \c handle method on a + /// consumer to propagate the result of the refactoring action. + virtual void invoke(RefactoringResultConsumer &Consumer, + RefactoringRuleContext &Context) = 0; }; /// A set of refactoring action rules that should have unique initiation Modified: cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRules.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRules.h?rev=312316&r1=312315&r2=312316&view=diff == --- cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRules.h (original) +++ cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRules.h Fri Sep 1 02:16:02 2017 @@ -42,15 +42,12 @@ std::unique_ptr createRefactoringRule(Expected (*RefactoringFunction)( typename RequirementTypes::OutputType...), const RequirementTypes &... Requirements) { - static_assert( - std::is_base_of< - RefactoringActionRule, - internal::SpecificRefactoringRuleAdapter>::value, - "invalid refactoring result type"); + static_assert(tooling::traits::IsValidRefactoringResult::value, +"invalid refactoring result type"); static_assert(traits::IsRequirement::value, "invalid refactoring action rule requirement"); return llvm::make_unique>( + decltype(RefactoringFunction), RequirementTypes...>>( RefactoringFunction, std::make_tuple(Requirements...)); } Modified: cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h?rev=312316&r1=312315&r2=312316&view=diff ===
[PATCH] D37291: [refactor] Use a RefactoringResultConsumer instead of tagged refactoring rule classes
This revision was automatically updated to reflect the committed changes. Closed by commit rL312316: [refactor] Use a RefactoringResultConsumer instead of tagged refactoring (authored by arphaman). Changed prior to commit: https://reviews.llvm.org/D37291?vs=113397&id=113520#toc Repository: rL LLVM https://reviews.llvm.org/D37291 Files: cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRule.h cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRules.h cfe/trunk/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h cfe/trunk/include/clang/Tooling/Refactoring/RefactoringResultConsumer.h cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp Index: cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp === --- cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp +++ cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp @@ -32,11 +32,23 @@ std::string DefaultCode = std::string(100, 'a'); }; -Expected> +Expected createReplacements(const std::unique_ptr &Rule, RefactoringRuleContext &Context) { - return cast(*Rule).createSourceReplacements( - Context); + class Consumer final : public RefactoringResultConsumer { +void handleError(llvm::Error Err) override { Result = std::move(Err); } + +void handle(AtomicChanges SourceReplacements) override { + Result = std::move(SourceReplacements); +} + + public: +Optional> Result; + }; + + Consumer C; + Rule->invoke(C, Context); + return std::move(*C.Result); } TEST_F(RefactoringActionRulesTest, MyFirstRefactoringRule) { @@ -70,11 +82,10 @@ .getLocWithOffset(10); RefContext.setSelectionRange({Cursor, Cursor}); -Expected> ErrorOrResult = +Expected ErrorOrResult = createReplacements(Rule, RefContext); ASSERT_FALSE(!ErrorOrResult); -ASSERT_FALSE(!*ErrorOrResult); -AtomicChanges Result = std::move(**ErrorOrResult); +AtomicChanges Result = std::move(*ErrorOrResult); ASSERT_EQ(Result.size(), 1u); std::string YAMLString = const_cast(Result[0]).toYAMLString(); @@ -94,16 +105,20 @@ YAMLString.c_str()); } - // When one of the requirements is not satisfied, perform should return either - // None or a valid diagnostic. + // When one of the requirements is not satisfied, invoke should return a + // valid error. { RefactoringRuleContext RefContext(Context.Sources); -Expected> ErrorOrResult = +Expected ErrorOrResult = createReplacements(Rule, RefContext); -ASSERT_FALSE(!ErrorOrResult); -Optional Value = std::move(*ErrorOrResult); -EXPECT_TRUE(!Value); +ASSERT_TRUE(!ErrorOrResult); +std::string Message; +llvm::handleAllErrors( +ErrorOrResult.takeError(), +[&](llvm::StringError &Error) { Message = Error.getMessage(); }); +EXPECT_EQ(Message, "refactoring action can't be initiated with the " + "specified selection range"); } } @@ -121,8 +136,7 @@ SourceLocation Cursor = Context.Sources.getLocForStartOfFile(Context.Sources.getMainFileID()); RefContext.setSelectionRange({Cursor, Cursor}); - Expected> Result = - createReplacements(Rule, RefContext); + Expected Result = createReplacements(Rule, RefContext); ASSERT_TRUE(!Result); std::string Message; @@ -151,8 +165,7 @@ SourceLocation Cursor = Context.Sources.getLocForStartOfFile(Context.Sources.getMainFileID()); RefContext.setSelectionRange({Cursor, Cursor}); - Expected> Result = - createReplacements(Rule, RefContext); + Expected Result = createReplacements(Rule, RefContext); ASSERT_TRUE(!Result); std::string Message; Index: cfe/trunk/include/clang/Tooling/Refactoring/RefactoringResultConsumer.h === --- cfe/trunk/include/clang/Tooling/Refactoring/RefactoringResultConsumer.h +++ cfe/trunk/include/clang/Tooling/Refactoring/RefactoringResultConsumer.h @@ -0,0 +1,70 @@ +//===--- RefactoringResultConsumer.h - Clang refactoring library --===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#ifndef LLVM_CLANG_TOOLING_REFACTOR_REFACTORING_RESULT_CONSUMER_H +#define LLVM_CLANG_TOOLING_REFACTOR_REFACTORING_RESULT_CONSUMER_H + +#include "clang/Basic/LLVM.h" +#include "clang/Tooling/Refactoring/AtomicChange.h" +#include "llvm/Support/Error.h" + +namespace clang { +namespace tooling { + +/// An abstract interface that consumes the various refactoring results that can +/// be produced by refactoring actions. +/// +/// A valid refactoring result must be handled by a \c handle method. +class RefactoringResultConsumer { +public: +
[PATCH] D37210: [refactor] add a refactoring action rule that returns symbol occurrences
arphaman updated this revision to Diff 113521. arphaman added a comment. Rebase on ToT Repository: rL LLVM https://reviews.llvm.org/D37210 Files: include/clang/Tooling/Refactoring/RefactoringResultConsumer.h unittests/Tooling/RefactoringActionRulesTest.cpp Index: unittests/Tooling/RefactoringActionRulesTest.cpp === --- unittests/Tooling/RefactoringActionRulesTest.cpp +++ unittests/Tooling/RefactoringActionRulesTest.cpp @@ -11,6 +11,7 @@ #include "RewriterTestContext.h" #include "clang/Tooling/Refactoring.h" #include "clang/Tooling/Refactoring/RefactoringActionRules.h" +#include "clang/Tooling/Refactoring/Rename/SymbolName.h" #include "clang/Tooling/Tooling.h" #include "llvm/Support/Errc.h" #include "gtest/gtest.h" @@ -175,4 +176,49 @@ EXPECT_EQ(Message, "bad selection"); } +Optional findOccurrences(RefactoringActionRule &Rule, +RefactoringRuleContext &Context) { + class Consumer final : public RefactoringResultConsumer { +void handleError(llvm::Error) override {} +void handle(SymbolOccurrences Occurrences) override { + Result = std::move(Occurrences); +} + + public: +Optional Result; + }; + + Consumer C; + Rule.invoke(C, Context); + return std::move(C.Result); +} + +TEST_F(RefactoringActionRulesTest, ReturnSymbolOccurrences) { + auto Rule = createRefactoringRule( + [](selection::SourceSelectionRange Selection) + -> Expected { +SymbolOccurrences Occurrences; +Occurrences.push_back(SymbolOccurrence( +SymbolName("test"), SymbolOccurrence::MatchingSymbol, +Selection.getRange().getBegin())); +return Occurrences; + }, + requiredSelection( + selection::identity())); + + RefactoringRuleContext RefContext(Context.Sources); + SourceLocation Cursor = + Context.Sources.getLocForStartOfFile(Context.Sources.getMainFileID()); + RefContext.setSelectionRange({Cursor, Cursor}); + Optional Result = findOccurrences(*Rule, RefContext); + + ASSERT_FALSE(!Result); + SymbolOccurrences Occurrences = std::move(*Result); + EXPECT_EQ(Occurrences.size(), 1u); + EXPECT_EQ(Occurrences[0].getKind(), SymbolOccurrence::MatchingSymbol); + EXPECT_EQ(Occurrences[0].getNameRanges().size(), 1u); + EXPECT_EQ(Occurrences[0].getNameRanges()[0], +SourceRange(Cursor, Cursor.getLocWithOffset(strlen("test"; +} + } // end anonymous namespace Index: include/clang/Tooling/Refactoring/RefactoringResultConsumer.h === --- include/clang/Tooling/Refactoring/RefactoringResultConsumer.h +++ include/clang/Tooling/Refactoring/RefactoringResultConsumer.h @@ -12,6 +12,7 @@ #include "clang/Basic/LLVM.h" #include "clang/Tooling/Refactoring/AtomicChange.h" +#include "clang/Tooling/Refactoring/Rename/SymbolOccurrences.h" #include "llvm/Support/Error.h" namespace clang { @@ -34,6 +35,10 @@ defaultResultHandler(); } + /// Handles the symbol occurrences that are found by an interactive + /// refactoring action. + virtual void handle(SymbolOccurrences Occurrences) { defaultResultHandler(); } + private: void defaultResultHandler() { handleError(llvm::make_error( Index: unittests/Tooling/RefactoringActionRulesTest.cpp === --- unittests/Tooling/RefactoringActionRulesTest.cpp +++ unittests/Tooling/RefactoringActionRulesTest.cpp @@ -11,6 +11,7 @@ #include "RewriterTestContext.h" #include "clang/Tooling/Refactoring.h" #include "clang/Tooling/Refactoring/RefactoringActionRules.h" +#include "clang/Tooling/Refactoring/Rename/SymbolName.h" #include "clang/Tooling/Tooling.h" #include "llvm/Support/Errc.h" #include "gtest/gtest.h" @@ -175,4 +176,49 @@ EXPECT_EQ(Message, "bad selection"); } +Optional findOccurrences(RefactoringActionRule &Rule, +RefactoringRuleContext &Context) { + class Consumer final : public RefactoringResultConsumer { +void handleError(llvm::Error) override {} +void handle(SymbolOccurrences Occurrences) override { + Result = std::move(Occurrences); +} + + public: +Optional Result; + }; + + Consumer C; + Rule.invoke(C, Context); + return std::move(C.Result); +} + +TEST_F(RefactoringActionRulesTest, ReturnSymbolOccurrences) { + auto Rule = createRefactoringRule( + [](selection::SourceSelectionRange Selection) + -> Expected { +SymbolOccurrences Occurrences; +Occurrences.push_back(SymbolOccurrence( +SymbolName("test"), SymbolOccurrence::MatchingSymbol, +Selection.getRange().getBegin())); +return Occurrences; + }, + requiredSelection( + selection::identity())); + + RefactoringRuleContext RefContext(Context.Sources); + SourceLocation Cursor = + Context.Sources.getLocForStartO
[PATCH] D37260: [clang-format] Fixed extern C brace wrapping
PriMee added a reviewer: krasimir. PriMee added a subscriber: krasimir. PriMee added a comment. @krasimir Could you please tell me what did you mean in the comment: > I am still not convinced about the extern part: some clients might prefer the > other style. Do you suggest adding a new option, new style, like **BraceWrapping.AfterExtern** flag? https://reviews.llvm.org/D37260 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37101: [clangd] [WIP] Add support for snippet completions
ilya-biryukov added a comment. This looks like a useful change even without prior changes to VSCode. Maybe add a command-line flag to clangd(`--enable-snippets`) and commit that? When snippets are disabled, we could simply do `insertText = /**/` after `ProcessChunks`, we will deprecate and remove that flag eventually when all the clients support it. Comment at: clangd/ClangdUnit.cpp:337 +// Fill in the kind field of the CompletionItem. +Item.kind = getKind(Result.CursorKind); + Could we also set `Item.filterText` to completion item name? So that various pieces of function signature would not match on user input. Comment at: clangd/ClangdUnit.cpp:419 +assert(item.detail.empty() && "Unexpected extraneous CK_ResultType"); +Item.detail = Chunk.Text; +break; Won't that assertion fail with function return types? Let's add a test for that. ``` int (*foo(int a))(float); ``` https://reviews.llvm.org/D37101 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37101: [clangd] [WIP] Add support for snippet completions
ilya-biryukov added a comment. Also wanted to stress once again that we need some tests for this change. https://reviews.llvm.org/D37101 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37101: [clangd] [WIP] Add support for snippet completions
ilya-biryukov added inline comments. Comment at: clangd/ClangdUnit.cpp:418 +// for functions and methods, the return type. +assert(item.detail.empty() && "Unexpected extraneous CK_ResultType"); +Item.detail = Chunk.Text; Typo: should be `Item` instead of `item`. Otherwise this does not compile with assertions enabled. https://reviews.llvm.org/D37101 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37375: [libcxx] Test case for the experimental library visibility macros
hamzasood created this revision. This patch adds a test case to ensure that every library header uses the correct visibility macros. libc++ headers should use _LIBCPP_* macros whereas libc++experimental headers should use _LIBCPPX_* macros. This was originally part of https://reviews.llvm.org/D37182, but it's been taken out for separate review as requested. It's dependent on the aforementioned patch; the test will fail until that patch has been applied. https://reviews.llvm.org/D37375 Files: test/libcxx/selftest/experimental_visibility.sh.cpp utils/check_experimental_visibility.py utils/libcxx/test/config.py Index: utils/libcxx/test/config.py === --- utils/libcxx/test/config.py +++ utils/libcxx/test/config.py @@ -1056,6 +1056,13 @@ not_py = os.path.join(self.libcxx_src_root, 'utils', 'not.py') not_str = '%s %s ' % (pipes.quote(sys.executable), pipes.quote(not_py)) sub.append(('not ', not_str)) +# Configure check_experimental_visibility program substitutions +check_experimental_vis_py = os.path.join(self.libcxx_src_root, + 'utils', + 'check_experimental_visibility.py') +check_experimental_vis_str = '%s %s' % (pipes.quote(sys.executable), +pipes.quote(check_experimental_vis_py)) +sub.append(('check_experimental_visibility', check_experimental_vis_str)) def can_use_deployment(self): # Check if the host is on an Apple platform using clang. Index: utils/check_experimental_visibility.py === --- utils/check_experimental_visibility.py +++ utils/check_experimental_visibility.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python +#===--===## +# +# The LLVM Compiler Infrastructure +# +# This file is dual licensed under the MIT and the University of Illinois Open +# Source Licenses. See LICENSE.TXT for details. +# +#===--===## + +# USAGE: check_experimental_visibility +# This script checks if each header in the given include dir use the correct +# visibility macros. Experimental headers should use _LIBCPPX macros whereas +# non-experimental headers should use the regular _LIBCPP macros. + +import itertools +import os +import sys + +visibility_macros = [ +"HIDDEN", +"FUNC_VIS", +"EXTERN_VIS", +"OVERRIDABLE_FUNC_VIS", +"INLINE_VISIBILITY", +"ALWAYS_INLINE", +"TYPE_VIS", +"TEMPLATE_VIS", +"ENUM_VIS", +"EXTERN_TEMPLATE_TYPE_VIS", +"CLASS_TEMPLATE_INSTANTIATION_VIS", +"METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS", +"EXTERN_TEMPLATE_INLINE_VISIBILITY", +"EXCEPTION_ABI", +] + +regular_visibility_macros = ["_LIBCPP_{}".format(m) for m in visibility_macros] +experimental_visibility_macros = ["_LIBCPPX_{}".format(m) for m in visibility_macros] + +def main(): +if len(sys.argv) != 2: +sys.stderr.write("Expected only one argument: the libcxx include path\n") +return 1 + +include_dir = sys.argv[1] +if not os.path.isdir(include_dir): +sys.stderr.write("Given include path isn't a directory\n") +return 1 + +# [(rel_file_path, line_number)] +invalid_regular_files = [] +invalid_experimental_files = [] + +files_to_check = itertools.chain.from_iterable(( +((dir, fname) for fname in filenames if fname != "__config") +for (dir, _, filenames) in os.walk(include_dir) +)) +for (dir, fname) in files_to_check: +parent_path = os.path.relpath(dir, include_dir) + +header_path = os.path.join(parent_path, fname) if parent_path != '.' else fname +experimental = os.path.split(header_path)[0] == "experimental" + +# List of macros that we shouldn't see in this file. +problem_macros = regular_visibility_macros if experimental \ + else experimental_visibility_macros + +with open(os.path.join(dir, fname), 'r') as f: +problem_lines = (i for (i, line) in enumerate(f, 1) + if any(m in line for m in problem_macros)) +(invalid_experimental_files if experimental else invalid_regular_files) \ +.extend((header_path, l) for l in problem_lines) + +if not invalid_regular_files and not invalid_experimental_files: +# No problems found +return 0 + +if invalid_regular_files: +sys.stderr.write( +"Found usage of experimental visibility macros in non-experimental files.\n" +"These should be changed to the corresponding _LIBCPP macros.\n") +for (path, line_num) in invalid_regular_files: +sys.stderr.write(" <{}>:{:d}\n".fo
[PATCH] D37376: [libcxx] Fix libc++experimental build on Windows
hamzasood created this revision. Herald added a subscriber: mgorny. This patch fixes a few problems with building libc++experimental on Windows. Previously _LIBCPP_BUILDING_LIBRARY was defined for every source file, including files destined for the experimental library. As a result of this, non-experimental APIs were marked as dllexport when compiling the experimental library (which led to link errors whenever experimental code uses symbols from the regular libc++ library). I've changed it so that _LIBCPP_BUILDING_LIBRARY is only defined for non-experimental source files, and _LIBCPPX_BUILDING_LIBRARY is defined for experimental source files (that macro isn't currently used for anything, it's mainly there for consistency). I've also added the needed MSVCRT defines to the experimental code too, so that there won't be a bunch of warnings about using "deprecated" functions etc. https://reviews.llvm.org/D37376 Files: CMakeLists.txt lib/CMakeLists.txt Index: lib/CMakeLists.txt === --- lib/CMakeLists.txt +++ lib/CMakeLists.txt @@ -186,31 +186,37 @@ split_list(LIBCXX_COMPILE_FLAGS) split_list(LIBCXX_LINK_FLAGS) +macro(add_msvcrt_defs_if_needed target) + if(WIN32 AND NOT MINGW) +target_compile_definitions(${target} + PRIVATE + # Ignore the -MSC_VER mismatch, as we may build + # with a different compatibility version. + _ALLOW_MSC_VER_MISMATCH + # Don't check the msvcprt iterator debug levels + # as we will define the iterator types; libc++ + # uses a different macro to identify the debug + # level. + _ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH + # We are building the c++ runtime, don't pull in + # msvcprt. + _CRTBLD + # Don't warn on the use of "deprecated" + # "insecure" functions which are standards + # specified. + _CRT_SECURE_NO_WARNINGS + # Use the ISO conforming behaviour for conversion + # in printf, scanf. + _CRT_STDIO_ISO_WIDE_SPECIFIERS) + endif() +endmacro() + # Add an object library that contains the compiled source files. add_library(cxx_objects OBJECT ${exclude_from_all} ${LIBCXX_SOURCES} ${LIBCXX_HEADERS}) -if(WIN32 AND NOT MINGW) - target_compile_definitions(cxx_objects - PRIVATE - # Ignore the -MSC_VER mismatch, as we may build - # with a different compatibility version. - _ALLOW_MSC_VER_MISMATCH - # Don't check the msvcprt iterator debug levels - # as we will define the iterator types; libc++ - # uses a different macro to identify the debug - # level. - _ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH - # We are building the c++ runtime, don't pull in - # msvcprt. - _CRTBLD - # Don't warn on the use of "deprecated" - # "insecure" functions which are standards - # specified. - _CRT_SECURE_NO_WARNINGS - # Use the ISO conforming behaviour for conversion - # in printf, scanf. - _CRT_STDIO_ISO_WIDE_SPECIFIERS) -endif() - +target_compile_definitions(cxx_objects + PRIVATE + _LIBCPP_BUILDING_LIBRARY) +add_msvcrt_defs_if_needed(cxx_objects) set_target_properties(cxx_objects PROPERTIES COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}" @@ -285,7 +291,13 @@ if (LIBCXX_ENABLE_FILESYSTEM) file(GLOB LIBCXX_FILESYSTEM_SOURCES ../src/experimental/filesystem/*.cpp) endif() + add_library(cxx_experimental STATIC ${LIBCXX_EXPERIMENTAL_SOURCES} ${LIBCXX_FILESYSTEM_SOURCES}) + target_compile_definitions(cxx_experimental + PRIVATE + _LIBCPPX_BUILDING_LIBRARY) + add_msvcrt_defs_if_needed(cxx_experimental) + if (LIBCXX_ENABLE_SHARED) target_link_libraries(cxx_experimental cxx_shared) else() @@ -313,6 +325,9 @@ add_library(cxx_external_threads STATIC ${LIBCXX_EXTERNAL_THREADING_SUPPORT_SOURCES}) endif() + target_compile_definitions(cxx_external_threa
[PATCH] D36574: [refactor] add clang-refactor tool with initial testing support and local-rename action
arphaman updated this revision to Diff 113533. arphaman added a comment. Rebase on top of trunk and https://reviews.llvm.org/D37210. Ping. Repository: rL LLVM https://reviews.llvm.org/D36574 Files: include/clang/Tooling/Refactoring/RefactoringAction.h include/clang/Tooling/Refactoring/RefactoringActionRegistry.def include/clang/Tooling/Refactoring/RefactoringActionRule.h include/clang/Tooling/Refactoring/RefactoringActionRuleRequirementsInternal.h include/clang/Tooling/Refactoring/RefactoringActionRules.h include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h include/clang/Tooling/Refactoring/RefactoringEngine.h include/clang/Tooling/Refactoring/RefactoringRuleContext.h include/clang/Tooling/Refactoring/Rename/SymbolOccurrences.h include/clang/Tooling/Refactoring/Rename/USRFindingAction.h include/clang/Tooling/Refactoring/SourceSelectionConstraints.h include/clang/module.modulemap lib/Tooling/Refactoring/CMakeLists.txt lib/Tooling/Refactoring/RefactoringEngine.cpp lib/Tooling/Refactoring/Rename/RenamingAction.cpp lib/Tooling/Refactoring/Rename/USRFindingAction.cpp test/CMakeLists.txt test/Refactor/LocalRename/Field.cpp test/Refactor/tool-common-options.c test/Refactor/tool-test-support.c test/clang-rename/Field.cpp tools/CMakeLists.txt tools/clang-refactor/CMakeLists.txt tools/clang-refactor/ClangRefactor.cpp tools/clang-refactor/DumpRefactoringResult.cpp tools/clang-refactor/RefactoringResult.h tools/clang-refactor/TestSupport.cpp tools/clang-refactor/TestSupport.h Index: tools/clang-refactor/TestSupport.h === --- /dev/null +++ tools/clang-refactor/TestSupport.h @@ -0,0 +1,105 @@ +//===--- TestSupport.h - Clang-based refactoring tool ---*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// +/// +/// \file +/// \brief Declares datatypes and routines that are used by test-specific code +/// in clang-refactor. +/// +//===--===// + +#ifndef LLVM_CLANG_TOOLS_CLANG_REFACTOR_TEST_SUPPORT_H +#define LLVM_CLANG_TOOLS_CLANG_REFACTOR_TEST_SUPPORT_H + +#include "RefactoringResult.h" +#include "clang/Basic/LLVM.h" +#include "clang/Basic/SourceLocation.h" +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/Support/Error.h" +#include +#include + +namespace clang { + +class SourceManager; + +namespace clang_refactor { + +/// A source selection range that's specified in a test file using an inline +/// command in the comment. These commands can take the following forms: +/// +/// - /*range=*/ will create an empty selection range in the default group +/// right after the comment. +/// - /*range a=*/ will create an empty selection range in the 'a' group right +/// after the comment. +/// - /*range = +1*/ will create an empty selection range at a location that's +/// right after the comment with one offset to the column. +/// - /*range= -> +2:3*/ will create a selection range that starts at the +/// location right after the comment, and ends at column 3 of the 2nd line +/// after the line of the starting location. +/// +/// Clang-refactor will expected all ranges in one test group to produce +/// identical results. +struct TestSelectionRange { + unsigned Begin, End; +}; + +/// A set of test selection ranges specified in one file. +struct TestSelectionRangesInFile { + std::string Filename; + std::map> GroupedRanges; + + TestSelectionRangesInFile(TestSelectionRangesInFile &&) = default; + TestSelectionRangesInFile &operator=(TestSelectionRangesInFile &&) = default; + + bool dispatch( + const SourceManager &SM, + llvm::function_ref< + Expected>(SourceRange)> + Producer) const; + + void dump(llvm::raw_ostream &OS) const; +}; + +/// Extracts the grouped selection ranges from the file that's specified in +/// the -selection=test: option. +/// +/// The grouped ranges are specified in comments using the following syntax: +/// "range" [ group-name ] "=" [ "+" starting-column-offset ] [ "->" +/// "+" ending-line-offset ":" +/// ending-column-position ] +/// +/// The selection range is then computed from this command by taking the ending +/// location of the comment, and adding 'starting-column-offset' to the column +/// for that location. That location in turns becomes the whole selection range, +/// unless 'ending-line-offset' and 'ending-column-position' are specified. If +/// they are specified, then the ending location of the selection range is +/// the starting location's line + 'ending-line-offset' and the +/// 'ending-column-position' column. +/// +///
[PATCH] D35110: [Analyzer] Constraint Manager Negates Difference
baloghadamsoftware added a comment. In https://reviews.llvm.org/D35110#854334, @zaks.anna wrote: > Is this blocked on the same reasons as what was raised in > https://reviews.llvm.org/D35109? No, it is blocked because https://reviews.llvm.org/D35109 is a prerequisite. https://reviews.llvm.org/D35110 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35109: [Analyzer] SValBuilder Comparison Rearrangement
baloghadamsoftware added a comment. Anna, Devin, should I proceed with Artem's suggested way? https://reviews.llvm.org/D35109 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37101: [clangd] [WIP] Add support for snippet completions
ilya-biryukov added inline comments. Comment at: clangd/ClangdUnit.cpp:337 +// Fill in the kind field of the CompletionItem. +Item.kind = getKind(Result.CursorKind); + ilya-biryukov wrote: > Could we also set `Item.filterText` to completion item name? > So that various pieces of function signature would not match on user input. After some investigation: `CK_TypedText` chunks are exactly the things that should go into `filterText`. Also, VSCode seems to ignore `filterText` right now, but that's certainly a bug in VSCode, I still propose to set `filterText` properly. https://reviews.llvm.org/D37101 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34091: Support for querying the exception specification type through libclang
mgorny added a comment. @ajbennieston, ping. Repository: rL LLVM https://reviews.llvm.org/D34091 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34091: Support for querying the exception specification type through libclang
mgorny added a comment. Nevermind. I found out what's wrong via looking at the older patch versions. Repository: rL LLVM https://reviews.llvm.org/D34091 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37378: [clang] [python] Move test_exception_specification_kind to correct subdir
mgorny created this revision. The test_exception_specification_kind.py test has been committed to the tests/ directory of clang Python bindings. As a result, it fails since it attempts to load util.py module relatively from the current directory: == ERROR: Failure: ImportError (No module named 'tests.util') -- Traceback (most recent call last): File "/usr/lib64/python3.5/site-packages/nose/failure.py", line 39, in runTest raise self.exc_val.with_traceback(self.tb) File "/usr/lib64/python3.5/site-packages/nose/loader.py", line 419, in loadTestsFromName addr.filename, addr.module) File "/usr/lib64/python3.5/site-packages/nose/importer.py", line 47, in importFromPath return self.importFromDir(dir_path, fqname) File "/usr/lib64/python3.5/site-packages/nose/importer.py", line 94, in importFromDir mod = load_module(part_fqname, fh, filename, desc) File "/usr/lib64/python3.5/imp.py", line 234, in load_module return load_source(name, filename, file) File "/usr/lib64/python3.5/imp.py", line 172, in load_source module = _load(spec) File "", line 693, in _load File "", line 673, in _load_unlocked File "", line 673, in exec_module File "", line 222, in _call_with_frames_removed File "/usr/src/llvm/tools/clang/bindings/python/tests/test_exception_specification_kind.py", line 3, in from .util import get_tu ImportError: No module named 'tests.util' After looking through the tree and the history of https://reviews.llvm.org/D34091, it seems that the test was intended for the tests/cindex subdirectory where util.py is indeed present. Move it there to fix the test. Repository: rL LLVM https://reviews.llvm.org/D37378 Files: bindings/python/tests/cindex/test_exception_specification_kind.py bindings/python/tests/test_exception_specification_kind.py ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36750: [analyzer] RetainCount: When diagnosing overrelease, mention if it's coming from a nested block.
NoQ planned changes to this revision. NoQ added a comment. This is all wrong. While `RetainCountChecker` is more function-local than, say, `MallocChecker`, we still can't say for sure that it is the bottom frame's function (or block) that should be owning the object in this case. Ideally it should, but that's not the pattern that the checker is de facto trying to find. The checker is usually fine seeing a pointer allocated in a top function and released in a sub-block. If the bottom frame is over-releasing, we'd warn, but it wouldn't be simply because the bottom frame is over-releasing, so mentioning the particular stack frame may end up being misleading. https://reviews.llvm.org/D36750 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36574: [refactor] add clang-refactor tool with initial testing support and local-rename action
klimek added a comment. One of my main concerns is still that I don't see the need for all the template magic yet :) Why doesn't everybody use the RefactoringResult we define here? Comment at: test/Refactor/LocalRename/Field.cpp:4 +class Baz { + int /*range=*/Foo; // CHECK: symbol [[@LINE]]:17 -> [[@LINE]]:20 +public: Does this just test the selection? Comment at: tools/clang-refactor/ClangRefactor.cpp:135 + +class ToolRefactoringEngine final : public RefactoringEngine { +public: Can we use composition instead of inheritance here? Repository: rL LLVM https://reviews.llvm.org/D36574 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36574: [refactor] add clang-refactor tool with initial testing support and local-rename action
arphaman added a comment. In https://reviews.llvm.org/D36574#858763, @klimek wrote: > One of my main concerns is still that I don't see the need for all the > template magic yet :) Why doesn't everybody use the RefactoringResult we > define here? This refactoring result is only really useful for the test part of `clang-refactor` so you can compare two results. The non-test part of `clang-refactor` and other clients don't really need an abstract interface for results as they will have different code for different results anyway. Repository: rL LLVM https://reviews.llvm.org/D36574 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36574: [refactor] add clang-refactor tool with initial testing support and local-rename action
arphaman added inline comments. Comment at: test/Refactor/LocalRename/Field.cpp:4 +class Baz { + int /*range=*/Foo; // CHECK: symbol [[@LINE]]:17 -> [[@LINE]]:20 +public: klimek wrote: > Does this just test the selection? No, this is the moved `clang-rename/Field.cpp` test that tests local-rename. I will move the other tests when this patch is accepted. Repository: rL LLVM https://reviews.llvm.org/D36574 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r312330 - Driver: extract modules flag handling (NFC)
Author: compnerd Date: Fri Sep 1 08:25:17 2017 New Revision: 312330 URL: http://llvm.org/viewvc/llvm-project?rev=312330&view=rev Log: Driver: extract modules flag handling (NFC) Extract a function to render the options related to modules. This reduces the cyclomatic complexity of the `ConstructJob` function. NFC. Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=312330&r1=312329&r2=312330&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Sep 1 08:25:17 2017 @@ -2191,6 +2191,165 @@ static void RenderARCMigrateToolOptions( } } +static void RenderModulesOptions(Compilation &C, const Driver &D, + const ArgList &Args, const InputInfo &Input, + const InputInfo &Output, + ArgStringList &CmdArgs, bool &HaveModules) { + // -fmodules enables the use of precompiled modules (off by default). + // Users can pass -fno-cxx-modules to turn off modules support for + // C++/Objective-C++ programs. + bool HaveClangModules = false; + if (Args.hasFlag(options::OPT_fmodules, options::OPT_fno_modules, false)) { +bool AllowedInCXX = Args.hasFlag(options::OPT_fcxx_modules, + options::OPT_fno_cxx_modules, true); +if (AllowedInCXX || !types::isCXX(Input.getType())) { + CmdArgs.push_back("-fmodules"); + HaveClangModules = true; +} + } + + HaveModules = HaveClangModules; + if (Args.hasArg(options::OPT_fmodules_ts)) { +CmdArgs.push_back("-fmodules-ts"); +HaveModules = true; + } + + // -fmodule-maps enables implicit reading of module map files. By default, + // this is enabled if we are using Clang's flavor of precompiled modules. + if (Args.hasFlag(options::OPT_fimplicit_module_maps, + options::OPT_fno_implicit_module_maps, HaveClangModules)) +CmdArgs.push_back("-fimplicit-module-maps"); + + // -fmodules-decluse checks that modules used are declared so (off by default) + if (Args.hasFlag(options::OPT_fmodules_decluse, + options::OPT_fno_modules_decluse, false)) +CmdArgs.push_back("-fmodules-decluse"); + + // -fmodules-strict-decluse is like -fmodule-decluse, but also checks that + // all #included headers are part of modules. + if (Args.hasFlag(options::OPT_fmodules_strict_decluse, + options::OPT_fno_modules_strict_decluse, false)) +CmdArgs.push_back("-fmodules-strict-decluse"); + + // -fno-implicit-modules turns off implicitly compiling modules on demand. + if (!Args.hasFlag(options::OPT_fimplicit_modules, +options::OPT_fno_implicit_modules, HaveClangModules)) { +if (HaveModules) + CmdArgs.push_back("-fno-implicit-modules"); + } else if (HaveModules) { +// -fmodule-cache-path specifies where our implicitly-built module files +// should be written. +SmallString<128> Path; +if (Arg *A = Args.getLastArg(options::OPT_fmodules_cache_path)) + Path = A->getValue(); + +if (C.isForDiagnostics()) { + // When generating crash reports, we want to emit the modules along with + // the reproduction sources, so we ignore any provided module path. + Path = Output.getFilename(); + llvm::sys::path::replace_extension(Path, ".cache"); + llvm::sys::path::append(Path, "modules"); +} else if (Path.empty()) { + // No module path was provided: use the default. + llvm::sys::path::system_temp_directory(/*erasedOnReboot=*/false, Path); + llvm::sys::path::append(Path, "org.llvm.clang."); + appendUserToPath(Path); + llvm::sys::path::append(Path, "ModuleCache"); +} + +const char Arg[] = "-fmodules-cache-path="; +Path.insert(Path.begin(), Arg, Arg + strlen(Arg)); +CmdArgs.push_back(Args.MakeArgString(Path)); + } + + if (HaveModules) { +// -fprebuilt-module-path specifies where to load the prebuilt module files. +for (const Arg *A : Args.filtered(options::OPT_fprebuilt_module_path)) { + CmdArgs.push_back(Args.MakeArgString( + std::string("-fprebuilt-module-path=") + A->getValue())); + A->claim(); +} + } + + // -fmodule-name specifies the module that is currently being built (or + // used for header checking by -fmodule-maps). + Args.AddLastArg(CmdArgs, options::OPT_fmodule_name_EQ); + + // -fmodule-map-file can be used to specify files containing module + // definitions. + Args.AddAllArgs(CmdArgs, options::OPT_fmodule_map_file); + + // -fbuiltin-module-map can be used to load the clang + // builtin headers modulemap file. + if (Args.hasArg(options::OPT_fbuiltin_module_map)) { +SmallString<128> BuiltinModuleMap(D.ResourceDir); +llvm::sys::path::append(
[PATCH] D37381: Fix regression in special member definitions under SuppressAllDiagnostics
brad.king created this revision. In commit r303930 (Switch from using a DiagnosticTrap and a note..., 2017-05-25) use of DiagnosticErrorTrap was removed because it was no longer needed to detect whether to add a diagnostic note. However, the trap was also necessary to correctly detect and mark invalid special members under `Sema.getDiagnostics().setSuppressAllDiagnostics(true)`. Restore use of the trap to fix semantic checking when diagnostics are suppressed. This is useful for external tools that need to detect the set of valid special members without issuing diagnostics on the invalid ones. https://reviews.llvm.org/D37381 Files: lib/Sema/SemaDeclCXX.cpp Index: lib/Sema/SemaDeclCXX.cpp === --- lib/Sema/SemaDeclCXX.cpp +++ lib/Sema/SemaDeclCXX.cpp @@ -10423,6 +10423,7 @@ assert(ClassDecl && "DefineImplicitDefaultConstructor - invalid constructor"); SynthesizedFunctionScope Scope(*this, Constructor); + DiagnosticErrorTrap Trap(Diags); // The exception specification is needed because we are defining the // function. @@ -10433,7 +10434,8 @@ // Add a context note for diagnostics produced after this point. Scope.addContextNote(CurrentLocation); - if (SetCtorInitializers(Constructor, /*AnyErrors=*/false)) { + if (SetCtorInitializers(Constructor, /*AnyErrors=*/false) || + Trap.hasErrorOccurred()) { Constructor->setInvalidDecl(); return; } @@ -10558,6 +10560,7 @@ // Initializations are performed "as if by a defaulted default constructor", // so enter the appropriate scope. SynthesizedFunctionScope Scope(*this, Constructor); + DiagnosticErrorTrap Trap(Diags); // The exception specification is needed because we are defining the // function. @@ -10612,7 +10615,8 @@ // We now proceed as if for a defaulted default constructor, with the relevant // initializers replaced. - if (SetCtorInitializers(Constructor, /*AnyErrors*/false, Inits)) { + if (SetCtorInitializers(Constructor, /*AnyErrors*/false, Inits) || + Trap.hasErrorOccurred()) { Constructor->setInvalidDecl(); return; } @@ -10701,6 +10705,7 @@ assert(ClassDecl && "DefineImplicitDestructor - invalid destructor"); SynthesizedFunctionScope Scope(*this, Destructor); + DiagnosticErrorTrap Trap(Diags); // The exception specification is needed because we are defining the // function. @@ -10714,7 +10719,7 @@ MarkBaseAndMemberDestructorsReferenced(Destructor->getLocation(), Destructor->getParent()); - if (CheckDestructor(Destructor)) { + if (CheckDestructor(Destructor) || Trap.hasErrorOccurred()) { Destructor->setInvalidDecl(); return; } @@ -11351,6 +11356,7 @@ } SynthesizedFunctionScope Scope(*this, CopyAssignOperator); + DiagnosticErrorTrap Trap(Diags); // The exception specification is needed because we are defining the // function. @@ -11513,8 +11519,11 @@ StmtResult Return = BuildReturnStmt(Loc, ThisObj.get()); if (Return.isInvalid()) Invalid = true; -else +else { Statements.push_back(Return.getAs()); + if (Trap.hasErrorOccurred()) +Invalid = true; +} } if (Invalid) { @@ -11725,6 +11734,7 @@ checkMoveAssignmentForRepeatedMove(*this, ClassDecl, CurrentLocation); SynthesizedFunctionScope Scope(*this, MoveAssignOperator); + DiagnosticErrorTrap Trap(Diags); // The exception specification is needed because we are defining the // function. @@ -11884,8 +11894,11 @@ StmtResult Return = BuildReturnStmt(Loc, ThisObj.get()); if (Return.isInvalid()) Invalid = true; -else +else { Statements.push_back(Return.getAs()); + if (Trap.hasErrorOccurred()) +Invalid = true; +} } if (Invalid) { @@ -12003,6 +12016,7 @@ assert(ClassDecl && "DefineImplicitCopyConstructor - invalid constructor"); SynthesizedFunctionScope Scope(*this, CopyConstructor); + DiagnosticErrorTrap Trap(Diags); // The exception specification is needed because we are defining the // function. @@ -12020,7 +12034,8 @@ if (getLangOpts().CPlusPlus11 && CopyConstructor->isImplicit()) diagnoseDeprecatedCopyOperation(*this, CopyConstructor); - if (SetCtorInitializers(CopyConstructor, /*AnyErrors=*/false)) { + if (SetCtorInitializers(CopyConstructor, /*AnyErrors=*/false) || + Trap.hasErrorOccurred()) { CopyConstructor->setInvalidDecl(); } else { SourceLocation Loc = CopyConstructor->getLocEnd().isValid() @@ -12126,6 +12141,7 @@ assert(ClassDecl && "DefineImplicitMoveConstructor - invalid constructor"); SynthesizedFunctionScope Scope(*this, MoveConstructor); + DiagnosticErrorTrap Trap(Diags); // The exception specification is needed because we are defining the // function. @@ -12136,7 +12152,8 @@ // Add a context note for diagnostics produced after this point. Scope.addContextNo
[PATCH] D37381: Fix regression in special member definitions under SuppressAllDiagnostics
lebedev.ri added a comment. 1. Please upload path with full context (-U) 2. Tests? https://reviews.llvm.org/D37381 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37381: Fix regression in special member definitions under SuppressAllDiagnostics
brad.king updated this revision to Diff 113544. brad.king added a comment. Updated diff with full context. https://reviews.llvm.org/D37381 Files: lib/Sema/SemaDeclCXX.cpp Index: lib/Sema/SemaDeclCXX.cpp === --- lib/Sema/SemaDeclCXX.cpp +++ lib/Sema/SemaDeclCXX.cpp @@ -10423,6 +10423,7 @@ assert(ClassDecl && "DefineImplicitDefaultConstructor - invalid constructor"); SynthesizedFunctionScope Scope(*this, Constructor); + DiagnosticErrorTrap Trap(Diags); // The exception specification is needed because we are defining the // function. @@ -10433,7 +10434,8 @@ // Add a context note for diagnostics produced after this point. Scope.addContextNote(CurrentLocation); - if (SetCtorInitializers(Constructor, /*AnyErrors=*/false)) { + if (SetCtorInitializers(Constructor, /*AnyErrors=*/false) || + Trap.hasErrorOccurred()) { Constructor->setInvalidDecl(); return; } @@ -10558,6 +10560,7 @@ // Initializations are performed "as if by a defaulted default constructor", // so enter the appropriate scope. SynthesizedFunctionScope Scope(*this, Constructor); + DiagnosticErrorTrap Trap(Diags); // The exception specification is needed because we are defining the // function. @@ -10612,7 +10615,8 @@ // We now proceed as if for a defaulted default constructor, with the relevant // initializers replaced. - if (SetCtorInitializers(Constructor, /*AnyErrors*/false, Inits)) { + if (SetCtorInitializers(Constructor, /*AnyErrors*/false, Inits) || + Trap.hasErrorOccurred()) { Constructor->setInvalidDecl(); return; } @@ -10701,6 +10705,7 @@ assert(ClassDecl && "DefineImplicitDestructor - invalid destructor"); SynthesizedFunctionScope Scope(*this, Destructor); + DiagnosticErrorTrap Trap(Diags); // The exception specification is needed because we are defining the // function. @@ -10714,7 +10719,7 @@ MarkBaseAndMemberDestructorsReferenced(Destructor->getLocation(), Destructor->getParent()); - if (CheckDestructor(Destructor)) { + if (CheckDestructor(Destructor) || Trap.hasErrorOccurred()) { Destructor->setInvalidDecl(); return; } @@ -11351,6 +11356,7 @@ } SynthesizedFunctionScope Scope(*this, CopyAssignOperator); + DiagnosticErrorTrap Trap(Diags); // The exception specification is needed because we are defining the // function. @@ -11513,8 +11519,11 @@ StmtResult Return = BuildReturnStmt(Loc, ThisObj.get()); if (Return.isInvalid()) Invalid = true; -else +else { Statements.push_back(Return.getAs()); + if (Trap.hasErrorOccurred()) +Invalid = true; +} } if (Invalid) { @@ -11725,6 +11734,7 @@ checkMoveAssignmentForRepeatedMove(*this, ClassDecl, CurrentLocation); SynthesizedFunctionScope Scope(*this, MoveAssignOperator); + DiagnosticErrorTrap Trap(Diags); // The exception specification is needed because we are defining the // function. @@ -11884,8 +11894,11 @@ StmtResult Return = BuildReturnStmt(Loc, ThisObj.get()); if (Return.isInvalid()) Invalid = true; -else +else { Statements.push_back(Return.getAs()); + if (Trap.hasErrorOccurred()) +Invalid = true; +} } if (Invalid) { @@ -12003,6 +12016,7 @@ assert(ClassDecl && "DefineImplicitCopyConstructor - invalid constructor"); SynthesizedFunctionScope Scope(*this, CopyConstructor); + DiagnosticErrorTrap Trap(Diags); // The exception specification is needed because we are defining the // function. @@ -12020,7 +12034,8 @@ if (getLangOpts().CPlusPlus11 && CopyConstructor->isImplicit()) diagnoseDeprecatedCopyOperation(*this, CopyConstructor); - if (SetCtorInitializers(CopyConstructor, /*AnyErrors=*/false)) { + if (SetCtorInitializers(CopyConstructor, /*AnyErrors=*/false) || + Trap.hasErrorOccurred()) { CopyConstructor->setInvalidDecl(); } else { SourceLocation Loc = CopyConstructor->getLocEnd().isValid() @@ -12126,6 +12141,7 @@ assert(ClassDecl && "DefineImplicitMoveConstructor - invalid constructor"); SynthesizedFunctionScope Scope(*this, MoveConstructor); + DiagnosticErrorTrap Trap(Diags); // The exception specification is needed because we are defining the // function. @@ -12136,7 +12152,8 @@ // Add a context note for diagnostics produced after this point. Scope.addContextNote(CurrentLocation); - if (SetCtorInitializers(MoveConstructor, /*AnyErrors=*/false)) { + if (SetCtorInitializers(MoveConstructor, /*AnyErrors=*/false) || + Trap.hasErrorOccurred()) { MoveConstructor->setInvalidDecl(); } else { SourceLocation Loc = MoveConstructor->getLocEnd().isValid() ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37381: Fix regression in special member definitions under SuppressAllDiagnostics
brad.king added a comment. > Tests? `make check` didn't regress from this. This behavior difference is not observable from within Clang itself, only in external applications that use SuppressAllDiagnostics while forcing definition of implicit members. Adding a test will require reproducing a chunk of the application code in the test suite to create the appropriate CompilerInstance. I'd be happy to do that to keep this working in the future, but where would be the appropriate place? BTW, I'd like to see this integrated in the `release_50` branch because this regression breaks my application that works with 3.6, 3.7, 3.8, 3.9, and 4.0. https://reviews.llvm.org/D37381 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37381: Fix regression in special member definitions under SuppressAllDiagnostics
lebedev.ri added a comment. In https://reviews.llvm.org/D37381#858800, @brad.king wrote: > > Tests? > > `make check` didn't regress from this. Which is the problem. Say this gets committed, and then someone else for some reason reverts part of the patch. Normally, tests should catch that. But as you have stated yourself, no tests failed because of this... > This behavior difference is not observable from within Clang itself, only in > external applications that use SuppressAllDiagnostics while forcing > definition of implicit members. Adding a test will require reproducing a > chunk of the application code in the test suite to create the appropriate > CompilerInstance. I'd be happy to do that to keep this working in the > future, but where would be the appropriate place? > > BTW, I'd like to see this integrated in the `release_50` branch because this > regression breaks my application that works with 3.6, 3.7, 3.8, 3.9, and 4.0. https://reviews.llvm.org/D37381 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37382: Fixed a crash in code completion.
ilya-biryukov created this revision. The crash occured when FunctionDecl was parsed with an initializer. https://reviews.llvm.org/D37382 Files: lib/Parse/ParseDecl.cpp test/CodeCompletion/crash-func-init.cpp Index: test/CodeCompletion/crash-func-init.cpp === --- /dev/null +++ test/CodeCompletion/crash-func-init.cpp @@ -0,0 +1,4 @@ +int (*foo(int a))(flo +// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:1:21 %s -o - \ +// RUN:| FileCheck %s +// CHECK: COMPLETION: float Index: lib/Parse/ParseDecl.cpp === --- lib/Parse/ParseDecl.cpp +++ lib/Parse/ParseDecl.cpp @@ -2264,11 +2264,21 @@ Actions.ActOnCXXEnterDeclInitializer(getCurScope(), ThisDecl); } -if (ParseExpressionList(Exprs, CommaLocs, [&] { - Actions.CodeCompleteConstructor(getCurScope(), - cast(ThisDecl)->getType()->getCanonicalTypeInternal(), - ThisDecl->getLocation(), Exprs); - })) { +std::function ExprListCompleter = nullptr; +if (auto ThisVarDecl = dyn_cast_or_null(ThisDecl)) { + // ParseExpressionList can sometimes succeed even when ThisDecl is not + // VarDecl. This is an error and it is reported in a call to + // Actions.ActOnInitializerError(). However, we call + // CodeCompleteConstructor only on VarDecls, falling back to default + // completer in other cases. + ExprListCompleter = [&, ThisVarDecl] { +Actions.CodeCompleteConstructor( +getCurScope(), ThisVarDecl->getType()->getCanonicalTypeInternal(), +ThisDecl->getLocation(), Exprs); + }; +} + +if (ParseExpressionList(Exprs, CommaLocs, ExprListCompleter)) { Actions.ActOnInitializerError(ThisDecl); SkipUntil(tok::r_paren, StopAtSemi); Index: test/CodeCompletion/crash-func-init.cpp === --- /dev/null +++ test/CodeCompletion/crash-func-init.cpp @@ -0,0 +1,4 @@ +int (*foo(int a))(flo +// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:1:21 %s -o - \ +// RUN:| FileCheck %s +// CHECK: COMPLETION: float Index: lib/Parse/ParseDecl.cpp === --- lib/Parse/ParseDecl.cpp +++ lib/Parse/ParseDecl.cpp @@ -2264,11 +2264,21 @@ Actions.ActOnCXXEnterDeclInitializer(getCurScope(), ThisDecl); } -if (ParseExpressionList(Exprs, CommaLocs, [&] { - Actions.CodeCompleteConstructor(getCurScope(), - cast(ThisDecl)->getType()->getCanonicalTypeInternal(), - ThisDecl->getLocation(), Exprs); - })) { +std::function ExprListCompleter = nullptr; +if (auto ThisVarDecl = dyn_cast_or_null(ThisDecl)) { + // ParseExpressionList can sometimes succeed even when ThisDecl is not + // VarDecl. This is an error and it is reported in a call to + // Actions.ActOnInitializerError(). However, we call + // CodeCompleteConstructor only on VarDecls, falling back to default + // completer in other cases. + ExprListCompleter = [&, ThisVarDecl] { +Actions.CodeCompleteConstructor( +getCurScope(), ThisVarDecl->getType()->getCanonicalTypeInternal(), +ThisDecl->getLocation(), Exprs); + }; +} + +if (ParseExpressionList(Exprs, CommaLocs, ExprListCompleter)) { Actions.ActOnInitializerError(ThisDecl); SkipUntil(tok::r_paren, StopAtSemi); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36998: [AST] Traverse templates in LexicallyOrderedRecursiveASTVisitor
johannes updated this revision to Diff 113546. johannes added a comment. fix by adding an option in RecursiveASTVisitor https://reviews.llvm.org/D36998 Files: include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h include/clang/AST/RecursiveASTVisitor.h unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp Index: unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp === --- unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp +++ unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp @@ -21,8 +21,9 @@ : public LexicallyOrderedRecursiveASTVisitor { public: LexicallyOrderedDeclVisitor(DummyMatchVisitor &Matcher, - const SourceManager &SM) - : LexicallyOrderedRecursiveASTVisitor(SM), Matcher(Matcher) {} + const SourceManager &SM, bool EmitIndices) + : LexicallyOrderedRecursiveASTVisitor(SM), Matcher(Matcher), +EmitIndices(EmitIndices) {} bool TraverseDecl(Decl *D) { TraversalStack.push_back(D); @@ -35,15 +36,20 @@ private: DummyMatchVisitor &Matcher; + bool EmitIndices; + unsigned Index = 0; llvm::SmallVector TraversalStack; }; class DummyMatchVisitor : public ExpectedLocationVisitor { + bool EmitIndices; + public: + DummyMatchVisitor(bool EmitIndices = false) : EmitIndices(EmitIndices) {} bool VisitTranslationUnitDecl(TranslationUnitDecl *TU) { const ASTContext &Context = TU->getASTContext(); const SourceManager &SM = Context.getSourceManager(); -LexicallyOrderedDeclVisitor SubVisitor(*this, SM); +LexicallyOrderedDeclVisitor SubVisitor(*this, SM, EmitIndices); SubVisitor.TraverseDecl(TU); return false; } @@ -64,9 +70,11 @@ OS << ND->getNameAsString(); else OS << "???"; -if (isa(D)) +if (isa(D) or isa(D)) OS << "/"; } + if (EmitIndices) +OS << "@" << Index++; Matcher.match(OS.str(), D); return true; } @@ -138,4 +146,18 @@ EXPECT_TRUE(Visitor.runOver(Source, DummyMatchVisitor::Lang_OBJC)); } +TEST(LexicallyOrderedRecursiveASTVisitor, VisitTemplateDecl) { + StringRef Source = R"( +template T f(); +template class Class {}; +)"; + DummyMatchVisitor Visitor(/*EmitIndices=*/true); + Visitor.ExpectMatch("/f/T@1", 2, 11); + Visitor.ExpectMatch("/f/f/@2", 2, 20); + Visitor.ExpectMatch("/Class/U@4", 3, 11); + Visitor.ExpectMatch("/Class/@5", 3, 20); + Visitor.ExpectMatch("/Class/Class/@6", 3, 34); + EXPECT_TRUE(Visitor.runOver(Source)); +} + } // end anonymous namespace Index: include/clang/AST/RecursiveASTVisitor.h === --- include/clang/AST/RecursiveASTVisitor.h +++ include/clang/AST/RecursiveASTVisitor.h @@ -499,10 +499,10 @@ bool canIgnoreChildDeclWhileTraversingDeclContext(const Decl *Child); -private: // These are helper methods used by more than one Traverse* method. bool TraverseTemplateParameterListHelper(TemplateParameterList *TPL); +private: // Traverses template parameter lists of either a DeclaratorDecl or TagDecl. template bool TraverseDeclTemplateParameterLists(T *D); @@ -535,6 +535,7 @@ bool dataTraverseNode(Stmt *S, DataRecursionQueue *Queue); bool PostVisitStmt(Stmt *S); + bool shouldTraverseTemplateArgumentsBeforeDecl() const { return false; } }; template @@ -1688,8 +1689,13 @@ // template declarations. #define DEF_TRAVERSE_TMPL_DECL(TMPLDECLKIND) \ DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplateDecl, { \ -TRY_TO(TraverseDecl(D->getTemplatedDecl())); \ -TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters())); \ +if (getDerived().shouldTraverseTemplateArgumentsBeforeDecl()) {\ + TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters())); \ + TRY_TO(TraverseDecl(D->getTemplatedDecl())); \ +} else { \ + TRY_TO(TraverseDecl(D->getTemplatedDecl())); \ + TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters())); \ +} \ \ /* By default, we do not traverse the instantiations of\ class templates since they do not appear in the user code. The \ Index: include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h === --- include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h +++ include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h @@ -111,6 +111,8 @@ return true; } + bool shouldTraverseTemplateArgumentsBeforeDecl() const { return
[PATCH] D37383: [AST] Add TableGen for StmtDataCollectors
johannes created this revision. Herald added a subscriber: mgorny. Herald added 1 blocking reviewer(s): teemperor. This adds an option "-gen-clang-data-collectors" to the Clang TableGen that is used to generate StmtDataCollectors.inc. https://reviews.llvm.org/D37383 Files: include/clang/AST/CMakeLists.txt include/clang/AST/StmtDataCollectors.td lib/AST/StmtDataCollectors.inc lib/Analysis/CloneDetection.cpp unittests/AST/DataCollectionTest.cpp utils/TableGen/CMakeLists.txt utils/TableGen/ClangDataCollectorsEmitter.cpp utils/TableGen/TableGen.cpp utils/TableGen/TableGenBackends.h Index: utils/TableGen/TableGenBackends.h === --- utils/TableGen/TableGenBackends.h +++ utils/TableGen/TableGenBackends.h @@ -75,6 +75,8 @@ void EmitClangDiagDocs(RecordKeeper &Records, raw_ostream &OS); void EmitClangOptDocs(RecordKeeper &Records, raw_ostream &OS); +void EmitClangDataCollectors(RecordKeeper &Records, raw_ostream &OS); + void EmitTestPragmaAttributeSupportedAttributes(RecordKeeper &Records, raw_ostream &OS); Index: utils/TableGen/TableGen.cpp === --- utils/TableGen/TableGen.cpp +++ utils/TableGen/TableGen.cpp @@ -57,6 +57,7 @@ GenAttrDocs, GenDiagDocs, GenOptDocs, + GenDataCollectors, GenTestPragmaAttributeSupportedAttributes }; @@ -147,6 +148,7 @@ clEnumValN(GenDiagDocs, "gen-diag-docs", "Generate diagnostic documentation"), clEnumValN(GenOptDocs, "gen-opt-docs", "Generate option documentation"), +clEnumValN(GenDataCollectors, "gen-clang-data-collectors", "Generate data collectors for AST nodes"), clEnumValN(GenTestPragmaAttributeSupportedAttributes, "gen-clang-test-pragma-attribute-supported-attributes", "Generate a list of attributes supported by #pragma clang " @@ -262,6 +264,9 @@ case GenOptDocs: EmitClangOptDocs(Records, OS); break; + case GenDataCollectors: +EmitClangDataCollectors(Records, OS); +break; case GenTestPragmaAttributeSupportedAttributes: EmitTestPragmaAttributeSupportedAttributes(Records, OS); break; Index: utils/TableGen/ClangDataCollectorsEmitter.cpp === --- /dev/null +++ utils/TableGen/ClangDataCollectorsEmitter.cpp @@ -0,0 +1,18 @@ +#include "llvm/TableGen/Record.h" +#include "llvm/TableGen/TableGenBackend.h" + +using namespace llvm; + +namespace clang { +void EmitClangDataCollectors(RecordKeeper &RK, raw_ostream &OS) { + const auto &Defs = RK.getClasses(); + for (const auto &Entry : Defs) { +Record &R = *Entry.second; +OS << "DEF_ADD_DATA(" << R.getName() << ", {"; +auto Code = R.getValue("Code")->getValue(); +OS << Code->getAsUnquotedString() << "}\n)"; +OS << "\n"; + } + OS << "#undef DEF_ADD_DATA\n"; +} +} // end namespace clang Index: utils/TableGen/CMakeLists.txt === --- utils/TableGen/CMakeLists.txt +++ utils/TableGen/CMakeLists.txt @@ -6,6 +6,7 @@ ClangCommentCommandInfoEmitter.cpp ClangCommentHTMLNamedCharacterReferenceEmitter.cpp ClangCommentHTMLTagsEmitter.cpp + ClangDataCollectorsEmitter.cpp ClangDiagnosticsEmitter.cpp ClangOptionDocEmitter.cpp ClangSACheckersEmitter.cpp Index: unittests/AST/DataCollectionTest.cpp === --- unittests/AST/DataCollectionTest.cpp +++ unittests/AST/DataCollectionTest.cpp @@ -46,7 +46,7 @@ ConstStmtVisitor::Visit##CLASS(S); \ } -#include "../../lib/AST/StmtDataCollectors.inc" +#include "clang/AST/StmtDataCollectors.inc" }; } // end anonymous namespace Index: lib/Analysis/CloneDetection.cpp === --- lib/Analysis/CloneDetection.cpp +++ lib/Analysis/CloneDetection.cpp @@ -205,7 +205,7 @@ ConstStmtVisitor>::Visit##CLASS(S);\ } -#include "../AST/StmtDataCollectors.inc" +#include "clang/AST/StmtDataCollectors.inc" // Type II clones ignore variable names and literals, so let's skip them. #define SKIP(CLASS)\ Index: lib/AST/StmtDataCollectors.inc === --- lib/AST/StmtDataCollectors.inc +++ /dev/null @@ -1,141 +0,0 @@ -// The functions below collect the class specific data of each Stmt subclass. - -DEF_ADD_DATA(Stmt, { - addData(S->getStmtClass()); - // This ensures that non-macro-generated code isn't identical to - // macro-generated code. - addData(data_collection::getMacroStack(S->getLocStart(), Context)); - addData(data_collection::getMacroStack(S->getLocEnd(), Context)); -}) -DEF_ADD_DATA(Expr, { addData(S->getType()); }) - -//--- Builtin
[PATCH] D37101: [clangd] [WIP] Add support for snippet completions
ilya-biryukov added inline comments. Comment at: clangd/ClangdUnit.cpp:337 +// Fill in the kind field of the CompletionItem. +Item.kind = getKind(Result.CursorKind); + ilya-biryukov wrote: > ilya-biryukov wrote: > > Could we also set `Item.filterText` to completion item name? > > So that various pieces of function signature would not match on user input. > After some investigation: `CK_TypedText` chunks are exactly the things that > should go into `filterText`. > Also, VSCode seems to ignore `filterText` right now, but that's certainly a > bug in VSCode, I still propose to set `filterText` properly. Sorry for confusion, after updating VSCode to the last version, `filterText` works just fine. https://reviews.llvm.org/D37101 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37231: Add half load and store builtins
Anastasia accepted this revision. Anastasia added inline comments. This revision is now accepted and ready to land. Comment at: include/clang/Basic/Builtins.def:1427 +// OpenCL half load/store builtin +BUILTIN(__builtin_store_half, "vdh*", "n") +BUILTIN(__builtin_store_halff, "vfh*", "n") jvesely wrote: > Anastasia wrote: > > I think this should be a language builtin (see above) but perhaps we might > > need to extend the language version here. Because I believe we only have > > OpenCL v2.0 currently. > > > > Also this should only be available if `cl_khr_fp16` is supported and > > enabled? I think we are doing similar with some subgroups functions (e.g. > > `get_kernel_sub_group_count_for_ndrange`) that are only supported by > > `cl_khr_subgroup` but those have custom diagnostic though. May be we could > > leave this check out since `half` is not available if `cl_khr_fp16` is not > > enabled anyways. > This is specifically meant to be used when `cl_khr_fp16` is **not** available. > CLC allows using half as storage format and half pointers without the > extension, > vstore_half/vload_half are used to load/store half values. (CL1.2 CH 6.1.1.1) > > These builtins are not necessary if `cl_khr_fp16` is available (we can use > regular loads/stores). > > I'll take stab at making these CLC only, but similarly to device specific > builtins it looked useful beyond that, since these builtins provide access to > half type storage. Strange. This is not how I would interpret from the extension spec though: https://www.khronos.org/registry/OpenCL/sdk/1.2/docs/man/xhtml/cl_khr_fp16.html But I think for this change is probably fine indeed because this doesn't affect half type itself. Repository: rL LLVM https://reviews.llvm.org/D37231 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36678: [OpenCL] Do not use vararg in emitted functions for enqueue_kernel
Anastasia accepted this revision. Anastasia added a comment. This revision is now accepted and ready to land. LGTM. Thanks! https://reviews.llvm.org/D36678 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37231: Add half load and store builtins
Anastasia added a comment. LGTM! Thanks! Repository: rL LLVM https://reviews.llvm.org/D37231 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37231: Add half load and store builtins
Anastasia added inline comments. Comment at: test/CodeGenOpenCL/no-half.cl:19 + __builtin_store_half(foo, bar); +// CHECK: [[HALF_VAL:%.*]] = fptrunc double %foo to half +// CHECK: store half [[HALF_VAL]], half addrspace({{.}})* %bar, align 2 Would it make sense to add a check for `load` similarly to `store` in the test_load_float/test_load_double tests? Comment at: test/CodeGenOpenCL/no-half.cl:27 + foo[0] = __builtin_load_halff(bar); +// CHECK: [[HALF_VAL:%.*]] = load +// CHECK: [[FULL_VAL:%.*]] = fpext half [[HALF_VAL]] to float Minor thing: any reason you are not checking the load fully? Repository: rL LLVM https://reviews.llvm.org/D37231 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r312336 - std::function -> llvm::function_ref. NFC.
Author: d0k Date: Fri Sep 1 09:51:51 2017 New Revision: 312336 URL: http://llvm.org/viewvc/llvm-project?rev=312336&view=rev Log: std::function -> llvm::function_ref. NFC. Modified: cfe/trunk/include/clang/Analysis/CloneDetection.h cfe/trunk/include/clang/Parse/Parser.h cfe/trunk/lib/Analysis/CloneDetection.cpp cfe/trunk/lib/Parse/ParseExpr.cpp Modified: cfe/trunk/include/clang/Analysis/CloneDetection.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CloneDetection.h?rev=312336&r1=312335&r2=312336&view=diff == --- cfe/trunk/include/clang/Analysis/CloneDetection.h (original) +++ cfe/trunk/include/clang/Analysis/CloneDetection.h Fri Sep 1 09:51:51 2017 @@ -233,9 +233,9 @@ public: ///filtered. /// \param Filter The filter function that should return true for all groups /// that should be removed from the list. - static void - filterGroups(std::vector &CloneGroups, - std::function Filter) { + static void filterGroups( + std::vector &CloneGroups, + llvm::function_ref Filter) { CloneGroups.erase( std::remove_if(CloneGroups.begin(), CloneGroups.end(), Filter), CloneGroups.end()); @@ -249,7 +249,8 @@ public: ///to the same CloneGroup. static void splitCloneGroups( std::vector &CloneGroups, - std::function Compare); + llvm::function_ref + Compare); }; /// This constraint moves clones into clone groups of type II via hashing. Modified: cfe/trunk/include/clang/Parse/Parser.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=312336&r1=312335&r2=312336&view=diff == --- cfe/trunk/include/clang/Parse/Parser.h (original) +++ cfe/trunk/include/clang/Parse/Parser.h Fri Sep 1 09:51:51 2017 @@ -1521,9 +1521,10 @@ private: typedef SmallVector CommaLocsTy; /// ParseExpressionList - Used for C/C++ (argument-)expression-list. - bool ParseExpressionList(SmallVectorImpl &Exprs, - SmallVectorImpl &CommaLocs, - std::function Completer = nullptr); + bool ParseExpressionList( + SmallVectorImpl &Exprs, + SmallVectorImpl &CommaLocs, + llvm::function_ref Completer = llvm::function_ref()); /// ParseSimpleExpressionList - A simple comma-separated list of expressions, /// used for misc language extensions. Modified: cfe/trunk/lib/Analysis/CloneDetection.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CloneDetection.cpp?rev=312336&r1=312335&r2=312336&view=diff == --- cfe/trunk/lib/Analysis/CloneDetection.cpp (original) +++ cfe/trunk/lib/Analysis/CloneDetection.cpp Fri Sep 1 09:51:51 2017 @@ -477,7 +477,8 @@ void MatchingVariablePatternConstraint:: void CloneConstraint::splitCloneGroups( std::vector &CloneGroups, -std::function Compare) { +llvm::function_ref +Compare) { std::vector Result; for (auto &HashGroup : CloneGroups) { // Contains all indexes in HashGroup that were already added to a Modified: cfe/trunk/lib/Parse/ParseExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=312336&r1=312335&r2=312336&view=diff == --- cfe/trunk/lib/Parse/ParseExpr.cpp (original) +++ cfe/trunk/lib/Parse/ParseExpr.cpp Fri Sep 1 09:51:51 2017 @@ -2762,7 +2762,7 @@ ExprResult Parser::ParseFoldExpression(E /// \endverbatim bool Parser::ParseExpressionList(SmallVectorImpl &Exprs, SmallVectorImpl &CommaLocs, - std::function Completer) { + llvm::function_ref Completer) { bool SawError = false; while (1) { if (Tok.is(tok::code_completion)) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37383: [AST] Add TableGen for StmtDataCollectors
arphaman added a comment. TableGen is great for structured data, but we shouldn't use it just to embed code in it. What was the issue you've had with the build when the inc file was in include? https://reviews.llvm.org/D37383 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36998: [AST] Traverse templates in LexicallyOrderedRecursiveASTVisitor
arphaman added inline comments. Comment at: include/clang/AST/RecursiveASTVisitor.h:507-508 // Traverses template parameter lists of either a DeclaratorDecl or TagDecl. template bool TraverseDeclTemplateParameterLists(T *D); I don't think you need to make this public with the new patch, right? https://reviews.llvm.org/D36998 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37383: [AST] Add TableGen for StmtDataCollectors
teemperor added a comment. @arphaman I suggested tablegen in https://reviews.llvm.org/D36664 because I remembered we had some CMake sanity check about not having an *.inc in our include dir: https://github.com/llvm-mirror/clang/blob/master/CMakeLists.txt#L266 Not sure if it actually fires for our case, but it looks like it does. Also it would be nicer to maintain once we have a second attribute for an optional single-TU code as tablegen could just fall back from `SingleTUCode` to the normal `Code` attribute. And we would have an easy solution for the CrossTU/SingleTU inc files as tablegen could just create both without us having to manually copy code around or do preprocessor hacks. I guess this review will make more sense once we have both CrossTU and SingleTU code ready. https://reviews.llvm.org/D37383 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37386: [AMDGPU] Implement infrastructure to set options in AMDGPUToolChain
kasaurov created this revision. Herald added subscribers: t-tye, Anastasia, tpr, dstuttard, nhaehnle, wdng, kzhuravl. In current OpenCL implementation some options are set in OpenCL RT/Driver, which causes discrepancy between online and offline paths. Implement infrastructure to move options from OpenCL RT/Driver to AMDGPUToolChain using overloaded TranslateArgs() method. Create map for default options values, as Options.td doesn't support default values (in contrast with OPTIONS.def). Add two driver options: -On and -mNN (like -O3, -m64). Some minor formatting changes to follow the clang-format style. https://reviews.llvm.org/D37386 Files: lib/Driver/ToolChains/AMDGPU.cpp lib/Driver/ToolChains/AMDGPU.h Index: lib/Driver/ToolChains/AMDGPU.h === --- lib/Driver/ToolChains/AMDGPU.h +++ lib/Driver/ToolChains/AMDGPU.h @@ -11,8 +11,10 @@ #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AMDGPU_H #include "Gnu.h" +#include "clang/Driver/Options.h" #include "clang/Driver/Tool.h" #include "clang/Driver/ToolChain.h" +#include namespace clang { namespace driver { @@ -37,14 +39,27 @@ namespace toolchains { class LLVM_LIBRARY_VISIBILITY AMDGPUToolChain : public Generic_ELF { + +private: + const std::map OptionsDefault = { + {options::OPT_O, "3"}, + {options::OPT_cl_std_EQ, "CL1.2"}}; + protected: Tool *buildLinker() const override; + const std::string getOptionDefault(options::ID OptID) const { +auto opt = OptionsDefault.find(OptID); +return opt->second; + } public: AMDGPUToolChain(const Driver &D, const llvm::Triple &Triple, -const llvm::opt::ArgList &Args); + const llvm::opt::ArgList &Args); unsigned GetDefaultDwarfVersion() const override { return 2; } bool IsIntegratedAssemblerDefault() const override { return true; } + llvm::opt::DerivedArgList * + TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch, +Action::OffloadKind DeviceOffloadKind) const override; }; } // end namespace toolchains Index: lib/Driver/ToolChains/AMDGPU.cpp === --- lib/Driver/ToolChains/AMDGPU.cpp +++ lib/Driver/ToolChains/AMDGPU.cpp @@ -8,8 +8,8 @@ //===--===// #include "AMDGPU.h" -#include "InputInfo.h" #include "CommonArgs.h" +#include "InputInfo.h" #include "clang/Driver/Compilation.h" #include "llvm/Option/ArgList.h" @@ -38,8 +38,44 @@ /// AMDGPU Toolchain AMDGPUToolChain::AMDGPUToolChain(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) - : Generic_ELF(D, Triple, Args) { } +: Generic_ELF(D, Triple, Args) {} Tool *AMDGPUToolChain::buildLinker() const { return new tools::amdgpu::Linker(*this); } + +DerivedArgList * +AMDGPUToolChain::TranslateArgs(const DerivedArgList &Args, StringRef BoundArch, + Action::OffloadKind DeviceOffloadKind) const { + + DerivedArgList *DAL = + Generic_ELF::TranslateArgs(Args, BoundArch, DeviceOffloadKind); + + // Do nothing if not OpenCL (-x cl) + if (!Args.getLastArgValue(options::OPT_x).equals("cl")) +return DAL; + + if (!DAL) +DAL = new DerivedArgList(Args.getBaseArgs()); + for (auto *A : Args) { +DAL->append(A); + } + + const OptTable &Opts = getDriver().getOpts(); + + // Phase 1 (.cl -> .bc) + if (Args.hasArg(options::OPT_c) && Args.hasArg(options::OPT_emit_llvm)) { +DAL->AddFlagArg(nullptr, Opts.getOption(getTriple().isArch64Bit() +? options::OPT_m64 +: options::OPT_m32)); + +// Have to check OPT_O4, OPT_O0 & OPT_Ofast separately +// as they defined that way in Options.td +if (!Args.hasArg(options::OPT_O) && !Args.hasArg(options::OPT_O0) && +!Args.hasArg(options::OPT_O4) && !Args.hasArg(options::OPT_Ofast)) + DAL->AddJoinedArg(nullptr, Opts.getOption(options::OPT_O), +getOptionDefault(options::OPT_O)); + } + + return DAL; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r312344 - Driver: extract ObjC option rendering (NFC)
Author: compnerd Date: Fri Sep 1 10:43:59 2017 New Revision: 312344 URL: http://llvm.org/viewvc/llvm-project?rev=312344&view=rev Log: Driver: extract ObjC option rendering (NFC) Extract the ObjC option rendering for the frontend. This localises the option translation. It augments the existing `AddRuntimeObjCOptions` which handles the runtime/ABI versioning flags only. This new function handles the non-runtime selecting flags. This logic was previously inlined into the `ConstructJob` function. Minor change to the flag ordering to group the blocks related flags together. Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/test/Driver/rewrite-legacy-objc.m cfe/trunk/test/Driver/rewrite-objc.m Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=312344&r1=312343&r2=312344&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Sep 1 10:43:59 2017 @@ -2350,6 +2350,85 @@ static void RenderModulesOptions(Compila Args.AddLastArg(CmdArgs, options::OPT_fmodules_disable_diagnostic_validation); } +static void RenderObjCOptions(const ToolChain &TC, const Driver &D, + const llvm::Triple &T, const ArgList &Args, + ObjCRuntime &Runtime, bool InferCovariantReturns, + const InputInfo &Input, ArgStringList &CmdArgs) { + const llvm::Triple::ArchType Arch = TC.getArch(); + + // -fobjc-dispatch-method is only relevant with the nonfragile-abi, and legacy + // is the default. Except for deployment target of 10.5, next runtime is + // always legacy dispatch and -fno-objc-legacy-dispatch gets ignored silently. + if (Runtime.isNonFragile()) { +if (!Args.hasFlag(options::OPT_fobjc_legacy_dispatch, + options::OPT_fno_objc_legacy_dispatch, + Runtime.isLegacyDispatchDefaultForArch(Arch))) { + if (TC.UseObjCMixedDispatch()) +CmdArgs.push_back("-fobjc-dispatch-method=mixed"); + else +CmdArgs.push_back("-fobjc-dispatch-method=non-legacy"); +} + } + + // When ObjectiveC legacy runtime is in effect on MacOSX, turn on the option + // to do Array/Dictionary subscripting by default. + if (Arch == llvm::Triple::x86 && T.isMacOSX() && + !T.isMacOSXVersionLT(10, 7) && + Runtime.getKind() == ObjCRuntime::FragileMacOSX && Runtime.isNeXTFamily()) +CmdArgs.push_back("-fobjc-subscripting-legacy-runtime"); + + // Allow -fno-objc-arr to trump -fobjc-arr/-fobjc-arc. + // NOTE: This logic is duplicated in ToolChains.cpp. + if (isObjCAutoRefCount(Args)) { +TC.CheckObjCARC(); + +CmdArgs.push_back("-fobjc-arc"); + +// FIXME: It seems like this entire block, and several around it should be +// wrapped in isObjC, but for now we just use it here as this is where it +// was being used previously. +if (types::isCXX(Input.getType()) && types::isObjC(Input.getType())) { + if (TC.GetCXXStdlibType(Args) == ToolChain::CST_Libcxx) +CmdArgs.push_back("-fobjc-arc-cxxlib=libc++"); + else +CmdArgs.push_back("-fobjc-arc-cxxlib=libstdc++"); +} + +// Allow the user to enable full exceptions code emission. +// We default off for Objective-C, on for Objective-C++. +if (Args.hasFlag(options::OPT_fobjc_arc_exceptions, + options::OPT_fno_objc_arc_exceptions, + /*default=*/types::isCXX(Input.getType( + CmdArgs.push_back("-fobjc-arc-exceptions"); + } + + // Silence warning for full exception code emission options when explicitly + // set to use no ARC. + if (Args.hasArg(options::OPT_fno_objc_arc)) { +Args.ClaimAllArgs(options::OPT_fobjc_arc_exceptions); +Args.ClaimAllArgs(options::OPT_fno_objc_arc_exceptions); + } + + // -fobjc-infer-related-result-type is the default, except in the Objective-C + // rewriter. + if (InferCovariantReturns) +CmdArgs.push_back("-fno-objc-infer-related-result-type"); + + // Pass down -fobjc-weak or -fno-objc-weak if present. + if (types::isObjC(Input.getType())) { +auto WeakArg = +Args.getLastArg(options::OPT_fobjc_weak, options::OPT_fno_objc_weak); +if (!WeakArg) { + // nothing to do +} else if (!Runtime.allowsWeak()) { + if (WeakArg->getOption().matches(options::OPT_fobjc_weak)) +D.Diag(diag::err_objc_weak_unsupported); +} else { + WeakArg->render(Args, CmdArgs); +} + } +} + void Clang::ConstructJob(Compilation &C, const JobAction &JA, const InputInfo &Output, const InputInfoList &Inputs, const ArgList &Args, const char *LinkingOutput) const { @@ -3737,6 +3816,10 @@ void Clang::ConstructJob(Compilation &C, CmdArgs.push_back("-fblocks-runtime-optional"); }
[PATCH] D37383: [AST] Add TableGen for StmtDataCollectors
arphaman added a comment. In https://reviews.llvm.org/D37383#858905, @teemperor wrote: > @arphaman I suggested tablegen in https://reviews.llvm.org/D36664 because I > remembered we had some CMake sanity check about not having an *.inc in our > include dir: > https://github.com/llvm-mirror/clang/blob/master/CMakeLists.txt#L266 Not sure > if it actually fires for our case, but it looks like it does. I see, thanks. > Also it would be nicer to maintain once we have a second attribute for an > optional single-TU code as tablegen could just fall back from `SingleTUCode` > to the normal `Code` attribute. And we would have an easy solution for the > CrossTU/SingleTU inc files as tablegen could just create both without us > having to manually copy code around or do preprocessor hacks. If you think there's a need for TableGen in the future then I see no problem with this approach. I was just reluctant to accept it only for code. > I guess this review will make more sense once we have both CrossTU and > SingleTU code ready. https://reviews.llvm.org/D37383 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37386: [AMDGPU] Implement infrastructure to set options in AMDGPUToolChain
emankov added inline comments. Comment at: lib/Driver/ToolChains/AMDGPU.cpp:60-62 + for (auto *A : Args) { +DAL->append(A); + } redundant braces Comment at: lib/Driver/ToolChains/AMDGPU.cpp:74-75 +// as they defined that way in Options.td +if (!Args.hasArg(options::OPT_O) && !Args.hasArg(options::OPT_O0) && +!Args.hasArg(options::OPT_O4) && !Args.hasArg(options::OPT_Ofast)) + DAL->AddJoinedArg(nullptr, Opts.getOption(options::OPT_O), One hasArg might be used for all. Comment at: lib/Driver/ToolChains/AMDGPU.h:50 Tool *buildLinker() const override; + const std::string getOptionDefault(options::ID OptID) const { +auto opt = OptionsDefault.find(OptID); const Ref might be returned here. Comment at: lib/Driver/ToolChains/AMDGPU.h:51-52 + const std::string getOptionDefault(options::ID OptID) const { +auto opt = OptionsDefault.find(OptID); +return opt->second; + } Check on not found opt is needed. Comment at: lib/Driver/ToolChains/AMDGPU.h:60 bool IsIntegratedAssemblerDefault() const override { return true; } + llvm::opt::DerivedArgList * + TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch, Return arg on the same line. https://reviews.llvm.org/D37386 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33852: Enable __declspec(selectany) on linux
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. Assuming no sphinx issues with the docs, this LGTM, thank you! Comment at: include/clang/Basic/AttrDocs.td:3154 + +def SelectAnyDocs : Documentation { + let Content = [{This attribute makes global symbol have a weak definition Prazek wrote: > aaron.ballman wrote: > > I think you need to set the `Category` as well. > > > > To test this you should run something like (replacing and fixing up > > path separators as needed): > > ``` > > clang-tblgen -gen-attr-docs -I \llvm\tools\clang\include > > \llvm\tools\clang\include\clang\Basic\Attr.td -o > > \llvm\tools\clang\docs\AttributeReference.rst > > ``` > Thanks for the testing command. Should I do anything in order to check if > docs build? > I enabled docs with -DLLVM_BUILD_DOCS=ON, and I have sphinx. Everything > builds, but I don't see docs anywhere. > > the docs looks like this: > +selectany (gnu::selectany) > +-- > +.. csv-table:: Supported Syntaxes > + :header: "GNU", "C++11", "__declspec", "Keyword", "Pragma", "Pragma clang > attribute" > + > + "X","X","X","", "", "" > + > +This attribute appertains to a global symbol, causing it to have a weak > +definition ( > +.. _`linkonce`: https://llvm.org/docs/LangRef.html#linkage-types > +), allowing the linker to select any definition. > + > +For more information see > +.. `gcc documentation`: > https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gcc/Microsoft-Windows-Variable-Attributes.html > + > Thanks for the testing command. Should I do anything in order to check if > docs build? On Windows, I use `make html` within the clang\docs directory to generate the actual sphinx docs -- that will tell you if there are sphinx issues. Be sure you do *not* commit the AttributeReference.rst file that it generates, however. Comment at: test/SemaCXX/attr-selectany.cpp:3 +// RUN: %clang_cc1 -triple x86_64-unknown-linux -fms-compatibility -fms-extensions -fsyntax-only -verify -std=c++11 %s +// RUN: %clang_cc1 -triple x86_64-win32-macho -fms-compatibility -fms-extensions -fsyntax-only -verify -std=c++11 %s + That has to be the strangest target triple I've ever seen. :-D https://reviews.llvm.org/D33852 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37386: [AMDGPU] Implement infrastructure to set options in AMDGPUToolChain
rampitec added inline comments. Comment at: lib/Driver/ToolChains/AMDGPU.h:44 +private: + const std::map OptionsDefault = { + {options::OPT_O, "3"}, Is it really needed to create map in the header? https://reviews.llvm.org/D37386 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37381: Fix regression in special member definitions under SuppressAllDiagnostics
brad.king updated this revision to Diff 113561. brad.king edited the summary of this revision. brad.king added a comment. Herald added a subscriber: mgorny. Updated diff to add a test case. https://reviews.llvm.org/D37381 Files: lib/Sema/SemaDeclCXX.cpp unittests/Sema/CMakeLists.txt unittests/Sema/SuppressAllDiagnosticsTest.cpp Index: unittests/Sema/SuppressAllDiagnosticsTest.cpp === --- /dev/null +++ unittests/Sema/SuppressAllDiagnosticsTest.cpp @@ -0,0 +1,205 @@ +//=== unittests/Sema/SuppressAllDiagnosticsTest.cpp ---===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "clang/AST/ASTConsumer.h" +#include "clang/AST/ASTContext.h" +#include "clang/Frontend/CompilerInstance.h" +#include "clang/Frontend/FrontendActions.h" +#include "clang/Sema/Sema.h" +#include "clang/Tooling/Tooling.h" +#include "gtest/gtest.h" + +#include + +namespace { + +// \brief ASTConsumer that forces definition of special members. +class ForceImplicitMembersASTConsumer : public clang::ASTConsumer { + clang::CompilerInstance &CI; + std::queue Classes; + +public: + ForceImplicitMembersASTConsumer(clang::CompilerInstance &CI) : CI(CI) {} + + void AddImplicitMembers(clang::CXXRecordDecl *RD) { +auto &Sema = CI.getSema(); + +// Declare implicit members. +Sema.ForceDeclarationOfImplicitMembers(RD); + +// Force definition of implicit members. +for (auto *D : RD->decls()) { + auto *M = clang::dyn_cast(D); + if (M && !M->isDeleted() && !M->isInvalidDecl()) { +bool Mark = false; +auto *C = clang::dyn_cast(M); +if (C) { + Mark = (C->isDefaultConstructor() || C->isCopyConstructor() || + C->isMoveConstructor()); +} else if (clang::dyn_cast(M)) { + Mark = true; +} else { + Mark = + (M->isCopyAssignmentOperator() || M->isMoveAssignmentOperator()); +} +if (Mark) { + // Ensure the member is defined. + Sema.MarkFunctionReferenced(clang::SourceLocation(), M); + if (C && C->isDefaulted() && C->isDefaultConstructor() && + C->isTrivial() && !C->isUsed(false)) { +// Clang does not build the definition of trivial constructors +// until they are used. Force semantic checking. +Sema.DefineImplicitDefaultConstructor(clang::SourceLocation(), C); + } + // Finish implicitly instantiated member. + Sema.PerformPendingInstantiations(); +} + } +} + } + + void HandleTagDeclDefinition(clang::TagDecl *D) { +if (auto *RD = clang::dyn_cast(D)) { + Classes.push(RD); +} + } + + void HandleTranslationUnit(clang::ASTContext &CTX) { +auto &Sema = CI.getSema(); + +// Finish the translation unit as written in the source. +Sema.PerformPendingInstantiations(); + +// Suppress diagnostics while we force more definitions. +Sema.getDiagnostics().setSuppressAllDiagnostics(true); + +// Force addition of implicit members to classes. +while (!Classes.empty()) { + auto *RD = Classes.front(); + Classes.pop(); + AddImplicitMembers(RD); +} +Sema.ActOnEndOfTranslationUnit(); + +// Verify that the "derived" class has the implicit members we expect. +auto const *TU = CTX.getTranslationUnitDecl(); +auto &Ids = CI.getPreprocessor().getIdentifierTable(); +auto const &result = +TU->lookup(clang::DeclarationName(&Ids.get("derived"))); +bool CheckedRecordDecl = false; +for (auto const *N : result) { + if (auto const *RD = clang::dyn_cast(N)) { +CheckedRecordDecl = true; +CheckImplicitMembers(RD); + } +} +ASSERT_TRUE(CheckedRecordDecl); + } + + void CheckImplicitMembers(clang::CXXRecordDecl const *RD) { +bool CheckedDefaultConstructor = false; +bool CheckedDestructor = false; +bool CheckedCopyConstructor = false; +bool CheckedMoveConstructor = false; +bool CheckedCopyAssignment = false; +bool CheckedMoveAssignment = false; +for (auto const *D : RD->decls()) { + if (auto const *M = clang::dyn_cast(D)) { +if (auto const *C = +clang::dyn_cast(M)) { + if (C->isDefaultConstructor()) { +CheckedDefaultConstructor = true; +ASSERT_FALSE(C->isDeleted()); +ASSERT_FALSE(C->isInvalidDecl()); + } else if (C->isCopyConstructor()) { +CheckedCopyConstructor = true; +if (CI.getLangOpts().CPlusPlus11) + ASSERT_TRUE(C->isDeleted()); +else + ASSERT_TRUE(C->isInvalidDecl()); + } else if (C->isMoveConstructor()) { +C
r312346 - [libFuzzer] switch -fsanitize=fuzzer from trace-pc-guard to inline-8bit-counters
Author: kcc Date: Fri Sep 1 11:34:36 2017 New Revision: 312346 URL: http://llvm.org/viewvc/llvm-project?rev=312346&view=rev Log: [libFuzzer] switch -fsanitize=fuzzer from trace-pc-guard to inline-8bit-counters Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp cfe/trunk/test/Driver/fuzzer.c Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=312346&r1=312345&r2=312346&view=diff == --- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original) +++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Fri Sep 1 11:34:36 2017 @@ -313,7 +313,7 @@ SanitizerArgs::SanitizerArgs(const ToolC // Enable coverage if the fuzzing flag is set. if (Add & FuzzerNoLink) { -CoverageFeatures |= CoverageTracePCGuard | CoverageIndirCall | +CoverageFeatures |= CoverageInline8bitCounters | CoverageIndirCall | CoverageTraceCmp | CoveragePCTable; // Due to TLS differences, stack depth tracking is only enabled on Linux if (TC.getTriple().isOSLinux()) Modified: cfe/trunk/test/Driver/fuzzer.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fuzzer.c?rev=312346&r1=312345&r2=312346&view=diff == --- cfe/trunk/test/Driver/fuzzer.c (original) +++ cfe/trunk/test/Driver/fuzzer.c Fri Sep 1 11:34:36 2017 @@ -3,7 +3,7 @@ // RUN: %clang -fsanitize=fuzzer %s -target x86_64-apple-darwin14 -### 2>&1 | FileCheck --check-prefixes=CHECK-FUZZER-LIB,CHECK-COVERAGE-FLAGS %s // // CHECK-FUZZER-LIB: libclang_rt.fuzzer -// CHECK-COVERAGE: -fsanitize-coverage-trace-pc-guard +// CHECK-COVERAGE: -fsanitize-coverage-inline-8bit-counters // CHECK-COVERAGE-SAME: -fsanitize-coverage-indirect-calls // CHECK-COVERAGE-SAME: -fsanitize-coverage-trace-cmp // CHECK-COVERAGE-SAME: -fsanitize-coverage-pc-table @@ -24,7 +24,7 @@ // Check that we don't link in libFuzzer when compiling with -fsanitize=fuzzer-no-link. // RUN: %clang -fsanitize=fuzzer-no-link %s -target x86_64-apple-darwin14 -### 2>&1 | FileCheck --check-prefixes=CHECK-NOLIB,CHECK-COV %s // CHECK-NOLIB-NOT: libclang_rt.libfuzzer -// CHECK-COV: -fsanitize-coverage-trace-pc-guard +// CHECK-COV: -fsanitize-coverage-inline-8bit-counters // RUN: %clang -fsanitize=fuzzer -fsanitize-coverage=trace-pc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-MSG %s // CHECK-MSG-NOT: argument unused during compilation ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r312351 - Driver: extract diagnostics flag handling (NFC)
Author: compnerd Date: Fri Sep 1 11:57:34 2017 New Revision: 312351 URL: http://llvm.org/viewvc/llvm-project?rev=312351&view=rev Log: Driver: extract diagnostics flag handling (NFC) Extract a function to render the diagnostics options to the clang frontend. This continues the simplification of the clang cc1 command line invocation generation. NFC Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=312351&r1=312350&r2=312351&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Sep 1 11:57:34 2017 @@ -2429,6 +2429,121 @@ static void RenderObjCOptions(const Tool } } +static void RenderDiagnosticsOptions(const Driver &D, const ArgList &Args, + ArgStringList &CmdArgs) { + bool CaretDefault = true; + bool ColumnDefault = true; + + if (const Arg *A = Args.getLastArg(options::OPT__SLASH_diagnostics_classic, + options::OPT__SLASH_diagnostics_column, + options::OPT__SLASH_diagnostics_caret)) { +switch (A->getOption().getID()) { +case options::OPT__SLASH_diagnostics_caret: + CaretDefault = true; + ColumnDefault = true; + break; +case options::OPT__SLASH_diagnostics_column: + CaretDefault = false; + ColumnDefault = true; + break; +case options::OPT__SLASH_diagnostics_classic: + CaretDefault = false; + ColumnDefault = false; + break; +} + } + + // -fcaret-diagnostics is default. + if (!Args.hasFlag(options::OPT_fcaret_diagnostics, +options::OPT_fno_caret_diagnostics, CaretDefault)) +CmdArgs.push_back("-fno-caret-diagnostics"); + + // -fdiagnostics-fixit-info is default, only pass non-default. + if (!Args.hasFlag(options::OPT_fdiagnostics_fixit_info, +options::OPT_fno_diagnostics_fixit_info)) +CmdArgs.push_back("-fno-diagnostics-fixit-info"); + + // Enable -fdiagnostics-show-option by default. + if (Args.hasFlag(options::OPT_fdiagnostics_show_option, + options::OPT_fno_diagnostics_show_option)) +CmdArgs.push_back("-fdiagnostics-show-option"); + + if (const Arg *A = + Args.getLastArg(options::OPT_fdiagnostics_show_category_EQ)) { +CmdArgs.push_back("-fdiagnostics-show-category"); +CmdArgs.push_back(A->getValue()); + } + + if (Args.hasFlag(options::OPT_fdiagnostics_show_hotness, + options::OPT_fno_diagnostics_show_hotness, false)) +CmdArgs.push_back("-fdiagnostics-show-hotness"); + + if (const Arg *A = + Args.getLastArg(options::OPT_fdiagnostics_hotness_threshold_EQ)) { +std::string Opt = +std::string("-fdiagnostics-hotness-threshold=") + A->getValue(); +CmdArgs.push_back(Args.MakeArgString(Opt)); + } + + if (const Arg *A = Args.getLastArg(options::OPT_fdiagnostics_format_EQ)) { +CmdArgs.push_back("-fdiagnostics-format"); +CmdArgs.push_back(A->getValue()); + } + + if (const Arg *A = Args.getLastArg( + options::OPT_fdiagnostics_show_note_include_stack, + options::OPT_fno_diagnostics_show_note_include_stack)) { +const Option &O = A->getOption(); +if (O.matches(options::OPT_fdiagnostics_show_note_include_stack)) + CmdArgs.push_back("-fdiagnostics-show-note-include-stack"); +else + CmdArgs.push_back("-fno-diagnostics-show-note-include-stack"); + } + + // Color diagnostics are parsed by the driver directly from argv and later + // re-parsed to construct this job; claim any possible color diagnostic here + // to avoid warn_drv_unused_argument and diagnose bad + // OPT_fdiagnostics_color_EQ values. + for (const Arg *A : Args) { +const Option &O = A->getOption(); +if (!O.matches(options::OPT_fcolor_diagnostics) && +!O.matches(options::OPT_fdiagnostics_color) && +!O.matches(options::OPT_fno_color_diagnostics) && +!O.matches(options::OPT_fno_diagnostics_color) && +!O.matches(options::OPT_fdiagnostics_color_EQ)) + continue; + +if (O.matches(options::OPT_fdiagnostics_color_EQ)) { + StringRef Value(A->getValue()); + if (Value != "always" && Value != "never" && Value != "auto") +D.Diag(diag::err_drv_clang_unsupported) +<< ("-fdiagnostics-color=" + Value).str(); +} +A->claim(); + } + + if (D.getDiags().getDiagnosticOptions().ShowColors) +CmdArgs.push_back("-fcolor-diagnostics"); + + if (Args.hasArg(options::OPT_fansi_escape_codes)) +CmdArgs.push_back("-fansi-escape-codes"); + + if (!Args.hasFlag(options::OPT_fshow_source_location, +options::OPT_fno_show_source_location)) +CmdArgs.push_back("-fno-show-source-location"); + + if (Args.hasArg(options::
[PATCH] D37322: [Sema] Correct typos in LHS, RHS before building a binop expression.
ahatanak added a comment. Is it possible to avoid creating CXXDependentScopeMemberExpr in the first place? It seems to me that we shouldn't be creating a CXXDependentScopeMemberExpr for an ObjC property access. Or perhaps there are reasons to type-correct it later? https://reviews.llvm.org/D37322 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37390: [diagtool] Add list-warning-flags
JDevlieghere created this revision. JDevlieghere added a project: clang. Herald added a subscriber: mgorny. This patch adds a new tool to diagnostic tool called `list-warning-flags` to display only warnings that have a corresponding -W flag. While we already have `list-warnings`, the output contains all internal diagnostic names. This is an implementation detail of the compiler and usually not what the users wants. I've rephrased the description of the exiting tool to emphasize its respective purpose. Because the limited amount of code and complexity, as well as the absence of arguments in the other tools and the existing duplication in features between the them, it seemed reasonable to me to add this as something separate. However I don't know too much about diagtool and its usage so this is very much open for discussion. Repository: rL LLVM https://reviews.llvm.org/D37390 Files: tools/diagtool/CMakeLists.txt tools/diagtool/ListWarningFlags.cpp tools/diagtool/ListWarnings.cpp Index: tools/diagtool/ListWarnings.cpp === --- tools/diagtool/ListWarnings.cpp +++ tools/diagtool/ListWarnings.cpp @@ -1,13 +1,13 @@ -//===- ListWarnings.h - diagtool tool for printing warning flags --===// +//===- ListWarnings.h - diagtool tool for printing warnings ---===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===--===// // -// This file provides a diagtool tool that displays warning flags for +// This file provides a diagtool tool that displays all warning for // diagnostics. // //===--===// @@ -21,20 +21,20 @@ #include "llvm/Support/Format.h" DEF_DIAGTOOL("list-warnings", - "List warnings and their corresponding flags", + "List all (internal) warnings", ListWarnings) - + using namespace clang; using namespace diagtool; namespace { struct Entry { llvm::StringRef DiagName; llvm::StringRef Flag; - + Entry(llvm::StringRef diagN, llvm::StringRef flag) : DiagName(diagN), Flag(flag) {} - + bool operator<(const Entry &x) const { return DiagName < x.DiagName; } }; } @@ -52,57 +52,57 @@ int ListWarnings::run(unsigned int argc, char **argv, llvm::raw_ostream &out) { std::vector Flagged, Unflagged; llvm::StringMap > flagHistogram; - + ArrayRef AllDiagnostics = getBuiltinDiagnosticsByName(); for (ArrayRef::iterator di = AllDiagnostics.begin(), de = AllDiagnostics.end(); di != de; ++di) { unsigned diagID = di->DiagID; - + if (DiagnosticIDs::isBuiltinNote(diagID)) continue; - + if (!DiagnosticIDs::isBuiltinWarningOrExtension(diagID)) continue; - + Entry entry(di->getName(), DiagnosticIDs::getWarningOptionForDiag(diagID)); - + if (entry.Flag.empty()) Unflagged.push_back(entry); else { Flagged.push_back(entry); flagHistogram[entry.Flag].push_back(diagID); } } - + out << "Warnings with flags (" << Flagged.size() << "):\n"; printEntries(Flagged, out); - + out << "Warnings without flags (" << Unflagged.size() << "):\n"; printEntries(Unflagged, out); out << "\nSTATISTICS:\n\n"; - double percentFlagged = ((double) Flagged.size()) + double percentFlagged = ((double) Flagged.size()) / (Flagged.size() + Unflagged.size()) * 100.0; - - out << " Percentage of warnings with flags: " + + out << " Percentage of warnings with flags: " << llvm::format("%.4g",percentFlagged) << "%\n"; - + out << " Number of unique flags: " << flagHistogram.size() << '\n'; - + double avgDiagsPerFlag = (double) Flagged.size() / flagHistogram.size(); out << " Average number of diagnostics per flag: " << llvm::format("%.4g", avgDiagsPerFlag) << '\n'; out << " Number in -Wpedantic (not covered by other -W flags): " << flagHistogram["pedantic"].size() << '\n'; out << '\n'; - + return 0; } Index: tools/diagtool/ListWarningFlags.cpp === --- /dev/null +++ tools/diagtool/ListWarningFlags.cpp @@ -0,0 +1,55 @@ +//===- ListWarningFlags.h - diagtool tool for printing warning flags --===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// +// +// This file provides a diagtool tool that displays only warnings that have a +// corresponding flags for diagnostics. +// +//===-
Re: [PATCH] D36707: [CodeGen]Refactor CpuSupports/CPUIs Builtin Code Gen to better work with "target" implementation
Don't wait on me here. On Thu, Aug 31, 2017, 10:53 PM Craig Topper via Phabricator < revi...@reviews.llvm.org> wrote: > craig.topper accepted this revision. > craig.topper added a comment. > This revision is now accepted and ready to land. > > LGTM > > > https://reviews.llvm.org/D36707 > > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
RE: [PATCH] D36707: [CodeGen]Refactor CpuSupports/CPUIs Builtin Code Gen to better work with "target" implementation
Oops, totally forgot this got approved ☺ Thanks for the reminder! From: Eric Christopher [mailto:echri...@gmail.com] Sent: Friday, September 1, 2017 12:40 PM To: reviews+d36707+public+aa8b48c258736...@reviews.llvm.org; Keane, Erich ; llvm-...@redking.me.uk; craig.top...@gmail.com Cc: cfe-commits@lists.llvm.org Subject: Re: [PATCH] D36707: [CodeGen]Refactor CpuSupports/CPUIs Builtin Code Gen to better work with "target" implementation Don't wait on me here. On Thu, Aug 31, 2017, 10:53 PM Craig Topper via Phabricator mailto:revi...@reviews.llvm.org>> wrote: craig.topper accepted this revision. craig.topper added a comment. This revision is now accepted and ready to land. LGTM https://reviews.llvm.org/D36707 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r312355 - [CodeGen]Refactor CpuSupports/CPUIs Builtin Code Gen to better work with
Author: erichkeane Date: Fri Sep 1 12:42:45 2017 New Revision: 312355 URL: http://llvm.org/viewvc/llvm-project?rev=312355&view=rev Log: [CodeGen]Refactor CpuSupports/CPUIs Builtin Code Gen to better work with "target" implementation A small set of refactors that'll make it easier for me to implement 'target' support. First, extract the CPUSupports functionality into its own function. THis has the advantage of not wasting time in this builtin to deal with arguments. Second, pulls both CPUSupports and CPUIs implementation into a member-function, so that it can be called from the resolver generation that I'm working on. Third, creates an overload that takes simply the feature/cpu name (rather than extracting it from a callexpr), since that info isn't available later. Note that despite how the 'diff' looks, the EmitX86CPUSupports function simply takes the implementation out of the 'switch'. Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=312355&r1=312354&r2=312355&view=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Sep 1 12:42:45 2017 @@ -7288,9 +7288,13 @@ static Value *EmitX86SExtMask(CodeGenFun return CGF.Builder.CreateSExt(Mask, DstTy, "vpmovm2"); } -static Value *EmitX86CpuIs(CodeGenFunction &CGF, const CallExpr *E) { +Value *CodeGenFunction::EmitX86CpuIs(const CallExpr *E) { const Expr *CPUExpr = E->getArg(0)->IgnoreParenCasts(); StringRef CPUStr = cast(CPUExpr)->getString(); + return EmitX86CpuIs(CPUStr); +} + +Value *CodeGenFunction::EmitX86CpuIs(StringRef CPUStr) { // This enum contains the vendor, type, and subtype enums from the // runtime library concatenated together. The _START labels mark @@ -7332,7 +7336,9 @@ static Value *EmitX86CpuIs(CodeGenFuncti StringSwitch(CPUStr) .Case("amd", AMD) .Case("amdfam10h", AMDFAM10H) + .Case("amdfam10", AMDFAM10H) .Case("amdfam15h", AMDFAM15H) + .Case("amdfam15", AMDFAM15H) .Case("atom", INTEL_BONNELL) .Case("barcelona", AMDFAM10H_BARCELONA) .Case("bdver1", AMDFAM15H_BDVER1) @@ -7360,7 +7366,7 @@ static Value *EmitX86CpuIs(CodeGenFuncti .Case("westmere", INTEL_COREI7_WESTMERE) .Case("znver1", AMDFAM17H_ZNVER1); - llvm::Type *Int32Ty = CGF.Builder.getInt32Ty(); + llvm::Type *Int32Ty = Builder.getInt32Ty(); // Matching the struct layout from the compiler-rt/libgcc structure that is // filled in: @@ -7372,7 +7378,7 @@ static Value *EmitX86CpuIs(CodeGenFuncti llvm::ArrayType::get(Int32Ty, 1)); // Grab the global __cpu_model. - llvm::Constant *CpuModel = CGF.CGM.CreateRuntimeVariable(STy, "__cpu_model"); + llvm::Constant *CpuModel = CGM.CreateRuntimeVariable(STy, "__cpu_model"); // Calculate the index needed to access the correct field based on the // range. Also adjust the expected value. @@ -7394,16 +7400,133 @@ static Value *EmitX86CpuIs(CodeGenFuncti ConstantInt::get(Int32Ty, 0), ConstantInt::get(Int32Ty, Index) }; - llvm::Value *CpuValue = CGF.Builder.CreateGEP(STy, CpuModel, Idxs); - CpuValue = CGF.Builder.CreateAlignedLoad(CpuValue, CharUnits::fromQuantity(4)); + llvm::Value *CpuValue = Builder.CreateGEP(STy, CpuModel, Idxs); + CpuValue = Builder.CreateAlignedLoad(CpuValue, CharUnits::fromQuantity(4)); // Check the value of the field against the requested value. - return CGF.Builder.CreateICmpEQ(CpuValue, + return Builder.CreateICmpEQ(CpuValue, llvm::ConstantInt::get(Int32Ty, Value)); } +Value *CodeGenFunction::EmitX86CpuSupports(const CallExpr *E) { + const Expr *FeatureExpr = E->getArg(0)->IgnoreParenCasts(); + StringRef FeatureStr = cast(FeatureExpr)->getString(); + return EmitX86CpuSupports(FeatureStr); +} + +Value *CodeGenFunction::EmitX86CpuSupports(ArrayRef FeatureStrs) { + // TODO: When/if this becomes more than x86 specific then use a TargetInfo + // based mapping. + // Processor features and mapping to processor feature value. + enum X86Features { +CMOV = 0, +MMX, +POPCNT, +SSE, +SSE2, +SSE3, +SSSE3, +SSE4_1, +SSE4_2, +AVX, +AVX2, +SSE4_A, +FMA4, +XOP, +FMA, +AVX512F, +BMI, +BMI2, +AES, +PCLMUL, +AVX512VL, +AVX512BW, +AVX512DQ, +AVX512CD, +AVX512ER, +AVX512PF, +AVX512VBMI, +AVX512IFMA, +AVX5124VNNIW, +AVX5124FMAPS, +AVX512VPOPCNTDQ, +MAX + }; + + uint32_t FeaturesMask = 0; + + for (const StringRef &FeatureStr : FeatureStrs) { +X86Features Feature = +StringSwitch(FeatureStr) +.Case("cmov", X86Features::CMOV) +.Case("mmx", X86Features::MMX) +
[PATCH] D37383: [AST] Add TableGen for StmtDataCollectors
johannes added a comment. In https://reviews.llvm.org/D37383#858905, @teemperor wrote: > @arphaman I suggested tablegen in https://reviews.llvm.org/D36664 because I > remembered we had some CMake sanity check about not having an *.inc in our > include dir: > https://github.com/llvm-mirror/clang/blob/master/CMakeLists.txt#L266 Not sure > if it actually fires for our case, but it looks like it does. Yes, that was the issue why it didn't work under include/. I think the sanity check could be removed, since in-source builds are forbidden anyway. Or maybe it is still useful by telling us that .inc is probably an generated file (most, but not all of them are generated, it seems), so another solution would be to just change the file extension. Actually, `.def` might be the right extension. Shall we move to using TableGen only when we need it, and rename it to `.def` for now? A preprocessor-only solution for the two modes could look like this: user: #define DERIVED MyStmtVisitor #define SINGLE_TU #include "clang/AST/StmtDataCollectors.def" StmtDataCollectors.def: #define DEF_VISIT(CLASS, CODE)\ template void Visit##CLASS(const CLASS *S) {\ CODE;\ ConstStmtVisitor<##DERIVED>::Visit##CLASS(S)\ } #ifdef SINGLE_TU #define DEF_ADD_DATA(CLASS, COMMON, SINGLE, CROSS) DEF_VISIT(CLASS, COMMON; SINGLE) #else #define DEF_ADD_DATA(CLASS, COMMON, SINGLE, CROSS) DEF_VISIT(CLASS, COMMON, CROSS) #endif DEF_ADD_DATA(Stmt, .., .., ..) ... However, I think TableGen has an advantage when we can extract some structure instead of just storing the code. Basically, a list of primitive and one of pointer members for each class could simplify things. https://reviews.llvm.org/D37383 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36998: [AST] Traverse templates in LexicallyOrderedRecursiveASTVisitor
johannes updated this revision to Diff 113581. johannes added a comment. undo visibility change https://reviews.llvm.org/D36998 Files: include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h include/clang/AST/RecursiveASTVisitor.h unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp Index: unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp === --- unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp +++ unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp @@ -21,8 +21,9 @@ : public LexicallyOrderedRecursiveASTVisitor { public: LexicallyOrderedDeclVisitor(DummyMatchVisitor &Matcher, - const SourceManager &SM) - : LexicallyOrderedRecursiveASTVisitor(SM), Matcher(Matcher) {} + const SourceManager &SM, bool EmitIndices) + : LexicallyOrderedRecursiveASTVisitor(SM), Matcher(Matcher), +EmitIndices(EmitIndices) {} bool TraverseDecl(Decl *D) { TraversalStack.push_back(D); @@ -35,15 +36,20 @@ private: DummyMatchVisitor &Matcher; + bool EmitIndices; + unsigned Index = 0; llvm::SmallVector TraversalStack; }; class DummyMatchVisitor : public ExpectedLocationVisitor { + bool EmitIndices; + public: + DummyMatchVisitor(bool EmitIndices = false) : EmitIndices(EmitIndices) {} bool VisitTranslationUnitDecl(TranslationUnitDecl *TU) { const ASTContext &Context = TU->getASTContext(); const SourceManager &SM = Context.getSourceManager(); -LexicallyOrderedDeclVisitor SubVisitor(*this, SM); +LexicallyOrderedDeclVisitor SubVisitor(*this, SM, EmitIndices); SubVisitor.TraverseDecl(TU); return false; } @@ -64,9 +70,11 @@ OS << ND->getNameAsString(); else OS << "???"; -if (isa(D)) +if (isa(D) or isa(D)) OS << "/"; } + if (EmitIndices) +OS << "@" << Index++; Matcher.match(OS.str(), D); return true; } @@ -138,4 +146,18 @@ EXPECT_TRUE(Visitor.runOver(Source, DummyMatchVisitor::Lang_OBJC)); } +TEST(LexicallyOrderedRecursiveASTVisitor, VisitTemplateDecl) { + StringRef Source = R"( +template T f(); +template class Class {}; +)"; + DummyMatchVisitor Visitor(/*EmitIndices=*/true); + Visitor.ExpectMatch("/f/T@1", 2, 11); + Visitor.ExpectMatch("/f/f/@2", 2, 20); + Visitor.ExpectMatch("/Class/U@4", 3, 11); + Visitor.ExpectMatch("/Class/@5", 3, 20); + Visitor.ExpectMatch("/Class/Class/@6", 3, 34); + EXPECT_TRUE(Visitor.runOver(Source)); +} + } // end anonymous namespace Index: include/clang/AST/RecursiveASTVisitor.h === --- include/clang/AST/RecursiveASTVisitor.h +++ include/clang/AST/RecursiveASTVisitor.h @@ -535,6 +535,7 @@ bool dataTraverseNode(Stmt *S, DataRecursionQueue *Queue); bool PostVisitStmt(Stmt *S); + bool shouldTraverseTemplateArgumentsBeforeDecl() const { return false; } }; template @@ -1688,8 +1689,13 @@ // template declarations. #define DEF_TRAVERSE_TMPL_DECL(TMPLDECLKIND) \ DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplateDecl, { \ -TRY_TO(TraverseDecl(D->getTemplatedDecl())); \ -TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters())); \ +if (getDerived().shouldTraverseTemplateArgumentsBeforeDecl()) {\ + TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters())); \ + TRY_TO(TraverseDecl(D->getTemplatedDecl())); \ +} else { \ + TRY_TO(TraverseDecl(D->getTemplatedDecl())); \ + TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters())); \ +} \ \ /* By default, we do not traverse the instantiations of\ class templates since they do not appear in the user code. The \ Index: include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h === --- include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h +++ include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h @@ -111,6 +111,8 @@ return true; } + bool shouldTraverseTemplateArgumentsBeforeDecl() const { return true; } + private: bool TraverseAdditionalLexicallyNestedDeclarations() { // FIXME: Ideally the gathered declarations and the declarations in the ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27810: FileManager: mark virtual file entries as valid entries
cameron314 added a comment. The `IsValid = true` line coincidentally fixes a tangentially related bug -- see https://reviews.llvm.org/D20338 (in which I tried to introduce the same fix almost a year earlier, but nobody accepted the review). I guess I have to maintain the test for that case out of tree, though I could try to upstream it again (however, given that it's now passing with your change, I don't have much hope of it being accepted). https://reviews.llvm.org/D27810 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37231: Add half load and store builtins
jvesely updated this revision to Diff 113588. jvesely marked 6 inline comments as done. jvesely edited the summary of this revision. jvesely added a comment. fully check loads in tests Repository: rL LLVM https://reviews.llvm.org/D37231 Files: include/clang/Basic/Builtins.def include/clang/Basic/Builtins.h lib/Basic/Builtins.cpp lib/CodeGen/CGBuiltin.cpp test/CodeGenOpenCL/no-half.cl Index: test/CodeGenOpenCL/no-half.cl === --- /dev/null +++ test/CodeGenOpenCL/no-half.cl @@ -0,0 +1,39 @@ +// RUN: %clang_cc1 %s -cl-std=cl2.0 -emit-llvm -o - -triple spir-unknown-unknown | FileCheck %s +// RUN: %clang_cc1 %s -cl-std=cl1.2 -emit-llvm -o - -triple spir-unknown-unknown | FileCheck %s +// RUN: %clang_cc1 %s -cl-std=cl1.1 -emit-llvm -o - -triple spir-unknown-unknown | FileCheck %s + +#pragma OPENCL EXTENSION cl_khr_fp64:enable + +// CHECK-LABEL: @test_store_float(float %foo, half addrspace({{.}}){{.*}} %bar) +__kernel void test_store_float(float foo, __global half* bar) +{ + __builtin_store_halff(foo, bar); +// CHECK: [[HALF_VAL:%.*]] = fptrunc float %foo to half +// CHECK: store half [[HALF_VAL]], half addrspace({{.}})* %bar, align 2 +} + +// CHECK-LABEL: @test_store_double(double %foo, half addrspace({{.}}){{.*}} %bar) +__kernel void test_store_double(double foo, __global half* bar) +{ + __builtin_store_half(foo, bar); +// CHECK: [[HALF_VAL:%.*]] = fptrunc double %foo to half +// CHECK: store half [[HALF_VAL]], half addrspace({{.}})* %bar, align 2 +} + +// CHECK-LABEL: @test_load_float(float addrspace({{.}}){{.*}} %foo, half addrspace({{.}}){{.*}} %bar) +__kernel void test_load_float(__global float* foo, __global half* bar) +{ + foo[0] = __builtin_load_halff(bar); +// CHECK: [[HALF_VAL:%.*]] = load half, half addrspace({{.}})* %bar +// CHECK: [[FULL_VAL:%.*]] = fpext half [[HALF_VAL]] to float +// CHECK: store float [[FULL_VAL]], float addrspace({{.}})* %foo +} + +// CHECK-LABEL: @test_load_double(double addrspace({{.}}){{.*}} %foo, half addrspace({{.}}){{.*}} %bar) +__kernel void test_load_double(__global double* foo, __global half* bar) +{ + foo[0] = __builtin_load_half(bar); +// CHECK: [[HALF_VAL:%.*]] = load half, half addrspace({{.}})* %bar +// CHECK: [[FULL_VAL:%.*]] = fpext half [[HALF_VAL]] to double +// CHECK: store double [[FULL_VAL]], double addrspace({{.}})* %foo +} Index: lib/CodeGen/CGBuiltin.cpp === --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -2724,6 +2724,24 @@ Name), {NDRange, Block})); } + + case Builtin::BI__builtin_store_half: + case Builtin::BI__builtin_store_halff: { +Value *Val = EmitScalarExpr(E->getArg(0)); +Address Address = EmitPointerWithAlignment(E->getArg(1)); +Value *HalfVal = Builder.CreateFPTrunc(Val, Builder.getHalfTy()); +return RValue::get(Builder.CreateStore(HalfVal, Address)); + } + case Builtin::BI__builtin_load_half: { +Address Address = EmitPointerWithAlignment(E->getArg(0)); +Value *HalfVal = Builder.CreateLoad(Address); +return RValue::get(Builder.CreateFPExt(HalfVal, Builder.getDoubleTy())); + } + case Builtin::BI__builtin_load_halff: { +Address Address = EmitPointerWithAlignment(E->getArg(0)); +Value *HalfVal = Builder.CreateLoad(Address); +return RValue::get(Builder.CreateFPExt(HalfVal, Builder.getFloatTy())); + } case Builtin::BIprintf: if (getTarget().getTriple().isNVPTX()) return EmitNVPTXDevicePrintfCallExpr(E, ReturnValue); Index: lib/Basic/Builtins.cpp === --- lib/Basic/Builtins.cpp +++ lib/Basic/Builtins.cpp @@ -69,9 +69,14 @@ bool MSModeUnsupported = !LangOpts.MicrosoftExt && (BuiltinInfo.Langs & MS_LANG); bool ObjCUnsupported = !LangOpts.ObjC1 && BuiltinInfo.Langs == OBJC_LANG; - bool OclCUnsupported = LangOpts.OpenCLVersion != 200 && - BuiltinInfo.Langs == OCLC20_LANG; + bool OclC1Unsupported = (LangOpts.OpenCLVersion / 100) != 1 && + (BuiltinInfo.Langs & ALL_OCLC_LANGUAGES ) == OCLC1X_LANG; + bool OclC2Unsupported = LangOpts.OpenCLVersion != 200 && + (BuiltinInfo.Langs & ALL_OCLC_LANGUAGES) == OCLC20_LANG; + bool OclCUnsupported = !LangOpts.OpenCL && + (BuiltinInfo.Langs & ALL_OCLC_LANGUAGES); return !BuiltinsUnsupported && !MathBuiltinsUnsupported && !OclCUnsupported && + !OclC1Unsupported && !OclC2Unsupported && !GnuModeUnsupported && !MSModeUnsupported && !ObjCUnsupported; } Index: include/clang/Basic/Builtins.h === --- include/clang/Basic/Builtins.h +++ include/clang/Basic/Builtins.h @@ -36,10 +36,12 @@ CXX_LANG = 0x4, // builtin for cplusplus only. OBJC_LANG = 0x8,// builtin for objective-c and objective-c++ MS_LANG = 0x10,
[PATCH] D37231: Add half load and store builtins
jvesely added inline comments. Comment at: include/clang/Basic/Builtins.def:1427 +// OpenCL half load/store builtin +BUILTIN(__builtin_store_half, "vdh*", "n") +BUILTIN(__builtin_store_halff, "vfh*", "n") Anastasia wrote: > jvesely wrote: > > Anastasia wrote: > > > I think this should be a language builtin (see above) but perhaps we > > > might need to extend the language version here. Because I believe we only > > > have OpenCL v2.0 currently. > > > > > > Also this should only be available if `cl_khr_fp16` is supported and > > > enabled? I think we are doing similar with some subgroups functions (e.g. > > > `get_kernel_sub_group_count_for_ndrange`) that are only supported by > > > `cl_khr_subgroup` but those have custom diagnostic though. May be we > > > could leave this check out since `half` is not available if `cl_khr_fp16` > > > is not enabled anyways. > > This is specifically meant to be used when `cl_khr_fp16` is **not** > > available. > > CLC allows using half as storage format and half pointers without the > > extension, > > vstore_half/vload_half are used to load/store half values. (CL1.2 CH > > 6.1.1.1) > > > > These builtins are not necessary if `cl_khr_fp16` is available (we can use > > regular loads/stores). > > > > I'll take stab at making these CLC only, but similarly to device specific > > builtins it looked useful beyond that, since these builtins provide access > > to half type storage. > Strange. This is not how I would interpret from the extension spec though: > https://www.khronos.org/registry/OpenCL/sdk/1.2/docs/man/xhtml/cl_khr_fp16.html > > But I think for this change is probably fine indeed because this doesn't > affect half type itself. I'm not sure I see the conflict here. `cl_khr_fp16` adds support for `half` scalar and `halfn` vector types. without the extension the specs say (`OCL 1.2 Ch. 6.1.1.1`): > The half data type can only be used to declare a pointer to a buffer that > contains half values. `vload_half` and `vstore_half` used to access those buffers without needing `half` type (or the `cl_khr_fp16` extension). > But I think for this change is probably fine indeed because this doesn't > affect half type itself. exactly. this is needed outside of `cl_khr_fp16`, or the `half` type Comment at: test/CodeGenOpenCL/no-half.cl:19 + __builtin_store_half(foo, bar); +// CHECK: [[HALF_VAL:%.*]] = fptrunc double %foo to half +// CHECK: store half [[HALF_VAL]], half addrspace({{.}})* %bar, align 2 Anastasia wrote: > Would it make sense to add a check for `load` similarly to `store` in the > test_load_float/test_load_double tests? there is no load. `fptrunc double %foo to half` uses the function parameter directly Comment at: test/CodeGenOpenCL/no-half.cl:27 + foo[0] = __builtin_load_halff(bar); +// CHECK: [[HALF_VAL:%.*]] = load +// CHECK: [[FULL_VAL:%.*]] = fpext half [[HALF_VAL]] to float Anastasia wrote: > Minor thing: any reason you are not checking the load fully? just my laziness, I've added full check. Repository: rL LLVM https://reviews.llvm.org/D37231 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r312361 - Enable check-ubsan-minimal in standalone compiler-rt build.
Author: eugenis Date: Fri Sep 1 13:37:20 2017 New Revision: 312361 URL: http://llvm.org/viewvc/llvm-project?rev=312361&view=rev Log: Enable check-ubsan-minimal in standalone compiler-rt build. Modified: cfe/trunk/runtime/CMakeLists.txt Modified: cfe/trunk/runtime/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/runtime/CMakeLists.txt?rev=312361&r1=312360&r2=312361&view=diff == --- cfe/trunk/runtime/CMakeLists.txt (original) +++ cfe/trunk/runtime/CMakeLists.txt Fri Sep 1 13:37:20 2017 @@ -108,7 +108,7 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND E USES_TERMINAL) # Add top-level targets that build specific compiler-rt runtimes. - set(COMPILER_RT_RUNTIMES asan builtins dfsan lsan msan profile tsan ubsan) + set(COMPILER_RT_RUNTIMES asan builtins dfsan lsan msan profile tsan ubsan ubsan-minimal) foreach(runtime ${COMPILER_RT_RUNTIMES}) get_ext_project_build_command(build_runtime_cmd ${runtime}) add_custom_target(${runtime} @@ -125,7 +125,7 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND E # Add top-level targets for various compiler-rt test suites. set(COMPILER_RT_TEST_SUITES check-asan check-asan-dynamic check-dfsan - check-lsan check-msan check-sanitizer check-tsan check-ubsan + check-lsan check-msan check-sanitizer check-tsan check-ubsan check-ubsan-minimal check-profile check-cfi check-cfi-and-supported check-safestack) foreach(test_suite ${COMPILER_RT_TEST_SUITES}) get_ext_project_build_command(run_test_suite ${test_suite}) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r312371 - Creating release candidate rc5 from release_500 branch
Author: hans Date: Fri Sep 1 14:02:55 2017 New Revision: 312371 URL: http://llvm.org/viewvc/llvm-project?rev=312371&view=rev Log: Creating release candidate rc5 from release_500 branch Added: libcxx/tags/RELEASE_500/rc5/ (props changed) - copied from r312370, libcxx/branches/release_50/ Propchange: libcxx/tags/RELEASE_500/rc5/ -- --- svn:mergeinfo (added) +++ svn:mergeinfo Fri Sep 1 14:02:55 2017 @@ -0,0 +1,2 @@ +/libcxx/branches/apple:136569-137939 +/libcxx/trunk:309296,309307,309474,309838,309851,309917,309920 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxxabi] r312372 - Creating release candidate rc5 from release_500 branch
Author: hans Date: Fri Sep 1 14:02:56 2017 New Revision: 312372 URL: http://llvm.org/viewvc/llvm-project?rev=312372&view=rev Log: Creating release candidate rc5 from release_500 branch Added: libcxxabi/tags/RELEASE_500/rc5/ - copied from r312371, libcxxabi/branches/release_50/ ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] r312378 - Creating release candidate rc5 from release_500 branch
Author: hans Date: Fri Sep 1 14:03:03 2017 New Revision: 312378 URL: http://llvm.org/viewvc/llvm-project?rev=312378&view=rev Log: Creating release candidate rc5 from release_500 branch Added: libunwind/tags/RELEASE_500/rc5/ (props changed) - copied from r312377, libunwind/branches/release_50/ Propchange: libunwind/tags/RELEASE_500/rc5/ -- svn:mergeinfo = /libunwind/trunk:308871,309147 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37400: [StaticAnalyzer] Fix failures due to the iteration order of ExplodedNode
mgrang created this revision. This fixes failures seen in the reverse iteration builder: http://lab.llvm.org:8011/builders/reverse-iteration/builds/26 Failing Tests (4): Clang :: Analysis/MisusedMovedObject.cpp Clang :: Analysis/keychainAPI.m Clang :: Analysis/loop-unrolling.cpp Clang :: Analysis/malloc.c https://reviews.llvm.org/D37400 Files: include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h Index: include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h === --- include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h +++ include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h @@ -27,7 +27,6 @@ #include "llvm/ADT/DepthFirstIterator.h" #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/GraphTraits.h" -#include "llvm/ADT/SmallPtrSet.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/Casting.h" #include @@ -404,7 +403,7 @@ }; class ExplodedNodeSet { - typedef llvm::SmallPtrSet ImplTy; + typedef llvm::SetVector ImplTy; ImplTy Impl; public: @@ -424,7 +423,7 @@ unsigned size() const { return Impl.size(); } bool empty()const { return Impl.empty(); } - bool erase(ExplodedNode *N) { return Impl.erase(N); } + bool erase(ExplodedNode *N) { return Impl.remove(N); } void clear() { Impl.clear(); } void insert(const ExplodedNodeSet &S) { Index: include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h === --- include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h +++ include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h @@ -27,7 +27,6 @@ #include "llvm/ADT/DepthFirstIterator.h" #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/GraphTraits.h" -#include "llvm/ADT/SmallPtrSet.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/Casting.h" #include @@ -404,7 +403,7 @@ }; class ExplodedNodeSet { - typedef llvm::SmallPtrSet ImplTy; + typedef llvm::SetVector ImplTy; ImplTy Impl; public: @@ -424,7 +423,7 @@ unsigned size() const { return Impl.size(); } bool empty()const { return Impl.empty(); } - bool erase(ExplodedNode *N) { return Impl.erase(N); } + bool erase(ExplodedNode *N) { return Impl.remove(N); } void clear() { Impl.clear(); } void insert(const ExplodedNodeSet &S) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37400: [StaticAnalyzer] Fix failures due to the iteration order of ExplodedNode
mgrang added a comment. The thing I am concerned with here is whether changing SmallPtrSet to a SetVector can potentially slow down the Static Analyzer? ExplodedNode seem to be used heavily in the analyzer and I can see it being iterated upon in several places. https://reviews.llvm.org/D37400 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37390: [diagtool] Add list-warning-flags
aprantl added a comment. Can this be tested? Comment at: tools/diagtool/ListWarningFlags.cpp:36 + for (ArrayRef::iterator di = AllDiagnostics.begin(), +de = AllDiagnostics.end(); + di != de; ++di) { range-based for / auto? Comment at: tools/diagtool/ListWarningFlags.cpp:38 + di != de; ++di) { +unsigned diagID = di->DiagID; +llvm::StringRef flag = DiagnosticIDs::getWarningOptionForDiag(diagID); The LLVM style wants variables to begin with an uppercase letter. Repository: rL LLVM https://reviews.llvm.org/D37390 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r312385 - Driver: extract floating point optimization handling (NFC)
Author: compnerd Date: Fri Sep 1 15:04:24 2017 New Revision: 312385 URL: http://llvm.org/viewvc/llvm-project?rev=312385&view=rev Log: Driver: extract floating point optimization handling (NFC) Extract the logic for the floating point handling into its own function. None of this information is needed for calculating the remainder of the arguments to the frontend. NFC Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=312385&r1=312384&r2=312385&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Sep 1 15:04:24 2017 @@ -1968,6 +1968,165 @@ static void CollectArgsForIntegratedAsse } } +static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D, + bool OFastEnabled, const ArgList &Args, + ArgStringList &CmdArgs) { + // Handle various floating point optimization flags, mapping them to the + // appropriate LLVM code generation flags. This is complicated by several + // "umbrella" flags, so we do this by stepping through the flags incrementally + // adjusting what we think is enabled/disabled, then at the end settting the + // LLVM flags based on the final state. + bool HonorINFs = true; + bool HonorNaNs = true; + // -fmath-errno is the default on some platforms, e.g. BSD-derived OSes. + bool MathErrno = TC.IsMathErrnoDefault(); + bool AssociativeMath = false; + bool ReciprocalMath = false; + bool SignedZeros = true; + bool TrappingMath = true; + StringRef DenormalFPMath = ""; + StringRef FPContract = ""; + + for (const Arg *A : Args) { +switch (A->getOption().getID()) { +// If this isn't an FP option skip the claim below +default: continue; + +// Options controlling individual features +case options::OPT_fhonor_infinities:HonorINFs = true; break; +case options::OPT_fno_honor_infinities: HonorINFs = false;break; +case options::OPT_fhonor_nans: HonorNaNs = true; break; +case options::OPT_fno_honor_nans: HonorNaNs = false;break; +case options::OPT_fmath_errno: MathErrno = true; break; +case options::OPT_fno_math_errno: MathErrno = false;break; +case options::OPT_fassociative_math:AssociativeMath = true; break; +case options::OPT_fno_associative_math: AssociativeMath = false; break; +case options::OPT_freciprocal_math: ReciprocalMath = true;break; +case options::OPT_fno_reciprocal_math: ReciprocalMath = false; break; +case options::OPT_fsigned_zeros:SignedZeros = true; break; +case options::OPT_fno_signed_zeros: SignedZeros = false; break; +case options::OPT_ftrapping_math: TrappingMath = true; break; +case options::OPT_fno_trapping_math:TrappingMath = false; break; + +case options::OPT_fdenormal_fp_math_EQ: + DenormalFPMath = A->getValue(); + break; + +// Validate and pass through -fp-contract option. +case options::OPT_ffp_contract: { + StringRef Val = A->getValue(); + if (Val == "fast" || Val == "on" || Val == "off") +FPContract = Val; + else +D.Diag(diag::err_drv_unsupported_option_argument) +<< A->getOption().getName() << Val; + break; +} + +case options::OPT_ffinite_math_only: + HonorINFs = false; + HonorNaNs = false; + break; +case options::OPT_fno_finite_math_only: + HonorINFs = true; + HonorNaNs = true; + break; + +case options::OPT_funsafe_math_optimizations: + AssociativeMath = true; + ReciprocalMath = true; + SignedZeros = false; + TrappingMath = false; + break; +case options::OPT_fno_unsafe_math_optimizations: + AssociativeMath = false; + ReciprocalMath = false; + SignedZeros = true; + TrappingMath = true; + // -fno_unsafe_math_optimizations restores default denormal handling + DenormalFPMath = ""; + break; + +case options::OPT_Ofast: + // If -Ofast is the optimization level, then -ffast-math should be enabled + if (!OFastEnabled) +continue; + LLVM_FALLTHROUGH; +case options::OPT_ffast_math: + HonorINFs = false; + HonorNaNs = false; + MathErrno = false; + AssociativeMath = true; + ReciprocalMath = true; + SignedZeros = false; + TrappingMath = false; + // If fast-math is set then set the fp-contract mode to fast. + FPContract = "fast"; + break; +case options::OPT_fno_fast_math: + HonorINFs = true; + HonorNaNs = true; + // Turning on -ffast-math (with either flag) removes the need for + // MathErrno. However, tu
[PATCH] D28955: [analyzer] Enable support for symbolic extension/truncation
ddcc updated this revision to Diff 113619. ddcc added a comment. Rebase, factor out floating-point changes, fix Z3 type bug, support general APSInt comparison https://reviews.llvm.org/D28955 Files: include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h lib/StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp lib/StaticAnalyzer/Core/ProgramState.cpp lib/StaticAnalyzer/Core/RangeConstraintManager.cpp lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp lib/StaticAnalyzer/Core/Store.cpp lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp test/Analysis/PR3991.m test/Analysis/dead-stores.m test/Analysis/explain-svals.cpp test/Analysis/malloc.c test/Analysis/misc-ps-eager-assume.m test/Analysis/std-c-library-functions.c Index: test/Analysis/std-c-library-functions.c === --- test/Analysis/std-c-library-functions.c +++ test/Analysis/std-c-library-functions.c @@ -146,7 +146,7 @@ void test_isgraph_isprint(int x) { char y = x; if (isgraph(y)) -clang_analyzer_eval(isprint(x)); // expected-warning{{TRUE}} +clang_analyzer_eval(isprint(y)); // expected-warning{{TRUE}} } int isdigit(int); Index: test/Analysis/misc-ps-eager-assume.m === --- test/Analysis/misc-ps-eager-assume.m +++ test/Analysis/misc-ps-eager-assume.m @@ -1,5 +1,4 @@ // RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks %s -analyzer-eagerly-assume -// expected-no-diagnostics // Delta-reduced header stuff (needed for test cases). typedef signed char BOOL; @@ -56,7 +55,7 @@ void handle_symbolic_cast_in_condition(void) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - BOOL needsAnArray = [@"aString" isEqualToString:@"anotherString"]; + BOOL needsAnArray = [@"aString" isEqualToString:@"anotherString"]; // expected-warning {{Assignment of a non-Boolean value}} NSMutableArray* array = needsAnArray ? [[NSMutableArray alloc] init] : 0; if(needsAnArray) [array release]; Index: test/Analysis/malloc.c === --- test/Analysis/malloc.c +++ test/Analysis/malloc.c @@ -1656,13 +1656,13 @@ void testOffsetPassedToStrlen() { char * string = malloc(sizeof(char)*10); string += 1; - int length = strlen(string); // expected-warning {{Potential leak of memory pointed to by 'string'}} + size_t length = strlen(string); // expected-warning {{Potential leak of memory pointed to by 'string'}} } void testOffsetPassedToStrlenThenFree() { char * string = malloc(sizeof(char)*10); string += 1; - int length = strlen(string); + size_t length = strlen(string); free(string); // expected-warning {{Argument to free() is offset by 1 byte from the start of memory allocated by malloc()}} } @@ -1705,7 +1705,7 @@ } char *dupstrNoWarn(const char *s) { - const int len = strlen(s); + const size_t len = strlen(s); char *p = (char*) smallocNoWarn(len + 1); strcpy(p, s); // no-warning return p; @@ -1721,7 +1721,7 @@ } char *dupstrWarn(const char *s) { - const int len = strlen(s); + const size_t len = strlen(s); char *p = (char*) smallocWarn(len + 1); strcpy(p, s); // expected-warning{{String copy function overflows destination buffer}} return p; Index: test/Analysis/explain-svals.cpp === --- test/Analysis/explain-svals.cpp +++ test/Analysis/explain-svals.cpp @@ -41,11 +41,19 @@ void test_2(char *ptr, int ext) { clang_analyzer_explain((void *) "asdf"); // expected-warning-re^pointer to element of type 'char' with index 0 of string literal "asdf"$ +#ifdef ANALYZER_CM_Z3 + clang_analyzer_explain(strlen(ptr)); // expected-warning-re^cast of type 'int' of metadata of type 'unsigned long' tied to pointee of argument 'ptr'$ +#else clang_analyzer_explain(strlen(ptr)); // expected-warning-re^metadata of type 'unsigned long' tied to pointee of argument 'ptr'$ +#endif clang_analyzer_explain(conjure()); // expected-warning-re^symbol of type 'int' conjured at statement 'conjure\(\)'$ clang_analyzer_explain(glob); // expected-warning-re^value derived from \(symbol of type 'int' conjured at statement 'conjure\(\)'\) for global variable 'glob'$ clang_analyzer_explain(glob_ptr); // expected-warning-re^value derived from \(symbol of type 'int' conjured at statement 'conjure\(\)'\) for global variable 'glob_ptr'$ +#ifdef ANALYZER_CM_Z3 + clang_analyzer_explain(clang_analyzer_getExtent(ptr)); // expected-warning-re^cast of type 'int' of extent of pointee of argument 'ptr'$ +#else clang_analyzer_explain(clang_analyzer_getExtent(
[PATCH] D28955: [analyzer] Enable support for symbolic extension/truncation
ddcc added a comment. @dcoughlin No, all three patches are separate. I have been testing them with each applied incrementally onto the previous, with the order trunk, https://reviews.llvm.org/D35450, https://reviews.llvm.org/D28954, then https://reviews.llvm.org/D28955 (this). But since these are a lot of dependencies, I've refactored this patch to apply directly on top of https://reviews.llvm.org/D35450, though the floating-point specific changes will need to be merged into https://reviews.llvm.org/D28954. Also, I think https://reviews.llvm.org/D28954 is waiting for review. https://reviews.llvm.org/D28955 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28955: [analyzer] Enable support for symbolic extension/truncation
ddcc added a comment. @NoQ Does the proposal in https://reviews.llvm.org/D28955#652465 satisfy your concern? https://reviews.llvm.org/D28955 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37231: Add half load and store builtins
jvesely updated this revision to Diff 113624. jvesely added a comment. mark load pointers const Repository: rL LLVM https://reviews.llvm.org/D37231 Files: include/clang/Basic/Builtins.def include/clang/Basic/Builtins.h lib/Basic/Builtins.cpp lib/CodeGen/CGBuiltin.cpp test/CodeGenOpenCL/no-half.cl Index: test/CodeGenOpenCL/no-half.cl === --- /dev/null +++ test/CodeGenOpenCL/no-half.cl @@ -0,0 +1,39 @@ +// RUN: %clang_cc1 %s -cl-std=cl2.0 -emit-llvm -o - -triple spir-unknown-unknown | FileCheck %s +// RUN: %clang_cc1 %s -cl-std=cl1.2 -emit-llvm -o - -triple spir-unknown-unknown | FileCheck %s +// RUN: %clang_cc1 %s -cl-std=cl1.1 -emit-llvm -o - -triple spir-unknown-unknown | FileCheck %s + +#pragma OPENCL EXTENSION cl_khr_fp64:enable + +// CHECK-LABEL: @test_store_float(float %foo, half addrspace({{.}}){{.*}} %bar) +__kernel void test_store_float(float foo, __global half* bar) +{ + __builtin_store_halff(foo, bar); +// CHECK: [[HALF_VAL:%.*]] = fptrunc float %foo to half +// CHECK: store half [[HALF_VAL]], half addrspace({{.}})* %bar, align 2 +} + +// CHECK-LABEL: @test_store_double(double %foo, half addrspace({{.}}){{.*}} %bar) +__kernel void test_store_double(double foo, __global half* bar) +{ + __builtin_store_half(foo, bar); +// CHECK: [[HALF_VAL:%.*]] = fptrunc double %foo to half +// CHECK: store half [[HALF_VAL]], half addrspace({{.}})* %bar, align 2 +} + +// CHECK-LABEL: @test_load_float(float addrspace({{.}}){{.*}} %foo, half addrspace({{.}}){{.*}} %bar) +__kernel void test_load_float(__global float* foo, __global half* bar) +{ + foo[0] = __builtin_load_halff(bar); +// CHECK: [[HALF_VAL:%.*]] = load half, half addrspace({{.}})* %bar +// CHECK: [[FULL_VAL:%.*]] = fpext half [[HALF_VAL]] to float +// CHECK: store float [[FULL_VAL]], float addrspace({{.}})* %foo +} + +// CHECK-LABEL: @test_load_double(double addrspace({{.}}){{.*}} %foo, half addrspace({{.}}){{.*}} %bar) +__kernel void test_load_double(__global double* foo, __global half* bar) +{ + foo[0] = __builtin_load_half(bar); +// CHECK: [[HALF_VAL:%.*]] = load half, half addrspace({{.}})* %bar +// CHECK: [[FULL_VAL:%.*]] = fpext half [[HALF_VAL]] to double +// CHECK: store double [[FULL_VAL]], double addrspace({{.}})* %foo +} Index: lib/CodeGen/CGBuiltin.cpp === --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -2724,6 +2724,24 @@ Name), {NDRange, Block})); } + + case Builtin::BI__builtin_store_half: + case Builtin::BI__builtin_store_halff: { +Value *Val = EmitScalarExpr(E->getArg(0)); +Address Address = EmitPointerWithAlignment(E->getArg(1)); +Value *HalfVal = Builder.CreateFPTrunc(Val, Builder.getHalfTy()); +return RValue::get(Builder.CreateStore(HalfVal, Address)); + } + case Builtin::BI__builtin_load_half: { +Address Address = EmitPointerWithAlignment(E->getArg(0)); +Value *HalfVal = Builder.CreateLoad(Address); +return RValue::get(Builder.CreateFPExt(HalfVal, Builder.getDoubleTy())); + } + case Builtin::BI__builtin_load_halff: { +Address Address = EmitPointerWithAlignment(E->getArg(0)); +Value *HalfVal = Builder.CreateLoad(Address); +return RValue::get(Builder.CreateFPExt(HalfVal, Builder.getFloatTy())); + } case Builtin::BIprintf: if (getTarget().getTriple().isNVPTX()) return EmitNVPTXDevicePrintfCallExpr(E, ReturnValue); Index: lib/Basic/Builtins.cpp === --- lib/Basic/Builtins.cpp +++ lib/Basic/Builtins.cpp @@ -69,9 +69,14 @@ bool MSModeUnsupported = !LangOpts.MicrosoftExt && (BuiltinInfo.Langs & MS_LANG); bool ObjCUnsupported = !LangOpts.ObjC1 && BuiltinInfo.Langs == OBJC_LANG; - bool OclCUnsupported = LangOpts.OpenCLVersion != 200 && - BuiltinInfo.Langs == OCLC20_LANG; + bool OclC1Unsupported = (LangOpts.OpenCLVersion / 100) != 1 && + (BuiltinInfo.Langs & ALL_OCLC_LANGUAGES ) == OCLC1X_LANG; + bool OclC2Unsupported = LangOpts.OpenCLVersion != 200 && + (BuiltinInfo.Langs & ALL_OCLC_LANGUAGES) == OCLC20_LANG; + bool OclCUnsupported = !LangOpts.OpenCL && + (BuiltinInfo.Langs & ALL_OCLC_LANGUAGES); return !BuiltinsUnsupported && !MathBuiltinsUnsupported && !OclCUnsupported && + !OclC1Unsupported && !OclC2Unsupported && !GnuModeUnsupported && !MSModeUnsupported && !ObjCUnsupported; } Index: include/clang/Basic/Builtins.h === --- include/clang/Basic/Builtins.h +++ include/clang/Basic/Builtins.h @@ -36,10 +36,12 @@ CXX_LANG = 0x4, // builtin for cplusplus only. OBJC_LANG = 0x8,// builtin for objective-c and objective-c++ MS_LANG = 0x10, // builtin requires MS mode. - OCLC20_LANG = 0x20, // builtin for OpenCL C only. +
[PATCH] D37381: Fix regression in special member definitions under SuppressAllDiagnostics
rsmith requested changes to this revision. rsmith added a comment. This revision now requires changes to proceed. It's not reasonable for external users of Clang's AST to infer deep meaning from the "invalid" flag. It's simply a mechanism by which we (a) limit the amount of follow-on diagnostics, and (b) somewhat weaken our AST invariants in the presence of invalid code; it is an implementation detail and subject to change at any time. (If a node is not marked invalid, that does not imply the corresponding source code is valid.) If you would like a system to hook into the start and end of creating a function (so you can install your own error trap from an external user of Sema), that would seem like something we could reasonably support. https://reviews.llvm.org/D37381 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r312392 - Driver: extract `-fbuiltin` option handling (NFC)
Author: compnerd Date: Fri Sep 1 16:44:01 2017 New Revision: 312392 URL: http://llvm.org/viewvc/llvm-project?rev=312392&view=rev Log: Driver: extract `-fbuiltin` option handling (NFC) Extract the handling of the `-fbuiltin` family of flags to the driver. This centralises the handling of those options, keeping the long standing `#if 0`'ed block of code. This requires some additional code archaeology to determine if we need to enable this functionality. Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=312392&r1=312391&r2=312392&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Sep 1 16:44:01 2017 @@ -2350,6 +2350,56 @@ static void RenderARCMigrateToolOptions( } } +static void RenderBuiltinOptions(const ToolChain &TC, const llvm::Triple &T, + const ArgList &Args, ArgStringList &CmdArgs) { + // -fbuiltin is default unless -mkernel is used. + bool UseBuiltins = + Args.hasFlag(options::OPT_fbuiltin, options::OPT_fno_builtin, + !Args.hasArg(options::OPT_mkernel)); + if (!UseBuiltins) +CmdArgs.push_back("-fno-builtin"); + + // -ffreestanding implies -fno-builtin. + if (Args.hasArg(options::OPT_ffreestanding)) +UseBuiltins = false; + + // Process the -fno-builtin-* options. + for (const auto &Arg : Args) { +const Option &O = Arg->getOption(); +if (!O.matches(options::OPT_fno_builtin_)) + continue; + +Arg->claim(); + +// If -fno-builtin is specified, then there's no need to pass the option to +// the frontend. +if (!UseBuiltins) + continue; + +StringRef FuncName = Arg->getValue(); +CmdArgs.push_back(Args.MakeArgString("-fno-builtin-" + FuncName)); + } + + // le32-specific flags: + // -fno-math-builtin: clang should not convert math builtins to intrinsics + // by default. + if (TC.getArch() == llvm::Triple::le32) +CmdArgs.push_back("-fno-math-builtin"); + +#if 0 + // Default to -fno-builtin-str{cat,cpy} on Darwin for ARM. + // + // FIXME: Now that PR4941 has been fixed this can be enabled. + if (T.isOSDarwin() && (TC.getArch() == llvm::Triple::arm || + TC.getArch() == llvm::Triple::thumb)) { +if (!Args.hasArg(options::OPT_fbuiltin_strcat)) + CmdArgs.push_back("-fno-builtin-strcat"); +if (!Args.hasArg(options::OPT_fbuiltin_strcpy)) + CmdArgs.push_back("-fno-builtin-strcpy"); + } +#endif +} + static void RenderModulesOptions(Compilation &C, const Driver &D, const ArgList &Args, const InputInfo &Input, const InputInfo &Output, @@ -3893,32 +3943,7 @@ void Clang::ConstructJob(Compilation &C, options::OPT_fno_debug_info_for_profiling, false)) CmdArgs.push_back("-fdebug-info-for-profiling"); - // -fbuiltin is default unless -mkernel is used. - bool UseBuiltins = - Args.hasFlag(options::OPT_fbuiltin, options::OPT_fno_builtin, - !Args.hasArg(options::OPT_mkernel)); - if (!UseBuiltins) -CmdArgs.push_back("-fno-builtin"); - - // -ffreestanding implies -fno-builtin. - if (Args.hasArg(options::OPT_ffreestanding)) -UseBuiltins = false; - - // Process the -fno-builtin-* options. - for (const auto &Arg : Args) { -const Option &O = Arg->getOption(); -if (!O.matches(options::OPT_fno_builtin_)) - continue; - -Arg->claim(); -// If -fno-builtin is specified, then there's no need to pass the option to -// the frontend. -if (!UseBuiltins) - continue; - -StringRef FuncName = Arg->getValue(); -CmdArgs.push_back(Args.MakeArgString("-fno-builtin-" + FuncName)); - } + RenderBuiltinOptions(getToolChain(), RawTriple, Args, CmdArgs); if (!Args.hasFlag(options::OPT_fassume_sane_operator_new, options::OPT_fno_assume_sane_operator_new)) @@ -4281,13 +4306,6 @@ void Clang::ConstructJob(Compilation &C, options::OPT_fno_apple_pragma_pack, false)) CmdArgs.push_back("-fapple-pragma-pack"); - // le32-specific flags: - // -fno-math-builtin: clang should not convert math builtins to intrinsics - // by default. - if (getToolChain().getArch() == llvm::Triple::le32) { -CmdArgs.push_back("-fno-math-builtin"); - } - if (Args.hasFlag(options::OPT_fsave_optimization_record, options::OPT_fno_save_optimization_record, false)) { CmdArgs.push_back("-opt-record-file"); @@ -4325,20 +4343,6 @@ void Clang::ConstructJob(Compilation &C, } } -// Default to -fno-builtin-str{cat,cpy} on Darwin for ARM. -// -// FIXME: Now that PR4941 has been fixed this can be enabled. -#if 0 - if (RawTriple.isOSDarw
[PATCH] D37386: [AMDGPU] Implement infrastructure to set options in AMDGPUToolChain
yaxunl added a comment. Is it possible to add a test for this? Thanks. https://reviews.llvm.org/D37386 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] r312402 - Add halfN types and enable fp16 when generating builtin declarations
Author: awatry Date: Fri Sep 1 19:23:16 2017 New Revision: 312402 URL: http://llvm.org/viewvc/llvm-project?rev=312402&view=rev Log: Add halfN types and enable fp16 when generating builtin declarations Uses the same mechanism to enable fp16 as we use for fp64 when processing clc.h Signed-off-by: Aaron Watry Reviewed-by: Jan Vesely Modified: libclc/trunk/generic/include/clc/clc.h libclc/trunk/generic/include/clc/clctypes.h Modified: libclc/trunk/generic/include/clc/clc.h URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=312402&r1=312401&r2=312402&view=diff == --- libclc/trunk/generic/include/clc/clc.h (original) +++ libclc/trunk/generic/include/clc/clc.h Fri Sep 1 19:23:16 2017 @@ -8,6 +8,10 @@ #pragma OPENCL EXTENSION cl_khr_fp64 : enable #endif +#ifdef cl_khr_fp16 +#pragma OPENCL EXTENSION cl_khr_fp16 : enable +#endif + /* Function Attributes */ #include Modified: libclc/trunk/generic/include/clc/clctypes.h URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clctypes.h?rev=312402&r1=312401&r2=312402&view=diff == --- libclc/trunk/generic/include/clc/clctypes.h (original) +++ libclc/trunk/generic/include/clc/clctypes.h Fri Sep 1 19:23:16 2017 @@ -85,3 +85,11 @@ typedef __attribute__((ext_vector_type(4 typedef __attribute__((ext_vector_type(8))) double double8; typedef __attribute__((ext_vector_type(16))) double double16; #endif + +#ifdef cl_khr_fp16 +typedef __attribute__((ext_vector_type(2))) half half2; +typedef __attribute__((ext_vector_type(3))) half half3; +typedef __attribute__((ext_vector_type(4))) half half4; +typedef __attribute__((ext_vector_type(8))) half half8; +typedef __attribute__((ext_vector_type(16))) half half16; +#endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] r312403 - relational: Implement shuffle builtin
Author: awatry Date: Fri Sep 1 19:23:26 2017 New Revision: 312403 URL: http://llvm.org/viewvc/llvm-project?rev=312403&view=rev Log: relational: Implement shuffle builtin This was added in CL 1.1 Tested with a Radeon HD 7850 (Pitcairn) using the CL CTS via: test_conformance/relationals/test_relationals shuffle_built_in v2: Add half-precision support to shuffle when available. Move to misc/ and add section 6.12.12 to clc.h Signed-off-by: Aaron Watry Reviewed-by: Jan Vesely Added: libclc/trunk/generic/include/clc/misc/ libclc/trunk/generic/include/clc/misc/shuffle.h libclc/trunk/generic/lib/misc/ libclc/trunk/generic/lib/misc/shuffle.cl Modified: libclc/trunk/generic/include/clc/clc.h libclc/trunk/generic/lib/SOURCES Modified: libclc/trunk/generic/include/clc/clc.h URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=312403&r1=312402&r2=312403&view=diff == --- libclc/trunk/generic/include/clc/clc.h (original) +++ libclc/trunk/generic/include/clc/clc.h Fri Sep 1 19:23:26 2017 @@ -237,6 +237,9 @@ /* 6.11.13 Image Read and Write Functions */ +/* 6.12.12 Miscellaneous Vector Functions */ +#include + #include #include Added: libclc/trunk/generic/include/clc/misc/shuffle.h URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/misc/shuffle.h?rev=312403&view=auto == --- libclc/trunk/generic/include/clc/misc/shuffle.h (added) +++ libclc/trunk/generic/include/clc/misc/shuffle.h Fri Sep 1 19:23:26 2017 @@ -0,0 +1,47 @@ +//===-- generic/include/clc/misc/shuffle.h --===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under both the University of Illinois Open Source +// License and the MIT license. See LICENSE.TXT for details. +// +//===--===// + +#define _CLC_SHUFFLE_DECL(TYPE, MASKTYPE, RETTYPE) \ + _CLC_OVERLOAD _CLC_DECL RETTYPE shuffle(TYPE x, MASKTYPE mask); + +//Return type is same base type as the input type, with the same vector size as the mask. +//Elements in the mask must be the same size (number of bits) as the input value. +//E.g. char8 ret = shuffle(char2 x, uchar8 mask); + +#define _CLC_VECTOR_SHUFFLE_MASKSIZE(INBASE, INTYPE, MASKTYPE) \ + _CLC_SHUFFLE_DECL(INTYPE, MASKTYPE##2, INBASE##2) \ + _CLC_SHUFFLE_DECL(INTYPE, MASKTYPE##4, INBASE##4) \ + _CLC_SHUFFLE_DECL(INTYPE, MASKTYPE##8, INBASE##8) \ + _CLC_SHUFFLE_DECL(INTYPE, MASKTYPE##16, INBASE##16) \ + +#define _CLC_VECTOR_SHUFFLE_INSIZE(TYPE, MASKTYPE) \ + _CLC_VECTOR_SHUFFLE_MASKSIZE(TYPE, TYPE##2, MASKTYPE) \ + _CLC_VECTOR_SHUFFLE_MASKSIZE(TYPE, TYPE##4, MASKTYPE) \ + _CLC_VECTOR_SHUFFLE_MASKSIZE(TYPE, TYPE##8, MASKTYPE) \ + _CLC_VECTOR_SHUFFLE_MASKSIZE(TYPE, TYPE##16, MASKTYPE) \ + +_CLC_VECTOR_SHUFFLE_INSIZE(char, uchar) +_CLC_VECTOR_SHUFFLE_INSIZE(short, ushort) +_CLC_VECTOR_SHUFFLE_INSIZE(int, uint) +_CLC_VECTOR_SHUFFLE_INSIZE(long, ulong) +_CLC_VECTOR_SHUFFLE_INSIZE(uchar, uchar) +_CLC_VECTOR_SHUFFLE_INSIZE(ushort, ushort) +_CLC_VECTOR_SHUFFLE_INSIZE(uint, uint) +_CLC_VECTOR_SHUFFLE_INSIZE(ulong, ulong) +_CLC_VECTOR_SHUFFLE_INSIZE(float, uint) +#ifdef cl_khr_fp64 +_CLC_VECTOR_SHUFFLE_INSIZE(double, ulong) +#endif +#ifdef cl_khr_fp16 +_CLC_VECTOR_SHUFFLE_INSIZE(half, ushort) +#endif + +#undef _CLC_SHUFFLE_DECL +#undef _CLC_VECTOR_SHUFFLE_MASKSIZE +#undef _CLC_VECTOR_SHUFFLE_INSIZE Modified: libclc/trunk/generic/lib/SOURCES URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=312403&r1=312402&r2=312403&view=diff == --- libclc/trunk/generic/lib/SOURCES (original) +++ libclc/trunk/generic/lib/SOURCES Fri Sep 1 19:23:26 2017 @@ -123,6 +123,7 @@ math/sqrt.cl math/tan.cl math/tanh.cl math/tgamma.cl +misc/shuffle.cl relational/all.cl relational/any.cl relational/bitselect.cl @@ -139,6 +140,7 @@ relational/isnormal.cl relational/isnotequal.cl relational/isordered.cl relational/isunordered.cl +relational/shuffle2.cl relational/signbit.cl shared/clamp.cl shared/max.cl Added: libclc/trunk/generic/lib/misc/shuffle.cl URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/misc/shuffle.cl?rev=312403&view=auto == --- libclc/trunk/generic/lib/misc/shuffle.cl (added) +++ libclc/trunk/generic/lib/misc/shuffle.cl Fri Sep 1 19:23:26 2017 @@ -0,0 +1,157 @@ +//===-- generic/lib/misc/shuffle.cl --===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under both the University of Illinois Open Source +// License and the MIT license. See LICENSE.TXT for details. +// +//===--
[libclc] r312404 - relational: Implement shuffle2 builtin
Author: awatry Date: Fri Sep 1 19:23:28 2017 New Revision: 312404 URL: http://llvm.org/viewvc/llvm-project?rev=312404&view=rev Log: relational: Implement shuffle2 builtin This was added in CL 1.1 Tested with a Radeon HD 7850 (Pitcairn) using the CL CTS via: test_conformance/relationals/test_relationals shuffle_built_in_dual_input v2: Add half support to shuffle2 Move shuffle2 to misc/ Signed-off-by: Aaron Watry Reviewed-by: Jan Vesely Added: libclc/trunk/generic/include/clc/misc/shuffle2.h libclc/trunk/generic/lib/misc/shuffle2.cl Modified: libclc/trunk/generic/include/clc/clc.h libclc/trunk/generic/lib/SOURCES Modified: libclc/trunk/generic/include/clc/clc.h URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=312404&r1=312403&r2=312404&view=diff == --- libclc/trunk/generic/include/clc/clc.h (original) +++ libclc/trunk/generic/include/clc/clc.h Fri Sep 1 19:23:28 2017 @@ -239,6 +239,7 @@ /* 6.12.12 Miscellaneous Vector Functions */ #include +#include #include #include Added: libclc/trunk/generic/include/clc/misc/shuffle2.h URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/misc/shuffle2.h?rev=312404&view=auto == --- libclc/trunk/generic/include/clc/misc/shuffle2.h (added) +++ libclc/trunk/generic/include/clc/misc/shuffle2.h Fri Sep 1 19:23:28 2017 @@ -0,0 +1,47 @@ +//===-- generic/include/clc/misc/shuffle2.h --===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under both the University of Illinois Open Source +// License and the MIT license. See LICENSE.TXT for details. +// +//===--===// + +#define _CLC_SHUFFLE2_DECL(TYPE, MASKTYPE, RETTYPE) \ + _CLC_OVERLOAD _CLC_DECL RETTYPE shuffle2(TYPE x, TYPE y, MASKTYPE mask); + +//Return type is same base type as the input type, with the same vector size as the mask. +//Elements in the mask must be the same size (number of bits) as the input value. +//E.g. char8 ret = shuffle2(char2 x, char2 y, uchar8 mask); + +#define _CLC_VECTOR_SHUFFLE2_MASKSIZE(INBASE, INTYPE, MASKTYPE) \ + _CLC_SHUFFLE2_DECL(INTYPE, MASKTYPE##2, INBASE##2) \ + _CLC_SHUFFLE2_DECL(INTYPE, MASKTYPE##4, INBASE##4) \ + _CLC_SHUFFLE2_DECL(INTYPE, MASKTYPE##8, INBASE##8) \ + _CLC_SHUFFLE2_DECL(INTYPE, MASKTYPE##16, INBASE##16) \ + +#define _CLC_VECTOR_SHUFFLE2_INSIZE(TYPE, MASKTYPE) \ + _CLC_VECTOR_SHUFFLE2_MASKSIZE(TYPE, TYPE##2, MASKTYPE) \ + _CLC_VECTOR_SHUFFLE2_MASKSIZE(TYPE, TYPE##4, MASKTYPE) \ + _CLC_VECTOR_SHUFFLE2_MASKSIZE(TYPE, TYPE##8, MASKTYPE) \ + _CLC_VECTOR_SHUFFLE2_MASKSIZE(TYPE, TYPE##16, MASKTYPE) \ + +_CLC_VECTOR_SHUFFLE2_INSIZE(char, uchar) +_CLC_VECTOR_SHUFFLE2_INSIZE(short, ushort) +_CLC_VECTOR_SHUFFLE2_INSIZE(int, uint) +_CLC_VECTOR_SHUFFLE2_INSIZE(long, ulong) +_CLC_VECTOR_SHUFFLE2_INSIZE(uchar, uchar) +_CLC_VECTOR_SHUFFLE2_INSIZE(ushort, ushort) +_CLC_VECTOR_SHUFFLE2_INSIZE(uint, uint) +_CLC_VECTOR_SHUFFLE2_INSIZE(ulong, ulong) +_CLC_VECTOR_SHUFFLE2_INSIZE(float, uint) +#ifdef cl_khr_fp64 +_CLC_VECTOR_SHUFFLE2_INSIZE(double, ulong) +#endif +#ifdef cl_khr_fp16 +_CLC_VECTOR_SHUFFLE2_INSIZE(half, ushort) +#endif + +#undef _CLC_SHUFFLE_DECL +#undef _CLC_VECTOR_SHUFFLE2_MASKSIZE +#undef _CLC_VECTOR_SHUFFLE2_INSIZE Modified: libclc/trunk/generic/lib/SOURCES URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=312404&r1=312403&r2=312404&view=diff == --- libclc/trunk/generic/lib/SOURCES (original) +++ libclc/trunk/generic/lib/SOURCES Fri Sep 1 19:23:28 2017 @@ -124,6 +124,7 @@ math/tan.cl math/tanh.cl math/tgamma.cl misc/shuffle.cl +misc/shuffle2.cl relational/all.cl relational/any.cl relational/bitselect.cl @@ -140,7 +141,6 @@ relational/isnormal.cl relational/isnotequal.cl relational/isordered.cl relational/isunordered.cl -relational/shuffle2.cl relational/signbit.cl shared/clamp.cl shared/max.cl Added: libclc/trunk/generic/lib/misc/shuffle2.cl URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/misc/shuffle2.cl?rev=312404&view=auto == --- libclc/trunk/generic/lib/misc/shuffle2.cl (added) +++ libclc/trunk/generic/lib/misc/shuffle2.cl Fri Sep 1 19:23:28 2017 @@ -0,0 +1,160 @@ +//===-- generic/lib/misc/shuffle2.cl --===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under both the University of Illinois Open Source +// License and the MIT license. See LICENSE.TXT for details. +// +//===--===// + +#include + +#define _CLC_ELEMENT_
r312407 - Don't search libxml2 if using msan. LLVM already has similar check.
Author: vitalybuka Date: Fri Sep 1 20:53:42 2017 New Revision: 312407 URL: http://llvm.org/viewvc/llvm-project?rev=312407&view=rev Log: Don't search libxml2 if using msan. LLVM already has similar check. Modified: cfe/trunk/CMakeLists.txt Modified: cfe/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=312407&r1=312406&r2=312407&view=diff == --- cfe/trunk/CMakeLists.txt (original) +++ cfe/trunk/CMakeLists.txt Fri Sep 1 20:53:42 2017 @@ -181,10 +181,14 @@ endif() # we can include cmake files from this directory. list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") -set (LIBXML2_FOUND 0) -find_package(LibXml2 2.5.3 QUIET) -if (LIBXML2_FOUND) - set(CLANG_HAVE_LIBXML 1) +# Don't look for libxml if we're using MSan, since uninstrumented third party +# code may call MSan interceptors like strlen, leading to false positives. +if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*") + set (LIBXML2_FOUND 0) + find_package(LibXml2 2.5.3 QUIET) + if (LIBXML2_FOUND) +set(CLANG_HAVE_LIBXML 1) + endif() endif() include(CheckIncludeFile) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37413: [X86][MS-InlineAsm] Extended support for variables / identifiers on memory / immediate expressions
coby created this revision. Allow the proper recognition of Enum values and global variables inside ms inline-asm memory / immediate expressions, as they require some additional overhead and treated incorrect if doesn't early recognized. supersedes https://reviews.llvm.org/D33277, https://reviews.llvm.org/D35774 Repository: rL LLVM https://reviews.llvm.org/D37413 Files: include/clang/Parse/Parser.h include/clang/Sema/Sema.h lib/Parse/ParseStmtAsm.cpp lib/Sema/SemaStmtAsm.cpp Index: lib/Parse/ParseStmtAsm.cpp === --- lib/Parse/ParseStmtAsm.cpp +++ lib/Parse/ParseStmtAsm.cpp @@ -54,17 +54,17 @@ assert(AsmToks.size() == AsmTokOffsets.size()); } - void *LookupInlineAsmIdentifier(StringRef &LineBuf, - llvm::InlineAsmIdentifierInfo &Info, - bool IsUnevaluatedContext) override { + void LookupInlineAsmIdentifier(StringRef &LineBuf, + llvm::InlineAsmIdentifierInfo &Info, + bool IsUnevaluatedContext) override { // Collect the desired tokens. SmallVector LineToks; const Token *FirstOrigToken = nullptr; findTokensForString(LineBuf, LineToks, FirstOrigToken); unsigned NumConsumedToks; ExprResult Result = TheParser.ParseMSAsmIdentifier( -LineToks, NumConsumedToks, &Info, IsUnevaluatedContext); +LineToks, NumConsumedToks, IsUnevaluatedContext); // If we consumed the entire line, tell MC that. // Also do this if we consumed nothing as a way of reporting failure. @@ -89,9 +89,10 @@ LineBuf = LineBuf.substr(0, TotalOffset); } -// Initialize the "decl" with the lookup result. -Info.OpDecl = static_cast(Result.get()); -return Info.OpDecl; +// Initialize Info with the lookup result. +if (!Result.isUsable()) + return; +TheParser.getActions().FillInlineAsmIdentifierInfo(Result.get(), Info); } StringRef LookupInlineAsmLabel(StringRef Identifier, llvm::SourceMgr &LSM, @@ -183,11 +184,7 @@ /// about the actual type. ExprResult Parser::ParseMSAsmIdentifier(llvm::SmallVectorImpl &LineToks, unsigned &NumLineToksConsumed, -void *CastInfo, bool IsUnevaluatedContext) { - llvm::InlineAsmIdentifierInfo &Info = - *(llvm::InlineAsmIdentifierInfo *)CastInfo; - // Push a fake token on the end so that we don't overrun the token // stream. We use ';' because it expression-parsing should never // overrun it. @@ -227,7 +224,7 @@ /*AllowDeductionGuide=*/false, /*ObjectType=*/nullptr, TemplateKWLoc, Id); // Perform the lookup. -Result = Actions.LookupInlineAsmIdentifier(SS, TemplateKWLoc, Id, Info, +Result = Actions.LookupInlineAsmIdentifier(SS, TemplateKWLoc, Id, IsUnevaluatedContext); } // While the next two tokens are 'period' 'identifier', repeatedly parse it as @@ -241,7 +238,7 @@ IdentifierInfo *Id = Tok.getIdentifierInfo(); ConsumeToken(); // Consume the identifier. Result = Actions.LookupInlineAsmVarDeclField(Result.get(), Id->getName(), - Info, Tok.getLocation()); + Tok.getLocation()); } // Figure out how many tokens we are into LineToks. Index: lib/Sema/SemaStmtAsm.cpp === --- lib/Sema/SemaStmtAsm.cpp +++ lib/Sema/SemaStmtAsm.cpp @@ -48,10 +48,10 @@ if (E != E2 && E2->isLValue()) { if (!S.getLangOpts().HeinousExtensions) S.Diag(E2->getLocStart(), diag::err_invalid_asm_cast_lvalue) -<< E->getSourceRange(); + << E->getSourceRange(); else S.Diag(E2->getLocStart(), diag::warn_invalid_asm_cast_lvalue) -<< E->getSourceRange(); + << E->getSourceRange(); // Accept, even if we emitted an error diagnostic. return false; } @@ -62,11 +62,13 @@ /// isOperandMentioned - Return true if the specified operand # is mentioned /// anywhere in the decomposed asm string. -static bool isOperandMentioned(unsigned OpNo, - ArrayRef AsmStrPieces) { +static bool +isOperandMentioned(unsigned OpNo, + ArrayRef AsmStrPieces) { for (unsigned p = 0, e = AsmStrPieces.size(); p != e; ++p) { const GCCAsmStmt::AsmStringPiece &Piece = AsmStrPieces[p]; -if (!Piece.isOperand()) continue; +if (!Piece.isOperand()) + continue; // If this is a reference to the input and if the input was the smaller // one, then we have to reject this asm. @@ -605,23 +607,32 @@ return NS; } -static void fillInlineAsmTypeInfo(const ASTContext &Context, QualType T, -