Re: [PATCH] D16087: Add some overview doxygen comments to lib/Format.
djasper added inline comments. Comment at: lib/Format/ContinuationIndenter.h:35 @@ -34,1 +34,3 @@ +/// \brief Helper class for breaking a logical line into multiple physical +/// lines. Manages moving state from one physical line to the next. You are the first to introduce the term "pyhsical" line and I don't actually think it is the right term. Also, this is not a "helper class". Maybe: If an unwrapped line needs to be split over multiple lines to fit into the column limit, this class can be used to keep track of the indentation for the different levels of parentheses and to get the desired indentation for any given line break. Comment at: lib/Format/Format.cpp:761 @@ -760,2 +760,3 @@ +/// \brief Responsible for splitting up a file into \c FormatTokens. class FormatTokenLexer { /// \brief Splits a file into FormatTokens. Also, this comment adds zero information. Comment at: lib/Format/Format.cpp:1426 @@ +1425,3 @@ +/// -# A \c FormatTokenLexer splits the file into raw tokens +/// -# A \c UnwrappedLineParser converts those into logical lines +/// -# A \c TokenAnnotator computes metadata for the tokens in each line If we wanted to call them logical lines, we would have. Stick to the term unwrapped line. Comment at: lib/Format/Format.cpp:1429 @@ -1420,1 +1428,3 @@ +/// -# A \c UnwrappedLineFormatter then produces whitespace adjustments +///which result in the desired logical lines class Formatter : public UnwrappedLineConsumer { Same here, although I think you don't even mean logical lines. Comment at: lib/Format/FormatToken.h:110-111 @@ -109,4 +109,4 @@ -/// \brief A wrapper around a \c Token storing information about the -/// whitespace characters preceding it. +/// \brief A wrapper around a \c Token storing additional information useful +/// for formatting. struct FormatToken { What information does this comment add? I am not against adding one, but then describe in a bit more detail what is going on. Comment at: lib/Format/TokenAnnotator.h:39 @@ -38,2 +38,3 @@ +/// \brief Stores additional information for an \c UnwrappedLine. class AnnotatedLine { What's the added info? Comment at: lib/Format/TokenAnnotator.h:152 @@ -150,2 +151,3 @@ + /// \brief Compute metadata of \c AnnotatedLine itself, like \c LineType. void annotate(AnnotatedLine &Line); s/like/such as/ Also, I think that the comment is misleading. The LineType is the least important thing that this function does. It annotates all the tokens, for that parses all the expressions in it, assigned TokenTypes to the format tokens, and also annotates all Children of this line. Comment at: lib/Format/TokenAnnotator.h:155-156 @@ -152,1 +154,4 @@ + + /// \brief For all the tokens in \c Line, compute if a line break is + /// needed for that token, and similar information. void calculateFormattingInformation(AnnotatedLine &Line); For all tokens in \c Line, use the additional information gathered during annotation to calculate formatting hints such as required line breaks, spaces and split penalties. Comment at: lib/Format/UnwrappedLineFormatter.h:31 @@ -30,1 +30,3 @@ +/// \brief Responsible for taking a list of logical lines, and for producing +/// a set of whitespace adjustments to turn them into physical lines so Go through all of your comments and s/logical/unwrapped/ Comment at: lib/Format/UnwrappedLineFormatter.h:32 @@ +31,3 @@ +/// \brief Responsible for taking a list of logical lines, and for producing +/// a set of whitespace adjustments to turn them into physical lines so +/// that each physical line is below a column limit. And the same with s/physical//. If that removes all the information, rephrase. E.g. here: Takes a list of unwrapped lines and produces whitespace adjustments to lay them out within the column limit. Comment at: lib/Format/UnwrappedLineParser.h:61-62 @@ -60,2 +60,4 @@ +/// \brief Takes a sequence of tokens, and splits it into chunks of tokens +/// that would be a single line each if there was no column limit. class UnwrappedLineParser { This might be a good place to introduce the term unwrapped line. The most notable fact about unwrapped lines btw. is not that you would put them on a single line if there was no column limit. This is a nice thought model and we should also write it, but it isn't always true. More importantly, formatting decisions in one unwrapped line do not influence formatting decisions in a different unwrapped line. http://reviews.llvm.org/D16087 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin
Re: [PATCH] D15862: A possible direction for fixing https://llvm.org/bugs/show_bug.cgi?id=25973.
mclow.lists marked 3 inline comments as done. mclow.lists added a comment. http://reviews.llvm.org/D15862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15862: A possible direction for fixing https://llvm.org/bugs/show_bug.cgi?id=25973.
mclow.lists updated this revision to Diff 44703. mclow.lists added a comment. Last change, I hope. I added some more tests to make sure that string was correctly identifying throwing vs. non-throwing iterators, and I discovered that I had an `#ifdef` backwards. Fixing that revealed a bug in `__libcpp_string_gets_noexcept_iterator_impl`, in that it would cause a compile error if you give it an output iterator. Addressed Richard's comment about things that derive from `std::input_iterator_tag`, (since Boost does this), even though section 24.4.3/1 seems to say that you must use one of the predefined iterator category tags. http://reviews.llvm.org/D15862 Files: include/algorithm include/iterator include/string test/libcxx/iterators/trivial_iterators.pass.cpp test/libcxx/strings/iterators.noexcept.pass.cpp test/std/strings/basic.string/string.modifiers/string_append/initializer_list.pass.cpp test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp test/std/strings/basic.string/string.modifiers/string_append/pointer.pass.cpp test/std/strings/basic.string/string.modifiers/string_append/pointer_size.pass.cpp test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp test/std/strings/basic.string/string.modifiers/string_append/size_char.pass.cpp test/std/strings/basic.string/string.modifiers/string_append/string.pass.cpp test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp test/std/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp test/std/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp test/std/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp test/std/strings/basic.string/string.modifiers/string_assign/rv_string.pass.cpp test/std/strings/basic.string/string.modifiers/string_assign/size_char.pass.cpp test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp test/std/strings/basic.string/string.modifiers/string_insert/iter_char.pass.cpp test/std/strings/basic.string/string.modifiers/string_insert/iter_initializer_list.pass.cpp test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp test/std/strings/basic.string/string.modifiers/string_insert/iter_size_char.pass.cpp test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_initializer_list.pass.cpp test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer_size.pass.cpp test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp test/support/test_iterators.h Index: test/support/test_iterators.h === --- test/support/test_iterators.h +++ test/support/test_iterators.h @@ -11,8 +11,11 @@ #define ITERATORS_H #include +#include #include +#include "test_macros.h" + #ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS #define DELETE_FUNCTION = delete #else @@ -324,6 +327,202 @@ template // everything else inline Iter base(Iter i) { return i; } +template +struct ThrowingIterator { +typedef std::bidirectional_iterator_tag iterator_category; +typedef ptrdiff_t difference_type; +typedef const T value_type; +typedef const T * pointer; +typedef const T & reference; + + enum ThrowingAction { TAIncrement, TADecrement, TADereference, TAAssignment, TAComparison }; + +// Constructors + ThrowingIterator () + : begin_(null
Re: [PATCH] D16113: [clang-tdiy] Add header file extension configuration support.
hokein added inline comments. Comment at: clang-tidy/ClangTidyOptions.h:216 @@ +215,3 @@ +/// HeaderFileExtensions. +bool endWithHeaderFileExtensions(llvm::StringRef FileName, + llvm::StringRef HeaderFileExtensions); aaron.ballman wrote: > endsWithHeaderFileExtension instead? However, given that uses of this all > start with a SourceLocation, I wonder if that makes for a cleaner API: > isLocInHeaderFile(SourceLocation, ); > > Also, how does this work if I want to include an extension-less file as the > header file "extension?" It would be plausible if the extensions were passed > in as a list, but as it stands it doesn't seem possible without weird > conventions like leaving a blank in the list (e.g., `.h,,.hpp`), which seems > error-prone. > > Also, I'm not certain what I can pass in. The documentation should be updated > to state whether these extensions are intended to include the ".". > endsWithHeaderFileExtension instead? However, given that uses of this all > start with a SourceLocation, I wonder if that makes for a cleaner API: > isLocInHeaderFile(SourceLocation, ); Using `SourceLocation` only is not enough to retrieve the belonging file name (we need `SourceManager` too). >Also, how does this work if I want to include an extension-less file as the >header file "extension?" It would be plausible if the extensions were passed >in as a list, but as it stands it doesn't seem possible without weird >conventions like leaving a blank in the list (e.g., .h,,.hpp), which seems >error-prone. Yeah, for extensions-less header file, you can pass the string like `.h,,.hpp`, which is a bit of weird. Do you have a better idea here? Passing a string into `header-file-extensions` seems the most reasonable choice. Repository: rL LLVM http://reviews.llvm.org/D16113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r257562 - Install scan-build and scan-view only if Static Analyzer was enabled.
Author: eugenezelenko Date: Tue Jan 12 20:03:50 2016 New Revision: 257562 URL: http://llvm.org/viewvc/llvm-project?rev=257562&view=rev Log: Install scan-build and scan-view only if Static Analyzer was enabled. Modified: cfe/trunk/tools/CMakeLists.txt Modified: cfe/trunk/tools/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/CMakeLists.txt?rev=257562&r1=257561&r2=257562&view=diff == --- cfe/trunk/tools/CMakeLists.txt (original) +++ cfe/trunk/tools/CMakeLists.txt Tue Jan 12 20:03:50 2016 @@ -5,8 +5,6 @@ add_clang_subdirectory(driver) add_clang_subdirectory(clang-format) add_clang_subdirectory(clang-format-vs) add_clang_subdirectory(clang-fuzzer) -add_clang_subdirectory(scan-build) -add_clang_subdirectory(scan-view) add_clang_subdirectory(c-index-test) add_clang_subdirectory(libclang) @@ -18,6 +16,8 @@ endif() if(CLANG_ENABLE_STATIC_ANALYZER) add_clang_subdirectory(clang-check) + add_clang_subdirectory(scan-build) + add_clang_subdirectory(scan-view) endif() # We support checking out the clang-tools-extra repository into the 'extra' ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D14877: Fix ICE on lowering of constexpr vector splats
This revision was automatically updated to reflect the committed changes. Closed by commit rL257559: [Bugfix] Fix ICE on constexpr vector splat. (authored by gbiv). Changed prior to commit: http://reviews.llvm.org/D14877?vs=44187&id=44701#toc Repository: rL LLVM http://reviews.llvm.org/D14877 Files: cfe/trunk/include/clang/AST/ASTContext.h cfe/trunk/include/clang/AST/OperationKinds.h cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/AST/Expr.cpp cfe/trunk/lib/AST/ExprConstant.cpp cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CGExprAgg.cpp cfe/trunk/lib/CodeGen/CGExprComplex.cpp cfe/trunk/lib/CodeGen/CGExprConstant.cpp cfe/trunk/lib/CodeGen/CGExprScalar.cpp cfe/trunk/lib/Edit/RewriteObjCFoundationAPI.cpp cfe/trunk/lib/Sema/SemaCast.cpp cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaExprCXX.cpp cfe/trunk/lib/Sema/SemaOverload.cpp cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp cfe/trunk/test/CodeGenCXX/builtins-systemz-zvector.cpp cfe/trunk/test/CodeGenCXX/vector-splat-conversion.cpp cfe/trunk/test/CodeGenOpenCL/bool_cast.cl Index: cfe/trunk/include/clang/AST/ASTContext.h === --- cfe/trunk/include/clang/AST/ASTContext.h +++ cfe/trunk/include/clang/AST/ASTContext.h @@ -2283,9 +2283,13 @@ /// \brief Make an APSInt of the appropriate width and signedness for the /// given \p Value and integer \p Type. llvm::APSInt MakeIntValue(uint64_t Value, QualType Type) const { -llvm::APSInt Res(getIntWidth(Type), - !Type->isSignedIntegerOrEnumerationType()); +// If Type is a signed integer type larger than 64 bits, we need to be sure +// to sign extend Res appropriately. +llvm::APSInt Res(64, !Type->isSignedIntegerOrEnumerationType()); Res = Value; +unsigned Width = getIntWidth(Type); +if (Width != Res.getBitWidth()) + return Res.extOrTrunc(Width); return Res; } Index: cfe/trunk/include/clang/AST/OperationKinds.h === --- cfe/trunk/include/clang/AST/OperationKinds.h +++ cfe/trunk/include/clang/AST/OperationKinds.h @@ -185,7 +185,11 @@ /// CK_FloatingToBoolean - Floating point to boolean. ///(bool) f CK_FloatingToBoolean, - + + // CK_BooleanToSignedIntegral - Convert a boolean to -1 or 0 for true and + // false, respectively. + CK_BooleanToSignedIntegral, + /// CK_FloatingCast - Casting between floating types of different size. ///(double) f ///(float) ld Index: cfe/trunk/include/clang/Sema/Sema.h === --- cfe/trunk/include/clang/Sema/Sema.h +++ cfe/trunk/include/clang/Sema/Sema.h @@ -8589,6 +8589,10 @@ bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty, CastKind &Kind); + /// \brief Prepare `SplattedExpr` for a vector splat operation, adding + /// implicit casts if necessary. + ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr); + // CheckExtVectorCast - check type constraints for extended vectors. // Since vectors are an extension, there are no C standard reference for this. // We allow casting between vectors and integer datatypes of the same size, Index: cfe/trunk/test/CodeGenCXX/vector-splat-conversion.cpp === --- cfe/trunk/test/CodeGenCXX/vector-splat-conversion.cpp +++ cfe/trunk/test/CodeGenCXX/vector-splat-conversion.cpp @@ -1,19 +1,51 @@ // RUN: %clang_cc1 %s -triple arm64-apple-ios8.1.0 -std=c++11 -emit-llvm -o - | FileCheck %s -// rdar://2762 typedef __attribute__((__ext_vector_type__(8))) float vector_float8; typedef vector_float8 float8; -void MandelbrotPolyCalcSIMD8() -{ -constexpr float8 v4 = 4.0; // value to compare against abs(z)^2, to see if bounded -float8 vABS; -auto vLT = vABS < v4; +// rdar://2762 +// CHECK-LABEL: define void @_Z23MandelbrotPolyCalcSIMD8v +void MandelbrotPolyCalcSIMD8() { + constexpr float8 v4 = 4.0; // value to compare against abs(z)^2, to see if bounded + float8 vABS; + auto vLT = vABS < v4; + // CHECK: store <8 x float> + // CHECK: [[ZERO:%.*]] = load <8 x float>, <8 x float>* [[VARBS:%.*]] + // CHECK: [[CMP:%.*]] = fcmp olt <8 x float> [[ZERO]] + // CHECK: [[SEXT:%.*]] = sext <8 x i1> [[CMP]] to <8 x i32> + // CHECK: store <8 x i32> [[SEXT]], <8 x i32>* [[VLT:%.*]] } -// CHECK: store <8 x float> -// CHECK: [[ZERO:%.*]] = load <8 x float>, <8 x float>* [[VARBS:%.*]] -// CHECK: [[CMP:%.*]] = fcmp olt <8 x float> [[ZERO]] -// CHECK: [[SEXT:%.*]] = sext <8 x i1> [[CMP]] to <8 x i32> -// CHECK: store <8 x i32> [[SEXT]], <8 x i32>* [[VLT:%.*]] +typedef __attribute__((__ext_vector_type__(4))) int int4; +typedef __attribute__((__ext_vector_type__(4))) float float4; +typedef __attribute__((__ext_vector_type__(
r257559 - [Bugfix] Fix ICE on constexpr vector splat.
Author: gbiv Date: Tue Jan 12 19:52:39 2016 New Revision: 257559 URL: http://llvm.org/viewvc/llvm-project?rev=257559&view=rev Log: [Bugfix] Fix ICE on constexpr vector splat. In {CG,}ExprConstant.cpp, we weren't treating vector splats properly. This patch makes us treat splats more properly. Additionally, this patch adds a new cast kind which allows a bool->int cast to result in -1 or 0, instead of 1 or 0 (for true and false, respectively), so we can sanely model OpenCL bool->int casts in the AST. Differential Revision: http://reviews.llvm.org/D14877 Added: cfe/trunk/test/CodeGenCXX/builtins-systemz-zvector.cpp Modified: cfe/trunk/include/clang/AST/ASTContext.h cfe/trunk/include/clang/AST/OperationKinds.h cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/AST/Expr.cpp cfe/trunk/lib/AST/ExprConstant.cpp cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CGExprAgg.cpp cfe/trunk/lib/CodeGen/CGExprComplex.cpp cfe/trunk/lib/CodeGen/CGExprConstant.cpp cfe/trunk/lib/CodeGen/CGExprScalar.cpp cfe/trunk/lib/Edit/RewriteObjCFoundationAPI.cpp cfe/trunk/lib/Sema/SemaCast.cpp cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaExprCXX.cpp cfe/trunk/lib/Sema/SemaOverload.cpp cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp cfe/trunk/test/CodeGenCXX/vector-splat-conversion.cpp cfe/trunk/test/CodeGenOpenCL/bool_cast.cl Modified: cfe/trunk/include/clang/AST/ASTContext.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=257559&r1=257558&r2=257559&view=diff == --- cfe/trunk/include/clang/AST/ASTContext.h (original) +++ cfe/trunk/include/clang/AST/ASTContext.h Tue Jan 12 19:52:39 2016 @@ -2283,9 +2283,13 @@ public: /// \brief Make an APSInt of the appropriate width and signedness for the /// given \p Value and integer \p Type. llvm::APSInt MakeIntValue(uint64_t Value, QualType Type) const { -llvm::APSInt Res(getIntWidth(Type), - !Type->isSignedIntegerOrEnumerationType()); +// If Type is a signed integer type larger than 64 bits, we need to be sure +// to sign extend Res appropriately. +llvm::APSInt Res(64, !Type->isSignedIntegerOrEnumerationType()); Res = Value; +unsigned Width = getIntWidth(Type); +if (Width != Res.getBitWidth()) + return Res.extOrTrunc(Width); return Res; } Modified: cfe/trunk/include/clang/AST/OperationKinds.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OperationKinds.h?rev=257559&r1=257558&r2=257559&view=diff == --- cfe/trunk/include/clang/AST/OperationKinds.h (original) +++ cfe/trunk/include/clang/AST/OperationKinds.h Tue Jan 12 19:52:39 2016 @@ -185,7 +185,11 @@ enum CastKind { /// CK_FloatingToBoolean - Floating point to boolean. ///(bool) f CK_FloatingToBoolean, - + + // CK_BooleanToSignedIntegral - Convert a boolean to -1 or 0 for true and + // false, respectively. + CK_BooleanToSignedIntegral, + /// CK_FloatingCast - Casting between floating types of different size. ///(double) f ///(float) ld Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=257559&r1=257558&r2=257559&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Tue Jan 12 19:52:39 2016 @@ -8589,6 +8589,10 @@ public: bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty, CastKind &Kind); + /// \brief Prepare `SplattedExpr` for a vector splat operation, adding + /// implicit casts if necessary. + ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr); + // CheckExtVectorCast - check type constraints for extended vectors. // Since vectors are an extension, there are no C standard reference for this. // We allow casting between vectors and integer datatypes of the same size, Modified: cfe/trunk/lib/AST/Expr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=257559&r1=257558&r2=257559&view=diff == --- cfe/trunk/lib/AST/Expr.cpp (original) +++ cfe/trunk/lib/AST/Expr.cpp Tue Jan 12 19:52:39 2016 @@ -1553,6 +1553,7 @@ bool CastExpr::CastConsistency() const { case CK_ToVoid: case CK_VectorSplat: case CK_IntegralCast: + case CK_BooleanToSignedIntegral: case CK_IntegralToFloating: case CK_FloatingToIntegral: case CK_FloatingCast: @@ -1646,6 +1647,8 @@ const char *CastExpr::getCastKindName() return "VectorSplat"; case CK_IntegralCast: return "IntegralCast"; + case CK_BooleanToSignedIntegral: +retur
Re: [PATCH] D16115: [test-suite] Add ClangAnalyzerBenchmarks directory to test-suite repository
MatzeB accepted this revision. MatzeB added a comment. This revision is now accepted and ready to land. LGTM, though you should wait a week or two for other opinions before committing. http://reviews.llvm.org/D16115 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15862: A possible direction for fixing https://llvm.org/bugs/show_bug.cgi?id=25973.
mclow.lists added inline comments. Comment at: include/iterator:442 @@ +441,3 @@ +struct __is_exactly_input_iterator +: public integral_constant::iterator_category, input_iterator_tag>::value> {}; + Sigh. Yes, `boost::input_output_iterator_tag` (and probably others) inherit from `std:: input_iterator_tag` http://reviews.llvm.org/D15862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r257557 - [CUDA] Rename check-prefixes in cuda-options.cu and cuda-unused-arg-warning.cu.
Author: jlebar Date: Tue Jan 12 19:24:35 2016 New Revision: 257557 URL: http://llvm.org/viewvc/llvm-project?rev=257557&view=rev Log: [CUDA] Rename check-prefixes in cuda-options.cu and cuda-unused-arg-warning.cu. Summary: Rename the args to be more human-readable. Among other things, this lets us get rid of a bunch of comments (e.g. "ensure we don't run the linker"), greatly shortening these tests. Also apply consistent formatting and fix some English nits while we're at it. Reviewers: tra Differential Revision: http://reviews.llvm.org/D15975 Modified: cfe/trunk/test/Driver/cuda-options.cu cfe/trunk/test/Driver/cuda-unused-arg-warning.cu Modified: cfe/trunk/test/Driver/cuda-options.cu URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-options.cu?rev=257557&r1=257556&r2=257557&view=diff == --- cfe/trunk/test/Driver/cuda-options.cu (original) +++ cfe/trunk/test/Driver/cuda-options.cu Tue Jan 12 19:24:35 2016 @@ -3,175 +3,140 @@ // REQUIRES: x86-registered-target // REQUIRES: nvptx-registered-target -// Simple compilation case: +// Simple compilation case. Compile device-side to PTX assembly and make sure +// we use it on the host side. // RUN: %clang -### -target x86_64-linux-gnu -c %s 2>&1 \ -// Compile device-side to PTX assembly and make sure we use it on the host side. -// RUN: | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1NS\ -// Then compile host side and incorporate device code. -// RUN: -check-prefix CUDA-H -check-prefix CUDA-H-I1 \ -// Make sure we don't link anything. -// RUN: -check-prefix CUDA-NL %s +// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \ +// RUN:-check-prefix HOST -check-prefix INCLUDES-DEVICE \ +// RUN:-check-prefix NOLINK %s -// Typical compilation + link case: +// Typical compilation + link case. // RUN: %clang -### -target x86_64-linux-gnu %s 2>&1 \ -// Compile device-side to PTX assembly and make sure we use it on the host side -// RUN: | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1NS\ -// Then compile host side and incorporate device code. -// RUN: -check-prefix CUDA-H -check-prefix CUDA-H-I1 \ -// Then link things. -// RUN: -check-prefix CUDA-L %s +// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \ +// RUN:-check-prefix HOST -check-prefix INCLUDES-DEVICE \ +// RUN:-check-prefix LINK %s -// Verify that --cuda-host-only disables device-side compilation and linking +// Verify that --cuda-host-only disables device-side compilation, but doesn't +// disable host-side compilation/linking. // RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only %s 2>&1 \ -// Make sure we didn't run device-side compilation. -// RUN: | FileCheck -check-prefix CUDA-ND \ -// Then compile host side and make sure we don't attempt to incorporate GPU code. -// RUN:-check-prefix CUDA-H -check-prefix CUDA-H-NI \ -// Linking is allowed to happen, even if we're missing GPU code. -// RUN:-check-prefix CUDA-L %s +// RUN: | FileCheck -check-prefix NODEVICE -check-prefix HOST \ +// RUN:-check-prefix NOINCLUDES-DEVICE -check-prefix LINK %s -// Same test as above, but with preceeding --cuda-device-only to make -// sure only last option has effect. +// Same test as above, but with preceeding --cuda-device-only to make sure only +// the last option has an effect. // RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only --cuda-host-only %s 2>&1 \ -// Make sure we didn't run device-side compilation. -// RUN: | FileCheck -check-prefix CUDA-ND \ -// Then compile host side and make sure we don't attempt to incorporate GPU code. -// RUN:-check-prefix CUDA-H -check-prefix CUDA-H-NI \ -// Linking is allowed to happen, even if we're missing GPU code. -// RUN:-check-prefix CUDA-L %s +// RUN: | FileCheck -check-prefix NODEVICE -check-prefix HOST \ +// RUN:-check-prefix NOINCLUDES-DEVICE -check-prefix LINK %s -// Verify that --cuda-device-only disables host-side compilation and linking +// Verify that --cuda-device-only disables host-side compilation and linking. // RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only %s 2>&1 \ -// Compile device-side to PTX assembly -// RUN: | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1NS\ -// Make sure there are no host cmpilation or linking. -// RUN: -check-prefix CUDA-NH -check-prefix CUDA-NL %s +// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \ +// RUN:-check-prefix NOHOST -check-prefix NOLINK %s -// Same test as above, but with preceeding --cuda-host-only to make -// sure only last option has effect. +// Same test as above, but with preceeding --cuda-host-only to make sure only +// the last option has an effect. // RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only --cuda-device-only %s 2>&1 \ -// Compile device-side to PTX assembly -// RUN: | FileCheck -check-prefix CUDA-D1 -chec
r257556 - Generalize r256026 to apply to all MachO targets, not just Darwin targets.
Author: bwilson Date: Tue Jan 12 19:19:02 2016 New Revision: 257556 URL: http://llvm.org/viewvc/llvm-project?rev=257556&view=rev Log: Generalize r256026 to apply to all MachO targets, not just Darwin targets. The PIC default is set for the MachO toolchain, not just the Darwin toolchain, so this treats those the same. The behavior with -static should be the same for all MachO targets. rdar://24152327 Modified: cfe/trunk/lib/Driver/Tools.cpp cfe/trunk/test/Driver/pic.c Modified: cfe/trunk/lib/Driver/Tools.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=257556&r1=257555&r2=257556&view=diff == --- cfe/trunk/lib/Driver/Tools.cpp (original) +++ cfe/trunk/lib/Driver/Tools.cpp Tue Jan 12 19:19:02 2016 @@ -3263,8 +3263,9 @@ ParsePICArgs(const ToolChain &ToolChain, // ToolChain.getTriple() and Triple? bool PIE = ToolChain.isPIEDefault(); bool PIC = PIE || ToolChain.isPICDefault(); - // The Darwin default to use PIC does not apply when using -static. - if (ToolChain.getTriple().isOSDarwin() && Args.hasArg(options::OPT_static)) + // The Darwin/MachO default to use PIC does not apply when using -static. + if (ToolChain.getTriple().isOSBinFormatMachO() && + Args.hasArg(options::OPT_static)) PIE = PIC = false; bool IsPICLevelTwo = PIC; Modified: cfe/trunk/test/Driver/pic.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/pic.c?rev=257556&r1=257555&r2=257556&view=diff == --- cfe/trunk/test/Driver/pic.c (original) +++ cfe/trunk/test/Driver/pic.c Tue Jan 12 19:19:02 2016 @@ -218,6 +218,8 @@ // RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC // RUN: %clang -c %s -target armv7-apple-ios -fapple-kext -miphoneos-version-min=6.0.0 -static -### 2>&1 \ // RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC +// RUN: %clang -c %s -target armv7-apple-unknown-macho -static -### 2>&1 \ +// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC // // On OpenBSD, PIE is enabled by default, but can be disabled. // RUN: %clang -c %s -target amd64-pc-openbsd -### 2>&1 \ ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15699: [cfi] Cross-DSO CFI diagnostic mode (clang part)
pcc added inline comments. Comment at: lib/CodeGen/CGExpr.cpp:2620 @@ +2619,3 @@ + Builder.CreateICmpEQ(Data, llvm::ConstantPointerNull::get(Int8PtrTy)); + Builder.CreateCondBr(DataIsNullPtr, TrapBB, ContBB); + This looks like `CodeGenFunction::EmitTrapCheck`. Comment at: lib/CodeGen/CGExpr.cpp:2654-2678 @@ +2653,27 @@ + for (auto CheckKindMaskPair : CheckKinds) { +int Kind = CheckKindMaskPair.first; +SanitizerMask Mask = CheckKindMaskPair.second; +// All CFI checks are recoverable. +assert(getRecoverableKind(Mask) == CheckRecoverableKind::Recoverable); +if (CGM.getCodeGenOpts().SanitizeTrap.has(Mask)) { + SI->addCase(llvm::ConstantInt::get(Int8Ty, Kind), TrapBB); +} else if (CGM.getCodeGenOpts().SanitizeRecover.has(Mask)) { + if (!RecoverBB) { +RecoverBB = createBasicBlock("non_fatal"); +EmitBlock(RecoverBB); +emitCheckHandlerCall(*this, F->getFunctionType(), {Data, Addr}, + "cfi_check_fail", + CheckRecoverableKind::Recoverable, false, ExitBB); + } + SI->addCase(llvm::ConstantInt::get(Int8Ty, Kind), RecoverBB); +} else { + if (!FatalBB) { +FatalBB = createBasicBlock("fatal"); +EmitBlock(FatalBB); +emitCheckHandlerCall(*this, F->getFunctionType(), {Data, Addr}, + "cfi_check_fail", + CheckRecoverableKind::Recoverable, true, ExitBB); + } + SI->addCase(llvm::ConstantInt::get(Int8Ty, Kind), FatalBB); +} + } Can't you replace all this code with a call to `EmitCheck` passing `icmp`s for each of the check kinds? Sure, it wouldn't be a switch, but we don't care about the performance of this code anyway. Comment at: lib/CodeGen/CodeGenFunction.h:1386 @@ -1385,3 +1385,3 @@ - enum CFITypeCheckKind { + enum CFICheckKind { CFITCK_VCall, No need to rename, these are still all type checks. Comment at: test/CodeGen/cfi-icall-cross-dso.c:28 @@ -22,3 +27,3 @@ // ITANIUM: call i1 @llvm.bitset.test(i8* %{{.*}}, metadata !"_ZTSFvE"), !nosanitize -// ITANIUM: call void @__cfi_slowpath(i64 6588678392271548388, i8* %{{.*}}) {{.*}}, !nosanitize +// ITANIUM: call void @__cfi_slowpath_diag(i64 6588678392271548388, i8* %{{.*}}, {{.*}}@[[DATA]]{{.*}}, !nosanitize Are you still testing the `__cfi_slowpath` code path? Repository: rL LLVM http://reviews.llvm.org/D15699 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r257554 - [CUDA] Report an error if code tries to mix incompatible CUDA attributes.
Author: jlebar Date: Tue Jan 12 19:07:35 2016 New Revision: 257554 URL: http://llvm.org/viewvc/llvm-project?rev=257554&view=rev Log: [CUDA] Report an error if code tries to mix incompatible CUDA attributes. Summary: Thanks to jhen for helping me figure this out. Reviewers: tra, echristo Subscribers: jhen Differential Revision: http://reviews.llvm.org/D16129 Added: cfe/trunk/test/SemaCUDA/attributes-on-non-cuda.cu - copied, changed from r257543, cfe/trunk/test/SemaCUDA/attributes.cu cfe/trunk/test/SemaCUDA/bad-attributes.cu Removed: cfe/trunk/test/SemaCUDA/attributes.cu Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp cfe/trunk/test/SemaCUDA/Inputs/cuda.h Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=257554&r1=257553&r2=257554&view=diff == --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue Jan 12 19:07:35 2016 @@ -348,6 +348,25 @@ static void handleSimpleAttribute(Sema & Attr.getAttributeSpellingListIndex())); } +template +static void handleSimpleAttributeWithExclusions(Sema &S, Decl *D, +const AttributeList &Attr) { + handleSimpleAttribute(S, D, Attr); +} + +/// \brief Applies the given attribute to the Decl so long as the Decl doesn't +/// already have one of the given incompatible attributes. +template +static void handleSimpleAttributeWithExclusions(Sema &S, Decl *D, +const AttributeList &Attr) { + if (checkAttrMutualExclusion(S, D, Attr.getRange(), + Attr.getName())) +return; + handleSimpleAttributeWithExclusions(S, D, + Attr); +} + /// \brief Check if the passed-in expression is of type int or bool. static bool isIntOrBool(Expr *Exp) { QualType QT = Exp->getType(); @@ -3588,6 +3607,12 @@ static void handleOptimizeNoneAttr(Sema } static void handleGlobalAttr(Sema &S, Decl *D, const AttributeList &Attr) { + if (checkAttrMutualExclusion(S, D, Attr.getRange(), + Attr.getName()) || + checkAttrMutualExclusion(S, D, Attr.getRange(), + Attr.getName())) { +return; + } FunctionDecl *FD = cast(D); if (!FD->getReturnType()->isVoidType()) { SourceRange RTRange = FD->getReturnTypeSourceRange(); @@ -4558,14 +4583,6 @@ static void handleInterruptAttr(Sema &S, handleARMInterruptAttr(S, D, Attr); } -static void handleMips16Attribute(Sema &S, Decl *D, const AttributeList &Attr) { - if (checkAttrMutualExclusion(S, D, Attr.getRange(), - Attr.getName())) -return; - - handleSimpleAttribute(S, D, Attr); -} - static void handleAMDGPUNumVGPRAttr(Sema &S, Decl *D, const AttributeList &Attr) { uint32_t NumRegs; @@ -4955,7 +4972,8 @@ static void ProcessDeclAttribute(Sema &S handleDLLAttr(S, D, Attr); break; case AttributeList::AT_Mips16: -handleMips16Attribute(S, D, Attr); +handleSimpleAttributeWithExclusions(S, D, + Attr); break; case AttributeList::AT_NoMips16: handleSimpleAttribute(S, D, Attr); @@ -5006,7 +5024,8 @@ static void ProcessDeclAttribute(Sema &S handleCommonAttr(S, D, Attr); break; case AttributeList::AT_CUDAConstant: -handleSimpleAttribute(S, D, Attr); +handleSimpleAttributeWithExclusions(S, D, + Attr); break; case AttributeList::AT_PassObjectSize: handlePassObjectSizeAttr(S, D, Attr); @@ -5051,10 +5070,12 @@ static void ProcessDeclAttribute(Sema &S handleGlobalAttr(S, D, Attr); break; case AttributeList::AT_CUDADevice: -handleSimpleAttribute(S, D, Attr); +handleSimpleAttributeWithExclusions(S, D, +Attr); break; case AttributeList::AT_CUDAHost: -handleSimpleAttribute(S, D, Attr); +handleSimpleAttributeWithExclusions(S, D, + Attr); break; case AttributeList::AT_GNUInline: handleGNUInlineAttr(S, D, Attr); @@ -5114,7 +5135,8 @@ static void ProcessDeclAttribute(Sema &S handleSimpleAttribute(S, D, Attr); break; case AttributeList::AT_CUDAShared: -handleSimpleAttribute(S, D, Attr); +handleSimpleAttributeWithExclusions(S, D, + Attr); break; case AttributeList::AT_VecReturn: handleVecReturnAttr(S, D, At
Re: [PATCH] D14877: Fix ICE on lowering of constexpr vector splats
rsmith accepted this revision. This revision is now accepted and ready to land. Comment at: lib/CodeGen/CGExprScalar.cpp:816-817 @@ +815,4 @@ +// the same as the vector's element type (sans qualifiers) +assert(DstType->castAs()->getElementType().getTypePtr() == + SrcType.getTypePtr() && + "Splatted expr doesn't match with vector element type?"); The TypePtr can still have qualifiers in it in some cases. Use `ASTContext::hasSameType`. http://reviews.llvm.org/D14877 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r249995 - [Sema] Allow C conversions in C overload logic
ISTM that there's no established way to tell Sema::Diag to not emit its diagnostic, and trying to swap to e.g. Sema::CanPerformCopyInitialization makes us too forgiving. So, given that we need to use CheckSingleAssignmentConstraints directly, I don't see a better way to handle this than plumbing the `Diagnose` boolean through. I'll take a pass at fixing it, and hopefully get a patch out tomorrow. On Tue, Jan 12, 2016 at 1:51 PM, George Burgess IV < george.burgess...@gmail.com> wrote: > Sorry for the delayed response; one of my filters silently marked this > mail as read. Looking into it now. :) > > On Fri, Jan 8, 2016 at 12:38 PM, Bob Wilson wrote: > >> George, >> >> This change caused a serious regression for Objective-C method lookup. >> See PR26085 (http://llvm.org/pr26085). >> >> For the test case in that PR, Sema::SelectBestMethod looks at the two >> candidate "test" methods. It will match the second one, but in the process >> of considering the first candidate, an error diagnostic is generated. This >> happens within the call to CheckSingleAssignmentConstraints that was added >> here in IsStandardConversion. The "Diagnose" argument in that call is set >> to false, but the diagnostic is generated anyway. For the test case in the >> PR, the diagnostic comes from CheckObjCARCConversion, but it looks like >> there are some other diagnostics that could also be generated from within >> CheckSingleAssignmentConstraints. >> >> I think I could manage a fix, e.g., by threading the “Diagnose” flag >> through all the relevant code and consistently checking it before emitting >> diagnostics, but I’m not especially familiar with this part of clang. If >> you or someone else who knows more about this area can figure out the best >> way to fix it, I would appreciate it. >> >> —Bob >> >> > On Oct 11, 2015, at 1:13 PM, George Burgess IV via cfe-commits < >> cfe-commits@lists.llvm.org> wrote: >> > >> > Author: gbiv >> > Date: Sun Oct 11 15:13:20 2015 >> > New Revision: 249995 >> > >> > URL: http://llvm.org/viewvc/llvm-project?rev=249995&view=rev >> > Log: >> > [Sema] Allow C conversions in C overload logic >> > >> > C allows for some implicit conversions that C++ does not, e.g. void* -> >> > char*. This patch teaches clang that these conversions are okay when >> > dealing with overloads in C. >> > >> > Differential Revision: http://reviews.llvm.org/D13604 >> > >> > Modified: >> >cfe/trunk/include/clang/Sema/Overload.h >> >cfe/trunk/include/clang/Sema/Sema.h >> >cfe/trunk/lib/Sema/SemaExpr.cpp >> >cfe/trunk/lib/Sema/SemaOverload.cpp >> >cfe/trunk/test/Sema/overloadable.c >> > >> > Modified: cfe/trunk/include/clang/Sema/Overload.h >> > URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Overload.h?rev=249995&r1=249994&r2=249995&view=diff >> > >> == >> > --- cfe/trunk/include/clang/Sema/Overload.h (original) >> > +++ cfe/trunk/include/clang/Sema/Overload.h Sun Oct 11 15:13:20 2015 >> > @@ -83,7 +83,8 @@ namespace clang { >> > ICK_TransparentUnionConversion, ///< Transparent Union Conversions >> > ICK_Writeback_Conversion, ///< Objective-C ARC writeback conversion >> > ICK_Zero_Event_Conversion, ///< Zero constant to event (OpenCL1.2 >> 6.12.10) >> > -ICK_Num_Conversion_Kinds ///< The number of conversion kinds >> > +ICK_C_Only_Conversion, ///< Conversions allowed in C, but not >> C++ >> > +ICK_Num_Conversion_Kinds, ///< The number of conversion kinds >> > }; >> > >> > /// ImplicitConversionRank - The rank of an implicit conversion >> > @@ -95,7 +96,9 @@ namespace clang { >> > ICR_Promotion, ///< Promotion >> > ICR_Conversion, ///< Conversion >> > ICR_Complex_Real_Conversion, ///< Complex <-> Real conversion >> > -ICR_Writeback_Conversion ///< ObjC ARC writeback conversion >> > +ICR_Writeback_Conversion,///< ObjC ARC writeback conversion >> > +ICR_C_Conversion ///< Conversion only allowed in the C >> standard. >> > + /// (e.g. void* to char*) >> > }; >> > >> > ImplicitConversionRank GetConversionRank(ImplicitConversionKind Kind); >> > >> > Modified: cfe/trunk/include/clang/Sema/Sema.h >> > URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=249995&r1=249994&r2=249995&view=diff >> > >> == >> > --- cfe/trunk/include/clang/Sema/Sema.h (original) >> > +++ cfe/trunk/include/clang/Sema/Sema.h Sun Oct 11 15:13:20 2015 >> > @@ -8292,19 +8292,23 @@ public: >> >QualType LHSType, >> >QualType RHSType); >> > >> > - /// Check assignment constraints and prepare for a conversion of the >> > - /// RHS to the LHS type. >> > + /// Check assignment constraints and optionally pre
Re: [PATCH] D9600: Add scan-build python implementation
dcoughlin closed this revision. dcoughlin added a comment. This was committed in r257533. Thanks Laszlo! http://reviews.llvm.org/D9600 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16082: [CUDA] Invoke ptxas and fatbinary during compilation.
tra accepted this revision. tra added a comment. This revision is now accepted and ready to land. LGTM. http://reviews.llvm.org/D16082 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15599: [CodeGen] Fix a crash that occurs when attribute "naked" is attached to a c++ member function
ahatanak added a comment. In http://reviews.llvm.org/D15599#325113, @hans wrote: > Just out of curiosity, where does this come up in practice? I only have a short test case a user provided so t's not really clear whether it was necessary to mark a member function naked or there were other ways to get the same behavior. But unless we want to disallow marking member functions as naked, we shouldn't let clang crash when it compiles such functions. > It seems a little backward that we're first emitting a bunch of instructions, > only to remove them later. It would be nice if for naked function we wouldn't > emit them in the first place. But maybe that's not practical. I initially tried to block the instructions from being emitted but I ended up checking hasAttr() in a lot of places. I agree approach taken in this patch might look a bit backward, but it seemed better than the alternative. > Anyway, this seems OK to me but I'd like to hear what Reid thinks too. http://reviews.llvm.org/D15599 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r257543 - [Darwin] Fix deployment target detection
Author: friss Date: Tue Jan 12 17:47:59 2016 New Revision: 257543 URL: http://llvm.org/viewvc/llvm-project?rev=257543&view=rev Log: [Darwin] Fix deployment target detection There was a thinko in the deployment target detection code that made the -isysroot parsing have precedence over the environment variable for tvOS. This patch makes this logic symetric for all platforms (the env variable must have precedence). Modified: cfe/trunk/lib/Driver/ToolChains.cpp cfe/trunk/test/Driver/appletvos-version-min.c Modified: cfe/trunk/lib/Driver/ToolChains.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=257543&r1=257542&r2=257543&view=diff == --- cfe/trunk/lib/Driver/ToolChains.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains.cpp Tue Jan 12 17:47:59 2016 @@ -526,7 +526,7 @@ void Darwin::AddDeploymentTarget(Derived // no environment variable defined, see if we can set the default based // on -isysroot. if (OSXTarget.empty() && iOSTarget.empty() && WatchOSTarget.empty() && -Args.hasArg(options::OPT_isysroot)) { +TvOSTarget.empty() && Args.hasArg(options::OPT_isysroot)) { if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) { StringRef isysroot = A->getValue(); // Assume SDK has path: SOME_PATH/SDKs/PlatformXX.YY.sdk Modified: cfe/trunk/test/Driver/appletvos-version-min.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/appletvos-version-min.c?rev=257543&r1=257542&r2=257543&view=diff == --- cfe/trunk/test/Driver/appletvos-version-min.c (original) +++ cfe/trunk/test/Driver/appletvos-version-min.c Tue Jan 12 17:47:59 2016 @@ -2,6 +2,7 @@ // REQUIRES: aarch64-registered-target // RUN: %clang -target i386-apple-darwin10 -mappletvsimulator-version-min=9.0 -arch x86_64 -S -o - %s | FileCheck %s // RUN: %clang -target armv7s-apple-darwin10 -mappletvos-version-min=9.0 -arch arm64 -S -o - %s | FileCheck %s +// RUN: env TVOS_DEPLOYMENT_TARGET=9.0 %clang -isysroot SDKs/MacOSX10.9.sdk -target i386-apple-darwin10 -arch x86_64 -S -o - %s | FileCheck %s int main() { return 0; } // CHECK: .tvos_version_min 9, 0 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15305: [CUDA] Do not allow dynamic initialization of global device side variables.
tra added a comment. Richard, I've updated the patch as you've suggested -- it indeed simplifies things quite a bit and handles the corner cases you've mentioned. Comment at: lib/CodeGen/CGDeclCXX.cpp:323-324 @@ +322,4 @@ + + // The constructor function has no parameters, + if (CD->getNumParams() != 0) +return false; rsmith wrote: > What if the constructor is a C-style varargs function: > > struct X { X(...) {} }; > > ? CUDA does not support varargs on device side. nvcc fails with an error: > error: a "device" function cannot have ellipsis That's another thing I'll need to fix (as a separate patch) as clang currently accepts varargs everywhere. This patch will ignore number of arguments passed to varargs constructor, but the checks for empty body still do apply. Comment at: lib/CodeGen/CGDeclCXX.cpp:329 @@ +328,3 @@ + for (const CXXCtorInitializer *CI: CD->inits()) +if (CI->isAnyMemberInitializer() && CI->isWritten()) + return false; rsmith wrote: > tra wrote: > > @rsmith: is this a good way to find member initializer list items? > > > > ``` > > struct S { > > int a,b,c; > > S() : a(1),b(2),c(3) {} > > }; > > ``` > > I'm looking for a(),b(),c() which is what I think CUDA spec wants to check > > for, but CD->inits() appears to have other initializers on the list as well. > You shouldn't need to check `isAnyMemberInitializer`: if there's any written > inits, the constructor violates the rules. As it turns out, the rules don't apply to all written initializers. For instance, nvcc allows empty constructor on init list: ``` struct A { __device__ A(){}; }; struct B { __device__ B(){}; }; struct C : A { B b; __device__ C() : A(), b() {} }; __device__ C c; ``` I've simplified the patch so that in only checks for constructor's 'emptiness', but disregards how that constructor gets to be executed. Comment at: lib/CodeGen/CGDeclCXX.cpp:333 @@ +332,3 @@ + // and the function body is an empty compound statement. + // That does not always work. + if (!CD->hasTrivialBody()) rsmith wrote: > What doesn't always work? It was leftover from early patch variant that didn't defer emitting global vars. If I don't defer and need to emit a global var before constructor definition is available, hasTrivialBody() returns false and triggers diagnostics. Comment at: lib/CodeGen/CGDeclCXX.cpp:347-367 @@ +346,23 @@ + + // The default constructors of all base classes of its class can be + // considered empty. + for (auto &Base : RD->bases()) +if (hasNonEmptyDefaultConstructors(*this, + Base.getType()->getAsCXXRecordDecl())) + return false; + + // For all the nonstatic data members of its class that are of class type + // (or array thereof), the default constructors can be considered empty. + for (const auto *I : RD->decls()) +if (const FieldDecl *V = dyn_cast(I)) { + QualType T = V->getType(); + + if (const ArrayType *Ty = dyn_cast(T)) +while ((Ty = dyn_cast(T))) + T = Ty->getElementType(); + + if (const CXXRecordDecl *R = T->getAsCXXRecordDecl()) +if (hasNonEmptyDefaultConstructors(*this, R)) + return false; +} + rsmith wrote: > Rather than checking these properties this way, I'd suggest you check the > initialization expression in each `CXXCtorInitializer` only contains > `CXXConstructExpr`s for empty constructors (or any other whitelisted > constructs). Your current approach will miss a couple of cases which the CUDA > spec misses but presumably meant to exclude: > > 1) Default member initializers > > int f(); > struct X { int n = f(); X() {} }; > > 2) Cases where a constructor other than a default constructor is implicitly > invoked > > struct A { template A(T...); }; > struct B : A { B() {} }; Nice. This has simplified the checks a lot. Comment at: lib/CodeGen/CodeGenModule.cpp:1347-1351 @@ -1346,2 +1346,7 @@ return false; + // Delay codegen for device-side CUDA variables. We need to have all + // constructor definitions available before we can determine whether + // we can skip them or produce an error. + if (LangOpts.CUDA && LangOpts.CUDAIsDevice && isa(Global)) +return false; rsmith wrote: > According to the quoted specification, you're supposed to check whether the > constructor can be considered empty at the point in the translation unit > where the definition of the variable occurs, so I don't think you need to > delay anything. I guess it's a bug in their guide as nvcc accepts following code with constructor definition appearing *after* the variable: ``` struct S { S(); }; __device__ S s; S::S() {} ``` http://reviews.llvm.org/D15305 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.
Re: [PATCH] D15670: Accept elided commas in macro function arguments for MS compatibility
rnk accepted this revision. rnk added a comment. This revision is now accepted and ready to land. Seems reasonable to me, but we should check with Richard. http://reviews.llvm.org/D15670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15448: [analyzer] SVal Visitor.
zaks.anna accepted this revision. zaks.anna added a comment. This revision is now accepted and ready to land. LGTM. Thank you! http://reviews.llvm.org/D15448 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r257541 - Follow-up to r257537: add test that majnemer asked about
Author: hans Date: Tue Jan 12 17:31:58 2016 New Revision: 257541 URL: http://llvm.org/viewvc/llvm-project?rev=257541&view=rev Log: Follow-up to r257537: add test that majnemer asked about Modified: cfe/trunk/test/Driver/cl-options.c Modified: cfe/trunk/test/Driver/cl-options.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=257541&r1=257540&r2=257541&view=diff == --- cfe/trunk/test/Driver/cl-options.c (original) +++ cfe/trunk/test/Driver/cl-options.c Tue Jan 12 17:31:58 2016 @@ -14,13 +14,14 @@ // C_P: "-E" // C_P: "-C" -// RUN: %clang_cl /Dfoo=bar /D bar=baz /DMYDEF#value /DMYDEF2=foo#bar /DMYDEF3#a=b \ +// RUN: %clang_cl /Dfoo=bar /D bar=baz /DMYDEF#value /DMYDEF2=foo#bar /DMYDEF3#a=b /DMYDEF4# \ // RUN:-### -- %s 2>&1 | FileCheck -check-prefix=D %s // D: "-D" "foo=bar" // D: "-D" "bar=baz" // D: "-D" "MYDEF=value" // D: "-D" "MYDEF2=foo#bar" // D: "-D" "MYDEF3=a=b" +// D: "-D" "MYDEF4=" // RUN: %clang_cl /E -### -- %s 2>&1 | FileCheck -check-prefix=E %s // E: "-E" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15686: PR25910: clang allows two var definitions with the same mangled name
rnk added a subscriber: rnk. rnk added a comment. I thought we already addressed this issue with @rjmccall and decided that, if the user intentionally declares extern "C" variables with an _Z prefix, then we know they are intentionally attempting to name some C++ global variable. I'd rather just warn on all extern "C" declarations starting with _Z, and let users keep the pieces when things break. http://reviews.llvm.org/D15686 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15305: [CUDA] Do not allow dynamic initialization of global device side variables.
tra updated this revision to Diff 44687. tra added a comment. Check all variable initializers and only allow 'empty constructors' as Richard has suggested. Changed test structure so that we test for allowed/disallowed constructors separately from testing how we handle initialization of base classes or member fields. http://reviews.llvm.org/D15305 Files: lib/CodeGen/CGDeclCXX.cpp lib/CodeGen/CodeGenModule.cpp lib/CodeGen/CodeGenModule.h test/CodeGenCUDA/device-var-init.cu Index: test/CodeGenCUDA/device-var-init.cu === --- /dev/null +++ test/CodeGenCUDA/device-var-init.cu @@ -0,0 +1,364 @@ +// REQUIRES: nvptx-registered-target + +// Make sure we don't allow dynamic initialization for device +// variables, but accept empty constructors allowed by CUDA. + +// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -std=c++11 \ +// RUN: -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -std=c++11 \ +// RUN: -emit-llvm -DERROR_CASE -verify -o /dev/null %s + +#ifdef __clang__ +#include "Inputs/cuda.h" +#endif + +// Base classes with different initializer variants. + +// trivial constructor -- allowed +struct T { + int t; +}; + +// empty constructor +struct EC { + int ec; + __device__ EC() {} // -- allowed + __device__ EC(int) {} // -- not allowed +}; + +// empty templated constructor -- allowed with no arguments +struct ETC { + template __device__ ETC(T...) {} +}; + +// undefined constructor -- not allowed +struct UC { + int uc; + __device__ UC(); +}; + +// empty constructor w/ initializer list -- not allowed +struct ECI { + int eci; + __device__ ECI() : eci(1) {} +}; + +// non-empty constructor -- not allowed +struct NEC { + int nec; + __device__ NEC() { nec = 1; } +}; + +// no-constructor, virtual method -- not allowed +struct NCV { + int ncv; + __device__ virtual void vm() {} +}; + +// dynamic in-class field initializer -- not allowed +__device__ int f(); +struct NCF { + int ncf = f(); +}; + +// static in-class field initializer -- not allowed by nvcc. +// NOTE: clang does generate statically initalized field here. +// So in practice it could be supported. +struct NCFS { + int ncfs = 3; +}; + +// undefined templated constructor -- not allowed +struct UTC { + template __device__ UTC(T...); +}; + +// non-empty templated constructor -- not allowed +struct NETC { + int netc; + template __device__ NETC(T...) { netc = 1; } +}; + +__device__ T d_t; +// CHECK: @d_t = addrspace(1) externally_initialized global %struct.T zeroinitializer +__shared__ T s_t; +// CHECK: @s_t = addrspace(3) global %struct.T undef, +__constant__ T c_t; +// CHECK: @c_t = addrspace(4) externally_initialized global %struct.T zeroinitializer, + +__device__ T d_t_i = {2}; +// CHECKL @d_t_i = addrspace(1) externally_initialized global %struct.T { i32 2 }, +#ifdef ERROR_CASE +__shared__ T s_t_i = {2}; +// expected-error@-1 {{initialization is not supported for __shared__ variables.}} +#endif +__constant__ T c_t_i = {2}; +// CHECK: @c_t_i = addrspace(4) externally_initialized global %struct.T { i32 2 }, + +__device__ EC d_ec; +// CHECK: @d_ec = addrspace(1) externally_initialized global %struct.EC zeroinitializer, +__shared__ EC s_ec; +// CHECK: @s_ec = addrspace(3) global %struct.EC undef, +__constant__ EC c_ec; +// CHECK: @c_ec = addrspace(4) externally_initialized global %struct.EC zeroinitializer, + +#if ERROR_CASE +__device__ EC d_ec_i(3); +// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__ and __shared__ variables.}} +__shared__ EC s_ec_i(3); +// expected-error@-1 {{initialization is not supported for __shared__ variables.}} +__constant__ EC c_ec_i(3); +// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__ and __shared__ variables.}} + +__device__ EC d_ec_i2 = {3}; +// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__ and __shared__ variables.}} +__shared__ EC s_ec_i2 = {3}; +// expected-error@-1 {{initialization is not supported for __shared__ variables.}} +__constant__ EC c_ec_i2 = {3}; +// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__ and __shared__ variables.}} +#endif + +__device__ ETC d_etc; +// CHETCK: @d_etc = addrspace(1) externally_initialized global %struct.ETC zeroinitializer, +__shared__ ETC s_etc; +// CHETCK: @s_etc = addrspace(3) global %struct.ETC undef, +__constant__ ETC c_etc; +// CHETCK: @c_etc = addrspace(4) externally_initialized global %struct.ETC zeroinitializer, + +#if ERROR_CASE +__device__ ETC d_etc_i(3); +// expected-error@-1 {{dynamic initialization is not supported for __device__, __constant__ and __shared__ variables.}} +__shared__ ETC s_etc_i(3); +// expected-error@-1 {{initialization is not supported for __shared__ variables.}} +__constant__ ETC c_etc_i(3); +// expected-error@-1 {{dynami
r257537 - clang-cl: Support /Dfoo#bar (PR25984)
Author: hans Date: Tue Jan 12 17:17:03 2016 New Revision: 257537 URL: http://llvm.org/viewvc/llvm-project?rev=257537&view=rev Log: clang-cl: Support /Dfoo#bar (PR25984) Such flags will now be translated to -Dfoo=bar. Modified: cfe/trunk/lib/Driver/MSVCToolChain.cpp cfe/trunk/test/Driver/cl-options.c Modified: cfe/trunk/lib/Driver/MSVCToolChain.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/MSVCToolChain.cpp?rev=257537&r1=257536&r2=257537&view=diff == --- cfe/trunk/lib/Driver/MSVCToolChain.cpp (original) +++ cfe/trunk/lib/Driver/MSVCToolChain.cpp Tue Jan 12 17:17:03 2016 @@ -634,6 +634,96 @@ SanitizerMask MSVCToolChain::getSupporte return Res; } +static void TranslateOptArg(Arg *A, llvm::opt::DerivedArgList &DAL, +bool SupportsForcingFramePointer, +const char *ExpandChar, const OptTable &Opts) { + assert(A->getOption().matches(options::OPT__SLASH_O)); + + StringRef OptStr = A->getValue(); + for (size_t I = 0, E = OptStr.size(); I != E; ++I) { +const char &OptChar = *(OptStr.data() + I); +switch (OptChar) { +default: + break; +case '1': +case '2': +case 'x': +case 'd': + if (&OptChar == ExpandChar) { +if (OptChar == 'd') { + DAL.AddFlagArg(A, Opts.getOption(options::OPT_O0)); +} else { + if (OptChar == '1') { +DAL.AddJoinedArg(A, Opts.getOption(options::OPT_O), "s"); + } else if (OptChar == '2' || OptChar == 'x') { +DAL.AddFlagArg(A, Opts.getOption(options::OPT_fbuiltin)); +DAL.AddJoinedArg(A, Opts.getOption(options::OPT_O), "2"); + } + if (SupportsForcingFramePointer) +DAL.AddFlagArg(A, + Opts.getOption(options::OPT_fomit_frame_pointer)); + if (OptChar == '1' || OptChar == '2') +DAL.AddFlagArg(A, + Opts.getOption(options::OPT_ffunction_sections)); +} + } + break; +case 'b': + if (I + 1 != E && isdigit(OptStr[I + 1])) +++I; + break; +case 'g': + break; +case 'i': + if (I + 1 != E && OptStr[I + 1] == '-') { +++I; +DAL.AddFlagArg(A, Opts.getOption(options::OPT_fno_builtin)); + } else { +DAL.AddFlagArg(A, Opts.getOption(options::OPT_fbuiltin)); + } + break; +case 's': + DAL.AddJoinedArg(A, Opts.getOption(options::OPT_O), "s"); + break; +case 't': + DAL.AddJoinedArg(A, Opts.getOption(options::OPT_O), "2"); + break; +case 'y': { + bool OmitFramePointer = true; + if (I + 1 != E && OptStr[I + 1] == '-') { +OmitFramePointer = false; +++I; + } + if (SupportsForcingFramePointer) { +if (OmitFramePointer) + DAL.AddFlagArg(A, + Opts.getOption(options::OPT_fomit_frame_pointer)); +else + DAL.AddFlagArg( + A, Opts.getOption(options::OPT_fno_omit_frame_pointer)); + } + break; +} +} + } +} + +static void TranslateDArg(Arg *A, llvm::opt::DerivedArgList &DAL, + const OptTable &Opts) { + assert(A->getOption().matches(options::OPT_D)); + + StringRef Val = A->getValue(); + size_t Hash = Val.find('#'); + if (Hash == StringRef::npos || Hash > Val.find('=')) { +DAL.append(A); +return; + } + + std::string NewVal = Val; + NewVal[Hash] = '='; + DAL.AddJoinedArg(A, Opts.getOption(options::OPT_D), NewVal); +} + llvm::opt::DerivedArgList * MSVCToolChain::TranslateArgs(const llvm::opt::DerivedArgList &Args, const char *BoundArch) const { @@ -664,81 +754,18 @@ MSVCToolChain::TranslateArgs(const llvm: } } - // The -O flag actually takes an amalgam of other options. For example, - // '/Ogyb2' is equivalent to '/Og' '/Oy' '/Ob2'. for (Arg *A : Args) { -if (!A->getOption().matches(options::OPT__SLASH_O)) { +if (A->getOption().matches(options::OPT__SLASH_O)) { + // The -O flag actually takes an amalgam of other options. For example, + // '/Ogyb2' is equivalent to '/Og' '/Oy' '/Ob2'. + TranslateOptArg(A, *DAL, SupportsForcingFramePointer, ExpandChar, Opts); +} else if (A->getOption().matches(options::OPT_D)) { + // Translate -Dfoo#bar into -Dfoo=bar. + TranslateDArg(A, *DAL, Opts); +} else { DAL->append(A); - continue; -} - -StringRef OptStr = A->getValue(); -for (size_t I = 0, E = OptStr.size(); I != E; ++I) { - const char &OptChar = *(OptStr.data() + I); - switch (OptChar) { - default: -break; - case '1': - case '2': - case 'x': - case 'd': -if (&OptChar == ExpandChar) { - if (OptChar == 'd') { -DAL->AddFlagArg(A, Opts.getOption(options::OPT_O0)); - } else { -if (Opt
Re: [PATCH] D14877: Fix ICE on lowering of constexpr vector splats
george.burgess.iv marked 2 inline comments as done. george.burgess.iv added a comment. Ping :) http://reviews.llvm.org/D14877 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15721: [Sema] Fix ICE on casting a vector of bools to a vector of T
george.burgess.iv added a comment. Ping :) http://reviews.llvm.org/D15721 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D9600: Add scan-build python implementation
rizsotto.mailinglist added a comment. Thank you guys for your review and help! The latest patch is commited. Let's do the next steps too. ;) @danielmarjamaki the standalone Bear will be maintained. and your comments will also be considered. http://reviews.llvm.org/D9600 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r257533 - D9600: Add scan-build python implementation
On 1/12/16 3:38 PM, Laszlo Nagy via cfe-commits wrote: Author: rizsotto Date: Tue Jan 12 16:38:41 2016 New Revision: 257533 URL: http://llvm.org/viewvc/llvm-project?rev=257533&view=rev Log: D9600: Add scan-build python implementation Yay! ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits -- Jon Roelofs jonat...@codesourcery.com CodeSourcery / Mentor Embedded ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r257530 - [CUDA] Add explicit mapping from sm_XX to compute_YY.
Author: jlebar Date: Tue Jan 12 16:23:04 2016 New Revision: 257530 URL: http://llvm.org/viewvc/llvm-project?rev=257530&view=rev Log: [CUDA] Add explicit mapping from sm_XX to compute_YY. Summary: This is used by D16082 when it invokes fatbinary. Reviewers: tra Subscribers: cfe-commits, jhen, echristo Differential Revision: http://reviews.llvm.org/D16097 Modified: cfe/trunk/include/clang/Driver/Action.h cfe/trunk/lib/Driver/Action.cpp cfe/trunk/test/Driver/cuda-bad-arch.cu Modified: cfe/trunk/include/clang/Driver/Action.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Action.h?rev=257530&r1=257529&r2=257530&view=diff == --- cfe/trunk/include/clang/Driver/Action.h (original) +++ cfe/trunk/include/clang/Driver/Action.h Tue Jan 12 16:23:04 2016 @@ -146,6 +146,10 @@ public: CudaDeviceAction(Action *Input, const char *ArchName, bool AtTopLevel); const char *getGpuArchName() const { return GpuArchName; } + + /// Gets the compute_XX that corresponds to getGpuArchName(). + const char *getComputeArchName() const; + bool isAtTopLevel() const { return AtTopLevel; } static bool IsValidGpuArchName(llvm::StringRef ArchName); Modified: cfe/trunk/lib/Driver/Action.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Action.cpp?rev=257530&r1=257529&r2=257530&view=diff == --- cfe/trunk/lib/Driver/Action.cpp (original) +++ cfe/trunk/lib/Driver/Action.cpp Tue Jan 12 16:23:04 2016 @@ -8,6 +8,7 @@ //===--===// #include "clang/Driver/Action.h" +#include "llvm/ADT/StringSwitch.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/Regex.h" #include @@ -50,6 +51,24 @@ void BindArchAction::anchor() {} BindArchAction::BindArchAction(Action *Input, const char *_ArchName) : Action(BindArchClass, Input), ArchName(_ArchName) {} +// Converts CUDA GPU architecture, e.g. "sm_21", to its corresponding virtual +// compute arch, e.g. "compute_20". Returns null if the input arch is null or +// doesn't match an existing arch. +static const char* GpuArchToComputeName(const char *ArchName) { + if (!ArchName) +return nullptr; + return llvm::StringSwitch(ArchName) + .Cases("sm_20", "sm_21", "compute_20") + .Case("sm_30", "compute_30") + .Case("sm_32", "compute_32") + .Case("sm_35", "compute_35") + .Case("sm_37", "compute_37") + .Case("sm_50", "compute_50") + .Case("sm_52", "compute_52") + .Case("sm_53", "compute_53") + .Default(nullptr); +} + void CudaDeviceAction::anchor() {} CudaDeviceAction::CudaDeviceAction(Action *Input, const char *ArchName, @@ -59,9 +78,12 @@ CudaDeviceAction::CudaDeviceAction(Actio assert(IsValidGpuArchName(GpuArchName)); } +const char *CudaDeviceAction::getComputeArchName() const { + return GpuArchToComputeName(GpuArchName); +} + bool CudaDeviceAction::IsValidGpuArchName(llvm::StringRef ArchName) { - static llvm::Regex RE("^sm_[0-9]+$"); - return RE.match(ArchName); + return GpuArchToComputeName(ArchName.data()) != nullptr; } void CudaHostAction::anchor() {} Modified: cfe/trunk/test/Driver/cuda-bad-arch.cu URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-bad-arch.cu?rev=257530&r1=257529&r2=257530&view=diff == --- cfe/trunk/test/Driver/cuda-bad-arch.cu (original) +++ cfe/trunk/test/Driver/cuda-bad-arch.cu Tue Jan 12 16:23:04 2016 @@ -5,28 +5,16 @@ // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=compute_20 -c %s 2>&1 \ // RUN: | FileCheck -check-prefix BAD %s -// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=foo_20 -c %s 2>&1 \ -// RUN: | FileCheck -check-prefix BAD %s // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm20 -c %s 2>&1 \ // RUN: | FileCheck -check-prefix BAD %s -// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_abc -c %s 2>&1 \ -// RUN: | FileCheck -check-prefix BAD %s -// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_20a -c %s 2>&1 \ -// RUN: | FileCheck -check-prefix BAD %s -// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_a20 -c %s 2>&1 \ -// RUN: | FileCheck -check-prefix BAD %s -// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=ssm_20 -c %s 2>&1 \ -// RUN: | FileCheck -check-prefix BAD %s -// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_ -c %s 2>&1 \ +// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_19 -c %s 2>&1 \ // RUN: | FileCheck -check-prefix BAD %s // BAD: error: Unsupported CUDA gpu architecture -// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_2 -c %s 2>&1 \ -// RUN: | FileCheck -check-prefix OK %s // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=s
Re: [PATCH] D16097: [CUDA] Add explicit mapping from sm_XX to compute_YY.
This revision was automatically updated to reflect the committed changes. Closed by commit rL257530: [CUDA] Add explicit mapping from sm_XX to compute_YY. (authored by jlebar). Changed prior to commit: http://reviews.llvm.org/D16097?vs=44673&id=44675#toc Repository: rL LLVM http://reviews.llvm.org/D16097 Files: cfe/trunk/include/clang/Driver/Action.h cfe/trunk/lib/Driver/Action.cpp cfe/trunk/test/Driver/cuda-bad-arch.cu Index: cfe/trunk/include/clang/Driver/Action.h === --- cfe/trunk/include/clang/Driver/Action.h +++ cfe/trunk/include/clang/Driver/Action.h @@ -146,6 +146,10 @@ CudaDeviceAction(Action *Input, const char *ArchName, bool AtTopLevel); const char *getGpuArchName() const { return GpuArchName; } + + /// Gets the compute_XX that corresponds to getGpuArchName(). + const char *getComputeArchName() const; + bool isAtTopLevel() const { return AtTopLevel; } static bool IsValidGpuArchName(llvm::StringRef ArchName); Index: cfe/trunk/test/Driver/cuda-bad-arch.cu === --- cfe/trunk/test/Driver/cuda-bad-arch.cu +++ cfe/trunk/test/Driver/cuda-bad-arch.cu @@ -5,28 +5,16 @@ // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=compute_20 -c %s 2>&1 \ // RUN: | FileCheck -check-prefix BAD %s -// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=foo_20 -c %s 2>&1 \ -// RUN: | FileCheck -check-prefix BAD %s // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm20 -c %s 2>&1 \ // RUN: | FileCheck -check-prefix BAD %s -// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_abc -c %s 2>&1 \ -// RUN: | FileCheck -check-prefix BAD %s -// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_20a -c %s 2>&1 \ -// RUN: | FileCheck -check-prefix BAD %s -// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_a20 -c %s 2>&1 \ -// RUN: | FileCheck -check-prefix BAD %s -// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=ssm_20 -c %s 2>&1 \ -// RUN: | FileCheck -check-prefix BAD %s -// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_ -c %s 2>&1 \ +// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_19 -c %s 2>&1 \ // RUN: | FileCheck -check-prefix BAD %s // BAD: error: Unsupported CUDA gpu architecture -// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_2 -c %s 2>&1 \ -// RUN: | FileCheck -check-prefix OK %s // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_20 -c %s 2>&1 \ // RUN: | FileCheck -check-prefix OK %s -// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_999 -c %s 2>&1 \ +// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_52 -c %s 2>&1 \ // RUN: | FileCheck -check-prefix OK %s // RUN: %clang -### -target x86_64-linux-gnu -c %s 2>&1 \ // RUN: | FileCheck -check-prefix OK %s Index: cfe/trunk/lib/Driver/Action.cpp === --- cfe/trunk/lib/Driver/Action.cpp +++ cfe/trunk/lib/Driver/Action.cpp @@ -8,6 +8,7 @@ //===--===// #include "clang/Driver/Action.h" +#include "llvm/ADT/StringSwitch.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/Regex.h" #include @@ -50,6 +51,24 @@ BindArchAction::BindArchAction(Action *Input, const char *_ArchName) : Action(BindArchClass, Input), ArchName(_ArchName) {} +// Converts CUDA GPU architecture, e.g. "sm_21", to its corresponding virtual +// compute arch, e.g. "compute_20". Returns null if the input arch is null or +// doesn't match an existing arch. +static const char* GpuArchToComputeName(const char *ArchName) { + if (!ArchName) +return nullptr; + return llvm::StringSwitch(ArchName) + .Cases("sm_20", "sm_21", "compute_20") + .Case("sm_30", "compute_30") + .Case("sm_32", "compute_32") + .Case("sm_35", "compute_35") + .Case("sm_37", "compute_37") + .Case("sm_50", "compute_50") + .Case("sm_52", "compute_52") + .Case("sm_53", "compute_53") + .Default(nullptr); +} + void CudaDeviceAction::anchor() {} CudaDeviceAction::CudaDeviceAction(Action *Input, const char *ArchName, @@ -59,9 +78,12 @@ assert(IsValidGpuArchName(GpuArchName)); } +const char *CudaDeviceAction::getComputeArchName() const { + return GpuArchToComputeName(GpuArchName); +} + bool CudaDeviceAction::IsValidGpuArchName(llvm::StringRef ArchName) { - static llvm::Regex RE("^sm_[0-9]+$"); - return RE.match(ArchName); + return GpuArchToComputeName(ArchName.data()) != nullptr; } void CudaHostAction::anchor() {} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16097: [CUDA] Add explicit mapping from sm_XX to compute_YY.
echristo added a comment. Still good. much nicer now. http://reviews.llvm.org/D16097 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16113: [clang-tdiy] Add header file extension configuration support.
aaron.ballman added a comment. Public-facing documentation should also be updated to specify the new option for the various checkers. Comment at: clang-tidy/ClangTidy.h:55 @@ +54,3 @@ + /// Reads the option with the check-local name \p LocalName from local or + /// global \c CheckOptions. If the option is not present in both options, + /// returns Default. "in both options" -> "in either list" Comment at: clang-tidy/ClangTidy.h:57 @@ +56,3 @@ + /// returns Default. + std::string getLocalOrGlobal(StringRef LocalName, std::string Default) const; + Any reason for Default to not be a `StringRef` (I assume this is always going to be a hard-coded string literal in callers)? At the very least, it should be a `const std::string &`. Comment at: clang-tidy/ClangTidyOptions.cpp:269 @@ +268,3 @@ + SmallVector Suffixes; + HeaderFileExtensions.split(Suffixes, ','); + for (const auto& Suffix : Suffixes) { This code seems like it will fail if there are spaces in the extension list, like `.h, .hxx` instead of `.h,.hxx`. I think the list, as given by the end user, should be processed into a vector of sorts so that things can be normalized (entries without a period can be diagnosed, spaces removed, etc). Comment at: clang-tidy/ClangTidyOptions.cpp:270 @@ +269,3 @@ + HeaderFileExtensions.split(Suffixes, ','); + for (const auto& Suffix : Suffixes) { +if (Suffix.empty() && llvm::sys::path::extension(Filename).empty()) clang-format the patch. Comment at: clang-tidy/ClangTidyOptions.h:216 @@ +215,3 @@ +/// HeaderFileExtensions. +bool endWithHeaderFileExtensions(llvm::StringRef FileName, + llvm::StringRef HeaderFileExtensions); endsWithHeaderFileExtension instead? However, given that uses of this all start with a SourceLocation, I wonder if that makes for a cleaner API: isLocInHeaderFile(SourceLocation, ); Also, how does this work if I want to include an extension-less file as the header file "extension?" It would be plausible if the extensions were passed in as a list, but as it stands it doesn't seem possible without weird conventions like leaving a blank in the list (e.g., `.h,,.hpp`), which seems error-prone. Also, I'm not certain what I can pass in. The documentation should be updated to state whether these extensions are intended to include the ".". Repository: rL LLVM http://reviews.llvm.org/D16113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16097: [CUDA] Add explicit mapping from sm_XX to compute_YY.
jlebar updated this revision to Diff 44673. jlebar added a comment. Use llvm::StringSwitch instead of a sequence of if statements. http://reviews.llvm.org/D16097 Files: include/clang/Driver/Action.h lib/Driver/Action.cpp test/Driver/cuda-bad-arch.cu Index: test/Driver/cuda-bad-arch.cu === --- test/Driver/cuda-bad-arch.cu +++ test/Driver/cuda-bad-arch.cu @@ -5,28 +5,16 @@ // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=compute_20 -c %s 2>&1 \ // RUN: | FileCheck -check-prefix BAD %s -// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=foo_20 -c %s 2>&1 \ -// RUN: | FileCheck -check-prefix BAD %s // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm20 -c %s 2>&1 \ // RUN: | FileCheck -check-prefix BAD %s -// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_abc -c %s 2>&1 \ -// RUN: | FileCheck -check-prefix BAD %s -// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_20a -c %s 2>&1 \ -// RUN: | FileCheck -check-prefix BAD %s -// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_a20 -c %s 2>&1 \ -// RUN: | FileCheck -check-prefix BAD %s -// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=ssm_20 -c %s 2>&1 \ -// RUN: | FileCheck -check-prefix BAD %s -// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_ -c %s 2>&1 \ +// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_19 -c %s 2>&1 \ // RUN: | FileCheck -check-prefix BAD %s // BAD: error: Unsupported CUDA gpu architecture -// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_2 -c %s 2>&1 \ -// RUN: | FileCheck -check-prefix OK %s // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_20 -c %s 2>&1 \ // RUN: | FileCheck -check-prefix OK %s -// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_999 -c %s 2>&1 \ +// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_52 -c %s 2>&1 \ // RUN: | FileCheck -check-prefix OK %s // RUN: %clang -### -target x86_64-linux-gnu -c %s 2>&1 \ // RUN: | FileCheck -check-prefix OK %s Index: lib/Driver/Action.cpp === --- lib/Driver/Action.cpp +++ lib/Driver/Action.cpp @@ -8,6 +8,7 @@ //===--===// #include "clang/Driver/Action.h" +#include "llvm/ADT/StringSwitch.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/Regex.h" #include @@ -50,6 +51,24 @@ BindArchAction::BindArchAction(Action *Input, const char *_ArchName) : Action(BindArchClass, Input), ArchName(_ArchName) {} +// Converts CUDA GPU architecture, e.g. "sm_21", to its corresponding virtual +// compute arch, e.g. "compute_20". Returns null if the input arch is null or +// doesn't match an existing arch. +static const char* GpuArchToComputeName(const char *ArchName) { + if (!ArchName) +return nullptr; + return llvm::StringSwitch(ArchName) + .Cases("sm_20", "sm_21", "compute_20") + .Case("sm_30", "compute_30") + .Case("sm_32", "compute_32") + .Case("sm_35", "compute_35") + .Case("sm_37", "compute_37") + .Case("sm_50", "compute_50") + .Case("sm_52", "compute_52") + .Case("sm_53", "compute_53") + .Default(nullptr); +} + void CudaDeviceAction::anchor() {} CudaDeviceAction::CudaDeviceAction(Action *Input, const char *ArchName, @@ -59,9 +78,12 @@ assert(IsValidGpuArchName(GpuArchName)); } +const char *CudaDeviceAction::getComputeArchName() const { + return GpuArchToComputeName(GpuArchName); +} + bool CudaDeviceAction::IsValidGpuArchName(llvm::StringRef ArchName) { - static llvm::Regex RE("^sm_[0-9]+$"); - return RE.match(ArchName); + return GpuArchToComputeName(ArchName.data()) != nullptr; } void CudaHostAction::anchor() {} Index: include/clang/Driver/Action.h === --- include/clang/Driver/Action.h +++ include/clang/Driver/Action.h @@ -146,6 +146,10 @@ CudaDeviceAction(Action *Input, const char *ArchName, bool AtTopLevel); const char *getGpuArchName() const { return GpuArchName; } + + /// Gets the compute_XX that corresponds to getGpuArchName(). + const char *getComputeArchName() const; + bool isAtTopLevel() const { return AtTopLevel; } static bool IsValidGpuArchName(llvm::StringRef ArchName); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r257529 - Improve AST dumping:
Author: rsmith Date: Tue Jan 12 15:59:26 2016 New Revision: 257529 URL: http://llvm.org/viewvc/llvm-project?rev=257529&view=rev Log: Improve AST dumping: 1) When dumping a declaration that declares a name for a type, also dump the named type. 2) Add a #pragma clang __debug dump X, that dumps the lookup results for X in the current context. Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td cfe/trunk/include/clang/Basic/TokenKinds.def cfe/trunk/include/clang/Parse/Parser.h cfe/trunk/include/clang/Sema/Lookup.h cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/AST/ASTDumper.cpp cfe/trunk/lib/Lex/Pragma.cpp cfe/trunk/lib/Parse/ParsePragma.cpp cfe/trunk/lib/Parse/ParseStmt.cpp cfe/trunk/lib/Parse/Parser.cpp cfe/trunk/lib/Sema/SemaLookup.cpp cfe/trunk/test/Misc/ast-dump-lookups.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=257529&r1=257528&r2=257529&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Tue Jan 12 15:59:26 2016 @@ -490,6 +490,8 @@ def warn_pragma_diagnostic_unknown_warni // - #pragma __debug def warn_pragma_debug_unexpected_command : Warning< "unexpected debug command '%0'">, InGroup; +def warn_pragma_debug_missing_argument : Warning< + "missing argument to debug command '%0'">, InGroup; def err_defined_macro_name : Error<"'defined' cannot be used as a macro name">; def err_paste_at_start : Error< Modified: cfe/trunk/include/clang/Basic/TokenKinds.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=257529&r1=257528&r2=257529&view=diff == --- cfe/trunk/include/clang/Basic/TokenKinds.def (original) +++ cfe/trunk/include/clang/Basic/TokenKinds.def Tue Jan 12 15:59:26 2016 @@ -699,6 +699,11 @@ ANNOTATION(pragma_parser_crash) // handles them. ANNOTATION(pragma_captured) +// Annotation for #pragma clang __debug dump... +// The lexer produces these so that the parser and semantic analysis can +// look up and dump the operand. +ANNOTATION(pragma_dump) + // Annotation for #pragma ms_struct... // The lexer produces these so that they only take effect when the parser // handles them. Modified: cfe/trunk/include/clang/Parse/Parser.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=257529&r1=257528&r2=257529&view=diff == --- cfe/trunk/include/clang/Parse/Parser.h (original) +++ cfe/trunk/include/clang/Parse/Parser.h Tue Jan 12 15:59:26 2016 @@ -502,6 +502,10 @@ private: void HandlePragmaAlign(); /// \brief Handle the annotation token produced for + /// #pragma clang __debug dump... + void HandlePragmaDump(); + + /// \brief Handle the annotation token produced for /// #pragma weak id... void HandlePragmaWeak(); Modified: cfe/trunk/include/clang/Sema/Lookup.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=257529&r1=257528&r2=257529&view=diff == --- cfe/trunk/include/clang/Sema/Lookup.h (original) +++ cfe/trunk/include/clang/Sema/Lookup.h Tue Jan 12 15:59:26 2016 @@ -515,6 +515,7 @@ public: configure(); } + void dump(); void print(raw_ostream &); /// Suppress the diagnostics that would normally fire because of this Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=257529&r1=257528&r2=257529&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Tue Jan 12 15:59:26 2016 @@ -7629,6 +7629,9 @@ public: void ActOnPragmaMSInitSeg(SourceLocation PragmaLocation, StringLiteral *SegmentName); + /// \brief Called on #pragma clang __debug dump II + void ActOnPragmaDump(Scope *S, SourceLocation Loc, IdentifierInfo *II); + /// ActOnPragmaDetectMismatch - Call on well-formed \#pragma detect_mismatch void ActOnPragmaDetectMismatch(StringRef Name, StringRef Value); Modified: cfe/trunk/lib/AST/ASTDumper.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=257529&r1=257528&r2=257529&view=diff == --- cfe/trunk/lib/AST/ASTDumper.cpp (original) +++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Jan 12 15:59:26 2016 @@ -1055,6 +1055,7 @@ void ASTDumper::VisitTypedefDecl(const T dumpType(D->getUnderlyingType()); if (D->isModulePrivate()) OS << " __module
Re: [PATCH] D16097: [CUDA] Add explicit mapping from sm_XX to compute_YY.
echristo added a comment. As long as the list of BAD things is somewhat conclusive I don't mind either way. Just making sure that this was the reason :) -eric http://reviews.llvm.org/D16097 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16097: [CUDA] Add explicit mapping from sm_XX to compute_YY.
jlebar added a comment. In http://reviews.llvm.org/D16097#325093, @echristo wrote: > Seems reasonable. Why remove all of the tests though? Previously we were checking that the arch was of the form /^sm_\d+$/ -- now we're checking that it's one of some list of acceptable things. I figured that the edge-casey tests aren't as useful in that latter case, but I can add them back if you like, not a big deal. http://reviews.llvm.org/D16097 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r249995 - [Sema] Allow C conversions in C overload logic
Sorry for the delayed response; one of my filters silently marked this mail as read. Looking into it now. :) On Fri, Jan 8, 2016 at 12:38 PM, Bob Wilson wrote: > George, > > This change caused a serious regression for Objective-C method lookup. See > PR26085 (http://llvm.org/pr26085). > > For the test case in that PR, Sema::SelectBestMethod looks at the two > candidate "test" methods. It will match the second one, but in the process > of considering the first candidate, an error diagnostic is generated. This > happens within the call to CheckSingleAssignmentConstraints that was added > here in IsStandardConversion. The "Diagnose" argument in that call is set > to false, but the diagnostic is generated anyway. For the test case in the > PR, the diagnostic comes from CheckObjCARCConversion, but it looks like > there are some other diagnostics that could also be generated from within > CheckSingleAssignmentConstraints. > > I think I could manage a fix, e.g., by threading the “Diagnose” flag > through all the relevant code and consistently checking it before emitting > diagnostics, but I’m not especially familiar with this part of clang. If > you or someone else who knows more about this area can figure out the best > way to fix it, I would appreciate it. > > —Bob > > > On Oct 11, 2015, at 1:13 PM, George Burgess IV via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > > > > Author: gbiv > > Date: Sun Oct 11 15:13:20 2015 > > New Revision: 249995 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=249995&view=rev > > Log: > > [Sema] Allow C conversions in C overload logic > > > > C allows for some implicit conversions that C++ does not, e.g. void* -> > > char*. This patch teaches clang that these conversions are okay when > > dealing with overloads in C. > > > > Differential Revision: http://reviews.llvm.org/D13604 > > > > Modified: > >cfe/trunk/include/clang/Sema/Overload.h > >cfe/trunk/include/clang/Sema/Sema.h > >cfe/trunk/lib/Sema/SemaExpr.cpp > >cfe/trunk/lib/Sema/SemaOverload.cpp > >cfe/trunk/test/Sema/overloadable.c > > > > Modified: cfe/trunk/include/clang/Sema/Overload.h > > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Overload.h?rev=249995&r1=249994&r2=249995&view=diff > > > == > > --- cfe/trunk/include/clang/Sema/Overload.h (original) > > +++ cfe/trunk/include/clang/Sema/Overload.h Sun Oct 11 15:13:20 2015 > > @@ -83,7 +83,8 @@ namespace clang { > > ICK_TransparentUnionConversion, ///< Transparent Union Conversions > > ICK_Writeback_Conversion, ///< Objective-C ARC writeback conversion > > ICK_Zero_Event_Conversion, ///< Zero constant to event (OpenCL1.2 > 6.12.10) > > -ICK_Num_Conversion_Kinds ///< The number of conversion kinds > > +ICK_C_Only_Conversion, ///< Conversions allowed in C, but not > C++ > > +ICK_Num_Conversion_Kinds, ///< The number of conversion kinds > > }; > > > > /// ImplicitConversionRank - The rank of an implicit conversion > > @@ -95,7 +96,9 @@ namespace clang { > > ICR_Promotion, ///< Promotion > > ICR_Conversion, ///< Conversion > > ICR_Complex_Real_Conversion, ///< Complex <-> Real conversion > > -ICR_Writeback_Conversion ///< ObjC ARC writeback conversion > > +ICR_Writeback_Conversion,///< ObjC ARC writeback conversion > > +ICR_C_Conversion ///< Conversion only allowed in the C > standard. > > + /// (e.g. void* to char*) > > }; > > > > ImplicitConversionRank GetConversionRank(ImplicitConversionKind Kind); > > > > Modified: cfe/trunk/include/clang/Sema/Sema.h > > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=249995&r1=249994&r2=249995&view=diff > > > == > > --- cfe/trunk/include/clang/Sema/Sema.h (original) > > +++ cfe/trunk/include/clang/Sema/Sema.h Sun Oct 11 15:13:20 2015 > > @@ -8292,19 +8292,23 @@ public: > >QualType LHSType, > >QualType RHSType); > > > > - /// Check assignment constraints and prepare for a conversion of the > > - /// RHS to the LHS type. > > + /// Check assignment constraints and optionally prepare for a > conversion of > > + /// the RHS to the LHS type. The conversion is prepared for if > ConvertRHS > > + /// is true. > > AssignConvertType CheckAssignmentConstraints(QualType LHSType, > >ExprResult &RHS, > > - CastKind &Kind); > > + CastKind &Kind, > > + bool ConvertRHS = true); > > > > // CheckSingleAssignmentConstraints - Currently used by > > // CheckAssignmentOperands, and ActOnRet
Re: [PATCH] D15599: [CodeGen] Fix a crash that occurs when attribute "naked" is attached to a c++ member function
hans added a subscriber: hans. hans added a reviewer: rnk. hans added a comment. Just out of curiosity, where does this come up in practice? It seems a little backward that we're first emitting a bunch of instructions, only to remove them later. It would be nice if for naked function we wouldn't emit them in the first place. But maybe that's not practical. Anyway, this seems OK to me but I'd like to hear what Reid thinks too. Comment at: lib/CodeGen/CodeGenFunction.cpp:1954 @@ +1953,3 @@ + // Erase all allocas and their users. + for (auto I = EntryBB->begin(); &*I != &*AllocaInsertPt; ++I) +if (auto Alloca = dyn_cast(&*I)) would declaring I as llvm::Instruction* allow you to get rid off the "&*" stuff here and below? If so, same for "auto BB" further down. Comment at: lib/CodeGen/CodeGenFunction.cpp:1972 @@ +1971,3 @@ + ++BB; +else { + BB++->eraseFromParent(); i don't think there's any need for curlies around the else branch here, especially since there are none for the then-branch http://reviews.llvm.org/D15599 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16097: [CUDA] Add explicit mapping from sm_XX to compute_YY.
echristo added a comment. Seems reasonable. Why remove all of the tests though? http://reviews.llvm.org/D16097 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D8149: Add hasUnderlyingType narrowing matcher for TypedefDecls, functionProtoType matcher for FunctionProtoType nodes, extend parameterCountIs to FunctionProtoType nodes
sbenza added inline comments. Comment at: unittests/ASTMatchers/ASTMatchersTest.cpp:4994 @@ +4993,3 @@ + EXPECT_TRUE(matches("typedef int hasUnderlyingTypeTest;", + typedefDecl(hasUnderlyingType(asString("int"); + EXPECT_TRUE(matches("typedef const int T;", aaron.ballman wrote: > LegalizeAdulthood wrote: > > aaron.ballman wrote: > > > LegalizeAdulthood wrote: > > > > aaron.ballman wrote: > > > > > Thank you for those examples! Given the following code: > > > > > ``` > > > > > typedef int foo; > > > > > typedef foo bar; > > > > > > > > > > bar i; > > > > > ``` > > > > > clang-query> match varDecl(hasType(asString("int"))) > > > > > 0 matches. > > > > > clang-query> match varDecl(hasType(asString("foo"))) > > > > > 0 matches. > > > > > clang-query> match varDecl(hasType(asString("bar"))) > > > > > > > > > > Match #1: > > > > > > > > > > E:\Desktop\t.cpp:4:1: note: "root" binds here > > > > > bar i; > > > > > ^ > > > > > 1 match. > > > > > > > > > > So hasType() looks at what the immediate type is for the declaration > > > > > (which we document, yay us!). Based on that, I don't think > > > > > hasUnderlyingType() makes sense -- you should modify hasType() to > > > > > work on a TypedefNameDecl (not just a TypedefDecl!) so that it looks > > > > > at the immediate type of the type definition. I would expect your > > > > > tests then to result in: > > > > > ``` > > > > > 1: typedef void (fn)(void); > > > > > 2: typedef fn foo; > > > > > 3: typedef int bar; > > > > > 4: typedef int (f); > > > > > 5: typedef int (fn2)(int); > > > > > clang-query> match typedefDecl(hasType(asString("int"))) > > > > > > > > > > Match #1: > > > > > > > > > > /tmp/a.cpp:3:1: note: "root" binds here > > > > > typedef int bar; > > > > > ^~~ > > > > > > > > > > Match #2: > > > > > > > > > > /tmp/a.cpp:4:1: note: "root" binds here > > > > > typedef int (f); > > > > > ^~~ > > > > > 2 matches. > > > > > clang-query> match typedefDecl(hasType(typedefType())) > > > > > > > > > > Match #1: > > > > > > > > > > /tmp/a.cpp:2:1: note: "root" binds here > > > > > typedef fn foo; > > > > > ^~ > > > > > 1 match. > > > > > clang-query> match typedefDecl(hasType(parenType())) > > > > > > > > > > Match #1: > > > > > > > > > > /tmp/a.cpp:1:1: note: "root" binds here > > > > > typedef void (fn)(void); > > > > > ^~~ > > > > > > > > > > Match #2: > > > > > > > > > > /tmp/a.cpp:4:1: note: "root" binds here > > > > > typedef int (f); > > > > > ^~~ > > > > > > > > > > Match #3: > > > > > > > > > > /tmp/a.cpp:5:1: note: "root" binds here > > > > > typedef int (fn2)(int); > > > > > ^~ > > > > > 3 matches. > > > > > clang-query> match > > > > > typedefDecl(hasType(parenType(innerType(functionType() > > > > > > > > > > Match #1: > > > > > > > > > > /tmp/a.cpp:1:1: note: "root" binds here > > > > > typedef void (fn)(void); > > > > > ^~~ > > > > > > > > > > Match #2: > > > > > > > > > > /tmp/a.cpp:5:1: note: "root" binds here > > > > > typedef int (fn2)(int); > > > > > ^~ > > > > > 2 matches. > > > > > ``` > > > > > The end results are the same, so this is just changing the way the > > > > > information is surfaced to the user that is logically consistent. > > > > > ValueDecls have an immediate type, and so do TypedefDecls. By using > > > > > TypedefNameDecl instead of TypedefDecl, this also covers the case > > > > > where hasType() is useful for an alias-declaration. (We don't expose > > > > > the matcher for that yet, but it seems quite reasonable to add in the > > > > > future, and it would be nice for hasType to automatically work with > > > > > that.) > > > > > > > > > > You can implement this with a helper function to handle abstracting > > > > > away the call to getType() vs getUnderlyingType(), then updating the > > > > > hasType() matchers to use it. Something like: > > > > > ``` > > > > > template > > > > > struct UnderlyingTypeGetter { > > > > > static QualType get(const Ty &Node) { > > > > > return Node.getType(); > > > > > } > > > > > }; > > > > > > > > > > template <> > > > > > QualType UnderlyingTypeGetter::get(const > > > > > TypedefNameDecl &Node) { > > > > > return Node.getUnderlyingType(); > > > > > } > > > > > ``` > > > > > (Somewhere in ASTMatchersInternal.h most likely.) > > > > > > > > > When I try to extend `hasType` to work on `TypedefDecl`, I get this > > > > error: > > > > > > > > ``` > > > > error: static assertion failed: right polymorphic conversion > > > > static_assert(TypeListContainsSuperOf::value, > > > > ``` > > > > > > > > ...because `TypedefDecl` is derived from `NamedDecl` and the existing > > > > definition for `hasType` looks like this: > > > > > > > > ``` > > > > AST_POLYMORPHIC_MATCHER_P_OVERLOAD(hasType, > > > >AST_POLYMORPHIC_SUPPOR
[clang-tools-extra] r257522 - Add extra tests for handling throw() and noexcept() specifiers.
Author: aaronballman Date: Tue Jan 12 15:08:27 2016 New Revision: 257522 URL: http://llvm.org/viewvc/llvm-project?rev=257522&view=rev Log: Add extra tests for handling throw() and noexcept() specifiers. Patch by Adrian Zgorzałek Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-use-override.cpp Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-use-override.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-override.cpp?rev=257522&r1=257521&r2=257522&view=diff == --- clang-tools-extra/trunk/test/clang-tidy/modernize-use-override.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-override.cpp Tue Jan 12 15:08:27 2016 @@ -37,6 +37,9 @@ struct Base { virtual void cv() const volatile; virtual void cv2() const volatile; + + virtual void ne() noexcept(false); + virtual void t() throw(); }; struct SimpleCases : public Base { @@ -104,6 +107,14 @@ public: virtual void o() __attribute__((unused)); // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using // CHECK-FIXES: {{^}} void o() override __attribute__((unused)); + + virtual void ne() noexcept(false); + // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using + // CHECK-FIXES: {{^}} void ne() noexcept(false) override; + + virtual void t() throw(); + // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using + // CHECK-FIXES: {{^}} void t() throw() override; }; // CHECK-MESSAGES-NOT: warning: ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15444: [clang-modernize] AddOverride: tests for handling throw() and noexcept() specifiers
aaron.ballman closed this revision. aaron.ballman added a comment. Commit in r257522 http://reviews.llvm.org/D15444 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15444: [clang-modernize] AddOverride: tests for handling throw() and noexcept() specifiers
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. LGTM, thanks! http://reviews.llvm.org/D15444 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15443: Fix getLocEnd for function declarations with exception specification.
aaron.ballman closed this revision. aaron.ballman added a comment. Commit in r257521 http://reviews.llvm.org/D15443 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r257521 - Properly track the end location of an exception specification.
Author: aaronballman Date: Tue Jan 12 15:04:22 2016 New Revision: 257521 URL: http://llvm.org/viewvc/llvm-project?rev=257521&view=rev Log: Properly track the end location of an exception specification. Patch by Adrian Zgorzałek Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp cfe/trunk/unittests/AST/SourceLocationTest.cpp Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=257521&r1=257520&r2=257521&view=diff == --- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original) +++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Tue Jan 12 15:04:22 2016 @@ -3363,7 +3363,8 @@ Parser::tryParseExceptionSpecification(b ConsumeAndStoreUntil(tok::r_paren, *ExceptionSpecTokens, /*StopAtSemi=*/true, /*ConsumeFinalToken=*/true); -SpecificationRange.setEnd(Tok.getLocation()); +SpecificationRange.setEnd(ExceptionSpecTokens->back().getLocation()); + return EST_Unparsed; } Modified: cfe/trunk/unittests/AST/SourceLocationTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/SourceLocationTest.cpp?rev=257521&r1=257520&r2=257521&view=diff == --- cfe/trunk/unittests/AST/SourceLocationTest.cpp (original) +++ cfe/trunk/unittests/AST/SourceLocationTest.cpp Tue Jan 12 15:04:22 2016 @@ -542,5 +542,43 @@ TEST(ObjCMessageExpr, CXXConstructExprRa cxxConstructExpr(), Lang_OBJCXX)); } +TEST(FunctionDecl, FunctionDeclWithThrowSpecification) { + RangeVerifier Verifier; + Verifier.expectRange(1, 1, 1, 16); + EXPECT_TRUE(Verifier.match( + "void f() throw();\n", + functionDecl())); +} + +TEST(FunctionDecl, FunctionDeclWithNoExceptSpecification) { + RangeVerifier Verifier; + Verifier.expectRange(1, 1, 1, 24); + EXPECT_TRUE(Verifier.match( + "void f() noexcept(false);\n", + functionDecl(), + Language::Lang_CXX11)); +} + +TEST(CXXMethodDecl, CXXMethodDeclWithThrowSpecification) { + RangeVerifier Verifier; + Verifier.expectRange(2, 1, 2, 16); + EXPECT_TRUE(Verifier.match( + "class A {\n" + "void f() throw();\n" + "};\n", + functionDecl())); +} + +TEST(CXXMethodDecl, CXXMethodDeclWithNoExceptSpecification) { + RangeVerifier Verifier; + Verifier.expectRange(2, 1, 2, 24); + EXPECT_TRUE(Verifier.match( + "class A {\n" + "void f() noexcept(false);\n" + "};\n", + functionDecl(), + Language::Lang_CXX11)); +} + } // end namespace ast_matchers } // end namespace clang ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r257520 - Module debugging: Make the module format part of the module hash instead
Author: adrian Date: Tue Jan 12 15:01:56 2016 New Revision: 257520 URL: http://llvm.org/viewvc/llvm-project?rev=257520&view=rev Log: Module debugging: Make the module format part of the module hash instead of the file name. This is consistent with how other HeaderSearchOptions are handled. Due to the other inputs of the module hash (revision number) this is not really testable in a meaningful way. Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/lib/Lex/HeaderSearch.cpp Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=257520&r1=257519&r2=257520&view=diff == --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original) +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Jan 12 15:01:56 2016 @@ -2202,8 +2202,11 @@ std::string CompilerInvocation::getModul code = hash_combine(code, I->first, I->second); } - // Extend the signature with the sysroot. - code = hash_combine(code, hsOpts.Sysroot, hsOpts.UseBuiltinIncludes, + // Extend the signature with the sysroot and other header search options. + code = hash_combine(code, hsOpts.Sysroot, + hsOpts.ModuleFormat, + hsOpts.UseDebugInfo, + hsOpts.UseBuiltinIncludes, hsOpts.UseStandardSystemIncludes, hsOpts.UseStandardCXXIncludes, hsOpts.UseLibcxx); Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=257520&r1=257519&r2=257520&view=diff == --- cfe/trunk/lib/Lex/HeaderSearch.cpp (original) +++ cfe/trunk/lib/Lex/HeaderSearch.cpp Tue Jan 12 15:01:56 2016 @@ -153,8 +153,7 @@ std::string HeaderSearch::getModuleFileN auto FileName = llvm::sys::path::filename(ModuleMapPath); llvm::hash_code Hash = - llvm::hash_combine(DirName.lower(), FileName.lower(), - HSOpts->ModuleFormat, HSOpts->UseDebugInfo); + llvm::hash_combine(DirName.lower(), FileName.lower()); SmallString<128> HashStr; llvm::APInt(64, size_t(Hash)).toStringUnsigned(HashStr, /*Radix*/36); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15636: Reduce false positives in printf/scanf format checker
AndyG added a comment. Bump! :o) http://reviews.llvm.org/D15636 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r257516 - Don't store CGOpenMPRegionInfo::CodeGen as a reference (PR26078)
Author: hans Date: Tue Jan 12 14:54:36 2016 New Revision: 257516 URL: http://llvm.org/viewvc/llvm-project?rev=257516&view=rev Log: Don't store CGOpenMPRegionInfo::CodeGen as a reference (PR26078) The referenced llvm::function_ref object can go away before CodeGen is used, resulting in a crash. Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=257516&r1=257515&r2=257516&view=diff == --- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original) +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Tue Jan 12 14:54:36 2016 @@ -84,7 +84,7 @@ public: protected: CGOpenMPRegionKind RegionKind; - const RegionCodeGenTy &CodeGen; + RegionCodeGenTy CodeGen; OpenMPDirectiveKind Kind; bool HasCancel; }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r257512 - [modules] Don't diagnose a conflict between two using-declarations that name equivalent internal linkage entities.
Author: rsmith Date: Tue Jan 12 14:34:32 2016 New Revision: 257512 URL: http://llvm.org/viewvc/llvm-project?rev=257512&view=rev Log: [modules] Don't diagnose a conflict between two using-declarations that name equivalent internal linkage entities. Added: cfe/trunk/test/Modules/Inputs/using-decl-redecl/d.h Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp cfe/trunk/test/Modules/Inputs/using-decl-redecl/a.h cfe/trunk/test/Modules/Inputs/using-decl-redecl/module.modulemap cfe/trunk/test/Modules/using-decl-redecl.cpp Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=257512&r1=257511&r2=257512&view=diff == --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Jan 12 14:34:32 2016 @@ -7797,6 +7797,10 @@ bool Sema::CheckUsingShadowDecl(UsingDec if (UsingShadowDecl *Shadow = dyn_cast(*I)) PrevShadow = Shadow; FoundEquivalentDecl = true; +} else if (isEquivalentInternalLinkageDeclaration(D, Target)) { + // We don't conflict with an existing using shadow decl of an equivalent + // declaration, but we're not a redeclaration of it. + FoundEquivalentDecl = true; } if (isVisible(D)) Modified: cfe/trunk/test/Modules/Inputs/using-decl-redecl/a.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/using-decl-redecl/a.h?rev=257512&r1=257511&r2=257512&view=diff == --- cfe/trunk/test/Modules/Inputs/using-decl-redecl/a.h (original) +++ cfe/trunk/test/Modules/Inputs/using-decl-redecl/a.h Tue Jan 12 14:34:32 2016 @@ -1,2 +1,3 @@ struct string {}; -namespace N { typedef ::string clstring; } +const int n = 0; +namespace N { typedef ::string clstring; using ::n; } Added: cfe/trunk/test/Modules/Inputs/using-decl-redecl/d.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/using-decl-redecl/d.h?rev=257512&view=auto == --- cfe/trunk/test/Modules/Inputs/using-decl-redecl/d.h (added) +++ cfe/trunk/test/Modules/Inputs/using-decl-redecl/d.h Tue Jan 12 14:34:32 2016 @@ -0,0 +1 @@ +#include "a.h" Modified: cfe/trunk/test/Modules/Inputs/using-decl-redecl/module.modulemap URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/using-decl-redecl/module.modulemap?rev=257512&r1=257511&r2=257512&view=diff == --- cfe/trunk/test/Modules/Inputs/using-decl-redecl/module.modulemap (original) +++ cfe/trunk/test/Modules/Inputs/using-decl-redecl/module.modulemap Tue Jan 12 14:34:32 2016 @@ -1,3 +1,4 @@ module a { header "a.h" } -module b { header "b.h" export * } -module c { header "c.h" export * } +module b { header "b.h" export a } +module c { header "c.h" export a export b } +module d { header "d.h" } Modified: cfe/trunk/test/Modules/using-decl-redecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/using-decl-redecl.cpp?rev=257512&r1=257511&r2=257512&view=diff == --- cfe/trunk/test/Modules/using-decl-redecl.cpp (original) +++ cfe/trunk/test/Modules/using-decl-redecl.cpp Tue Jan 12 14:34:32 2016 @@ -2,10 +2,20 @@ // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t \ // RUN: -fmodule-map-file=%S/Inputs/using-decl-redecl/module.modulemap \ // RUN:-I%S/Inputs/using-decl-redecl \ +// RUN:-Wno-modules-ambiguous-internal-linkage \ // RUN:-verify %s + +#include "d.h" + +const int n = 0; +namespace M { using ::n; } + #include "c.h" + N::clstring y = b; // Use a typo to trigger import of all declarations in N. N::clstrinh s; // expected-error {{did you mean 'clstring'}} -// expected-note@a.h:2 {{here}} +// expected-note@a.h:3 {{here}} + +namespace M { using N::n; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15823: Support virtual-near-miss check.
congliu updated this revision to Diff 44661. congliu added a comment. - Removed braces; corrected comments; updated test. http://reviews.llvm.org/D15823 Files: clang-tidy/misc/CMakeLists.txt clang-tidy/misc/MiscTidyModule.cpp clang-tidy/misc/VirtualNearMissCheck.cpp clang-tidy/misc/VirtualNearMissCheck.h docs/clang-tidy/checks/list.rst docs/clang-tidy/checks/misc-virtual-near-miss.rst test/clang-tidy/misc-virtual-near-miss.cpp Index: test/clang-tidy/misc-virtual-near-miss.cpp === --- /dev/null +++ test/clang-tidy/misc-virtual-near-miss.cpp @@ -0,0 +1,65 @@ +// RUN: %check_clang_tidy %s misc-virtual-near-miss %t + +struct Base { + virtual void func(); + virtual void gunk(); +}; + +struct Derived : Base { + // Should not warn "do you want to override 'gunk'?", because gunk is already + // overriden by this class. + virtual void funk(); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Derived::funk' has a similar name and the same signature as virtual method 'Base::func'; did you mean to override it? [misc-virtual-near-miss] + + void func2(); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Derived::func2' has {{.*}} 'Base::func' + + void func22(); // Should not warn. + + void gunk(); // Should not warn: gunk is override. + + void fun(); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Derived::fun' has {{.*}} 'Base::func' +}; + +class Father { +public: + Father(); + virtual void func(); + virtual Father *create(int i); + virtual Base &&generate(); +}; + +class Mother { +public: + Mother(); + static void method(); + virtual int method(int argc, const char **argv); + virtual int method(int argc) const; +}; + +class Child : private Father, private Mother { +public: + Child(); + + virtual void func2(); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::func2' has {{.*}} 'Father::func' + + int methoe(int x, char **strs); // Should not warn: parameter types don't match. + + int methoe(int x); // Should not warn: method is not const. + + void methof(int x, const char **strs); // Should not warn: return types don't match. + + int methoh(int x, const char **strs); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::methoh' has {{.*}} 'Mother::method' + + virtual Child *creat(int i); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::creat' has {{.*}} 'Father::create' + + virtual Derived &&generat(); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::generat' has {{.*}} 'Father::generate' + +private: + void funk(); // Should not warn: access qualifers don't match. +}; Index: docs/clang-tidy/checks/misc-virtual-near-miss.rst === --- /dev/null +++ docs/clang-tidy/checks/misc-virtual-near-miss.rst @@ -0,0 +1,17 @@ +misc-virtual-near-miss +== + +Warn if a function is a near miss (ie. the name is very similar and the function signiture is the same) to a virtual function from a base class. + +Example: + +.. code-block:: c++ + + struct Base { +virtual void func(); + }; + + struct Derived : Base { +virtual funk(); +// warning: Do you want to override 'func'? + }; Index: docs/clang-tidy/checks/list.rst === --- docs/clang-tidy/checks/list.rst +++ docs/clang-tidy/checks/list.rst @@ -56,6 +56,7 @@ misc-unused-alias-decls misc-unused-parameters misc-unused-raii + misc-virtual-near-miss modernize-loop-convert modernize-make-unique modernize-pass-by-value Index: clang-tidy/misc/VirtualNearMissCheck.h === --- /dev/null +++ clang-tidy/misc/VirtualNearMissCheck.h @@ -0,0 +1,65 @@ +//===--- VirtualNearMissCheck.h - clang-tidy-*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_VIRTUAL_NEAR_MISS_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_VIRTUAL_NEAR_MISS_H + +#include "../ClangTidy.h" +#include +#include + +namespace clang { +namespace tidy { +namespace misc { + +/// \brief Checks for near miss of virtual methods. +/// +/// For a method in a derived class, this check looks for virtual method with a +/// very similar name and an identical signature defined in a base class. +/// +/// For the user-facing documentation see: +/// http://clang.llvm.org/extra/clang-tidy/checks/misc-virtual-near-miss.html +class VirtualNearMissCheck : public ClangTidyCheck { +public: + VirtualNearMissCheck(StringRef Name, ClangTidyContext *Context) + : ClangTidyCheck(Name, Context) {} + void registerMatchers(ast_matchers::MatchFinder
Re: [PATCH] D15823: Support virtual-near-miss check.
congliu marked 9 inline comments as done. congliu added a comment. Fixed. For next steps, I will go through the results of clangmr, find out false alarms, and fix them. Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:90 @@ +89,3 @@ +// Check ambiguity. +if (Paths.isAmbiguous(Context->getCanonicalType(BTy).getUnqualifiedType())) + return false; alexfh wrote: > I wonder whether `BTy.getCanonicalType().getUnqualifiedType()` will work here. I'm afraid they're different. [[ http://clang.llvm.org/doxygen/classclang_1_1CXXBasePaths.html#a61341e71c248072b3f5bfbd54aea6174 | CXXBasePaths.isAmbiguous ]] receives a CanQualType parameter, while BTy.getCanonicalType().getUnqualifiedType() returns a QualType object. http://reviews.llvm.org/D15823 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D8149: Add hasUnderlyingType narrowing matcher for TypedefDecls, functionProtoType matcher for FunctionProtoType nodes, extend parameterCountIs to FunctionProtoType nodes
aaron.ballman added a subscriber: sbenza. Comment at: unittests/ASTMatchers/ASTMatchersTest.cpp:4994 @@ +4993,3 @@ + EXPECT_TRUE(matches("typedef int hasUnderlyingTypeTest;", + typedefDecl(hasUnderlyingType(asString("int"); + EXPECT_TRUE(matches("typedef const int T;", LegalizeAdulthood wrote: > aaron.ballman wrote: > > LegalizeAdulthood wrote: > > > aaron.ballman wrote: > > > > Thank you for those examples! Given the following code: > > > > ``` > > > > typedef int foo; > > > > typedef foo bar; > > > > > > > > bar i; > > > > ``` > > > > clang-query> match varDecl(hasType(asString("int"))) > > > > 0 matches. > > > > clang-query> match varDecl(hasType(asString("foo"))) > > > > 0 matches. > > > > clang-query> match varDecl(hasType(asString("bar"))) > > > > > > > > Match #1: > > > > > > > > E:\Desktop\t.cpp:4:1: note: "root" binds here > > > > bar i; > > > > ^ > > > > 1 match. > > > > > > > > So hasType() looks at what the immediate type is for the declaration > > > > (which we document, yay us!). Based on that, I don't think > > > > hasUnderlyingType() makes sense -- you should modify hasType() to work > > > > on a TypedefNameDecl (not just a TypedefDecl!) so that it looks at the > > > > immediate type of the type definition. I would expect your tests then > > > > to result in: > > > > ``` > > > > 1: typedef void (fn)(void); > > > > 2: typedef fn foo; > > > > 3: typedef int bar; > > > > 4: typedef int (f); > > > > 5: typedef int (fn2)(int); > > > > clang-query> match typedefDecl(hasType(asString("int"))) > > > > > > > > Match #1: > > > > > > > > /tmp/a.cpp:3:1: note: "root" binds here > > > > typedef int bar; > > > > ^~~ > > > > > > > > Match #2: > > > > > > > > /tmp/a.cpp:4:1: note: "root" binds here > > > > typedef int (f); > > > > ^~~ > > > > 2 matches. > > > > clang-query> match typedefDecl(hasType(typedefType())) > > > > > > > > Match #1: > > > > > > > > /tmp/a.cpp:2:1: note: "root" binds here > > > > typedef fn foo; > > > > ^~ > > > > 1 match. > > > > clang-query> match typedefDecl(hasType(parenType())) > > > > > > > > Match #1: > > > > > > > > /tmp/a.cpp:1:1: note: "root" binds here > > > > typedef void (fn)(void); > > > > ^~~ > > > > > > > > Match #2: > > > > > > > > /tmp/a.cpp:4:1: note: "root" binds here > > > > typedef int (f); > > > > ^~~ > > > > > > > > Match #3: > > > > > > > > /tmp/a.cpp:5:1: note: "root" binds here > > > > typedef int (fn2)(int); > > > > ^~ > > > > 3 matches. > > > > clang-query> match > > > > typedefDecl(hasType(parenType(innerType(functionType() > > > > > > > > Match #1: > > > > > > > > /tmp/a.cpp:1:1: note: "root" binds here > > > > typedef void (fn)(void); > > > > ^~~ > > > > > > > > Match #2: > > > > > > > > /tmp/a.cpp:5:1: note: "root" binds here > > > > typedef int (fn2)(int); > > > > ^~ > > > > 2 matches. > > > > ``` > > > > The end results are the same, so this is just changing the way the > > > > information is surfaced to the user that is logically consistent. > > > > ValueDecls have an immediate type, and so do TypedefDecls. By using > > > > TypedefNameDecl instead of TypedefDecl, this also covers the case where > > > > hasType() is useful for an alias-declaration. (We don't expose the > > > > matcher for that yet, but it seems quite reasonable to add in the > > > > future, and it would be nice for hasType to automatically work with > > > > that.) > > > > > > > > You can implement this with a helper function to handle abstracting > > > > away the call to getType() vs getUnderlyingType(), then updating the > > > > hasType() matchers to use it. Something like: > > > > ``` > > > > template > > > > struct UnderlyingTypeGetter { > > > > static QualType get(const Ty &Node) { > > > > return Node.getType(); > > > > } > > > > }; > > > > > > > > template <> > > > > QualType UnderlyingTypeGetter::get(const > > > > TypedefNameDecl &Node) { > > > > return Node.getUnderlyingType(); > > > > } > > > > ``` > > > > (Somewhere in ASTMatchersInternal.h most likely.) > > > > > > > When I try to extend `hasType` to work on `TypedefDecl`, I get this error: > > > > > > ``` > > > error: static assertion failed: right polymorphic conversion > > > static_assert(TypeListContainsSuperOf::value, > > > ``` > > > > > > ...because `TypedefDecl` is derived from `NamedDecl` and the existing > > > definition for `hasType` looks like this: > > > > > > ``` > > > AST_POLYMORPHIC_MATCHER_P_OVERLOAD(hasType, > > >AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, > > > > > > ValueDecl), > > >internal::Matcher, InnerMatcher, > > > 1) { > > > return qualType(hasDeclaration(InnerMatcher)) > > > .matches(Node.getType(), Fin
Re: [PATCH] D15443: Fix getLocEnd for function declarations with exception specification.
adek05 added a comment. Would you mind committing it for me, and I don't have a commit access yet. Also, could you take a look at http://reviews.llvm.org/D15444 with tests for clang-tidy related to this change? http://reviews.llvm.org/D15443 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15862: A possible direction for fixing https://llvm.org/bugs/show_bug.cgi?id=25973.
mclow.lists updated this revision to Diff 44659. mclow.lists added a comment. Made all iterators "noexcept" when building with exceptions turned off. http://reviews.llvm.org/D15862 Files: include/algorithm include/iterator include/string test/libcxx/iterators/trivial_iterators.pass.cpp test/std/strings/basic.string/string.modifiers/string_append/initializer_list.pass.cpp test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp test/std/strings/basic.string/string.modifiers/string_append/pointer.pass.cpp test/std/strings/basic.string/string.modifiers/string_append/pointer_size.pass.cpp test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp test/std/strings/basic.string/string.modifiers/string_append/size_char.pass.cpp test/std/strings/basic.string/string.modifiers/string_append/string.pass.cpp test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp test/std/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp test/std/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp test/std/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp test/std/strings/basic.string/string.modifiers/string_assign/rv_string.pass.cpp test/std/strings/basic.string/string.modifiers/string_assign/size_char.pass.cpp test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp test/std/strings/basic.string/string.modifiers/string_insert/iter_char.pass.cpp test/std/strings/basic.string/string.modifiers/string_insert/iter_initializer_list.pass.cpp test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp test/std/strings/basic.string/string.modifiers/string_insert/iter_size_char.pass.cpp test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_initializer_list.pass.cpp test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer_size.pass.cpp test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp test/support/test_iterators.h Index: test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp === --- test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp +++ test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp @@ -5903,7 +5903,7 @@ test54(); test55(); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; test0(); Index: test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp === --- test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp +++ test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp @@ -362,7 +362,7 @@ test1(); test2(); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; test0(); Index: test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp === --- test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp +++ test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp @@ -364,7 +364,7 @@ test1(); t
Re: [PATCH] D15862: A possible direction for fixing https://llvm.org/bugs/show_bug.cgi?id=25973.
rsmith added inline comments. Comment at: include/iterator:442 @@ +441,3 @@ +struct __is_exactly_input_iterator +: public integral_constant::iterator_category, input_iterator_tag>::value> {}; + Is it permitted for people to derive their own tag types from input_iterator_tag and use them here? Perhaps "not (derived from) forward_iterator_tag" would be more robust? http://reviews.llvm.org/D15862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D8149: Add hasUnderlyingType narrowing matcher for TypedefDecls, functionProtoType matcher for FunctionProtoType nodes, extend parameterCountIs to FunctionProtoType nodes
LegalizeAdulthood added inline comments. Comment at: unittests/ASTMatchers/ASTMatchersTest.cpp:4994 @@ +4993,3 @@ + EXPECT_TRUE(matches("typedef int hasUnderlyingTypeTest;", + typedefDecl(hasUnderlyingType(asString("int"); + EXPECT_TRUE(matches("typedef const int T;", aaron.ballman wrote: > LegalizeAdulthood wrote: > > aaron.ballman wrote: > > > Thank you for those examples! Given the following code: > > > ``` > > > typedef int foo; > > > typedef foo bar; > > > > > > bar i; > > > ``` > > > clang-query> match varDecl(hasType(asString("int"))) > > > 0 matches. > > > clang-query> match varDecl(hasType(asString("foo"))) > > > 0 matches. > > > clang-query> match varDecl(hasType(asString("bar"))) > > > > > > Match #1: > > > > > > E:\Desktop\t.cpp:4:1: note: "root" binds here > > > bar i; > > > ^ > > > 1 match. > > > > > > So hasType() looks at what the immediate type is for the declaration > > > (which we document, yay us!). Based on that, I don't think > > > hasUnderlyingType() makes sense -- you should modify hasType() to work on > > > a TypedefNameDecl (not just a TypedefDecl!) so that it looks at the > > > immediate type of the type definition. I would expect your tests then to > > > result in: > > > ``` > > > 1: typedef void (fn)(void); > > > 2: typedef fn foo; > > > 3: typedef int bar; > > > 4: typedef int (f); > > > 5: typedef int (fn2)(int); > > > clang-query> match typedefDecl(hasType(asString("int"))) > > > > > > Match #1: > > > > > > /tmp/a.cpp:3:1: note: "root" binds here > > > typedef int bar; > > > ^~~ > > > > > > Match #2: > > > > > > /tmp/a.cpp:4:1: note: "root" binds here > > > typedef int (f); > > > ^~~ > > > 2 matches. > > > clang-query> match typedefDecl(hasType(typedefType())) > > > > > > Match #1: > > > > > > /tmp/a.cpp:2:1: note: "root" binds here > > > typedef fn foo; > > > ^~ > > > 1 match. > > > clang-query> match typedefDecl(hasType(parenType())) > > > > > > Match #1: > > > > > > /tmp/a.cpp:1:1: note: "root" binds here > > > typedef void (fn)(void); > > > ^~~ > > > > > > Match #2: > > > > > > /tmp/a.cpp:4:1: note: "root" binds here > > > typedef int (f); > > > ^~~ > > > > > > Match #3: > > > > > > /tmp/a.cpp:5:1: note: "root" binds here > > > typedef int (fn2)(int); > > > ^~ > > > 3 matches. > > > clang-query> match > > > typedefDecl(hasType(parenType(innerType(functionType() > > > > > > Match #1: > > > > > > /tmp/a.cpp:1:1: note: "root" binds here > > > typedef void (fn)(void); > > > ^~~ > > > > > > Match #2: > > > > > > /tmp/a.cpp:5:1: note: "root" binds here > > > typedef int (fn2)(int); > > > ^~ > > > 2 matches. > > > ``` > > > The end results are the same, so this is just changing the way the > > > information is surfaced to the user that is logically consistent. > > > ValueDecls have an immediate type, and so do TypedefDecls. By using > > > TypedefNameDecl instead of TypedefDecl, this also covers the case where > > > hasType() is useful for an alias-declaration. (We don't expose the > > > matcher for that yet, but it seems quite reasonable to add in the future, > > > and it would be nice for hasType to automatically work with that.) > > > > > > You can implement this with a helper function to handle abstracting away > > > the call to getType() vs getUnderlyingType(), then updating the hasType() > > > matchers to use it. Something like: > > > ``` > > > template > > > struct UnderlyingTypeGetter { > > > static QualType get(const Ty &Node) { > > > return Node.getType(); > > > } > > > }; > > > > > > template <> > > > QualType UnderlyingTypeGetter::get(const TypedefNameDecl > > > &Node) { > > > return Node.getUnderlyingType(); > > > } > > > ``` > > > (Somewhere in ASTMatchersInternal.h most likely.) > > > > > When I try to extend `hasType` to work on `TypedefDecl`, I get this error: > > > > ``` > > error: static assertion failed: right polymorphic conversion > > static_assert(TypeListContainsSuperOf::value, > > ``` > > > > ...because `TypedefDecl` is derived from `NamedDecl` and the existing > > definition for `hasType` looks like this: > > > > ``` > > AST_POLYMORPHIC_MATCHER_P_OVERLOAD(hasType, > >AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, > > > > ValueDecl), > >internal::Matcher, InnerMatcher, > > 1) { > > return qualType(hasDeclaration(InnerMatcher)) > > .matches(Node.getType(), Finder, Builder); > > } > > ``` > > > > So I'll need some guidance on how to extend `hasType` to work for > > `TypedefNamedDecl` nodes. I don't understand exactly what all these nasty > > macros do. So far, I've simply made changes by imitation, but my approach > > didn't work this time. > This ({F1302460}) d
Re: [PATCH] D15914: [OpenCL] Pipe builtin functions
keryell added a subscriber: keryell. Comment at: include/clang/Basic/Builtins.h:39 @@ -38,2 +38,3 @@ MS_LANG = 0x10, // builtin requires MS mode. + OCLC_LANG = 0x20,// builtin for OpenCL C only. ALL_LANGUAGES = C_LANG | CXX_LANG | OBJC_LANG, // builtin for all languages. Yes, it may be useful to differentiate OpenCL C from the on-going OpenCL C++ http://reviews.llvm.org/D15914 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D8940: Clang changes for indirect call target profiling
betulb updated this revision to Diff 44657. betulb added a comment. Addressed vsk's comment on CallSite API use. http://reviews.llvm.org/D8940 Files: lib/CodeGen/CGCall.cpp lib/CodeGen/CodeGenPGO.cpp lib/CodeGen/CodeGenPGO.h test/Profile/c-indirect-call.c Index: test/Profile/c-indirect-call.c === --- /dev/null +++ test/Profile/c-indirect-call.c @@ -0,0 +1,15 @@ +// Check the data structures emitted by instrumentation. +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-indirect-call.c %s -o - -emit-llvm -fprofile-instr-generate -mllvm -enable-value-profiling | FileCheck %s + +void (*foo)(void); + +int main(void) { +// CHECK: [[REG1:%[0-9]+]] = load void ()*, void ()** @foo, align 8 +// CHECK-NEXT: call void [[REG1]]() +// CHECK-NEXT: [[REG2:%[0-9]+]] = ptrtoint void ()* [[REG1]] to i64 +// CHECK-NEXT: call void @__llvm_profile_instrument_target(i64 [[REG2]], i8* bitcast ({ i32, i32, i64, i8*, i64*, i8*, i8*, [1 x i16] }* @__profd_main to i8*), i32 0) + foo(); + return 0; +} + +// CHECK: declare void @__llvm_profile_instrument_target(i64, i8*, i32) Index: lib/CodeGen/CodeGenPGO.h === --- lib/CodeGen/CodeGenPGO.h +++ lib/CodeGen/CodeGenPGO.h @@ -19,6 +19,7 @@ #include "CodeGenTypes.h" #include "clang/Frontend/CodeGenOptions.h" #include "llvm/ADT/StringMap.h" +#include "llvm/ProfileData/InstrProfReader.h" #include "llvm/Support/MemoryBuffer.h" #include @@ -32,20 +33,22 @@ std::string FuncName; llvm::GlobalVariable *FuncNameVar; + unsigned NumValueSites[llvm::IPVK_Last + 1]; unsigned NumRegionCounters; uint64_t FunctionHash; std::unique_ptr> RegionCounterMap; std::unique_ptr> StmtCountMap; + std::unique_ptr ProfRecord; std::vector RegionCounts; uint64_t CurrentRegionCount; /// \brief A flag that is set to true when this function doesn't need /// to have coverage mapping data. bool SkipCoverageMapping; public: CodeGenPGO(CodeGenModule &CGM) - : CGM(CGM), NumRegionCounters(0), FunctionHash(0), CurrentRegionCount(0), -SkipCoverageMapping(false) {} + : CGM(CGM), NumValueSites{0}, NumRegionCounters(0), +FunctionHash(0), CurrentRegionCount(0), SkipCoverageMapping(false) {} /// Whether or not we have PGO region data for the current function. This is /// false both when we have no data at all and when our data has been @@ -87,6 +90,9 @@ /// for an unused declaration. void emitEmptyCounterMapping(const Decl *D, StringRef FuncName, llvm::GlobalValue::LinkageTypes Linkage); + // Insert instrumentation or attach profile metadata at value sites + void valueProfile(CGBuilderTy &Builder, uint32_t ValueKind, +llvm::Instruction *ValueSite, llvm::Value *ValuePtr); private: void setFuncName(llvm::Function *Fn); void setFuncName(StringRef Name, llvm::GlobalValue::LinkageTypes Linkage); Index: lib/CodeGen/CodeGenPGO.cpp === --- lib/CodeGen/CodeGenPGO.cpp +++ lib/CodeGen/CodeGenPGO.cpp @@ -18,11 +18,14 @@ #include "clang/AST/StmtVisitor.h" #include "llvm/IR/Intrinsics.h" #include "llvm/IR/MDBuilder.h" -#include "llvm/ProfileData/InstrProfReader.h" #include "llvm/Support/Endian.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/MD5.h" +static llvm::cl::opt EnableValueProfiling( + "enable-value-profiling", llvm::cl::ZeroOrMore, + llvm::cl::desc("Enable value profiling"), llvm::cl::init(false)); + using namespace clang; using namespace CodeGen; @@ -740,21 +743,104 @@ Builder.getInt32(Counter)}); } +static inline std::string getRawFuncName(std::string PrefixedFunctionName) { + // For local symbols, the main file name is prepended to the function name + // to distinguish them. + std::size_t SeparatorPosition = PrefixedFunctionName.find(":"); + if (SeparatorPosition == std::string::npos) +return PrefixedFunctionName; + return PrefixedFunctionName.substr(++SeparatorPosition); +} + +// This method either inserts a call to the profile run-time during +// instrumentation or puts profile data into metadata for PGO use. +void CodeGenPGO::valueProfile(CGBuilderTy &Builder, uint32_t ValueKind, +llvm::Instruction *ValueSite, llvm::Value *ValuePtr) { + + if (!EnableValueProfiling) +return; + + if (!ValuePtr || !ValueSite || !Builder.GetInsertBlock()) +return; + + bool InstrumentValueSites = CGM.getCodeGenOpts().ProfileInstrGenerate; + llvm::IndexedInstrProfReader *PGOReader = CGM.getPGOReader(); + if (!InstrumentValueSites && !PGOReader) +return; + + llvm::LLVMContext &Ctx = CGM.getLLVMContext(); + if (InstrumentValueSites && RegionCounterMap) { +auto *I8PtrTy = llvm::Type::getInt8PtrTy(Ctx); +llvm::Value *Args[5] = { + llvm::ConstantExpr::getBitCast(FuncNameVar, I8PtrTy), +
Re: [PATCH] D15862: A possible direction for fixing https://llvm.org/bugs/show_bug.cgi?id=25973.
mclow.lists added a comment. I think the best way to handle Richard's question is to specialize `__libcpp_string_gets_noexcept_iterator` to always return true when exceptions are turned off. http://reviews.llvm.org/D15862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r257509 - Add a clang test for r257376 (Ensure -mcpu=xscale works for arm targets).
Author: dim Date: Tue Jan 12 13:40:55 2016 New Revision: 257509 URL: http://llvm.org/viewvc/llvm-project?rev=257509&view=rev Log: Add a clang test for r257376 (Ensure -mcpu=xscale works for arm targets). Added: cfe/trunk/test/Driver/arm-xscale.c Added: cfe/trunk/test/Driver/arm-xscale.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arm-xscale.c?rev=257509&view=auto == --- cfe/trunk/test/Driver/arm-xscale.c (added) +++ cfe/trunk/test/Driver/arm-xscale.c Tue Jan 12 13:40:55 2016 @@ -0,0 +1,3 @@ +// RUN: %clang -target arm-freebsd -mcpu=xscale -### -c %s 2>&1 | FileCheck %s +// CHECK-NOT: error: the clang compiler does not support '-mcpu=xscale' +// CHECK: "-cc1"{{.*}} "-target-cpu" "xscale"{{.*}} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15862: A possible direction for fixing https://llvm.org/bugs/show_bug.cgi?id=25973.
rsmith added a comment. Would this be expected to degrade performance for people building with -fno-exceptions who use iterators with non-noexcept operations (such as LLVM and Clang)? http://reviews.llvm.org/D15862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r257506 - One more missing std:: qualification from Jonathan
Author: marshall Date: Tue Jan 12 13:15:10 2016 New Revision: 257506 URL: http://llvm.org/viewvc/llvm-project?rev=257506&view=rev Log: One more missing std:: qualification from Jonathan Modified: libcxx/trunk/test/std/utilities/function.objects/unord.hash/integral.pass.cpp Modified: libcxx/trunk/test/std/utilities/function.objects/unord.hash/integral.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/unord.hash/integral.pass.cpp?rev=257506&r1=257505&r2=257506&view=diff == --- libcxx/trunk/test/std/utilities/function.objects/unord.hash/integral.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/function.objects/unord.hash/integral.pass.cpp Tue Jan 12 13:15:10 2016 @@ -21,6 +21,7 @@ #include #include #include +#include #include template @@ -59,7 +60,7 @@ int main() test(); // LWG #2119 -test(); +test(); test(); test(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16115: [test-suite] Add ClangAnalyzerBenchmarks directory to test-suite repository
MatzeB added a comment. Putting static-analyzer tests into the test-suite sounds good to me, the static analyzer is part of llvm so this should be fine. Though I'd like to wait a bit to hear other opinions on this matter. As for the patch itself: - I'd call the directory ClangAnalyzer - For the external file you should provide a sha256 (or md5) sum and ideally check it in the download script, so other people can be sure that the reference results do indeed match the artifact being analyzed. - Why is there a subdirectory "2016-01-11-134007-41609-1" in the RefScanBuildResults directory, that name appears arbitrary for reference results. http://reviews.llvm.org/D16115 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16008: [clang-tidy] Add calling virtual functions in constructors/destructors check.
Eugene.Zelenko added a comment. See http://reviews.llvm.org/D14779 for discussion about Clang-tidy vs Static Analyzer. Repository: rL LLVM http://reviews.llvm.org/D16008 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16062: [analyzer] Rename kind-enumeration values of SVal, SymExpr, MemRegion classes, for consistency.
dcoughlin accepted this revision. dcoughlin added a comment. This revision is now accepted and ready to land. Looks good to me. Please commit! http://reviews.llvm.org/D16062 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15998: Implement __attribute__((gc_leaf_function)).
aaron.ballman added a comment. In http://reviews.llvm.org/D15998#324821, @mjacob wrote: > In http://reviews.llvm.org/D15998#324757, @aaron.ballman wrote: > > > Can you point me to some documentation on what the semantics of this > > attribute are? For instance, how does it play with other attributes (like > > naked or dllexport), is there a reason it shouldn't apply to Objective-C > > methods, etc? > > > As it was noted earlier in this review, this attribute (as its underlying > LLVM attribute) is underspecified. We should discuss the semantics (and > whether we want to keep it in the first place) of the LLVM attribute on the > mailing list. I'm not sure how we should proceed with this patch in the > meantime, probably one of: > > 1. Mark this (Clang) attribute as tentative, and remove it in case we remove > the LLVM attribute. > 2. Close this revision and create a new patch depending on the outcome of the > discussion. > 3. Postpone (but not close) this revision. Given how relatively easy this patch is at this stage, I would recommend #2 if the LLVM side of the discussion is going to take more than a month, and #3 otherwise. http://reviews.llvm.org/D15998 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r257497 - function names start with a lower case letter ; NFC
Author: spatel Date: Tue Jan 12 12:03:41 2016 New Revision: 257497 URL: http://llvm.org/viewvc/llvm-project?rev=257497&view=rev Log: function names start with a lower case letter ; NFC Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=257497&r1=257496&r2=257497&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Tue Jan 12 12:03:41 2016 @@ -79,7 +79,7 @@ CodeGenFunction::CodeGenFunction(CodeGen if (CGM.getCodeGenOpts().ReciprocalMath) { FMF.setAllowReciprocal(); } - Builder.SetFastMathFlags(FMF); + Builder.setFastMathFlags(FMF); } CodeGenFunction::~CodeGenFunction() { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15528: Teach clang-tidy how to -Werror checks.
jroelofs updated this revision to Diff 44650. jroelofs added a comment. Added docs. http://reviews.llvm.org/D15528 Files: clang-tidy/ClangTidy.cpp clang-tidy/ClangTidy.h clang-tidy/ClangTidyDiagnosticConsumer.cpp clang-tidy/ClangTidyDiagnosticConsumer.h clang-tidy/ClangTidyOptions.cpp clang-tidy/ClangTidyOptions.h clang-tidy/tool/ClangTidyMain.cpp docs/clang-tidy/index.rst test/clang-tidy/werrors-plural.cpp Index: test/clang-tidy/werrors-plural.cpp === --- test/clang-tidy/werrors-plural.cpp +++ test/clang-tidy/werrors-plural.cpp @@ -0,0 +1,15 @@ +// RUN: clang-tidy %s -checks='-*,llvm-namespace-comment' -- 2>&1 | FileCheck %s --check-prefix=CHECK-WARN +// RUN: not clang-tidy %s -checks='-*,llvm-namespace-comment' -warnings-as-errors='llvm-namespace-comment' -- 2>&1 | FileCheck %s --check-prefix=CHECK-WERR + +namespace j { +} +// CHECK-WARN: warning: namespace 'j' not terminated with a closing comment [llvm-namespace-comment] +// CHECK-WERR: error: namespace 'j' not terminated with a closing comment [llvm-namespace-comment,-warnings-as-errors] + +namespace k { +} +// CHECK-WARN: warning: namespace 'k' not terminated with a closing comment [llvm-namespace-comment] +// CHECK-WERR: error: namespace 'k' not terminated with a closing comment [llvm-namespace-comment,-warnings-as-errors] + +// CHECK-WARN-NOT: treated as +// CHECK-WERR: 2 warnings treated as errors Index: docs/clang-tidy/index.rst === --- docs/clang-tidy/index.rst +++ docs/clang-tidy/index.rst @@ -68,7 +68,9 @@ diagnostics are displayed by clang-tidy and can be filtered out using ``-checks=`` option. However, the ``-checks=`` option does not affect compilation arguments, so it can not turn on Clang warnings which are not -already turned on in build configuration. +already turned on in build configuration. The ``-warnings-as-errors=`` option +upgrades any warnings emitted under the ``-checks=`` flag to errors (but it +does not enable any checks itself). Clang diagnostics have check names starting with ``clang-diagnostic-``. Diagnostics which have a corresponding warning option, are named @@ -150,6 +152,7 @@ -checks=* to list all available checks. -p=- Build path -system-headers- Display the errors from system headers. +-warnings-as-errors= - Upgrades warnings to errors. Same format as '-checks'. -p is used to read a compile command database. Index: clang-tidy/tool/ClangTidyMain.cpp === --- clang-tidy/tool/ClangTidyMain.cpp +++ clang-tidy/tool/ClangTidyMain.cpp @@ -64,6 +64,11 @@ cl::init(""), cl::cat(ClangTidyCategory)); static cl::opt +WarningsAsErrors("warnings-as-errors", cl::desc("Upgrades warnings to errors. " +"Same format as '-checks'."), + cl::init(""), cl::cat(ClangTidyCategory)); + +static cl::opt HeaderFilter("header-filter", cl::desc("Regular expression matching the names of the\n" "headers to output diagnostics from. Diagnostics\n" @@ -227,6 +232,7 @@ ClangTidyOptions DefaultOptions; DefaultOptions.Checks = DefaultChecks; + DefaultOptions.WarningsAsErrors = ""; DefaultOptions.HeaderFilterRegex = HeaderFilter; DefaultOptions.SystemHeaders = SystemHeaders; DefaultOptions.AnalyzeTemporaryDtors = AnalyzeTemporaryDtors; @@ -238,6 +244,8 @@ ClangTidyOptions OverrideOptions; if (Checks.getNumOccurrences() > 0) OverrideOptions.Checks = Checks; + if (WarningsAsErrors.getNumOccurrences() > 0) +OverrideOptions.WarningsAsErrors = WarningsAsErrors; if (HeaderFilter.getNumOccurrences() > 0) OverrideOptions.HeaderFilterRegex = HeaderFilter; if (SystemHeaders.getNumOccurrences() > 0) @@ -322,8 +330,10 @@ const bool DisableFixes = Fix && FoundErrors && !FixErrors; + unsigned WErrorCount = 0; + // -fix-errors implies -fix. - handleErrors(Errors, (FixErrors || Fix) && !DisableFixes); + handleErrors(Errors, (FixErrors || Fix) && !DisableFixes, WErrorCount); if (!ExportFixes.empty() && !Errors.empty()) { std::error_code EC; @@ -344,6 +354,13 @@ if (EnableCheckProfile) printProfileData(Profile, llvm::errs()); + if (WErrorCount) { +StringRef Plural = WErrorCount == 1 ? "" : "s"; +llvm::errs() << WErrorCount << " warning" << Plural + << " treated as error" << Plural << "\n"; +return WErrorCount; + } + return 0; } Index: clang-tidy/ClangTidyOptions.h === --- clang-tidy/ClangTidyOptions.h +++ clang-tidy/ClangTidyOptions.h @@ -62,6 +62,9 @@ /// \brief Checks filter. llvm::Optional Checks; + /// \brief WarningsAsErrors filter. + llvm::Optional WarningsAsErrors; + //
Re: [PATCH] D15528: Teach clang-tidy how to -Werror checks.
jroelofs added a comment. In http://reviews.llvm.org/D15528#312031, @alexfh wrote: > Thank you for explaining. The use case seems to be important enough to > support it. And the solution seems to be good for now. A few concerns: > > 1. `Werrors` isn't a good name for this. The only reason why a similar thing > is called `-Werror` in compilers is that they use `-W` for warnings. I'd > suggest TreatAsErrors, WarningsAsErrors or anything similar (with the proper > casing change for the command line argument). Renamed. > 2. Documentation is missing. Working on that now. http://reviews.llvm.org/D15528 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15528: Teach clang-tidy how to -Werror checks.
jroelofs marked 9 inline comments as done. jroelofs added a comment. http://reviews.llvm.org/D15528 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15528: Teach clang-tidy how to -Werror checks.
jroelofs updated this revision to Diff 44648. jroelofs added a comment. Address review comments. http://reviews.llvm.org/D15528 Files: clang-tidy/ClangTidy.cpp clang-tidy/ClangTidy.h clang-tidy/ClangTidyDiagnosticConsumer.cpp clang-tidy/ClangTidyDiagnosticConsumer.h clang-tidy/ClangTidyOptions.cpp clang-tidy/ClangTidyOptions.h clang-tidy/tool/ClangTidyMain.cpp test/clang-tidy/werrors-plural.cpp Index: test/clang-tidy/werrors-plural.cpp === --- test/clang-tidy/werrors-plural.cpp +++ test/clang-tidy/werrors-plural.cpp @@ -0,0 +1,15 @@ +// RUN: clang-tidy %s -checks='-*,llvm-namespace-comment' -- 2>&1 | FileCheck %s --check-prefix=CHECK-WARN +// RUN: not clang-tidy %s -checks='-*,llvm-namespace-comment' -warnings-as-errors='llvm-namespace-comment' -- 2>&1 | FileCheck %s --check-prefix=CHECK-WERR + +namespace j { +} +// CHECK-WARN: warning: namespace 'j' not terminated with a closing comment [llvm-namespace-comment] +// CHECK-WERR: error: namespace 'j' not terminated with a closing comment [llvm-namespace-comment,-warnings-as-errors] + +namespace k { +} +// CHECK-WARN: warning: namespace 'k' not terminated with a closing comment [llvm-namespace-comment] +// CHECK-WERR: error: namespace 'k' not terminated with a closing comment [llvm-namespace-comment,-warnings-as-errors] + +// CHECK-WARN-NOT: treated as +// CHECK-WERR: 2 warnings treated as errors Index: clang-tidy/tool/ClangTidyMain.cpp === --- clang-tidy/tool/ClangTidyMain.cpp +++ clang-tidy/tool/ClangTidyMain.cpp @@ -64,6 +64,11 @@ cl::init(""), cl::cat(ClangTidyCategory)); static cl::opt +WarningsAsErrors("warnings-as-errors", cl::desc("Upgrades warnings to errors. " +"Same format as '-checks'."), + cl::init(""), cl::cat(ClangTidyCategory)); + +static cl::opt HeaderFilter("header-filter", cl::desc("Regular expression matching the names of the\n" "headers to output diagnostics from. Diagnostics\n" @@ -227,6 +232,7 @@ ClangTidyOptions DefaultOptions; DefaultOptions.Checks = DefaultChecks; + DefaultOptions.WarningsAsErrors = ""; DefaultOptions.HeaderFilterRegex = HeaderFilter; DefaultOptions.SystemHeaders = SystemHeaders; DefaultOptions.AnalyzeTemporaryDtors = AnalyzeTemporaryDtors; @@ -238,6 +244,8 @@ ClangTidyOptions OverrideOptions; if (Checks.getNumOccurrences() > 0) OverrideOptions.Checks = Checks; + if (WarningsAsErrors.getNumOccurrences() > 0) +OverrideOptions.WarningsAsErrors = WarningsAsErrors; if (HeaderFilter.getNumOccurrences() > 0) OverrideOptions.HeaderFilterRegex = HeaderFilter; if (SystemHeaders.getNumOccurrences() > 0) @@ -322,8 +330,10 @@ const bool DisableFixes = Fix && FoundErrors && !FixErrors; + unsigned WErrorCount = 0; + // -fix-errors implies -fix. - handleErrors(Errors, (FixErrors || Fix) && !DisableFixes); + handleErrors(Errors, (FixErrors || Fix) && !DisableFixes, WErrorCount); if (!ExportFixes.empty() && !Errors.empty()) { std::error_code EC; @@ -344,6 +354,13 @@ if (EnableCheckProfile) printProfileData(Profile, llvm::errs()); + if (WErrorCount) { +StringRef Plural = WErrorCount == 1 ? "" : "s"; +llvm::errs() << WErrorCount << " warning" << Plural + << " treated as error" << Plural << "\n"; +return WErrorCount; + } + return 0; } Index: clang-tidy/ClangTidyOptions.h === --- clang-tidy/ClangTidyOptions.h +++ clang-tidy/ClangTidyOptions.h @@ -62,6 +62,9 @@ /// \brief Checks filter. llvm::Optional Checks; + /// \brief WarningsAsErrors filter. + llvm::Optional WarningsAsErrors; + /// \brief Output warnings from headers matching this filter. Warnings from /// main files will always be displayed. llvm::Optional HeaderFilterRegex; Index: clang-tidy/ClangTidyOptions.cpp === --- clang-tidy/ClangTidyOptions.cpp +++ clang-tidy/ClangTidyOptions.cpp @@ -85,6 +85,7 @@ MappingNormalization NOpts( IO, Options.CheckOptions); IO.mapOptional("Checks", Options.Checks); +IO.mapOptional("WarningsAsErrors", Options.WarningsAsErrors); IO.mapOptional("HeaderFilterRegex", Options.HeaderFilterRegex); IO.mapOptional("AnalyzeTemporaryDtors", Options.AnalyzeTemporaryDtors); IO.mapOptional("User", Options.User); @@ -103,6 +104,7 @@ ClangTidyOptions ClangTidyOptions::getDefaults() { ClangTidyOptions Options; Options.Checks = ""; + Options.WarningsAsErrors = ""; Options.HeaderFilterRegex = ""; Options.SystemHeaders = false; Options.AnalyzeTemporaryDtors = false; @@ -123,6 +125,10 @@ Result.Checks = (Result.Checks && !Result.Checks->empty() ? *Result.Checks + "," : "") + *Oth
Re: [PATCH] D15729: Load compiler plugins in ASTUnit, too
kfunk added a comment. @realincubus: Sorry, I didn't know you had put this up for review already. So back to this patch. Yes, it works fine for me *without* amending libclang.exports. I'm injecting the arguments to `clang_parseTranslationUnit2`. See this patch here for reference: https://quickgit.kde.org/?p=kdevelop.git&a=commit&h=b299e550f6753667d415c6aea8c0b0806e954e36 (when you view the whole blob of *parsesession.cpp*, you can also see the call to `clang_parseTranslationUnit2`) http://reviews.llvm.org/D15729 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15998: Implement __attribute__((gc_leaf_function)).
mjacob added a comment. In http://reviews.llvm.org/D15998#324757, @aaron.ballman wrote: > Can you point me to some documentation on what the semantics of this > attribute are? For instance, how does it play with other attributes (like > naked or dllexport), is there a reason it shouldn't apply to Objective-C > methods, etc? As it was noted earlier in this review, this attribute (as its underlying LLVM attribute) is underspecified. We should discuss the semantics (and whether we want to keep it in the first place) of the LLVM attribute on the mailing list. I'm not sure how we should proceed with this patch in the meantime, probably one of: 1. Mark this (Clang) attribute as tentative, and remove it in case we remove the LLVM attribute. 2. Close this revision and create a new patch depending on the outcome of the discussion. 3. Postpone (but not close) this revision. Comment at: include/clang/Basic/Attr.td:2175 @@ +2174,3 @@ +def GcLeafFunction : InheritableAttr { + let Spellings = [GNU<"gc_leaf_function">]; + let Subjects = SubjectList<[Function]>; aaron.ballman wrote: > Any particular reason for this to not have a C++11 spelling under the clang > namespace, in addition to the GNU-style spelling? I'll add this in case we decide the attribute is the right approach. http://reviews.llvm.org/D15998 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15881: [DWARF] Omitting the explicit import of an anonymous namespace is a debugger-tuning decision, not a target decision.
probinson added inline comments. Comment at: lib/Frontend/CompilerInvocation.cpp:446-448 @@ -445,3 +445,5 @@ Opts.DebugTypeExtRefs = Args.hasArg(OPT_dwarf_ext_refs); - Opts.DebugExplicitImport = Triple.isPS4CPU(); + Opts.DebugExplicitImport = + Opts.getDebuggerTuning() != CodeGenOptions::DebuggerKindGDB && + Opts.getDebuggerTuning() != CodeGenOptions::DebuggerKindLLDB; probinson wrote: > echristo wrote: > > probinson wrote: > > > echristo wrote: > > > > Why not just a positive for debugger tuning SCE? > > > Because the default (i.e., no tuning specified) behavior should be to > > > conform to the DWARF spec, which basically says you need the explicit > > > import. There's a new extra RUN line in the test, with no tuning > > > specified, to verify this. > > > GDB and LLDB are the oddballs here, they implement a special case for > > > namespaces whose name meets certain criteria, and do something beyond > > > what DWARF says to do. So, the condition is written to express that. > > > > > I don't necessarily agree with that interpretation on the explicit import - > > I did skim the thread, perhaps you could highlight what makes you think > > this? > Basically, a namespace is a "context" for declarations, and the DWARF > mechanism for making declarations from one context available in another > context is with DW_TAG_imported_declaration and DW_TAG_imported_module. > The C++ spec describes the behavior "as if" there was an explicit using > directive, and DW_TAG_imported_module is the DWARF mechanism for describing a > using directive. > > The meaning of DWARF is determined by the DWARF spec, not the C++ spec, and > the DWARF spec does not say there's anything special about a namespace that > has no name. There is a perfectly reasonable DWARF mechanism for getting the > desired effect, so there's no reason for DWARF to make a special rule for an > unnamed namespace. Therefore, an anonymous namespace should be explicitly > imported into the containing namespace. The explicit import would be marked > artificial of course. > Ping. Have I missed something in the DWARF spec that makes you think my interpretation is incorrect? Wouldn't be the first time... http://reviews.llvm.org/D15881 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15729: Load compiler plugins in ASTUnit, too
realincubus added a comment. Hi. I am finally back at work and happy to see that some effort already went into the patch that i initially wrote some time ago (http://reviews.llvm.org/D5611) I just looked through the files of the new patch and noticed that the libclang.exports file is missing. As far as i understand this, the exports file defines which symbols will be visible to the linker when linking to the libclang.so library. Since some of the symbols that are needed for the plugin mechanism to work are not exported, i wrote a list of these symbols and appended theses to the libclang.exports file. **If i don't add these symbols it's impossible to load any plugin from libclang.so ** I assume that if you write a test for loading plugins via libclang you should write a test that acually uses libclang for loading plugins via its C interface (clang_parseTranslationUnit). @kfunk you said that this works for you without the additional symbols. it might be that something changed in clangs codebase and i dont have to export the symbols anymore. In the following days i will try to run my code without the symbols and write a test that uses libclangs C interface. all the best stefan kemnitz http://reviews.llvm.org/D15729 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15862: A possible direction for fixing https://llvm.org/bugs/show_bug.cgi?id=25973.
mclow.lists added a comment. Ping? I'd like to land this before the branch for release tomorrow. http://reviews.llvm.org/D15862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [libcxx] r257422 - Put the definition of _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK in the right place.
On 1/11/16 5:38 PM, Marshall Clow via cfe-commits wrote: Author: marshall Date: Mon Jan 11 18:38:04 2016 New Revision: 257422 URL: http://llvm.org/viewvc/llvm-project?rev=257422&view=rev Log: Put the definition of _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK in the right place. Modified: libcxx/trunk/include/__config Modified: libcxx/trunk/include/__config URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=257422&r1=257421&r2=257422&view=diff == --- libcxx/trunk/include/__config (original) +++ libcxx/trunk/include/__config Mon Jan 11 18:38:04 2016 @@ -433,6 +433,11 @@ namespace std { #define _LIBCPP_HAS_NO_ASAN #endif +// Allow for build-time disabling of unsigned integer sanitization +#ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK +#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute((no_sanitize("unsigned-integer-overflow"))) +#endif I get a bunch of -Wunknown-attributes warnings from this... can it be this instead? #ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK #if defined(__has_attribute) && __has_attribute(no_sanitize) #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute((no_sanitize("unsigned-integer-overflow"))) #else #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK #endif #endif Jon + #elif defined(__GNUC__) #define _ALIGNAS(x) __attribute__((__aligned__(x))) @@ -597,11 +602,6 @@ namespace std { #define _LIBCPP_HAS_NO_ASAN -// Allow for build-time disabling of unsigned integer sanitization -#ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK -#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute((no_sanitize("unsigned integer"))) -#endif - #endif // __clang__ || __GNUC__ || _MSC_VER || __IBMCPP__ #ifndef _LIBCPP_HAS_NO_NOEXCEPT ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits -- Jon Roelofs jonat...@codesourcery.com CodeSourcery / Mentor Embedded ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13304: Avoid inlining in throw statement
junbuml abandoned this revision. junbuml added a comment. Abandon this based the last comment in http://reviews.llvm.org/D15289. http://reviews.llvm.org/D13304 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16063: [Analyzer] Use a wider integer type for an array index
a.sidorin added a comment. LongLongTy is initialized as a built-in type in ASTContext and, as I understand, is always available. It is not 64-bit on some platforms (like TCE), but these platforms don't have a wider type too. http://reviews.llvm.org/D16063 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15998: Implement __attribute__((gc_leaf_function)).
aaron.ballman added a comment. Can you point me to some documentation on what the semantics of this attribute are? For instance, how does it play with other attributes (like naked or dllexport), is there a reason it shouldn't apply to Objective-C methods, etc? Comment at: include/clang/Basic/Attr.td:2175 @@ +2174,3 @@ +def GcLeafFunction : InheritableAttr { + let Spellings = [GNU<"gc_leaf_function">]; + let Subjects = SubjectList<[Function]>; Any particular reason for this to not have a C++11 spelling under the clang namespace, in addition to the GNU-style spelling? http://reviews.llvm.org/D15998 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r257474 - Add a bunch of missing includes in the test suite to make it more portable. Fixes bugs #26120 and #26121. Thanks to Jonathan Wakely for the reports and the patches.
Author: marshall Date: Tue Jan 12 08:51:04 2016 New Revision: 257474 URL: http://llvm.org/viewvc/llvm-project?rev=257474&view=rev Log: Add a bunch of missing includes in the test suite to make it more portable. Fixes bugs #26120 and #26121. Thanks to Jonathan Wakely for the reports and the patches. Modified: libcxx/trunk/test/std/containers/sequences/vector.bool/find.pass.cpp libcxx/trunk/test/std/containers/unord/unord.map/load_factor.pass.cpp libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/range_size.pass.cpp libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash.pass.cpp libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.pass.cpp libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp libcxx/trunk/test/std/containers/unord/unord.multimap/load_factor.pass.cpp libcxx/trunk/test/std/containers/unord/unord.multimap/rehash.pass.cpp libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp libcxx/trunk/test/std/containers/unord/unord.multiset/load_factor.pass.cpp libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy.pass.cpp libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy_alloc.pass.cpp libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size.pass.cpp libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash.pass.cpp libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal.pass.cpp libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal_allocator.pass.cpp libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size.pass.cpp libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash.pass.cpp libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal.pass.cpp libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal_allocator.pass.cpp libcxx/trunk/test/std/containers/unord/unord.set/load_factor.pass.cpp libcxx/trunk/test/std/containers/unord/unord.set/unord.set.cnstr/copy.pass.cpp libcxx/trunk/test/std/containers/unord/unord.set/unord.set.cnstr/copy_alloc.pass.cpp libcxx/trunk/test/std/containers/unord/unord.set/unord.set.cnstr/init_size.pass.cpp libcxx/trunk/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash.pass.cpp libcxx/trunk/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal.pass.cpp libcxx/trunk/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal_allocator.pass.cpp libcxx
Re: [PATCH] D16112: PR26111: segmentation fault with __attribute__((mode(QI))) on function declaration
aaron.ballman added a comment. I think the better way to fix this is to add a Subjects line in Attr.td that limits the mode attribute to just TypedefNameDecl and VarDecl, then remove err_attr_wrong_decl entirely. http://reviews.llvm.org/D16112 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D8149: Add hasUnderlyingType narrowing matcher for TypedefDecls, functionProtoType matcher for FunctionProtoType nodes, extend parameterCountIs to FunctionProtoType nodes
aaron.ballman added inline comments. Comment at: unittests/ASTMatchers/ASTMatchersTest.cpp:4994 @@ +4993,3 @@ + EXPECT_TRUE(matches("typedef int hasUnderlyingTypeTest;", + typedefDecl(hasUnderlyingType(asString("int"); + EXPECT_TRUE(matches("typedef const int T;", LegalizeAdulthood wrote: > aaron.ballman wrote: > > Thank you for those examples! Given the following code: > > ``` > > typedef int foo; > > typedef foo bar; > > > > bar i; > > ``` > > clang-query> match varDecl(hasType(asString("int"))) > > 0 matches. > > clang-query> match varDecl(hasType(asString("foo"))) > > 0 matches. > > clang-query> match varDecl(hasType(asString("bar"))) > > > > Match #1: > > > > E:\Desktop\t.cpp:4:1: note: "root" binds here > > bar i; > > ^ > > 1 match. > > > > So hasType() looks at what the immediate type is for the declaration (which > > we document, yay us!). Based on that, I don't think hasUnderlyingType() > > makes sense -- you should modify hasType() to work on a TypedefNameDecl > > (not just a TypedefDecl!) so that it looks at the immediate type of the > > type definition. I would expect your tests then to result in: > > ``` > > 1: typedef void (fn)(void); > > 2: typedef fn foo; > > 3: typedef int bar; > > 4: typedef int (f); > > 5: typedef int (fn2)(int); > > clang-query> match typedefDecl(hasType(asString("int"))) > > > > Match #1: > > > > /tmp/a.cpp:3:1: note: "root" binds here > > typedef int bar; > > ^~~ > > > > Match #2: > > > > /tmp/a.cpp:4:1: note: "root" binds here > > typedef int (f); > > ^~~ > > 2 matches. > > clang-query> match typedefDecl(hasType(typedefType())) > > > > Match #1: > > > > /tmp/a.cpp:2:1: note: "root" binds here > > typedef fn foo; > > ^~ > > 1 match. > > clang-query> match typedefDecl(hasType(parenType())) > > > > Match #1: > > > > /tmp/a.cpp:1:1: note: "root" binds here > > typedef void (fn)(void); > > ^~~ > > > > Match #2: > > > > /tmp/a.cpp:4:1: note: "root" binds here > > typedef int (f); > > ^~~ > > > > Match #3: > > > > /tmp/a.cpp:5:1: note: "root" binds here > > typedef int (fn2)(int); > > ^~ > > 3 matches. > > clang-query> match > > typedefDecl(hasType(parenType(innerType(functionType() > > > > Match #1: > > > > /tmp/a.cpp:1:1: note: "root" binds here > > typedef void (fn)(void); > > ^~~ > > > > Match #2: > > > > /tmp/a.cpp:5:1: note: "root" binds here > > typedef int (fn2)(int); > > ^~ > > 2 matches. > > ``` > > The end results are the same, so this is just changing the way the > > information is surfaced to the user that is logically consistent. > > ValueDecls have an immediate type, and so do TypedefDecls. By using > > TypedefNameDecl instead of TypedefDecl, this also covers the case where > > hasType() is useful for an alias-declaration. (We don't expose the matcher > > for that yet, but it seems quite reasonable to add in the future, and it > > would be nice for hasType to automatically work with that.) > > > > You can implement this with a helper function to handle abstracting away > > the call to getType() vs getUnderlyingType(), then updating the hasType() > > matchers to use it. Something like: > > ``` > > template > > struct UnderlyingTypeGetter { > > static QualType get(const Ty &Node) { > > return Node.getType(); > > } > > }; > > > > template <> > > QualType UnderlyingTypeGetter::get(const TypedefNameDecl > > &Node) { > > return Node.getUnderlyingType(); > > } > > ``` > > (Somewhere in ASTMatchersInternal.h most likely.) > > > When I try to extend `hasType` to work on `TypedefDecl`, I get this error: > > ``` > error: static assertion failed: right polymorphic conversion > static_assert(TypeListContainsSuperOf::value, > ``` > > ...because `TypedefDecl` is derived from `NamedDecl` and the existing > definition for `hasType` looks like this: > > ``` > AST_POLYMORPHIC_MATCHER_P_OVERLOAD(hasType, >AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, >ValueDecl), >internal::Matcher, InnerMatcher, 1) { > return qualType(hasDeclaration(InnerMatcher)) > .matches(Node.getType(), Finder, Builder); > } > ``` > > So I'll need some guidance on how to extend `hasType` to work for > `TypedefNamedDecl` nodes. I don't understand exactly what all these nasty > macros do. So far, I've simply made changes by imitation, but my approach > didn't work this time. This ({F1302460}) does all of what you need (sans documentation, testing, etc). (File should be attached, but if you need me to send it to you via email, I can do so -- I've never tried this with Phab before.) http://reviews.llvm.org/D8149 ___ cfe-commits mailing list cfe-commits@lists.llvm.org
Re: [PATCH] D16008: [clang-tidy] Add calling virtual functions in constructors/destructors check.
hokein added a comment. In http://reviews.llvm.org/D16008#322811, @Eugene.Zelenko wrote: > This check is duplicate of clang-analyzer-alpha.cplusplus.VirtualCall. Oops... Didn't notice there is an implementation already. > From my point of view, Clang-tidy is better place, since such calls doesn't > depend of run-time paths. > > I think will be good idea to try to establish better functionality separation > between Clang/Clang-tidy/Clang Static Analyzer. Current situation looks like > different teams try to take everything coming to them without considering big > picture. This my impression based on including padding check in Clang Static > Analyzer. > > I may be wrong, but Clang seems even better place for such warnings. However clang-tidy has a ' clang-analyzer-*' check option to run the clang static analyzer check. I'm not sure whether it's worthwhile to move `VirtualCall` check to the module in clang-tidy. Repository: rL LLVM http://reviews.llvm.org/D16008 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15448: [analyzer] SVal Visitor.
NoQ updated this revision to Diff 44629. NoQ added a comment. Another rebase on top of http://reviews.llvm.org/D16062. http://reviews.llvm.org/D15448 Files: docs/analyzer/DebugChecks.rst include/clang/StaticAnalyzer/Checkers/SValExplainer.h include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h include/clang/StaticAnalyzer/Core/PathSensitive/Regions.def include/clang/StaticAnalyzer/Core/PathSensitive/SValVisitor.h include/clang/StaticAnalyzer/Core/PathSensitive/SVals.def include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h include/clang/StaticAnalyzer/Core/PathSensitive/Symbols.def lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp test/Analysis/explain-svals.cpp Index: test/Analysis/explain-svals.cpp === --- /dev/null +++ test/Analysis/explain-svals.cpp @@ -0,0 +1,98 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core.builtin,debug.ExprInspection,unix.cstring -verify %s + +typedef unsigned long size_t; + +struct S { + struct S3 { +int y[10]; + }; + struct S2 : S3 { +int *x; + } s2[10]; + int z; +}; + + +void clang_analyzer_explain(int); +void clang_analyzer_explain(void *); +void clang_analyzer_explain(S); + +size_t clang_analyzer_getExtent(void *); + +size_t strlen(const char *); + +int conjure(); +S conjure_S(); + +int glob; +static int stat_glob; +void *glob_ptr; + +// Test strings are regex'ed because we need to match exact string +// rather than a substring. + +void test_1(int param, void *ptr) { + clang_analyzer_explain(&glob); // expected-warning-re^pointer to global variable 'glob'$ + clang_analyzer_explain(param); // expected-warning-re^argument 'param'$ + clang_analyzer_explain(ptr); // expected-warning-re^argument 'ptr'$ + if (param == 42) +clang_analyzer_explain(param); // expected-warning-re^signed 32-bit integer '42'$ +} + +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"$ + clang_analyzer_explain(strlen(ptr)); // expected-warning-re^metadata of type 'unsigned long' tied to pointee of argument 'ptr'$ + 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'$ + clang_analyzer_explain(clang_analyzer_getExtent(ptr)); // expected-warning-re^extent of pointee of argument 'ptr'$ + int *x = new int[ext]; + clang_analyzer_explain(x); // expected-warning-re^pointer to element of type 'int' with index 0 of pointee of symbol of type 'int \*' conjured at statement 'new int \[ext\]'$ + // Sic! What gets computed is the extent of the element-region. + clang_analyzer_explain(clang_analyzer_getExtent(x)); // expected-warning-re^signed 32-bit integer '4'$ + delete[] x; +} + +void test_3(S s) { + clang_analyzer_explain(&s); // expected-warning-re^pointer to parameter 's'$ + clang_analyzer_explain(s.z); // expected-warning-re^initial value of field 'z' of parameter 's'$ + clang_analyzer_explain(&s.s2[5].y[3]); // expected-warning-re^pointer to element of type 'int' with index 3 of field 'y' of base object 'S::S3' inside element of type 'struct S::S2' with index 5 of field 's2' of parameter 's'$ + if (!s.s2[7].x) { +clang_analyzer_explain(s.s2[7].x); // expected-warning-re^concrete memory address '0'$ +// FIXME: we need to be explaining '1' rather than '0' here; not explainer bug. +clang_analyzer_explain(s.s2[7].x + 1); // expected-warning-re^concrete memory address '0'$ + } +} + +void test_4(int x, int y) { + int z; + static int stat; + clang_analyzer_explain(x + 1); // expected-warning-re^\(argument 'x'\) \+ 1$ + clang_analyzer_explain(1 + y); // expected-warning-re^\(argument 'y'\) \+ 1$ + clang_analyzer_explain(x + y); // expected-warning-re^unknown value$ + clang_analyzer_explain(z); // expected-warning-re^undefined value$ + clang_analyzer_explain(&z); // expected-warning-re^pointer to local variable 'z'$ + clang_analyzer_explain(stat); // expected-warning-re^signed 32-bit integer '0'$ + clang_analyzer_explain(&stat); // expected-warning-re^pointer to static local variable 'stat'$ + clang_analyzer_explain(stat_glob); // expected-warning-re^initial value of global variable 'stat_glob'$ + clang_analyzer_explain(&stat_glob); // expected-warning-re^pointer to global variable 'sta
Re: [PATCH] D16062: [analyzer] Rename kind-enumeration values of SVal, SymExpr, MemRegion classes, for consistency.
NoQ updated this revision to Diff 44628. NoQ marked 2 inline comments as done. NoQ added a comment. Good point! Removed the friend-class directive here, and also in `NonStaticGlobalSpaceRegion`, which is also abstract. Agreed and renamed text regions to code regions. http://reviews.llvm.org/D16062 Files: include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h lib/StaticAnalyzer/Checkers/CStringChecker.cpp lib/StaticAnalyzer/Checkers/MallocChecker.cpp lib/StaticAnalyzer/Core/MemRegion.cpp lib/StaticAnalyzer/Core/ProgramState.cpp lib/StaticAnalyzer/Core/SValBuilder.cpp lib/StaticAnalyzer/Core/SVals.cpp lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp lib/StaticAnalyzer/Core/Store.cpp lib/StaticAnalyzer/Core/SymbolManager.cpp Index: lib/StaticAnalyzer/Core/SymbolManager.cpp === --- lib/StaticAnalyzer/Core/SymbolManager.cpp +++ lib/StaticAnalyzer/Core/SymbolManager.cpp @@ -115,22 +115,22 @@ const SymExpr *SE = itr.pop_back_val(); switch (SE->getKind()) { -case SymExpr::RegionValueKind: -case SymExpr::ConjuredKind: -case SymExpr::DerivedKind: -case SymExpr::ExtentKind: -case SymExpr::MetadataKind: +case SymExpr::SymbolRegionValueKind: +case SymExpr::SymbolConjuredKind: +case SymExpr::SymbolDerivedKind: +case SymExpr::SymbolExtentKind: +case SymExpr::SymbolMetadataKind: return; -case SymExpr::CastSymbolKind: +case SymExpr::SymbolCastKind: itr.push_back(cast(SE)->getOperand()); return; -case SymExpr::SymIntKind: +case SymExpr::SymIntExprKind: itr.push_back(cast(SE)->getLHS()); return; -case SymExpr::IntSymKind: +case SymExpr::IntSymExprKind: itr.push_back(cast(SE)->getRHS()); return; -case SymExpr::SymSymKind: { +case SymExpr::SymSymExprKind: { const SymSymExpr *x = cast(SE); itr.push_back(x->getLHS()); itr.push_back(x->getRHS()); @@ -458,35 +458,35 @@ bool KnownLive; switch (sym->getKind()) { - case SymExpr::RegionValueKind: + case SymExpr::SymbolRegionValueKind: KnownLive = isLiveRegion(cast(sym)->getRegion()); break; - case SymExpr::ConjuredKind: + case SymExpr::SymbolConjuredKind: KnownLive = false; break; - case SymExpr::DerivedKind: + case SymExpr::SymbolDerivedKind: KnownLive = isLive(cast(sym)->getParentSymbol()); break; - case SymExpr::ExtentKind: + case SymExpr::SymbolExtentKind: KnownLive = isLiveRegion(cast(sym)->getRegion()); break; - case SymExpr::MetadataKind: + case SymExpr::SymbolMetadataKind: KnownLive = MetadataInUse.count(sym) && isLiveRegion(cast(sym)->getRegion()); if (KnownLive) MetadataInUse.erase(sym); break; - case SymExpr::SymIntKind: + case SymExpr::SymIntExprKind: KnownLive = isLive(cast(sym)->getLHS()); break; - case SymExpr::IntSymKind: + case SymExpr::IntSymExprKind: KnownLive = isLive(cast(sym)->getRHS()); break; - case SymExpr::SymSymKind: + case SymExpr::SymSymExprKind: KnownLive = isLive(cast(sym)->getLHS()) && isLive(cast(sym)->getRHS()); break; - case SymExpr::CastSymbolKind: + case SymExpr::SymbolCastKind: KnownLive = isLive(cast(sym)->getOperand()); break; } Index: lib/StaticAnalyzer/Core/Store.cpp === --- lib/StaticAnalyzer/Core/Store.cpp +++ lib/StaticAnalyzer/Core/Store.cpp @@ -100,7 +100,7 @@ // Process region cast according to the kind of the region being cast. switch (R->getKind()) { case MemRegion::CXXThisRegionKind: -case MemRegion::GenericMemSpaceRegionKind: +case MemRegion::CodeSpaceRegionKind: case MemRegion::StackLocalsSpaceRegionKind: case MemRegion::StackArgumentsSpaceRegionKind: case MemRegion::HeapSpaceRegionKind: @@ -112,8 +112,8 @@ llvm_unreachable("Invalid region cast"); } -case MemRegion::FunctionTextRegionKind: -case MemRegion::BlockTextRegionKind: +case MemRegion::FunctionCodeRegionKind: +case MemRegion::BlockCodeRegionKind: case MemRegion::BlockDataRegionKind: case MemRegion::StringRegionKind: // FIXME: Need to handle arbitrary downcasts. @@ -393,7 +393,7 @@ const MemRegion* BaseR = nullptr; switch (BaseL.getSubKind()) { - case loc::MemRegionKind: + case loc::MemRegionValKind: BaseR = BaseL.castAs().getRegion(); break; Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp === --- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp +++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp @@ -141,9 +141,9 @@ // unless this is a weak function or a symbolic region. if (castTy->isBooleanType()) { switch (val.get
Re: [PATCH] D15914: [OpenCL] Pipe builtin functions
pxli168 updated this revision to Diff 44624. pxli168 added a comment. Rewrite some comment. Can this patch be in llvm3.8 release if it is commited after 13th Jan? http://reviews.llvm.org/D15914 Files: include/clang/Basic/Builtins.def include/clang/Basic/Builtins.h include/clang/Basic/DiagnosticSemaKinds.td lib/Basic/Builtins.cpp lib/CodeGen/CGBuiltin.cpp lib/Sema/SemaChecking.cpp test/CodeGenOpenCL/pipe_builtin.cl test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl Index: test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl === --- /dev/null +++ test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl @@ -0,0 +1,56 @@ +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0 + +void test1(read_only pipe int p, global int* ptr){ + int tmp; + reserve_id_t rid; + + // read/write_pipe + read_pipe(tmp, p);// expected-error {{first argument to read_pipe must be a pipe type}} + read_pipe(p); // expected-error {{invalid number of arguments to function: read_pipe}} + read_pipe(p, tmp, tmp, ptr); // expected-error {{invalid argument type to function read_pipe (expecting: 'reserve_id_t')}} + read_pipe(p, rid, rid, ptr); // expected-error {{invalid argument type to function read_pipe (expecting: 'unsigned int')}} + read_pipe(p, tmp); // expected-error {{invalid argument type to function read_pipe (expecting: 'int *')}} + write_pipe(p, ptr);// expected-error {{invalid pipe access modifier (expecting write_only)}} + write_pipe(p, rid, tmp, ptr);// expected-error {{invalid pipe access modifier (expecting write_only)}} + + // reserve_read/write_pipe + reserve_read_pipe(p, ptr);// expected-error{{invalid argument type to function reserve_read_pipe (expecting: 'unsigned int')}} + work_group_reserve_read_pipe(tmp, tmp);// expected-error{{first argument to work_group_reserve_read_pipe must be a pipe type}} + sub_group_reserve_write_pipe(p, tmp);// expected-error{{invalid pipe access modifier (expecting write_only)}} + + // commit_read/write_pipe + commit_read_pipe(tmp, rid);// expected-error{{first argument to commit_read_pipe must be a pipe type}} + work_group_commit_read_pipe(p, tmp);// expected-error{{invalid argument type to function work_group_commit_read_pipe (expecting: 'reserve_id_t')}} + sub_group_commit_write_pipe(p, tmp);// expected-error{{nvalid pipe access modifier (expecting write_only)}} +} + +void test2(write_only pipe int p, global int* ptr){ + int tmp; + reserve_id_t rid; + + // read/write_pipe + write_pipe(tmp, p);// expected-error {{first argument to write_pipe must be a pipe type}} + write_pipe(p); // expected-error {{invalid number of arguments to function: write_pipe}} + write_pipe(p, tmp, tmp, ptr); // expected-error {{invalid argument type to function write_pipe (expecting: 'reserve_id_t')}} + write_pipe(p, rid, rid, ptr); // expected-error {{invalid argument type to function write_pipe (expecting: 'unsigned int')}} + write_pipe(p, tmp); // expected-error {{invalid argument type to function write_pipe (expecting: 'int *')}} + read_pipe(p, ptr);// expected-error {{invalid pipe access modifier (expecting read_only)}} + read_pipe(p, rid, tmp, ptr);// expected-error {{invalid pipe access modifier (expecting read_only)}} + + // reserve_read/write_pipe + reserve_write_pipe(p, ptr);// expected-error{{invalid argument type to function reserve_write_pipe (expecting: 'unsigned int')}} + work_group_reserve_write_pipe(tmp, tmp);// expected-error{{first argument to work_group_reserve_write_pipe must be a pipe type}} + sub_group_reserve_read_pipe(p, tmp);// expected-error{{invalid pipe access modifier (expecting read_only)}} + + // commit_read/write_pipe + commit_write_pipe(tmp, rid);// expected-error{{first argument to commit_write_pipe must be a pipe type}} + work_group_commit_write_pipe(p, tmp);// expected-error{{invalid argument type to function work_group_commit_write_pipe (expecting: 'reserve_id_t')}} + sub_group_commit_read_pipe(p, tmp);// expected-error{{nvalid pipe access modifier (expecting read_only)}} +} + +void test3(){ + int tmp; + get_pipe_num_packets(tmp);// expected-error {{first argument to get_pipe_num_packets must be a pipe type}} + get_pipe_max_packets(tmp);// expected-error {{first argument to get_pipe_max_packets must be a pipe type}} +} + Index: test/CodeGenOpenCL/pipe_builtin.cl === --- /dev/null +++ test/CodeGenOpenCL/pipe_builtin.cl @@ -0,0 +1,61 @@ +// RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s + +// CHECK: %opencl.pipe_t = type opaque +// CHECK: %opencl.reserve_id_t = type opaque + +void test1(read_only pipe int p, global int *ptr) { + // CHECK: call i32 @read_pipe_2(%opencl.pipe_t* %{{.*}}, i8 addrspace(4)* %{{.*}}) + read_pipe(p, ptr); + // CHECK: call %opencl.reserve_id_t* @reserve_read_pi
[PATCH] D16112: PR26111: segmentation fault with __attribute__((mode(QI))) on function declaration
d.zobnin.bugzilla created this revision. d.zobnin.bugzilla added a reviewer: aaron.ballman. d.zobnin.bugzilla added a subscriber: cfe-commits. Allow "mode" attribute to be applied to VarDecl, not ValueDecl (which includes FunctionDecl and EnumConstantDecl), emit an error if this attribute is used with function declarations and enum constants. http://reviews.llvm.org/D16112 Files: include/clang/AST/Decl.h include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDeclAttr.cpp test/Sema/attr-mode.c Index: lib/Sema/SemaDeclAttr.cpp === --- lib/Sema/SemaDeclAttr.cpp +++ lib/Sema/SemaDeclAttr.cpp @@ -3372,11 +3372,11 @@ QualType OldTy; if (TypedefNameDecl *TD = dyn_cast(D)) OldTy = TD->getUnderlyingType(); - else if (ValueDecl *VD = dyn_cast(D)) + else if (VarDecl *VD = dyn_cast(D)) OldTy = VD->getType(); else { -S.Diag(D->getLocation(), diag::err_attr_wrong_decl) - << Attr.getName() << Attr.getRange(); +S.Diag(D->getLocation(), diag::err_mode_requires_typedef_or_variable) +<< Attr.getRange(); return; } @@ -3451,7 +3451,7 @@ if (TypedefNameDecl *TD = dyn_cast(D)) TD->setModedTypeSourceInfo(TD->getTypeSourceInfo(), NewTy); else -cast(D)->setType(NewTy); +cast(D)->setType(NewTy); D->addAttr(::new (S.Context) ModeAttr(Attr.getRange(), S.Context, Name, Index: include/clang/AST/Decl.h === --- include/clang/AST/Decl.h +++ include/clang/AST/Decl.h @@ -1954,6 +1954,7 @@ unsigned getMinRequiredArguments() const; QualType getReturnType() const { +assert(getType()->getAs() && "Expected a FunctionType!"); return getType()->getAs()->getReturnType(); } @@ -1964,6 +1965,7 @@ /// \brief Determine the type of an expression that calls this function. QualType getCallResultType() const { +assert(getType()->getAs() && "Expected a FunctionType!"); return getType()->getAs()->getCallResultType(getASTContext()); } Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -2838,14 +2838,14 @@ "mode attribute only supported for integer and floating-point types">; def err_mode_wrong_type : Error< "type of machine mode does not match type of base type">; +def err_mode_requires_typedef_or_variable : Error< + "mode attribute invalid on this declaration, requires typedef or variable">; def warn_vector_mode_deprecated : Warning< "specifying vector types with the 'mode' attribute is deprecated; " "use the 'vector_size' attribute instead">, InGroup; def err_complex_mode_vector_type : Error< "type of machine mode does not support base vector types">; -def err_attr_wrong_decl : Error< - "%0 attribute invalid on this declaration, requires typedef or value">; def warn_attribute_nonnull_no_pointers : Warning< "'nonnull' attribute applied to function with no pointer arguments">, InGroup; Index: test/Sema/attr-mode.c === --- test/Sema/attr-mode.c +++ test/Sema/attr-mode.c @@ -24,6 +24,9 @@ int **__attribute((mode(QI)))* i32; // expected-error{{mode attribute}} +__attribute__((mode(QI))) int invalid_func() { return 1; } // expected-error{{mode attribute invalid on this declaration}} +enum invalid_enum { A1 __attribute__((mode(QI))) }; // expected-error{{mode attribute invalid on this declaration}} + typedef _Complex double c32 __attribute((mode(SC))); int c32_test[sizeof(c32) == 8 ? 1 : -1]; typedef _Complex float c64 __attribute((mode(DC))); Index: lib/Sema/SemaDeclAttr.cpp === --- lib/Sema/SemaDeclAttr.cpp +++ lib/Sema/SemaDeclAttr.cpp @@ -3372,11 +3372,11 @@ QualType OldTy; if (TypedefNameDecl *TD = dyn_cast(D)) OldTy = TD->getUnderlyingType(); - else if (ValueDecl *VD = dyn_cast(D)) + else if (VarDecl *VD = dyn_cast(D)) OldTy = VD->getType(); else { -S.Diag(D->getLocation(), diag::err_attr_wrong_decl) - << Attr.getName() << Attr.getRange(); +S.Diag(D->getLocation(), diag::err_mode_requires_typedef_or_variable) +<< Attr.getRange(); return; } @@ -3451,7 +3451,7 @@ if (TypedefNameDecl *TD = dyn_cast(D)) TD->setModedTypeSourceInfo(TD->getTypeSourceInfo(), NewTy); else -cast(D)->setType(NewTy); +cast(D)->setType(NewTy); D->addAttr(::new (S.Context) ModeAttr(Attr.getRange(), S.Context, Name, Index: include/clang/AST/Decl.h === --- include/clang/AST/Decl.h +++ include/clang/AST/Decl.h @@ -1954,6 +1954,7 @@ unsigned getMinRequiredArguments() const; QualType getReturnType() const { +assert(getType()->getA
Re: [PATCH] D15443: Fix getLocEnd for function declarations with exception specification.
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. In http://reviews.llvm.org/D15443#324426, @adek05 wrote: > Adding testcases in unittest/AST/SourceLocationTest.cpp as suggested by > @aaronballman > > Interestingly, without my change tests for function declarations pass. Only > member functions fail: > > tools/clang/unittests/AST/ASTTests > ... > [--] 2 tests from FunctionDecl > [ RUN ] FunctionDecl.FunctionDeclWithThrowSpecification > [ OK ] FunctionDecl.FunctionDeclWithThrowSpecification (17 ms) > [ RUN ] FunctionDecl.FunctionDeclWithNoExceptSpecification > [ OK ] FunctionDecl.FunctionDeclWithNoExceptSpecification (10 ms) > [--] 2 tests from FunctionDecl (27 ms total) > > [--] 2 tests from CXXMethodDecl > [ RUN ] CXXMethodDecl.CXXMethodDeclWithThrowSpecification > /Users/adek/llvm-git/tools/clang/unittests/AST/SourceLocationTest.cpp:569: > Failure > Value of: Verifier.match( "class A {\n" "void f() throw();\n" "};\n", > functionDecl()) > Actual: false (Expected range <2:1-2:16>, found > ) > Expected: true > [ FAILED ] CXXMethodDecl.CXXMethodDeclWithThrowSpecification (10 ms) > [ RUN ] CXXMethodDecl.CXXMethodDeclWithNoExceptSpecification > /Users/adek/llvm-git/tools/clang/unittests/AST/SourceLocationTest.cpp:580: > Failure > Value of: Verifier.match( "class A {\n" "void f() noexcept(false);\n" > "};\n", functionDecl(), Language::Lang_CXX11) > Actual: false (Expected range <2:1-2:24>, found > ) > Expected: true > [ FAILED ] CXXMethodDecl.CXXMethodDeclWithNoExceptSpecification (10 ms) > [--] 2 tests from CXXMethodDecl (20 ms total) > > > Not sure why would they take different codepaths, throw and noexcept are > C++(11) specific so both should go through ParseDeclCXX. It would be nice to understand why that is the case and whether there's some code sharing possibilities, but since this is such a small change, I'm not certain of the gains. LGTM! Thanks! http://reviews.llvm.org/D15443 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15914: [OpenCL] Pipe builtin functions
pxli168 added inline comments. Comment at: include/clang/Basic/Builtins.h:39 @@ -38,2 +38,3 @@ MS_LANG = 0x10, // builtin requires MS mode. + OCLC_LANG = 0x20,// builtin for OpenCL C only. ALL_LANGUAGES = C_LANG | CXX_LANG | OBJC_LANG, // builtin for all languages. Anastasia wrote: > May be: OCLC -> OCL I just usede OCLC from **O**pen**CL** **C**. http://reviews.llvm.org/D15914 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15914: [OpenCL] Pipe builtin functions
pxli168 marked 4 inline comments as done. Comment at: include/clang/Basic/Builtins.def:1255 @@ -1254,1 +1254,3 @@ +// OpenCL v2.0 s6.13.16, s9.17.3.5 -- Pipe functions. +// We need the generic prototype, since the packet type could be anything. Anastasia wrote: > Could you remove one -? Removed. Comment at: lib/Sema/SemaChecking.cpp:291 @@ +290,3 @@ + bool isValid = true; + // TODO: For all pipe built-in read is for read_only? + bool ReadOnly = getFunctionName(Call).find("read") != StringRef::npos; Anastasia wrote: > Why the TODO here? TODO after get clarify from Khronos. Comment at: test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl:36 @@ +35,3 @@ + write_pipe(p, rid, rid, ptr); // expected-error {{invalid argument type to function write_pipe (expecting: 'unsigned int')}} + write_pipe(p, tmp); // expected-error {{invalid argument type to function write_pipe (expecting: 'int *')}} + read_pipe(p, ptr);// expected-error {{invalid pipe access modifier (expecting read_only)}} Anastasia wrote: > remove : from error string what do you mean by > remove : from error string http://reviews.llvm.org/D15914 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16102: Bug 25496 - clang++ -pg links with -lc++ instead of -lc++_p
dws added a comment. Added cfe-commits to the Reviewers. http://reviews.llvm.org/D16102 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16047: [OpenCL] Add Sema checks for OpenCL 2.0
pxli168 updated this revision to Diff 44619. pxli168 added a comment. FIxed bugs and relocate the test cases. Upload the full diff. http://reviews.llvm.org/D16047 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDecl.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaInit.cpp lib/Sema/SemaType.cpp test/CodeGenOpenCL/opencl_types.cl test/Parser/opencl-atomics-cl20.cl test/SemaOpenCL/invalid-block.cl test/SemaOpenCL/invalid-decl.cl test/SemaOpenCL/invalid-image.cl test/SemaOpenCL/invalid-pipes-cl2.0.cl Index: test/SemaOpenCL/invalid-pipes-cl2.0.cl === --- test/SemaOpenCL/invalid-pipes-cl2.0.cl +++ test/SemaOpenCL/invalid-pipes-cl2.0.cl @@ -6,3 +6,6 @@ } void test3(int pipe p){// expected-error {{cannot combine with previous 'int' declaration specifier}} } +void test4() { + pipe int p; // expected-error {{pipe can only be used as a function parameter}} +} Index: test/SemaOpenCL/invalid-image.cl === --- /dev/null +++ test/SemaOpenCL/invalid-image.cl @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -verify %s + +void test1(image1d_t *i){} // expected-error {{pointer to image is invalid in OpenCL}} + +void test2() { + image1d_t i; // expected-error {{image can only be used as a function parameter}} +} Index: test/SemaOpenCL/invalid-decl.cl === --- /dev/null +++ test/SemaOpenCL/invalid-decl.cl @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -verify -cl-std=CL2.0 %s +int; // expected-error {{declaration does not declare anything}} + +void test1(){ + myfun(); // expected-error {{implicit declaration of function 'myfun' is invalid in OpenCL}} +} Index: test/SemaOpenCL/invalid-block.cl === --- /dev/null +++ test/SemaOpenCL/invalid-block.cl @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -verify -fblocks -cl-std=CL2.0 %s + +int (^BlkVariadic)(int, ...) = ^int(int I, ...) { // expected-error {{invalid block prototype, variadic arguments are not allowed}} + return 0; +}; + +typedef int (^BlkInt)(int); +void f1(int i) { + BlkInt B1 = ^int(int I) {return 1;}; + BlkInt B2 = ^int(int I) {return 2;}; + BlkInt Arr[] = {B1, B2}; // expected-error {{array of block is invalid in OpenCL}} + int tmp = i ? B1(i) // expected-error {{blocks cannot be used as expressions in ternary expressions}} + : B2(i); // expected-error {{blocks cannot be used as expressions in ternary expressions}} +} + +void f2(BlkInt *BlockPtr) { + BlkInt B = ^int(int I) {return 1;}; + BlkInt *P = &B; // expected-error {{invalid argument type 'BlkInt' (aka 'int (^)(int)') to unary expression}} + B = *BlockPtr; // expected-error {{dereferencing pointer of type '__generic BlkInt *' (aka 'int (^__generic *)(int)') is not allowed}} +} + Index: test/Parser/opencl-atomics-cl20.cl === --- test/Parser/opencl-atomics-cl20.cl +++ test/Parser/opencl-atomics-cl20.cl @@ -56,6 +56,7 @@ #endif #ifdef CL20 +#define ATOMIC_VAR_INIT void foo(atomic_int * ptr) {} void atomic_ops_test() { atomic_int i; @@ -66,4 +67,7 @@ i += 1; // expected-error {{invalid operands to binary expression ('atomic_int' (aka '_Atomic(int)') and 'int')}} i = i + i; // expected-error {{invalid operands to binary expression ('atomic_int' (aka '_Atomic(int)') and 'atomic_int')}} } +void atomic_init_test() { +atomic_int guide = ATOMIC_VAR_INIT(42); // expected-error {{initialization of atomic variables is restricted to variables in global address space in opencl}} +} #endif Index: test/CodeGenOpenCL/opencl_types.cl === --- test/CodeGenOpenCL/opencl_types.cl +++ test/CodeGenOpenCL/opencl_types.cl @@ -35,6 +35,3 @@ fnc4smp(glb_smp); // CHECK: call {{.*}}void @fnc4smp(i32 } - -void __attribute__((overloadable)) bad1(image1d_t *b, image2d_t *c, image2d_t *d) {} -// CHECK-LABEL: @{{_Z4bad1P11ocl_image1dP11ocl_image2dS2_|"\\01\?bad1@@\$\$J0YAXPE?APAUocl_image1d@@PE?APAUocl_image2d@@1@Z"}} Index: lib/Sema/SemaType.cpp === --- lib/Sema/SemaType.cpp +++ lib/Sema/SemaType.cpp @@ -2176,6 +2176,14 @@ Diag(Loc, diag::warn_vla_used); } + // OpenCL v2.0 s6.12.5 - The following Blocks features are currently not + // supported in OpenCL C: Arrays of Blocks. + if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion >= 200 && + Context.getBaseElementType(T)->isBlockPointerType()) { +Diag(Loc, diag::err_opencl_invalid_block_array); +return QualType(); + } + return T; } Index: lib/Sema/SemaInit.cpp === --- lib/Sema/SemaInit.cpp +++ lib/Sema/SemaInit.cpp @@ -6135,6 +6135,32 @@ << Init->getSourceRange(); } + // OpenCL v2.0 s6.
Re: [PATCH] D16047: [OpenCL] Add Sema checks for OpenCL 2.0
pxli168 added inline comments. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:593 @@ -592,2 +592,3 @@ InGroup; +def err_no_declarators : Error<"declaration does not declare anything">; def ext_typedef_without_a_name : ExtWarn<"typedef requires a name">, I think this no declarator is just for bit-field in C. And OpenCL C does not support the bit-field I think we need not to support that. If you think it is useless I think we can remove it then. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7666 @@ +7665,3 @@ +def err_opencl_atomic_init_addressspace : Error< + "initialization of atomic variables is restricted to variables in global address space in opencl">; +def err_opencl_block_proto_variadic : Error< It seems that this two are very different and need a big select. Then it seems two maybe OK. Comment at: lib/Sema/SemaDecl.cpp:5724 @@ +5723,3 @@ + // Pipes can only be passed as arguments to a function. + if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion >= 200 && + R->isPipeType()) { It seems all other check for OpenCL goes this way. I don't know if we just check OpenCL version will cause any error. Comment at: lib/Sema/SemaDecl.cpp:6718 @@ +6717,3 @@ +const BlockPointerType *BlkTy = T->getAs(); +assert(BlkTy && "Not a block pointer."); + agree. I will remove it. Comment at: lib/Sema/SemaExpr.cpp:6299 @@ +6298,3 @@ +// should output error for both LHS and RHS, use | instead || +if (checkBlockType(*this, LHS.get()) | checkBlockType(*this, RHS.get())) + return QualType(); But how can we know if LHS or RHS is Block, or they both are? Comment at: lib/Sema/SemaExpr.cpp:10095 @@ -10060,1 +10094,3 @@ Result = PT->getPointeeType(); +// OpenCL v2.0 s6.12.5 --The unary operators (* and &) cannot be used with a +// Block. Fixed Comment at: lib/Sema/SemaInit.cpp:6138 @@ -6137,1 +6137,3 @@ + // OpenCL v2.0 s6.13.1.1 - This macro can only be used to initialize atomic + // objects that are declared in program scope in the global address space. yes, thank you! Comment at: lib/Sema/SemaInit.cpp:6147 @@ +6146,3 @@ +Args.size() > 0) { + const Expr *Init = Args[0]; + S.Diag(Init->getLocStart(), diag::err_opencl_atomic_init_addressspace) I just follow the surrounding code style. Comment at: test/CodeGenOpenCL/opencl_types.cl:39 @@ -38,3 @@ - -void __attribute__((overloadable)) bad1(image1d_t *b, image2d_t *c, image2d_t *d) {} -// CHECK-LABEL: @{{_Z4bad1P11ocl_image1dP11ocl_image2dS2_|"\\01\?bad1@@\$\$J0YAXPE?APAUocl_image1d@@PE?APAUocl_image2d@@1@Z"}} As you can see, it used pointer of image type which I just added a semacheck for it. Comment at: test/SemaOpenCL/invalid-decl.cl:11 @@ +10,3 @@ +void test2(image1d_t *i){} // expected-error {{pointer to image is invalid in OpenCL}} + +void test3() { I will find some place to put these test in. Comment at: test/SemaOpenCL/invalid-decl.cl:19 @@ +18,2 @@ + atomic_int guide = ATOMIC_VAR_INIT(42); // expected-error {{initialization of atomic variables is restricted to variables in global address space in opencl}} +} It seems strange to put sema test cases in Parser, just let them be together then. http://reviews.llvm.org/D16047 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16056: [Gold] Pass -mllvm options to the gold plugin
jmolloy abandoned this revision. jmolloy added a comment. Abandoning - this isn't as clear-cut as I thought. Repository: rL LLVM http://reviews.llvm.org/D16056 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15006: Driver: Better detection of mingw-gcc
ismail added a comment. Reverted in r257468. http://reviews.llvm.org/D15006 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15914: [OpenCL] Pipe builtin functions
Anastasia added inline comments. Comment at: include/clang/Basic/Builtins.def:1255 @@ -1254,1 +1254,3 @@ +// OpenCL v2.0 s6.13.16, s9.17.3.5 -- Pipe functions. +// We need the generic prototype, since the packet type could be anything. Could you remove one -? Comment at: include/clang/Basic/Builtins.h:39 @@ -38,2 +38,3 @@ MS_LANG = 0x10, // builtin requires MS mode. + OCLC_LANG = 0x20,// builtin for OpenCL C only. ALL_LANGUAGES = C_LANG | CXX_LANG | OBJC_LANG, // builtin for all languages. May be: OCLC -> OCL Comment at: lib/CodeGen/CGBuiltin.cpp:2002 @@ +2001,3 @@ + Value *BCast = Builder.CreatePointerCast(Arg3, I8PTy); + // We know the third argument is an integer type (Verified by Sema), but + // we may need to cast it to i32. remove "(Verified by Sema)" Comment at: lib/CodeGen/CGBuiltin.cpp:2033 @@ +2032,3 @@ + *Arg1 = EmitScalarExpr(E->getArg(1)); +llvm::Type *ReservedIDTy = ConvertType(getContext().OCLReserveIDTy); + Yes. I do believe that a pass would recover this, but on the other hand it is an extra step. Every such step can potentially add to compilation time which can easily be avoided by already generating code in the format that directly sets the right value. > "Yours optimizes automatically but requires special casing (when calling a > builtin, not user function, add this magic parameter)" I am not sure what is special casing. All pipe functions are Clang builtins now and will be generated to calls to internal functions (for those we can define the format the way we need it to be). Anyways, I see what you mean this is an optimization and not needed for supporting correct functionality. I still think it's nicer not to force compiler developer to create extra passes for something we can provide in a suitable format from the beginning. I don't want to block this change for that reason though. This is a small modification and so can be done later as well. Comment at: lib/CodeGen/CGBuiltin.cpp:2039 @@ +2038,3 @@ +ReservedIDTy, llvm::ArrayRef(ArgTys), false); +// We know the second argument is an integer type (Verified by Sema), but +// we may need to cast it to i32. remove "(Verified by Sema)" Comment at: lib/Sema/SemaChecking.cpp:267 @@ +266,3 @@ +/// Returns OpenCL access qual. +// TODO:Refine OpenCLImageAccessAttr to OpenCLArgAccessAttr since pipe can use +// it too Add space after TODO: Comment at: lib/Sema/SemaChecking.cpp:291 @@ +290,3 @@ + bool isValid = true; + // TODO: For all pipe built-in read is for read_only? + bool ReadOnly = getFunctionName(Call).find("read") != StringRef::npos; Why the TODO here? Comment at: lib/Sema/SemaChecking.cpp:769 @@ +768,3 @@ +// We need to override the return type of the reserve pipe functions. +TheCall->setType(Context.OCLReserveIDTy); +break; Could you improve the comment? Not clear why do we need to override the type... Comment at: test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl:5 @@ +4,3 @@ + int tmp; + reserve_id_t rid; + We should tests all code added to the compiler. Comment at: test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl:33 @@ +32,3 @@ + write_pipe(tmp, p);// expected-error {{first argument to write_pipe must be a pipe type}} + write_pipe(p); // expected-error {{invalid number of arguments to function: write_pipe}} + write_pipe(p, tmp, tmp, ptr); // expected-error {{invalid argument type to function write_pipe (expecting: 'reserve_id_t')}} remove : from error string Comment at: test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl:34 @@ +33,3 @@ + write_pipe(p); // expected-error {{invalid number of arguments to function: write_pipe}} + write_pipe(p, tmp, tmp, ptr); // expected-error {{invalid argument type to function write_pipe (expecting: 'reserve_id_t')}} + write_pipe(p, rid, rid, ptr); // expected-error {{invalid argument type to function write_pipe (expecting: 'unsigned int')}} remove : from error string Comment at: test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl:35 @@ +34,3 @@ + write_pipe(p, tmp, tmp, ptr); // expected-error {{invalid argument type to function write_pipe (expecting: 'reserve_id_t')}} + write_pipe(p, rid, rid, ptr); // expected-error {{invalid argument type to function write_pipe (expecting: 'unsigned int')}} + write_pipe(p, tmp); // expected-error {{invalid argument type to function write_pipe (expecting: 'int *')}} remove : from error string Comment at: test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl:36 @@ +35,3 @@ + write_pipe(p, rid, rid, ptr); // expected-error {{invalid argumen
Re: [PATCH] D16047: [OpenCL] Add Sema checks for OpenCL 2.0
Anastasia added a comment. Also generally it's much nicer to have small logically isolated changes committed. I can see how you could partition this change into into pipe, blocks and images. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:593 @@ -592,2 +592,3 @@ InGroup; +def err_no_declarators : Error<"declaration does not declare anything">; def ext_typedef_without_a_name : ExtWarn<"typedef requires a name">, Can you explain why you are adding this and not relying on standard C behavior? Any reference to spec or complete example would be helpful! Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7666 @@ +7665,3 @@ +def err_opencl_atomic_init_addressspace : Error< + "initialization of atomic variables is restricted to variables in global address space in opencl">; +def err_opencl_block_proto_variadic : Error< I think it's best to merge this with err_atomic_init_constant diagnostic. You can have {assigned|initialize} in the text and pass which value to select in the code handling the error. I would also rename it directly to: err_opencl_atomic_init_constant Comment at: lib/Sema/SemaDecl.cpp:5724 @@ +5723,3 @@ + // Pipes can only be passed as arguments to a function. + if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion >= 200 && + R->isPipeType()) { is CL check really needed since we are accepting pipes only in CL2.0? Comment at: lib/Sema/SemaDecl.cpp:5735 @@ +5734,3 @@ + + // OpenCL v1.2 s6.5 p5 + // There is no generic address space name for program scope variables. Dead code here? Comment at: lib/Sema/SemaDecl.cpp:6745 @@ +6744,3 @@ +const BlockPointerType *BlkTy = T->getAs(); +assert(BlkTy && "Not a block pointer."); + this seems to be redundant considering the check above. Comment at: lib/Sema/SemaDecl.cpp:6760 @@ +6759,3 @@ +#if 0 + // OpenCL v2.0 s6.9.b + // An image type can only be used as a type of a function argument. Dead code! Comment at: lib/Sema/SemaDecl.cpp:7302 @@ -7209,2 +7302,2 @@ QualType PointeeType = PT->getPointeeType(); if (PointeeType->isPointerType()) I feel like exporting the full diff might be a good idea here. A lot of small framents hard to understand. "To get a full diff, use one of the following commands (or just use Arcanist to upload your patch): git diff -U99 other-branch svn diff --diff-cmd=diff -x -U99" Comment at: lib/Sema/SemaDecl.cpp:7308 @@ +7307,3 @@ +unsigned addrSpace = PointeeType.getAddressSpace(); +return (addrSpace != LangAS::opencl_global && +addrSpace != LangAS::opencl_constant && Why this change? Comment at: lib/Sema/SemaDecl.cpp:11466 @@ +11465,3 @@ + else if (getLangOpts().OpenCL) +// OpenCL spir-function need to be called with prototype, so we don't allow +// implicit function declarations in OpenCL Can you remove "spir-" from here? Comment at: lib/Sema/SemaExpr.cpp:6299 @@ +6298,3 @@ +if (checkBlockType(*this, LHS.get()) | checkBlockType(*this, RHS.get())) + return QualType(); + } Can we produce the diagnostic here and let checkBlockType only return true or false? Comment at: lib/Sema/SemaExpr.cpp:10094 @@ -10060,1 +10093,3 @@ Result = PT->getPointeeType(); +// OpenCL v2.0 s6.12.5 --The unary operators (* and &) cannot be used with a +// Block. Remove one -, add space after Comment at: lib/Sema/SemaInit.cpp:6138 @@ -6137,1 +6137,3 @@ + // OpenCL v2.0 s6.13.1.1 -- This macro can only be used to initialize atomic + // objects that are declared in program scope in the global address space. I guess you mean s6.13.11.1? Comment at: lib/Sema/SemaInit.cpp:6139 @@ +6138,3 @@ + // OpenCL v2.0 s6.13.1.1 -- This macro can only be used to initialize atomic + // objects that are declared in program scope in the global address space. + if (S.getLangOpts().OpenCL && S.getLangOpts().OpenCLVersion >= 200 && Not clear about the macro. Could you be more generic here i.e. write about initialization is generally disallowed. Comment at: lib/Sema/SemaInit.cpp:6143 @@ +6142,3 @@ +Qualifiers TyQualifiers = Entity.getType().getQualifiers(); +bool HasGlobalAS = TyQualifiers.hasAddressSpace() && + TyQualifiers.getAddressSpace() == LangAS::opencl_global; It would be sufficient to check: TyQualifiers.getAddressSpace() == LangAS::opencl_global Comment at: lib/Sema/SemaInit.cpp:6145 @@ +6144,3 @@ + TyQualifiers.getAddressSpace() == LangAS::opencl_global; +if (!HasGlobalAS && Entity.getKind