[PATCH] D49722: [CStringSyntaxChecker] Check strlcat sizeof check
devnexen added a comment. ping :) https://reviews.llvm.org/D49722 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D41458: [libc++][C++17] Elementary string conversions for integral types
Quuxplusone added a comment. @lichray: I'm interested in merging this patch into my libc++ fork, but the latest update seems to be missing a ton of files. For example `charconv_test_helpers.h` is included by one of the tests, but does not exist. Also there's a lot of boilerplate missing: you ought to add the new header to module.modulemap, and to double_include.sh.cpp, and so on. Might you upload a new patch anytime soon? Repository: rCXX libc++ https://reviews.llvm.org/D41458 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49833: [clangd] Receive compilationDatabasePath in 'initialize' request
malaperle added a comment. Was there any objection to this patch? It would have been nice to have this before the branching. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D49833 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50029: [COFF, ARM64] Enable SEH for ARM64 Windows
rnk accepted this revision. rnk added a comment. This revision is now accepted and ready to land. lgtm https://reviews.llvm.org/D50029 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49922: [P0936R0] add [[clang::lifetimebound]] attribute
rsmith added inline comments. Comment at: include/clang/Basic/AttrDocs.td:2371 +is retained by the return value of the annotated function +(or, for a constructor, in the value of the constructed object). +It is only supported in C++. aaron.ballman wrote: > I read this as allowing a `lifetimebound` attribute on a constructor, but > that seems to be an error case. A `lifetimebound` attribute is permitted on a parameter of a constructor. I've reworded to clarify. Comment at: lib/Parse/ParseDeclCXX.cpp:3811 case ParsedAttr::AT_CXX11NoReturn: + case ParsedAttr::AT_LifetimeBound: return true; aaron.ballman wrote: > Hmmm, this isn't a standards-based attribute yet. The only thing this > controls, however, is not parsing a duplicate attribute within the same > attribute specifier sequence as the standard is the only thing persnickety > enough to feel that warrants an error. > > My personal preference is to not disallow that, especially given that users > can write `void f() [[clang::lifetimebound]][[clang::lifetimebound]]` > and get no diagnostic. This also controls whether redundant parens are permitted, which is what I wanted to disallow. However, some testing of this has revealed that I actually do want an optional argument, so I'll leave the checking out for now, and we can talk about that in the next patch :) Comment at: lib/Sema/SemaDecl.cpp:6013 + // Check the attributes on the function type, if any. + if (auto *FD = dyn_cast()) { +for (TypeLoc TL = FD->getTypeSourceInfo()->getTypeLoc(); aaron.ballman wrote: > `const auto *` (and thread the const-correctness through). > > Actually, if you could double-check on the const correctness elsewhere in the > patch, that'd be useful, as it looks like there are other places that could > be similarly touched up. Done. I don't think it makes any difference, though: this constness is shallow, and doesn't defend against us somehow accidentally mutating the `TypeSourceInfo` (which is all we're looking at, and `TypeLoc` doesn't have a `const` view). Comment at: lib/Sema/SemaDecl.cpp:6022-6028 +if (!MD || MD->isStatic()) { + S.Diag(ATL.getAttrNameLoc(), diag::err_lifetimebound_no_object_param) + << !MD << ATL.getLocalSourceRange(); +} else if (isa(MD) || isa(MD)) { + S.Diag(ATL.getAttrNameLoc(), diag::err_lifetimebound_ctor_dtor) + << isa(MD) << ATL.getLocalSourceRange(); +} aaron.ballman wrote: > Can elide the braces. True, but the controlled statements are multi-line, so I'd prefer not to. :) Comment at: lib/Sema/SemaOverload.cpp:5233-5235 + if (From->getType()->isPointerType()) +return From; + return TemporaryMaterializationConversion(From); Reverted this change; I committed this separately. Comment at: lib/Sema/SemaType.cpp:7202-7207 + if (D.isDeclarationOfFunction()) { +CurType = S.Context.getAttributedType(AttributedType::attr_lifetimebound, + CurType, CurType); + } else { +Attr.diagnoseAppertainsTo(S, nullptr); + } aaron.ballman wrote: > Elide braces I'd prefer to not elide braces around a multi-line `if` body, and I'd strongly prefer to avoid bracing an `if` and not its `else`. https://reviews.llvm.org/D49922 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49922: [P0936R0] add [[clang::lifetimebound]] attribute
rsmith updated this revision to Diff 158149. rsmith marked 8 inline comments as done. https://reviews.llvm.org/D49922 Files: include/clang/AST/Type.h include/clang/Basic/Attr.td include/clang/Basic/AttrDocs.td include/clang/Basic/DiagnosticSemaKinds.td lib/AST/Type.cpp lib/AST/TypePrinter.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaDeclAttr.cpp lib/Sema/SemaInit.cpp lib/Sema/SemaType.cpp test/SemaCXX/attr-lifetimebound.cpp utils/TableGen/ClangAttrEmitter.cpp Index: utils/TableGen/ClangAttrEmitter.cpp === --- utils/TableGen/ClangAttrEmitter.cpp +++ utils/TableGen/ClangAttrEmitter.cpp @@ -3305,11 +3305,16 @@ // Otherwise, generate an appertainsTo check specific to this attribute which // checks all of the given subjects against the Decl passed in. Return the // name of that check to the caller. + // + // If D is null, that means the attribute was not applied to a declaration + // at all (for instance because it was applied to a type), or that the caller + // has determined that the check should fail (perhaps prior to the creation + // of the declaration). std::string FnName = "check" + Attr.getName().str() + "AppertainsTo"; std::stringstream SS; SS << "static bool " << FnName << "(Sema , const ParsedAttr , "; SS << "const Decl *D) {\n"; - SS << " if ("; + SS << " if (!D || ("; for (auto I = Subjects.begin(), E = Subjects.end(); I != E; ++I) { // If the subject has custom code associated with it, generate a function // for it. The function cannot be inlined into this check (yet) because it @@ -3325,7 +3330,7 @@ if (I + 1 != E) SS << " && "; } - SS << ") {\n"; + SS << ")) {\n"; SS << "S.Diag(Attr.getLoc(), diag::"; SS << (Warn ? "warn_attribute_wrong_decl_type_str" : "err_attribute_wrong_decl_type_str"); Index: test/SemaCXX/attr-lifetimebound.cpp === --- test/SemaCXX/attr-lifetimebound.cpp +++ test/SemaCXX/attr-lifetimebound.cpp @@ -0,0 +1,114 @@ +// RUN: %clang_cc1 -std=c++2a -verify %s + +namespace usage_invalid { + // FIXME: Diagnose void return type? + void voidreturn(int [[clang::lifetimebound]]); + + int *not_class_member() [[clang::lifetimebound]]; // expected-error {{non-member function has no implicit object parameter}} + struct A { +A() [[clang::lifetimebound]]; // expected-error {{cannot be applied to a constructor}} +~A() [[clang::lifetimebound]]; // expected-error {{cannot be applied to a destructor}} +static int *static_class_member() [[clang::lifetimebound]]; // expected-error {{static member function has no implicit object parameter}} +int not_function [[clang::lifetimebound]]; // expected-error {{only applies to parameters and implicit object parameters}} +int [[clang::lifetimebound]] also_not_function; // expected-error {{cannot be applied to types}} + }; +} + +namespace usage_ok { + struct IntRef { int *target; }; + + int (int [[clang::lifetimebound]]); + int (IntRef param [[clang::lifetimebound]]); + + // Do not diagnose non-void return types; they can still be lifetime-bound. + long long ptrintcast(int [[clang::lifetimebound]]) { +return (long long) + } + // Likewise. + int (long long param [[clang::lifetimebound]]) { +return *(int*)param; + } + + struct A { +A(); +A(int); +int *class_member() [[clang::lifetimebound]]; +operator int*() [[clang::lifetimebound]]; + }; + + int *p = A().class_member(); // expected-warning {{temporary whose address is used as value of local variable 'p' will be destroyed at the end of the full-expression}} + int *q = A(); // expected-warning {{temporary whose address is used as value of local variable 'q' will be destroyed at the end of the full-expression}} + int *r = A(1); // expected-warning {{temporary whose address is used as value of local variable 'r' will be destroyed at the end of the full-expression}} +} + +# 1 "" 1 3 +namespace std { + using size_t = __SIZE_TYPE__; + struct string { +string(); +string(const char*); + +char [](size_t) const [[clang::lifetimebound]]; + }; + string operator""s(const char *, size_t); + + struct string_view { +string_view(); +string_view(const char *p [[clang::lifetimebound]]); +string_view(const string [[clang::lifetimebound]]); + }; + string_view operator""sv(const char *, size_t); + + struct vector { +int *data(); +size_t size(); + }; + + template struct map {}; +} +# 68 "attr-lifetimebound.cpp" 2 + +using std::operator""s; +using std::operator""sv; + +namespace p0936r0_examples { + std::string_view s = "foo"s; // expected-warning {{temporary}} + + std::string operator+(std::string_view s1, std::string_view s2); + void f() { +std::string_view sv = "hi"; +std::string_view sv2 = sv + sv; // expected-warning {{temporary}} +sv2 = sv + sv; // FIXME: can we infer that we
[PATCH] D49953: [compiler-rt] Add a routine to specify the mode used when creating profile dirs.
mattd updated this revision to Diff 158144. mattd added a comment. - Added a test that creates a directory via __llvm_profile_recursive_mkdir and verifies the mode. - I intend to only commit one of the two tests, but wanted to provide a more specific/detailed test. - I don't know if we really want such a specific test, but it's a potential start at one. - We can definitely ignore windows here (since there is no mode passed to its equivalent to mkdir). - I don't know if there are other systems we need to ignore, e.g., android? - I'm still hesitant to adding the more specific test, it feels very os specific. - I didn't see an alternative to FileCheck's (deprecated) %T, so I wrote a simple 'dirname' routine that is not dependent on libgen. - I hope that is sufficient for this test case. https://reviews.llvm.org/D49953 Files: lib/profile/InstrProfilingUtil.c lib/profile/InstrProfilingUtil.h test/profile/instrprof-set-dir-mode.c test/profile/instrprof-set-dir-mode2.c Index: test/profile/instrprof-set-dir-mode2.c === --- /dev/null +++ test/profile/instrprof-set-dir-mode2.c @@ -0,0 +1,73 @@ +// UNSUPPORTED: windows +// RUN: %clang_pgogen -o %t %s -DTESTPATH=\"%t\" +// RUN: %run %t + +#include +#include +#include +#include +#include + +void __llvm_profile_set_dir_mode(uint32_t Mode); +unsigned __llvm_profile_get_dir_mode(void); +void __llvm_profile_recursive_mkdir(char *Path); + +/* Drop characters starting from the last '/'. */ +static char *dirname(const char *Filename) { + const char *End; + if (!(End = strrchr(Filename, '/'))) +return NULL; + char *D = strdup(Filename); + if ((intptr_t)End - (intptr_t)Filename - 1 < 0) +return NULL; + D[End - Filename - 1] = '\0'; + return D; +} + +static char *join(const char *Dir, const char *Subdir) { + char *Joined = malloc(strlen(Dir) + strlen(Subdir) + 2); + if (!Joined) +return NULL; + sprintf(Joined, "%s/%s", Dir, Subdir); + return Joined; +} + +static int test(uint32_t Mode, const char *Subdir) { + int Ret = 0; + char *Base, *Dir; + + /* Truncate the path removing the filename and adding Subdir. */ + if (!(Base = dirname(TESTPATH))) +return -1; + if (!(Dir = join(Base, Subdir))) +return -1; + + /* Create a dir and set the mode accordingly. */ + __llvm_profile_set_dir_mode(Mode); + __llvm_profile_recursive_mkdir(Dir); + + if (Mode != __llvm_profile_get_dir_mode()) +Ret = -1; + else { +const uint32_t Expected = ~umask(0) & Mode; +struct stat DirSt; +if (stat(Dir, ) == -1) + Ret = -1; +else if (DirSt.st_mode != Expected) { + printf("Modes do not match: Expected %o but found %o (%s)\n", Expected, + DirSt.st_mode, Dir); + Ret = -1; +} + } + + free(Base); + free(Dir); + return Ret; +} + +int main(int argc, const char *argv[]) { + if (test(S_IFDIR | 0777, "/foo/bar/baz/") || + test(S_IFDIR | 0666, "/foo/bar/qux/")) +return -1; + return 0; +} Index: test/profile/instrprof-set-dir-mode.c === --- /dev/null +++ test/profile/instrprof-set-dir-mode.c @@ -0,0 +1,17 @@ +// RUN: %clang_pgogen -o %t %s +// RUN: %run %t + +void __llvm_profile_set_dir_mode(unsigned Mode); +unsigned __llvm_profile_get_dir_mode(void); + +int main(void) { + __llvm_profile_set_dir_mode(0777); + if (__llvm_profile_get_dir_mode() != 0777) +return -1; + + __llvm_profile_set_dir_mode(0666); + if (__llvm_profile_get_dir_mode() != 0666) +return -1; + + return 0; +} Index: lib/profile/InstrProfilingUtil.h === --- lib/profile/InstrProfilingUtil.h +++ lib/profile/InstrProfilingUtil.h @@ -16,6 +16,12 @@ /*! \brief Create a directory tree. */ void __llvm_profile_recursive_mkdir(char *Pathname); +/*! Set the mode used when creating profile directories. */ +void __llvm_profile_set_dir_mode(unsigned Mode); + +/*! Return the directory creation mode. */ +unsigned __llvm_profile_get_dir_mode(void); + int lprofLockFd(int fd); int lprofUnlockFd(int fd); Index: lib/profile/InstrProfilingUtil.c === --- lib/profile/InstrProfilingUtil.c +++ lib/profile/InstrProfilingUtil.c @@ -35,6 +35,8 @@ #include "InstrProfiling.h" #include "InstrProfilingUtil.h" +COMPILER_RT_WEAK unsigned lprofDirMode = 0755; + COMPILER_RT_VISIBILITY void __llvm_profile_recursive_mkdir(char *path) { int i; @@ -47,12 +49,19 @@ #ifdef _WIN32 _mkdir(path); #else -mkdir(path, 0755); /* Some of these will fail, ignore it. */ +/* Some of these will fail, ignore it. */ +mkdir(path, __llvm_profile_get_dir_mode()); #endif path[i] = save; } } +COMPILER_RT_VISIBILITY +void __llvm_profile_set_dir_mode(unsigned Mode) { lprofDirMode = Mode; } + +COMPILER_RT_VISIBILITY +unsigned __llvm_profile_get_dir_mode(void) { return
[PATCH] D50029: [COFF, ARM64] Enable SEH for ARM64 Windows
mgrang updated this revision to Diff 158147. mgrang added a comment. Addressed comments. https://reviews.llvm.org/D50029 Files: include/clang/Basic/TargetInfo.h test/CodeGen/exceptions-seh-finally.c test/CodeGen/exceptions-seh.c Index: test/CodeGen/exceptions-seh.c === --- test/CodeGen/exceptions-seh.c +++ test/CodeGen/exceptions-seh.c @@ -2,6 +2,8 @@ // RUN: | FileCheck %s --check-prefix=CHECK --check-prefix=X64 // RUN: %clang_cc1 %s -triple i686-pc-win32 -fms-extensions -emit-llvm -o - \ // RUN: | FileCheck %s --check-prefix=CHECK --check-prefix=X86 +// RUN: %clang_cc1 %s -triple aarch64-windows -fms-extensions -emit-llvm -o - \ +// RUN: | FileCheck %s --check-prefixes=CHECK,ARM64 // RUN: %clang_cc1 %s -triple i686-pc-windows-gnu -fms-extensions -emit-llvm -o - \ // RUN: | FileCheck %s --check-prefix=X86-GNU // RUN: %clang_cc1 %s -triple x86_64-pc-windows-gnu -fms-extensions -emit-llvm -o - \ @@ -29,12 +31,14 @@ // CHECK-LABEL: define dso_local i32 @safe_div(i32 %numerator, i32 %denominator, i32* %res) // X64-SAME: personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) +// ARM64-SAME:personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) // X86-SAME: personality i8* bitcast (i32 (...)* @_except_handler3 to i8*) // CHECK: invoke void @try_body(i32 %{{.*}}, i32 %{{.*}}, i32* %{{.*}}) #[[NOINLINE:[0-9]+]] // CHECK: to label %{{.*}} unwind label %[[catchpad:[^ ]*]] // // CHECK: [[catchpad]] // X64: %[[padtoken:[^ ]*]] = catchpad within %{{[^ ]*}} [i8* null] +// ARM64: %[[padtoken:[^ ]*]] = catchpad within %{{[^ ]*}} [i8* null] // X86: %[[padtoken:[^ ]*]] = catchpad within %{{[^ ]*}} [i8* bitcast (i32 ()* @"?filt$0@0@safe_div@@" to i8*)] // CHECK-NEXT: catchret from %[[padtoken]] to label %[[except:[^ ]*]] // @@ -76,8 +80,10 @@ // CHECK-LABEL: define dso_local i32 @filter_expr_capture() // X64-SAME: personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) +// ARM64-SAME: personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) // X86-SAME: personality i8* bitcast (i32 (...)* @_except_handler3 to i8*) // X64: call void (...) @llvm.localescape(i32* %[[r:[^ ,]*]]) +// ARM64: call void (...) @llvm.localescape(i32* %[[r:[^ ,]*]]) // X86: call void (...) @llvm.localescape(i32* %[[r:[^ ,]*]], i32* %[[code:[^ ,]*]]) // CHECK: store i32 42, i32* %[[r]] // CHECK: invoke void @j() #[[NOINLINE]] @@ -92,6 +98,10 @@ // X64: %[[fp:[^ ]*]] = call i8* @llvm.x86.seh.recoverfp(i8* bitcast (i32 ()* @filter_expr_capture to i8*), i8* %frame_pointer) // X64: call i8* @llvm.localrecover(i8* bitcast (i32 ()* @filter_expr_capture to i8*), i8* %[[fp]], i32 0) // +// ARM64-LABEL: define internal i32 @"?filt$0@0@filter_expr_capture@@"(i8* %exception_pointers, i8* %frame_pointer) +// ARM64: %[[fp:[^ ]*]] = call i8* @llvm.x86.seh.recoverfp(i8* bitcast (i32 ()* @filter_expr_capture to i8*), i8* %frame_pointer) +// ARM64: call i8* @llvm.localrecover(i8* bitcast (i32 ()* @filter_expr_capture to i8*), i8* %[[fp]], i32 0) +// // X86-LABEL: define internal i32 @"?filt$0@0@filter_expr_capture@@"() // X86: %[[ebp:[^ ]*]] = call i8* @llvm.frameaddress(i32 1) // X86: %[[fp:[^ ]*]] = call i8* @llvm.x86.seh.recoverfp(i8* bitcast (i32 ()* @filter_expr_capture to i8*), i8* %[[ebp]]) @@ -116,6 +126,7 @@ } // CHECK-LABEL: define dso_local i32 @nested_try() // X64-SAME: personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) +// ARM64-SAME: personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) // X86-SAME: personality i8* bitcast (i32 (...)* @_except_handler3 to i8*) // CHECK: store i32 42, i32* %[[r:[^ ,]*]] // CHECK: invoke void @j() #[[NOINLINE]] @@ -176,6 +187,7 @@ } // CHECK-LABEL: define dso_local i32 @basic_finally(i32 %g) // X64-SAME: personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) +// ARM64-SAME: personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) // X86-SAME: personality i8* bitcast (i32 (...)* @_except_handler3 to i8*) // CHECK: %[[g_addr:[^ ]*]] = alloca i32, align 4 // CHECK: call void (...) @llvm.localescape(i32* %[[g_addr]]) @@ -275,6 +287,8 @@ // CHECK: catchret from %[[pad]] // X64: %[[code:[^ ]*]] = call i32 @llvm.eh.exceptioncode(token %[[pad]]) // X64: store i32 %[[code]], i32* %[[code_slot]] +// ARM64: %[[code:[^ ]*]] = call i32 @llvm.eh.exceptioncode(token %[[pad]]) +// ARM64: store i32 %[[code]], i32* %[[code_slot]] // CHECK: %[[ret1:[^ ]*]] = load i32, i32* %[[code_slot]] // CHECK: store i32 %[[ret1]], i32* %[[ret_slot]] // CHECK: %[[ret2:[^ ]*]] = load i32, i32* %[[ret_slot]] Index: test/CodeGen/exceptions-seh-finally.c === --- test/CodeGen/exceptions-seh-finally.c +++ test/CodeGen/exceptions-seh-finally.c @@ -1,5 +1,6 @@ // RUN: %clang_cc1 %s -triple x86_64-pc-win32
[PATCH] D50002: [coroutines] Fix handling of dependent co_await in StmtProfiler
This revision was automatically updated to reflect the committed changes. Closed by commit rL338343: [coroutines] Fix handling of dependent co_await in StmtProfiler. (authored by rsmith, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D50002?vs=158045=158145#toc Repository: rL LLVM https://reviews.llvm.org/D50002 Files: cfe/trunk/lib/AST/StmtProfile.cpp cfe/trunk/test/PCH/coroutines.cpp Index: cfe/trunk/lib/AST/StmtProfile.cpp === --- cfe/trunk/lib/AST/StmtProfile.cpp +++ cfe/trunk/lib/AST/StmtProfile.cpp @@ -1277,7 +1277,6 @@ case OO_Arrow: case OO_Call: case OO_Conditional: - case OO_Coawait: case NUM_OVERLOADED_OPERATORS: llvm_unreachable("Invalid operator call kind"); @@ -1449,6 +1448,10 @@ case OO_Subscript: return Stmt::ArraySubscriptExprClass; + + case OO_Coawait: +UnaryOp = UO_Coawait; +return Stmt::UnaryOperatorClass; } llvm_unreachable("Invalid overloaded operator expression"); Index: cfe/trunk/test/PCH/coroutines.cpp === --- cfe/trunk/test/PCH/coroutines.cpp +++ cfe/trunk/test/PCH/coroutines.cpp @@ -66,6 +66,14 @@ co_return x; // checks coreturn_stmt with expr } +struct S {}; +S operator co_await(S) { return S(); } + +template +int f3(T x) { + co_await x; // checks dependent_coawait with overloaded co_await operator +} + #else // expected-no-diagnostics Index: cfe/trunk/lib/AST/StmtProfile.cpp === --- cfe/trunk/lib/AST/StmtProfile.cpp +++ cfe/trunk/lib/AST/StmtProfile.cpp @@ -1277,7 +1277,6 @@ case OO_Arrow: case OO_Call: case OO_Conditional: - case OO_Coawait: case NUM_OVERLOADED_OPERATORS: llvm_unreachable("Invalid operator call kind"); @@ -1449,6 +1448,10 @@ case OO_Subscript: return Stmt::ArraySubscriptExprClass; + + case OO_Coawait: +UnaryOp = UO_Coawait; +return Stmt::UnaryOperatorClass; } llvm_unreachable("Invalid overloaded operator expression"); Index: cfe/trunk/test/PCH/coroutines.cpp === --- cfe/trunk/test/PCH/coroutines.cpp +++ cfe/trunk/test/PCH/coroutines.cpp @@ -66,6 +66,14 @@ co_return x; // checks coreturn_stmt with expr } +struct S {}; +S operator co_await(S) { return S(); } + +template +int f3(T x) { + co_await x; // checks dependent_coawait with overloaded co_await operator +} + #else // expected-no-diagnostics ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r338343 - [coroutines] Fix handling of dependent co_await in StmtProfiler.
Author: rsmith Date: Mon Jul 30 17:47:41 2018 New Revision: 338343 URL: http://llvm.org/viewvc/llvm-project?rev=338343=rev Log: [coroutines] Fix handling of dependent co_await in StmtProfiler. Fix "Invalid operator call kind" error (llvm_unreachable) in DecodeOperatorCall when profiling a dependent co_await. Patch by Victor Zverovich! Differential Revision: https://reviews.llvm.org/D50002 Modified: cfe/trunk/lib/AST/StmtProfile.cpp cfe/trunk/test/PCH/coroutines.cpp Modified: cfe/trunk/lib/AST/StmtProfile.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=338343=338342=338343=diff == --- cfe/trunk/lib/AST/StmtProfile.cpp (original) +++ cfe/trunk/lib/AST/StmtProfile.cpp Mon Jul 30 17:47:41 2018 @@ -1277,7 +1277,6 @@ static Stmt::StmtClass DecodeOperatorCal case OO_Arrow: case OO_Call: case OO_Conditional: - case OO_Coawait: case NUM_OVERLOADED_OPERATORS: llvm_unreachable("Invalid operator call kind"); @@ -1449,6 +1448,10 @@ static Stmt::StmtClass DecodeOperatorCal case OO_Subscript: return Stmt::ArraySubscriptExprClass; + + case OO_Coawait: +UnaryOp = UO_Coawait; +return Stmt::UnaryOperatorClass; } llvm_unreachable("Invalid overloaded operator expression"); Modified: cfe/trunk/test/PCH/coroutines.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/coroutines.cpp?rev=338343=338342=338343=diff == --- cfe/trunk/test/PCH/coroutines.cpp (original) +++ cfe/trunk/test/PCH/coroutines.cpp Mon Jul 30 17:47:41 2018 @@ -66,6 +66,14 @@ int f2(T x) { // checks coawait_expr an co_return x; // checks coreturn_stmt with expr } +struct S {}; +S operator co_await(S) { return S(); } + +template +int f3(T x) { + co_await x; // checks dependent_coawait with overloaded co_await operator +} + #else // expected-no-diagnostics ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r338339 - [analyzer] Rename test: cxx17-mandatory-elision.cpp -> copy-elision.cpp
Author: dergachev Date: Mon Jul 30 17:18:35 2018 New Revision: 338339 URL: http://llvm.org/viewvc/llvm-project?rev=338339=rev Log: [analyzer] Rename test: cxx17-mandatory-elision.cpp -> copy-elision.cpp It reflects its contents more accurately. No functional change intended. Added: cfe/trunk/test/Analysis/copy-elision.cpp Removed: cfe/trunk/test/Analysis/cxx17-mandatory-elision.cpp Added: cfe/trunk/test/Analysis/copy-elision.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/copy-elision.cpp?rev=338339=auto == --- cfe/trunk/test/Analysis/copy-elision.cpp (added) +++ cfe/trunk/test/Analysis/copy-elision.cpp Mon Jul 30 17:18:35 2018 @@ -0,0 +1,304 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -std=c++11 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -std=c++17 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -std=c++11 -analyzer-config elide-constructors=false -DNO_ELIDE_FLAG -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -std=c++17 -analyzer-config elide-constructors=false -DNO_ELIDE_FLAG -verify %s + +// Copy elision always occurs in C++17, otherwise it's under +// an on-by-default flag. +#if __cplusplus >= 201703L + #define ELIDE 1 +#else + #ifndef NO_ELIDE_FLAG +#define ELIDE 1 + #endif +#endif + +void clang_analyzer_eval(bool); + +namespace variable_functional_cast_crash { + +struct A { + A(int) {} +}; + +void foo() { + A a = A(0); +} + +struct B { + A a; + B(): a(A(0)) {} +}; + +} // namespace variable_functional_cast_crash + + +namespace ctor_initializer { + +struct S { + int x, y, z; +}; + +struct T { + S s; + int w; + T(int w): s(), w(w) {} +}; + +class C { + T t; +public: + C() : t(T(4)) { +S s = {1, 2, 3}; +t.s = s; +// FIXME: Should be TRUE regardless of copy elision. +clang_analyzer_eval(t.w == 4); +#ifdef ELIDE +// expected-warning@-2{{TRUE}} +#else +// expected-warning@-4{{UNKNOWN}} +#endif + } +}; + + +struct A { + int x; + A(): x(0) {} + ~A() {} +}; + +struct B { + A a; + B() : a(A()) {} +}; + +void foo() { + B b; + clang_analyzer_eval(b.a.x == 0); // expected-warning{{TRUE}} +} + +} // namespace ctor_initializer + + +namespace elision_on_ternary_op_branches { +class C1 { + int x; +public: + C1(int x): x(x) {} + int getX() const { return x; } + ~C1(); +}; + +class C2 { + int x; + int y; +public: + C2(int x, int y): x(x), y(y) {} + int getX() const { return x; } + int getY() const { return y; } + ~C2(); +}; + +void foo(int coin) { + C1 c1 = coin ? C1(1) : C1(2); + if (coin) { +clang_analyzer_eval(c1.getX() == 1); // expected-warning{{TRUE}} + } else { +clang_analyzer_eval(c1.getX() == 2); // expected-warning{{TRUE}} + } + C2 c2 = coin ? C2(3, 4) : C2(5, 6); + if (coin) { +clang_analyzer_eval(c2.getX() == 3); // expected-warning{{TRUE}} +clang_analyzer_eval(c2.getY() == 4); // expected-warning{{TRUE}} + } else { +clang_analyzer_eval(c2.getX() == 5); // expected-warning{{TRUE}} +clang_analyzer_eval(c2.getY() == 6); // expected-warning{{TRUE}} + } +} +} // namespace elision_on_ternary_op_branches + + +namespace address_vector_tests { + +template struct AddressVector { + T *buf[10]; + int len; + + AddressVector() : len(0) {} + + void push(T *t) { +buf[len] = t; +++len; + } +}; + +class ClassWithoutDestructor { + AddressVector + +public: + ClassWithoutDestructor(AddressVector ) : v(v) { +v.push(this); + } + + ClassWithoutDestructor(ClassWithoutDestructor &) : v(c.v) { v.push(this); } + ClassWithoutDestructor(const ClassWithoutDestructor ) : v(c.v) { +v.push(this); + } +}; + +ClassWithoutDestructor make1(AddressVector ) { + return ClassWithoutDestructor(v); +} +ClassWithoutDestructor make2(AddressVector ) { + return make1(v); +} +ClassWithoutDestructor make3(AddressVector ) { + return make2(v); +} + +void testMultipleReturns() { + AddressVector v; + ClassWithoutDestructor c = make3(v); + +#if ELIDE + clang_analyzer_eval(v.len == 1); // expected-warning{{TRUE}} + clang_analyzer_eval(v.buf[0] == ); // expected-warning{{TRUE}} +#else + clang_analyzer_eval(v.len == 5); // expected-warning{{TRUE}} + clang_analyzer_eval(v.buf[0] != v.buf[1]); // expected-warning{{TRUE}} + clang_analyzer_eval(v.buf[1] != v.buf[2]); // expected-warning{{TRUE}} + clang_analyzer_eval(v.buf[2] != v.buf[3]); // expected-warning{{TRUE}} + clang_analyzer_eval(v.buf[3] != v.buf[4]); // expected-warning{{TRUE}} + clang_analyzer_eval(v.buf[4] == ); // expected-warning{{TRUE}} +#endif +} + +class ClassWithDestructor { + AddressVector + +public: + ClassWithDestructor(AddressVector ) : v(v) { +v.push(this); + } + + ClassWithDestructor(ClassWithDestructor &) : v(c.v) { v.push(this); } + ClassWithDestructor(const ClassWithDestructor ) : v(c.v) { +
[PATCH] D49766: Fix a crash when an error occurs in Template and the initializer is a nullptr for C++17
This revision was automatically updated to reflect the committed changes. Closed by commit rL338338: [Sema] Relax a failing assert in TemplateArgumentLoc (authored by epilk, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D49766?vs=157730=158138#toc Repository: rL LLVM https://reviews.llvm.org/D49766 Files: cfe/trunk/include/clang/AST/TemplateBase.h cfe/trunk/test/SemaObjCXX/class-templ-error-null-init.mm Index: cfe/trunk/include/clang/AST/TemplateBase.h === --- cfe/trunk/include/clang/AST/TemplateBase.h +++ cfe/trunk/include/clang/AST/TemplateBase.h @@ -465,7 +465,13 @@ TemplateArgumentLoc(const TemplateArgument , Expr *E) : Argument(Argument), LocInfo(E) { -assert(Argument.getKind() == TemplateArgument::Expression); + +// Permit any kind of template argument that can be represented with an +// expression +assert(Argument.getKind() == TemplateArgument::NullPtr || + Argument.getKind() == TemplateArgument::Integral || + Argument.getKind() == TemplateArgument::Declaration || + Argument.getKind() == TemplateArgument::Expression); } TemplateArgumentLoc(const TemplateArgument , Index: cfe/trunk/test/SemaObjCXX/class-templ-error-null-init.mm === --- cfe/trunk/test/SemaObjCXX/class-templ-error-null-init.mm +++ cfe/trunk/test/SemaObjCXX/class-templ-error-null-init.mm @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s +// expected-no-diagnostics +template +struct e { +e(a) {} +}; +e c(0); Index: cfe/trunk/include/clang/AST/TemplateBase.h === --- cfe/trunk/include/clang/AST/TemplateBase.h +++ cfe/trunk/include/clang/AST/TemplateBase.h @@ -465,7 +465,13 @@ TemplateArgumentLoc(const TemplateArgument , Expr *E) : Argument(Argument), LocInfo(E) { -assert(Argument.getKind() == TemplateArgument::Expression); + +// Permit any kind of template argument that can be represented with an +// expression +assert(Argument.getKind() == TemplateArgument::NullPtr || + Argument.getKind() == TemplateArgument::Integral || + Argument.getKind() == TemplateArgument::Declaration || + Argument.getKind() == TemplateArgument::Expression); } TemplateArgumentLoc(const TemplateArgument , Index: cfe/trunk/test/SemaObjCXX/class-templ-error-null-init.mm === --- cfe/trunk/test/SemaObjCXX/class-templ-error-null-init.mm +++ cfe/trunk/test/SemaObjCXX/class-templ-error-null-init.mm @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s +// expected-no-diagnostics +template +struct e { +e(a) {} +}; +e c(0); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r338338 - [Sema] Relax a failing assert in TemplateArgumentLoc
Author: epilk Date: Mon Jul 30 17:18:30 2018 New Revision: 338338 URL: http://llvm.org/viewvc/llvm-project?rev=338338=rev Log: [Sema] Relax a failing assert in TemplateArgumentLoc Any of these template argument kinds can be represented with an expression, so accept them in this constructor. Patch by Balaji Iyer! rdar://41459965 Differential revision: https://reviews.llvm.org/D49766 Added: cfe/trunk/test/SemaObjCXX/class-templ-error-null-init.mm Modified: cfe/trunk/include/clang/AST/TemplateBase.h Modified: cfe/trunk/include/clang/AST/TemplateBase.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TemplateBase.h?rev=338338=338337=338338=diff == --- cfe/trunk/include/clang/AST/TemplateBase.h (original) +++ cfe/trunk/include/clang/AST/TemplateBase.h Mon Jul 30 17:18:30 2018 @@ -465,7 +465,13 @@ public: TemplateArgumentLoc(const TemplateArgument , Expr *E) : Argument(Argument), LocInfo(E) { -assert(Argument.getKind() == TemplateArgument::Expression); + +// Permit any kind of template argument that can be represented with an +// expression +assert(Argument.getKind() == TemplateArgument::NullPtr || + Argument.getKind() == TemplateArgument::Integral || + Argument.getKind() == TemplateArgument::Declaration || + Argument.getKind() == TemplateArgument::Expression); } TemplateArgumentLoc(const TemplateArgument , Added: cfe/trunk/test/SemaObjCXX/class-templ-error-null-init.mm URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/class-templ-error-null-init.mm?rev=338338=auto == --- cfe/trunk/test/SemaObjCXX/class-templ-error-null-init.mm (added) +++ cfe/trunk/test/SemaObjCXX/class-templ-error-null-init.mm Mon Jul 30 17:18:30 2018 @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s +// expected-no-diagnostics +template +struct e { +e(a) {} +}; +e c(0); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50029: [COFF, ARM64] Enable SEH for ARM64 Windows
rnk added inline comments. Comment at: test/CodeGen/exceptions-seh.c:10 +// RUN: %clang_cc1 %s -triple aarch64-windows -fms-extensions -emit-llvm -o - \ +// RUN: | FileCheck %s --check-prefix=X64-GNU mgrang wrote: > Is it OK to re-use the X64-GNU check prefix here or should I create one > called X64-MS? I'd put this before the GNU tests after the MS tests, since that's what it's targeting. You can include the CHECK lines with `--check-prefixes=CHECK,ARM64`. Comment at: test/CodeGen/exceptions-seh.c:33 // CHECK-LABEL: define dso_local i32 @safe_div(i32 %numerator, i32 %denominator, i32* %res) // X64-SAME: personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) // X86-SAME: personality i8* bitcast (i32 (...)* @_except_handler3 to i8*) Looks like ARM64 wants __C_specific_handler as well. Repository: rC Clang https://reviews.llvm.org/D50029 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50029: [COFF, ARM64] Enable SEH for ARM64 Windows
mgrang added inline comments. Comment at: test/CodeGen/exceptions-seh.c:10 +// RUN: %clang_cc1 %s -triple aarch64-windows -fms-extensions -emit-llvm -o - \ +// RUN: | FileCheck %s --check-prefix=X64-GNU Is it OK to re-use the X64-GNU check prefix here or should I create one called X64-MS? Repository: rC Clang https://reviews.llvm.org/D50029 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50029: [COFF, ARM64] Enable SEH for ARM64 Windows
mgrang created this revision. mgrang added reviewers: rnk, mstorsjo, ssijaric, haripul, TomTan. Herald added subscribers: chrib, kristof.beyls. Repository: rC Clang https://reviews.llvm.org/D50029 Files: include/clang/Basic/TargetInfo.h test/CodeGen/exceptions-seh-finally.c test/CodeGen/exceptions-seh.c Index: test/CodeGen/exceptions-seh.c === --- test/CodeGen/exceptions-seh.c +++ test/CodeGen/exceptions-seh.c @@ -6,6 +6,8 @@ // RUN: | FileCheck %s --check-prefix=X86-GNU // RUN: %clang_cc1 %s -triple x86_64-pc-windows-gnu -fms-extensions -emit-llvm -o - \ // RUN: | FileCheck %s --check-prefix=X64-GNU +// RUN: %clang_cc1 %s -triple aarch64-windows -fms-extensions -emit-llvm -o - \ +// RUN: | FileCheck %s --check-prefix=X64-GNU void try_body(int numerator, int denominator, int *myres) { *myres = numerator / denominator; Index: test/CodeGen/exceptions-seh-finally.c === --- test/CodeGen/exceptions-seh-finally.c +++ test/CodeGen/exceptions-seh-finally.c @@ -1,5 +1,6 @@ // RUN: %clang_cc1 %s -triple x86_64-pc-win32 -fms-extensions -emit-llvm -o - | FileCheck %s // RUN: %clang_cc1 %s -triple i686-pc-win32 -fms-extensions -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple aarch64-windows -fms-extensions -emit-llvm -o - | FileCheck %s void abort(void) __attribute__((noreturn)); void might_crash(void); Index: include/clang/Basic/TargetInfo.h === --- include/clang/Basic/TargetInfo.h +++ include/clang/Basic/TargetInfo.h @@ -1139,7 +1139,8 @@ bool isSEHTrySupported() const { return getTriple().isOSWindows() && (getTriple().getArch() == llvm::Triple::x86 || -getTriple().getArch() == llvm::Triple::x86_64); +getTriple().getArch() == llvm::Triple::x86_64 || +getTriple().getArch() == llvm::Triple::aarch64); } /// Return true if {|} are normal characters in the asm string. Index: test/CodeGen/exceptions-seh.c === --- test/CodeGen/exceptions-seh.c +++ test/CodeGen/exceptions-seh.c @@ -6,6 +6,8 @@ // RUN: | FileCheck %s --check-prefix=X86-GNU // RUN: %clang_cc1 %s -triple x86_64-pc-windows-gnu -fms-extensions -emit-llvm -o - \ // RUN: | FileCheck %s --check-prefix=X64-GNU +// RUN: %clang_cc1 %s -triple aarch64-windows -fms-extensions -emit-llvm -o - \ +// RUN: | FileCheck %s --check-prefix=X64-GNU void try_body(int numerator, int denominator, int *myres) { *myres = numerator / denominator; Index: test/CodeGen/exceptions-seh-finally.c === --- test/CodeGen/exceptions-seh-finally.c +++ test/CodeGen/exceptions-seh-finally.c @@ -1,5 +1,6 @@ // RUN: %clang_cc1 %s -triple x86_64-pc-win32 -fms-extensions -emit-llvm -o - | FileCheck %s // RUN: %clang_cc1 %s -triple i686-pc-win32 -fms-extensions -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple aarch64-windows -fms-extensions -emit-llvm -o - | FileCheck %s void abort(void) __attribute__((noreturn)); void might_crash(void); Index: include/clang/Basic/TargetInfo.h === --- include/clang/Basic/TargetInfo.h +++ include/clang/Basic/TargetInfo.h @@ -1139,7 +1139,8 @@ bool isSEHTrySupported() const { return getTriple().isOSWindows() && (getTriple().getArch() == llvm::Triple::x86 || -getTriple().getArch() == llvm::Triple::x86_64); +getTriple().getArch() == llvm::Triple::x86_64 || +getTriple().getArch() == llvm::Triple::aarch64); } /// Return true if {|} are normal characters in the asm string. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48436: [analyzer][UninitializedObjectChecker] Fixed a false negative by no longer filtering out certain constructor calls
NoQ added inline comments. Comment at: lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp:681-689 +Optional OtherObject = +getObjectVal(OtherCtor, Context); +if (!OtherObject) + continue; + +// If the CurrentObject is a field of OtherObject, it will be analyzed +// during the analysis of OtherObject. Szelethus wrote: > NoQ wrote: > > Szelethus wrote: > > > NoQ wrote: > > > > It seems safer to look at `CXXConstructExpr::getConstructionKind()`. > > > > > > > > Taking a `LazyCompoundVal` and converting it back to a region is > > > > definitely a bad idea because the region within `LazyCompoundVal` is > > > > completely immaterial and carries no meaning for the value represented > > > > by this `SVal`; it's not necessarily the region you're looking for. > > > Looking at the singleton test case, I think I need to get that region > > > somehow, and I'm not too sure what you meant under using > > > `CXXConstructExpr::getConstructionKind()`. One thing I could do, is > > > similar to how `getObjectVal` works: > > > ``` > > > Loc Tmp = Context.getSValBuilder().getCXXThis(OtherCtor->getParent(), > > > Context.getStackFrame()); > > > > > > auto OtherThis = > > > Context.getState()->getSVal(Tmp).castAs(); > > > > > > OtherThis.getRegion(); // Hooray! > > > ``` > > > > > > I have tested it, and it works wonders. Is this a "safe-to-use" region? > > You can directly ask `CXXConstructExpr` if it's a field or a base > > constructor. I could describe `getConstructionKind()` as some sort of very > > limited `ConstructionContext` that's available in the AST: it explains to > > you what sort of object is being constructed. I suspect it's enough for > > your purposes. > I think I'm aware of how it works, but my issue is that it's very limited: > ``` > enum ConstructionKind { CK_Complete, CK_NonVirtualBase, CK_VirtualBase, > CK_Delegating } > ``` > Sadly, whether the `CXXConstructExpr` was a field construction or a "top > level" (non-field) construction can't be retrieved from > `getConstructionKind()`, as I understand it. > > If I were to return true (say that the constructed object will be analyzed > later, thus ignoring it for now) if `getConstructionKind() == CK_Complete`, > the singleton testcase will fail (I have tested it). I'm very confident that > I need to obtain the constructed object's `MemRegion`. Whoops, yeah, i was wrong. I mis-remembered that there's a `CK_` for field. Then, yeah, the code looks good, let me recall where we were in terms of why do we need it>< https://reviews.llvm.org/D48436 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50028: [analyzer] CStringChecker: Fix argument highlighting.
This revision was automatically updated to reflect the committed changes. Closed by commit rC338333: [analyzer] CStringChecker: Remember to highlight the argument expression range. (authored by dergachev, committed by ). Repository: rC Clang https://reviews.llvm.org/D50028 Files: lib/StaticAnalyzer/Checkers/CStringChecker.cpp test/Analysis/cstring-ranges.c Index: test/Analysis/cstring-ranges.c === --- test/Analysis/cstring-ranges.c +++ test/Analysis/cstring-ranges.c @@ -0,0 +1,15 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=unix.cstring -analyzer-output=text %s 2>&1 | FileCheck %s + +// This test verifies argument source range highlighting. +// Otherwise we've no idea which of the arguments is null. + +char *strcpy(char *, const char *); + +void foo() { + char *a = 0, *b = 0; + strcpy(a, b); +} + +// CHECK: warning: Null pointer argument in call to string copy function +// CHECK-NEXT: strcpy(a, b); +// CHECK-NEXT: ^ ~ Index: lib/StaticAnalyzer/Checkers/CStringChecker.cpp === --- lib/StaticAnalyzer/Checkers/CStringChecker.cpp +++ lib/StaticAnalyzer/Checkers/CStringChecker.cpp @@ -552,6 +552,7 @@ BuiltinBug *BT = static_cast(BT_Null.get()); auto Report = llvm::make_unique(*BT, WarningMsg, N); +Report->addRange(S->getSourceRange()); bugreporter::trackNullOrUndefValue(N, S, *Report); C.emitReport(std::move(Report)); } Index: test/Analysis/cstring-ranges.c === --- test/Analysis/cstring-ranges.c +++ test/Analysis/cstring-ranges.c @@ -0,0 +1,15 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=unix.cstring -analyzer-output=text %s 2>&1 | FileCheck %s + +// This test verifies argument source range highlighting. +// Otherwise we've no idea which of the arguments is null. + +char *strcpy(char *, const char *); + +void foo() { + char *a = 0, *b = 0; + strcpy(a, b); +} + +// CHECK: warning: Null pointer argument in call to string copy function +// CHECK-NEXT: strcpy(a, b); +// CHECK-NEXT: ^ ~ Index: lib/StaticAnalyzer/Checkers/CStringChecker.cpp === --- lib/StaticAnalyzer/Checkers/CStringChecker.cpp +++ lib/StaticAnalyzer/Checkers/CStringChecker.cpp @@ -552,6 +552,7 @@ BuiltinBug *BT = static_cast(BT_Null.get()); auto Report = llvm::make_unique(*BT, WarningMsg, N); +Report->addRange(S->getSourceRange()); bugreporter::trackNullOrUndefValue(N, S, *Report); C.emitReport(std::move(Report)); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r338333 - [analyzer] CStringChecker: Remember to highlight the argument expression range.
Author: dergachev Date: Mon Jul 30 16:44:37 2018 New Revision: 338333 URL: http://llvm.org/viewvc/llvm-project?rev=338333=rev Log: [analyzer] CStringChecker: Remember to highlight the argument expression range. When emitting a bug report, it is important to highlight which argument of the call-expression is causing the problem. Before: warning: Null pointer argument in call to string comparison function strcmp(a, b); ^~~~ After: warning: Null pointer argument in call to string comparison function strcmp(a, b); ^ ~ Affects other output modes as well, not just text. Differential Revision: https://reviews.llvm.org/D50028 Added: cfe/trunk/test/Analysis/cstring-ranges.c Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp?rev=338333=338332=338333=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp Mon Jul 30 16:44:37 2018 @@ -552,6 +552,7 @@ void CStringChecker::emitNullArgBug(Chec BuiltinBug *BT = static_cast(BT_Null.get()); auto Report = llvm::make_unique(*BT, WarningMsg, N); +Report->addRange(S->getSourceRange()); bugreporter::trackNullOrUndefValue(N, S, *Report); C.emitReport(std::move(Report)); } Added: cfe/trunk/test/Analysis/cstring-ranges.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cstring-ranges.c?rev=338333=auto == --- cfe/trunk/test/Analysis/cstring-ranges.c (added) +++ cfe/trunk/test/Analysis/cstring-ranges.c Mon Jul 30 16:44:37 2018 @@ -0,0 +1,15 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=unix.cstring -analyzer-output=text %s 2>&1 | FileCheck %s + +// This test verifies argument source range highlighting. +// Otherwise we've no idea which of the arguments is null. + +char *strcpy(char *, const char *); + +void foo() { + char *a = 0, *b = 0; + strcpy(a, b); +} + +// CHECK: warning: Null pointer argument in call to string copy function +// CHECK-NEXT: strcpy(a, b); +// CHECK-NEXT: ^ ~ ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50028: [analyzer] CStringChecker: Fix argument highlighting.
NoQ created this revision. NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet, rnkovacs. Herald added subscribers: cfe-commits, mikhail.ramalho, baloghadamsoftware. Sometimes it's important to do `BugReport->addRange()` in order to know which part of the expression is problematic. It's also useful to write this down in the warning message, but i didn't bother yet. Repository: rC Clang https://reviews.llvm.org/D50028 Files: lib/StaticAnalyzer/Checkers/CStringChecker.cpp test/Analysis/cstring-ranges.c Index: test/Analysis/cstring-ranges.c === --- /dev/null +++ test/Analysis/cstring-ranges.c @@ -0,0 +1,15 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=unix.cstring -analyzer-output=text %s 2>&1 | FileCheck %s + +// This test verifies argument source range highlighting. +// Otherwise we've no idea which of the arguments is null. + +char *strcpy(char *, const char *); + +void foo() { + char *a = 0, *b = 0; + strcpy(a, b); +} + +// CHECK: warning: Null pointer argument in call to string copy function +// CHECK-NEXT: strcpy(a, b); +// CHECK-NEXT: ^ ~ Index: lib/StaticAnalyzer/Checkers/CStringChecker.cpp === --- lib/StaticAnalyzer/Checkers/CStringChecker.cpp +++ lib/StaticAnalyzer/Checkers/CStringChecker.cpp @@ -552,6 +552,7 @@ BuiltinBug *BT = static_cast(BT_Null.get()); auto Report = llvm::make_unique(*BT, WarningMsg, N); +Report->addRange(S->getSourceRange()); bugreporter::trackNullOrUndefValue(N, S, *Report); C.emitReport(std::move(Report)); } Index: test/Analysis/cstring-ranges.c === --- /dev/null +++ test/Analysis/cstring-ranges.c @@ -0,0 +1,15 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=unix.cstring -analyzer-output=text %s 2>&1 | FileCheck %s + +// This test verifies argument source range highlighting. +// Otherwise we've no idea which of the arguments is null. + +char *strcpy(char *, const char *); + +void foo() { + char *a = 0, *b = 0; + strcpy(a, b); +} + +// CHECK: warning: Null pointer argument in call to string copy function +// CHECK-NEXT: strcpy(a, b); +// CHECK-NEXT: ^ ~ Index: lib/StaticAnalyzer/Checkers/CStringChecker.cpp === --- lib/StaticAnalyzer/Checkers/CStringChecker.cpp +++ lib/StaticAnalyzer/Checkers/CStringChecker.cpp @@ -552,6 +552,7 @@ BuiltinBug *BT = static_cast(BT_Null.get()); auto Report = llvm::make_unique(*BT, WarningMsg, N); +Report->addRange(S->getSourceRange()); bugreporter::trackNullOrUndefValue(N, S, *Report); C.emitReport(std::move(Report)); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r338332 - Code cleanup - change naked 'throw' expressions to call helpre function '__throw_future_error'. The behavior change is that if you build libc++ with exceptions disabled, and then us
Author: marshall Date: Mon Jul 30 16:33:48 2018 New Revision: 338332 URL: http://llvm.org/viewvc/llvm-project?rev=338332=rev Log: Code cleanup - change naked 'throw' expressions to call helpre function '__throw_future_error'. The behavior change is that if you build libc++ with exceptions disabled, and then use that in a program that sets the value of the future twice (for example), it will now abort instead of behaving unpredictably. Modified: libcxx/trunk/src/future.cpp Modified: libcxx/trunk/src/future.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/future.cpp?rev=338332=338331=338332=diff == --- libcxx/trunk/src/future.cpp (original) +++ libcxx/trunk/src/future.cpp Mon Jul 30 16:33:48 2018 @@ -92,10 +92,8 @@ void __assoc_sub_state::set_value() { unique_lock __lk(__mut_); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__has_value()) -throw future_error(make_error_code(future_errc::promise_already_satisfied)); -#endif +__throw_future_error(future_errc::promise_already_satisfied); __state_ |= __constructed | ready; __cv_.notify_all(); } @@ -104,10 +102,8 @@ void __assoc_sub_state::set_value_at_thread_exit() { unique_lock __lk(__mut_); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__has_value()) -throw future_error(make_error_code(future_errc::promise_already_satisfied)); -#endif +__throw_future_error(future_errc::promise_already_satisfied); __state_ |= __constructed; __thread_local_data()->__make_ready_at_thread_exit(this); } @@ -116,10 +112,8 @@ void __assoc_sub_state::set_exception(exception_ptr __p) { unique_lock __lk(__mut_); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__has_value()) -throw future_error(make_error_code(future_errc::promise_already_satisfied)); -#endif +__throw_future_error(future_errc::promise_already_satisfied); __exception_ = __p; __state_ |= ready; __cv_.notify_all(); @@ -129,10 +123,8 @@ void __assoc_sub_state::set_exception_at_thread_exit(exception_ptr __p) { unique_lock __lk(__mut_); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__has_value()) -throw future_error(make_error_code(future_errc::promise_already_satisfied)); -#endif +__throw_future_error(future_errc::promise_already_satisfied); __exception_ = __p; __thread_local_data()->__make_ready_at_thread_exit(this); } @@ -181,18 +173,14 @@ __assoc_sub_state::__sub_wait(unique_loc void __assoc_sub_state::__execute() { -#ifndef _LIBCPP_NO_EXCEPTIONS -throw future_error(make_error_code(future_errc::no_state)); -#endif +__throw_future_error(future_errc::no_state); } future::future(__assoc_sub_state* __state) : __state_(__state) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_->__has_future_attached()) -throw future_error(make_error_code(future_errc::future_already_retrieved)); -#endif +__throw_future_error(future_errc::future_already_retrieved); __state_->__add_shared(); __state_->__set_future_attached(); } @@ -234,50 +222,40 @@ promise::~promise() future promise::get_future() { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_ == nullptr) -throw future_error(make_error_code(future_errc::no_state)); -#endif +__throw_future_error(future_errc::no_state); return future(__state_); } void promise::set_value() { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_ == nullptr) -throw future_error(make_error_code(future_errc::no_state)); -#endif +__throw_future_error(future_errc::no_state); __state_->set_value(); } void promise::set_exception(exception_ptr __p) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_ == nullptr) -throw future_error(make_error_code(future_errc::no_state)); -#endif +__throw_future_error(future_errc::no_state); __state_->set_exception(__p); } void promise::set_value_at_thread_exit() { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_ == nullptr) -throw future_error(make_error_code(future_errc::no_state)); -#endif +__throw_future_error(future_errc::no_state); __state_->set_value_at_thread_exit(); } void promise::set_exception_at_thread_exit(exception_ptr __p) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_ == nullptr) -throw future_error(make_error_code(future_errc::no_state)); -#endif +__throw_future_error(future_errc::no_state); __state_->set_exception_at_thread_exit(__p); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r338321 - Fix use of uninitialized variable in r338299
Is 0 right for FieldOffset for OpenCL here? Seems a little odd. -eric On Mon, Jul 30, 2018 at 3:56 PM Scott Linder via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: scott.linder > Date: Mon Jul 30 15:52:07 2018 > New Revision: 338321 > > URL: http://llvm.org/viewvc/llvm-project?rev=338321=rev > Log: > Fix use of uninitialized variable in r338299 > > Modified: > cfe/trunk/lib/CodeGen/CGDebugInfo.cpp > > Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=338321=338320=338321=diff > > == > --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) > +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Jul 30 15:52:07 2018 > @@ -989,9 +989,9 @@ llvm::DIType *CGDebugInfo::CreateType(co > EltTys.push_back(DBuilder.createMemberType( > Unit, "__descriptor", nullptr, LineNo, FieldSize, FieldAlign, > FieldOffset, > llvm::DINode::FlagZero, DescTy)); > +FieldOffset += FieldSize; >} > > - FieldOffset += FieldSize; >Elements = DBuilder.getOrCreateArray(EltTys); > >// The __block_literal_generic structs are marked with a special > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r338328 - Revert "Add a definition for FieldSize that seems to make sense here."
Author: echristo Date: Mon Jul 30 16:21:51 2018 New Revision: 338328 URL: http://llvm.org/viewvc/llvm-project?rev=338328=rev Log: Revert "Add a definition for FieldSize that seems to make sense here." This reverts commit r338327, the problem was previously fixed in r338321. Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=338328=338327=338328=diff == --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Jul 30 16:21:51 2018 @@ -974,7 +974,6 @@ llvm::DIType *CGDebugInfo::CreateType(co if (CGM.getLangOpts().OpenCL) { FType = CGM.getContext().IntTy; EltTys.push_back(CreateMemberType(Unit, FType, "__size", )); -FieldSize = CGM.getContext().getTypeSize(Ty); EltTys.push_back(CreateMemberType(Unit, FType, "__align", )); } else { FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r338327 - Add a definition for FieldSize that seems to make sense here.
Author: echristo Date: Mon Jul 30 16:17:27 2018 New Revision: 338327 URL: http://llvm.org/viewvc/llvm-project?rev=338327=rev Log: Add a definition for FieldSize that seems to make sense here. This could be sunk out of the if statements, but fix the warning for now. Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=338327=338326=338327=diff == --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Jul 30 16:17:27 2018 @@ -974,6 +974,7 @@ llvm::DIType *CGDebugInfo::CreateType(co if (CGM.getLangOpts().OpenCL) { FType = CGM.getContext().IntTy; EltTys.push_back(CreateMemberType(Unit, FType, "__size", )); +FieldSize = CGM.getContext().getTypeSize(Ty); EltTys.push_back(CreateMemberType(Unit, FType, "__align", )); } else { FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r338325 - [libcxx] fix `>> 42` UB in
Author: timshen Date: Mon Jul 30 16:05:40 2018 New Revision: 338325 URL: http://llvm.org/viewvc/llvm-project?rev=338325=rev Log: [libcxx] fix `>> 42` UB in Modified: libcxx/trunk/test/std/experimental/simd/simd.access/default.pass.cpp Modified: libcxx/trunk/test/std/experimental/simd/simd.access/default.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/simd/simd.access/default.pass.cpp?rev=338325=338324=338325=diff == --- libcxx/trunk/test/std/experimental/simd/simd.access/default.pass.cpp (original) +++ libcxx/trunk/test/std/experimental/simd/simd.access/default.pass.cpp Mon Jul 30 16:05:40 2018 @@ -161,7 +161,7 @@ void test_access() { } { auto c = a; - (void)(a[0] + (c[0] >>= a[0])); + (void)(a[0] + (c[0] >>= b[0])); } { auto c = a; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r338323 - [analyzer] [tests] Add an option for showing statistics after running tests.
Author: george.karpenkov Date: Mon Jul 30 16:01:47 2018 New Revision: 338323 URL: http://llvm.org/viewvc/llvm-project?rev=338323=rev Log: [analyzer] [tests] Add an option for showing statistics after running tests. Do not show statistics by default. Modified: cfe/trunk/utils/analyzer/CmpRuns.py Modified: cfe/trunk/utils/analyzer/CmpRuns.py URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/CmpRuns.py?rev=338323=338322=338323=diff == --- cfe/trunk/utils/analyzer/CmpRuns.py (original) +++ cfe/trunk/utils/analyzer/CmpRuns.py Mon Jul 30 16:01:47 2018 @@ -324,7 +324,7 @@ def dumpScanBuildResultsDiff(dirA, dirB, # Load the run results. resultsA = loadResults(dirA, opts, opts.rootA, deleteEmpty) resultsB = loadResults(dirB, opts, opts.rootB, deleteEmpty) -if resultsA.stats: +if opts.show_stats: compareStats(resultsA, resultsB) if opts.stats_only: return @@ -399,6 +399,8 @@ def generate_option_parser(): Requires matplotlib") parser.add_option("--stats-only", action="store_true", dest="stats_only", default=False, help="Only show statistics on reports") +parser.add_option("--show-stats", action="store_true", dest="show_stats", + default=False, help="Show change in statistics") return parser ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r338322 - [analyzer] [tests] Style fixes for testing harness.
Author: george.karpenkov Date: Mon Jul 30 16:01:20 2018 New Revision: 338322 URL: http://llvm.org/viewvc/llvm-project?rev=338322=rev Log: [analyzer] [tests] Style fixes for testing harness. Modified: cfe/trunk/utils/analyzer/CmpRuns.py cfe/trunk/utils/analyzer/SATestBuild.py Modified: cfe/trunk/utils/analyzer/CmpRuns.py URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/CmpRuns.py?rev=338322=338321=338322=diff == --- cfe/trunk/utils/analyzer/CmpRuns.py (original) +++ cfe/trunk/utils/analyzer/CmpRuns.py Mon Jul 30 16:01:20 2018 @@ -312,11 +312,11 @@ def compareStats(resultsA, resultsB): # Only apply highlighting when writing to TTY and it's not Windows if sys.stdout.isatty() and os.name != 'nt': if valB != 0: - ratio = (valB - valA) / valB - if ratio < -0.2: - report = Colors.GREEN + report + Colors.CLEAR - elif ratio > 0.2: - report = Colors.RED + report + Colors.CLEAR +ratio = (valB - valA) / valB +if ratio < -0.2: +report = Colors.GREEN + report + Colors.CLEAR +elif ratio > 0.2: +report = Colors.RED + report + Colors.CLEAR print "\t %s %s" % (kkey, report) def dumpScanBuildResultsDiff(dirA, dirB, opts, deleteEmpty=True, Modified: cfe/trunk/utils/analyzer/SATestBuild.py URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/SATestBuild.py?rev=338322=338321=338322=diff == --- cfe/trunk/utils/analyzer/SATestBuild.py (original) +++ cfe/trunk/utils/analyzer/SATestBuild.py Mon Jul 30 16:01:20 2018 @@ -60,9 +60,9 @@ import threading import time import Queue -#-- +### # Helper functions. -#-- +### Local = threading.local() Local.stdout = sys.stdout @@ -91,9 +91,9 @@ def getProjectMapPath(): ProjectMapPath = os.path.join(os.path.abspath(os.curdir), ProjectMapFile) if not os.path.exists(ProjectMapPath): -Local.stdout.write("Error: Cannot find the Project Map file " - + ProjectMapPath - + "\nRunning script for the wrong directory?\n") +Local.stdout.write("Error: Cannot find the Project Map file " + + ProjectMapPath + + "\nRunning script for the wrong directory?\n") sys.exit(1) return ProjectMapPath @@ -108,9 +108,9 @@ def getSBOutputDirName(IsReferenceBuild) else: return SBOutputDirName -#-- +### # Configuration setup. -#-- +### # Find Clang for static analysis. @@ -185,9 +185,9 @@ Checkers = ",".join([ Verbose = 0 -#-- +### # Test harness logic. -#-- +### def runCleanupScript(Dir, PBuildLogFile): ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49763: [CUDA] Call atexit() for CUDA destructor early on.
tra abandoned this revision. tra added a comment. It appears that the issue that originally prompted this change is due to suspected bug in glibc triggered by specific details of our internal build. https://reviews.llvm.org/D49763 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r338299 - [DebugInfo][OpenCL] Generate correct block literal debug info for OpenCL
Sorry for the delay, this should be fixed in r338321. Scott On 2018-07-30 17:19, Benjamin Kramer wrote: On Mon, Jul 30, 2018 at 10:37 PM Scott Linder via cfe-commits wrote: Author: scott.linder Date: Mon Jul 30 13:31:11 2018 New Revision: 338299 URL: http://llvm.org/viewvc/llvm-project?rev=338299=rev [1] Log: [DebugInfo][OpenCL] Generate correct block literal debug info for OpenCL OpenCL block literal structs have different fields which are now correctly identified in the debug info. Differential Revision: https://reviews.llvm.org/D49930 [2] Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/test/CodeGenOpenCL/blocks.cl [3] Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=338299=338298=338299=diff [4] == --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Jul 30 13:31:11 2018 @@ -971,20 +971,25 @@ llvm::DIType *CGDebugInfo::CreateType(co auto *DescTy = DBuilder.createPointerType(EltTy, Size); FieldOffset = 0; - FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy); - EltTys.push_back(CreateMemberType(Unit, FType, "__isa", )); - FType = CGM.getContext().IntTy; - EltTys.push_back(CreateMemberType(Unit, FType, "__flags", )); - EltTys.push_back(CreateMemberType(Unit, FType, "__reserved", )); - FType = CGM.getContext().getPointerType(Ty->getPointeeType()); - EltTys.push_back(CreateMemberType(Unit, FType, "__FuncPtr", )); - - FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy); - FieldSize = CGM.getContext().getTypeSize(Ty); - FieldAlign = CGM.getContext().getTypeAlign(Ty); - EltTys.push_back(DBuilder.createMemberType( - Unit, "__descriptor", nullptr, LineNo, FieldSize, FieldAlign, FieldOffset, - llvm::DINode::FlagZero, DescTy)); + if (CGM.getLangOpts().OpenCL) { + FType = CGM.getContext().IntTy; + EltTys.push_back(CreateMemberType(Unit, FType, "__size", )); + EltTys.push_back(CreateMemberType(Unit, FType, "__align", )); + } else { + FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy); + EltTys.push_back(CreateMemberType(Unit, FType, "__isa", )); + FType = CGM.getContext().IntTy; + EltTys.push_back(CreateMemberType(Unit, FType, "__flags", )); + EltTys.push_back(CreateMemberType(Unit, FType, "__reserved", )); + FType = CGM.getContext().getPointerType(Ty->getPointeeType()); + EltTys.push_back(CreateMemberType(Unit, FType, "__FuncPtr", )); + FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy); + FieldSize = CGM.getContext().getTypeSize(Ty); + FieldAlign = CGM.getContext().getTypeAlign(Ty); + EltTys.push_back(DBuilder.createMemberType( + Unit, "__descriptor", nullptr, LineNo, FieldSize, FieldAlign, FieldOffset, + llvm::DINode::FlagZero, DescTy)); + } llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:974:7: error: variable 'FieldSize' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized] if (CGM.getLangOpts().OpenCL) { ^~~~ llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:994:18: note: uninitialized use occurs here FieldOffset += FieldSize; ^ llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:974:3: note: remove the 'if' if its condition is always false if (CGM.getLangOpts().OpenCL) { ^~~ llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:949:21: note: initialize the variable 'FieldSize' to silence this warning uint64_t FieldSize, FieldOffset; ^ = 0 1 error generated. FieldOffset += FieldSize; Elements = DBuilder.getOrCreateArray(EltTys); @@ -3847,26 +3852,35 @@ void CGDebugInfo::EmitDeclareOfBlockLite CGM.getDataLayout().getStructLayout(block.StructureType); SmallVector fields; - fields.push_back(createFieldType("__isa", C.VoidPtrTy, loc, AS_public, - blockLayout->getElementOffsetInBits(0), - tunit, tunit)); - fields.push_back(createFieldType("__flags", C.IntTy, loc, AS_public, - blockLayout->getElementOffsetInBits(1), - tunit, tunit)); - fields.push_back(createFieldType("__reserved", C.IntTy, loc, AS_public, - blockLayout->getElementOffsetInBits(2), - tunit, tunit)); - auto *FnTy = block.getBlockExpr()->getFunctionType(); - auto FnPtrType = CGM.getContext().getPointerType(FnTy->desugar()); - fields.push_back(createFieldType("__FuncPtr", FnPtrType, loc, AS_public, - blockLayout->getElementOffsetInBits(3), - tunit, tunit)); - fields.push_back(createFieldType( - "__descriptor", - C.getPointerType(block.NeedsCopyDispose - ? C.getBlockDescriptorExtendedType() - : C.getBlockDescriptorType()), - loc, AS_public, blockLayout->getElementOffsetInBits(4), tunit, tunit)); + if (CGM.getLangOpts().OpenCL) { + fields.push_back(createFieldType("__size", C.IntTy, loc, AS_public, + blockLayout->getElementOffsetInBits(0), + tunit, tunit)); + fields.push_back(createFieldType("__align", C.IntTy, loc, AS_public, +
r338321 - Fix use of uninitialized variable in r338299
Author: scott.linder Date: Mon Jul 30 15:52:07 2018 New Revision: 338321 URL: http://llvm.org/viewvc/llvm-project?rev=338321=rev Log: Fix use of uninitialized variable in r338299 Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=338321=338320=338321=diff == --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Jul 30 15:52:07 2018 @@ -989,9 +989,9 @@ llvm::DIType *CGDebugInfo::CreateType(co EltTys.push_back(DBuilder.createMemberType( Unit, "__descriptor", nullptr, LineNo, FieldSize, FieldAlign, FieldOffset, llvm::DINode::FlagZero, DescTy)); +FieldOffset += FieldSize; } - FieldOffset += FieldSize; Elements = DBuilder.getOrCreateArray(EltTys); // The __block_literal_generic structs are marked with a special ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r338291 - Remove trailing space
On Mon, Jul 30, 2018 at 6:17 PM, Fāng-ruì Sòng wrote: > On 2018-07-30, Aaron Ballman wrote: > >> On Mon, Jul 30, 2018 at 4:43 PM, Fāng-ruì Sòng >> wrote: >> >>> Does this apply to only public headers (include/llvm include/llvm-c >>> include/clang ...) or everything? (lib/**/*.{cpp,h})? >>> >> >> I've understood it applies to "everything" in that you should not >> commit large-scale NFC changes that don't have considerable benefit >> (for some definition of considerable benefit). >> > > The benefits I can think of are: > > * Some editors are configured to highlight trailing whitespace. Before > the two cleanup commits, they will interfere reading. > * Some editors are configured to remove whitespace (as Michael pointed > out). The removal will show up in diffs where revision authors have to > undo > manually. For some out-of-tree users, if they have local patches but do > not > strip trailing whitespace, related to settings of their code review > system, > this could turn to whitespace errors. > > e.g., if you're fixing >> a typo in an API and it hits a lot of files, that's fine because a >> typo in an API is pretty egregious, but don't clang-format a bunch of >> files and commit that because formatting isn't super critical and >> instead we migrate it more slowly as the code gets touched. >> > > Thank you for raising these. I learned from your examples☺ > > On Mon, Jul 30, 2018 at 4:49 PM, Fāng-ruì Sòng wrote: >> >>> Maybe not too terrible for out-of-tree projects. If they use git >>> mirror, `git rebase` is smart enough to ignore changing lines with >>> trailing whitespace (if not, there is git rebase >>> -Xignore-space-at-eol). Some editors are configured with highlighting >>> trailing spaces and these spaces will turn to eyesore... >>> >> >> Not everyone uses git; svn is still the official repository for the >> project. >> > > I am not familiar with svn but stackoverflow tells me there is svn diff -x > "--ignore-eol-style". > This should also be available to other svn functionality. > I don't disagree that there are pros and cons in the discussion and that we should consider them carefully, but I think there should be a discussion that happens with the community *before* landing this patch, even though it's a NFC patch. Please revert these patches and start a discussion thread on whether this is something the community would like to see committed or not. ~Aaron ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r338318 - Re-apply "[libcxx] implement ABI for Clang/GCC vector extension, constructors, copy_from and copy_to."
Author: timshen Date: Mon Jul 30 15:27:38 2018 New Revision: 338318 URL: http://llvm.org/viewvc/llvm-project?rev=338318=rev Log: Re-apply "[libcxx] implement ABI for Clang/GCC vector extension, constructors, copy_from and copy_to." ...with proper guarding #ifdefs for unsupported C++11. Added: libcxx/trunk/test/std/experimental/simd/simd.abi/ libcxx/trunk/test/std/experimental/simd/simd.abi/vector_extension.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.access/ libcxx/trunk/test/std/experimental/simd/simd.access/default.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.cons/default.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.cons/load.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.mem/ libcxx/trunk/test/std/experimental/simd/simd.mem/load.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.mem/store.pass.cpp Modified: libcxx/trunk/include/__config libcxx/trunk/include/experimental/__config libcxx/trunk/include/experimental/simd libcxx/trunk/test/std/experimental/simd/simd.casts/simd_cast.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.casts/static_simd_cast.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.cons/broadcast.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.cons/generator.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.traits/abi_for_size.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.traits/is_abi_tag.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd_flag_type.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp Modified: libcxx/trunk/include/__config URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=338318=338317=338318=diff == --- libcxx/trunk/include/__config (original) +++ libcxx/trunk/include/__config Mon Jul 30 15:27:38 2018 @@ -620,6 +620,8 @@ namespace std { #define _LIBCPP_ALWAYS_INLINE __forceinline +#define _LIBCPP_HAS_NO_VECTOR_EXTENSION + #elif defined(_LIBCPP_COMPILER_IBM) #define _ALIGNAS(x) __attribute__((__aligned__(x))) @@ -652,6 +654,8 @@ namespace std { #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) +#define _LIBCPP_HAS_NO_VECTOR_EXTENSION + #endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM] #if _LIBCPP_STD_VER >= 17 Modified: libcxx/trunk/include/experimental/__config URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/__config?rev=338318=338317=338318=diff == --- libcxx/trunk/include/experimental/__config (original) +++ libcxx/trunk/include/experimental/__config Mon Jul 30 15:27:38 2018 @@ -64,4 +64,11 @@ #define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD_ABI \ } _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD +// TODO: support more targets +#if defined(__AVX__) +#define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 32 +#else +#define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 16 +#endif + #endif Modified: libcxx/trunk/include/experimental/simd URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/simd?rev=338318=338317=338318=diff == --- libcxx/trunk/include/experimental/simd (original) +++ libcxx/trunk/include/experimental/simd Mon Jul 30 15:27:38 2018 @@ -651,6 +651,7 @@ public: */ #include +#include #include #include #include @@ -661,26 +662,246 @@ public: _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD +#if _LIBCPP_STD_VER >= 17 + enum class _StorageKind { _Scalar, _Array, + _VecExt, }; template <_StorageKind __kind, int _Np> struct __simd_abi {}; template -struct __simd_storage_traits {}; +class __simd_storage {}; template -struct __simd_storage_traits<_Tp, - __simd_abi<_StorageKind::_Array, __num_element>> { - using type = std::array<_Tp, __num_element>; +class __simd_storage<_Tp, __simd_abi<_StorageKind::_Array, __num_element>> { + std::array<_Tp, __num_element> __storage_; + + template + friend struct simd; + + template + friend struct simd_mask; + +public: + _Tp __get(size_t __index) const noexcept { return __storage_[__index]; }; + void __set(size_t __index, _Tp __val) noexcept { +__storage_[__index] = __val; + } }; template -struct __simd_storage_traits<_Tp, __simd_abi<_StorageKind::_Scalar, 1>> { - using type = _Tp; +class __simd_storage<_Tp, __simd_abi<_StorageKind::_Scalar, 1>> { + _Tp __storage_; + + template + friend struct simd; + + template + friend struct simd_mask; + +public: + _Tp __get(size_t __index) const noexcept { return (&__storage_)[__index]; }; + void __set(size_t __index, _Tp __val) noexcept { +(&__storage_)[__index] = __val; + } +}; + +#ifndef _LIBCPP_HAS_NO_VECTOR_EXTENSION +
[libcxx] r338316 - Revert "[libcxx] implement ABI for Clang/GCC vector extension, constructors, copy_from and copy_to."
Author: timshen Date: Mon Jul 30 15:21:22 2018 New Revision: 338316 URL: http://llvm.org/viewvc/llvm-project?rev=338316=rev Log: Revert "[libcxx] implement ABI for Clang/GCC vector extension, constructors, copy_from and copy_to." This reverts commit r338309. Removed: libcxx/trunk/test/std/experimental/simd/simd.abi/ libcxx/trunk/test/std/experimental/simd/simd.access/ libcxx/trunk/test/std/experimental/simd/simd.cons/default.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.cons/load.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.mem/ Modified: libcxx/trunk/include/__config libcxx/trunk/include/experimental/__config libcxx/trunk/include/experimental/simd libcxx/trunk/test/std/experimental/simd/simd.casts/simd_cast.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.casts/static_simd_cast.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.cons/broadcast.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.cons/generator.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.traits/abi_for_size.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.traits/is_abi_tag.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd_flag_type.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp Modified: libcxx/trunk/include/__config URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=338316=338315=338316=diff == --- libcxx/trunk/include/__config (original) +++ libcxx/trunk/include/__config Mon Jul 30 15:21:22 2018 @@ -620,8 +620,6 @@ namespace std { #define _LIBCPP_ALWAYS_INLINE __forceinline -#define _LIBCPP_HAS_NO_VECTOR_EXTENSION - #elif defined(_LIBCPP_COMPILER_IBM) #define _ALIGNAS(x) __attribute__((__aligned__(x))) @@ -654,8 +652,6 @@ namespace std { #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) -#define _LIBCPP_HAS_NO_VECTOR_EXTENSION - #endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM] #if _LIBCPP_STD_VER >= 17 Modified: libcxx/trunk/include/experimental/__config URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/__config?rev=338316=338315=338316=diff == --- libcxx/trunk/include/experimental/__config (original) +++ libcxx/trunk/include/experimental/__config Mon Jul 30 15:21:22 2018 @@ -64,11 +64,4 @@ #define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD_ABI \ } _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD -// TODO: support more targets -#if defined(__AVX__) -#define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 32 -#else -#define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 16 -#endif - #endif Modified: libcxx/trunk/include/experimental/simd URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/simd?rev=338316=338315=338316=diff == --- libcxx/trunk/include/experimental/simd (original) +++ libcxx/trunk/include/experimental/simd Mon Jul 30 15:21:22 2018 @@ -651,7 +651,6 @@ public: */ #include -#include #include #include #include @@ -665,241 +664,23 @@ _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIM enum class _StorageKind { _Scalar, _Array, - _VecExt, }; template <_StorageKind __kind, int _Np> struct __simd_abi {}; template -class __simd_storage {}; +struct __simd_storage_traits {}; template -class __simd_storage<_Tp, __simd_abi<_StorageKind::_Array, __num_element>> { - std::array<_Tp, __num_element> __storage_; - - template - friend struct simd; - - template - friend struct simd_mask; - -public: - _Tp __get(size_t __index) const noexcept { return __storage_[__index]; }; - void __set(size_t __index, _Tp __val) noexcept { -__storage_[__index] = __val; - } +struct __simd_storage_traits<_Tp, + __simd_abi<_StorageKind::_Array, __num_element>> { + using type = std::array<_Tp, __num_element>; }; template -class __simd_storage<_Tp, __simd_abi<_StorageKind::_Scalar, 1>> { - _Tp __storage_; - - template - friend struct simd; - - template - friend struct simd_mask; - -public: - _Tp __get(size_t __index) const noexcept { return (&__storage_)[__index]; }; - void __set(size_t __index, _Tp __val) noexcept { -(&__storage_)[__index] = __val; - } -}; - -#ifndef _LIBCPP_HAS_NO_VECTOR_EXTENSION - -constexpr size_t __floor_pow_of_2(size_t __val) { - return ((__val - 1) & __val) == 0 ? __val -: __floor_pow_of_2((__val - 1) & __val); -} - -constexpr size_t __ceil_pow_of_2(size_t __val) { - return __val == 1 ? 1 : __floor_pow_of_2(__val - 1) << 1; -} - -template -struct __vec_ext_traits { -#if !defined(_LIBCPP_COMPILER_CLANG) - typedef _Tp type __attribute__((vector_size(__ceil_pow_of_2(__bytes;
r338315 - [analyzer] [NFC] Simplify some visitors by giving a convenient getter from state to analysis manager
Author: george.karpenkov Date: Mon Jul 30 15:18:47 2018 New Revision: 338315 URL: http://llvm.org/viewvc/llvm-project?rev=338315=rev Log: [analyzer] [NFC] Simplify some visitors by giving a convenient getter from state to analysis manager Differential Revision: https://reviews.llvm.org/D49772 Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h?rev=338315=338314=338315=diff == --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h (original) +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h Mon Jul 30 15:18:47 2018 @@ -36,6 +36,7 @@ class ASTContext; namespace ento { +class AnalysisManager; class CallEvent; class CallEventManager; @@ -111,6 +112,8 @@ public: return *stateMgr; } + AnalysisManager () const; + /// Return the ConstraintManager. ConstraintManager () const; Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=338315=338314=338315=diff == --- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Mon Jul 30 15:18:47 2018 @@ -269,6 +269,8 @@ namespace { /// pointer dereference outside. class NoStoreFuncVisitor final : public BugReporterVisitor { const SubRegion *RegionOfInterest; + const SourceManager + const PrintingPolicy static constexpr const char *DiagnosticsMsg = "Returning without writing to '"; @@ -284,7 +286,10 @@ class NoStoreFuncVisitor final : public llvm::SmallPtrSet FramesModifyingCalculated; public: - NoStoreFuncVisitor(const SubRegion *R) : RegionOfInterest(R) {} + NoStoreFuncVisitor(const SubRegion *R) + : RegionOfInterest(R), +SM(R->getMemRegionManager()->getContext().getSourceManager()), +PP(R->getMemRegionManager()->getContext().getPrintingPolicy()) {} void Profile(llvm::FoldingSetNodeID ) const override { static int Tag = 0; @@ -307,8 +312,6 @@ public: CallEventRef<> Call = BRC.getStateManager().getCallEventManager().getCaller(SCtx, State); -const PrintingPolicy = BRC.getASTContext().getPrintingPolicy(); -const SourceManager = BRC.getSourceManager(); // Region of interest corresponds to an IVar, exiting a method // which could have written into that IVar, but did not. @@ -318,16 +321,14 @@ public: IvarR->getDecl()) && !isRegionOfInterestModifiedInFrame(N)) return notModifiedMemberDiagnostics( - Ctx, SM, PP, *CallExitLoc, Call, - MC->getReceiverSVal().getAsRegion()); + Ctx, *CallExitLoc, Call, MC->getReceiverSVal().getAsRegion()); if (const auto *CCall = dyn_cast(Call)) { - const MemRegion *ThisRegion = CCall->getCXXThisVal().getAsRegion(); - if (RegionOfInterest->isSubRegionOf(ThisRegion) + const MemRegion *ThisR = CCall->getCXXThisVal().getAsRegion(); + if (RegionOfInterest->isSubRegionOf(ThisR) && !CCall->getDecl()->isImplicit() && !isRegionOfInterestModifiedInFrame(N)) -return notModifiedMemberDiagnostics(Ctx, SM, PP, *CallExitLoc, - CCall, ThisRegion); +return notModifiedMemberDiagnostics(Ctx, *CallExitLoc, Call, ThisR); } ArrayRef parameters = getCallParameters(Call); @@ -344,7 +345,7 @@ public: return nullptr; return notModifiedParameterDiagnostics( - Ctx, SM, PP, *CallExitLoc, Call, PVD, R, IndirectionLevel); + Ctx, *CallExitLoc, Call, PVD, R, IndirectionLevel); } QualType PT = T->getPointeeType(); if (PT.isNull() || PT->isVoidType()) break; @@ -446,8 +447,6 @@ private: /// in a given function. std::shared_ptr notModifiedMemberDiagnostics( const LocationContext *Ctx, - const SourceManager , - const PrintingPolicy , CallExitBegin , CallEventRef<> Call, const MemRegion *ArgRegion) { @@ -474,8 +473,6 @@ private: /// before we get to the super region of \c RegionOfInterest std::shared_ptr notModifiedParameterDiagnostics(const LocationContext *Ctx, - const SourceManager , - const PrintingPolicy , CallExitBegin , CallEventRef<> Call,
[PATCH] D49921: [analyzer] Bugfix for autorelease + main run loop leak checker
This revision was automatically updated to reflect the committed changes. Closed by commit rC338314: [analyzer] Bugfix for autorelease + main run loop leak checker (authored by george.karpenkov, committed by ). Herald added a subscriber: cfe-commits. Changed prior to commit: https://reviews.llvm.org/D49921?vs=157708=158100#toc Repository: rC Clang https://reviews.llvm.org/D49921 Files: lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m Index: lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp === --- lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp +++ lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp @@ -45,6 +45,7 @@ const char * RunLoopRunBind = "RunLoopRunM"; const char * OtherMsgBind = "OtherMessageSentM"; const char * AutoreleasePoolBind = "AutoreleasePoolM"; +const char * OtherStmtAutoreleasePoolBind = "OtherAutoreleasePoolM"; class RunLoopAutoreleaseLeakChecker : public Checker { @@ -111,17 +112,20 @@ const auto *AP = Match.getNodeAs(AutoreleasePoolBind); + const auto *OAP = + Match.getNodeAs(OtherStmtAutoreleasePoolBind); bool HasAutoreleasePool = (AP != nullptr); const auto *RL = Match.getNodeAs(RunLoopBind); const auto *RLR = Match.getNodeAs(RunLoopRunBind); assert(RLR && "Run loop launch not found"); - assert(ME != RLR); - if (HasAutoreleasePool && seenBefore(AP, RLR, ME)) + + // Launch of run loop occurs before the message-sent expression is seen. + if (seenBefore(DeclBody, RLR, ME)) return; - if (!HasAutoreleasePool && seenBefore(DeclBody, RLR, ME)) + if (HasAutoreleasePool && (OAP != AP)) return; PathDiagnosticLocation Location = PathDiagnosticLocation::createBegin( @@ -170,7 +174,8 @@ checkTempObjectsInSamePool(const Decl *D, AnalysisManager , BugReporter , const RunLoopAutoreleaseLeakChecker *Chkr) { StatementMatcher RunLoopRunM = getRunLoopRunM(); - StatementMatcher OtherMessageSentM = getOtherMessageSentM(); + StatementMatcher OtherMessageSentM = getOtherMessageSentM( +hasAncestor(autoreleasePoolStmt().bind(OtherStmtAutoreleasePoolBind))); StatementMatcher RunLoopInAutorelease = autoreleasePoolStmt( Index: test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m === --- test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m +++ test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m @@ -29,6 +29,17 @@ } } +void runloop_init_before_separate_pool() { // No warning: separate autorelease pool. + @autoreleasepool { +NSObject *object; +@autoreleasepool { + object = [[NSObject alloc] init]; // no-warning +} +(void) object; +[[NSRunLoop mainRunLoop] run]; + } +} + void xpcmain_init_before() { // Warning: object created before the loop. @autoreleasepool { NSObject *object = [[NSObject alloc] init]; // expected-warning{{Temporary objects allocated in the autorelease pool followed by the launch of xpc_main may never get released; consider moving them to a separate autorelease pool}} Index: lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp === --- lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp +++ lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp @@ -45,6 +45,7 @@ const char * RunLoopRunBind = "RunLoopRunM"; const char * OtherMsgBind = "OtherMessageSentM"; const char * AutoreleasePoolBind = "AutoreleasePoolM"; +const char * OtherStmtAutoreleasePoolBind = "OtherAutoreleasePoolM"; class RunLoopAutoreleaseLeakChecker : public Checker { @@ -111,17 +112,20 @@ const auto *AP = Match.getNodeAs(AutoreleasePoolBind); + const auto *OAP = + Match.getNodeAs(OtherStmtAutoreleasePoolBind); bool HasAutoreleasePool = (AP != nullptr); const auto *RL = Match.getNodeAs(RunLoopBind); const auto *RLR = Match.getNodeAs(RunLoopRunBind); assert(RLR && "Run loop launch not found"); - assert(ME != RLR); - if (HasAutoreleasePool && seenBefore(AP, RLR, ME)) + + // Launch of run loop occurs before the message-sent expression is seen. + if (seenBefore(DeclBody, RLR, ME)) return; - if (!HasAutoreleasePool && seenBefore(DeclBody, RLR, ME)) + if (HasAutoreleasePool && (OAP != AP)) return; PathDiagnosticLocation Location = PathDiagnosticLocation::createBegin( @@ -170,7 +174,8 @@ checkTempObjectsInSamePool(const Decl *D, AnalysisManager , BugReporter , const RunLoopAutoreleaseLeakChecker *Chkr) { StatementMatcher RunLoopRunM = getRunLoopRunM(); - StatementMatcher OtherMessageSentM = getOtherMessageSentM(); + StatementMatcher OtherMessageSentM = getOtherMessageSentM( +
r338314 - [analyzer] Bugfix for autorelease + main run loop leak checker
Author: george.karpenkov Date: Mon Jul 30 15:18:21 2018 New Revision: 338314 URL: http://llvm.org/viewvc/llvm-project?rev=338314=rev Log: [analyzer] Bugfix for autorelease + main run loop leak checker Do not warn when the other message-send-expression is correctly wrapped in a different autorelease pool. Differential Revision: https://reviews.llvm.org/D49921 Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp cfe/trunk/test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp?rev=338314=338313=338314=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp Mon Jul 30 15:18:21 2018 @@ -45,6 +45,7 @@ const char * RunLoopBind = "NSRunLoopM"; const char * RunLoopRunBind = "RunLoopRunM"; const char * OtherMsgBind = "OtherMessageSentM"; const char * AutoreleasePoolBind = "AutoreleasePoolM"; +const char * OtherStmtAutoreleasePoolBind = "OtherAutoreleasePoolM"; class RunLoopAutoreleaseLeakChecker : public Checker { @@ -111,17 +112,20 @@ static void emitDiagnostics(BoundNodes & const auto *AP = Match.getNodeAs(AutoreleasePoolBind); + const auto *OAP = + Match.getNodeAs(OtherStmtAutoreleasePoolBind); bool HasAutoreleasePool = (AP != nullptr); const auto *RL = Match.getNodeAs(RunLoopBind); const auto *RLR = Match.getNodeAs(RunLoopRunBind); assert(RLR && "Run loop launch not found"); - assert(ME != RLR); - if (HasAutoreleasePool && seenBefore(AP, RLR, ME)) + + // Launch of run loop occurs before the message-sent expression is seen. + if (seenBefore(DeclBody, RLR, ME)) return; - if (!HasAutoreleasePool && seenBefore(DeclBody, RLR, ME)) + if (HasAutoreleasePool && (OAP != AP)) return; PathDiagnosticLocation Location = PathDiagnosticLocation::createBegin( @@ -170,7 +174,8 @@ static void checkTempObjectsInSamePool(const Decl *D, AnalysisManager , BugReporter , const RunLoopAutoreleaseLeakChecker *Chkr) { StatementMatcher RunLoopRunM = getRunLoopRunM(); - StatementMatcher OtherMessageSentM = getOtherMessageSentM(); + StatementMatcher OtherMessageSentM = getOtherMessageSentM( +hasAncestor(autoreleasePoolStmt().bind(OtherStmtAutoreleasePoolBind))); StatementMatcher RunLoopInAutorelease = autoreleasePoolStmt( Modified: cfe/trunk/test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m?rev=338314=338313=338314=diff == --- cfe/trunk/test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m (original) +++ cfe/trunk/test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m Mon Jul 30 15:18:21 2018 @@ -29,6 +29,17 @@ void runloop_init_before() { // Warning: } } +void runloop_init_before_separate_pool() { // No warning: separate autorelease pool. + @autoreleasepool { +NSObject *object; +@autoreleasepool { + object = [[NSObject alloc] init]; // no-warning +} +(void) object; +[[NSRunLoop mainRunLoop] run]; + } +} + void xpcmain_init_before() { // Warning: object created before the loop. @autoreleasepool { NSObject *object = [[NSObject alloc] init]; // expected-warning{{Temporary objects allocated in the autorelease pool followed by the launch of xpc_main may never get released; consider moving them to a separate autorelease pool}} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r338291 - Remove trailing space
On 2018-07-30, Aaron Ballman wrote: On Mon, Jul 30, 2018 at 4:43 PM, Fāng-ruì Sòng wrote: Does this apply to only public headers (include/llvm include/llvm-c include/clang ...) or everything? (lib/**/*.{cpp,h})? I've understood it applies to "everything" in that you should not commit large-scale NFC changes that don't have considerable benefit (for some definition of considerable benefit). The benefits I can think of are: * Some editors are configured to highlight trailing whitespace. Before the two cleanup commits, they will interfere reading. * Some editors are configured to remove whitespace (as Michael pointed out). The removal will show up in diffs where revision authors have to undo manually. For some out-of-tree users, if they have local patches but do not strip trailing whitespace, related to settings of their code review system, this could turn to whitespace errors. e.g., if you're fixing a typo in an API and it hits a lot of files, that's fine because a typo in an API is pretty egregious, but don't clang-format a bunch of files and commit that because formatting isn't super critical and instead we migrate it more slowly as the code gets touched. Thank you for raising these. I learned from your examples☺ On Mon, Jul 30, 2018 at 4:49 PM, Fāng-ruì Sòng wrote: Maybe not too terrible for out-of-tree projects. If they use git mirror, `git rebase` is smart enough to ignore changing lines with trailing whitespace (if not, there is git rebase -Xignore-space-at-eol). Some editors are configured with highlighting trailing spaces and these spaces will turn to eyesore... Not everyone uses git; svn is still the official repository for the project. I am not familiar with svn but stackoverflow tells me there is svn diff -x "--ignore-eol-style". This should also be available to other svn functionality. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r338291 - Remove trailing space
On Mon, Jul 30, 2018 at 5:36 PM, Michael Kruse wrote: > Can you point me to such a discussion about trailing whitespace? I don't know of one, which is why I am concerned with these commits. > It seems to contradict the conclusion in another current thread to not > consider churn for out-of-tree users (for C++ API in this case) > > https://lists.llvm.org/pipermail/cfe-dev/2018-July/058579.html This is discussing an API refactoring, which is an entirely different beast than removing trailing whitespace across hundreds of files. I see trailing whitespace as being similar to other code formatting and style issues; it isn't problematic to leave in and it can be fixed up as the code gets touched. ~Aaron > >> We have historically taken the position that the churn caused for >> out-of-tree users of the C++ API are not a consideration when performing an >> API refactoring. (For two reasons: one is that we explicitly do not have a >> stable C++ API; the other is that this is the mechanism by which we >> encourage people to upstream changes.) This actually seems like a >> relatively easy change in that regard: client code can be largely updated >> by a regular expression. > > > Michael > > > > 2018-07-30 15:36 GMT-05:00 Aaron Ballman : >> On Mon, Jul 30, 2018 at 4:24 PM, Michael Kruse >> wrote: >>> I think removing trailing space is a good thing. Some editors remove >>> any trailing space when saving a file. This shows up in diffs that I >>> then have to undo manually. >> >> I've also run into the same issues on occasion. However, this isn't >> about whether we dislike trailing spaces or not; it's about NFC churn >> for out of tree users who have to try to keep their local patches >> clean against upstream. This kind of churn makes for merge conflicts >> and this is a the reason the community has traditionally rejected >> these large-scale commits in the past. If we want to change that >> policy, it should come after community discussion and agreement. >> >> ~Aaron ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r338291 - Remove trailing space
On Mon, Jul 30, 2018 at 4:43 PM, Fāng-ruì Sòng wrote: > Does this apply to only public headers (include/llvm include/llvm-c > include/clang ...) or everything? (lib/**/*.{cpp,h})? I've understood it applies to "everything" in that you should not commit large-scale NFC changes that don't have considerable benefit (for some definition of considerable benefit). e.g., if you're fixing a typo in an API and it hits a lot of files, that's fine because a typo in an API is pretty egregious, but don't clang-format a bunch of files and commit that because formatting isn't super critical and instead we migrate it more slowly as the code gets touched. On Mon, Jul 30, 2018 at 4:49 PM, Fāng-ruì Sòng wrote: > Maybe not too terrible for out-of-tree projects. If they use git > mirror, `git rebase` is smart enough to ignore changing lines with > trailing whitespace (if not, there is git rebase > -Xignore-space-at-eol). Some editors are configured with highlighting > trailing spaces and these spaces will turn to eyesore... Not everyone uses git; svn is still the official repository for the project. ~Aaron ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D41412: [libcxx] implement concat() and split()
timshen added a comment. A note on test cases: I only used simds ints to test split() and concat(), as both functions don't specialize on the element type, unlike the constructors. Comment at: libcxx/include/experimental/simd:1491 - template + template static constexpr decltype( mclow.lists wrote: > I see no change here other than fixing a typo - correct? That is correct. Comment at: libcxx/include/experimental/simd:1630 + +#if !defined(_LIBCPP_HAS_NO_VECTOR_EXTENSION) && defined(_LIBCPP_COMPILER_CLANG) + template mclow.lists wrote: > In general, we try to keep all the compiler-specific bits in `<__config>`. > They tend to grow/mutate over time, and so it's nice to have them all in one > place. > > Better to define something like `_LIBCPP_HAS_BUILTIN_SHUFFLEVECTOR` and use > that; then if GCC gets religion and adds it, you will only have to update a > single place. Also, it makes the reading easier - no more looking at this > and wondering "Why are you requiring clang here?" > > Is this the only place you plan on using `__simd_shuffle`? If so, why not a > member function. GCC already got religion and had it, but in a radically different interface. There is little chance that they will merge the interface in the future. The GCC one is called __builtin_shuffle (https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html). I haven't added it only because I don't care about the performance on GCC. It's rather non-trivial to eliminate the difference between them, certainly more than a macro like _LIBCPP_HAS_BUILTIN_SHUFFLEVECTOR. Do you have any other way to improve the readability? https://reviews.llvm.org/D41412 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D41412: [libcxx] implement concat() and split()
timshen updated this revision to Diff 158092. timshen marked 2 inline comments as done. timshen edited the summary of this revision. timshen added a comment. Update based on comments. https://reviews.llvm.org/D41412 Files: libcxx/include/experimental/simd libcxx/test/std/experimental/simd/simd.horizontal/concat.pass.cpp libcxx/test/std/experimental/simd/simd.horizontal/split.pass.cpp Index: libcxx/test/std/experimental/simd/simd.horizontal/split.pass.cpp === --- /dev/null +++ libcxx/test/std/experimental/simd/simd.horizontal/split.pass.cpp @@ -0,0 +1,128 @@ +//===--===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +// UNSUPPORTED: c++98, c++03 + +// +// +// template +// tuple>...> split(const simd&); +// +// template +// tuple>...> split(const simd_mask&); +// +// template +// array / V::size()> split( +// const simd&); +// +// template +// array / V::size()> split( +// const simd_mask&); +// +// template +// array / n, A>>, n> split_by( +// const simd& x); +// +// template +// array / n, A>>, n> split_by( +// const simd_mask& x); + +#include +#include +#include + +namespace ex = std::experimental::parallelism_v2; + +void test_split() { + auto t = + ex::split<1, 2, 3>(ex::fixed_size_simd([](int i) { return i; })); + static_assert(std::tuple_size::value == 3, ""); + + assert(std::get<0>(t).size() == 1); + assert(std::get<0>(t)[0] == 0); + + assert(std::get<1>(t).size() == 2); + assert(std::get<1>(t)[0] == 1); + assert(std::get<1>(t)[1] == 2); + + assert(std::get<2>(t).size() == 3); + assert(std::get<2>(t)[0] == 3); + assert(std::get<2>(t)[1] == 4); + assert(std::get<2>(t)[2] == 5); +} + +void test_split_array() { + { +auto arr = +ex::split_by<2>(ex::fixed_size_simd([](int i) { return i; })); +static_assert(arr.size() == 2, ""); + +assert(arr[0].size() == 3); +assert(arr[0][0] == 0); +assert(arr[0][1] == 1); +assert(arr[0][2] == 2); + +assert(arr[1].size() == 3); +assert(arr[1][0] == 3); +assert(arr[1][1] == 4); +assert(arr[1][2] == 5); + } + { +auto arr = ex::split>( +ex::fixed_size_simd([](int i) { return i; })); +static_assert(arr.size() == 2, ""); + +assert(arr[0].size() == 3); +assert(arr[0][0] == 0); +assert(arr[0][1] == 1); +assert(arr[0][2] == 2); + +assert(arr[1].size() == 3); +assert(arr[1][0] == 3); +assert(arr[1][1] == 4); +assert(arr[1][2] == 5); + } +} + +void compile_split_propagate_abi() { + using compatible_simd_half = + ex::simd::size() / 2, + ex::simd_abi::compatible>>; + using native_simd_half = + ex::simd::size() / 2, + ex::simd_abi::native>>; + + static_assert( + std::is_same< + decltype(ex::split::size() / 2, + ex::simd::size() / 2>(ex::simd())), + std::tuple>::value, + ""); + + static_assert( + std::is_same::size() / 2, + ex::native_simd::size() / 2>( + ex::native_simd())), + std::tuple>::value, + ""); + + static_assert(std::is_same(ex::simd())), + std::array>::value, +""); + + static_assert(std::is_same(ex::native_simd())), + std::array>::value, +""); +} + +int main() { + test_split(); + test_split_array(); +} Index: libcxx/test/std/experimental/simd/simd.horizontal/concat.pass.cpp === --- /dev/null +++ libcxx/test/std/experimental/simd/simd.horizontal/concat.pass.cpp @@ -0,0 +1,99 @@ +//===--===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +// UNSUPPORTED: c++98, c++03 + +// +// +// template +// simd + ...)>> +// concat(const simd&...); +// +// template +// simd, Abi>> +// concat(const std::array, N>& __v); +// +// template +// simd_mask + ...)>> +// concat(const simd_mask&...); +// +// template +// simd_mask, Abi>> +// concat(const std::array, N>&); + +#include +#include +#include + +namespace ex = std::experimental::parallelism_v2; + +void test_concat() { + auto v = ex::concat(ex::fixed_size_simd([](int i) { return i; }), + ex::fixed_size_simd([](int i) {
[PATCH] D50012: [analyzer] Fix crash in RunLoopAutoreleaseChecker on empty children
This revision was automatically updated to reflect the committed changes. Closed by commit rC338312: [analyzer] Fix crash in RunLoopAutoreleaseChecker on empty children (authored by george.karpenkov, committed by ). Herald added a subscriber: cfe-commits. Changed prior to commit: https://reviews.llvm.org/D50012?vs=158069=158082#toc Repository: rC Clang https://reviews.llvm.org/D50012 Files: lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m Index: test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m === --- test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m +++ test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m @@ -43,7 +43,7 @@ NSObject *object2 = [[NSObject alloc] init]; // no-warning, warning on the first one is enough. (void) object; (void) object2; -[[NSRunLoop mainRunLoop] run]; +[[NSRunLoop mainRunLoop] run]; } } @@ -61,6 +61,15 @@ } } +void no_crash_on_empty_children() { + @autoreleasepool { +for (;;) {} +NSObject *object = [[NSObject alloc] init]; // expected-warning{{Temporary objects allocated in the autorelease pool followed by the launch of main run loop may never get released; consider moving them to a separate autorelease pool}} +[[NSRunLoop mainRunLoop] run]; +(void) object; + } +} + #endif #ifdef AP1 Index: lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp === --- lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp +++ lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp @@ -46,8 +46,7 @@ const char * OtherMsgBind = "OtherMessageSentM"; const char * AutoreleasePoolBind = "AutoreleasePoolM"; -class RunLoopAutoreleaseLeakChecker : public Checker< - check::ASTCodeBody> { +class RunLoopAutoreleaseLeakChecker : public Checker { public: void checkASTCodeBody(const Decl *D, @@ -66,6 +65,8 @@ seenBeforeRec(const Stmt *Parent, const Stmt *A, const Stmt *B, MemoizationMapTy ) { for (const Stmt *C : Parent->children()) { +if (!C) continue; + if (C == A) return true; Index: test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m === --- test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m +++ test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m @@ -43,7 +43,7 @@ NSObject *object2 = [[NSObject alloc] init]; // no-warning, warning on the first one is enough. (void) object; (void) object2; -[[NSRunLoop mainRunLoop] run]; +[[NSRunLoop mainRunLoop] run]; } } @@ -61,6 +61,15 @@ } } +void no_crash_on_empty_children() { + @autoreleasepool { +for (;;) {} +NSObject *object = [[NSObject alloc] init]; // expected-warning{{Temporary objects allocated in the autorelease pool followed by the launch of main run loop may never get released; consider moving them to a separate autorelease pool}} +[[NSRunLoop mainRunLoop] run]; +(void) object; + } +} + #endif #ifdef AP1 Index: lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp === --- lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp +++ lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp @@ -46,8 +46,7 @@ const char * OtherMsgBind = "OtherMessageSentM"; const char * AutoreleasePoolBind = "AutoreleasePoolM"; -class RunLoopAutoreleaseLeakChecker : public Checker< - check::ASTCodeBody> { +class RunLoopAutoreleaseLeakChecker : public Checker { public: void checkASTCodeBody(const Decl *D, @@ -66,6 +65,8 @@ seenBeforeRec(const Stmt *Parent, const Stmt *A, const Stmt *B, MemoizationMapTy ) { for (const Stmt *C : Parent->children()) { +if (!C) continue; + if (C == A) return true; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r338312 - [analyzer] Fix crash in RunLoopAutoreleaseChecker on empty children
Author: george.karpenkov Date: Mon Jul 30 14:44:15 2018 New Revision: 338312 URL: http://llvm.org/viewvc/llvm-project?rev=338312=rev Log: [analyzer] Fix crash in RunLoopAutoreleaseChecker on empty children Differential Revision: https://reviews.llvm.org/D50012 Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp cfe/trunk/test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp?rev=338312=338311=338312=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp Mon Jul 30 14:44:15 2018 @@ -46,8 +46,7 @@ const char * RunLoopRunBind = "RunLoopRu const char * OtherMsgBind = "OtherMessageSentM"; const char * AutoreleasePoolBind = "AutoreleasePoolM"; -class RunLoopAutoreleaseLeakChecker : public Checker< - check::ASTCodeBody> { +class RunLoopAutoreleaseLeakChecker : public Checker { public: void checkASTCodeBody(const Decl *D, @@ -66,6 +65,8 @@ static TriBoolTy seenBeforeRec(const Stmt *Parent, const Stmt *A, const Stmt *B, MemoizationMapTy ) { for (const Stmt *C : Parent->children()) { +if (!C) continue; + if (C == A) return true; Modified: cfe/trunk/test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m?rev=338312=338311=338312=diff == --- cfe/trunk/test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m (original) +++ cfe/trunk/test/Analysis/Checkers/RunLoopAutoreleaseLeakChecker.m Mon Jul 30 14:44:15 2018 @@ -43,7 +43,7 @@ void runloop_init_before_two_objects() { NSObject *object2 = [[NSObject alloc] init]; // no-warning, warning on the first one is enough. (void) object; (void) object2; -[[NSRunLoop mainRunLoop] run]; +[[NSRunLoop mainRunLoop] run]; } } @@ -60,6 +60,15 @@ void runloop_init_after() { // No warnin (void) object; } } + +void no_crash_on_empty_children() { + @autoreleasepool { +for (;;) {} +NSObject *object = [[NSObject alloc] init]; // expected-warning{{Temporary objects allocated in the autorelease pool followed by the launch of main run loop may never get released; consider moving them to a separate autorelease pool}} +[[NSRunLoop mainRunLoop] run]; +(void) object; + } +} #endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48958: [clang][ubsan] Implicit Cast Sanitizer - integer truncation - clang part
rsmith added inline comments. Comment at: docs/UndefinedBehaviorSanitizer.rst:136-137 + overflow happens (signed or unsigned). + Both of these two issues are handled by ``-fsanitize=implicit-conversion`` + group of checks. - ``-fsanitize=unreachable``: If control flow reaches an unreachable lebedev.ri wrote: > rsmith wrote: > > I don't think that's true (not until you add a sanitizer for signed <-> > > unsigned conversions that change the value). `4U / -2` produces the > > unexpected result `0U` rather than the mathematically-correct result `-2`, > > and `-fsanitize=implicit-conversion` doesn't catch it. Maybe just strike > > this sentence for now? > > > > In fact... I think this is too much text to be adding to this bulleted > > list, which is just supposed to summarize the available checks. Maybe > > replace the description with > > > > Signed integer overflow, where the result of a signed integer > > computation cannot be represented in its type. This includes all the checks > > covered by ``-ftrapv``, as well as checks for signed division overflow > > (``INT_MIN/-1``), but not checks for lossy implicit conversions performed > > before the computation (see ``-fsanitize=implicit-conversion``). > I will assume you meant "lossy implicit conversions performed *after* the > computation". I really meant "performed before", for cases like `4u / -2`, where `-2` is implicitly converted to `UINT_MAX - 2` before the computation. Conversions that are performed after a computation aren't part of the computation at all, so I think it's much clearer that they're not in scope for this sanitizer. Repository: rC Clang https://reviews.llvm.org/D48958 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48958: [clang][ubsan] Implicit Cast Sanitizer - integer truncation - clang part
lebedev.ri added inline comments. Comment at: docs/UndefinedBehaviorSanitizer.rst:136-137 + overflow happens (signed or unsigned). + Both of these two issues are handled by ``-fsanitize=implicit-conversion`` + group of checks. - ``-fsanitize=unreachable``: If control flow reaches an unreachable rsmith wrote: > lebedev.ri wrote: > > rsmith wrote: > > > I don't think that's true (not until you add a sanitizer for signed <-> > > > unsigned conversions that change the value). `4U / -2` produces the > > > unexpected result `0U` rather than the mathematically-correct result > > > `-2`, and `-fsanitize=implicit-conversion` doesn't catch it. Maybe just > > > strike this sentence for now? > > > > > > In fact... I think this is too much text to be adding to this bulleted > > > list, which is just supposed to summarize the available checks. Maybe > > > replace the description with > > > > > > Signed integer overflow, where the result of a signed integer > > > computation cannot be represented in its type. This includes all the > > > checks covered by ``-ftrapv``, as well as checks for signed division > > > overflow (``INT_MIN/-1``), but not checks for lossy implicit conversions > > > performed before the computation (see ``-fsanitize=implicit-conversion``). > > I will assume you meant "lossy implicit conversions performed *after* the > > computation". > I really meant "performed before", for cases like `4u / -2`, where `-2` is > implicitly converted to `UINT_MAX - 2` before the computation. Conversions > that are performed after a computation aren't part of the computation at all, > so I think it's much clearer that they're not in scope for this sanitizer. Ok, with that additional explanation, i do see the error of my ways, and will re-adjust the docs accordingly. Sorry. Repository: rC Clang https://reviews.llvm.org/D48958 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r338291 - Remove trailing space
Can you point me to such a discussion about trailing whitespace? It seems to contradict the conclusion in another current thread to not consider churn for out-of-tree users (for C++ API in this case) https://lists.llvm.org/pipermail/cfe-dev/2018-July/058579.html > We have historically taken the position that the churn caused for > out-of-tree users of the C++ API are not a consideration when performing an > API refactoring. (For two reasons: one is that we explicitly do not have a > stable C++ API; the other is that this is the mechanism by which we > encourage people to upstream changes.) This actually seems like a > relatively easy change in that regard: client code can be largely updated > by a regular expression. Michael 2018-07-30 15:36 GMT-05:00 Aaron Ballman : > On Mon, Jul 30, 2018 at 4:24 PM, Michael Kruse > wrote: >> I think removing trailing space is a good thing. Some editors remove >> any trailing space when saving a file. This shows up in diffs that I >> then have to undo manually. > > I've also run into the same issues on occasion. However, this isn't > about whether we dislike trailing spaces or not; it's about NFC churn > for out of tree users who have to try to keep their local patches > clean against upstream. This kind of churn makes for merge conflicts > and this is a the reason the community has traditionally rejected > these large-scale commits in the past. If we want to change that > policy, it should come after community discussion and agreement. > > ~Aaron ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D41376: [libcxx] Implement ABI for Clang/GCC vector extension, constructors, copy_from and copy_to.
This revision was automatically updated to reflect the committed changes. Closed by commit rL338309: [libcxx] implement simd ABI for Clang/GCC vector extension, constructors… (authored by timshen, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D41376?vs=158038=158071#toc Repository: rL LLVM https://reviews.llvm.org/D41376 Files: libcxx/trunk/include/__config libcxx/trunk/include/experimental/__config libcxx/trunk/include/experimental/simd libcxx/trunk/test/std/experimental/simd/simd.abi/vector_extension.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.access/default.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.casts/simd_cast.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.casts/static_simd_cast.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.cons/broadcast.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.cons/default.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.cons/generator.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.cons/load.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.mem/load.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.mem/store.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.traits/abi_for_size.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.traits/is_abi_tag.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd_flag_type.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp Index: libcxx/trunk/include/experimental/__config === --- libcxx/trunk/include/experimental/__config +++ libcxx/trunk/include/experimental/__config @@ -64,4 +64,11 @@ #define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD_ABI \ } _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD +// TODO: support more targets +#if defined(__AVX__) +#define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 32 +#else +#define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 16 +#endif + #endif Index: libcxx/trunk/include/experimental/simd === --- libcxx/trunk/include/experimental/simd +++ libcxx/trunk/include/experimental/simd @@ -651,6 +651,7 @@ */ #include +#include #include #include #include @@ -664,23 +665,241 @@ enum class _StorageKind { _Scalar, _Array, + _VecExt, }; template <_StorageKind __kind, int _Np> struct __simd_abi {}; template -struct __simd_storage_traits {}; +class __simd_storage {}; template -struct __simd_storage_traits<_Tp, - __simd_abi<_StorageKind::_Array, __num_element>> { - using type = std::array<_Tp, __num_element>; +class __simd_storage<_Tp, __simd_abi<_StorageKind::_Array, __num_element>> { + std::array<_Tp, __num_element> __storage_; + + template + friend struct simd; + + template + friend struct simd_mask; + +public: + _Tp __get(size_t __index) const noexcept { return __storage_[__index]; }; + void __set(size_t __index, _Tp __val) noexcept { +__storage_[__index] = __val; + } }; template -struct __simd_storage_traits<_Tp, __simd_abi<_StorageKind::_Scalar, 1>> { - using type = _Tp; +class __simd_storage<_Tp, __simd_abi<_StorageKind::_Scalar, 1>> { + _Tp __storage_; + + template + friend struct simd; + + template + friend struct simd_mask; + +public: + _Tp __get(size_t __index) const noexcept { return (&__storage_)[__index]; }; + void __set(size_t __index, _Tp __val) noexcept { +(&__storage_)[__index] = __val; + } +}; + +#ifndef _LIBCPP_HAS_NO_VECTOR_EXTENSION + +constexpr size_t __floor_pow_of_2(size_t __val) { + return ((__val - 1) & __val) == 0 ? __val +: __floor_pow_of_2((__val - 1) & __val); +} + +constexpr size_t __ceil_pow_of_2(size_t __val) { + return __val == 1 ? 1 : __floor_pow_of_2(__val - 1) << 1; +} + +template +struct __vec_ext_traits { +#if !defined(_LIBCPP_COMPILER_CLANG) + typedef _Tp type __attribute__((vector_size(__ceil_pow_of_2(__bytes; +#endif +}; + +#if defined(_LIBCPP_COMPILER_CLANG) +#define _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, _NUM_ELEMENT)\ + template <> \ + struct __vec_ext_traits<_TYPE, sizeof(_TYPE) * _NUM_ELEMENT> { \ +using type = \ +_TYPE __attribute__((vector_size(sizeof(_TYPE) * _NUM_ELEMENT))); \ + } + +#define _LIBCPP_SPECIALIZE_VEC_EXT_32(_TYPE) \ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 1);\ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 2);\ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 3);\ + _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 4);
[libcxx] r338309 - [libcxx] implement ABI for Clang/GCC vector extension, constructors, copy_from and copy_to.
Author: timshen Date: Mon Jul 30 14:23:13 2018 New Revision: 338309 URL: http://llvm.org/viewvc/llvm-project?rev=338309=rev Log: [libcxx] implement ABI for Clang/GCC vector extension, constructors, copy_from and copy_to. Summary: This patch adds a new macro _LIBCPP_HAS_NO_VECTOR_EXTENSION for detecting whether a vector extension (\_\_attribute\_\_((vector_size(num_bytes is available. On the top of that, this patch implements the following API: * all constructors * operator[] * copy_from * copy_to It also defines simd_abi::native to use vector extension, if available. In GCC and Clang, certain values with vector extension are passed by registers, instead of memory. Based on D41148. Reviewers: mclow.lists, EricWF Subscribers: cfe-commits, MaskRay, lichray, sanjoy Differential Revision: https://reviews.llvm.org/D41376 Added: libcxx/trunk/test/std/experimental/simd/simd.abi/ libcxx/trunk/test/std/experimental/simd/simd.abi/vector_extension.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.access/ libcxx/trunk/test/std/experimental/simd/simd.access/default.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.cons/default.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.cons/load.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.mem/ libcxx/trunk/test/std/experimental/simd/simd.mem/load.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.mem/store.pass.cpp Modified: libcxx/trunk/include/__config libcxx/trunk/include/experimental/__config libcxx/trunk/include/experimental/simd libcxx/trunk/test/std/experimental/simd/simd.casts/simd_cast.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.casts/static_simd_cast.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.cons/broadcast.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.cons/generator.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.traits/abi_for_size.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.traits/is_abi_tag.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd_flag_type.pass.cpp libcxx/trunk/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp Modified: libcxx/trunk/include/__config URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=338309=338308=338309=diff == --- libcxx/trunk/include/__config (original) +++ libcxx/trunk/include/__config Mon Jul 30 14:23:13 2018 @@ -620,6 +620,8 @@ namespace std { #define _LIBCPP_ALWAYS_INLINE __forceinline +#define _LIBCPP_HAS_NO_VECTOR_EXTENSION + #elif defined(_LIBCPP_COMPILER_IBM) #define _ALIGNAS(x) __attribute__((__aligned__(x))) @@ -652,6 +654,8 @@ namespace std { #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) +#define _LIBCPP_HAS_NO_VECTOR_EXTENSION + #endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM] #if _LIBCPP_STD_VER >= 17 Modified: libcxx/trunk/include/experimental/__config URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/__config?rev=338309=338308=338309=diff == --- libcxx/trunk/include/experimental/__config (original) +++ libcxx/trunk/include/experimental/__config Mon Jul 30 14:23:13 2018 @@ -64,4 +64,11 @@ #define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD_ABI \ } _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD +// TODO: support more targets +#if defined(__AVX__) +#define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 32 +#else +#define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 16 +#endif + #endif Modified: libcxx/trunk/include/experimental/simd URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/simd?rev=338309=338308=338309=diff == --- libcxx/trunk/include/experimental/simd (original) +++ libcxx/trunk/include/experimental/simd Mon Jul 30 14:23:13 2018 @@ -651,6 +651,7 @@ public: */ #include +#include #include #include #include @@ -664,23 +665,241 @@ _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIM enum class _StorageKind { _Scalar, _Array, + _VecExt, }; template <_StorageKind __kind, int _Np> struct __simd_abi {}; template -struct __simd_storage_traits {}; +class __simd_storage {}; template -struct __simd_storage_traits<_Tp, - __simd_abi<_StorageKind::_Array, __num_element>> { - using type = std::array<_Tp, __num_element>; +class __simd_storage<_Tp, __simd_abi<_StorageKind::_Array, __num_element>> { + std::array<_Tp, __num_element> __storage_; + + template + friend struct simd; + + template + friend struct simd_mask; + +public: + _Tp __get(size_t __index) const noexcept { return __storage_[__index]; }; + void __set(size_t __index, _Tp __val) noexcept { +__storage_[__index] = __val; + } };
Re: r338299 - [DebugInfo][OpenCL] Generate correct block literal debug info for OpenCL
On Mon, Jul 30, 2018 at 10:37 PM Scott Linder via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: scott.linder > Date: Mon Jul 30 13:31:11 2018 > New Revision: 338299 > > URL: http://llvm.org/viewvc/llvm-project?rev=338299=rev > Log: > [DebugInfo][OpenCL] Generate correct block literal debug info for OpenCL > > OpenCL block literal structs have different fields which are now correctly > identified in the debug info. > > Differential Revision: https://reviews.llvm.org/D49930 > > Modified: > cfe/trunk/lib/CodeGen/CGDebugInfo.cpp > cfe/trunk/test/CodeGenOpenCL/blocks.cl > > Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=338299=338298=338299=diff > > == > --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) > +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Jul 30 13:31:11 2018 > @@ -971,20 +971,25 @@ llvm::DIType *CGDebugInfo::CreateType(co >auto *DescTy = DBuilder.createPointerType(EltTy, Size); > >FieldOffset = 0; > - FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy); > - EltTys.push_back(CreateMemberType(Unit, FType, "__isa", )); > - FType = CGM.getContext().IntTy; > - EltTys.push_back(CreateMemberType(Unit, FType, "__flags", > )); > - EltTys.push_back(CreateMemberType(Unit, FType, "__reserved", > )); > - FType = CGM.getContext().getPointerType(Ty->getPointeeType()); > - EltTys.push_back(CreateMemberType(Unit, FType, "__FuncPtr", > )); > - > - FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy); > - FieldSize = CGM.getContext().getTypeSize(Ty); > - FieldAlign = CGM.getContext().getTypeAlign(Ty); > - EltTys.push_back(DBuilder.createMemberType( > - Unit, "__descriptor", nullptr, LineNo, FieldSize, FieldAlign, > FieldOffset, > - llvm::DINode::FlagZero, DescTy)); > + if (CGM.getLangOpts().OpenCL) { > +FType = CGM.getContext().IntTy; > +EltTys.push_back(CreateMemberType(Unit, FType, "__size", > )); > +EltTys.push_back(CreateMemberType(Unit, FType, "__align", > )); > + } else { > +FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy); > +EltTys.push_back(CreateMemberType(Unit, FType, "__isa", > )); > +FType = CGM.getContext().IntTy; > +EltTys.push_back(CreateMemberType(Unit, FType, "__flags", > )); > +EltTys.push_back(CreateMemberType(Unit, FType, "__reserved", > )); > +FType = CGM.getContext().getPointerType(Ty->getPointeeType()); > +EltTys.push_back(CreateMemberType(Unit, FType, "__FuncPtr", > )); > +FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy); > +FieldSize = CGM.getContext().getTypeSize(Ty); > +FieldAlign = CGM.getContext().getTypeAlign(Ty); > +EltTys.push_back(DBuilder.createMemberType( > +Unit, "__descriptor", nullptr, LineNo, FieldSize, FieldAlign, > FieldOffset, > +llvm::DINode::FlagZero, DescTy)); > + } > llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:974:7: error: variable 'FieldSize' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized] if (CGM.getLangOpts().OpenCL) { ^~~~ llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:994:18: note: uninitialized use occurs here FieldOffset += FieldSize; ^ llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:974:3: note: remove the 'if' if its condition is always false if (CGM.getLangOpts().OpenCL) { ^~~ llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:949:21: note: initialize the variable 'FieldSize' to silence this warning uint64_t FieldSize, FieldOffset; ^ = 0 1 error generated. >FieldOffset += FieldSize; >Elements = DBuilder.getOrCreateArray(EltTys); > @@ -3847,26 +3852,35 @@ void CGDebugInfo::EmitDeclareOfBlockLite >CGM.getDataLayout().getStructLayout(block.StructureType); > >SmallVector fields; > - fields.push_back(createFieldType("__isa", C.VoidPtrTy, loc, AS_public, > - blockLayout->getElementOffsetInBits(0), > - tunit, tunit)); > - fields.push_back(createFieldType("__flags", C.IntTy, loc, AS_public, > - blockLayout->getElementOffsetInBits(1), > - tunit, tunit)); > - fields.push_back(createFieldType("__reserved", C.IntTy, loc, AS_public, > - blockLayout->getElementOffsetInBits(2), > - tunit, tunit)); > - auto *FnTy = block.getBlockExpr()->getFunctionType(); > - auto FnPtrType = CGM.getContext().getPointerType(FnTy->desugar()); > - fields.push_back(createFieldType("__FuncPtr", FnPtrType, loc, AS_public, > - blockLayout->getElementOffsetInBits(3), > - tunit, tunit)); > -
r338306 - [docs] UndefinedBehaviorSanitizer.rst: {, un}signed-integer-overflow: tune docs
Author: lebedevri Date: Mon Jul 30 14:11:32 2018 New Revision: 338306 URL: http://llvm.org/viewvc/llvm-project?rev=338306=rev Log: [docs] UndefinedBehaviorSanitizer.rst: {,un}signed-integer-overflow: tune docs Yes, i erroneously assumed that the "after" was meant, but i was wrong: > I really meant "performed before", for cases like 4u / -2, > where -2 is implicitly converted to UINT_MAX - 2 before > the computation. Conversions that are performed after > a computation aren't part of the computation at all, > so I think it's much clearer that they're not in scope > for this sanitizer. Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UndefinedBehaviorSanitizer.rst?rev=338306=338305=338306=diff == --- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original) +++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Mon Jul 30 14:11:32 2018 @@ -131,7 +131,7 @@ Available checks are: result of a signed integer computation cannot be represented in its type. This includes all the checks covered by ``-ftrapv``, as well as checks for signed division overflow (``INT_MIN/-1``), but not checks for - lossy implicit conversions performed after the computation + lossy implicit conversions performed before the computation (see ``-fsanitize=implicit-conversion``). Both of these two issues are handled by ``-fsanitize=implicit-conversion`` group of checks. - ``-fsanitize=unreachable``: If control flow reaches an unreachable @@ -140,7 +140,7 @@ Available checks are: the result of an unsigned integer computation cannot be represented in its type. Unlike signed integer overflow, this is not undefined behavior, but it is often unintentional. This sanitizer does not check for lossy implicit - conversions performed after such a computation + conversions performed before such a computation (see ``-fsanitize=implicit-conversion``). - ``-fsanitize=vla-bound``: A variable-length array whose bound does not evaluate to a positive value. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D41458: [libc++][C++17] Elementary string conversions for integral types
lichray marked an inline comment as done. lichray added inline comments. Comment at: include/charconv:158 + +#if !defined(_LIBCPP_COMPILER_MSVC) +static _LIBCPP_INLINE_VISIBILITY int __width(_Tp __v) mclow.lists wrote: > In general, we don't put `_LIBCPP_COMPILER_XXX` in header files in libc++. > Instead, we declare a feature macro `_LIBCPP_HAS_` in `<__config>` and > then use that everywhere. > > I see that most of the uses of `_LIBCPP_COMPILER_MSVC` are in ``, > and center around the builtins for `__builtin_clz`, etc. > > We can clean this up later. (/me makes note). > MSVC has the intrinsics we need, but I did not plan to put too much in this patch. The suggested `` header sounds like a good place for grouping up those intrinsics in the future. Comment at: include/charconv:285 +inline _LIBCPP_INLINE_VISIBILITY auto +__to_unsigned(_Tp __x) +{ mclow.lists wrote: > in libc++, we put the return type on the left. > > template > inline _LIBCPP_INLINE_VISIBILITY > auto __to_unsigned(_Tp __x) > > (and then ask 'why auto'?) > ``` template inline _LIBCPP_INLINE_VISIBILITY auto __to_unsigned(_Tp __x) ``` I want this as well, but ClangFormat doesn't support it... The style which I'm using is close to FreeBSD style(9), please forgive. I don't mind if you send me a `.clang-format` file (the one I used is http://paste.openstack.org/show/726883/), but I won't manually adjust the code... About why `auto` -- this file requires C++14 already, so I don't need to repeat my self (by writing `make_unsigned_t<_Tp>` again). Comment at: test/support/charconv_test_helpers.h:226 +void +run(type_list) +{ mclow.lists wrote: > This name `run` concerns me. I'd feel better if it was `run_integral_tests` > or something a bit less general. > > On the other hand, it's in a test, so we can change it whenever we want. > The callsites look like ``` run(all_signed); ``` That's why I named it "run". Not an issue for now I think. Repository: rCXX libc++ https://reviews.llvm.org/D41458 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49930: [DebugInfo][OpenCL] Generate correct block literal debug info for OpenCL
echristo added a comment. In https://reviews.llvm.org/D49930#1181000, @scott.linder wrote: > Sorry, I didn't see the additional comments until after I committed. I will > make those changes; is it OK to update this review, or should I create a new > one? A new one is great. Just treat this as post commit :) > As for choosing limited it was just what the function adding the debug info > checked for as a minimum; what would you generally choose instead? I'd have just suggested plain -g for it? Repository: rL LLVM https://reviews.llvm.org/D49930 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49771: CodeGen: use non-zero memset when possible for automatic variables
mehdi_amini added a comment. I'm curious: isn't the kind of optimization we should expect LLVM to provide? Repository: rL LLVM https://reviews.llvm.org/D49771 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r338291 - Remove trailing space
Maybe not too terrible for out-of-tree projects. If they use git mirror, `git rebase` is smart enough to ignore changing lines with trailing whitespace (if not, there is git rebase -Xignore-space-at-eol). Some editors are configured with highlighting trailing spaces and these spaces will turn to eyesore... On Mon, Jul 30, 2018 at 1:36 PM Aaron Ballman wrote: > > On Mon, Jul 30, 2018 at 4:24 PM, Michael Kruse > wrote: > > I think removing trailing space is a good thing. Some editors remove > > any trailing space when saving a file. This shows up in diffs that I > > then have to undo manually. > > I've also run into the same issues on occasion. However, this isn't > about whether we dislike trailing spaces or not; it's about NFC churn > for out of tree users who have to try to keep their local patches > clean against upstream. This kind of churn makes for merge conflicts > and this is a the reason the community has traditionally rejected > these large-scale commits in the past. If we want to change that > policy, it should come after community discussion and agreement. > > ~Aaron -- 宋方睿 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49722: [CStringSyntaxChecker] Check strlcat sizeof check
devnexen updated this revision to Diff 158062. https://reviews.llvm.org/D49722 Files: lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp test/Analysis/cstring-syntax.c Index: test/Analysis/cstring-syntax.c === --- test/Analysis/cstring-syntax.c +++ test/Analysis/cstring-syntax.c @@ -7,6 +7,7 @@ char *strncat(char *, const char *, size_t); size_t strlen (const char *s); size_t strlcpy(char *, const char *, size_t); +size_t strlcat(char *, const char *, size_t); void testStrncat(const char *src) { char dest[10]; @@ -33,3 +34,19 @@ strlcpy(dest + 5, src, 5); strlcpy(dest + 5, src, 10); // expected-warning {{The third argument is larger than the size of the input buffer.}} } + +void testStrlcat(const char *src) { + char dest[10]; + size_t badlen = 10; + size_t ulen; + strlcpy(dest, "a", sizeof("a") - 1); + strlcat(dest, "", (sizeof("") - 1) - sizeof(dest) - 1); + strlcpy(dest, "012345678", sizeof(dest)); + strlcat(dest, "910", sizeof(dest)); // expected-warning {{The third argument allows to potentially copy more bytes than it should. Replace with the value- strlen(dest) - 1 or lower}} + strlcpy(dest, "0123456789", sizeof(dest)); + strlcat(dest, "0123456789", badlen); // expected-warning {{The third argument allows to potentially copy more bytes than it should. Replace with the value 'badlen' - strlen(dest) - 1 or lower}} + strlcat(dest, "0123456789", badlen - strlen(dest) - 1); + strlcat(dest, src, ulen); + strlcpy(dest, src, 5); + strlcat(dest + 5, src, badlen); // expected-warning {{The third argument allows to potentially copy more bytes than it should. Replace with the value 'badlen' - strlen() - 1 or lower}} +} Index: lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp === --- lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp +++ lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp @@ -90,7 +90,16 @@ /// strlcpy(dst, "abcd", 4); /// strlcpy(dst + 3, "abcd", 2); /// strlcpy(dst, "abcd", cpy); - bool containsBadStrlcpyPattern(const CallExpr *CE); + /// Identify erroneous patterns in the last argument to strlcat - the number + /// of bytes to copy. + /// The bad pattern checked is when the last argument is basically + /// pointing to the destination buffer size or argument larger or + /// equal to. + /// char dst[2]; + /// strlcat(dst, src2, sizeof(dst)); + /// strlcat(dst, src2, 2); + /// strlcat(dst, src2, 10); + bool containsBadStrlcpyStrlcatPattern(const CallExpr *CE); public: WalkAST(const CheckerBase *Checker, BugReporter , AnalysisDeclContext *AC) @@ -142,15 +151,21 @@ return false; } -bool WalkAST::containsBadStrlcpyPattern(const CallExpr *CE) { +bool WalkAST::containsBadStrlcpyStrlcatPattern(const CallExpr *CE) { if (CE->getNumArgs() != 3) return false; + const FunctionDecl *FD = CE->getDirectCallee(); + bool Append = CheckerContext::isCLibraryFunction(FD, "strlcat"); const Expr *DstArg = CE->getArg(0); const Expr *LenArg = CE->getArg(2); const auto *DstArgDecl = dyn_cast(DstArg->IgnoreParenImpCasts()); const auto *LenArgDecl = dyn_cast(LenArg->IgnoreParenLValueCasts()); uint64_t DstOff = 0; + // - sizeof(dst) + // strlcat appends at most size - strlen(dst) - 1 + if (Append && isSizeof(LenArg, DstArg)) +return true; // - size_t dstlen = sizeof(dst) if (LenArgDecl) { const auto *LenArgVal = dyn_cast(LenArgDecl->getDecl()); @@ -181,8 +196,14 @@ if (const auto *Buffer = dyn_cast(DstArgDecl->getType())) { ASTContext = BR.getContext(); uint64_t BufferLen = C.getTypeSize(Buffer) / 8; -if ((BufferLen - DstOff) < ILRawVal) - return true; +auto RemainingBufferLen = BufferLen - DstOff; +if (Append) { + if (RemainingBufferLen <= ILRawVal) +return true; +} else { + if (RemainingBufferLen < ILRawVal) +return true; +} } } } @@ -220,7 +241,7 @@ LenArg->getSourceRange()); } } else if (CheckerContext::isCLibraryFunction(FD, "strlcpy")) { -if (containsBadStrlcpyPattern(CE)) { +if (containsBadStrlcpyStrlcatPattern(CE)) { const Expr *DstArg = CE->getArg(0); const Expr *LenArg = CE->getArg(2); PathDiagnosticLocation Loc = @@ -234,6 +255,34 @@ if (!DstName.empty()) os << "Replace with the value 'sizeof(" << DstName << ")` or lower"; + BR.EmitBasicReport(FD, Checker, "Anti-pattern in the argument", + "C String API", os.str(), Loc, + LenArg->getSourceRange()); +} + } else if (CheckerContext::isCLibraryFunction(FD, "strlcat")) { +if (containsBadStrlcpyStrlcatPattern(CE)) { + const Expr *DstArg = CE->getArg(0); + const Expr *LenArg = CE->getArg(2); +
[PATCH] D49100: Avoid returning an invalid end source loc
steveire closed this revision. steveire added a comment. Committed in SVN revision 338301. Repository: rC Clang https://reviews.llvm.org/D49100 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r338291 - Remove trailing space
Does this apply to only public headers (include/llvm include/llvm-c include/clang ...) or everything? (lib/**/*.{cpp,h})? On Mon, Jul 30, 2018 at 1:36 PM Aaron Ballman wrote: > > On Mon, Jul 30, 2018 at 4:24 PM, Michael Kruse > wrote: > > I think removing trailing space is a good thing. Some editors remove > > any trailing space when saving a file. This shows up in diffs that I > > then have to undo manually. > > I've also run into the same issues on occasion. However, this isn't > about whether we dislike trailing spaces or not; it's about NFC churn > for out of tree users who have to try to keep their local patches > clean against upstream. This kind of churn makes for merge conflicts > and this is a the reason the community has traditionally rejected > these large-scale commits in the past. If we want to change that > policy, it should come after community discussion and agreement. > > ~Aaron -- 宋方睿 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r338301 - Avoid returning an invalid end source loc
Author: steveire Date: Mon Jul 30 13:39:14 2018 New Revision: 338301 URL: http://llvm.org/viewvc/llvm-project?rev=338301=rev Log: Avoid returning an invalid end source loc Modified: cfe/trunk/include/clang/AST/DeclarationName.h cfe/trunk/lib/AST/DeclarationName.cpp Modified: cfe/trunk/include/clang/AST/DeclarationName.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclarationName.h?rev=338301=338300=338301=diff == --- cfe/trunk/include/clang/AST/DeclarationName.h (original) +++ cfe/trunk/include/clang/AST/DeclarationName.h Mon Jul 30 13:39:14 2018 @@ -558,7 +558,7 @@ public: SourceLocation getBeginLoc() const { return NameLoc; } /// getEndLoc - Retrieve the location of the last token. - SourceLocation getEndLoc() const; + SourceLocation getEndLoc() const { return getLocEnd(); } /// getSourceRange - The range of the declaration name. SourceRange getSourceRange() const LLVM_READONLY { @@ -570,9 +570,11 @@ public: } SourceLocation getLocEnd() const LLVM_READONLY { -SourceLocation EndLoc = getEndLoc(); +SourceLocation EndLoc = getEndLocPrivate(); return EndLoc.isValid() ? EndLoc : getLocStart(); } +private: + SourceLocation getEndLocPrivate() const; }; /// Insertion operator for diagnostics. This allows sending DeclarationName's Modified: cfe/trunk/lib/AST/DeclarationName.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclarationName.cpp?rev=338301=338300=338301=diff == --- cfe/trunk/lib/AST/DeclarationName.cpp (original) +++ cfe/trunk/lib/AST/DeclarationName.cpp Mon Jul 30 13:39:14 2018 @@ -689,7 +689,7 @@ void DeclarationNameInfo::printName(raw_ llvm_unreachable("Unexpected declaration name kind"); } -SourceLocation DeclarationNameInfo::getEndLoc() const { +SourceLocation DeclarationNameInfo::getEndLocPrivate() const { switch (Name.getNameKind()) { case DeclarationName::Identifier: case DeclarationName::CXXDeductionGuideName: ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r338299 - [DebugInfo][OpenCL] Generate correct block literal debug info for OpenCL
Author: scott.linder Date: Mon Jul 30 13:31:11 2018 New Revision: 338299 URL: http://llvm.org/viewvc/llvm-project?rev=338299=rev Log: [DebugInfo][OpenCL] Generate correct block literal debug info for OpenCL OpenCL block literal structs have different fields which are now correctly identified in the debug info. Differential Revision: https://reviews.llvm.org/D49930 Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/test/CodeGenOpenCL/blocks.cl Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=338299=338298=338299=diff == --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Jul 30 13:31:11 2018 @@ -971,20 +971,25 @@ llvm::DIType *CGDebugInfo::CreateType(co auto *DescTy = DBuilder.createPointerType(EltTy, Size); FieldOffset = 0; - FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy); - EltTys.push_back(CreateMemberType(Unit, FType, "__isa", )); - FType = CGM.getContext().IntTy; - EltTys.push_back(CreateMemberType(Unit, FType, "__flags", )); - EltTys.push_back(CreateMemberType(Unit, FType, "__reserved", )); - FType = CGM.getContext().getPointerType(Ty->getPointeeType()); - EltTys.push_back(CreateMemberType(Unit, FType, "__FuncPtr", )); - - FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy); - FieldSize = CGM.getContext().getTypeSize(Ty); - FieldAlign = CGM.getContext().getTypeAlign(Ty); - EltTys.push_back(DBuilder.createMemberType( - Unit, "__descriptor", nullptr, LineNo, FieldSize, FieldAlign, FieldOffset, - llvm::DINode::FlagZero, DescTy)); + if (CGM.getLangOpts().OpenCL) { +FType = CGM.getContext().IntTy; +EltTys.push_back(CreateMemberType(Unit, FType, "__size", )); +EltTys.push_back(CreateMemberType(Unit, FType, "__align", )); + } else { +FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy); +EltTys.push_back(CreateMemberType(Unit, FType, "__isa", )); +FType = CGM.getContext().IntTy; +EltTys.push_back(CreateMemberType(Unit, FType, "__flags", )); +EltTys.push_back(CreateMemberType(Unit, FType, "__reserved", )); +FType = CGM.getContext().getPointerType(Ty->getPointeeType()); +EltTys.push_back(CreateMemberType(Unit, FType, "__FuncPtr", )); +FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy); +FieldSize = CGM.getContext().getTypeSize(Ty); +FieldAlign = CGM.getContext().getTypeAlign(Ty); +EltTys.push_back(DBuilder.createMemberType( +Unit, "__descriptor", nullptr, LineNo, FieldSize, FieldAlign, FieldOffset, +llvm::DINode::FlagZero, DescTy)); + } FieldOffset += FieldSize; Elements = DBuilder.getOrCreateArray(EltTys); @@ -3847,26 +3852,35 @@ void CGDebugInfo::EmitDeclareOfBlockLite CGM.getDataLayout().getStructLayout(block.StructureType); SmallVector fields; - fields.push_back(createFieldType("__isa", C.VoidPtrTy, loc, AS_public, - blockLayout->getElementOffsetInBits(0), - tunit, tunit)); - fields.push_back(createFieldType("__flags", C.IntTy, loc, AS_public, - blockLayout->getElementOffsetInBits(1), - tunit, tunit)); - fields.push_back(createFieldType("__reserved", C.IntTy, loc, AS_public, - blockLayout->getElementOffsetInBits(2), - tunit, tunit)); - auto *FnTy = block.getBlockExpr()->getFunctionType(); - auto FnPtrType = CGM.getContext().getPointerType(FnTy->desugar()); - fields.push_back(createFieldType("__FuncPtr", FnPtrType, loc, AS_public, - blockLayout->getElementOffsetInBits(3), - tunit, tunit)); - fields.push_back(createFieldType( - "__descriptor", - C.getPointerType(block.NeedsCopyDispose - ? C.getBlockDescriptorExtendedType() - : C.getBlockDescriptorType()), - loc, AS_public, blockLayout->getElementOffsetInBits(4), tunit, tunit)); + if (CGM.getLangOpts().OpenCL) { +fields.push_back(createFieldType("__size", C.IntTy, loc, AS_public, + blockLayout->getElementOffsetInBits(0), + tunit, tunit)); +fields.push_back(createFieldType("__align", C.IntTy, loc, AS_public, + blockLayout->getElementOffsetInBits(1), + tunit, tunit)); + } else { +fields.push_back(createFieldType("__isa", C.VoidPtrTy, loc, AS_public, + blockLayout->getElementOffsetInBits(0), + tunit, tunit)); +fields.push_back(createFieldType("__flags", C.IntTy, loc, AS_public, +
[PATCH] D49930: [DebugInfo][OpenCL] Generate correct block literal debug info for OpenCL
scott.linder added a comment. Sorry, I didn't see the additional comments until after I committed. I will make those changes; is it OK to update this review, or should I create a new one? As for choosing limited it was just what the function adding the debug info checked for as a minimum; what would you generally choose instead? Repository: rL LLVM https://reviews.llvm.org/D49930 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r338291 - Remove trailing space
On Mon, Jul 30, 2018 at 4:24 PM, Michael Kruse wrote: > I think removing trailing space is a good thing. Some editors remove > any trailing space when saving a file. This shows up in diffs that I > then have to undo manually. I've also run into the same issues on occasion. However, this isn't about whether we dislike trailing spaces or not; it's about NFC churn for out of tree users who have to try to keep their local patches clean against upstream. This kind of churn makes for merge conflicts and this is a the reason the community has traditionally rejected these large-scale commits in the past. If we want to change that policy, it should come after community discussion and agreement. ~Aaron ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r338291 - Remove trailing space
On Mon, Jul 30, 2018 at 3:52 PM, Fāng-ruì Sòng wrote: > Oops.. sorry but now they have been committed.. The commits can still be reverted and I think they should be. ~Aaron ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49930: [DebugInfo][OpenCL] Generate correct block literal debug info for OpenCL
This revision was automatically updated to reflect the committed changes. Closed by commit rL338299: [DebugInfo][OpenCL] Generate correct block literal debug info for OpenCL (authored by scott.linder, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D49930?vs=157737=158060#toc Repository: rL LLVM https://reviews.llvm.org/D49930 Files: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/test/CodeGenOpenCL/blocks.cl Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp === --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp @@ -971,20 +971,25 @@ auto *DescTy = DBuilder.createPointerType(EltTy, Size); FieldOffset = 0; - FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy); - EltTys.push_back(CreateMemberType(Unit, FType, "__isa", )); - FType = CGM.getContext().IntTy; - EltTys.push_back(CreateMemberType(Unit, FType, "__flags", )); - EltTys.push_back(CreateMemberType(Unit, FType, "__reserved", )); - FType = CGM.getContext().getPointerType(Ty->getPointeeType()); - EltTys.push_back(CreateMemberType(Unit, FType, "__FuncPtr", )); - - FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy); - FieldSize = CGM.getContext().getTypeSize(Ty); - FieldAlign = CGM.getContext().getTypeAlign(Ty); - EltTys.push_back(DBuilder.createMemberType( - Unit, "__descriptor", nullptr, LineNo, FieldSize, FieldAlign, FieldOffset, - llvm::DINode::FlagZero, DescTy)); + if (CGM.getLangOpts().OpenCL) { +FType = CGM.getContext().IntTy; +EltTys.push_back(CreateMemberType(Unit, FType, "__size", )); +EltTys.push_back(CreateMemberType(Unit, FType, "__align", )); + } else { +FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy); +EltTys.push_back(CreateMemberType(Unit, FType, "__isa", )); +FType = CGM.getContext().IntTy; +EltTys.push_back(CreateMemberType(Unit, FType, "__flags", )); +EltTys.push_back(CreateMemberType(Unit, FType, "__reserved", )); +FType = CGM.getContext().getPointerType(Ty->getPointeeType()); +EltTys.push_back(CreateMemberType(Unit, FType, "__FuncPtr", )); +FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy); +FieldSize = CGM.getContext().getTypeSize(Ty); +FieldAlign = CGM.getContext().getTypeAlign(Ty); +EltTys.push_back(DBuilder.createMemberType( +Unit, "__descriptor", nullptr, LineNo, FieldSize, FieldAlign, FieldOffset, +llvm::DINode::FlagZero, DescTy)); + } FieldOffset += FieldSize; Elements = DBuilder.getOrCreateArray(EltTys); @@ -3847,26 +3852,35 @@ CGM.getDataLayout().getStructLayout(block.StructureType); SmallVector fields; - fields.push_back(createFieldType("__isa", C.VoidPtrTy, loc, AS_public, - blockLayout->getElementOffsetInBits(0), - tunit, tunit)); - fields.push_back(createFieldType("__flags", C.IntTy, loc, AS_public, - blockLayout->getElementOffsetInBits(1), - tunit, tunit)); - fields.push_back(createFieldType("__reserved", C.IntTy, loc, AS_public, - blockLayout->getElementOffsetInBits(2), - tunit, tunit)); - auto *FnTy = block.getBlockExpr()->getFunctionType(); - auto FnPtrType = CGM.getContext().getPointerType(FnTy->desugar()); - fields.push_back(createFieldType("__FuncPtr", FnPtrType, loc, AS_public, - blockLayout->getElementOffsetInBits(3), - tunit, tunit)); - fields.push_back(createFieldType( - "__descriptor", - C.getPointerType(block.NeedsCopyDispose - ? C.getBlockDescriptorExtendedType() - : C.getBlockDescriptorType()), - loc, AS_public, blockLayout->getElementOffsetInBits(4), tunit, tunit)); + if (CGM.getLangOpts().OpenCL) { +fields.push_back(createFieldType("__size", C.IntTy, loc, AS_public, + blockLayout->getElementOffsetInBits(0), + tunit, tunit)); +fields.push_back(createFieldType("__align", C.IntTy, loc, AS_public, + blockLayout->getElementOffsetInBits(1), + tunit, tunit)); + } else { +fields.push_back(createFieldType("__isa", C.VoidPtrTy, loc, AS_public, + blockLayout->getElementOffsetInBits(0), + tunit, tunit)); +fields.push_back(createFieldType("__flags", C.IntTy, loc, AS_public, + blockLayout->getElementOffsetInBits(1), + tunit, tunit)); +fields.push_back(createFieldType("__reserved", C.IntTy, loc, AS_public, +
[PATCH] D41458: [libc++][C++17] Elementary string conversions for integral types
mclow.lists added a comment. Getting close here. I'll have a couple more comments later today, so don't post a new diff quite yet. Comment at: include/charconv:244 +static _LIBCPP_INLINE_VISIBILITY char const* +read(char const* __p, char const* __ep, type& __a, type& __b) +{ Quuxplusone wrote: > mclow.lists wrote: > > lichray wrote: > > > mclow.lists wrote: > > > > Same comment as above about `read` and `inner_product` - they need to > > > > be "ugly names" > > > Unlike `traits` which is a template parameter name in the standard, > > > `read` and `inner_product` are function names in the standard, which > > > means the users cannot make a macro for them (and there is no guarantee > > > about what name you make **not** get by including certain headers), so we > > > don't need to use ugly names here, am I right? > > I understand your reasoning, but I don't agree. > > > > Just last month, I had to rename a function in `vector` from `allocate` to > > `__vallocate` because it confused our "is this an allocator" detection. The > > function in question was private, so it shouldn't have mattered, but GCC > > has a bug where sometimes it partially ignores access restrictions in > > non-deduced contexts, and then throws a hard error when it comes back to a > > different context. The easiest workaround was to rename the function in > > `vector`. > > > > Since then, I've been leery of public names that match others. This is > > pretty obscure, since it's in a private namespace, but I'd feel better if > > they were `__read` and `__inner_product`. > > > FWIW, +1 to ugly names. Even if the un-ugly code is "technically not broken > yet", and besides the technical reason Marshall gives, > (1) it's nice that libc++ has style rules and sticks to them, precisely to > *avoid* bikeshedding the name of every private member in the world; > (2) just because users can't `#define read write` doesn't mean they *won't* > do it. I would actually be extremely surprised if `read` were *not* defined > as a macro somewhere inside ``. :) > > See also: "should this function call be `_VSTD::`-qualified?" Sometimes the > answer is technically "no", but stylistically "yes", precisely to indicate > that we *don't* intend for it to be an ADL customization point. Consistent > style leads to maintainability. > See also: "should this function call be _VSTD::-qualified We already have an `inner_product` ( in ``), so I think not. We `_VSTD::` qualify `move` and `forward` always. `min`/`max` due mostly to windows macros. `swap` when need to disable ADL. Other things we're inconsistent about: `declval` sometimes (I don't know why), `use_facet`, `addressof`, `to_raw_pointer`. I'll figure out when we should mark things with `_VSTD` and write it up. Comment at: include/charconv:359 +auto __gen_digit = [](_Tp __c) { +return "0123456789abcdefghijklmnopqrstuvwxyz"[__c]; +}; lichray wrote: > mclow.lists wrote: > > Thinking some more - did this used to do more? Because I don't see why > > having a lambda here is a benefit, as compared to: > > > > const char *__digits = "0123456789abcdefghijklmnopqrstuvwxyz"; > > > > and > > *--p = digits[__c]; > > > I use a lambda here because it may do more in the future. If someone wants > to let it support non-ASCII platforms, then they only need to make a patch > against this lambda rather than changing the sites of uses. After all, there > is nothing wrong to abstract out anything into a function, I think... I don't think that making it a lambda today buys us anything. Since it is local, we can make it a lambda again in the future if we need to w/o breaking anyone. Shades of YAGNI. Comment at: include/charconv:158 + +#if !defined(_LIBCPP_COMPILER_MSVC) +static _LIBCPP_INLINE_VISIBILITY int __width(_Tp __v) In general, we don't put `_LIBCPP_COMPILER_XXX` in header files in libc++. Instead, we declare a feature macro `_LIBCPP_HAS_` in `<__config>` and then use that everywhere. I see that most of the uses of `_LIBCPP_COMPILER_MSVC` are in ``, and center around the builtins for `__builtin_clz`, etc. We can clean this up later. (/me makes note). Comment at: include/charconv:285 +inline _LIBCPP_INLINE_VISIBILITY auto +__to_unsigned(_Tp __x) +{ in libc++, we put the return type on the left. template inline _LIBCPP_INLINE_VISIBILITY auto __to_unsigned(_Tp __x) (and then ask 'why auto'?) Comment at: test/support/charconv_test_helpers.h:226 +void +run(type_list) +{ This name `run` concerns me. I'd feel better if it was `run_integral_tests` or something a bit less general. On the other hand, it's in a test, so we can change it whenever we want. Repository: rCXX libc++ https://reviews.llvm.org/D41458
[PATCH] D49986: [ADT] ImmutableList::add parameters are switched
NoQ accepted this revision. NoQ added a comment. This revision is now accepted and ready to land. Cool! Always bothered me. In https://reviews.llvm.org/D49986#1180403, @george.karpenkov wrote: > I'm a bit confused: does it mean these methods are never called in Clang? This patch *is* for clang. Repository: rC Clang https://reviews.llvm.org/D49986 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50008: [libc++] Remove _LIBCPP_BUILDING_XXX macros, which are redundant since _LIBCPP_BUILDING_LIBRARY
ldionne created this revision. ldionne added a reviewer: mclow.lists. Herald added a reviewer: EricWF. Herald added subscribers: cfe-commits, dexonsmith, christof. As suggested by Marshall in https://reviews.llvm.org/D49914 Repository: rCXX libc++ https://reviews.llvm.org/D50008 Files: libcxx/include/__functional_base libcxx/include/__mutex_base libcxx/include/functional libcxx/include/memory libcxx/include/new libcxx/include/shared_mutex libcxx/include/system_error libcxx/include/utility libcxx/src/bind.cpp libcxx/src/memory.cpp libcxx/src/mutex.cpp libcxx/src/new.cpp libcxx/src/shared_mutex.cpp libcxx/src/system_error.cpp libcxx/src/utility.cpp libcxxabi/src/stdlib_exception.cpp libcxxabi/src/stdlib_new_delete.cpp Index: libcxxabi/src/stdlib_new_delete.cpp === --- libcxxabi/src/stdlib_new_delete.cpp +++ libcxxabi/src/stdlib_new_delete.cpp @@ -9,7 +9,6 @@ // This file implements the new and delete operators. //===--===// -#define _LIBCPP_BUILDING_NEW #define _LIBCPP_BUILDING_LIBRARY #include "__cxxabi_config.h" #include Index: libcxxabi/src/stdlib_exception.cpp === --- libcxxabi/src/stdlib_exception.cpp +++ libcxxabi/src/stdlib_exception.cpp @@ -8,7 +8,6 @@ //===--===// #define _LIBCPP_BUILDING_LIBRARY -#define _LIBCPP_BUILDING_NEW #include #include Index: libcxx/src/utility.cpp === --- libcxx/src/utility.cpp +++ libcxx/src/utility.cpp @@ -7,7 +7,6 @@ // //===--===// -#define _LIBCPP_BUILDING_UTILITY #include "utility" _LIBCPP_BEGIN_NAMESPACE_STD Index: libcxx/src/system_error.cpp === --- libcxx/src/system_error.cpp +++ libcxx/src/system_error.cpp @@ -9,7 +9,6 @@ #include "__config" -#define _LIBCPP_BUILDING_SYSTEM_ERROR #include "system_error" #include "include/config_elast.h" Index: libcxx/src/shared_mutex.cpp === --- libcxx/src/shared_mutex.cpp +++ libcxx/src/shared_mutex.cpp @@ -10,7 +10,6 @@ #include "__config" #ifndef _LIBCPP_HAS_NO_THREADS -#define _LIBCPP_BUILDING_SHARED_MUTEX #include "shared_mutex" _LIBCPP_BEGIN_NAMESPACE_STD Index: libcxx/src/new.cpp === --- libcxx/src/new.cpp +++ libcxx/src/new.cpp @@ -7,8 +7,6 @@ // //===--===// -#define _LIBCPP_BUILDING_NEW - #include #include "new" Index: libcxx/src/mutex.cpp === --- libcxx/src/mutex.cpp +++ libcxx/src/mutex.cpp @@ -7,7 +7,6 @@ // //===--===// -#define _LIBCPP_BUILDING_MUTEX #include "mutex" #include "limits" #include "system_error" Index: libcxx/src/memory.cpp === --- libcxx/src/memory.cpp +++ libcxx/src/memory.cpp @@ -7,7 +7,6 @@ // //===--===// -#define _LIBCPP_BUILDING_MEMORY #include "memory" #ifndef _LIBCPP_HAS_NO_THREADS #include "mutex" Index: libcxx/src/bind.cpp === --- libcxx/src/bind.cpp +++ libcxx/src/bind.cpp @@ -7,7 +7,6 @@ // //===--===// -#define _LIBCPP_BUILDING_BIND #include "functional" _LIBCPP_BEGIN_NAMESPACE_STD Index: libcxx/include/utility === --- libcxx/include/utility +++ libcxx/include/utility @@ -295,7 +295,7 @@ #endif struct _LIBCPP_TEMPLATE_VIS piecewise_construct_t { }; -#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_UTILITY) +#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY) extern const piecewise_construct_t piecewise_construct;// = piecewise_construct_t(); #else /* _LIBCPP_INLINE_VAR */ constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t(); Index: libcxx/include/system_error === --- libcxx/include/system_error +++ libcxx/include/system_error @@ -199,7 +199,7 @@ public: virtual ~error_category() _NOEXCEPT; -#if defined(_LIBCPP_BUILDING_SYSTEM_ERROR) && \ +#if defined(_LIBCPP_BUILDING_LIBRARY) && \ defined(_LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS) error_category() _NOEXCEPT; #else Index: libcxx/include/shared_mutex
[PATCH] D49930: [DebugInfo][OpenCL] Generate correct block literal debug info for OpenCL
echristo added a comment. The patch is fine, in general, couple of comments: a) Can you refactor this so the if conditionals are just two functions? Those functions are big enough already. b) I'm not quite sure why you're picking limited here, do you have an explanation? c) Can you split that part out into a separate test? Additional run lines in the existing blocks.cl test would be fine. Thanks! Repository: rC Clang https://reviews.llvm.org/D49930 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49911: Summary:Add clang::reinitializes attribute
mboehme marked 3 inline comments as done. mboehme added a comment. > Should this attribute have some semantic checking that ensures the non-static > data members are accessed in the function that claims it reinitializes the > object? I think this would be hard to do in a way that provides meaningful value. We can't demand that the function should modify all member variables because not all functions that perform a logical "clear" or other reinitialization need to do this. For example, a typical implementation of `std::string::clear()` only modifies the string length but leaves the capacity and buffer unchanged. The strongest requirement I think we can impose is that the function needs to modify at least one of the member variables -- possibly indirectly (i.e. through a call to another function). I don't think checking this would provide a real benefit though. We already disallow the `reinitializes` attribute for const member functions -- so if someone misuses the attribute, it'll be on a non-const member function that most likely modifies member variables, just not in a way that's guaranteed to reinitialize the object. What we'd really want to check is whether the function is actually doing a logical reinitialization of the object. Instead of putting the 'reinitializes' attribute on the function, we'd want some way of expressing "this function has the precondition `true` and the postcondition `empty()`", and then we'd like to prove this at compile time or at least check it at runtime. That's obviously beyond the scope of what is possible in C++ today though. Comment at: include/clang/Basic/Attr.td:96 +[{!S->isStatic() && !S->isConst()}], +"non-static non-const member functions">; + aaron.ballman wrote: > `non-static, non-const member functions` (with the comma) IIUC, Clang then translates the comma into an "and" -- so the actual diagnostic becomes "non-static and non-const member functions" (see the expected-error in the tests). Is this as intended? Comment at: include/clang/Basic/Attr.td:2945 +def Reinitializes : InheritableAttr { + let Spellings = [CXX11<"clang", "reinitializes">]; + let Subjects = SubjectList<[NonStaticNonConstCXXMethod], ErrorDiag>; aaron.ballman wrote: > I think it makes sense to use `CXX11` instead of `Clang` as this attribute > doesn't make sense in C2x mode, but should there be a `GNU` spelling as well? I have to admit I'm not sure. What are the usual considerations here? Does this need to be coordinated in any way with GNU, or can Clang simply introduce additional "GNU-style" spellings (i.e. with `__attribute__`) that are Clang-only? I understand there's a difference between `GCC` spellings and `GNU` spellings -- but I'm not sure what the rules around the latter are. Let me know if you think this should have a `GNU` spelling, and I'll add it! Comment at: include/clang/Basic/AttrDocs.td:3426 + let Content = [{ +The ``reinitializes`` attribute can be applied to a non-static, non-const C++ +member function to indicate that this member function reinitializes the entire aaron.ballman wrote: > While I kind of understand the restriction on a `const` member function, what > about code that has mutable members being reset within a const method? I find it hard to envision a method that reinitializes an object by modifying only mutable member variables. Mutable members are, after all, intended to be used for purposes (such as caching and locking) that do not change the "logical state" of the object, whereas reinitialization is an operation that does change the logical state of the object. If it really does turn out that there are legitimate use cases for applying the 'reinitializes' attribute to a const member function, we can always relax this requirement later on. Repository: rC Clang https://reviews.llvm.org/D49911 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49317: Move __construct_forward (etc.) out of std::allocator_traits.
Quuxplusone added a comment. In https://reviews.llvm.org/D49317#1180852, @ldionne wrote: > After thinking about this for some more, I'm not sure this patch is worth > doing in its current form. The minimal patch for allowing specializations of > `allocator_traits` would be: > > 1. move the `__move_construct_forward` & friends functions from > `allocator_traits` to private static member functions of `std::vector` > (because they're only used in `std::vector` right now). > 2. keep the SFINAE on the allocator and avoid encoding any `memcpy` decision > at the call site. FWLIW, I approve of (1) but not (2), for the previously stated reason that the optimal path is known only at the call-site; the callee doesn't have enough information to know whether memcpy is appropriate. (But it sounds like Marshall doesn't want any memcpy happening at all, so maybe it's moot?) > However, an even better alternative would be to look into adding an overload > to `uninitialized_move` & friends that takes an allocator. We could then be > clever in how this is implemented. The major benefit I see here is that there > would be one common code path to optimize, as opposed to a > `std::vector`-specific code path. Yes, when I implemented https://github.com/Quuxplusone/from-scratch/, one of the many things I noticed was that none of the uninitialized_foo algorithms were useful out of the box; every one of them needed to be reimplemented to take an allocator parameter. (A.k.a., "scoped_allocator_adaptor is why we can't have nice things.") However, as you point out, this is a long-standing problem and would require a library paper to do "right." (It would still be easy enough to add the needed algorithms with uglified names, e.g. `__uninitialized_copy_a`, `__destroy_a`, etc. This is exactly what libstdc++ does, and libc++ might be wise to copy its approach.) I'd be happy to throw together a patch for `__uninitialized_copy_a` etc., since I think that would improve libc++ in general; but I don't see how that would directly help any specific short-term problem in libc++. This patch as it is helps two specific short-term problems: (1) that user specializations of allocator_traits don't work (but, as the test case comments, this is arguably not a good idea anyway; see also https://quuxplusone.github.io/blog/2018/07/14/traits-classes/ ) (2) that the diff between libc++ trunk and libc++ trivially-relocatable is unnecessarily large Messing with the uninitialized_foo algorithms would not directly help either of these problems, so we'd have to come up with some other rationale for it. Repository: rCXX libc++ https://reviews.llvm.org/D49317 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49865: Inform the AST of #pragma FENV_ACCESS use
rsmith accepted this revision. rsmith added inline comments. This revision is now accepted and ready to land. Comment at: lib/Parse/ParsePragma.cpp:619-623 +#if NOTYET // FIXME: Add this cli option when it makes sense. + case tok::OOS_DEFAULT: +FPC = getLangOpts().getDefaultFENVAccessMode(); +break; +#endif rsmith wrote: > You need to do *something* in this case. Currently, `FPC` is read > uninitialized a few lines below when this happens. How about just treating > this as the same as `OFF` for now, since that is our default. Drop the `#if NOTYET` part; we don't like having checked-in but commented-out code. Just keep the FIXME comment. Comment at: lib/Parse/ParsePragma.cpp:109 return; -if (OOS == tok::OOS_ON) +if (OOS == tok::OOS_ON) { PP.Diag(Tok, diag::warn_stdc_fenv_access_not_supported); We also need to pass the pragma on to `Sema` when it's set to `OFF`. https://reviews.llvm.org/D49865 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r338291 - Remove trailing space
Oops.. sorry but now they have been committed.. On Mon, Jul 30, 2018 at 12:31 PM Aaron Ballman wrote: > > This is an extraordinary amount of churn for very little value, IMO. > The same goes for r338291. Were these changes discussed somewhere > before being committed? I worry about the negative impact for third > parties having to deal with changes on this scale. > > ~Aaron > > On Mon, Jul 30, 2018 at 3:24 PM, Fangrui Song via cfe-commits > wrote: > > Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp > > URL: > > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=338291=338290=338291=diff > > == > > --- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original) > > +++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Mon Jul 30 12:24:48 2018 > > @@ -73,7 +73,7 @@ ExprResult Sema::ParseObjCStringLiteral( > >/*Pascal=*/false, StrTy, [0], > >StrLocs.size()); > >} > > - > > + > >return BuildObjCStringLiteral(AtLocs[0], S); > > } > > > > @@ -92,12 +92,12 @@ ExprResult Sema::BuildObjCStringLiteral( > >} else if (getLangOpts().NoConstantCFStrings) { > > IdentifierInfo *NSIdent=nullptr; > > std::string StringClass(getLangOpts().ObjCConstantStringClass); > > - > > + > > if (StringClass.empty()) > >NSIdent = ("NSConstantString"); > > else > >NSIdent = (StringClass); > > - > > + > > NamedDecl *IF = LookupSingleName(TUScope, NSIdent, AtLoc, > > LookupOrdinaryName); > > if (ObjCInterfaceDecl *StrIF = > > dyn_cast_or_null(IF)) { > > @@ -126,10 +126,10 @@ ExprResult Sema::BuildObjCStringLiteral( > >// being an 'id' type. > >Ty = Context.getObjCNSStringType(); > >if (Ty.isNull()) { > > -ObjCInterfaceDecl *NSStringIDecl = > > - ObjCInterfaceDecl::Create (Context, > > - Context.getTranslationUnitDecl(), > > - SourceLocation(), NSIdent, > > +ObjCInterfaceDecl *NSStringIDecl = > > + ObjCInterfaceDecl::Create (Context, > > + Context.getTranslationUnitDecl(), > > + SourceLocation(), NSIdent, > > nullptr, nullptr, SourceLocation()); > > Ty = Context.getObjCInterfaceType(NSStringIDecl); > > Context.setObjCNSStringType(Ty); > > @@ -252,16 +252,16 @@ static ObjCMethodDecl *getNSNumberFactor > > } > > return nullptr; > >} > > - > > + > >// If we already looked up this method, we're done. > >if (S.NSNumberLiteralMethods[*Kind]) > > return S.NSNumberLiteralMethods[*Kind]; > > - > > + > >Selector Sel = S.NSAPIObj->getNSNumberLiteralSelector(*Kind, > > > > /*Instance=*/false); > > - > > + > >ASTContext = S.Context; > > - > > + > >// Look up the NSNumber class, if we haven't done so already. It's cached > >// in the Sema instance. > >if (!S.NSNumberDecl) { > > @@ -277,7 +277,7 @@ static ObjCMethodDecl *getNSNumberFactor > > QualType NSNumberObject = CX.getObjCInterfaceType(S.NSNumberDecl); > > S.NSNumberPointer = CX.getObjCObjectPointerType(NSNumberObject); > >} > > - > > + > >// Look for the appropriate method within NSNumber. > >ObjCMethodDecl *Method = S.NSNumberDecl->lookupClassMethod(Sel); > >if (!Method && S.getLangOpts().DebuggerObjCLiteral) { > > @@ -304,7 +304,7 @@ static ObjCMethodDecl *getNSNumberFactor > > > >// Note: if the parameter type is out-of-line, we'll catch it later in > > the > >// implicit conversion. > > - > > + > >S.NSNumberLiteralMethods[*Kind] = Method; > >return Method; > > } > > @@ -322,21 +322,21 @@ ExprResult Sema::BuildObjCNumericLiteral > > case CharacterLiteral::UTF8: > >NumberType = Context.CharTy; > >break; > > - > > + > > case CharacterLiteral::Wide: > >NumberType = Context.getWideCharType(); > >break; > > - > > + > > case CharacterLiteral::UTF16: > >NumberType = Context.Char16Ty; > >break; > > - > > + > > case CharacterLiteral::UTF32: > >NumberType = Context.Char32Ty; > >break; > > } > >} > > - > > + > >// Look for the appropriate method within NSNumber. > >// Construct the literal. > >SourceRange NR(Number->getSourceRange()); > > @@ -355,33 +355,33 @@ ExprResult Sema::BuildObjCNumericLiteral > >if (ConvertedNumber.isInvalid()) > > return ExprError(); > >Number = ConvertedNumber.get(); > > - > > + > >// Use the effective source range of the literal, including the leading > > '@'. > >return MaybeBindToTemporary( > > new (Context) ObjCBoxedExpr(Number, NSNumberPointer, Method, > >
[PATCH] D49911: Summary:Add clang::reinitializes attribute
mboehme updated this revision to Diff 158051. mboehme added a comment. Various changes in response to reviewer comments. Repository: rC Clang https://reviews.llvm.org/D49911 Files: include/clang/Basic/Attr.td include/clang/Basic/AttrDocs.td lib/Sema/SemaDeclAttr.cpp test/SemaCXX/attr-reinitializes.cpp Index: test/SemaCXX/attr-reinitializes.cpp === --- /dev/null +++ test/SemaCXX/attr-reinitializes.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s + +[[clang::reinitializes]] int a; // expected-error {{'reinitializes' attribute only applies to non-static and non-const member functions}} + +[[clang::reinitializes]] void f(); // expected-error {{only applies to}} + +struct A { + [[clang::reinitializes]] void foo(); + [[clang::reinitializes]] void bar() const; // expected-error {{only applies to}} + [[clang::reinitializes]] static void baz(); // expected-error {{only applies to}} + [[clang::reinitializes]] int a; // expected-error {{only applies to}} + + [[clang::reinitializes("arg")]] void qux(); // expected-error {{'reinitializes' attribute takes no arguments}} +}; Index: lib/Sema/SemaDeclAttr.cpp === --- lib/Sema/SemaDeclAttr.cpp +++ lib/Sema/SemaDeclAttr.cpp @@ -6539,6 +6539,11 @@ case ParsedAttr::AT_XRayLogArgs: handleXRayLogArgsAttr(S, D, AL); break; + + // Move semantics attribute. + case ParsedAttr::AT_Reinitializes: +handleSimpleAttribute(S, D, AL); +break; } } Index: include/clang/Basic/AttrDocs.td === --- include/clang/Basic/AttrDocs.td +++ include/clang/Basic/AttrDocs.td @@ -3419,3 +3419,31 @@ corresponding line within the inlined callee. }]; } + +def ReinitializesDocs : Documentation { + let Category = DocCatFunction; + let Content = [{ +The ``reinitializes`` attribute can be applied to a non-static, non-const C++ +member function to indicate that this member function reinitializes the entire +object to a known state, independent of the previous state of the object. + +This attribute can be interpreted by static analyzers that warn about uses of an +object that has been left in an indeterminate state by a move operation. If a +member function marked with the ``reinitializes`` attribute is called on a +moved-from object, the analyzer can conclude that the object is no longer in an +indeterminate state. + +A typical example where this attribute would be used is on functions that clear +a container class: + +.. code-block:: c++ + + template + class Container { + public: +... +[[clang::reinitializes]] void Clear(); +... + }; + }]; +} Index: include/clang/Basic/Attr.td === --- include/clang/Basic/Attr.td +++ include/clang/Basic/Attr.td @@ -90,6 +90,11 @@ [{!S->isBitField()}], "non-bit-field non-static data members">; +def NonStaticNonConstCXXMethod +: SubsetSubjectisStatic() && !S->isConst()}], +"non-static, non-const member functions">; + def ObjCInstanceMethod : SubsetSubjectisInstanceMethod()}], "Objective-C instance methods">; @@ -2935,3 +2940,9 @@ let Subjects = SubjectList<[Var, Function, CXXRecord]>; let Documentation = [InternalLinkageDocs]; } + +def Reinitializes : InheritableAttr { + let Spellings = [CXX11<"clang", "reinitializes">]; + let Subjects = SubjectList<[NonStaticNonConstCXXMethod], ErrorDiag>; + let Documentation = [ReinitializesDocs]; +} Index: test/SemaCXX/attr-reinitializes.cpp === --- /dev/null +++ test/SemaCXX/attr-reinitializes.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s + +[[clang::reinitializes]] int a; // expected-error {{'reinitializes' attribute only applies to non-static and non-const member functions}} + +[[clang::reinitializes]] void f(); // expected-error {{only applies to}} + +struct A { + [[clang::reinitializes]] void foo(); + [[clang::reinitializes]] void bar() const; // expected-error {{only applies to}} + [[clang::reinitializes]] static void baz(); // expected-error {{only applies to}} + [[clang::reinitializes]] int a; // expected-error {{only applies to}} + + [[clang::reinitializes("arg")]] void qux(); // expected-error {{'reinitializes' attribute takes no arguments}} +}; Index: lib/Sema/SemaDeclAttr.cpp === --- lib/Sema/SemaDeclAttr.cpp +++ lib/Sema/SemaDeclAttr.cpp @@ -6539,6 +6539,11 @@ case ParsedAttr::AT_XRayLogArgs: handleXRayLogArgsAttr(S, D, AL); break; + + // Move semantics attribute. + case ParsedAttr::AT_Reinitializes: +handleSimpleAttribute(S, D, AL); +break; } }
[PATCH] D45639: [Driver] Support default libc++ library location on Darwin
phosek added a comment. I think we just ran into one such issue. We're using our own Clang that's usually following tip-of-tree and we recently switched to C++17, but that started failing on our macOS 10.12 bots with: Undefined symbols for architecture x86_64: "operator delete(void*, std::align_val_t)", referenced from: _main in main.cpp.o std::__1::__vector_base >, std::__1::allocator > > >::~__vector_base() in main.cpp.o std::__1::__vector_base >, std::__1::allocator > > >::~__vector_base() in main.cpp.o std::__1::__vector_base >, std::__1::allocator > > >::~__vector_base() in main.cpp.o std::__1::__vector_base >, std::__1::allocator > > >::~__vector_base() in main.cpp.o std::__1::__vector_base >, std::__1::allocator > > >::~__vector_base() in main.cpp.o std::__1::__vector_base >, std::__1::allocator > > >::~__vector_base() in main.cpp.o ... "operator new(unsigned long, std::align_val_t)", referenced from: std::__1::enable_if<__is_forward_iterator::value, void>::type std::__1::basic_string, std::__1::allocator >::__init(char*, char*) in main.cpp.o std::__1::unique_ptr > >, void*>, std::__1::__tree_node_destructor > >, void*> > > > std::__1::__tree > >, std::__1::__map_value_compare<(anonymous namespace)::Behavior, std::__1::__value_type<(anonymous namespace)::Behavior, std::__1::basic_fstream > >, std::__1::less<(anonymous namespace)::Behavior>, true>, std::__1::allocator > > > >::__construct_node<(anonymous namespace)::Behavior, std::__1::basic_fstream > >((anonymous namespace)::Behavior&&, std::__1::basic_fstream >&&) in main.cpp.o std::__1::__split_buffer&>::__split_buffer(unsigned long, unsigned long, std::__1::allocator&) in main.cpp.o std::__1::vector >::__vallocate(unsigned long) in main.cpp.o std::__1::unique_ptr >, std::__1::unique_ptr > >, void*>, std::__1::__tree_node_destructor >, std::__1::unique_ptr > >, void*> > > > std::__1::__tree >, std::__1::unique_ptr > >, std::__1::__map_value_compare >, std::__1::__value_type >, std::__1::unique_ptr > >, std::__1::less > >, true>, std::__1::allocator >, std::__1::unique_ptr > > > >::__construct_node >, std::__1::unique_ptr > > >(std::__1::pair >, std::__1::unique_ptr > >&&) in main.cpp.o std::__1::enable_if<__is_forward_iterator::value, void>::type std::__1::basic_string, std::__1::allocator >::__init(char const*, char const*) in libfidl.a(c_generator.cpp.o) std::__1::__split_buffer&>::__split_buffer(unsigned long, unsigned long, std::__1::allocator&) in libfidl.a(c_generator.cpp.o) ... ld: symbol(s) not found for architecture x86_64 AFAICT this is because `/usr/lib/libc++.dylib` doesn't yet support C++17, but the headers that are part of Clang toolchain do. When we force Clang to use libc++ that's part of the toolchain by manually setting the necessary `-L`/`-l` flag resolves the issue. I don't know if this is an expected behavior, but I'd really appreciate some response on this. Repository: rC Clang https://reviews.llvm.org/D45639 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D41376: [libcxx] Implement ABI for Clang/GCC vector extension, constructors, copy_from and copy_to.
mclow.lists accepted this revision. mclow.lists added a comment. This revision is now accepted and ready to land. LGTM. Thanks! https://reviews.llvm.org/D41376 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48862: [OpenEmbedded] Fix lib paths for OpenEmbedded targets
This revision was automatically updated to reflect the committed changes. Closed by commit rL338294: [OpenEmbedded] Fix lib paths for OpenEmbedded targets (authored by mgrang, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D48862?vs=157391=158049#toc Repository: rL LLVM https://reviews.llvm.org/D48862 Files: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp cfe/trunk/lib/Driver/ToolChains/Linux.cpp cfe/trunk/test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/include/c++/6.3.0/backward/.keep cfe/trunk/test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/lib64/aarch64-oe-linux/6.3.0/crtbegin.o cfe/trunk/test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/lib64/aarch64-oe-linux/6.3.0/crtend.o cfe/trunk/test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/lib64/crt1.o cfe/trunk/test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/lib64/crti.o cfe/trunk/test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/lib64/crtn.o cfe/trunk/test/Driver/Inputs/openembedded_arm_linux_tree/usr/include/c++/6.3.0/backward/.keep cfe/trunk/test/Driver/Inputs/openembedded_arm_linux_tree/usr/lib/arm-oe-linux-gnueabi/6.3.0/crtbegin.o cfe/trunk/test/Driver/Inputs/openembedded_arm_linux_tree/usr/lib/arm-oe-linux-gnueabi/6.3.0/crtend.o cfe/trunk/test/Driver/Inputs/openembedded_arm_linux_tree/usr/lib/crt1.o cfe/trunk/test/Driver/Inputs/openembedded_arm_linux_tree/usr/lib/crti.o cfe/trunk/test/Driver/Inputs/openembedded_arm_linux_tree/usr/lib/crtn.o cfe/trunk/test/Driver/linux-header-search.cpp cfe/trunk/test/Driver/linux-ld.c Index: cfe/trunk/test/Driver/linux-ld.c === --- cfe/trunk/test/Driver/linux-ld.c +++ cfe/trunk/test/Driver/linux-ld.c @@ -1813,4 +1813,40 @@ // CHECK-LD-AMI: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" // CHECK-LD-AMI: "-lc" // CHECK-LD-AMI: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" -// + +// Check whether the OpenEmbedded ARM libs are added correctly. +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: --target=arm-oe-linux-gnueabi \ +// RUN: --sysroot=%S/Inputs/openembedded_arm_linux_tree \ +// RUN: | FileCheck --check-prefix=CHECK-OE-ARM %s + +// CHECK-OE-ARM: "-cc1" "-triple" "armv4t-oe-linux-gnueabi" +// CHECK-OE-ARM: ld{{.*}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-OE-ARM: "-m" "armelf_linux_eabi" "-dynamic-linker" +// CHECK-OE-ARM: "[[SYSROOT]]/usr/lib/arm-oe-linux-gnueabi/6.3.0/../../../lib{{/|}}crt1.o" +// CHECK-OE-ARM: "[[SYSROOT]]/usr/lib/arm-oe-linux-gnueabi/6.3.0/../../../lib{{/|}}crti.o" +// CHECK-OE-ARM: "[[SYSROOT]]/usr/lib/arm-oe-linux-gnueabi/6.3.0{{/|}}crtbegin.o" +// CHECK-OE-ARM: "-L[[SYSROOT]]/usr/lib/arm-oe-linux-gnueabi/6.3.0" +// CHECK-OE-ARM: "-L[[SYSROOT]]/usr/lib/arm-oe-linux-gnueabi" +// CHECK-OE-ARM: "-L[[SYSROOT]]/usr/lib" +// CHECK-OE-ARM: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" +// CHECK-OE-ARM: "[[SYSROOT]]/usr/lib/arm-oe-linux-gnueabi/6.3.0{{/|}}crtend.o" +// CHECK-OE-ARM: "[[SYSROOT]]/usr/lib/arm-oe-linux-gnueabi/6.3.0/../../../lib{{/|}}crtn.o" + +// Check whether the OpenEmbedded AArch64 libs are added correctly. +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: --target=aarch64-oe-linux \ +// RUN: --sysroot=%S/Inputs/openembedded_aarch64_linux_tree \ +// RUN: | FileCheck --check-prefix=CHECK-OE-AARCH64 %s + +// CHECK-OE-AARCH64: "-cc1" "-triple" "aarch64-oe-linux" +// CHECK-OE-AARCH64: ld{{.*}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-OE-AARCH64: "-m" "aarch64linux" "-dynamic-linker" +// CHECK-OE-AARCH64: "[[SYSROOT]]/usr/lib64/aarch64-oe-linux/6.3.0/../../../lib64{{/|}}crt1.o" +// CHECK-OE-AARCH64: "[[SYSROOT]]/usr/lib64/aarch64-oe-linux/6.3.0/../../../lib64{{/|}}crti.o" +// CHECK-OE-AARCH64: "[[SYSROOT]]/usr/lib64/aarch64-oe-linux/6.3.0{{/|}}crtbegin.o" +// CHECK-OE-AARCH64: "-L[[SYSROOT]]/usr/lib64/aarch64-oe-linux/6.3.0" +// CHECK-OE-AARCH64: "-L[[SYSROOT]]/usr/lib64" +// CHECK-OE-AARCH64: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" +// CHECK-OE-AARCH64: "[[SYSROOT]]/usr/lib64/aarch64-oe-linux/6.3.0{{/|}}crtend.o" +// CHECK-OE-AARCH64: "[[SYSROOT]]/usr/lib64/aarch64-oe-linux/6.3.0/../../../lib64{{/|}}crtn.o" Index: cfe/trunk/test/Driver/linux-header-search.cpp === --- cfe/trunk/test/Driver/linux-header-search.cpp +++ cfe/trunk/test/Driver/linux-header-search.cpp @@ -493,3 +493,25 @@ // CHECK-DEBIAN-SPARC64: "-internal-externc-isystem" "[[SYSROOT]]/usr/include/sparc64-linux-gnu" // CHECK-DEBIAN-SPARC64: "-internal-externc-isystem" "[[SYSROOT]]/include" // CHECK-DEBIAN-SPARC64: "-internal-externc-isystem" "[[SYSROOT]]/usr/include" + +// Check header search on OpenEmbedded ARM. +// RUN: %clang
[PATCH] D49317: Move __construct_forward (etc.) out of std::allocator_traits.
ldionne requested changes to this revision. ldionne added a comment. This revision now requires changes to proceed. After thinking about this for some more, I'm not sure this patch is worth doing in its current form. The minimal patch for allowing specializations of `allocator_traits` would be: 1. move the `__move_construct_forward` & friends functions from `allocator_traits` to private static member functions of `std::vector` (because they're only used in `std::vector` right now). 2. keep the SFINAE on the allocator and avoid encoding any `memcpy` decision at the call site. However, an even better alternative would be to look into adding an overload to `uninitialized_move` & friends that takes an allocator. We could then be clever in how this is implemented. The major benefit I see here is that there would be one common code path to optimize, as opposed to a `std::vector`-specific code path. Given the small benefit provided by this patch, my opinion is that it's not worth moving forward with it as-is. However, I believe either of the two alternatives suggested above would be welcome, with a preference for the more comprehensive second approach, which requires a paper. Arthur, what do you think? Do you think the second approach can work? Repository: rCXX libc++ https://reviews.llvm.org/D49317 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r338294 - [OpenEmbedded] Fix lib paths for OpenEmbedded targets
Author: mgrang Date: Mon Jul 30 12:44:13 2018 New Revision: 338294 URL: http://llvm.org/viewvc/llvm-project?rev=338294=rev Log: [OpenEmbedded] Fix lib paths for OpenEmbedded targets Summary: The lib paths are not correctly picked up for OpenEmbedded sysroots (like arm-oe-linux-gnueabi) for 2 reasons: 1. OpenEmbedded sysroots are of the form /usr/lib//x.y.z. This form is handled in clang but only for Freescale vendor. 2. 64-bit OpenEmbedded sysroots may not have a /usr/lib dir. So they cannot find /usr/lib64 as it is referenced as /usr/lib/../lib64 in clang. This is a follow-up to the llvm patch: D48861 Reviewers: dlj, rengolin, fedor.sergeev, javed.absar, hfinkel, rsmith Reviewed By: rsmith Subscribers: rsmith, kristof.beyls, cfe-commits Differential Revision: https://reviews.llvm.org/D48862 Added: cfe/trunk/test/Driver/Inputs/openembedded_aarch64_linux_tree/ cfe/trunk/test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/ cfe/trunk/test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/include/ cfe/trunk/test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/include/c++/ cfe/trunk/test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/include/c++/6.3.0/ cfe/trunk/test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/include/c++/6.3.0/backward/ cfe/trunk/test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/include/c++/6.3.0/backward/.keep cfe/trunk/test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/lib64/ cfe/trunk/test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/lib64/aarch64-oe-linux/ cfe/trunk/test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/lib64/aarch64-oe-linux/6.3.0/ cfe/trunk/test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/lib64/aarch64-oe-linux/6.3.0/crtbegin.o cfe/trunk/test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/lib64/aarch64-oe-linux/6.3.0/crtend.o cfe/trunk/test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/lib64/crt1.o cfe/trunk/test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/lib64/crti.o cfe/trunk/test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/lib64/crtn.o cfe/trunk/test/Driver/Inputs/openembedded_arm_linux_tree/ cfe/trunk/test/Driver/Inputs/openembedded_arm_linux_tree/usr/ cfe/trunk/test/Driver/Inputs/openembedded_arm_linux_tree/usr/include/ cfe/trunk/test/Driver/Inputs/openembedded_arm_linux_tree/usr/include/c++/ cfe/trunk/test/Driver/Inputs/openembedded_arm_linux_tree/usr/include/c++/6.3.0/ cfe/trunk/test/Driver/Inputs/openembedded_arm_linux_tree/usr/include/c++/6.3.0/backward/ cfe/trunk/test/Driver/Inputs/openembedded_arm_linux_tree/usr/include/c++/6.3.0/backward/.keep cfe/trunk/test/Driver/Inputs/openembedded_arm_linux_tree/usr/lib/ cfe/trunk/test/Driver/Inputs/openembedded_arm_linux_tree/usr/lib/arm-oe-linux-gnueabi/ cfe/trunk/test/Driver/Inputs/openembedded_arm_linux_tree/usr/lib/arm-oe-linux-gnueabi/6.3.0/ cfe/trunk/test/Driver/Inputs/openembedded_arm_linux_tree/usr/lib/arm-oe-linux-gnueabi/6.3.0/crtbegin.o cfe/trunk/test/Driver/Inputs/openembedded_arm_linux_tree/usr/lib/arm-oe-linux-gnueabi/6.3.0/crtend.o cfe/trunk/test/Driver/Inputs/openembedded_arm_linux_tree/usr/lib/crt1.o cfe/trunk/test/Driver/Inputs/openembedded_arm_linux_tree/usr/lib/crti.o cfe/trunk/test/Driver/Inputs/openembedded_arm_linux_tree/usr/lib/crtn.o Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp cfe/trunk/lib/Driver/ToolChains/Linux.cpp cfe/trunk/test/Driver/linux-header-search.cpp cfe/trunk/test/Driver/linux-ld.c Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=338294=338293=338294=diff == --- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Mon Jul 30 12:44:13 2018 @@ -2188,7 +2188,8 @@ void Generic_GCC::GCCInstallationDetecto // this on Freescale triples, though, since some systems put a *lot* of // files in that location, not just GCC installation data. {CandidateTriple.str(), "..", - TargetTriple.getVendor() == llvm::Triple::Freescale}, + TargetTriple.getVendor() == llvm::Triple::Freescale || + TargetTriple.getVendor() == llvm::Triple::OpenEmbedded}, // Natively multiarch systems sometimes put the GCC triple-specific // directory within their multiarch lib directory, resulting in the Modified: cfe/trunk/lib/Driver/ToolChains/Linux.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Linux.cpp?rev=338294=338293=338294=diff == --- cfe/trunk/lib/Driver/ToolChains/Linux.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp Mon Jul 30 12:44:13 2018 @@ -376,7 +376,14 @@ Linux::Linux(const Driver , const llvm }
[PATCH] D50002: [coroutines] Fix handling of dependent co_await in StmtProfiler
vitaut added a comment. > Do you need someone to commit this for you? Yes, please. I don't have commit rights. Repository: rC Clang https://reviews.llvm.org/D50002 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50002: [coroutines] Fix handling of dependent co_await in StmtProfiler
rsmith accepted this revision. rsmith added a comment. This revision is now accepted and ready to land. Looks good, thanks. Do you need someone to commit this for you? Repository: rC Clang https://reviews.llvm.org/D50002 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48862: [OpenEmbedded] Fix lib paths for OpenEmbedded targets
mgrang added a comment. I would commit this today unless there any comments. Thanks. https://reviews.llvm.org/D48862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49930: [DebugInfo][OpenCL] Generate correct block literal debug info for OpenCL
yaxunl accepted this revision. yaxunl added a comment. This revision is now accepted and ready to land. In https://reviews.llvm.org/D49930#1180388, @scott.linder wrote: > Thank you for taking a look @yaxunl. Should I wait for another reviewer or > can I commit this? I think it is OK to land. We could have post-commit reviews if there are any issues. Repository: rC Clang https://reviews.llvm.org/D49930 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50003: Sema: Fix explicit address space cast involving void pointers
yaxunl created this revision. yaxunl added a reviewer: rjmccall. Explicit cast of a void pointer to a pointer type in different address space is incorrectly classified as bitcast, which causes invalid bitcast in codegen. The patch fixes that by checking the address space of the source and destination type and set the correct cast kind. https://reviews.llvm.org/D50003 Files: lib/Sema/SemaCast.cpp test/CodeGenCXX/address-space-cast.cpp Index: test/CodeGenCXX/address-space-cast.cpp === --- test/CodeGenCXX/address-space-cast.cpp +++ test/CodeGenCXX/address-space-cast.cpp @@ -3,13 +3,63 @@ #define __private__ __attribute__((address_space(5))) void func_pchar(__private__ char *x); +void func_pvoid(__private__ void *x); +void func_pint(__private__ int *x); -void test_cast(char *gen_ptr) { +void test_cast(char *gen_char_ptr, void *gen_void_ptr, int *gen_int_ptr) { // CHECK: %[[cast:.*]] = addrspacecast i8* %{{.*}} to i8 addrspace(5)* // CHECK-NEXT: store i8 addrspace(5)* %[[cast]] - __private__ char *priv_ptr = (__private__ char *)gen_ptr; + __private__ char *priv_char_ptr = (__private__ char *)gen_char_ptr; // CHECK: %[[cast:.*]] = addrspacecast i8* %{{.*}} to i8 addrspace(5)* + // CHECK-NEXT: store i8 addrspace(5)* %[[cast]] + priv_char_ptr = (__private__ char *)gen_void_ptr; + + // CHECK: %[[cast:.*]] = addrspacecast i32* %{{.*}} to i8 addrspace(5)* + // CHECK-NEXT: store i8 addrspace(5)* %[[cast]] + priv_char_ptr = (__private__ char *)gen_int_ptr; + + // CHECK: %[[cast:.*]] = addrspacecast i8* %{{.*}} to i8 addrspace(5)* + // CHECK-NEXT: store i8 addrspace(5)* %[[cast]] + __private__ void *priv_void_ptr = (__private__ void *)gen_char_ptr; + + // CHECK: %[[cast:.*]] = addrspacecast i8* %{{.*}} to i8 addrspace(5)* + // CHECK-NEXT: store i8 addrspace(5)* %[[cast]] + priv_void_ptr = (__private__ void *)gen_void_ptr; + + // CHECK: %[[cast:.*]] = addrspacecast i32* %{{.*}} to i8 addrspace(5)* + // CHECK-NEXT: store i8 addrspace(5)* %[[cast]] + priv_void_ptr = (__private__ void *)gen_int_ptr; + + // CHECK: %[[cast:.*]] = addrspacecast i8* %{{.*}} to i32 addrspace(5)* + // CHECK-NEXT: store i32 addrspace(5)* %[[cast]] + __private__ int *priv_int_ptr = (__private__ int *)gen_void_ptr; + + // CHECK: %[[cast:.*]] = addrspacecast i8* %{{.*}} to i8 addrspace(5)* + // CHECK-NEXT: call void @_Z10func_pcharPU3AS5c(i8 addrspace(5)* %[[cast]]) + func_pchar((__private__ char *)gen_char_ptr); + + // CHECK: %[[cast:.*]] = addrspacecast i8* %{{.*}} to i8 addrspace(5)* + // CHECK-NEXT: call void @_Z10func_pcharPU3AS5c(i8 addrspace(5)* %[[cast]]) + func_pchar((__private__ char *)gen_void_ptr); + + // CHECK: %[[cast:.*]] = addrspacecast i32* %{{.*}} to i8 addrspace(5)* // CHECK-NEXT: call void @_Z10func_pcharPU3AS5c(i8 addrspace(5)* %[[cast]]) - func_pchar((__private__ char *)gen_ptr); + func_pchar((__private__ char *)gen_int_ptr); + + // CHECK: %[[cast:.*]] = addrspacecast i8* %{{.*}} to i8 addrspace(5)* + // CHECK-NEXT: call void @_Z10func_pvoidPU3AS5v(i8 addrspace(5)* %[[cast]]) + func_pvoid((__private__ void *)gen_char_ptr); + + // CHECK: %[[cast:.*]] = addrspacecast i8* %{{.*}} to i8 addrspace(5)* + // CHECK-NEXT: call void @_Z10func_pvoidPU3AS5v(i8 addrspace(5)* %[[cast]]) + func_pvoid((__private__ void *)gen_void_ptr); + + // CHECK: %[[cast:.*]] = addrspacecast i32* %{{.*}} to i8 addrspace(5)* + // CHECK-NEXT: call void @_Z10func_pvoidPU3AS5v(i8 addrspace(5)* %[[cast]]) + func_pvoid((__private__ void *)gen_int_ptr); + + // CHECK: %[[cast:.*]] = addrspacecast i8* %{{.*}} to i32 addrspace(5)* + // CHECK-NEXT: call void @_Z9func_pintPU3AS5i(i32 addrspace(5)* %[[cast]]) + func_pint((__private__ int *)gen_void_ptr); } Index: lib/Sema/SemaCast.cpp === --- lib/Sema/SemaCast.cpp +++ lib/Sema/SemaCast.cpp @@ -1044,6 +1044,12 @@ } } +static bool IsAddressSpaceConversion(QualType SrcType, QualType DestType) { + return SrcType->isPointerType() && DestType->isPointerType() && + SrcType->getAs()->getPointeeType().getAddressSpace() != + DestType->getAs()->getPointeeType().getAddressSpace(); +} + /// TryStaticCast - Check if a static cast can be performed, and do so if /// possible. If @p CStyle, ignore access restrictions on hierarchy casting /// and casting away constness. @@ -1185,7 +1191,9 @@ return TC_Failed; } } - Kind = CK_BitCast; + Kind = IsAddressSpaceConversion(SrcType, DestType) + ? CK_AddressSpaceConversion + : CK_BitCast; return TC_Success; } @@ -1964,12 +1972,6 @@ return Result.isUsable(); } -static bool IsAddressSpaceConversion(QualType SrcType, QualType DestType) { - return SrcType->isPointerType() && DestType->isPointerType() && -
[PATCH] D50002: [coroutines] Fix handling of dependent co_await in StmtProfiler
vitaut created this revision. vitaut added reviewers: rsmith, GorNishanov, EricWF. Herald added subscribers: cfe-commits, modocache. Fix "Invalid operator call kind" error (`llvm_unreachable`) in `DecodeOperatorCall` when compiling the following example with `-emit-pch`: struct S {}; S operator co_await(S) { return S(); } template int f3(T x) { co_await x; } Add the example to PCH test cases. Repository: rC Clang https://reviews.llvm.org/D50002 Files: lib/AST/StmtProfile.cpp test/PCH/coroutines.cpp Index: test/PCH/coroutines.cpp === --- test/PCH/coroutines.cpp +++ test/PCH/coroutines.cpp @@ -66,6 +66,14 @@ co_return x; // checks coreturn_stmt with expr } +struct S {}; +S operator co_await(S) { return S(); } + +template +int f3(T x) { + co_await x; // checks dependent_coawait with overloaded co_await operator +} + #else // expected-no-diagnostics Index: lib/AST/StmtProfile.cpp === --- lib/AST/StmtProfile.cpp +++ lib/AST/StmtProfile.cpp @@ -1277,7 +1277,6 @@ case OO_Arrow: case OO_Call: case OO_Conditional: - case OO_Coawait: case NUM_OVERLOADED_OPERATORS: llvm_unreachable("Invalid operator call kind"); @@ -1449,6 +1448,10 @@ case OO_Subscript: return Stmt::ArraySubscriptExprClass; + + case OO_Coawait: +UnaryOp = UO_Coawait; +return Stmt::UnaryOperatorClass; } llvm_unreachable("Invalid overloaded operator expression"); Index: test/PCH/coroutines.cpp === --- test/PCH/coroutines.cpp +++ test/PCH/coroutines.cpp @@ -66,6 +66,14 @@ co_return x; // checks coreturn_stmt with expr } +struct S {}; +S operator co_await(S) { return S(); } + +template +int f3(T x) { + co_await x; // checks dependent_coawait with overloaded co_await operator +} + #else // expected-no-diagnostics Index: lib/AST/StmtProfile.cpp === --- lib/AST/StmtProfile.cpp +++ lib/AST/StmtProfile.cpp @@ -1277,7 +1277,6 @@ case OO_Arrow: case OO_Call: case OO_Conditional: - case OO_Coawait: case NUM_OVERLOADED_OPERATORS: llvm_unreachable("Invalid operator call kind"); @@ -1449,6 +1448,10 @@ case OO_Subscript: return Stmt::ArraySubscriptExprClass; + + case OO_Coawait: +UnaryOp = UO_Coawait; +return Stmt::UnaryOperatorClass; } llvm_unreachable("Invalid overloaded operator expression"); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r338239 - [mips64][clang] Provide the signext attribute for i32 return values
On 7/30/2018 3:44 AM, Stefan Maksimovic via cfe-commits wrote: Author: smaksimovic Date: Mon Jul 30 03:44:46 2018 New Revision: 338239 URL: http://llvm.org/viewvc/llvm-project?rev=338239=rev Log: [mips64][clang] Provide the signext attribute for i32 return values Additional info: see r338019. Differential Revision: https://reviews.llvm.org/D49289 Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp I'd like to see some test coverage for this. -El -- Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49898: Make test/Driver/baremetal.cpp work with linkers other than lld
greened closed this revision. greened added a comment. Committed in 338290. Repository: rC Clang https://reviews.llvm.org/D49898 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D41376: [libcxx] Implement ABI for Clang/GCC vector extension, constructors, copy_from and copy_to.
timshen added inline comments. Comment at: libcxx/include/experimental/simd:703 +public: + _Tp __get(size_t __index) const { return (&__storage_)[__index]; }; + void __set(size_t __index, _Tp __val) { (&__storage_)[__index] = __val; } mclow.lists wrote: > Can these (`__get` and `__set`) be noexcept? Obviously, it depends on `_Tp`. Currently _Tp is always a subset of arithmetic type, so it's safe to say noexcept. Added them, as they may help with -O0 performance. Comment at: libcxx/include/experimental/simd:811 +class __simd_reference { + static_assert(std::is_same<_Vp, _Tp>::value, ""); + mclow.lists wrote: > If `_Vp` and `_Tp` have to name the same type, why have two of them? > What is the difference, and when would you use each one internally? > > __simd_reference(__simd_storage<_Tp, _Abi>* __ptr, size_t __index); > vs. > __simd_reference operator=(_Vp __value) &&; > > If _Vp and _Tp have to name the same type, why have two of them? Currently there is no difference. It's going to be different when simd_mask is implemented (_Vp can be bool, but _Tp may not be). > What is the difference, and when would you use each one internally? This is not an internal class. This is part of the interface. IIRC since P0214R9 opreator=() is changed to something. In a later patch operator=() should be implemented as R9 specified. https://reviews.llvm.org/D41376 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D41376: [libcxx] Implement ABI for Clang/GCC vector extension, constructors, copy_from and copy_to.
timshen updated this revision to Diff 158038. timshen marked 2 inline comments as done. timshen added a comment. Update based on comments. https://reviews.llvm.org/D41376 Files: libcxx/include/__config libcxx/include/experimental/__config libcxx/include/experimental/simd libcxx/test/std/experimental/simd/simd.abi/vector_extension.pass.cpp libcxx/test/std/experimental/simd/simd.access/default.pass.cpp libcxx/test/std/experimental/simd/simd.casts/simd_cast.pass.cpp libcxx/test/std/experimental/simd/simd.casts/static_simd_cast.pass.cpp libcxx/test/std/experimental/simd/simd.cons/broadcast.pass.cpp libcxx/test/std/experimental/simd/simd.cons/default.pass.cpp libcxx/test/std/experimental/simd/simd.cons/generator.pass.cpp libcxx/test/std/experimental/simd/simd.cons/load.pass.cpp libcxx/test/std/experimental/simd/simd.mem/load.pass.cpp libcxx/test/std/experimental/simd/simd.mem/store.pass.cpp libcxx/test/std/experimental/simd/simd.traits/abi_for_size.pass.cpp libcxx/test/std/experimental/simd/simd.traits/is_abi_tag.pass.cpp libcxx/test/std/experimental/simd/simd.traits/is_simd.pass.cpp libcxx/test/std/experimental/simd/simd.traits/is_simd_flag_type.pass.cpp libcxx/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp Index: libcxx/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp === --- libcxx/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp +++ libcxx/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp @@ -7,127 +7,146 @@ // //===--===// -// UNSUPPORTED: c++98, c++03 +// UNSUPPORTED: c++98, c++03, c++11, c++14 // // // [simd.traits] -// template struct is_simd_mask; -// template inline constexpr bool is_simd_mask_v = is_simd_mask::value; +// template struct ex::is_simd_mask; +// template inline constexpr bool ex::is_simd_mask_v = +// ex::is_simd_mask::value; #include #include #include "test_macros.h" -using namespace std::experimental::parallelism_v2; +namespace ex = std::experimental::parallelism_v2; struct UserType {}; -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); - -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); - -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); - -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); -static_assert( is_simd_mask>::value, ""); - -static_assert(!is_simd_mask::value, ""); -static_assert(!is_simd_mask::value, ""); -static_assert(!is_simd_mask::value, ""); -static_assert(!is_simd_mask>::value, ""); -static_assert(!is_simd_mask>::value, ""); -static_assert(!is_simd_mask::value, ""); - -#if TEST_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) &&\ -!defined(_LIBCPP_HAS_NO_INLINE_VARIABLES) - -static_assert( is_simd_mask_v>, ""); -static_assert( is_simd_mask_v>, ""); -static_assert( is_simd_mask_v>, ""); -static_assert( is_simd_mask_v>, ""); -static_assert( is_simd_mask_v>, ""); -static_assert( is_simd_mask_v>, ""); -static_assert( is_simd_mask_v>, ""); -static_assert( is_simd_mask_v>, ""); -static_assert( is_simd_mask_v>, ""); -static_assert( is_simd_mask_v>, ""); - -static_assert( is_simd_mask_v>, ""); -static_assert( is_simd_mask_v>, ""); -static_assert( is_simd_mask_v>, ""); -static_assert( is_simd_mask_v>, ""); -static_assert( is_simd_mask_v>, ""); -static_assert( is_simd_mask_v>, ""); -static_assert( is_simd_mask_v>, ""); -static_assert( is_simd_mask_v>, "");
r338290 - Make test/Driver/baremetal.cpp work with linkers other than lld
Author: greened Date: Mon Jul 30 12:08:20 2018 New Revision: 338290 URL: http://llvm.org/viewvc/llvm-project?rev=338290=rev Log: Make test/Driver/baremetal.cpp work with linkers other than lld This test fails if clang is configure with, for example, gold as the default linker. It does not appear that this test really relies on lld so make the checks accept ld, ld.gold and ld.bfd too. Modified: cfe/trunk/test/Driver/baremetal.cpp Modified: cfe/trunk/test/Driver/baremetal.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/baremetal.cpp?rev=338290=338289=338290=diff == --- cfe/trunk/test/Driver/baremetal.cpp (original) +++ cfe/trunk/test/Driver/baremetal.cpp Mon Jul 30 12:08:20 2018 @@ -10,7 +10,7 @@ // CHECK-V6M-C-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1" // CHECk-V6M-C-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}include" // CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal.cpp" -// CHECK-V6M-C-NEXT: "{{[^"]*}}ld.lld{{(\.exe)?}}" "{{.*}}.o" "-Bstatic" +// CHECK-V6M-C-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic" // CHECK-V6M-C-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal" // CHECK-V6M-C-SAME: "-T" "semihosted.lds" "-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for" // CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a" @@ -32,7 +32,7 @@ // RUN: -target armv6m-none-eabi \ // RUN: --sysroot=%S/Inputs/baremetal_arm \ // RUN: | FileCheck --check-prefix=CHECK-V6M-DEFAULTCXX %s -// CHECK-V6M-DEFAULTCXX: "{{[^"]*}}ld.lld{{(\.exe)?}}" "{{.*}}.o" "-Bstatic" +// CHECK-V6M-DEFAULTCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic" // CHECK-V6M-DEFAULTCXX-SAME: "-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal" // CHECK-V6M-DEFAULTCXX-SAME: "-lc++" "-lc++abi" "-lunwind" // CHECK-V6M-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a" @@ -45,7 +45,7 @@ // RUN: | FileCheck --check-prefix=CHECK-V6M-LIBCXX %s // CHECK-V6M-LIBCXX-NOT: "-internal-isystem" "{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}{{[^v].*}}" // CHECK-V6M-LIBCXX: "-internal-isystem" "{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1" -// CHECK-V6M-LIBCXX: "{{[^"]*}}ld.lld{{(\.exe)?}}" "{{.*}}.o" "-Bstatic" +// CHECK-V6M-LIBCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic" // CHECK-V6M-LIBCXX-SAME: "-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal" // CHECK-V6M-LIBCXX-SAME: "-lc++" "-lc++abi" "-lunwind" // CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a" @@ -58,7 +58,7 @@ // RUN: | FileCheck --check-prefix=CHECK-V6M-LIBSTDCXX %s // CHECK-V6M-LIBSTDCXX-NOT: "-internal-isystem" "{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1" // CHECK-V6M-LIBSTDCXX: "-internal-isystem" "{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}6.0.0" -// CHECK-V6M-LIBSTDCXX: "{{[^"]*}}ld.lld{{(\.exe)?}}" "{{.*}}.o" "-Bstatic" +// CHECK-V6M-LIBSTDCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic" // CHECK-V6M-LIBSTDCXX-SAME: "-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal" // CHECK-V6M-LIBSTDCXX-SAME: "-lstdc++" "-lsupc++" "-lunwind" // CHECK-V6M-LIBSTDCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a" @@ -69,7 +69,7 @@ // RUN: --sysroot=%S/Inputs/baremetal_arm \ // RUN: -nodefaultlibs \ // RUN: | FileCheck --check-prefix=CHECK-V6M-NDL %s -// CHECK-V6M-NDL: "{{[^"]*}}ld.lld{{(\.exe)?}}" "{{.*}}.o" "-Bstatic" +// CHECK-V6M-NDL: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic" // CHECK-V6M-NDL-SAME: "-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal" "-o" "{{.*}}.o" // RUN: %clangxx -target arm-none-eabi -v 2>&1 \ ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49865: Inform the AST of #pragma FENV_ACCESS use
kpn marked 3 inline comments as done. kpn added inline comments. Comment at: include/clang/Basic/LangOptions.h:273-280 FPOptions() : fp_contract(LangOptions::FPC_Off) {} // Used for serializing. explicit FPOptions(unsigned I) : fp_contract(static_cast(I)) {} explicit FPOptions(const LangOptions ) rsmith wrote: > These constructors need to be updated. I think this is what you intend? https://reviews.llvm.org/D49865 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49865: Inform the AST of #pragma FENV_ACCESS use
kpn updated this revision to Diff 158036. kpn added a comment. Updated based on review. https://reviews.llvm.org/D49865 Files: include/clang/AST/Expr.h include/clang/Basic/LangOptions.h include/clang/Basic/TokenKinds.def include/clang/Parse/Parser.h include/clang/Sema/Sema.h lib/Parse/ParsePragma.cpp lib/Parse/ParseStmt.cpp lib/Parse/Parser.cpp lib/Sema/SemaAttr.cpp Index: lib/Sema/SemaAttr.cpp === --- lib/Sema/SemaAttr.cpp +++ lib/Sema/SemaAttr.cpp @@ -773,6 +773,18 @@ } } +void Sema::ActOnPragmaFEnvAccess(LangOptions::FEnvAccessModeKind FPC) { + switch (FPC) { + case LangOptions::FEA_On: +FPFeatures.setAllowFEnvAccess(); +break; + case LangOptions::FEA_Off: +FPFeatures.setDisallowFEnvAccess(); +break; + } +} + + void Sema::PushNamespaceVisibilityAttr(const VisibilityAttr *Attr, SourceLocation Loc) { // Visibility calculations will consider the namespace's visibility. Index: lib/Parse/Parser.cpp === --- lib/Parse/Parser.cpp +++ lib/Parse/Parser.cpp @@ -674,6 +674,9 @@ case tok::annot_pragma_fp_contract: HandlePragmaFPContract(); return nullptr; + case tok::annot_pragma_fenv_access: +HandlePragmaFEnvAccess(); +return nullptr; case tok::annot_pragma_fp: HandlePragmaFP(); break; Index: lib/Parse/ParseStmt.cpp === --- lib/Parse/ParseStmt.cpp +++ lib/Parse/ParseStmt.cpp @@ -348,6 +348,11 @@ ConsumeAnnotationToken(); return StmtError(); + case tok::annot_pragma_fenv_access: +ProhibitAttributes(Attrs); +HandlePragmaFEnvAccess(); +return StmtEmpty(); + case tok::annot_pragma_opencl_extension: ProhibitAttributes(Attrs); HandlePragmaOpenCLExtension(); @@ -914,6 +919,9 @@ case tok::annot_pragma_fp: HandlePragmaFP(); break; +case tok::annot_pragma_fenv_access: + HandlePragmaFEnvAccess(); + break; case tok::annot_pragma_ms_pointers_to_members: HandlePragmaMSPointersToMembers(); break; Index: lib/Parse/ParsePragma.cpp === --- lib/Parse/ParsePragma.cpp +++ lib/Parse/ParsePragma.cpp @@ -106,8 +106,19 @@ tok::OnOffSwitch OOS; if (PP.LexOnOffSwitch(OOS)) return; -if (OOS == tok::OOS_ON) +if (OOS == tok::OOS_ON) { PP.Diag(Tok, diag::warn_stdc_fenv_access_not_supported); + + MutableArrayRef Toks(PP.getPreprocessorAllocator().Allocate(1), +1); + Toks[0].startToken(); + Toks[0].setKind(tok::annot_pragma_fenv_access); + Toks[0].setLocation(Tok.getLocation()); + Toks[0].setAnnotationEndLoc(Tok.getLocation()); + Toks[0].setAnnotationValue(reinterpret_cast( + static_cast(OOS))); + PP.EnterTokenStream(Toks, /*DisableMacroExpansion=*/true); +} } }; @@ -591,6 +602,34 @@ ConsumeAnnotationToken(); } +void Parser::HandlePragmaFEnvAccess() { + assert(Tok.is(tok::annot_pragma_fenv_access)); + tok::OnOffSwitch OOS = +static_cast( +reinterpret_cast(Tok.getAnnotationValue())); + + LangOptions::FEnvAccessModeKind FPC; + switch (OOS) { + case tok::OOS_ON: +FPC = LangOptions::FEA_On; +break; + case tok::OOS_OFF: +FPC = LangOptions::FEA_Off; +break; + case tok::OOS_DEFAULT: +#if NOTYET // FIXME: Add this cli option when it makes sense. +FPC = getLangOpts().getDefaultFEnvAccessMode(); +#else +FPC = LangOptions::FEA_Off; +#endif +break; + } + + Actions.ActOnPragmaFEnvAccess(FPC); + ConsumeAnnotationToken(); +} + + StmtResult Parser::HandlePragmaCaptured() { assert(Tok.is(tok::annot_pragma_captured)); Index: include/clang/Sema/Sema.h === --- include/clang/Sema/Sema.h +++ include/clang/Sema/Sema.h @@ -8433,6 +8433,10 @@ /// \#pragma clang fp contract void ActOnPragmaFPContract(LangOptions::FPContractModeKind FPC); + /// ActOnPragmaFenvAccess - Called on well formed + /// \#pragma STDC FENV_ACCESS + void ActOnPragmaFEnvAccess(LangOptions::FEnvAccessModeKind FPC); + /// AddAlignmentAttributesForRecord - Adds any needed alignment attributes to /// a the record decl, to handle '\#pragma pack' and '\#pragma options align'. void AddAlignmentAttributesForRecord(RecordDecl *RD); Index: include/clang/Parse/Parser.h === --- include/clang/Parse/Parser.h +++ include/clang/Parse/Parser.h @@ -668,6 +668,10 @@ void HandlePragmaFPContract(); /// Handle the annotation token produced for + /// #pragma STDC FENV_ACCESS... + void HandlePragmaFEnvAccess(); + + /// \brief Handle the annotation token produced for /// #pragma clang fp ... void
[PATCH] D48958: [clang][ubsan] Implicit Cast Sanitizer - integer truncation - clang part
This revision was automatically updated to reflect the committed changes. Closed by commit rC338288: [clang][ubsan] Implicit Conversion Sanitizer - integer truncation - clang part (authored by lebedevri, committed by ). Repository: rC Clang https://reviews.llvm.org/D48958 Files: docs/ReleaseNotes.rst docs/UndefinedBehaviorSanitizer.rst include/clang/Basic/Sanitizers.def include/clang/Basic/Sanitizers.h lib/CodeGen/CGExprScalar.cpp lib/CodeGen/CodeGenFunction.h lib/Driver/SanitizerArgs.cpp lib/Driver/ToolChain.cpp test/CodeGen/catch-implicit-integer-truncations.c test/CodeGenCXX/catch-implicit-integer-truncations.cpp test/Driver/fsanitize.c Index: include/clang/Basic/Sanitizers.h === --- include/clang/Basic/Sanitizers.h +++ include/clang/Basic/Sanitizers.h @@ -84,7 +84,8 @@ /// Return the sanitizers which do not affect preprocessing. inline SanitizerMask getPPTransparentSanitizers() { return SanitizerKind::CFI | SanitizerKind::Integer | - SanitizerKind::Nullability | SanitizerKind::Undefined; + SanitizerKind::ImplicitConversion | SanitizerKind::Nullability | + SanitizerKind::Undefined; } } // namespace clang Index: include/clang/Basic/Sanitizers.def === --- include/clang/Basic/Sanitizers.def +++ include/clang/Basic/Sanitizers.def @@ -131,9 +131,14 @@ // -fsanitize=undefined-trap is an alias for -fsanitize=undefined. SANITIZER_GROUP("undefined-trap", UndefinedTrap, Undefined) +// ImplicitConversionSanitizer +SANITIZER("implicit-integer-truncation", ImplicitIntegerTruncation) +SANITIZER_GROUP("implicit-conversion", ImplicitConversion, +ImplicitIntegerTruncation) + SANITIZER_GROUP("integer", Integer, -SignedIntegerOverflow | UnsignedIntegerOverflow | Shift | -IntegerDivideByZero) +ImplicitIntegerTruncation | IntegerDivideByZero | Shift | +SignedIntegerOverflow | UnsignedIntegerOverflow) SANITIZER("local-bounds", LocalBounds) SANITIZER_GROUP("bounds", Bounds, ArrayBounds | LocalBounds) Index: test/Driver/fsanitize.c === --- test/Driver/fsanitize.c +++ test/Driver/fsanitize.c @@ -29,7 +29,22 @@ // CHECK-COVERAGE-WIN64: "--dependent-lib={{[^"]*}}ubsan_standalone-x86_64.lib" // RUN: %clang -target x86_64-linux-gnu -fsanitize=integer %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-INTEGER -implicit-check-not="-fsanitize-address-use-after-scope" -// CHECK-INTEGER: "-fsanitize={{((signed-integer-overflow|unsigned-integer-overflow|integer-divide-by-zero|shift-base|shift-exponent),?){5}"}} +// CHECK-INTEGER: "-fsanitize={{((signed-integer-overflow|unsigned-integer-overflow|integer-divide-by-zero|shift-base|shift-exponent|implicit-integer-truncation),?){6}"}} + +// RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-conversion %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-implicit-conversion,CHECK-implicit-conversion-RECOVER +// RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-conversion -fsanitize-recover=implicit-conversion %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-implicit-conversion,CHECK-implicit-conversion-RECOVER +// RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-conversion -fno-sanitize-recover=implicit-conversion %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-implicit-conversion,CHECK-implicit-conversion-NORECOVER +// RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-conversion -fsanitize-trap=implicit-conversion %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-implicit-conversion,CHECK-implicit-conversion-TRAP +// CHECK-implicit-conversion: "-fsanitize={{((implicit-integer-truncation),?){1}"}} +// CHECK-implicit-conversion-RECOVER: "-fsanitize-recover={{((implicit-integer-truncation),?){1}"}} +// CHECK-implicit-conversion-RECOVER-NOT: "-fno-sanitize-recover={{((implicit-integer-truncation),?){1}"}} +// CHECK-implicit-conversion-RECOVER-NOT: "-fsanitize-trap={{((implicit-integer-truncation),?){1}"}} +// CHECK-implicit-conversion-NORECOVER-NOT: "-fno-sanitize-recover={{((implicit-integer-truncation),?){1}"}} // ??? +// CHECK-implicit-conversion-NORECOVER-NOT: "-fsanitize-recover={{((implicit-integer-truncation),?){1}"}} +// CHECK-implicit-conversion-NORECOVER-NOT: "-fsanitize-trap={{((implicit-integer-truncation),?){1}"}} +// CHECK-implicit-conversion-TRAP: "-fsanitize-trap={{((implicit-integer-truncation),?){1}"}} +// CHECK-implicit-conversion-TRAP-NOT: "-fsanitize-recover={{((implicit-integer-truncation),?){1}"}} +// CHECK-implicit-conversion-TRAP-NOT: "-fno-sanitize-recover={{((implicit-integer-truncation),?){1}"}} // RUN: %clang -fsanitize=bounds -### -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix=CHECK-BOUNDS // CHECK-BOUNDS: "-fsanitize={{((array-bounds|local-bounds),?){2}"}} Index:
[PATCH] D48958: [clang][ubsan] Implicit Cast Sanitizer - integer truncation - clang part
lebedev.ri added inline comments. Comment at: docs/UndefinedBehaviorSanitizer.rst:136-137 + overflow happens (signed or unsigned). + Both of these two issues are handled by ``-fsanitize=implicit-conversion`` + group of checks. - ``-fsanitize=unreachable``: If control flow reaches an unreachable rsmith wrote: > I don't think that's true (not until you add a sanitizer for signed <-> > unsigned conversions that change the value). `4U / -2` produces the > unexpected result `0U` rather than the mathematically-correct result `-2`, > and `-fsanitize=implicit-conversion` doesn't catch it. Maybe just strike this > sentence for now? > > In fact... I think this is too much text to be adding to this bulleted list, > which is just supposed to summarize the available checks. Maybe replace the > description with > > Signed integer overflow, where the result of a signed integer computation > cannot be represented in its type. This includes all the checks covered by > ``-ftrapv``, as well as checks for signed division overflow (``INT_MIN/-1``), > but not checks for lossy implicit conversions performed before the > computation (see ``-fsanitize=implicit-conversion``). I will assume you meant "lossy implicit conversions performed *after* the computation". Repository: rC Clang https://reviews.llvm.org/D48958 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r338288 - [clang][ubsan] Implicit Conversion Sanitizer - integer truncation - clang part
Author: lebedevri Date: Mon Jul 30 11:58:30 2018 New Revision: 338288 URL: http://llvm.org/viewvc/llvm-project?rev=338288=rev Log: [clang][ubsan] Implicit Conversion Sanitizer - integer truncation - clang part Summary: C and C++ are interesting languages. They are statically typed, but weakly. The implicit conversions are allowed. This is nice, allows to write code while balancing between getting drowned in everything being convertible, and nothing being convertible. As usual, this comes with a price: ``` unsigned char store = 0; bool consume(unsigned int val); void test(unsigned long val) { if (consume(val)) { // the 'val' is `unsigned long`, but `consume()` takes `unsigned int`. // If their bit widths are different on this platform, the implicit // truncation happens. And if that `unsigned long` had a value bigger // than UINT_MAX, then you may or may not have a bug. // Similarly, integer addition happens on `int`s, so `store` will // be promoted to an `int`, the sum calculated (0+768=768), // and the result demoted to `unsigned char`, and stored to `store`. // In this case, the `store` will still be 0. Again, not always intended. store = store + 768; // before addition, 'store' was promoted to int. } // But yes, sometimes this is intentional. // You can either make the conversion explicit (void)consume((unsigned int)val); // or mask the value so no bits will be *implicitly* lost. (void)consume((~((unsigned int)0)) & val); } ``` Yes, there is a `-Wconversion`` diagnostic group, but first, it is kinda noisy, since it warns on everything (unlike sanitizers, warning on an actual issues), and second, there are cases where it does **not** warn. So a Sanitizer is needed. I don't have any motivational numbers, but i know i had this kind of problem 10-20 times, and it was never easy to track down. The logic to detect whether an truncation has happened is pretty simple if you think about it - https://godbolt.org/g/NEzXbb - basically, just extend (using the new, not original!, signedness) the 'truncated' value back to it's original width, and equality-compare it with the original value. The most non-trivial thing here is the logic to detect whether this `ImplicitCastExpr` AST node is **actually** an implicit conversion, //or// part of an explicit cast. Because the explicit casts are modeled as an outer `ExplicitCastExpr` with some `ImplicitCastExpr`'s as **direct** children. https://godbolt.org/g/eE1GkJ Nowadays, we can just use the new `part_of_explicit_cast` flag, which is set on all the implicitly-added `ImplicitCastExpr`'s of an `ExplicitCastExpr`. So if that flag is **not** set, then it is an actual implicit conversion. As you may have noted, this isn't just named `-fsanitize=implicit-integer-truncation`. There are potentially some more implicit conversions to be warned about. Namely, implicit conversions that result in sign change; implicit conversion between different floating point types, or between fp and an integer, when again, that conversion is lossy. One thing i know isn't handled is bitfields. This is a clang part. The compiler-rt part is D48959. Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=21530 | PR21530 ]], [[ https://bugs.llvm.org/show_bug.cgi?id=37552 | PR37552 ]], [[ https://bugs.llvm.org/show_bug.cgi?id=35409 | PR35409 ]]. Partially fixes [[ https://bugs.llvm.org/show_bug.cgi?id=9821 | PR9821 ]]. Fixes https://github.com/google/sanitizers/issues/940. (other than sign-changing implicit conversions) Reviewers: rjmccall, rsmith, samsonov, pcc, vsk, eugenis, efriedma, kcc, erichkeane Reviewed By: rsmith, vsk, erichkeane Subscribers: erichkeane, klimek, #sanitizers, aaron.ballman, RKSimon, dtzWill, filcab, danielaustin, ygribov, dvyukov, milianw, mclow.lists, cfe-commits, regehr Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D48958 Added: cfe/trunk/test/CodeGen/catch-implicit-integer-truncations.c cfe/trunk/test/CodeGenCXX/catch-implicit-integer-truncations.cpp Modified: cfe/trunk/docs/ReleaseNotes.rst cfe/trunk/docs/UndefinedBehaviorSanitizer.rst cfe/trunk/include/clang/Basic/Sanitizers.def cfe/trunk/include/clang/Basic/Sanitizers.h cfe/trunk/lib/CodeGen/CGExprScalar.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/lib/Driver/SanitizerArgs.cpp cfe/trunk/lib/Driver/ToolChain.cpp cfe/trunk/test/Driver/fsanitize.c Modified: cfe/trunk/docs/ReleaseNotes.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=338288=338287=338288=diff == --- cfe/trunk/docs/ReleaseNotes.rst (original) +++ cfe/trunk/docs/ReleaseNotes.rst Mon Jul 30 11:58:30 2018 @@ -46,7 +46,9 @@ sections with improvements to Clang's su Major New Features -- -- ... +- A new Implicit Conversion Sanitizer (``-fsanitize=implicit-conversion``) group + was added. Please
r338286 - [analyzer] Store ValueDecl in DeclRegion
Author: george.karpenkov Date: Mon Jul 30 11:57:13 2018 New Revision: 338286 URL: http://llvm.org/viewvc/llvm-project?rev=338286=rev Log: [analyzer] Store ValueDecl in DeclRegion All use cases of DeclRegion actually have ValueDecl there, and getting the name from declaration comes in very handy. Differential Revision: https://reviews.llvm.org/D49998 Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h?rev=338286=338285=338286=diff == --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h (original) +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h Mon Jul 30 11:57:13 2018 @@ -897,9 +897,9 @@ public: class DeclRegion : public TypedValueRegion { protected: - const Decl *D; + const ValueDecl *D; - DeclRegion(const Decl *d, const MemRegion *sReg, Kind k) + DeclRegion(const ValueDecl *d, const MemRegion *sReg, Kind k) : TypedValueRegion(sReg, k), D(d) { assert(classof(this)); assert(d); @@ -909,7 +909,7 @@ protected: const MemRegion* superRegion, Kind k); public: - const Decl *getDecl() const { return D; } + const ValueDecl *getDecl() const { return D; } void Profile(llvm::FoldingSetNodeID& ID) const override; static bool classof(const MemRegion* R) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49998: [analyzer] Store ValueDecl in DeclRegion
This revision was automatically updated to reflect the committed changes. Closed by commit rC338286: [analyzer] Store ValueDecl in DeclRegion (authored by george.karpenkov, committed by ). Herald added a subscriber: cfe-commits. Changed prior to commit: https://reviews.llvm.org/D49998?vs=158027=158032#toc Repository: rC Clang https://reviews.llvm.org/D49998 Files: include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h Index: include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h === --- include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h +++ include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h @@ -897,9 +897,9 @@ class DeclRegion : public TypedValueRegion { protected: - const Decl *D; + const ValueDecl *D; - DeclRegion(const Decl *d, const MemRegion *sReg, Kind k) + DeclRegion(const ValueDecl *d, const MemRegion *sReg, Kind k) : TypedValueRegion(sReg, k), D(d) { assert(classof(this)); assert(d); @@ -909,7 +909,7 @@ const MemRegion* superRegion, Kind k); public: - const Decl *getDecl() const { return D; } + const ValueDecl *getDecl() const { return D; } void Profile(llvm::FoldingSetNodeID& ID) const override; static bool classof(const MemRegion* R) { Index: include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h === --- include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h +++ include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h @@ -897,9 +897,9 @@ class DeclRegion : public TypedValueRegion { protected: - const Decl *D; + const ValueDecl *D; - DeclRegion(const Decl *d, const MemRegion *sReg, Kind k) + DeclRegion(const ValueDecl *d, const MemRegion *sReg, Kind k) : TypedValueRegion(sReg, k), D(d) { assert(classof(this)); assert(d); @@ -909,7 +909,7 @@ const MemRegion* superRegion, Kind k); public: - const Decl *getDecl() const { return D; } + const ValueDecl *getDecl() const { return D; } void Profile(llvm::FoldingSetNodeID& ID) const override; static bool classof(const MemRegion* R) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48958: [clang][ubsan] Implicit Cast Sanitizer - integer truncation - clang part
lebedev.ri updated this revision to Diff 158030. lebedev.ri marked 9 inline comments as done. lebedev.ri edited the summary of this revision. lebedev.ri added a comment. Address last portion of @rsmith review notes. @rsmith, @vsk, @erichkeane - thank you for the review! Repository: rC Clang https://reviews.llvm.org/D48958 Files: docs/ReleaseNotes.rst docs/UndefinedBehaviorSanitizer.rst include/clang/Basic/Sanitizers.def include/clang/Basic/Sanitizers.h lib/CodeGen/CGExprScalar.cpp lib/CodeGen/CodeGenFunction.h lib/Driver/SanitizerArgs.cpp lib/Driver/ToolChain.cpp test/CodeGen/catch-implicit-integer-truncations.c test/CodeGenCXX/catch-implicit-integer-truncations.cpp test/Driver/fsanitize.c Index: test/Driver/fsanitize.c === --- test/Driver/fsanitize.c +++ test/Driver/fsanitize.c @@ -29,7 +29,22 @@ // CHECK-COVERAGE-WIN64: "--dependent-lib={{[^"]*}}ubsan_standalone-x86_64.lib" // RUN: %clang -target x86_64-linux-gnu -fsanitize=integer %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-INTEGER -implicit-check-not="-fsanitize-address-use-after-scope" -// CHECK-INTEGER: "-fsanitize={{((signed-integer-overflow|unsigned-integer-overflow|integer-divide-by-zero|shift-base|shift-exponent),?){5}"}} +// CHECK-INTEGER: "-fsanitize={{((signed-integer-overflow|unsigned-integer-overflow|integer-divide-by-zero|shift-base|shift-exponent|implicit-integer-truncation),?){6}"}} + +// RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-conversion %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-implicit-conversion,CHECK-implicit-conversion-RECOVER +// RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-conversion -fsanitize-recover=implicit-conversion %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-implicit-conversion,CHECK-implicit-conversion-RECOVER +// RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-conversion -fno-sanitize-recover=implicit-conversion %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-implicit-conversion,CHECK-implicit-conversion-NORECOVER +// RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-conversion -fsanitize-trap=implicit-conversion %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK-implicit-conversion,CHECK-implicit-conversion-TRAP +// CHECK-implicit-conversion: "-fsanitize={{((implicit-integer-truncation),?){1}"}} +// CHECK-implicit-conversion-RECOVER: "-fsanitize-recover={{((implicit-integer-truncation),?){1}"}} +// CHECK-implicit-conversion-RECOVER-NOT: "-fno-sanitize-recover={{((implicit-integer-truncation),?){1}"}} +// CHECK-implicit-conversion-RECOVER-NOT: "-fsanitize-trap={{((implicit-integer-truncation),?){1}"}} +// CHECK-implicit-conversion-NORECOVER-NOT: "-fno-sanitize-recover={{((implicit-integer-truncation),?){1}"}} // ??? +// CHECK-implicit-conversion-NORECOVER-NOT: "-fsanitize-recover={{((implicit-integer-truncation),?){1}"}} +// CHECK-implicit-conversion-NORECOVER-NOT: "-fsanitize-trap={{((implicit-integer-truncation),?){1}"}} +// CHECK-implicit-conversion-TRAP: "-fsanitize-trap={{((implicit-integer-truncation),?){1}"}} +// CHECK-implicit-conversion-TRAP-NOT: "-fsanitize-recover={{((implicit-integer-truncation),?){1}"}} +// CHECK-implicit-conversion-TRAP-NOT: "-fno-sanitize-recover={{((implicit-integer-truncation),?){1}"}} // RUN: %clang -fsanitize=bounds -### -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix=CHECK-BOUNDS // CHECK-BOUNDS: "-fsanitize={{((array-bounds|local-bounds),?){2}"}} Index: test/CodeGenCXX/catch-implicit-integer-truncations.cpp === --- /dev/null +++ test/CodeGenCXX/catch-implicit-integer-truncations.cpp @@ -0,0 +1,256 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefix=CHECK +// RUN: %clang_cc1 -fsanitize=implicit-integer-truncation -fno-sanitize-recover=implicit-integer-truncation -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-NORECOVER +// RUN: %clang_cc1 -fsanitize=implicit-integer-truncation -fsanitize-recover=implicit-integer-truncation -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-RECOVER +// RUN: %clang_cc1 -fsanitize=implicit-integer-truncation -fsanitize-trap=implicit-integer-truncation -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-TRAP + +extern "C" { // Disable name mangling. + +// == // +// Check that explicit cast does not interfere with implicit conversion +// == // +// These contain one implicit truncating conversion, and one explicit truncating cast. +// We want to make sure that we still diagnose the implicit conversion. +
[PATCH] D49722: [CStringSyntaxChecker] Check strlcat sizeof check
george.karpenkov requested changes to this revision. george.karpenkov added inline comments. This revision now requires changes to proceed. Comment at: lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp:154 -bool WalkAST::containsBadStrlcpyPattern(const CallExpr *CE) { +bool WalkAST::containsBadStrlcpyStrlcatPattern(const CallExpr *CE, bool Append) { if (CE->getNumArgs() != 3) `Append` can be deduced from a call expression; I think it would be better to drop it from the parameter list and calculate again in the function body. Comment at: lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp:164 + // - sizeof(dst) + if (Append && isSizeof(LenArg, DstArg)) +return true; I am confused on what is happening in this branch and why is it bad. Could we add a commend? Comment at: lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp:196 uint64_t BufferLen = C.getTypeSize(Buffer) / 8; -if ((BufferLen - DstOff) < ILRawVal) - return true; +BufferLen -= DstOff; +if (Append) { Better to introduce a new variable, e.g. `RemainingBufferLen` https://reviews.llvm.org/D49722 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49999: [Hexagon] Remove fp-contract=fast setting for at O3
bcahoon created this revision. bcahoon added a reviewer: kparzysz. Herald added a subscriber: cfe-commits. Change Hexagon so that the setting for fp-contract is the default setting. This makes Hexagon consistent with all the other targets. Repository: rC Clang https://reviews.llvm.org/D4 Files: clang/lib/Driver/ToolChains/Hexagon.cpp clang/test/Driver/hexagon-toolchain-elf.c Index: clang/test/Driver/hexagon-toolchain-elf.c === --- clang/test/Driver/hexagon-toolchain-elf.c +++ clang/test/Driver/hexagon-toolchain-elf.c @@ -110,7 +110,7 @@ // RUN: -O3 \ // RUN: %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK026 %s -// CHECK026: "-ffp-contract=fast" +// CHECK026-NOT: "-ffp-contract=fast" // CHECK026: hexagon-link // RUN: %clang -### -target hexagon-unknown-elf \ Index: clang/lib/Driver/ToolChains/Hexagon.cpp === --- clang/lib/Driver/ToolChains/Hexagon.cpp +++ clang/lib/Driver/ToolChains/Hexagon.cpp @@ -513,11 +513,6 @@ void HexagonToolChain::addClangTargetOptions(const ArgList , ArgStringList , Action::OffloadKind) const { - if (!DriverArgs.hasArg(options::OPT_ffp_contract)) { -unsigned OptLevel = getOptimizationLevel(DriverArgs); -if (OptLevel >= 3) - CC1Args.push_back("-ffp-contract=fast"); - } if (DriverArgs.hasArg(options::OPT_ffixed_r19)) { CC1Args.push_back("-target-feature"); CC1Args.push_back("+reserved-r19"); Index: clang/test/Driver/hexagon-toolchain-elf.c === --- clang/test/Driver/hexagon-toolchain-elf.c +++ clang/test/Driver/hexagon-toolchain-elf.c @@ -110,7 +110,7 @@ // RUN: -O3 \ // RUN: %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK026 %s -// CHECK026: "-ffp-contract=fast" +// CHECK026-NOT: "-ffp-contract=fast" // CHECK026: hexagon-link // RUN: %clang -### -target hexagon-unknown-elf \ Index: clang/lib/Driver/ToolChains/Hexagon.cpp === --- clang/lib/Driver/ToolChains/Hexagon.cpp +++ clang/lib/Driver/ToolChains/Hexagon.cpp @@ -513,11 +513,6 @@ void HexagonToolChain::addClangTargetOptions(const ArgList , ArgStringList , Action::OffloadKind) const { - if (!DriverArgs.hasArg(options::OPT_ffp_contract)) { -unsigned OptLevel = getOptimizationLevel(DriverArgs); -if (OptLevel >= 3) - CC1Args.push_back("-ffp-contract=fast"); - } if (DriverArgs.hasArg(options::OPT_ffixed_r19)) { CC1Args.push_back("-target-feature"); CC1Args.push_back("+reserved-r19"); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49361: [analyzer] Detect pointers escaped after return statement execution in MallocChecker
NoQ added inline comments. Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:2488 + + checkPreStmt(S, C); +} Let's do a common sub-function, similarly to how `MallocChecker::checkPointerEscape` and `MallocChecker::checkConstPointerEscape` both call `MallocChecker::checkPointerEscapeAux`. Should prevent us from unleashing `addTransition` hell if the code becomes more complicated. https://reviews.llvm.org/D49361 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49997: [libcxx] Fix _LIBCPP_NO_EXCEPTIONS redefined warning
jasonl220 created this revision. jasonl220 added a reviewer: mclow.lists. Herald added a reviewer: EricWF. Herald added subscribers: cfe-commits, ldionne. Fix GCC 7.2.0 redefinition warning when LIBCXX_ENABLE_EXCEPTIONS cmake option is not set. > llvm/projects/libcxx/include/__config:514:0: warning: "_LIBCPP_NO_EXCEPTIONS" > redefined > #define _LIBCPP_NO_EXCEPTIONS > > :0:0: note: this is the location of the previous definition This warning fires every time __config is included, 33 in total. Repository: rCXX libc++ https://reviews.llvm.org/D49997 Files: __config Index: __config === --- __config +++ __config @@ -510,7 +510,7 @@ #define _LIBCPP_HAS_IS_BASE_OF #endif -#if !__EXCEPTIONS +#if !__EXCEPTIONS && !defined(_LIBCPP_NO_EXCEPTIONS) #define _LIBCPP_NO_EXCEPTIONS #endif Index: __config === --- __config +++ __config @@ -510,7 +510,7 @@ #define _LIBCPP_HAS_IS_BASE_OF #endif -#if !__EXCEPTIONS +#if !__EXCEPTIONS && !defined(_LIBCPP_NO_EXCEPTIONS) #define _LIBCPP_NO_EXCEPTIONS #endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits