[PATCH] D53085: [clang-doc] Add unit tests for Markdown
phosek added inline comments. Comment at: clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp:44 + assert(!Err); + std::string Expected = "# namespace Namespace\n" + "\n" Can we use the C++11 raw string literals here and below to to avoid all the escaping? https://reviews.llvm.org/D53085 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52835: [Diagnostics] Check integer to floating point number implicit conversions
xbolva00 added inline comments. Comment at: lib/Sema/SemaChecking.cpp:10874 + if (Target->isSpecificBuiltinType(BuiltinType::LongDouble)) +FloatSem = &llvm::APFloat::x87DoubleExtended(); + efriedma wrote: > ASTContext::getFloatTypeSemantics. (Your explicit computation here is both > redundant and wrong.) Great tip! thanks. I overlooked it :/ https://reviews.llvm.org/D52835 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52835: [Diagnostics] Check integer to floating point number implicit conversions
xbolva00 updated this revision to Diff 169162. xbolva00 added a comment. - Addressed comments https://reviews.llvm.org/D52835 Files: lib/Sema/SemaChecking.cpp test/Sema/ext_vector_casts.c test/Sema/impcast-integer-float.c Index: test/Sema/impcast-integer-float.c === --- test/Sema/impcast-integer-float.c +++ test/Sema/impcast-integer-float.c @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 %s -verify -Wconversion -fsyntax-only + +#define shift_plus_one(x) ((1ULL << x) + 1) + +void test(void) { +float a1 = (1ULL << 31) + 1; // expected-warning {{implicit conversion from 'unsigned long long' to 'float' changes value from 2147483649 to 2.1474836E+9}} +float a2 = 1ULL << 31; +float a3 = shift_plus_one(31); // expected-warning {{implicit conversion from 'unsigned long long' to 'float' changes value from 2147483649 to 2.1474836E+9}} +float a4 = (1ULL << 31) - 1; // expected-warning {{implicit conversion from 'unsigned long long' to 'float' changes value from 2147483647 to 2.1474836E+9}} + +double b1 = (1ULL << 63) + 1; // expected-warning {{implicit conversion from 'unsigned long long' to 'double' changes value from 9223372036854775809 to 9.223372036854775E+18}} +double b2 = 1ULL << 63; +double b3 = shift_plus_one(63); // expected-warning {{implicit conversion from 'unsigned long long' to 'double' changes value from 9223372036854775809 to 9.223372036854775E+18}} +double b4 = (1ULL << 63) - 1; // expected-warning {{implicit conversion from 'unsigned long long' to 'double' changes value from 9223372036854775807 to 9.223372036854775E+18}} + +long double c1 = ((__int128)1 << 127) + 1; // expected-warning {{implicit conversion from '__int128' to 'long double' changes value from -170141183460469231731687303715884105727 to -1.7014118346046923173E+38}} +long double c2 = (__int128)1 << 127; + +_Float16 d1 = (1ULL << 15) + 1; // expected-warning {{implicit conversion from 'unsigned long long' to '_Float16' changes value from 32769 to 3.277E+4}} +_Float16 d2 = 1ULL << 15; +_Float16 d3 = shift_plus_one(15); // expected-warning {{implicit conversion from 'unsigned long long' to '_Float16' changes value from 32769 to 3.277E+4}} +_Float16 d4 = (1ULL << 15) - 1; // expected-warning {{implicit conversion from 'unsigned long long' to '_Float16' changes value from 32767 to 3.277E+4}} + +float e = (__uint128_t)-1; // expected-warning {{implicit conversion from '__uint128_t' (aka 'unsigned __int128') to 'float' changes value from 340282366920938463463374607431768211455 to +Inf}} +} Index: test/Sema/ext_vector_casts.c === --- test/Sema/ext_vector_casts.c +++ test/Sema/ext_vector_casts.c @@ -118,7 +118,7 @@ vf = l + vf; vf = 2.0 + vf; vf = d + vf; // expected-warning {{implicit conversion loses floating-point precision}} - vf = vf + 0x; + vf = vf + 0x; // expected-warning {{implicit conversion from 'unsigned int' to 'float2' (vector of 2 'float' values) changes value from 4294967295 to 4.2949673E+9}} vf = vf + 2.1; // expected-warning {{implicit conversion loses floating-point precision}} vd = l + vd; Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -105,6 +105,19 @@ Context.getTargetInfo()); } +// FIXME: Force the precision of the source value down so we don't print +// digits which are usually useless (we don't really care here if we +// truncate a digit by accident in edge cases). Ideally, APFloat::toString +// would automatically print the shortest representation, but it's a bit +// tricky to implement. +static void PrettyPrintFloat(const llvm::APFloat &floatValue, + const llvm::fltSemantics &floatSem, + SmallVectorImpl &prettyFloatValue) { + unsigned precision = llvm::APFloat::semanticsPrecision(floatSem); + precision = llvm::divideCeil(precision * 59, 196); + floatValue.toString(prettyFloatValue, precision); +} + /// Checks that a call expression's argument count is the desired number. /// This is useful when doing custom type-checking. Returns true on error. static bool checkArgCount(Sema &S, CallExpr *call, unsigned desiredArgCount) { @@ -10414,15 +10427,8 @@ DiagID = diag::warn_impcast_float_to_integer; } - // FIXME: Force the precision of the source value down so we don't print - // digits which are usually useless (we don't really care here if we - // truncate a digit by accident in edge cases). Ideally, APFloat::toString - // would automatically print the shortest representation, but it's a bit - // tricky to implement. SmallString<16> PrettySourceValue; - unsigned precision = llvm::APFloat::semanticsPrecision(Value.getSemantics()); - precision = (precision * 59 + 195)
[PATCH] D53052: [AST] Use -fvisibility value when ignoring -fv-i-h* inline static locals
hans added a comment. In https://reviews.llvm.org/D53052#1261158, @rnk wrote: > This is rewritten enough that you might want to re-review it, but I'm going > to push it today so we don't have to wait another day/night cycle for the fix. Looks good to me. It's hard to follow the logic, but the testing seems pretty comprehensive now. It's a lot like the dll attributes in that way :-) Repository: rC Clang https://reviews.llvm.org/D53052 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r344225 - Fix the qualification of `IntrusiveRefCntPtr` to use `llvm::`.
Author: chandlerc Date: Thu Oct 11 01:05:10 2018 New Revision: 344225 URL: http://llvm.org/viewvc/llvm-project?rev=344225&view=rev Log: Fix the qualification of `IntrusiveRefCntPtr` to use `llvm::`. Without this, the code only compiled if the header was included after something introduced the alias from `clang::` to `llvm::` for this type. Any modules build would fail here. Modified: clang-tools-extra/trunk/clangd/FSProvider.h Modified: clang-tools-extra/trunk/clangd/FSProvider.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FSProvider.h?rev=344225&r1=344224&r2=344225&view=diff == --- clang-tools-extra/trunk/clangd/FSProvider.h (original) +++ clang-tools-extra/trunk/clangd/FSProvider.h Thu Oct 11 01:05:10 2018 @@ -25,13 +25,15 @@ public: /// Context::current() will be the context passed to the clang entrypoint, /// such as addDocument(), and will also be propagated to result callbacks. /// Embedders may use this to isolate filesystem accesses. - virtual IntrusiveRefCntPtr getFileSystem() const = 0; + virtual llvm::IntrusiveRefCntPtr + getFileSystem() const = 0; }; class RealFileSystemProvider : public FileSystemProvider { public: // FIXME: returns the single real FS instance, which is not threadsafe. - IntrusiveRefCntPtr getFileSystem() const override { + llvm::IntrusiveRefCntPtr + getFileSystem() const override { return llvm::vfs::getRealFileSystem(); } }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53125: Detect Clear Linux and apply Clear's default linker options
mgorny added inline comments. Comment at: lib/Driver/Distro.cpp:139 + File = VFS.getBufferForFile("/usr/lib/os-release"); + if (File) { Technically speaking, the spec says you are supposed to read `/etc/os-release` first and fall back to `/usr/lib/os-release` only if the former does not exist. https://reviews.llvm.org/D53125 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53121: [Driver] Add defaults for Android ARM FPUs.
kristof.beyls added a subscriber: peter.smith. kristof.beyls added a comment. In https://reviews.llvm.org/D53121#1261408, @srhines wrote: > This LGTM, but we should wait to hear from Kristof before submitting. Seems fine to me too. I'd maybe just add an additional test case to verify that things still work as expected when users explicitly specify that they want to target a different FPU (e.g. "-mfpu=none"). Repository: rC Clang https://reviews.llvm.org/D53121 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52891: [AMDGPU] Add -fvisibility-amdgpu-non-kernel-functions
arsenm added a comment. Offload to me sounds like it decided to extract out a section of the program for offload, which is not how OpenCL works https://reviews.llvm.org/D52891 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r344230 - [clang][ubsan] Split Implicit Integer Truncation Sanitizer into unsigned and signed checks
Author: lebedevri Date: Thu Oct 11 02:09:50 2018 New Revision: 344230 URL: http://llvm.org/viewvc/llvm-project?rev=344230&view=rev Log: [clang][ubsan] Split Implicit Integer Truncation Sanitizer into unsigned and signed checks Summary: As per IRC disscussion, it seems we really want to have more fine-grained `-fsanitize=implicit-integer-truncation`: * A check when both of the types are unsigned. * Another check for the other cases (either one of the types is signed, or both of the types is signed). This is clang part. Compiler-rt part is D50902. Reviewers: rsmith, vsk, Sanitizers Reviewed by: rsmith Differential Revision: https://reviews.llvm.org/D50901 Added: cfe/trunk/test/CodeGen/catch-implicit-signed-integer-truncations-basics-negatives.c cfe/trunk/test/CodeGen/catch-implicit-signed-integer-truncations-basics.c - copied, changed from r344205, cfe/trunk/test/CodeGen/catch-implicit-integer-truncations-basics.c cfe/trunk/test/CodeGen/catch-implicit-unsigned-integer-truncations-basics-negatives.c cfe/trunk/test/CodeGen/catch-implicit-unsigned-integer-truncations-basics.c - copied, changed from r344205, cfe/trunk/test/CodeGen/catch-implicit-integer-truncations-basics.c Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst cfe/trunk/include/clang/Basic/Sanitizers.def cfe/trunk/lib/CodeGen/CGExprScalar.cpp cfe/trunk/test/CodeGen/catch-implicit-integer-conversions-basics.c cfe/trunk/test/CodeGen/catch-implicit-integer-truncations-basics-negatives.c cfe/trunk/test/CodeGen/catch-implicit-integer-truncations-basics.c cfe/trunk/test/CodeGen/catch-implicit-integer-truncations.c cfe/trunk/test/CodeGenCXX/catch-implicit-integer-truncations.cpp cfe/trunk/test/Driver/fsanitize.c Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UndefinedBehaviorSanitizer.rst?rev=344230&r1=344229&r2=344230&view=diff == --- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original) +++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Thu Oct 11 02:09:50 2018 @@ -89,11 +89,16 @@ Available checks are: - ``-fsanitize=function``: Indirect call of a function through a function pointer of the wrong type (Darwin/Linux, C++ and x86/x86_64 only). - - ``-fsanitize=implicit-integer-truncation``: Implicit conversion from + - ``-fsanitize=implicit-unsigned-integer-truncation``, + ``-fsanitize=implicit-signed-integer-truncation``: Implicit conversion from integer of larger bit width to smaller bit width, if that results in data loss. That is, if the demoted value, after casting back to the original width, is not equal to the original value before the downcast. - Issues caught by this sanitizer are not undefined behavior, + The ``-fsanitize=implicit-unsigned-integer-truncation`` handles conversions + between two ``unsigned`` types, while + ``-fsanitize=implicit-signed-integer-truncation`` handles the rest of the + conversions - when either one, or both of the types are signed. + Issues caught by these sanitizers are not undefined behavior, but are often unintentional. - ``-fsanitize=integer-divide-by-zero``: Integer division by zero. - ``-fsanitize=nonnull-attribute``: Passing null pointer as a function @@ -160,6 +165,10 @@ You can also use the following check gro behavior (e.g. unsigned integer overflow). Enables ``signed-integer-overflow``, ``unsigned-integer-overflow``, ``shift``, ``integer-divide-by-zero``, and ``implicit-integer-truncation``. + - ``fsanitize=implicit-integer-truncation``: Checks for implicit integral + conversions that result in data loss. + Enables ``implicit-unsigned-integer-truncation`` and + ``implicit-signed-integer-truncation``. - ``-fsanitize=implicit-conversion``: Checks for suspicious behaviours of implicit conversions. Currently, only ``-fsanitize=implicit-integer-truncation`` is implemented. Modified: cfe/trunk/include/clang/Basic/Sanitizers.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Sanitizers.def?rev=344230&r1=344229&r2=344230&view=diff == --- cfe/trunk/include/clang/Basic/Sanitizers.def (original) +++ cfe/trunk/include/clang/Basic/Sanitizers.def Thu Oct 11 02:09:50 2018 @@ -135,7 +135,13 @@ SANITIZER_GROUP("undefined", Undefined, SANITIZER_GROUP("undefined-trap", UndefinedTrap, Undefined) // ImplicitConversionSanitizer -SANITIZER("implicit-integer-truncation", ImplicitIntegerTruncation) +SANITIZER("implicit-unsigned-integer-truncation", + ImplicitUnsignedIntegerTruncation) +SANITIZER("implicit-signed-integer-truncation", ImplicitSignedIntegerTruncation) +SANITIZER_GROUP("implicit-integer-truncation", ImplicitIntegerTruncation, +ImplicitUnsi
[PATCH] D50901: [clang][ubsan] Split Implicit Integer Truncation Sanitizer into unsigned and signed checks
This revision was automatically updated to reflect the committed changes. Closed by commit rL344230: [clang][ubsan] Split Implicit Integer Truncation Sanitizer into unsigned and… (authored by lebedevri, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D50901?vs=167621&id=169173#toc Repository: rL LLVM https://reviews.llvm.org/D50901 Files: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst cfe/trunk/include/clang/Basic/Sanitizers.def cfe/trunk/lib/CodeGen/CGExprScalar.cpp cfe/trunk/test/CodeGen/catch-implicit-integer-conversions-basics.c cfe/trunk/test/CodeGen/catch-implicit-integer-truncations-basics-negatives.c cfe/trunk/test/CodeGen/catch-implicit-integer-truncations-basics.c cfe/trunk/test/CodeGen/catch-implicit-integer-truncations.c cfe/trunk/test/CodeGen/catch-implicit-signed-integer-truncations-basics-negatives.c cfe/trunk/test/CodeGen/catch-implicit-signed-integer-truncations-basics.c cfe/trunk/test/CodeGen/catch-implicit-unsigned-integer-truncations-basics-negatives.c cfe/trunk/test/CodeGen/catch-implicit-unsigned-integer-truncations-basics.c cfe/trunk/test/CodeGenCXX/catch-implicit-integer-truncations.cpp cfe/trunk/test/Driver/fsanitize.c Index: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst === --- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst +++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst @@ -89,11 +89,16 @@ - ``-fsanitize=function``: Indirect call of a function through a function pointer of the wrong type (Darwin/Linux, C++ and x86/x86_64 only). - - ``-fsanitize=implicit-integer-truncation``: Implicit conversion from + - ``-fsanitize=implicit-unsigned-integer-truncation``, + ``-fsanitize=implicit-signed-integer-truncation``: Implicit conversion from integer of larger bit width to smaller bit width, if that results in data loss. That is, if the demoted value, after casting back to the original width, is not equal to the original value before the downcast. - Issues caught by this sanitizer are not undefined behavior, + The ``-fsanitize=implicit-unsigned-integer-truncation`` handles conversions + between two ``unsigned`` types, while + ``-fsanitize=implicit-signed-integer-truncation`` handles the rest of the + conversions - when either one, or both of the types are signed. + Issues caught by these sanitizers are not undefined behavior, but are often unintentional. - ``-fsanitize=integer-divide-by-zero``: Integer division by zero. - ``-fsanitize=nonnull-attribute``: Passing null pointer as a function @@ -160,6 +165,10 @@ behavior (e.g. unsigned integer overflow). Enables ``signed-integer-overflow``, ``unsigned-integer-overflow``, ``shift``, ``integer-divide-by-zero``, and ``implicit-integer-truncation``. + - ``fsanitize=implicit-integer-truncation``: Checks for implicit integral + conversions that result in data loss. + Enables ``implicit-unsigned-integer-truncation`` and + ``implicit-signed-integer-truncation``. - ``-fsanitize=implicit-conversion``: Checks for suspicious behaviours of implicit conversions. Currently, only ``-fsanitize=implicit-integer-truncation`` is implemented. Index: cfe/trunk/include/clang/Basic/Sanitizers.def === --- cfe/trunk/include/clang/Basic/Sanitizers.def +++ cfe/trunk/include/clang/Basic/Sanitizers.def @@ -135,7 +135,13 @@ SANITIZER_GROUP("undefined-trap", UndefinedTrap, Undefined) // ImplicitConversionSanitizer -SANITIZER("implicit-integer-truncation", ImplicitIntegerTruncation) +SANITIZER("implicit-unsigned-integer-truncation", + ImplicitUnsignedIntegerTruncation) +SANITIZER("implicit-signed-integer-truncation", ImplicitSignedIntegerTruncation) +SANITIZER_GROUP("implicit-integer-truncation", ImplicitIntegerTruncation, +ImplicitUnsignedIntegerTruncation | +ImplicitSignedIntegerTruncation) + SANITIZER_GROUP("implicit-conversion", ImplicitConversion, ImplicitIntegerTruncation) Index: cfe/trunk/test/CodeGenCXX/catch-implicit-integer-truncations.cpp === --- cfe/trunk/test/CodeGenCXX/catch-implicit-integer-truncations.cpp +++ cfe/trunk/test/CodeGenCXX/catch-implicit-integer-truncations.cpp @@ -1,7 +1,7 @@ // 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-
[PATCH] D53060: [clang-move] Remove clang:: qualifier
hokein accepted this revision. hokein added a comment. This revision is now accepted and ready to land. Thanks for the cleanup. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53060 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52695: [clang][Parse] Diagnose useless null statements (PR39111)
lebedev.ri added a comment. Ping. Repository: rC Clang https://reviews.llvm.org/D52695 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52771: [clang-tidy] Non-private member variables in classes (MISRA, CppCoreGuidelines, HICPP)
zinovy.nis added inline comments. Comment at: test/clang-tidy/misc-non-private-member-variables-in-classes.cpp:1 +// RUN: %check_clang_tidy -check-suffix=NONPRIVATE %s misc-non-private-member-variables-in-classes %t +// RUN: %check_clang_tidy -check-suffix=NONPRIVATE %s misc-non-private-member-variables-in-classes %t -- -config='{CheckOptions: [{key: misc-non-private-member-variables-in-classes.IgnorePublicMemberVariables, value: 0}, {key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic, value: 0}]}' -- JonasToth wrote: > lebedev.ri wrote: > > JonasToth wrote: > > > I would prefer multiple test-files instead of mixing them all together. > > Hmm, no. Then the tests will have to be duplicated in N files, > > because i really do want to see what each of these 4 configurations do on > > the *same* input. > > > > It only looks ugly because the script only supports `-check-suffix=`, > > and not `-check-suffixes=`, which would significantly cut down on > > check-lines. > Ok, if you prefer this. Not an issue anymore. You can use `-check-suffixes` since now. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D52771 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50766: Fix false positive unsequenced access and modification warning in array subscript expression.
Rakete added inline comments. Comment at: test/SemaCXX/warn-unsequenced-cxx17.cpp:1 +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 -Wno-unused %s + lebedev.ri wrote: > One last-minute thought: this is only a positive test. > You don't test what happens before C++17. It is tested. Look at the diff for test/SemaCXX/warn-unsequenced.cpp :) Or are you suggesting to merge the two files? https://reviews.llvm.org/D50766 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D50766: Fix false positive unsequenced access and modification warning in array subscript expression.
lebedev.ri added inline comments. Comment at: test/SemaCXX/warn-unsequenced-cxx17.cpp:1 +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 -Wno-unused %s + Rakete wrote: > lebedev.ri wrote: > > One last-minute thought: this is only a positive test. > > You don't test what happens before C++17. > It is tested. Look at the diff for test/SemaCXX/warn-unsequenced.cpp :) > Or are you suggesting to merge the two files? I see that the negative test is in `warn-unsequenced.cpp`, but the positive test is in `warn-unsequenced-cxx17.cpp`. This split is the reason of my remark. I'm not sure if this is an issue, or if merging them is the solution. https://reviews.llvm.org/D50766 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52773: clang-cl: Add /showFilenames option (PR31957)
hans added inline comments. Comment at: test/Driver/cl-showfilenames.c:7-8 +// multiple: cl-showfilenames.c +// multiple-NEXT: wildcard1.c +// multiple-NEXT: wildcard2.c rnk wrote: > I think it'd be nice to have the test show that diagnostics come out > interleaved between the filenames. You can use `#pragma message` in the input > files or something else to create warnings. Good idea, thanks. https://reviews.llvm.org/D52773 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r344234 - clang-cl: Add /showFilenames option (PR31957)
Author: hans Date: Thu Oct 11 03:04:15 2018 New Revision: 344234 URL: http://llvm.org/viewvc/llvm-project?rev=344234&view=rev Log: clang-cl: Add /showFilenames option (PR31957) Add a /showFilenames option for users who want clang to echo the currently compiled filename. MSVC does this echoing by default, and it's useful for showing progress in build systems that doesn't otherwise provide any progress report, such as MSBuild. Differential Revision: https://reviews.llvm.org/D52773 Added: cfe/trunk/test/Driver/cl-showfilenames.c Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td cfe/trunk/include/clang/Driver/Job.h cfe/trunk/lib/Driver/Job.cpp cfe/trunk/lib/Driver/ToolChains/Clang.cpp Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=344234&r1=344233&r2=344234&view=diff == --- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original) +++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Thu Oct 11 03:04:15 2018 @@ -158,6 +158,10 @@ def _SLASH_Qvec_ : CLFlag<"Qvec-">, def _SLASH_showIncludes : CLFlag<"showIncludes">, HelpText<"Print info about included files to stderr">, Alias; +def _SLASH_showFilenames : CLFlag<"showFilenames">, + HelpText<"Print the name of each compiled file">; +def _SLASH_showFilenames_ : CLFlag<"showFilenames-">, + HelpText<"Don't print the name of each compiled file (default)">; def _SLASH_source_charset : CLCompileJoined<"source-charset:">, HelpText<"Source encoding, supports only UTF-8">, Alias; def _SLASH_execution_charset : CLCompileJoined<"execution-charset:">, Modified: cfe/trunk/include/clang/Driver/Job.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Job.h?rev=344234&r1=344233&r2=344234&view=diff == --- cfe/trunk/include/clang/Driver/Job.h (original) +++ cfe/trunk/include/clang/Driver/Job.h Thu Oct 11 03:04:15 2018 @@ -59,6 +59,9 @@ class Command { /// The list of program arguments which are inputs. llvm::opt::ArgStringList InputFilenames; + /// Whether to print the input filenames when executing. + bool PrintInputFilenames = false; + /// Response file name, if this command is set to use one, or nullptr /// otherwise const char *ResponseFile = nullptr; @@ -128,6 +131,9 @@ public: /// Print a command argument, and optionally quote it. static void printArg(llvm::raw_ostream &OS, StringRef Arg, bool Quote); + + /// Set whether to print the input filenames when executing. + void setPrintInputFilenames(bool P) { PrintInputFilenames = P; } }; /// Like Command, but with a fallback which is executed in case Modified: cfe/trunk/lib/Driver/Job.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Job.cpp?rev=344234&r1=344233&r2=344234&view=diff == --- cfe/trunk/lib/Driver/Job.cpp (original) +++ cfe/trunk/lib/Driver/Job.cpp Thu Oct 11 03:04:15 2018 @@ -315,6 +315,12 @@ void Command::setEnvironment(llvm::Array int Command::Execute(ArrayRef> Redirects, std::string *ErrMsg, bool *ExecutionFailed) const { + if (PrintInputFilenames) { +for (const char *Arg : InputFilenames) + llvm::outs() << llvm::sys::path::filename(Arg) << "\n"; +llvm::outs().flush(); + } + SmallVector Argv; Optional> Env; Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=344234&r1=344233&r2=344234&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Oct 11 03:04:15 2018 @@ -5067,6 +5067,13 @@ void Clang::ConstructJob(Compilation &C, C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs)); } + // Make the compile command echo its inputs for /showFilenames. + if (Output.getType() == types::TY_Object && + Args.hasFlag(options::OPT__SLASH_showFilenames, + options::OPT__SLASH_showFilenames_, false)) { +C.getJobs().getJobs().back()->setPrintInputFilenames(true); + } + if (Arg *A = Args.getLastArg(options::OPT_pg)) if (!shouldUseFramePointer(Args, Triple)) D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer" Added: cfe/trunk/test/Driver/cl-showfilenames.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-showfilenames.c?rev=344234&view=auto == --- cfe/trunk/test/Driver/cl-showfilenames.c (added) +++ cfe/trunk/test/Driver/cl-showfilenames.c Thu Oct 11 03:04:15 2018 @@ -0,0 +1,19 @@ +// RUN: %clang_cl /c /showFilenames -- %s 2>&1 |
[PATCH] D52773: clang-cl: Add /showFilenames option (PR31957)
This revision was automatically updated to reflect the committed changes. Closed by commit rL344234: clang-cl: Add /showFilenames option (PR31957) (authored by hans, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D52773?vs=168999&id=169178#toc Repository: rL LLVM https://reviews.llvm.org/D52773 Files: cfe/trunk/include/clang/Driver/CLCompatOptions.td cfe/trunk/include/clang/Driver/Job.h cfe/trunk/lib/Driver/Job.cpp cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/test/Driver/cl-showfilenames.c Index: cfe/trunk/include/clang/Driver/Job.h === --- cfe/trunk/include/clang/Driver/Job.h +++ cfe/trunk/include/clang/Driver/Job.h @@ -59,6 +59,9 @@ /// The list of program arguments which are inputs. llvm::opt::ArgStringList InputFilenames; + /// Whether to print the input filenames when executing. + bool PrintInputFilenames = false; + /// Response file name, if this command is set to use one, or nullptr /// otherwise const char *ResponseFile = nullptr; @@ -128,6 +131,9 @@ /// Print a command argument, and optionally quote it. static void printArg(llvm::raw_ostream &OS, StringRef Arg, bool Quote); + + /// Set whether to print the input filenames when executing. + void setPrintInputFilenames(bool P) { PrintInputFilenames = P; } }; /// Like Command, but with a fallback which is executed in case Index: cfe/trunk/include/clang/Driver/CLCompatOptions.td === --- cfe/trunk/include/clang/Driver/CLCompatOptions.td +++ cfe/trunk/include/clang/Driver/CLCompatOptions.td @@ -158,6 +158,10 @@ def _SLASH_showIncludes : CLFlag<"showIncludes">, HelpText<"Print info about included files to stderr">, Alias; +def _SLASH_showFilenames : CLFlag<"showFilenames">, + HelpText<"Print the name of each compiled file">; +def _SLASH_showFilenames_ : CLFlag<"showFilenames-">, + HelpText<"Don't print the name of each compiled file (default)">; def _SLASH_source_charset : CLCompileJoined<"source-charset:">, HelpText<"Source encoding, supports only UTF-8">, Alias; def _SLASH_execution_charset : CLCompileJoined<"execution-charset:">, Index: cfe/trunk/test/Driver/cl-showfilenames.c === --- cfe/trunk/test/Driver/cl-showfilenames.c +++ cfe/trunk/test/Driver/cl-showfilenames.c @@ -0,0 +1,19 @@ +// RUN: %clang_cl /c /showFilenames -- %s 2>&1 | FileCheck -check-prefix=show %s +// RUN: %clang_cl /c /showFilenames -- %s %S/Inputs/wildcard*.c 2>&1 | FileCheck -check-prefix=multiple %s + +// RUN: %clang_cl /c -- %s 2>&1 | FileCheck -check-prefix=noshow %s +// RUN: %clang_cl /c /showFilenames /showFilenames- -- %s 2>&1 | FileCheck -check-prefix=noshow %s + + +#pragma message "Hello" + +// show: cl-showfilenames.c +// show-NEXT: warning: Hello + +// multiple: cl-showfilenames.c +// multiple-NEXT: warning: Hello +// multiple: wildcard1.c +// multiple-NEXT: wildcard2.c + +// noshow: warning: Hello +// noshow-NOT: cl-showfilenames.c Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp === --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp @@ -5067,6 +5067,13 @@ C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs)); } + // Make the compile command echo its inputs for /showFilenames. + if (Output.getType() == types::TY_Object && + Args.hasFlag(options::OPT__SLASH_showFilenames, + options::OPT__SLASH_showFilenames_, false)) { +C.getJobs().getJobs().back()->setPrintInputFilenames(true); + } + if (Arg *A = Args.getLastArg(options::OPT_pg)) if (!shouldUseFramePointer(Args, Triple)) D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer" Index: cfe/trunk/lib/Driver/Job.cpp === --- cfe/trunk/lib/Driver/Job.cpp +++ cfe/trunk/lib/Driver/Job.cpp @@ -315,6 +315,12 @@ int Command::Execute(ArrayRef> Redirects, std::string *ErrMsg, bool *ExecutionFailed) const { + if (PrintInputFilenames) { +for (const char *Arg : InputFilenames) + llvm::outs() << llvm::sys::path::filename(Arg) << "\n"; +llvm::outs().flush(); + } + SmallVector Argv; Optional> Env; Index: cfe/trunk/include/clang/Driver/Job.h === --- cfe/trunk/include/clang/Driver/Job.h +++ cfe/trunk/include/clang/Driver/Job.h @@ -59,6 +59,9 @@ /// The list of program arguments which are inputs. llvm::opt::ArgStringList InputFilenames; + /// Whether to print the input filenames when executing. + bool PrintInputFilenames = false; + /// Response file name, if this command is set to use one, or nullptr /// otherwise const char *ResponseFile
[PATCH] D52750: [Diagnostics] Check for integer overflow in array size expressions
xbolva00 added a comment. @Rakete plesse take a look :) https://reviews.llvm.org/D52750 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51340: Add /Zc:DllexportInlines option to clang-cl
takuto.ikuta updated this revision to Diff 169179. takuto.ikuta marked an inline comment as done. takuto.ikuta added a comment. address comment https://reviews.llvm.org/D51340 Files: clang/include/clang/Basic/Attr.td clang/include/clang/Basic/LangOptions.h clang/include/clang/Driver/CC1Options.td clang/include/clang/Driver/CLCompatOptions.td clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Frontend/CompilerInvocation.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaDeclCXX.cpp clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp Index: clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp === --- /dev/null +++ clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp @@ -0,0 +1,163 @@ +// RUN: %clang_cc1 %s -fms-extensions -triple x86_64-windows-msvc \ +// RUN: -fno-dllexport-inlines -emit-llvm -O0 -o - |\ +// RUN: FileCheck --check-prefix=DEFAULT --check-prefix=NOINLINE %s + +// RUN: %clang_cc1 %s -fms-extensions -triple x86_64-windows-msvc \ +// RUN: -emit-llvm -O0 -o - | \ +// RUN: FileCheck --check-prefix=DEFAULT --check-prefix=INLINE %s + +// Function + +// DEFAULT-DAG: define dso_local dllexport void @"?NormalFunction@@YAXXZ"() +void __declspec(dllexport) NormalFunction() {} + + +// DEFAULT-DAG: define weak_odr dso_local dllexport void @"?AlwaysInlineFunction@@YAXXZ" +__forceinline void __declspec(dllexport) AlwaysInlineFunction() {} + +// DEFAULT-DAG: @"?static_variable@?1??AlwaysInlineWithStaticVariableExported@@YAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4 +__forceinline int __declspec(dllexport) AlwaysInlineWithStaticVariableExported() { + static int static_variable = 0; + ++static_variable; + return static_variable; +} + +// DEFAULT-DAG: @"?static_variable@?1??AlwaysInlineWithStaticVariableImported@@YAHXZ@4HA" = available_externally dllimport global i32 0, align 4 +__forceinline int __declspec(dllimport) AlwaysInlineWithStaticVariableImported() { + static int static_variable = 0; + ++static_variable; + return static_variable; +} + +int ImportedFunctionUser() { + return AlwaysInlineWithStaticVariableImported(); +} + +// Class member function + +// check for local static variables +// NOINLINE-DAG: @"?static_variable@?1??InclassDefFuncWithStaticVariable@NoTemplateExportedClass@@QEAAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4 + +// INLINE-DAG: @"?static_variable@?1??InclassDefFuncWithStaticVariable@NoTemplateExportedClass@@QEAAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4 + +// NOINLINE-DAG: @"?static_variable@?1??InClassDefFuncWithStaticVariable@ImportedClass@@QEAAHXZ@4HA" = available_externally dllimport global i32 0, align 4 + +class __declspec(dllexport) NoTemplateExportedClass { + public: + // DEFAULT-NOT: NoTemplateExportedClass@NoTemplateExportedClass@@ + NoTemplateExportedClass() = default; + + // NOINLINE-NOT: InclassDefFunc@NoTemplateExportedClass + // INLINE-DAG: define weak_odr dso_local dllexport void @"?InclassDefFunc@NoTemplateExportedClass@@ + void InclassDefFunc() {} + + int f(); + + // DEFAULT-DAG: define weak_odr dso_local dllexport i32 @"?InclassDefFuncWithStaticVariable@NoTemplateExportedClass@@QEAAHXZ" + int InclassDefFuncWithStaticVariable() { +static int static_variable = 0; +++static_variable; +return static_variable; + } + + // DEFAULT-DAG: define weak_odr dso_local dllexport i32 @"?InclassDefFunctWithLambdaStaticVariable@NoTemplateExportedClass@@QEAAHXZ" + int InclassDefFunctWithLambdaStaticVariable() { +return ([]() { static int static_x; return ++static_x; })(); + } + + // DEFAULT-NOT: InlineOutclassDefFuncWihtoutDefinition + __forceinline void InlineOutclassDefFuncWihtoutDefinition(); + + // DEFAULT-NOT: InlineOutclassDefFunc@NoTemplateExportedClass@@ + __forceinline void InlineOutclassDefFunc(); + + // DEFAULT-NOT: InlineOutclassDefFuncWithStaticVariable@NoTemplateExportedClass@@ + __forceinline int InlineOutclassDefFuncWithStaticVariable(); + + // DEFAULT-DAG: define dso_local dllexport void @"?OutclassDefFunc@NoTemplateExportedClass@@QEAAXXZ" + void OutclassDefFunc(); +}; + +void NoTemplateExportedClass::OutclassDefFunc() {} + +__forceinline void NoTemplateExportedClass::InlineOutclassDefFunc() {} + +__forceinline int NoTemplateExportedClass::InlineOutclassDefFuncWithStaticVariable() { + static int static_variable = 0; + return ++static_variable; +} + +void __declspec(dllexport) NoTemplateExportedClassUser() { + NoTemplateExportedClass a; + a.InlineOutclassDefFunc(); +} + +template +class __declspec(dllexport) TemplateExportedClass { + void InclassDefFunc() {} + void OutclassDefFunc(); + + T templateValue; +}; + +// DEFAULT-NOT: define dso_local dllexport void @"?OutclassDefFunc@NoTemplateExportedClass@@ +template void TemplateExportedClass::OutclassDefFunc() {} + +clas
[PATCH] D53131: [clangd] Support scope proximity in code completion.
ioeric created this revision. ioeric added a reviewer: sammccall. Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, ilya-biryukov. This should make all-scope completion more usable. Scope proximity for indexes will be added in followup patch. Measurements showed a slight improvement on the overall completion quality (with all-scope completion diabled). Total measurements: 110715 (+0) Average latency (ms): 278.558380127 (+47) All measurements: MRR: 67.47 (+0.32) Top-1: 57.68% (+0.27%) Top-5: 79.92% (+0.46%) Top-100: 94.57% (+0.39%) Full identifiers: MRR: 97.85 (-0.01) Top-1: 97.09% (-0.01%) Top-5: 98.74% (-0.01%) Top-100: 98.78% (-0.02%) Filter length 0-5: MRR: 22.88 (+0.04) 55.86 (+0.64) 69.39 (+0.84) 73.53 (+0.34) 76.47 (+0.20) 80.76 (+0.17) Top-1:12.06% (-0.05%) 42.40% (+0.23%) 57.28% (+0.85%) 61.85% (+0.39%) 65.80% (+0.25%) 71.38% (+0.22%) Top-5:35.86% (-0.03%) 72.92% (+1.46%) 85.07% (+0.99%) 88.60% (+0.33%) 90.25% (+0.18%) 92.91% (+0.19%) Top-100: 76.26% (+2.59%) 95.91% (+0.04%) 98.02% (-0.01%) 98.22% (-0.03%) 98.18% (-0.03%) 98.33% (-0.02%) Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53131 Files: clangd/CodeComplete.cpp clangd/Quality.cpp clangd/Quality.h unittests/clangd/CodeCompleteTests.cpp unittests/clangd/QualityTests.cpp Index: unittests/clangd/QualityTests.cpp === --- unittests/clangd/QualityTests.cpp +++ unittests/clangd/QualityTests.cpp @@ -28,6 +28,7 @@ #include "llvm/Support/Casting.h" #include "gmock/gmock.h" #include "gtest/gtest.h" +#include namespace clang { namespace clangd { @@ -117,13 +118,14 @@ Relevance = {}; Relevance.merge(CodeCompletionResult(&findDecl(AST, "main"), 42)); - EXPECT_FLOAT_EQ(Relevance.SemaProximityScore, 1.0f) << "Decl in current file"; + EXPECT_FLOAT_EQ(Relevance.SemaFileProximityScore, 1.0f) + << "Decl in current file"; Relevance = {}; Relevance.merge(CodeCompletionResult(&findDecl(AST, "header"), 42)); - EXPECT_FLOAT_EQ(Relevance.SemaProximityScore, 0.6f) << "Decl from header"; + EXPECT_FLOAT_EQ(Relevance.SemaFileProximityScore, 0.6f) << "Decl from header"; Relevance = {}; Relevance.merge(CodeCompletionResult(&findDecl(AST, "header_main"), 42)); - EXPECT_FLOAT_EQ(Relevance.SemaProximityScore, 1.0f) + EXPECT_FLOAT_EQ(Relevance.SemaFileProximityScore, 1.0f) << "Current file and header"; auto constructShadowDeclCompletionResult = [&](const std::string DeclName) { @@ -146,10 +148,10 @@ Relevance = {}; Relevance.merge(constructShadowDeclCompletionResult("Bar")); - EXPECT_FLOAT_EQ(Relevance.SemaProximityScore, 1.0f) + EXPECT_FLOAT_EQ(Relevance.SemaFileProximityScore, 1.0f) << "Using declaration in main file"; Relevance.merge(constructShadowDeclCompletionResult("FLAGS_FOO")); - EXPECT_FLOAT_EQ(Relevance.SemaProximityScore, 1.0f) + EXPECT_FLOAT_EQ(Relevance.SemaFileProximityScore, 1.0f) << "Using declaration in main file"; Relevance = {}; @@ -210,9 +212,19 @@ PoorNameMatch.NameMatch = 0.2f; EXPECT_LT(PoorNameMatch.evaluate(), Default.evaluate()); - SymbolRelevanceSignals WithSemaProximity; - WithSemaProximity.SemaProximityScore = 0.2f; - EXPECT_GT(WithSemaProximity.evaluate(), Default.evaluate()); + SymbolRelevanceSignals WithSemaFileProximity; + WithSemaFileProximity.SemaFileProximityScore = 0.2f; + EXPECT_GT(WithSemaFileProximity.evaluate(), Default.evaluate()); + + SymbolRelevanceSignals WithSemaScopeProximity; + WithSemaScopeProximity.SemaScopeProximityScore = 0.2f; + EXPECT_GT(WithSemaScopeProximity.evaluate(), Default.evaluate()); + + SymbolRelevanceSignals WithIndexScopeProximity; + QueryScopeProximity ScopeProximity({"x::y::"}); + WithSemaFileProximity.ScopeProximityMatch = &ScopeProximity; + WithSemaScopeProximity.SymbolScope = "x::y::"; + EXPECT_GT(WithSemaScopeProximity.evaluate(), Default.evaluate()); SymbolRelevanceSignals IndexProximate; IndexProximate.SymbolURI = "unittest:/foo/bar.h"; @@ -242,6 +254,30 @@ EXPECT_EQ(Instance.evaluate(), Default.evaluate()); } +TEST(QualityTests, ScopeProximity) { + SymbolRelevanceSignals Default; + + SymbolRelevanceSignals Relevance; + QueryScopeProximity ScopeProximity({"x::y::", "x::", "std::"}); + Relevance.ScopeProximityMatch = &ScopeProximity; + + + Relevance.SymbolScope = "other::"; + float NotMatched = Relevance.evaluate(); + EXPECT_EQ(NotMatched, Default.evaluate()); + + Relevance.SymbolScope = "std::"; + float NonParent = Relevance.evaluate(); + + Relevance.SymbolScope = "x::"; + float Parent = Relevance.evaluate(); + EXPECT_GT(Parent, NonParent); + + Relevance.SymbolScop
[PATCH] D51340: Add /Zc:DllexportInlines option to clang-cl
takuto.ikuta added a comment. Thank you for review! I updated the code. Comment at: clang/lib/Sema/SemaDecl.cpp:11976 + +while (FD && !getDLLAttr(FD) && + !FD->hasAttr() && hans wrote: > Why does this need to be a loop? I don't think FunctionDecl's can be nested? This is for static local var in lambda function. static_x's ParentFunction does not become f(). ``` class __declspec(dllexport) C { int f() { return ([]() { static int static_x; return ++static_x; })(); } }; ``` Comment at: clang/lib/Sema/SemaDecl.cpp:11995 + +// Function having static local variables should be exported. +auto *ExportAttr = cast(NewAttr->clone(getASTContext())); hans wrote: > Isn't it enough that the static local is exported, does the function itself > need to be exported too? Adding dllexport only to variable does not export variable when the function is not used. But dllimport is not necessary for function, removed. Comment at: clang/lib/Sema/SemaDeclCXX.cpp:5705 +TSK != TSK_ExplicitInstantiationDeclaration && +TSK != TSK_ExplicitInstantiationDefinition) { + if (ClassExported) { hans wrote: > But I don't understand why the template stuff is checked here... > > The way I imagined this, we'd only need to change the code when creating > NewAttr below.. > Something like > > ``` > NewAttr = ClassAtr->clone()... > if (!getLandOpts().DllExportInlines() && Member is an inline method) > NewAttr = our new dllimport/export static locals attribute > ``` > > What do you think? > But I don't understand why the template stuff is checked here... Templated inline function is not always inlined, it seems depending on optimization level. I updated the code as you wrote in later part of comment. https://reviews.llvm.org/D51340 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53023: Prototype OpenCL BIFs using Tablegen
joey updated this revision to Diff 169182. joey added a comment. Re-uploading the patch. The previous version of the patch was missing the include and lib prefixes. https://reviews.llvm.org/D53023 Files: include/clang/Basic/CMakeLists.txt include/clang/Basic/OpenCLBuiltins.td lib/Sema/SemaDecl.cpp lib/Sema/SemaExpr.cpp test/SemaOpenCL/builtin-new.cl utils/TableGen/CMakeLists.txt utils/TableGen/ClangOpenCLBuiltinEmitter.cpp utils/TableGen/TableGen.cpp utils/TableGen/TableGenBackends.h Index: utils/TableGen/TableGenBackends.h === --- utils/TableGen/TableGenBackends.h +++ utils/TableGen/TableGenBackends.h @@ -81,6 +81,7 @@ void EmitTestPragmaAttributeSupportedAttributes(RecordKeeper &Records, raw_ostream &OS); +void EmitClangOpenCLBuiltins(RecordKeeper &Records, raw_ostream &OS); } // end namespace clang #endif Index: utils/TableGen/TableGen.cpp === --- utils/TableGen/TableGen.cpp +++ utils/TableGen/TableGen.cpp @@ -61,7 +61,8 @@ GenDiagDocs, GenOptDocs, GenDataCollectors, - GenTestPragmaAttributeSupportedAttributes + GenTestPragmaAttributeSupportedAttributes, + GenClangOpenCLBuiltins, }; namespace { @@ -161,7 +162,9 @@ clEnumValN(GenTestPragmaAttributeSupportedAttributes, "gen-clang-test-pragma-attribute-supported-attributes", "Generate a list of attributes supported by #pragma clang " - "attribute for testing purposes"))); + "attribute for testing purposes"), +clEnumValN(GenClangOpenCLBuiltins, "gen-clang-opencl-builtins", + "Generate OpenCL builtin handlers"))); cl::opt ClangComponent("clang-component", @@ -288,6 +291,9 @@ case GenTestPragmaAttributeSupportedAttributes: EmitTestPragmaAttributeSupportedAttributes(Records, OS); break; + case GenClangOpenCLBuiltins: +EmitClangOpenCLBuiltins(Records, OS); +break; } return false; Index: utils/TableGen/ClangOpenCLBuiltinEmitter.cpp === --- /dev/null +++ utils/TableGen/ClangOpenCLBuiltinEmitter.cpp @@ -0,0 +1,195 @@ +//===- ClangOpenCLBuiltinEmitter.cpp - Generate Clang OpenCL Builtin handling +//=-*- C++ -*--=// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// +// +// This tablegen backend emits Clang OpenCL Builtin checking code. +// +//===--===// + +#include "llvm/ADT/MapVector.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/SmallString.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/ADT/StringSet.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/raw_ostream.h" +#include "llvm/TableGen/Error.h" +#include "llvm/TableGen/Record.h" +#include "llvm/TableGen/StringMatcher.h" +#include "llvm/TableGen/TableGenBackend.h" + +#include + +using namespace llvm; + +namespace { +class BuiltinNameEmitter { +public: + BuiltinNameEmitter(RecordKeeper &Records, raw_ostream &OS) + : Records(Records), OS(OS) {} + + void Emit(); + +private: + RecordKeeper &Records; + raw_ostream &OS; + + void EmitDeclarations(); + void EmitTable(); + void GetOverloads(); + + MapVector>> + OverloadInfo; + std::vector, unsigned>> ArgTypesSet; +}; +} // namespace + +void BuiltinNameEmitter::GetOverloads() { + unsigned CumulativeArgIndex = 0; + std::vector Builtins = Records.getAllDerivedDefinitions("Builtin"); + for (const auto *B : Builtins) { +StringRef BName = B->getValueAsString("name"); + +if (OverloadInfo.find(BName) == OverloadInfo.end()) { + OverloadInfo.insert(std::make_pair( + BName, std::vector>{})); +} + +auto Args = B->getValueAsListOfDefs("args"); +auto it = +std::find_if(ArgTypesSet.begin(), ArgTypesSet.end(), + [&](const std::pair, unsigned> &a) { + return a.first == Args; + }); +unsigned ArgIndex; +if (it == ArgTypesSet.end()) { + ArgTypesSet.push_back(std::make_pair(Args, CumulativeArgIndex)); + ArgIndex = CumulativeArgIndex; + CumulativeArgIndex += Args.size(); +} else { + ArgIndex = it->second; +} +OverloadInfo[BName].push_back(std::make_pair(B, ArgIndex)); + } +} + +void BuiltinNameEmitter::EmitDeclarations() { + OS << "enum OpenCLTypeID {\n"; + std::vector Types = Records.getAllDerivedDefinitions("Type"); + StringMap TypesSeen; + for (const auto *T : Types) { +if (TypesSeen.find(T->getValueAsString("name")) == TypesSeen.end()) + OS
[PATCH] D52750: [Diagnostics] Check for integer overflow in array size expressions
Rakete added a comment. The array size is still evaluated twice. Try to incorporate the check in `Sema::VerifyIntegerConstantExpression`. https://reviews.llvm.org/D52750 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52750: [Diagnostics] Check for integer overflow in array size expressions
xbolva00 added a comment. Thanks! But I think I need to change EvaluateForOverflow method to return bool to indicate overflowing. https://reviews.llvm.org/D52750 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51402: [OpenCL] Adding cl_intel_planar_yuv extension
sidorovd updated this revision to Diff 169187. sidorovd added a comment. Moved the test to test/Headers/opencl-c-header.cl https://reviews.llvm.org/D51402 Files: Headers/opencl-c-header.cl Headers/opencl-c.h Index: Headers/opencl-c-header.cl === --- Headers/opencl-c-header.cl +++ Headers/opencl-c-header.cl @@ -1,5 +1,6 @@ -// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s| FileCheck %s -// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| FileCheck %s +// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify | FileCheck %s +// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL1.1| FileCheck %s +// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL1.2| FileCheck %s // Test including the default header as a module. // The module should be compiled only once and loaded from cache afterwards. @@ -71,4 +72,16 @@ } #endif //__OPENCL_C_VERSION__ +// Verify that non-builtin cl_intel_planar_yuv extension is defined from +// OpenCL 1.2 onwards. +#if (__OPENCL_C_VERSION__ >= CL_VERSION_1_2) +// expected-no-diagnostics +#ifndef cl_intel_planar_yuv +#error "Missing cl_intel_planar_yuv define" +#endif +#else +// expected-warning@+2{{unknown OpenCL extension 'cl_intel_planar_yuv' - ignoring}} +#endif +#pragma OPENCL EXTENSION cl_intel_planar_yuv : enable + // CHECK-MOD: Reading modules Index: Headers/opencl-c.h === --- Headers/opencl-c.h +++ Headers/opencl-c.h @@ -22,6 +22,14 @@ #endif //cl_khr_3d_image_writes #endif //__OPENCL_C_VERSION__ < CL_VERSION_2_0 +#if __OPENCL_C_VERSION__ >= CL_VERSION_1_2 +#ifndef cl_intel_planar_yuv +#define cl_intel_planar_yuv +#endif // cl_intel_planar_yuv +#pragma OPENCL EXTENSION cl_intel_planar_yuv : begin +#pragma OPENCL EXTENSION cl_intel_planar_yuv : end +#endif // __OPENCL_C_VERSION__ >= CL_VERSION_1_2 + #define __ovld __attribute__((overloadable)) #define __conv __attribute__((convergent)) Index: Headers/opencl-c-header.cl === --- Headers/opencl-c-header.cl +++ Headers/opencl-c-header.cl @@ -1,5 +1,6 @@ -// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s| FileCheck %s -// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| FileCheck %s +// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify | FileCheck %s +// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL1.1| FileCheck %s +// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL1.2| FileCheck %s // Test including the default header as a module. // The module should be compiled only once and loaded from cache afterwards. @@ -71,4 +72,16 @@ } #endif //__OPENCL_C_VERSION__ +// Verify that non-builtin cl_intel_planar_yuv extension is defined from +// OpenCL 1.2 onwards. +#if (__OPENCL_C_VERSION__ >= CL_VERSION_1_2) +// expected-no-diagnostics +#ifndef cl_intel_planar_yuv +#error "Missing cl_intel_planar_yuv define" +#endif +#else +// expected-warning@+2{{unknown OpenCL extension 'cl_intel_planar_yuv' - ignoring}} +#endif +#pragma OPENCL EXTENSION cl_intel_planar_yuv : enable + // CHECK-MOD: Reading modules Index: Headers/opencl-c.h === --- Headers/opencl-c.h +++ Headers/opencl-c.h @@ -22,6 +22,14 @@ #endif //cl_khr_3d_image_writes #endif //__OPENCL_C_VERSION__ < CL_VERSION_2_0 +#if __OPENCL_C_VERSION__ >= CL_VERSION_1_2 +#ifndef cl_intel_planar_yuv +#define cl_intel_planar_yuv +#endif // cl_intel_planar_yuv +#pragma OPENCL EXTENSION cl_intel_planar_yuv : begin +#pragma OPENCL EXTENSION cl_intel_planar_yuv : end +#endif // __OPENCL_C_VERSION__ >= CL_VERSION_1_2 + #define __ovld __attribute__((overloadable)) #define __conv __attribute__((convergent)) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51402: [OpenCL] Adding cl_intel_planar_yuv extension
sidorovd updated this revision to Diff 169188. sidorovd added a comment. - Forgot to add clarification comments on conditional branching. Added. https://reviews.llvm.org/D51402 Files: Headers/opencl-c-header.cl Headers/opencl-c.h Index: Headers/opencl-c-header.cl === --- Headers/opencl-c-header.cl +++ Headers/opencl-c-header.cl @@ -1,5 +1,6 @@ -// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s| FileCheck %s -// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| FileCheck %s +// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify | FileCheck %s +// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL1.1| FileCheck %s +// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL1.2| FileCheck %s // Test including the default header as a module. // The module should be compiled only once and loaded from cache afterwards. @@ -71,4 +72,16 @@ } #endif //__OPENCL_C_VERSION__ +// Verify that non-builtin cl_intel_planar_yuv extension is defined from +// OpenCL 1.2 onwards. +#if (__OPENCL_C_VERSION__ >= CL_VERSION_1_2) +// expected-no-diagnostics +#ifndef cl_intel_planar_yuv +#error "Missing cl_intel_planar_yuv define" +#endif +#else //__OPENCL_C_VERSION__ +// expected-warning@+2{{unknown OpenCL extension 'cl_intel_planar_yuv' - ignoring}} +#endif //__OPENCL_C_VERSION__ +#pragma OPENCL EXTENSION cl_intel_planar_yuv : enable + // CHECK-MOD: Reading modules Index: Headers/opencl-c.h === --- Headers/opencl-c.h +++ Headers/opencl-c.h @@ -22,6 +22,14 @@ #endif //cl_khr_3d_image_writes #endif //__OPENCL_C_VERSION__ < CL_VERSION_2_0 +#if __OPENCL_C_VERSION__ >= CL_VERSION_1_2 +#ifndef cl_intel_planar_yuv +#define cl_intel_planar_yuv +#endif // cl_intel_planar_yuv +#pragma OPENCL EXTENSION cl_intel_planar_yuv : begin +#pragma OPENCL EXTENSION cl_intel_planar_yuv : end +#endif // __OPENCL_C_VERSION__ >= CL_VERSION_1_2 + #define __ovld __attribute__((overloadable)) #define __conv __attribute__((convergent)) Index: Headers/opencl-c-header.cl === --- Headers/opencl-c-header.cl +++ Headers/opencl-c-header.cl @@ -1,5 +1,6 @@ -// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s| FileCheck %s -// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| FileCheck %s +// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify | FileCheck %s +// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL1.1| FileCheck %s +// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL1.2| FileCheck %s // Test including the default header as a module. // The module should be compiled only once and loaded from cache afterwards. @@ -71,4 +72,16 @@ } #endif //__OPENCL_C_VERSION__ +// Verify that non-builtin cl_intel_planar_yuv extension is defined from +// OpenCL 1.2 onwards. +#if (__OPENCL_C_VERSION__ >= CL_VERSION_1_2) +// expected-no-diagnostics +#ifndef cl_intel_planar_yuv +#error "Missing cl_intel_planar_yuv define" +#endif +#else //__OPENCL_C_VERSION__ +// expected-warning@+2{{unknown OpenCL extension 'cl_intel_planar_yuv' - ignoring}} +#endif //__OPENCL_C_VERSION__ +#pragma OPENCL EXTENSION cl_intel_planar_yuv : enable + // CHECK-MOD: Reading modules Index: Headers/opencl-c.h === --- Headers/opencl-c.h +++ Headers/opencl-c.h @@ -22,6 +22,14 @@ #endif //cl_khr_3d_image_writes #endif //__OPENCL_C_VERSION__ < CL_VERSION_2_0 +#if __OPENCL_C_VERSION__ >= CL_VERSION_1_2 +#ifndef cl_intel_planar_yuv +#define cl_intel_planar_yuv +#endif // cl_intel_planar_yuv +#pragma OPENCL EXTENSION cl_intel_planar_yuv : begin +#pragma OPENCL EXTENSION cl_intel_planar_yuv : end +#endif // __OPENCL_C_VERSION__ >= CL_VERSION_1_2 + #define __ovld __attribute__((overloadable)) #define __conv __attribute__((convergent)) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53034: [clangd] Remove no-op crash handler, we never set a crash context.
ioeric accepted this revision. ioeric added a comment. This revision is now accepted and ready to land. LGTM > Of course the question arises: *should* we set one Agree with your points. If the cleanup is unsafe, it might end up biting us harder in the future. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53034 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52750: [Diagnostics] Check for integer overflow in array size expressions
Rakete added a comment. Nah, you don't even need to call `EvaluateForOverflow` I believe. :) Have a look overflow evaluation is done. https://reviews.llvm.org/D52750 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53024: [analyzer][www] Add more open projects
Szelethus updated this revision to Diff 169193. Szelethus added a comment. - Fixed typos - Fixed stupid characters (Thank you so much @MTC for going the extra mile and opening this patch in a browser!) - Removed outdated entries as mentioned by @MTC https://reviews.llvm.org/D53024 Files: www/analyzer/open_projects.html Index: www/analyzer/open_projects.html === --- www/analyzer/open_projects.html +++ www/analyzer/open_projects.html @@ -25,13 +25,94 @@ Core Analyzer Infrastructure +Implement a dataflow flamework. + + (Difficulty: Hard) + + +Handle aggregate construction. +Aggregates are object that can be brace-initialized without calling a +constructor (i.e., no https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html";> +CXXConstructExpr in the AST), but potentially calling +constructors for their fields and (since C++17) base classes - and these +constructors of sub-objects need to know what object (field in the +aggregate) they are constructing. Moreover, if the aggregate contains +references, lifetime extension needs to be modeled. Aggregates can be +nested, so https://clang.llvm.org/doxygen/classclang_1_1ConstructionContext.html";> +ConstructionContext can potentially cover an unlimited amount of +statements. One can start untangling this problem by trying to replace the +hacky https://clang.llvm.org/doxygen/classclang_1_1ParentMap.html";> +ParentMap lookup in https://clang.llvm.org/doxygen/ExprEngineCXX_8cpp_source.html#l00430";> +CXXConstructExpr::CK_NonVirtualBase branch of +ExprEngine::VisitCXXConstructExpr() with some actual +support for the feature. + (Difficulty: Medium) + + +Fix CFG for GNU "binary conditional" operator ?:. +CFG for GNU "binary conditional" operator ?: is broken in +C++. Its condition-and-LHS need to only be evaluated once. +(Difficulty: Easy) + + +Handle unions. +Currently in the analyzer, the value of a union is always regarded as +unknown. There has been some discussion about this on the http://lists.llvm.org/pipermail/cfe-dev/2017-March/052864.html";> +mailing list already, but it is still an untouched area. + (Difficulty: Medium) + + +Enhance the modeling of the standard library. +There is a huge amount of checker work for teaching the Static Analyzer +about the C++ standard library. It is very easy to explain to the static +analyzer that calling .length() on an empty std::string + will yield 0, and vice versa, but supporting all of them is a huge +amount of work. One good thing to start with here would be to notice that +inlining methods of C++ "containers" is currently outright forbidden in +order to suppress a lot of false alarms due to weird assume()s +made within inlined methods. There's a hypothesis that these suppressions +should have been instead implemented as bug report visitors, which would +still suppress false positives, but will not prevent us from inlining the +methods, and therefore will not cause other false positives. Verifying this +hypothesis would be a wonderful accomplishment. Previous understanding of +the "inlined defensive checks" problem is a pre-requisite for this project. +(Difficulty: Medium) + + +Reimplement the representation for various symbolic values. +https://clang.llvm.org/doxygen/classclang_1_1ento_1_1nonloc_1_1LocAsInteger.html";> +LocAsInteger is annoying, but alternatives are vague. Casts into +the opposite direction - integers to pointers - are completely unsupported. +Pointer-to-pointer casts are a mess; modeling them with https://clang.llvm.org/doxygen/classclang_1_1ento_1_1ElementRegion.html";> +ElementRegion is a impractical, and we are suffering a lot from +this hack, but coming up with a significantly better solution is very hard, +as there are a lot of corner-cases to cover, and it's hard to maintain +balance between richness of our representation of symbolic values and our +ability to understand when the two different values in fact represent the +same thing. +(Difficulty: Hard) + + + Provide better alternatives to inlining. +Sometimes instead of inlining, a much simpler behavior would be more +efficient. For instance, if the function is pure, then a single bit of +information "this function is pure" would already be much better than +conservative evaluation, and sometimes good enough to make inlining not +worth the effort. Gathering such snippets of information - "partial +summaries" - automatically, from the more simple to the more complex +summaries, and re-using them later, probably across translation units, might +improve our analysis quite a lot, while being something that can be worked +on incrementally and doesn't require checkers to rea
[PATCH] D52979: [clangd] Add removeFile interface in FileIndex.
ioeric added inline comments. Comment at: clangd/index/FileIndex.h:78 + /// Remove all index data associated with the file \p Path. + void removeFile(PathRef Path); + hokein wrote: > ioeric wrote: > > should we use this somewhere? E.g. when file is closed in ClangdServer? > Yes, the usage of this method is not included in this patch. > > We probably use this function in `TUScheduler::remove`, the code path will be > like > > `TUScheduler::remove => ParsingCallback::onASTRemove => > FileIndex::removeFile`. > > We need to add a similar interface to `ParsingCallback`. Or maybe in `ClangdServer::removeDocument`? Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D52979 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53121: [Driver] Add defaults for Android ARM FPUs.
peter.smith added a comment. It looks like we might be able to simplify a bit, and I think there probably could be some more test cases but no objections from me. Comment at: lib/Driver/ToolChains/Arch/ARM.cpp:360 + unsigned ArchVersion; + if (ArchName.empty()) Do you need to parse the arch version here? I would expect the -march=armv7 to be reflected in getARMSubArchVersionNumber(Triple) If reduce this to ArchVersion = getARMSubArchVersionNumber(Triple) and add a test with -target arm-linux-androideabi21 -march=armv7 then everything still passes. If I'm right you should be able to simplify this and perhaps roll it into the if (Triple.isAndroid() && ArchVersion >= 7) below. If I'm wrong can we add a test case that fails without the ArchVersion = llvm::ARM::parseArchVersion(ArchName) ? It will also be worth adding tests for a generic target with -march Repository: rC Clang https://reviews.llvm.org/D53121 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r344240 - [python] [tests] Support overriding library path via environment
Author: mgorny Date: Thu Oct 11 04:58:07 2018 New Revision: 344240 URL: http://llvm.org/viewvc/llvm-project?rev=344240&view=rev Log: [python] [tests] Support overriding library path via environment Support a new CLANG_LIBRARY_PATH environment variable for the Python binding tests. This variable can be used to force the bindings to load libclang.* from a specific directory. I plan to use this when integrating Python binding tests with the CMake build system. Currently, those tests load libclang.so from default search paths, so I would have to rely on platform-specific mechanics such as LD_LIBRARY_PATH. Instead of copying the whole logic necessary to handle platform differences into yet another place, it's easier to just add a dedicated variable for this purpose. Differential Revision: https://reviews.llvm.org/D52806 Modified: cfe/trunk/bindings/python/README.txt cfe/trunk/bindings/python/tests/cindex/test_access_specifiers.py cfe/trunk/bindings/python/tests/cindex/test_cdb.py cfe/trunk/bindings/python/tests/cindex/test_code_completion.py cfe/trunk/bindings/python/tests/cindex/test_comment.py cfe/trunk/bindings/python/tests/cindex/test_cursor.py cfe/trunk/bindings/python/tests/cindex/test_cursor_kind.py cfe/trunk/bindings/python/tests/cindex/test_diagnostics.py cfe/trunk/bindings/python/tests/cindex/test_exception_specification_kind.py cfe/trunk/bindings/python/tests/cindex/test_file.py cfe/trunk/bindings/python/tests/cindex/test_index.py cfe/trunk/bindings/python/tests/cindex/test_linkage.py cfe/trunk/bindings/python/tests/cindex/test_location.py cfe/trunk/bindings/python/tests/cindex/test_tls_kind.py cfe/trunk/bindings/python/tests/cindex/test_token_kind.py cfe/trunk/bindings/python/tests/cindex/test_tokens.py cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py cfe/trunk/bindings/python/tests/cindex/test_type.py Modified: cfe/trunk/bindings/python/README.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/README.txt?rev=344240&r1=344239&r2=344240&view=diff == --- cfe/trunk/bindings/python/README.txt (original) +++ cfe/trunk/bindings/python/README.txt Thu Oct 11 04:58:07 2018 @@ -4,12 +4,12 @@ This directory implements Python bindings for Clang. -You may need to alter LD_LIBRARY_PATH so that the Clang library can be +You may need to set CLANG_LIBRARY_PATH so that the Clang library can be found. The unit tests are designed to be run with any standard test runner. For example: -- $ env PYTHONPATH=$(echo ~/llvm/tools/clang/bindings/python/) \ - LD_LIBRARY_PATH=$(llvm-config --libdir) \ + CLANG_LIBRARY_PATH=$(llvm-config --libdir) \ python -m unittest discover -v tests.cindex.test_index.test_create ... ok ... Modified: cfe/trunk/bindings/python/tests/cindex/test_access_specifiers.py URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_access_specifiers.py?rev=344240&r1=344239&r2=344240&view=diff == --- cfe/trunk/bindings/python/tests/cindex/test_access_specifiers.py (original) +++ cfe/trunk/bindings/python/tests/cindex/test_access_specifiers.py Thu Oct 11 04:58:07 2018 @@ -1,3 +1,7 @@ +import os +from clang.cindex import Config +if 'CLANG_LIBRARY_PATH' in os.environ: +Config.set_library_path(os.environ['CLANG_LIBRARY_PATH']) from clang.cindex import AccessSpecifier from clang.cindex import Cursor Modified: cfe/trunk/bindings/python/tests/cindex/test_cdb.py URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_cdb.py?rev=344240&r1=344239&r2=344240&view=diff == --- cfe/trunk/bindings/python/tests/cindex/test_cdb.py (original) +++ cfe/trunk/bindings/python/tests/cindex/test_cdb.py Thu Oct 11 04:58:07 2018 @@ -1,3 +1,8 @@ +import os +from clang.cindex import Config +if 'CLANG_LIBRARY_PATH' in os.environ: +Config.set_library_path(os.environ['CLANG_LIBRARY_PATH']) + from clang.cindex import CompilationDatabase from clang.cindex import CompilationDatabaseError from clang.cindex import CompileCommands Modified: cfe/trunk/bindings/python/tests/cindex/test_code_completion.py URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_code_completion.py?rev=344240&r1=344239&r2=344240&view=diff == --- cfe/trunk/bindings/python/tests/cindex/test_code_completion.py (original) +++ cfe/trunk/bindings/python/tests/cindex/test_code_completion.py Thu Oct 11 04:58:07 2018 @@ -1,3 +1,8 @@ +import os +from clang.cindex import Config +if 'CLANG_LIBRARY_PATH' in os.environ: +Config.set_library_path(os.environ['CLANG_LIBRARY_PATH']) + from clang.cindex import TranslationUnit import unit
r344241 - [tests] Include Python binding tests in CMake rules
Author: mgorny Date: Thu Oct 11 04:58:14 2018 New Revision: 344241 URL: http://llvm.org/viewvc/llvm-project?rev=344241&view=rev Log: [tests] Include Python binding tests in CMake rules Add a new CMake rule check-clang-python to run the Python bindings' test suite, and include it in check-all. Differential Revision: https://reviews.llvm.org/D52840 Added: cfe/trunk/bindings/python/tests/CMakeLists.txt Modified: cfe/trunk/CMakeLists.txt Modified: cfe/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=344241&r1=344240&r2=344241&view=diff == --- cfe/trunk/CMakeLists.txt (original) +++ cfe/trunk/CMakeLists.txt Thu Oct 11 04:58:14 2018 @@ -502,6 +502,7 @@ if( CLANG_INCLUDE_TESTS ) ) endif() add_subdirectory(utils/perf-training) + add_subdirectory(bindings/python/tests) endif() option(CLANG_INCLUDE_DOCS "Generate build targets for the Clang docs." Added: cfe/trunk/bindings/python/tests/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/CMakeLists.txt?rev=344241&view=auto == --- cfe/trunk/bindings/python/tests/CMakeLists.txt (added) +++ cfe/trunk/bindings/python/tests/CMakeLists.txt Thu Oct 11 04:58:14 2018 @@ -0,0 +1,7 @@ +# Test target to run Python test suite from main build. + +add_custom_target(check-clang-python + COMMAND CLANG_LIBRARY_PATH=$ ${PYTHON_EXECUTABLE} -m unittest discover + DEPENDS libclang + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..) +add_dependencies(check-all check-clang-python) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52840: Include Python binding tests in CMake rules
This revision was automatically updated to reflect the committed changes. Closed by commit rL344241: [tests] Include Python binding tests in CMake rules (authored by mgorny, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D52840?vs=168147&id=169194#toc Repository: rL LLVM https://reviews.llvm.org/D52840 Files: cfe/trunk/CMakeLists.txt cfe/trunk/bindings/python/tests/CMakeLists.txt Index: cfe/trunk/CMakeLists.txt === --- cfe/trunk/CMakeLists.txt +++ cfe/trunk/CMakeLists.txt @@ -502,6 +502,7 @@ ) endif() add_subdirectory(utils/perf-training) + add_subdirectory(bindings/python/tests) endif() option(CLANG_INCLUDE_DOCS "Generate build targets for the Clang docs." Index: cfe/trunk/bindings/python/tests/CMakeLists.txt === --- cfe/trunk/bindings/python/tests/CMakeLists.txt +++ cfe/trunk/bindings/python/tests/CMakeLists.txt @@ -0,0 +1,7 @@ +# Test target to run Python test suite from main build. + +add_custom_target(check-clang-python + COMMAND CLANG_LIBRARY_PATH=$ ${PYTHON_EXECUTABLE} -m unittest discover + DEPENDS libclang + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..) +add_dependencies(check-all check-clang-python) Index: cfe/trunk/CMakeLists.txt === --- cfe/trunk/CMakeLists.txt +++ cfe/trunk/CMakeLists.txt @@ -502,6 +502,7 @@ ) endif() add_subdirectory(utils/perf-training) + add_subdirectory(bindings/python/tests) endif() option(CLANG_INCLUDE_DOCS "Generate build targets for the Clang docs." Index: cfe/trunk/bindings/python/tests/CMakeLists.txt === --- cfe/trunk/bindings/python/tests/CMakeLists.txt +++ cfe/trunk/bindings/python/tests/CMakeLists.txt @@ -0,0 +1,7 @@ +# Test target to run Python test suite from main build. + +add_custom_target(check-clang-python + COMMAND CLANG_LIBRARY_PATH=$ ${PYTHON_EXECUTABLE} -m unittest discover + DEPENDS libclang + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..) +add_dependencies(check-all check-clang-python) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52806: [python] [tests] Support overriding library path via environment
This revision was automatically updated to reflect the committed changes. Closed by commit rL344240: [python] [tests] Support overriding library path via environment (authored by mgorny, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D52806?vs=168079&id=169195#toc Repository: rL LLVM https://reviews.llvm.org/D52806 Files: cfe/trunk/bindings/python/README.txt cfe/trunk/bindings/python/tests/cindex/test_access_specifiers.py cfe/trunk/bindings/python/tests/cindex/test_cdb.py cfe/trunk/bindings/python/tests/cindex/test_code_completion.py cfe/trunk/bindings/python/tests/cindex/test_comment.py cfe/trunk/bindings/python/tests/cindex/test_cursor.py cfe/trunk/bindings/python/tests/cindex/test_cursor_kind.py cfe/trunk/bindings/python/tests/cindex/test_diagnostics.py cfe/trunk/bindings/python/tests/cindex/test_exception_specification_kind.py cfe/trunk/bindings/python/tests/cindex/test_file.py cfe/trunk/bindings/python/tests/cindex/test_index.py cfe/trunk/bindings/python/tests/cindex/test_linkage.py cfe/trunk/bindings/python/tests/cindex/test_location.py cfe/trunk/bindings/python/tests/cindex/test_tls_kind.py cfe/trunk/bindings/python/tests/cindex/test_token_kind.py cfe/trunk/bindings/python/tests/cindex/test_tokens.py cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py cfe/trunk/bindings/python/tests/cindex/test_type.py Index: cfe/trunk/bindings/python/README.txt === --- cfe/trunk/bindings/python/README.txt +++ cfe/trunk/bindings/python/README.txt @@ -4,12 +4,12 @@ This directory implements Python bindings for Clang. -You may need to alter LD_LIBRARY_PATH so that the Clang library can be +You may need to set CLANG_LIBRARY_PATH so that the Clang library can be found. The unit tests are designed to be run with any standard test runner. For example: -- $ env PYTHONPATH=$(echo ~/llvm/tools/clang/bindings/python/) \ - LD_LIBRARY_PATH=$(llvm-config --libdir) \ + CLANG_LIBRARY_PATH=$(llvm-config --libdir) \ python -m unittest discover -v tests.cindex.test_index.test_create ... ok ... Index: cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py === --- cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py +++ cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py @@ -1,3 +1,8 @@ +import os +from clang.cindex import Config +if 'CLANG_LIBRARY_PATH' in os.environ: +Config.set_library_path(os.environ['CLANG_LIBRARY_PATH']) + from contextlib import contextmanager import gc import os Index: cfe/trunk/bindings/python/tests/cindex/test_cdb.py === --- cfe/trunk/bindings/python/tests/cindex/test_cdb.py +++ cfe/trunk/bindings/python/tests/cindex/test_cdb.py @@ -1,3 +1,8 @@ +import os +from clang.cindex import Config +if 'CLANG_LIBRARY_PATH' in os.environ: +Config.set_library_path(os.environ['CLANG_LIBRARY_PATH']) + from clang.cindex import CompilationDatabase from clang.cindex import CompilationDatabaseError from clang.cindex import CompileCommands Index: cfe/trunk/bindings/python/tests/cindex/test_token_kind.py === --- cfe/trunk/bindings/python/tests/cindex/test_token_kind.py +++ cfe/trunk/bindings/python/tests/cindex/test_token_kind.py @@ -1,3 +1,8 @@ +import os +from clang.cindex import Config +if 'CLANG_LIBRARY_PATH' in os.environ: +Config.set_library_path(os.environ['CLANG_LIBRARY_PATH']) + from clang.cindex import TokenKind import unittest Index: cfe/trunk/bindings/python/tests/cindex/test_cursor_kind.py === --- cfe/trunk/bindings/python/tests/cindex/test_cursor_kind.py +++ cfe/trunk/bindings/python/tests/cindex/test_cursor_kind.py @@ -1,3 +1,8 @@ +import os +from clang.cindex import Config +if 'CLANG_LIBRARY_PATH' in os.environ: +Config.set_library_path(os.environ['CLANG_LIBRARY_PATH']) + from clang.cindex import CursorKind import unittest Index: cfe/trunk/bindings/python/tests/cindex/test_type.py === --- cfe/trunk/bindings/python/tests/cindex/test_type.py +++ cfe/trunk/bindings/python/tests/cindex/test_type.py @@ -1,3 +1,8 @@ +import os +from clang.cindex import Config +if 'CLANG_LIBRARY_PATH' in os.environ: +Config.set_library_path(os.environ['CLANG_LIBRARY_PATH']) + import gc import unittest Index: cfe/trunk/bindings/python/tests/cindex/test_file.py === --- cfe/trunk/bindings/python/tests/cindex/test_file.py +++ cfe/trunk/bindings/python/tests/cindex/test_file.py @@ -1,3 +1,8 @@ +import os +from clang.cindex import Config +if 'CLANG_LIBRARY_PATH' in os.environ: +Config.set_libr
r344242 - [analyzer][UninitializedObjectChecker] Reports Loc fields pointing to themselves
Author: szelethus Date: Thu Oct 11 04:58:53 2018 New Revision: 344242 URL: http://llvm.org/viewvc/llvm-project?rev=344242&view=rev Log: [analyzer][UninitializedObjectChecker] Reports Loc fields pointing to themselves I've added a new functionality, the checker is now able to detect and report fields pointing to themselves. I figured this would fit well into the checker as there's no reason for a pointer to point to itself instead of being nullptr. Differential Revision: https://reviews.llvm.org/D51305 Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp cfe/trunk/test/Analysis/cxx-uninitialized-object-ptr-ref.cpp Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp?rev=344242&r1=344241&r2=344242&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp Thu Oct 11 04:58:53 2018 @@ -89,15 +89,39 @@ public: } }; +/// Represents a Loc field that points to itself. +class CyclicLocField final : public FieldNode { + +public: + CyclicLocField(const FieldRegion *FR) : FieldNode(FR) {} + + virtual void printNoteMsg(llvm::raw_ostream &Out) const override { +Out << "object references itself "; + } + + virtual void printPrefix(llvm::raw_ostream &Out) const override {} + + virtual void printNode(llvm::raw_ostream &Out) const override { +Out << getVariableName(getDecl()); + } + + virtual void printSeparator(llvm::raw_ostream &Out) const override { +llvm_unreachable("CyclicLocField objects must be the last node of the " + "fieldchain!"); + } +}; + } // end of anonymous namespace // Utility function declarations. -/// Returns whether \p T can be (transitively) dereferenced to a void pointer -/// type (void*, void**, ...). -static bool isVoidPointer(QualType T); - -using DereferenceInfo = std::pair; +struct DereferenceInfo { + const TypedValueRegion *R; + const bool NeedsCastBack; + const bool IsCyclic; + DereferenceInfo(const TypedValueRegion *R, bool NCB, bool IC) + : R(R), NeedsCastBack(NCB), IsCyclic(IC) {} +}; /// Dereferences \p FR and returns with the pointee's region, and whether it /// needs to be casted back to it's location type. If for whatever reason @@ -105,6 +129,10 @@ using DereferenceInfo = std::pair dereference(ProgramStateRef State, const FieldRegion *FR); +/// Returns whether \p T can be (transitively) dereferenced to a void pointer +/// type (void*, void**, ...). +static bool isVoidPointer(QualType T); + //===--===// // Methods for FindUninitializedFields. //===--===// @@ -141,8 +169,11 @@ bool FindUninitializedFields::isDerefere return false; } - const TypedValueRegion *R = DerefInfo->first; - const bool NeedsCastBack = DerefInfo->second; + if (DerefInfo->IsCyclic) +return addFieldToUninits(LocalChain.add(CyclicLocField(FR))); + + const TypedValueRegion *R = DerefInfo->R; + const bool NeedsCastBack = DerefInfo->NeedsCastBack; QualType DynT = R->getLocationType(); QualType PointeeT = DynT->getPointeeType(); @@ -189,15 +220,6 @@ bool FindUninitializedFields::isDerefere // Utility functions. //===--===// -static bool isVoidPointer(QualType T) { - while (!T.isNull()) { -if (T->isVoidPointerType()) - return true; -T = T->getPointeeType(); - } - return false; -} - static llvm::Optional dereference(ProgramStateRef State, const FieldRegion *FR) { @@ -229,9 +251,8 @@ static llvm::Optional d return None; // We found a cyclic pointer, like int *ptr = (int *)&ptr. -// TODO: Should we report these fields too? if (!VisitedRegions.insert(R).second) - return None; + return DereferenceInfo{R, NeedsCastBack, /*IsCyclic*/ true}; DynT = R->getLocationType(); // In order to ensure that this loop terminates, we're also checking the @@ -248,5 +269,14 @@ static llvm::Optional d R = R->getSuperRegion()->getAs(); } - return std::make_pair(R, NeedsCastBack); + return DereferenceInfo{R, NeedsCastBack, /*IsCyclic*/ false}; +} + +static bool isVoidPointer(QualType T) { + while (!T.isNull()) { +if (T->isVoidPointerType()) + return true; +T = T->getPointeeType(); + } + return false; } Modified: cfe/trunk/test/Analysis/cxx-uninitialized-object-ptr-ref.cpp URL: ht
[PATCH] D52840: Include Python binding tests in CMake rules
Szelethus added a comment. I'm afraid this may have broken many buildbots, I'm having issues building from scratch. Can you please take a look? Repository: rL LLVM https://reviews.llvm.org/D52840 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53135: Remove top-level using declaration from header files, as these aliases leak.
sammccall created this revision. sammccall added a reviewer: ilya-biryukov. Herald added subscribers: cfe-commits, arphaman. Repository: rC Clang https://reviews.llvm.org/D53135 Files: include/clang/Driver/Job.h include/clang/Frontend/PCHContainerOperations.h include/clang/Serialization/GlobalModuleIndex.h lib/Frontend/FrontendAction.cpp lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h utils/TableGen/TableGenBackends.h Index: utils/TableGen/TableGenBackends.h === --- utils/TableGen/TableGenBackends.h +++ utils/TableGen/TableGenBackends.h @@ -23,63 +23,60 @@ class RecordKeeper; } -using llvm::raw_ostream; -using llvm::RecordKeeper; - namespace clang { -void EmitClangDeclContext(RecordKeeper &RK, raw_ostream &OS); -void EmitClangASTNodes(RecordKeeper &RK, raw_ostream &OS, +void EmitClangDeclContext(llvm::RecordKeeper &RK, llvm::raw_ostream &OS); +void EmitClangASTNodes(llvm::RecordKeeper &RK, llvm::raw_ostream &OS, const std::string &N, const std::string &S); -void EmitClangAttrParserStringSwitches(RecordKeeper &Records, raw_ostream &OS); -void EmitClangAttrSubjectMatchRulesParserStringSwitches(RecordKeeper &Records, -raw_ostream &OS); -void EmitClangAttrClass(RecordKeeper &Records, raw_ostream &OS); -void EmitClangAttrImpl(RecordKeeper &Records, raw_ostream &OS); -void EmitClangAttrList(RecordKeeper &Records, raw_ostream &OS); -void EmitClangAttrSubjectMatchRuleList(RecordKeeper &Records, raw_ostream &OS); -void EmitClangAttrPCHRead(RecordKeeper &Records, raw_ostream &OS); -void EmitClangAttrPCHWrite(RecordKeeper &Records, raw_ostream &OS); -void EmitClangAttrHasAttrImpl(RecordKeeper &Records, raw_ostream &OS); -void EmitClangAttrSpellingListIndex(RecordKeeper &Records, raw_ostream &OS); -void EmitClangAttrASTVisitor(RecordKeeper &Records, raw_ostream &OS); -void EmitClangAttrTemplateInstantiate(RecordKeeper &Records, raw_ostream &OS); -void EmitClangAttrParsedAttrList(RecordKeeper &Records, raw_ostream &OS); -void EmitClangAttrParsedAttrImpl(RecordKeeper &Records, raw_ostream &OS); -void EmitClangAttrParsedAttrKinds(RecordKeeper &Records, raw_ostream &OS); -void EmitClangAttrDump(RecordKeeper &Records, raw_ostream &OS); - -void EmitClangDiagsDefs(RecordKeeper &Records, raw_ostream &OS, +void EmitClangAttrParserStringSwitches(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangAttrSubjectMatchRulesParserStringSwitches(llvm::RecordKeeper &Records, +llvm::raw_ostream &OS); +void EmitClangAttrClass(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangAttrImpl(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangAttrList(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangAttrSubjectMatchRuleList(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangAttrPCHRead(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangAttrPCHWrite(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangAttrHasAttrImpl(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangAttrSpellingListIndex(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangAttrASTVisitor(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangAttrTemplateInstantiate(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangAttrParsedAttrList(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangAttrParsedAttrImpl(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangAttrParsedAttrKinds(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangAttrDump(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); + +void EmitClangDiagsDefs(llvm::RecordKeeper &Records, llvm::raw_ostream &OS, const std::string &Component); -void EmitClangDiagGroups(RecordKeeper &Records, raw_ostream &OS); -void EmitClangDiagsIndexName(RecordKeeper &Records, raw_ostream &OS); +void EmitClangDiagGroups(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangDiagsIndexName(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); -void EmitClangSACheckers(RecordKeeper &Records, raw_ostream &OS); +void EmitClangSACheckers(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); -void EmitClangCommentHTMLTags(RecordKeeper &Records, raw_ostream &OS); -void EmitClangCommentHTMLTagsProperties(RecordKeeper &Records, raw_ostream &OS); -void EmitClangCommentHTMLNamedCharacterReferences(RecordKeeper &Records, raw_ostream &OS); +void EmitClangCommentHTMLTags(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangCommentHTMLTagsProperties(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); +void EmitClangCommentHTMLNamedCharacterReferences(llvm::RecordKeeper &Records, llvm::raw_ostream &OS); -void EmitClangCommentCommandInfo
[PATCH] D51725: Allow un-setting the compilation database path
ilya-biryukov added a subscriber: sammccall. ilya-biryukov added a comment. In https://reviews.llvm.org/D51725#1255695, @simark wrote: > But I am wondering what to do with the feature that allows clangd to change > compilation database path using the `didChangeConfiguration` notification. > In my opinion, it's a bug that it's not possible to switch back to use no > explicit compilation database path, so I'd still like to get this patch > merged. Or, if we decide this is really not useful, then it should be > removed. I don't think we should keep the feature in the current state, > either we fix it or remove it. Fair point. The original patch looked scary mostly because of `Optional>`. Many thanks for clearing up your use-case, though. I thought Theia was exclusively using custom directories for compile_commands.json, I didn't know the user had an option to turn this behavior on/off and configure directories explicitly. I would question the usefulness of the option if Theia can live without it, so I'd vouch for removing it. @sammccall, WDYT? Especially wrt to auto-indexing and it being a customizable build directory? > Even if right now it's not very expensive to restart clangd, do you foresee a > situation in the future where it could become more expensive? We should keep clangd restarts fast, I don't see any reason why they should be slow. Changing compile_commands.json files would probably always require both reparsing all the files and reloading all the indexes, so there's little hope we can make clangd faster in those cases, unless we're willing to keep multiple versions of the AST/indexes in memory. > Also, I tried to remove the double Optional and do as you suggested (use the > empty string to mean to use no explicit compilation database path), and in > the end I find it more confusing, because we need special cases at both ends. > When we deserialize the JSON and the value is null, and when storing the > value in DirectoryBasedGlobalCompilationDatabase, where we convert an empty > string to an empty Optional. Yeah, moving this special meaning into all layers was a bad idea. Maybe replace an empty optional with an empty string on deseraizliation? The rest of the code using `Optional` seems fine, it's just the `ClangdConfigurationParamsChange` definition that looks complicated. The code for deserializing would look like this: bool fromJSON(const json::Value &Params, ClangdConfigurationParamsChange &CCPC) { json::ObjectMapper O(Params); if (!O) return ...; if (const Value* CDBPath = Params->get("compilationDatabasePath")) { // Have to update the DB path, CCPC.compilationDatabasePath will have a value. llvm::Optional NewDBPath; if (!fromJSON(CDBPath, NewDBPath)) return false; CCPC.compilationDatabasePath = NewDBPath ? std::move(NewDBPath) : ""; } else { // No need to update DB path, CCPC.compilationDatabasePath will be llvm::None. } ... } Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D51725 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52311: [clangd] Add support for hierarchical documentSymbol
ilya-biryukov added a comment. In https://reviews.llvm.org/D52311#1255876, @simark wrote: > I just tried this, this looks very promising! It should help build our > outline view in a much more robust way than we do currently. > A nit for the final patch, I would suggest omitting the fields that are > optional, like `children` (when the list is empty) and `deprecated`. SG, will do. > In vscode, is there a way to get a tree representation of this data? When I > look at "Go to symbol in File..." (ctrl-shift-o) or the outline view at the > bottom of the file explorer, they are both a flat list. What difference does > this patch make in how vscode shows the data? There's an outline view that shows the tree after this patch. IIRC, the "Go to symbol in File..." also shows the tree view now without the lack of functionality like filtering by name, etc. Overall, the experience with a tree seemed strictly better in all scenarios for me. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D52311 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53131: [clangd] Support scope proximity in code completion.
sammccall added inline comments. Comment at: clangd/CodeComplete.cpp:558 +if (const auto *NS = dyn_cast(Ctx)) + return NS->getQualifiedNameAsString() + "::"; + return llvm::None; does this do the right thing if it's anonymous or inline, or a parent is? For indexing, we call a function in AST.h, we should probably do something similar. The catch is that function relies on NamedDecl::printQualifiedName, maybe we need to factor out the relevant part so we can call it on a DeclContext. Comment at: clangd/CodeComplete.cpp:559 + return NS->getQualifiedNameAsString() + "::"; + return llvm::None; +} shouldn't this be ""? That's a definite scope, not a failure to find one. (It's not a *namespace* scope, but I'm not sure why that's important) Comment at: clangd/Quality.cpp:246 +float QueryScopeProximity::proximity(llvm::StringRef Scope) const { + if (QueryScopes.empty()) If you're going to decide these numbers directly... a) I think you should just return a multiplier here, rather than a 0-1 score b) we should more aggressively downrank non-preferred symbols: currently by only ~1/3 vs symbols from a preferred scopes e.g. I'd suggest returning 1, 2, 1.5, 1, 1, 1.5, 0.3 or similar Comment at: clangd/Quality.cpp:301 +// results can be tricky (e.g. class/function scope), and sema results are +// always in the accessible scope. +SemaScopeProximityScore = 1.0; I don't think "always in the accessible scope" is sufficient justification to give a score of 1. However "we don't load top-level symbols from the preamble" might be? Comment at: clangd/Quality.h:92 + private: +std::vector QueryScopes; +}; hmm, can/should we use FileProximity for this, and just transform the strings? This isn't going to cache for symbols sharing a namespace, isn't going to handle "symbol is in a child namespace of an included namespace", and some other combinations. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53131 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r344244 - Revert r344241 as it broke multiple bots.
Author: aaronballman Date: Thu Oct 11 05:57:29 2018 New Revision: 344244 URL: http://llvm.org/viewvc/llvm-project?rev=344244&view=rev Log: Revert r344241 as it broke multiple bots. http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/10814 http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/20613 Removed: cfe/trunk/bindings/python/tests/CMakeLists.txt Modified: cfe/trunk/CMakeLists.txt Modified: cfe/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=344244&r1=344243&r2=344244&view=diff == --- cfe/trunk/CMakeLists.txt (original) +++ cfe/trunk/CMakeLists.txt Thu Oct 11 05:57:29 2018 @@ -502,7 +502,6 @@ if( CLANG_INCLUDE_TESTS ) ) endif() add_subdirectory(utils/perf-training) - add_subdirectory(bindings/python/tests) endif() option(CLANG_INCLUDE_DOCS "Generate build targets for the Clang docs." Removed: cfe/trunk/bindings/python/tests/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/CMakeLists.txt?rev=344243&view=auto == --- cfe/trunk/bindings/python/tests/CMakeLists.txt (original) +++ cfe/trunk/bindings/python/tests/CMakeLists.txt (removed) @@ -1,7 +0,0 @@ -# Test target to run Python test suite from main build. - -add_custom_target(check-clang-python - COMMAND CLANG_LIBRARY_PATH=$ ${PYTHON_EXECUTABLE} -m unittest discover - DEPENDS libclang - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..) -add_dependencies(check-all check-clang-python) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D52840: Include Python binding tests in CMake rules
On Thu, Oct 11, 2018 at 8:23 AM Umann Kristóf via Phabricator via llvm-commits wrote: > > Szelethus added a comment. > > I'm afraid this may have broken many buildbots, I'm having issues building > from scratch. Can you please take a look? I've reverted in r344244. ~Aaron ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r344245 - [clangd] Remove no-op crash handler, we never set a crash context.
Author: sammccall Date: Thu Oct 11 06:06:10 2018 New Revision: 344245 URL: http://llvm.org/viewvc/llvm-project?rev=344245&view=rev Log: [clangd] Remove no-op crash handler, we never set a crash context. Summary: I think this was just copied from somewhere with the belief that it actually did some crash handling. Of course the question arises: *should* we set one? I don't think so: - clangd used to crash a lot, now it's pretty stable, because we found and fixed the crashes. I think the long-term effects of crashing hard are good. - the implementation can't do any magic, it just uses longjmp to return without running any destructors by default. This is unsafe in general (e.g. mutexes won't unlock) and will certainly end up leaking memory. Whatever UB caused the crash may still stomp all over global state, etc. I think there's an argument for isolating the background indexer (autoindex) because it's not directly under the user's control, the crash surface is larger, and it doesn't particularly need to interact with the rest of clangd. But there, fork() and communicate through the FS is safer. Reviewers: ioeric, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53034 Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=344245&r1=344244&r2=344245&view=diff == --- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original) +++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Thu Oct 11 06:06:10 2018 @@ -31,7 +31,6 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallVector.h" -#include "llvm/Support/CrashRecoveryContext.h" #include "llvm/Support/raw_ostream.h" #include @@ -141,10 +140,6 @@ ParsedAST::build(std::unique_ptr CICleanup( - Clang.get()); - auto Action = llvm::make_unique(); const FrontendInputFile &MainInput = Clang->getFrontendOpts().Inputs[0]; if (!Action->BeginSourceFile(*Clang, MainInput)) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53034: [clangd] Remove no-op crash handler, we never set a crash context.
This revision was automatically updated to reflect the committed changes. Closed by commit rL344245: [clangd] Remove no-op crash handler, we never set a crash context. (authored by sammccall, committed by ). Herald added a subscriber: llvm-commits. Repository: rL LLVM https://reviews.llvm.org/D53034 Files: clang-tools-extra/trunk/clangd/ClangdUnit.cpp Index: clang-tools-extra/trunk/clangd/ClangdUnit.cpp === --- clang-tools-extra/trunk/clangd/ClangdUnit.cpp +++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp @@ -31,7 +31,6 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallVector.h" -#include "llvm/Support/CrashRecoveryContext.h" #include "llvm/Support/raw_ostream.h" #include @@ -141,10 +140,6 @@ if (!Clang) return llvm::None; - // Recover resources if we crash before exiting this method. - llvm::CrashRecoveryContextCleanupRegistrar CICleanup( - Clang.get()); - auto Action = llvm::make_unique(); const FrontendInputFile &MainInput = Clang->getFrontendOpts().Inputs[0]; if (!Action->BeginSourceFile(*Clang, MainInput)) { Index: clang-tools-extra/trunk/clangd/ClangdUnit.cpp === --- clang-tools-extra/trunk/clangd/ClangdUnit.cpp +++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp @@ -31,7 +31,6 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallVector.h" -#include "llvm/Support/CrashRecoveryContext.h" #include "llvm/Support/raw_ostream.h" #include @@ -141,10 +140,6 @@ if (!Clang) return llvm::None; - // Recover resources if we crash before exiting this method. - llvm::CrashRecoveryContextCleanupRegistrar CICleanup( - Clang.get()); - auto Action = llvm::make_unique(); const FrontendInputFile &MainInput = Clang->getFrontendOpts().Inputs[0]; if (!Action->BeginSourceFile(*Clang, MainInput)) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51725: Allow un-setting the compilation database path
sammccall added a comment. In https://reviews.llvm.org/D51725#1261798, @ilya-biryukov wrote: > In https://reviews.llvm.org/D51725#1255695, @simark wrote: > > > But I am wondering what to do with the feature that allows clangd to change > > compilation database path using the `didChangeConfiguration` notification. > > In my opinion, it's a bug that it's not possible to switch back to use no > > explicit compilation database path, so I'd still like to get this patch > > merged. Or, if we decide this is really not useful, then it should be > > removed. I don't think we should keep the feature in the current state, > > either we fix it or remove it. > > > I would question the usefulness of the option if Theia can live without it, > so I'd vouch for removing it. @sammccall, WDYT? Especially wrt to > auto-indexing and it being a customizable build directory? Agree with you both here. Not being able to reset the initial state is weird, but *being able to* is complicated. (Even more so than switching between CDBs). And since switching between CDBs invalidates almost everything, restarting clangd seems like a great simplification if it's viable for you. Supporting a single CDB that's available on startup (either a flag, or maybe more likely set during initialize()?) would be a very useful simplification. (Even if it's not a lot of code, I find myself getting tangled in it often). >> Even if right now it's not very expensive to restart clangd, do you foresee >> a situation in the future where it could become more expensive? > > We should keep clangd restarts fast, I don't see any reason why they should > be slow. Agree, it's important that clangd starts fast for other reasons. And auto-indexing should stop/resume fine. Shutdown is a slightly trickier case: actually doing a clean shutdown may require waiting for e.g. any current AST parse to finish. But if this is a problem, I think you can just send SIGTERM. > Changing compile_commands.json files would probably always require both > reparsing all the files and reloading all the indexes, so there's little hope > we can make clangd faster in those cases, unless we're willing to keep > multiple versions of the AST/indexes in memory. The only thing I think we can gain is if you change CDBs, but actually many of the commands are *completely* identical. Then we could detect it and avoid invalidating ASTs etc for those files. But this seems like a really marginal edge-case. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D51725 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r344246 - [Sema][OpenCL] Improve diagnostics for not viable overloadable function candidates
Author: asavonic Date: Thu Oct 11 06:35:34 2018 New Revision: 344246 URL: http://llvm.org/viewvc/llvm-project?rev=344246&view=rev Log: [Sema][OpenCL] Improve diagnostics for not viable overloadable function candidates Summary: Allowed extension name (that ought to be disabled) printing in the note message. This diagnostic was proposed here: https://reviews.llvm.org/D51341 Reviewers: Anastasia, yaxunl Reviewed By: Anastasia Subscribers: cfe-commits, asavonic, bader Differential Revision: https://reviews.llvm.org/D52292 Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Sema/Sema.cpp cfe/trunk/lib/Sema/SemaOverload.cpp cfe/trunk/test/SemaOpenCL/extension-begin.cl Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=344246&r1=344245&r2=344246&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Oct 11 06:35:34 2018 @@ -3674,7 +3674,7 @@ def warn_diagnose_if_succeeded : Warning def note_ovl_candidate_disabled_by_function_cond_attr : Note< "candidate disabled: %0">; def note_ovl_candidate_disabled_by_extension : Note< -"candidate disabled due to OpenCL extension">; +"candidate unavailable as it requires OpenCL extension '%0' to be disabled">; def err_addrof_function_disabled_by_enable_if_attr : Error< "cannot take address of function %0 because it has one or more " "non-tautological enable_if conditions">; Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=344246&r1=344245&r2=344246&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Thu Oct 11 06:35:34 2018 @@ -8576,6 +8576,21 @@ public: llvm::StringRef getCurrentOpenCLExtension() const { return CurrOpenCLExtension; } + + /// Check if a function declaration \p FD associates with any + /// extensions present in OpenCLDeclExtMap and if so return the + /// extension(s) name(s). + std::string getOpenCLExtensionsFromDeclExtMap(FunctionDecl *FD); + + /// Check if a function type \p FT associates with any + /// extensions present in OpenCLTypeExtMap and if so return the + /// extension(s) name(s). + std::string getOpenCLExtensionsFromTypeExtMap(FunctionType *FT); + + /// Find an extension in an appropriate extension map and return its name + template + std::string getOpenCLExtensionsFromExtMap(T* FT, MapT &Map); + void setCurrentOpenCLExtension(llvm::StringRef Ext) { CurrOpenCLExtension = Ext; } Modified: cfe/trunk/lib/Sema/Sema.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=344246&r1=344245&r2=344246&view=diff == --- cfe/trunk/lib/Sema/Sema.cpp (original) +++ cfe/trunk/lib/Sema/Sema.cpp Thu Oct 11 06:35:34 2018 @@ -1914,6 +1914,34 @@ void Sema::setCurrentOpenCLExtensionForD setOpenCLExtensionForDecl(D, CurrOpenCLExtension); } +std::string Sema::getOpenCLExtensionsFromDeclExtMap(FunctionDecl *FD) { + if (!OpenCLDeclExtMap.empty()) +return getOpenCLExtensionsFromExtMap(FD, OpenCLDeclExtMap); + + return ""; +} + +std::string Sema::getOpenCLExtensionsFromTypeExtMap(FunctionType *FT) { + if (!OpenCLTypeExtMap.empty()) +return getOpenCLExtensionsFromExtMap(FT, OpenCLTypeExtMap); + + return ""; +} + +template +std::string Sema::getOpenCLExtensionsFromExtMap(T *FDT, MapT &Map) { + std::string ExtensionNames = ""; + auto Loc = Map.find(FDT); + + for (auto const& I : Loc->second) { +ExtensionNames += I; +ExtensionNames += " "; + } + ExtensionNames.pop_back(); + + return ExtensionNames; +} + bool Sema::isOpenCLDisabledDecl(Decl *FD) { auto Loc = OpenCLDeclExtMap.find(FD); if (Loc == OpenCLDeclExtMap.end()) Modified: cfe/trunk/lib/Sema/SemaOverload.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=344246&r1=344245&r2=344246&view=diff == --- cfe/trunk/lib/Sema/SemaOverload.cpp (original) +++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Oct 11 06:35:34 2018 @@ -10242,7 +10242,8 @@ static void DiagnoseOpenCLExtensionDisab FunctionDecl *Callee = Cand->Function; S.Diag(Callee->getLocation(), - diag::note_ovl_candidate_disabled_by_extension); + diag::note_ovl_candidate_disabled_by_extension) +<< S.getOpenCLExtensionsFromDeclExtMap(Callee); } /// Generates a 'note' diagnostic for an overload candidate. We've Modified: cfe/trunk/test/SemaOpenCL/extension-begin.cl URL: http://llvm
[PATCH] D52292: [Sema][OpenCL] Improve diagnostics for not viable overloadable function candidates
This revision was automatically updated to reflect the committed changes. Closed by commit rC344246: [Sema][OpenCL] Improve diagnostics for not viable overloadable function… (authored by asavonic, committed by ). Repository: rC Clang https://reviews.llvm.org/D52292 Files: include/clang/Basic/DiagnosticSemaKinds.td include/clang/Sema/Sema.h lib/Sema/Sema.cpp lib/Sema/SemaOverload.cpp test/SemaOpenCL/extension-begin.cl Index: include/clang/Sema/Sema.h === --- include/clang/Sema/Sema.h +++ include/clang/Sema/Sema.h @@ -8576,6 +8576,21 @@ llvm::StringRef getCurrentOpenCLExtension() const { return CurrOpenCLExtension; } + + /// Check if a function declaration \p FD associates with any + /// extensions present in OpenCLDeclExtMap and if so return the + /// extension(s) name(s). + std::string getOpenCLExtensionsFromDeclExtMap(FunctionDecl *FD); + + /// Check if a function type \p FT associates with any + /// extensions present in OpenCLTypeExtMap and if so return the + /// extension(s) name(s). + std::string getOpenCLExtensionsFromTypeExtMap(FunctionType *FT); + + /// Find an extension in an appropriate extension map and return its name + template + std::string getOpenCLExtensionsFromExtMap(T* FT, MapT &Map); + void setCurrentOpenCLExtension(llvm::StringRef Ext) { CurrOpenCLExtension = Ext; } Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -3674,7 +3674,7 @@ def note_ovl_candidate_disabled_by_function_cond_attr : Note< "candidate disabled: %0">; def note_ovl_candidate_disabled_by_extension : Note< -"candidate disabled due to OpenCL extension">; +"candidate unavailable as it requires OpenCL extension '%0' to be disabled">; def err_addrof_function_disabled_by_enable_if_attr : Error< "cannot take address of function %0 because it has one or more " "non-tautological enable_if conditions">; Index: test/SemaOpenCL/extension-begin.cl === --- test/SemaOpenCL/extension-begin.cl +++ test/SemaOpenCL/extension-begin.cl @@ -48,7 +48,7 @@ PointerOfA test_A_pointer; // expected-error {{use of type 'PointerOfA' (aka 'const struct A *') requires my_ext extension to be enabled}} f(); // expected-error {{use of declaration 'f' requires my_ext extension to be enabled}} g(0); // expected-error {{no matching function for call to 'g'}} -// expected-note@-26 {{candidate disabled due to OpenCL extension}} +// expected-note@-26 {{candidate unavailable as it requires OpenCL extension 'my_ext' to be disabled}} // expected-note@-22 {{candidate function not viable: requires 0 arguments, but 1 was provided}} } Index: lib/Sema/SemaOverload.cpp === --- lib/Sema/SemaOverload.cpp +++ lib/Sema/SemaOverload.cpp @@ -10242,7 +10242,8 @@ FunctionDecl *Callee = Cand->Function; S.Diag(Callee->getLocation(), - diag::note_ovl_candidate_disabled_by_extension); + diag::note_ovl_candidate_disabled_by_extension) +<< S.getOpenCLExtensionsFromDeclExtMap(Callee); } /// Generates a 'note' diagnostic for an overload candidate. We've Index: lib/Sema/Sema.cpp === --- lib/Sema/Sema.cpp +++ lib/Sema/Sema.cpp @@ -1914,6 +1914,34 @@ setOpenCLExtensionForDecl(D, CurrOpenCLExtension); } +std::string Sema::getOpenCLExtensionsFromDeclExtMap(FunctionDecl *FD) { + if (!OpenCLDeclExtMap.empty()) +return getOpenCLExtensionsFromExtMap(FD, OpenCLDeclExtMap); + + return ""; +} + +std::string Sema::getOpenCLExtensionsFromTypeExtMap(FunctionType *FT) { + if (!OpenCLTypeExtMap.empty()) +return getOpenCLExtensionsFromExtMap(FT, OpenCLTypeExtMap); + + return ""; +} + +template +std::string Sema::getOpenCLExtensionsFromExtMap(T *FDT, MapT &Map) { + std::string ExtensionNames = ""; + auto Loc = Map.find(FDT); + + for (auto const& I : Loc->second) { +ExtensionNames += I; +ExtensionNames += " "; + } + ExtensionNames.pop_back(); + + return ExtensionNames; +} + bool Sema::isOpenCLDisabledDecl(Decl *FD) { auto Loc = OpenCLDeclExtMap.find(FD); if (Loc == OpenCLDeclExtMap.end()) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r344247 - [Tooling] Move CompilationDatabasePlugin to the Registry header, where it's useful. NFC
Author: sammccall Date: Thu Oct 11 06:42:53 2018 New Revision: 344247 URL: http://llvm.org/viewvc/llvm-project?rev=344247&view=rev Log: [Tooling] Move CompilationDatabasePlugin to the Registry header, where it's useful. NFC Modified: cfe/trunk/include/clang/Tooling/CompilationDatabase.h cfe/trunk/include/clang/Tooling/CompilationDatabasePluginRegistry.h Modified: cfe/trunk/include/clang/Tooling/CompilationDatabase.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/CompilationDatabase.h?rev=344247&r1=344246&r2=344247&view=diff == --- cfe/trunk/include/clang/Tooling/CompilationDatabase.h (original) +++ cfe/trunk/include/clang/Tooling/CompilationDatabase.h Thu Oct 11 06:42:53 2018 @@ -141,27 +141,6 @@ public: virtual std::vector getAllCompileCommands() const; }; -/// Interface for compilation database plugins. -/// -/// A compilation database plugin allows the user to register custom compilation -/// databases that are picked up as compilation database if the corresponding -/// library is linked in. To register a plugin, declare a static variable like: -/// -/// \code -/// static CompilationDatabasePluginRegistry::Add -/// X("my-compilation-database", "Reads my own compilation database"); -/// \endcode -class CompilationDatabasePlugin { -public: - virtual ~CompilationDatabasePlugin(); - - /// Loads a compilation database from a build directory. - /// - /// \see CompilationDatabase::loadFromDirectory(). - virtual std::unique_ptr - loadFromDirectory(StringRef Directory, std::string &ErrorMessage) = 0; -}; - /// A compilation database that returns a single compile command line. /// /// Useful when we want a tool to behave more like a compiler invocation. Modified: cfe/trunk/include/clang/Tooling/CompilationDatabasePluginRegistry.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/CompilationDatabasePluginRegistry.h?rev=344247&r1=344246&r2=344247&view=diff == --- cfe/trunk/include/clang/Tooling/CompilationDatabasePluginRegistry.h (original) +++ cfe/trunk/include/clang/Tooling/CompilationDatabasePluginRegistry.h Thu Oct 11 06:42:53 2018 @@ -16,6 +16,27 @@ namespace clang { namespace tooling { +/// Interface for compilation database plugins. +/// +/// A compilation database plugin allows the user to register custom compilation +/// databases that are picked up as compilation database if the corresponding +/// library is linked in. To register a plugin, declare a static variable like: +/// +/// \code +/// static CompilationDatabasePluginRegistry::Add +/// X("my-compilation-database", "Reads my own compilation database"); +/// \endcode +class CompilationDatabasePlugin { +public: + virtual ~CompilationDatabasePlugin(); + + /// Loads a compilation database from a build directory. + /// + /// \see CompilationDatabase::loadFromDirectory(). + virtual std::unique_ptr + loadFromDirectory(StringRef Directory, std::string &ErrorMessage) = 0; +}; + using CompilationDatabasePluginRegistry = llvm::Registry; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51340: Add /Zc:DllexportInlines option to clang-cl
hans added inline comments. Comment at: clang/lib/Sema/SemaDecl.cpp:11976 + +while (FD && !getDLLAttr(FD) && + !FD->hasAttr() && takuto.ikuta wrote: > hans wrote: > > Why does this need to be a loop? I don't think FunctionDecl's can be nested? > This is for static local var in lambda function. > static_x's ParentFunction does not become f(). > ``` > class __declspec(dllexport) C { > int f() { > return ([]() { static int static_x; return ++static_x; })(); > } > }; > ``` I don't think the lambda (or its static local) should be exported in this case. Comment at: clang/lib/Sema/SemaDecl.cpp:11995 + +// Function having static local variables should be exported. +auto *ExportAttr = cast(NewAttr->clone(getASTContext())); takuto.ikuta wrote: > hans wrote: > > Isn't it enough that the static local is exported, does the function itself > > need to be exported too? > Adding dllexport only to variable does not export variable when the function > is not used. > But dllimport is not necessary for function, removed. Hmm, I wonder if we could fix that instead? That is, export the variable in that case even if the function is not used? Comment at: clang/lib/Sema/SemaDeclCXX.cpp:5719 + TSK != TSK_ExplicitInstantiationDeclaration && + TSK != TSK_ExplicitInstantiationDefinition) { +if (ClassExported) { I still don't understand why we need these checks for template instantiations. Why does it matter whether the functions get inlined or not? https://reviews.llvm.org/D51340 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53138: Scalable type size queries (clang)
huntergr created this revision. Initial changes for clang to use the scalable type size queries (https://reviews.llvm.org/D53137) This isn't ready for inclusion yet, more discussion on the mailing list required. https://reviews.llvm.org/D53138 Files: lib/CodeGen/CGBuiltin.cpp lib/CodeGen/CGExprScalar.cpp lib/CodeGen/CGStmt.cpp lib/CodeGen/TargetInfo.cpp Index: lib/CodeGen/TargetInfo.cpp === --- lib/CodeGen/TargetInfo.cpp +++ lib/CodeGen/TargetInfo.cpp @@ -890,9 +890,10 @@ /// IsX86_MMXType - Return true if this is an MMX type. bool IsX86_MMXType(llvm::Type *IRType) { // Return true if the type is an MMX type <2 x i32>, <4 x i16>, or <8 x i8>. - return IRType->isVectorTy() && IRType->getPrimitiveSizeInBits() == 64 && -cast(IRType)->getElementType()->isIntegerTy() && -IRType->getScalarSizeInBits() != 64; + auto Size = IRType->getScalableSizeInBits(); + return IRType->isVectorTy() && Size.Scaled == 0 && +Size.Unscaled == 64 && IRType->getScalarSizeInBits() != 64 && +cast(IRType)->getElementType()->isIntegerTy(); } static llvm::Type* X86AdjustInlineAsmType(CodeGen::CodeGenFunction &CGF, Index: lib/CodeGen/CGStmt.cpp === --- lib/CodeGen/CGStmt.cpp +++ lib/CodeGen/CGStmt.cpp @@ -1985,7 +1985,7 @@ // Update largest vector width for any vector types. if (auto *VT = dyn_cast(ResultRegTypes.back())) LargestVectorWidth = std::max(LargestVectorWidth, - VT->getPrimitiveSizeInBits()); + VT->getScalableSizeInBits().Unscaled); } else { ArgTypes.push_back(Dest.getAddress().getType()); Args.push_back(Dest.getPointer()); @@ -2010,7 +2010,7 @@ // Update largest vector width for any vector types. if (auto *VT = dyn_cast(Arg->getType())) LargestVectorWidth = std::max(LargestVectorWidth, - VT->getPrimitiveSizeInBits()); + VT->getScalableSizeInBits().Unscaled); if (Info.allowsRegister()) InOutConstraints += llvm::utostr(i); else @@ -2094,7 +2094,7 @@ // Update largest vector width for any vector types. if (auto *VT = dyn_cast(Arg->getType())) LargestVectorWidth = std::max(LargestVectorWidth, -VT->getPrimitiveSizeInBits()); +VT->getScalableSizeInBits().Unscaled); ArgTypes.push_back(Arg->getType()); Args.push_back(Arg); Index: lib/CodeGen/CGExprScalar.cpp === --- lib/CodeGen/CGExprScalar.cpp +++ lib/CodeGen/CGExprScalar.cpp @@ -1079,8 +1079,8 @@ if (isa(SrcTy) || isa(DstTy)) { // Allow bitcast from vector to integer/fp of the same size. -unsigned SrcSize = SrcTy->getPrimitiveSizeInBits(); -unsigned DstSize = DstTy->getPrimitiveSizeInBits(); +auto SrcSize = SrcTy->getScalableSizeInBits(); +auto DstSize = DstTy->getScalableSizeInBits(); if (SrcSize == DstSize) return Builder.CreateBitCast(Src, DstTy, "conv"); Index: lib/CodeGen/CGBuiltin.cpp === --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -4790,8 +4790,8 @@ for (Function::const_arg_iterator ai = F->arg_begin(), ae = F->arg_end(); ai != ae; ++ai, ++j) { llvm::Type *ArgTy = ai->getType(); -if (Ops[j]->getType()->getPrimitiveSizeInBits() == - ArgTy->getPrimitiveSizeInBits()) +if (Ops[j]->getType()->getScalableSizeInBits() == + ArgTy->getScalableSizeInBits()) continue; assert(ArgTy->isVectorTy() && !Ops[j]->getType()->isVectorTy()); @@ -4805,8 +4805,8 @@ Value *Result = CGF.EmitNeonCall(F, Ops, s); llvm::Type *ResultType = CGF.ConvertType(E->getType()); - if (ResultType->getPrimitiveSizeInBits() < - Result->getType()->getPrimitiveSizeInBits()) + if (ResultType->getScalableSizeInBits() < + Result->getType()->getScalableSizeInBits()) return CGF.Builder.CreateExtractElement(Result, C0); return CGF.Builder.CreateBitCast(Result, ResultType, s); @@ -5336,7 +5336,7 @@ case NEON::BI__builtin_neon_vdot_v: case NEON::BI__builtin_neon_vdotq_v: { llvm::Type *InputTy = -llvm::VectorType::get(Int8Ty, Ty->getPrimitiveSizeInBits() / 8); +llvm::VectorType::get(Int8Ty, Ty->getScalableSizeInBits().Unscaled / 8); llvm::Type *Tys[2] = { Ty, InputTy }; Int = Usgn ? LLVMIntrinsic : AltLLVMIntrinsic; return EmitNeonCall(CGM.getIntrinsic(Int, Tys), Ops, "vdot"); @@ -6735,7 +6735,7 @@ case NEON::BI__builtin_neon_vcvts_s32_f32: case NEON::BI__builtin_neon_vcvtd_s64_f64: { Ops.push_back(EmitScalarExpr(E->getArg(0))); -bool Is64 = Ops[0]->getType()->getPrimitiveSizeInBits() == 64; +b
[PATCH] D53102: Support for the mno-tls-direct-seg-refs flag
hans added a comment. Looking good, just a few minor comments. Comment at: docs/ClangCommandLineReference.rst:2241 + +Enable or disable direct TLS access through segment registers + This file is automatically generated based on the options .td files, so no need to update it here. Comment at: include/clang/Driver/CC1Options.td:195 HelpText<"Do not emit code that uses the red zone.">; +def indirect_tls_seg_refs : Flag<["-"], "indirect-tls-seg-refs">, + HelpText<"Do not emit code that uses direct TLS segment access.">; Could mno_tls_direct_seg_refs be used as a cc1 flag instead? Comment at: include/clang/Driver/Options.td:2167 +def mtls_direct_seg_refs : Flag<["-"], "mtls-direct-seg-refs">, Group, + HelpText<"Enable direct TLS access through segment registers">; def mregparm_EQ : Joined<["-"], "mregparm=">, Group; Maybe add (default) to the help text to indicate this is the default? Repository: rC Clang https://reviews.llvm.org/D53102 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52784: [ARM][AArch64] Pass through endianness flags to the GNU assembler
peter.smith added a comment. Thanks for the comments. I agree with you that the -EB and -EL flags need to be passed to the linker as well, I kind of expected that ld.bfd would infer it from the endianness of the first object but it doesn't seem to do that. If it's ok I'll do that in a separate patch? I hope I've been able to explain the test. I'm on the fence about passing in the triple as a parameter, I have a mild preference for the way it is but if you'd like me to change it I can. Comment at: lib/Driver/ToolChains/Gnu.cpp:543-549 +static const char* GetEndianArg(bool IsBigEndian, const ArgList &Args) { + if (Arg *A = Args.getLastArg(options::OPT_mlittle_endian, + options::OPT_mbig_endian)) { + IsBigEndian = !A->getOption().matches(options::OPT_mlittle_endian); + } + return (IsBigEndian) ? "-EB" : "-EL"; +} nickdesaulniers wrote: > If you passed `llvm::Triple` instead of `bool`, then I think you could do > something like: > > ``` > static const char* GetEndianArg(const llvm::Triple &triple, const ArgList > &Args) { > const bool IsBigEndian = triple == llvm::Triple::armeb || >triple == llvm::Triple::thumbeb || >triple == llvm::Triple::aarch64_be || >Args.getLastArg(options::OPT_mlittle_endian, > > options::OPT_mbig_endian)->getOption().matches(options::OPT_mbig_endian); > return IsBigEndian ? "-EB" : "-EL"; > } > ``` > > Might encapsulate the logic from the call sites better, but that's a minor > nit. I did think about separating it from the triple. In the end I thought it best to follow the existing switch on the triple and put up with a bit of duplication. As it stands I think the above wouldn't quite work as we could have --target=armeb-linux-gnueabi -mlittle-endian which would get short-circuited to big endian if all the tests are done at once. I think it would be possible to do something like: ``` bool IsBigEndian = getTriple().getArch() == llvm::Triple::armeb || getTriple().getArch() == llvm::Triple::thumbeb || getTriple().getArch() == llvm::Triple::aarch64_be; if (Arg *A = Args.getLastArg(options::OPT_mlittle_endian, options::OPT_mbig_endian)) IsBigEndian = !A->getOption().matches(options::OPT_mlittle_endian); return IsBigEndian ? "-EB" : "-EL"; ``` but we'd only want to call it for Arm and AArch64 so I don't think it saves us much. Comment at: lib/Driver/ToolChains/Gnu.cpp:544-547 + if (Arg *A = Args.getLastArg(options::OPT_mlittle_endian, + options::OPT_mbig_endian)) { + IsBigEndian = !A->getOption().matches(options::OPT_mlittle_endian); + } nickdesaulniers wrote: > Just so I understand this check, even if we didn't have a BE triple, we set > `IsBigEndian` if `-mlittle-endian` was not set? Is `-mlittle-endian` a > default set flag, or does this set `"-EB"` even if no `-m*-endian` flag is > specified (I think we want little-endian to be the default, and IIUC, this > would change that)? I stole the logic from ToolChain::ComputeLLVMTriple in ToolChain.cpp. On entry to the function IsBigEndian will be set to true if the triple is one of armeb, thumbeb or aarch64eb. Otherwise it will be false. The getLastArg(options::OPT_mlittle_endian, options_mbig_endian) will return NULL if neither was set, so we'd default to the value in the triple. https://reviews.llvm.org/D52784 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52384: [Sema] Fix redeclaration contexts for enumerators in C
aaron.ballman added a comment. Ping https://reviews.llvm.org/D52384 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r344249 - Add support for 'dynamic_allocators' clause on 'requires' directive. Differential Revision: https://reviews.llvm.org/D53079
Author: plyster Date: Thu Oct 11 07:41:10 2018 New Revision: 344249 URL: http://llvm.org/viewvc/llvm-project?rev=344249&view=rev Log: Add support for 'dynamic_allocators' clause on 'requires' directive. Differential Revision: https://reviews.llvm.org/D53079 Modified: cfe/trunk/include/clang/AST/OpenMPClause.h cfe/trunk/include/clang/AST/RecursiveASTVisitor.h cfe/trunk/include/clang/Basic/OpenMPKinds.def cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/AST/OpenMPClause.cpp cfe/trunk/lib/AST/StmtPrinter.cpp cfe/trunk/lib/AST/StmtProfile.cpp cfe/trunk/lib/Basic/OpenMPKinds.cpp cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp cfe/trunk/lib/Parse/ParseOpenMP.cpp cfe/trunk/lib/Sema/SemaOpenMP.cpp cfe/trunk/lib/Sema/TreeTransform.h cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/lib/Serialization/ASTWriter.cpp cfe/trunk/test/OpenMP/requires_unified_address_ast_print.cpp cfe/trunk/test/OpenMP/requires_unified_address_messages.cpp cfe/trunk/tools/libclang/CIndex.cpp Modified: cfe/trunk/include/clang/AST/OpenMPClause.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=344249&r1=344248&r2=344249&view=diff == --- cfe/trunk/include/clang/AST/OpenMPClause.h (original) +++ cfe/trunk/include/clang/AST/OpenMPClause.h Thu Oct 11 07:41:10 2018 @@ -827,6 +827,38 @@ public: } }; +/// This represents 'dynamic_allocators' clause in the '#pragma omp requires' +/// directive. +/// +/// \code +/// #pragma omp requires dynamic_allocators +/// \endcode +/// In this example directive '#pragma omp requires' has 'dynamic_allocators' +/// clause. +class OMPDynamicAllocatorsClause final : public OMPClause { +public: + friend class OMPClauseReader; + /// Build 'dynamic_allocators' clause. + /// + /// \param StartLoc Starting location of the clause. + /// \param EndLoc Ending location of the clause. + OMPDynamicAllocatorsClause(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPClause(OMPC_dynamic_allocators, StartLoc, EndLoc) {} + + /// Build an empty clause. + OMPDynamicAllocatorsClause() + : OMPClause(OMPC_dynamic_allocators, SourceLocation(), SourceLocation()) { + } + + child_range children() { +return child_range(child_iterator(), child_iterator()); + } + + static bool classof(const OMPClause *T) { +return T->getClauseKind() == OMPC_dynamic_allocators; + } +}; + /// This represents 'schedule' clause in the '#pragma omp ...' directive. /// /// \code Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=344249&r1=344248&r2=344249&view=diff == --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original) +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Thu Oct 11 07:41:10 2018 @@ -2880,6 +2880,12 @@ bool RecursiveASTVisitor::Visit } template +bool RecursiveASTVisitor::VisitOMPDynamicAllocatorsClause( +OMPDynamicAllocatorsClause *) { + return true; +} + +template bool RecursiveASTVisitor::VisitOMPScheduleClause(OMPScheduleClause *C) { TRY_TO(VisitOMPClauseWithPreInit(C)); Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.def?rev=344249&r1=344248&r2=344249&view=diff == --- cfe/trunk/include/clang/Basic/OpenMPKinds.def (original) +++ cfe/trunk/include/clang/Basic/OpenMPKinds.def Thu Oct 11 07:41:10 2018 @@ -282,6 +282,7 @@ OPENMP_CLAUSE(in_reduction, OMPInReduct OPENMP_CLAUSE(unified_address, OMPUnifiedAddressClause) OPENMP_CLAUSE(unified_shared_memory, OMPUnifiedSharedMemoryClause) OPENMP_CLAUSE(reverse_offload, OMPReverseOffloadClause) +OPENMP_CLAUSE(dynamic_allocators, OMPDynamicAllocatorsClause) // Clauses allowed for OpenMP directive 'parallel'. OPENMP_PARALLEL_CLAUSE(if) @@ -467,6 +468,7 @@ OPENMP_TARGET_CLAUSE(reduction) OPENMP_REQUIRES_CLAUSE(unified_address) OPENMP_REQUIRES_CLAUSE(unified_shared_memory) OPENMP_REQUIRES_CLAUSE(reverse_offload) +OPENMP_REQUIRES_CLAUSE(dynamic_allocators) // Clauses allowed for OpenMP directive 'target data'. OPENMP_TARGET_DATA_CLAUSE(if) Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=344249&r1=344248&r2=344249&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Thu Oct 11 07:41:10 2018 @@ -9191,6 +9191,10 @@ public: OMPClause *ActOnOpenMPReverseOffloadClause(SourceLocation StartLoc, SourceLocation EndLoc); + /// Called on well-formed 'dynamic_a
[PATCH] D52727: [clang-tidy] White List Option for performance-unnecessary-value-param, performance-unnecessary-copy-initialization and performance-for-range-copy
JonasToth added a comment. LG in principle, just the SmallVec thing could be done if you agree. I don't insist on it, but it looks like a performance benefit to me. Comment at: clang-tidy/performance/UnnecessaryCopyInitialization.h:41 ASTContext &Context); + const std::vector AllowedTypes; }; I think these lists for the allowed types could even be SmallVectors, as I wouldn't expect so many entries. https://reviews.llvm.org/D52727 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52979: [clangd] Add removeFile interface in FileIndex.
hokein added inline comments. Comment at: clangd/index/FileIndex.h:78 + /// Remove all index data associated with the file \p Path. + void removeFile(PathRef Path); + ioeric wrote: > hokein wrote: > > ioeric wrote: > > > should we use this somewhere? E.g. when file is closed in ClangdServer? > > Yes, the usage of this method is not included in this patch. > > > > We probably use this function in `TUScheduler::remove`, the code path will > > be like > > > > `TUScheduler::remove => ParsingCallback::onASTRemove => > > FileIndex::removeFile`. > > > > We need to add a similar interface to `ParsingCallback`. > Or maybe in `ClangdServer::removeDocument`? It seems that we will have problems if calling it in `ClangdServer::removeDocument`. When removing a file, we schedule a remove task in TUScheduler, and the AST thread will wait for all pending tasks to be finished and then exit. An example like: 1. The AST thread has a pending request of update AST task (which will update the FileIndex) in its task queue. 2. We remove the documentation, FileIndex will be cleanup immediately in `ClangdServer::removeDocument`, and clangd schedules a remove task. 3. The AST thread processes all pending tasks (including update AST), and exits, Now the symbol comes back again. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D52979 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51340: Add /Zc:DllexportInlines option to clang-cl
takuto.ikuta added inline comments. Comment at: clang/lib/Sema/SemaDecl.cpp:11976 + +while (FD && !getDLLAttr(FD) && + !FD->hasAttr() && hans wrote: > takuto.ikuta wrote: > > hans wrote: > > > Why does this need to be a loop? I don't think FunctionDecl's can be > > > nested? > > This is for static local var in lambda function. > > static_x's ParentFunction does not become f(). > > ``` > > class __declspec(dllexport) C { > > int f() { > > return ([]() { static int static_x; return ++static_x; })(); > > } > > }; > > ``` > I don't think the lambda (or its static local) should be exported in this > case. If we don't export static_x, dllimport library cannot find static_x when linking? Comment at: clang/lib/Sema/SemaDecl.cpp:11995 + +// Function having static local variables should be exported. +auto *ExportAttr = cast(NewAttr->clone(getASTContext())); hans wrote: > takuto.ikuta wrote: > > hans wrote: > > > Isn't it enough that the static local is exported, does the function > > > itself need to be exported too? > > Adding dllexport only to variable does not export variable when the > > function is not used. > > But dllimport is not necessary for function, removed. > Hmm, I wonder if we could fix that instead? That is, export the variable in > that case even if the function is not used? I see. I'll investigate which code path emits static variables Comment at: clang/lib/Sema/SemaDeclCXX.cpp:5719 + TSK != TSK_ExplicitInstantiationDeclaration && + TSK != TSK_ExplicitInstantiationDefinition) { +if (ClassExported) { hans wrote: > I still don't understand why we need these checks for template > instantiations. Why does it matter whether the functions get inlined or not? When function of dllimported class is not inlined, such funtion needs to be dllexported from implementation library. c.h ``` template class EXPORT C { public: void f() {} }; ``` cuser.cc ``` #include "c.h" void cuser() { C c; c.f(); // This function may not be inlined when EXPORT is __declspec(dllimport), so link may fail. } ``` When cuser.cc and c.h are built to different library, cuser.cc needs to be able to see dllexported C::f() when C::f() is not inlined. This is my understanding. https://reviews.llvm.org/D51340 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53135: Remove top-level using declaration from header files, as these aliases leak.
ilya-biryukov accepted this revision. ilya-biryukov added a comment. This revision is now accepted and ready to land. LGTM Comment at: include/clang/Driver/Job.h:33 // Re-export this as clang::driver::ArgStringList. -using llvm::opt::ArgStringList; +using ArgStringList = llvm::opt::ArgStringList; Both approaches seem equivalent in that case, since we do want the re-export. So not sure we want to change this in the first place. But feel free to keep it too, don't have a strong opinion on this one. Repository: rC Clang https://reviews.llvm.org/D53135 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52840: Include Python binding tests in CMake rules
mgorny updated this revision to Diff 169218. mgorny added a comment. v2: fixed appending to check-all to make it compatible both with in-tree and standalone builds https://reviews.llvm.org/D52840 Files: CMakeLists.txt bindings/python/tests/CMakeLists.txt Index: bindings/python/tests/CMakeLists.txt === --- /dev/null +++ bindings/python/tests/CMakeLists.txt @@ -0,0 +1,8 @@ +# Test target to run Python test suite from main build. + +add_custom_target(check-clang-python + COMMAND CLANG_LIBRARY_PATH=$ ${PYTHON_EXECUTABLE} -m unittest discover + DEPENDS libclang + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..) + +set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_TARGETS check-clang-python) Index: CMakeLists.txt === --- CMakeLists.txt +++ CMakeLists.txt @@ -485,6 +485,7 @@ ) endif() add_subdirectory(test) + add_subdirectory(bindings/python/tests) if(CLANG_BUILT_STANDALONE) # Add a global check rule now that all subdirectories have been traversed @@ -497,7 +498,7 @@ "Running all regression tests" ${LLVM_LIT_TESTSUITES} PARAMS ${LLVM_LIT_PARAMS} - DEPENDS ${LLVM_LIT_DEPENDS} + DEPENDS ${LLVM_LIT_DEPENDS} ${LLVM_ADDITIONAL_TEST_TARGETS} ARGS ${LLVM_LIT_EXTRA_ARGS} ) endif() Index: bindings/python/tests/CMakeLists.txt === --- /dev/null +++ bindings/python/tests/CMakeLists.txt @@ -0,0 +1,8 @@ +# Test target to run Python test suite from main build. + +add_custom_target(check-clang-python + COMMAND CLANG_LIBRARY_PATH=$ ${PYTHON_EXECUTABLE} -m unittest discover + DEPENDS libclang + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..) + +set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_TARGETS check-clang-python) Index: CMakeLists.txt === --- CMakeLists.txt +++ CMakeLists.txt @@ -485,6 +485,7 @@ ) endif() add_subdirectory(test) + add_subdirectory(bindings/python/tests) if(CLANG_BUILT_STANDALONE) # Add a global check rule now that all subdirectories have been traversed @@ -497,7 +498,7 @@ "Running all regression tests" ${LLVM_LIT_TESTSUITES} PARAMS ${LLVM_LIT_PARAMS} - DEPENDS ${LLVM_LIT_DEPENDS} + DEPENDS ${LLVM_LIT_DEPENDS} ${LLVM_ADDITIONAL_TEST_TARGETS} ARGS ${LLVM_LIT_EXTRA_ARGS} ) endif() ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52840: Include Python binding tests in CMake rules
mgorny updated this revision to Diff 169219. mgorny added a comment. v3: one more correction for stand-alone builds. https://reviews.llvm.org/D52840 Files: CMakeLists.txt bindings/python/tests/CMakeLists.txt Index: bindings/python/tests/CMakeLists.txt === --- /dev/null +++ bindings/python/tests/CMakeLists.txt @@ -0,0 +1,8 @@ +# Test target to run Python test suite from main build. + +add_custom_target(check-clang-python + COMMAND CLANG_LIBRARY_PATH=$ ${PYTHON_EXECUTABLE} -m unittest discover + DEPENDS libclang + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..) + +set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_TARGETS check-clang-python) Index: CMakeLists.txt === --- CMakeLists.txt +++ CMakeLists.txt @@ -485,19 +485,22 @@ ) endif() add_subdirectory(test) + add_subdirectory(bindings/python/tests) if(CLANG_BUILT_STANDALONE) # Add a global check rule now that all subdirectories have been traversed # and we know the total set of lit testsuites. get_property(LLVM_LIT_TESTSUITES GLOBAL PROPERTY LLVM_LIT_TESTSUITES) get_property(LLVM_LIT_PARAMS GLOBAL PROPERTY LLVM_LIT_PARAMS) get_property(LLVM_LIT_DEPENDS GLOBAL PROPERTY LLVM_LIT_DEPENDS) get_property(LLVM_LIT_EXTRA_ARGS GLOBAL PROPERTY LLVM_LIT_EXTRA_ARGS) +get_property(LLVM_ADDITIONAL_TEST_TARGETS + GLOBAL PROPERTY LLVM_ADDITIONAL_TEST_TARGETS) add_lit_target(check-all "Running all regression tests" ${LLVM_LIT_TESTSUITES} PARAMS ${LLVM_LIT_PARAMS} - DEPENDS ${LLVM_LIT_DEPENDS} + DEPENDS ${LLVM_LIT_DEPENDS} ${LLVM_ADDITIONAL_TEST_TARGETS} ARGS ${LLVM_LIT_EXTRA_ARGS} ) endif() Index: bindings/python/tests/CMakeLists.txt === --- /dev/null +++ bindings/python/tests/CMakeLists.txt @@ -0,0 +1,8 @@ +# Test target to run Python test suite from main build. + +add_custom_target(check-clang-python + COMMAND CLANG_LIBRARY_PATH=$ ${PYTHON_EXECUTABLE} -m unittest discover + DEPENDS libclang + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..) + +set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_TARGETS check-clang-python) Index: CMakeLists.txt === --- CMakeLists.txt +++ CMakeLists.txt @@ -485,19 +485,22 @@ ) endif() add_subdirectory(test) + add_subdirectory(bindings/python/tests) if(CLANG_BUILT_STANDALONE) # Add a global check rule now that all subdirectories have been traversed # and we know the total set of lit testsuites. get_property(LLVM_LIT_TESTSUITES GLOBAL PROPERTY LLVM_LIT_TESTSUITES) get_property(LLVM_LIT_PARAMS GLOBAL PROPERTY LLVM_LIT_PARAMS) get_property(LLVM_LIT_DEPENDS GLOBAL PROPERTY LLVM_LIT_DEPENDS) get_property(LLVM_LIT_EXTRA_ARGS GLOBAL PROPERTY LLVM_LIT_EXTRA_ARGS) +get_property(LLVM_ADDITIONAL_TEST_TARGETS + GLOBAL PROPERTY LLVM_ADDITIONAL_TEST_TARGETS) add_lit_target(check-all "Running all regression tests" ${LLVM_LIT_TESTSUITES} PARAMS ${LLVM_LIT_PARAMS} - DEPENDS ${LLVM_LIT_DEPENDS} + DEPENDS ${LLVM_LIT_DEPENDS} ${LLVM_ADDITIONAL_TEST_TARGETS} ARGS ${LLVM_LIT_EXTRA_ARGS} ) endif() ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51340: Add /Zc:DllexportInlines option to clang-cl
hans added inline comments. Comment at: clang/lib/Sema/SemaDecl.cpp:11976 + +while (FD && !getDLLAttr(FD) && + !FD->hasAttr() && takuto.ikuta wrote: > hans wrote: > > takuto.ikuta wrote: > > > hans wrote: > > > > Why does this need to be a loop? I don't think FunctionDecl's can be > > > > nested? > > > This is for static local var in lambda function. > > > static_x's ParentFunction does not become f(). > > > ``` > > > class __declspec(dllexport) C { > > > int f() { > > > return ([]() { static int static_x; return ++static_x; })(); > > > } > > > }; > > > ``` > > I don't think the lambda (or its static local) should be exported in this > > case. > If we don't export static_x, dllimport library cannot find static_x when > linking? > > I believe even if C is marked dllimport, the lambda will not be dllimport. The inline definition will be used. Comment at: clang/lib/Sema/SemaDeclCXX.cpp:5719 + TSK != TSK_ExplicitInstantiationDeclaration && + TSK != TSK_ExplicitInstantiationDefinition) { +if (ClassExported) { takuto.ikuta wrote: > hans wrote: > > I still don't understand why we need these checks for template > > instantiations. Why does it matter whether the functions get inlined or not? > When function of dllimported class is not inlined, such funtion needs to be > dllexported from implementation library. > > c.h > ``` > template > class EXPORT C { > public: > void f() {} > }; > ``` > > cuser.cc > ``` > #include "c.h" > > void cuser() { > C c; > c.f(); // This function may not be inlined when EXPORT is > __declspec(dllimport), so link may fail. > } > ``` > > When cuser.cc and c.h are built to different library, cuser.cc needs to be > able to see dllexported C::f() when C::f() is not inlined. > This is my understanding. Your example doesn't use explicit instantiation definition or declaration, so doesn't apply here I think. As long as the dllexport and dllimport attributes matches it's fine. It doesn't matter whether the function gets inlined or not, the only thing that matters is that if it's marked dllimport on the "consumer side", it must be dllexport when building the dll. https://reviews.llvm.org/D51340 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52840: Include Python binding tests in CMake rules
mgorny requested review of this revision. mgorny added a comment. Please review the new version, addressing the issue caught by buildbots. https://reviews.llvm.org/D52840 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52784: [ARM][AArch64] Pass through endianness flags to the GNU assembler
peter.smith added a comment. On reflection after looking at what would be needed for the linker tools::gnutools::Linker::ConstructJob() I think it may be better to move the triple detection into a separate function. I'll work on that and will hopefully post an update soon. https://reviews.llvm.org/D52784 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53085: [clang-doc] Add unit tests for Markdown
juliehockett updated this revision to Diff 169221. juliehockett added a comment. Switching to raw strings. https://reviews.llvm.org/D53085 Files: clang-tools-extra/unittests/clang-doc/CMakeLists.txt clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp Index: clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp === --- /dev/null +++ clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp @@ -0,0 +1,361 @@ +//===-- clang-doc/MDGeneratorTest.cpp -===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "ClangDocTest.h" +#include "Generators.h" +#include "Representation.h" +#include "gtest/gtest.h" + +namespace clang { +namespace doc { + +std::unique_ptr getMDGenerator() { + auto G = doc::findGeneratorByName("md"); + if (!G) +return nullptr; + return std::move(G.get()); +} + +TEST(MDGeneratorTest, emitNamespaceMD) { + NamespaceInfo I; + I.Name = "Namespace"; + I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace); + + I.ChildNamespaces.emplace_back(EmptySID, "ChildNamespace", + InfoType::IT_namespace); + I.ChildRecords.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record); + I.ChildFunctions.emplace_back(); + I.ChildFunctions.back().Name = "OneFunction"; + I.ChildEnums.emplace_back(); + I.ChildEnums.back().Name = "OneEnum"; + + auto G = getMDGenerator(); + assert(G); + std::string Buffer; + llvm::raw_string_ostream Actual(Buffer); + auto Err = G->generateDocForInfo(&I, Actual); + assert(!Err); + std::string Expected = R"raw(# namespace Namespace + + + +## Namespaces + +ChildNamespace + + + +## Records + +ChildStruct + + + +## Functions + +### OneFunction + +* OneFunction()* + + + +## Enums + +| enum OneEnum | + +-- + + + + + +)raw"; + EXPECT_EQ(Expected, Actual.str()); +} + +TEST(MDGeneratorTest, emitRecordMD) { + RecordInfo I; + I.Name = "r"; + I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace); + + I.DefLoc = Location(10, llvm::SmallString<16>("test.cpp")); + I.Loc.emplace_back(12, llvm::SmallString<16>("test.cpp")); + + I.Members.emplace_back("int", "X", AccessSpecifier::AS_private); + I.TagType = TagTypeKind::TTK_Class; + I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record); + I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record); + + I.ChildRecords.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record); + I.ChildFunctions.emplace_back(); + I.ChildFunctions.back().Name = "OneFunction"; + I.ChildEnums.emplace_back(); + I.ChildEnums.back().Name = "OneEnum"; + + auto G = getMDGenerator(); + assert(G); + std::string Buffer; + llvm::raw_string_ostream Actual(Buffer); + auto Err = G->generateDocForInfo(&I, Actual); + assert(!Err); + std::string Expected = R"raw(# class r + +*Defined at line 10 of test.cpp* + +Inherits from F, G + + + +## Members + +private int X + + + +## Records + +ChildStruct + + + +## Functions + +### OneFunction + +* OneFunction()* + + + +## Enums + +| enum OneEnum | + +-- + + + + + +)raw"; + EXPECT_EQ(Expected, Actual.str()); +} + +TEST(MDGeneratorTest, emitFunctionMD) { + FunctionInfo I; + I.Name = "f"; + I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace); + + I.DefLoc = Location(10, llvm::SmallString<16>("test.cpp")); + I.Loc.emplace_back(12, llvm::SmallString<16>("test.cpp")); + + I.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default); + I.Params.emplace_back("int", "P"); + I.IsMethod = true; + I.Parent = Reference(EmptySID, "Parent", InfoType::IT_record); + + auto G = getMDGenerator(); + assert(G); + std::string Buffer; + llvm::raw_string_ostream Actual(Buffer); + auto Err = G->generateDocForInfo(&I, Actual); + assert(!Err); + std::string Expected = R"raw(### f + +*void f(int P)* + +*Defined at line 10 of test.cpp* + +)raw"; + + EXPECT_EQ(Expected, Actual.str()); +} + +TEST(MDGeneratorTest, emitEnumMD) { + EnumInfo I; + I.Name = "e"; + I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace); + + I.DefLoc = Location(10, llvm::SmallString<16>("test.cpp")); + I.Loc.emplace_back(12, llvm::SmallString<16>("test.cpp")); + + I.Members.emplace_back("X"); + I.Scoped = true; + + auto G = getMDGenerator(); + assert(G); + std::string Buffer; + llvm::raw_string_ostream Actual(Buffer); + auto Err = G->generateDocForInfo(&I, Actual); + assert(!Err); + std::string Expected = R"raw(| enum class e | + +-- + +| X | + + +*Defined at line 10 of test.cpp* + +)raw"; + + EXPECT_EQ(Expected, Actual.str()); +} + +TEST(MDGeneratorTest, emitCommentMD) { + FunctionInfo I; + I.Name = "f"; + I.DefLoc = Location(10, llvm::SmallString<16>("test.cpp")); + I.ReturnType = TypeInfo(EmptySID
[PATCH] D52840: Include Python binding tests in CMake rules
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. I'm not a CMake expert, but when I apply this patch locally, I'm able to run cmake to completion without errors, so LGTM! https://reviews.llvm.org/D52840 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r344256 - [clang-move] Remove clang:: qualifier
Author: maskray Date: Thu Oct 11 09:09:26 2018 New Revision: 344256 URL: http://llvm.org/viewvc/llvm-project?rev=344256&view=rev Log: [clang-move] Remove clang:: qualifier Summary: The use sites are enclosed by `namespace clang`, so clang:: is not necessary. Many unqualified names have already been used, e.g. SourceManager SourceLocation LangOptions. This change makes the code terser and more consistent. Reviewers: hokein Reviewed By: hokein Subscribers: ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D53060 Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.cpp?rev=344256&r1=344255&r2=344256&view=diff == --- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original) +++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Thu Oct 11 09:09:26 2018 @@ -128,18 +128,17 @@ AST_POLYMORPHIC_MATCHER_P(isExpansionInF AbsoluteFilePath; } -class FindAllIncludes : public clang::PPCallbacks { +class FindAllIncludes : public PPCallbacks { public: explicit FindAllIncludes(SourceManager *SM, ClangMoveTool *const MoveTool) : SM(*SM), MoveTool(MoveTool) {} - void InclusionDirective(clang::SourceLocation HashLoc, - const clang::Token & /*IncludeTok*/, + void InclusionDirective(SourceLocation HashLoc, const Token & /*IncludeTok*/, StringRef FileName, bool IsAngled, - clang::CharSourceRange FilenameRange, - const clang::FileEntry * /*File*/, - StringRef SearchPath, StringRef /*RelativePath*/, - const clang::Module * /*Imported*/, + CharSourceRange FilenameRange, + const FileEntry * /*File*/, StringRef SearchPath, + StringRef /*RelativePath*/, + const Module * /*Imported*/, SrcMgr::CharacteristicKind /*FileType*/) override { if (const auto *FileEntry = SM.getFileEntryForID(SM.getFileID(HashLoc))) MoveTool->addIncludes(FileName, IsAngled, SearchPath, @@ -165,9 +164,9 @@ public: : MoveTool(MoveTool) {} void run(const MatchFinder::MatchResult &Result) override { -const auto *FD = Result.Nodes.getNodeAs("function"); +const auto *FD = Result.Nodes.getNodeAs("function"); assert(FD); -const clang::NamedDecl *D = FD; +const NamedDecl *D = FD; if (const auto *FTD = FD->getDescribedFunctionTemplate()) D = FTD; MoveDeclFromOldFileToNewFile(MoveTool, D); @@ -183,7 +182,7 @@ public: : MoveTool(MoveTool) {} void run(const MatchFinder::MatchResult &Result) override { -const auto *VD = Result.Nodes.getNodeAs("var"); +const auto *VD = Result.Nodes.getNodeAs("var"); assert(VD); MoveDeclFromOldFileToNewFile(MoveTool, VD); } @@ -198,10 +197,10 @@ public: : MoveTool(MoveTool) {} void run(const MatchFinder::MatchResult &Result) override { -if (const auto *TD = Result.Nodes.getNodeAs("typedef")) +if (const auto *TD = Result.Nodes.getNodeAs("typedef")) MoveDeclFromOldFileToNewFile(MoveTool, TD); else if (const auto *TAD = - Result.Nodes.getNodeAs("type_alias")) { + Result.Nodes.getNodeAs("type_alias")) { const NamedDecl * D = TAD; if (const auto * TD = TAD->getDescribedAliasTemplate()) D = TD; @@ -219,7 +218,7 @@ public: : MoveTool(MoveTool) {} void run(const MatchFinder::MatchResult &Result) override { -const auto *ED = Result.Nodes.getNodeAs("enum"); +const auto *ED = Result.Nodes.getNodeAs("enum"); assert(ED); MoveDeclFromOldFileToNewFile(MoveTool, ED); } @@ -233,21 +232,19 @@ public: explicit ClassDeclarationMatch(ClangMoveTool *MoveTool) : MoveTool(MoveTool) {} void run(const MatchFinder::MatchResult &Result) override { -clang::SourceManager* SM = &Result.Context->getSourceManager(); -if (const auto *CMD = -Result.Nodes.getNodeAs("class_method")) +SourceManager *SM = &Result.Context->getSourceManager(); +if (const auto *CMD = Result.Nodes.getNodeAs("class_method")) MatchClassMethod(CMD, SM); -else if (const auto *VD = Result.Nodes.getNodeAs( - "class_static_var_decl")) +else if (const auto *VD = + Result.Nodes.getNodeAs("class_static_var_decl")) MatchClassStaticVariable(VD, SM); -else if (const auto *CD = Result.Nodes.getNodeAs( - "moved_class")) +else if (const auto *CD = + Result.Nodes.getNodeAs("moved_class")) MatchClassDeclaration(CD, SM); } private: - void MatchClassMethod(const clang::CXXMethodDecl* CMD, -
[PATCH] D53060: [clang-move] Remove clang:: qualifier
This revision was automatically updated to reflect the committed changes. Closed by commit rL344256: [clang-move] Remove clang:: qualifier (authored by MaskRay, committed by ). Herald added a subscriber: llvm-commits. Repository: rL LLVM https://reviews.llvm.org/D53060 Files: clang-tools-extra/trunk/clang-move/ClangMove.cpp Index: clang-tools-extra/trunk/clang-move/ClangMove.cpp === --- clang-tools-extra/trunk/clang-move/ClangMove.cpp +++ clang-tools-extra/trunk/clang-move/ClangMove.cpp @@ -128,18 +128,17 @@ AbsoluteFilePath; } -class FindAllIncludes : public clang::PPCallbacks { +class FindAllIncludes : public PPCallbacks { public: explicit FindAllIncludes(SourceManager *SM, ClangMoveTool *const MoveTool) : SM(*SM), MoveTool(MoveTool) {} - void InclusionDirective(clang::SourceLocation HashLoc, - const clang::Token & /*IncludeTok*/, + void InclusionDirective(SourceLocation HashLoc, const Token & /*IncludeTok*/, StringRef FileName, bool IsAngled, - clang::CharSourceRange FilenameRange, - const clang::FileEntry * /*File*/, - StringRef SearchPath, StringRef /*RelativePath*/, - const clang::Module * /*Imported*/, + CharSourceRange FilenameRange, + const FileEntry * /*File*/, StringRef SearchPath, + StringRef /*RelativePath*/, + const Module * /*Imported*/, SrcMgr::CharacteristicKind /*FileType*/) override { if (const auto *FileEntry = SM.getFileEntryForID(SM.getFileID(HashLoc))) MoveTool->addIncludes(FileName, IsAngled, SearchPath, @@ -165,9 +164,9 @@ : MoveTool(MoveTool) {} void run(const MatchFinder::MatchResult &Result) override { -const auto *FD = Result.Nodes.getNodeAs("function"); +const auto *FD = Result.Nodes.getNodeAs("function"); assert(FD); -const clang::NamedDecl *D = FD; +const NamedDecl *D = FD; if (const auto *FTD = FD->getDescribedFunctionTemplate()) D = FTD; MoveDeclFromOldFileToNewFile(MoveTool, D); @@ -183,7 +182,7 @@ : MoveTool(MoveTool) {} void run(const MatchFinder::MatchResult &Result) override { -const auto *VD = Result.Nodes.getNodeAs("var"); +const auto *VD = Result.Nodes.getNodeAs("var"); assert(VD); MoveDeclFromOldFileToNewFile(MoveTool, VD); } @@ -198,10 +197,10 @@ : MoveTool(MoveTool) {} void run(const MatchFinder::MatchResult &Result) override { -if (const auto *TD = Result.Nodes.getNodeAs("typedef")) +if (const auto *TD = Result.Nodes.getNodeAs("typedef")) MoveDeclFromOldFileToNewFile(MoveTool, TD); else if (const auto *TAD = - Result.Nodes.getNodeAs("type_alias")) { + Result.Nodes.getNodeAs("type_alias")) { const NamedDecl * D = TAD; if (const auto * TD = TAD->getDescribedAliasTemplate()) D = TD; @@ -219,7 +218,7 @@ : MoveTool(MoveTool) {} void run(const MatchFinder::MatchResult &Result) override { -const auto *ED = Result.Nodes.getNodeAs("enum"); +const auto *ED = Result.Nodes.getNodeAs("enum"); assert(ED); MoveDeclFromOldFileToNewFile(MoveTool, ED); } @@ -233,21 +232,19 @@ explicit ClassDeclarationMatch(ClangMoveTool *MoveTool) : MoveTool(MoveTool) {} void run(const MatchFinder::MatchResult &Result) override { -clang::SourceManager* SM = &Result.Context->getSourceManager(); -if (const auto *CMD = -Result.Nodes.getNodeAs("class_method")) +SourceManager *SM = &Result.Context->getSourceManager(); +if (const auto *CMD = Result.Nodes.getNodeAs("class_method")) MatchClassMethod(CMD, SM); -else if (const auto *VD = Result.Nodes.getNodeAs( - "class_static_var_decl")) +else if (const auto *VD = + Result.Nodes.getNodeAs("class_static_var_decl")) MatchClassStaticVariable(VD, SM); -else if (const auto *CD = Result.Nodes.getNodeAs( - "moved_class")) +else if (const auto *CD = + Result.Nodes.getNodeAs("moved_class")) MatchClassDeclaration(CD, SM); } private: - void MatchClassMethod(const clang::CXXMethodDecl* CMD, -clang::SourceManager* SM) { + void MatchClassMethod(const CXXMethodDecl *CMD, SourceManager *SM) { // Skip inline class methods. isInline() ast matcher doesn't ignore this // case. if (!CMD->isInlined()) { @@ -262,13 +259,11 @@ } } - void MatchClassStaticVariable(const clang::NamedDecl *VD, -clang::SourceManager* SM) { + void MatchClassStaticVariable(const NamedDecl *VD, SourceManager *SM) { MoveDeclFromOldFileToNewFile(MoveTool, VD); } - void MatchCla
[PATCH] D53102: Support for the mno-tls-direct-seg-refs flag
nruslan added inline comments. Comment at: docs/ClangCommandLineReference.rst:2241 + +Enable or disable direct TLS access through segment registers + hans wrote: > This file is automatically generated based on the options .td files, so no > need to update it here. ok Comment at: include/clang/Driver/CC1Options.td:195 HelpText<"Do not emit code that uses the red zone.">; +def indirect_tls_seg_refs : Flag<["-"], "indirect-tls-seg-refs">, + HelpText<"Do not emit code that uses direct TLS segment access.">; hans wrote: > Could mno_tls_direct_seg_refs be used as a cc1 flag instead? done Comment at: include/clang/Driver/Options.td:2167 +def mtls_direct_seg_refs : Flag<["-"], "mtls-direct-seg-refs">, Group, + HelpText<"Enable direct TLS access through segment registers">; def mregparm_EQ : Joined<["-"], "mregparm=">, Group; hans wrote: > Maybe add (default) to the help text to indicate this is the default? done https://reviews.llvm.org/D53102 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53102: Support for the mno-tls-direct-seg-refs flag
nruslan updated this revision to Diff 169224. nruslan marked 3 inline comments as done. nruslan added a comment. @hans , @craig.topper : Updated the patch with all requested changes https://reviews.llvm.org/D53102 Files: include/clang/Driver/Options.td include/clang/Frontend/CodeGenOptions.def lib/CodeGen/CGCall.cpp lib/Driver/ToolChains/Clang.cpp lib/Frontend/CompilerInvocation.cpp test/CodeGen/indirect-tls-seg-refs.c test/Driver/indirect-tls-seg-refs.c Index: test/Driver/indirect-tls-seg-refs.c === --- /dev/null +++ test/Driver/indirect-tls-seg-refs.c @@ -0,0 +1,7 @@ +// RUN: %clang -### %s 2>&1 | FileCheck %s -check-prefix=TLSDIRECT +// RUN: %clang -### -mno-tls-direct-seg-refs -mtls-direct-seg-refs %s 2>&1 | FileCheck %s -check-prefix=TLSDIRECT +// RUN: %clang -### -mtls-direct-seg-refs -mno-tls-direct-seg-refs %s 2>&1 | FileCheck %s -check-prefix=NO-TLSDIRECT +// REQUIRES: clang-driver + +// NO-TLSDIRECT: -mno-tls-direct-seg-refs +// TLSDIRECT-NOT: -mno-tls-direct-seg-refs Index: test/CodeGen/indirect-tls-seg-refs.c === --- /dev/null +++ test/CodeGen/indirect-tls-seg-refs.c @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 %s -emit-llvm -o - -mno-tls-direct-seg-refs | FileCheck %s -check-prefix=NO-TLSDIRECT +// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s -check-prefix=TLSDIRECT + +// NO-TLSDIRECT: attributes #{{[0-9]+}} = {{{.*}} "indirect-tls-seg-refs" +// TLSDIRECT-NOT: attributes #{{[0-9]+}} = {{{.*}} "indirect-tls-seg-refs" + +void test1() { +} Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -614,6 +614,7 @@ Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers); Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone); Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone); + Opts.IndirectTlsSegRefs = Args.hasArg(OPT_mno_tls_direct_seg_refs); Opts.ForbidGuardVariables = Args.hasArg(OPT_fforbid_guard_variables); Opts.UseRegisterSizedBitfieldAccess = Args.hasArg( OPT_fuse_register_sized_bitfield_access); Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -1739,6 +1739,10 @@ Args.hasArg(options::OPT_fapple_kext)) CmdArgs.push_back("-disable-red-zone"); + if (!Args.hasFlag(options::OPT_mtls_direct_seg_refs, + options::OPT_mno_tls_direct_seg_refs, true)) +CmdArgs.push_back("-mno-tls-direct-seg-refs"); + // Default to avoid implicit floating-point for kernel/kext code, but allow // that to be overridden with -mno-soft-float. bool NoImplicitFloat = (Args.hasArg(options::OPT_mkernel) || Index: lib/CodeGen/CGCall.cpp === --- lib/CodeGen/CGCall.cpp +++ lib/CodeGen/CGCall.cpp @@ -1709,6 +1709,8 @@ if (CodeGenOpts.DisableRedZone) FuncAttrs.addAttribute(llvm::Attribute::NoRedZone); + if (CodeGenOpts.IndirectTlsSegRefs) +FuncAttrs.addAttribute("indirect-tls-seg-refs"); if (CodeGenOpts.NoImplicitFloat) FuncAttrs.addAttribute(llvm::Attribute::NoImplicitFloat); Index: include/clang/Frontend/CodeGenOptions.def === --- include/clang/Frontend/CodeGenOptions.def +++ include/clang/Frontend/CodeGenOptions.def @@ -62,6 +62,8 @@ CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new ///< pass manager. CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled. +CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs + ///< is specified. CODEGENOPT(DisableTailCalls , 1, 0) ///< Do not emit tail calls. CODEGENOPT(NoEscapingBlockTailCalls, 1, 0) ///< Do not emit tail calls from ///< escaping blocks. Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -2006,6 +2006,8 @@ def mno_pascal_strings : Flag<["-"], "mno-pascal-strings">, Alias; def mno_red_zone : Flag<["-"], "mno-red-zone">, Group; +def mno_tls_direct_seg_refs : Flag<["-"], "mno-tls-direct-seg-refs">, Group, Flags<[CC1Option]>, + HelpText<"Disable direct TLS access through segment registers">; def mno_relax_all : Flag<["-"], "mno-relax-all">, Group; def mno_rtd: Flag<["-"], "mno-rtd">, Group; def mno_soft_float : Flag<["-"], "mno-soft-float">, Group; @@ -2161,6 +2163,8 @@ def moslib_EQ : Joined<["-"], "moslib=">, Group; def mpascal_strings : Flag<["-"], "mpascal-strings">, Alias; def mred_zone : Flag<["-"], "mr
r344257 - Some improvements to the OpenBSD driver.
Author: brad Date: Thu Oct 11 09:13:44 2018 New Revision: 344257 URL: http://llvm.org/viewvc/llvm-project?rev=344257&view=rev Log: Some improvements to the OpenBSD driver. - OpenBSD has switched to compiler_rt / libcxx - Fix sysroot and lib path handling - Some cleaning up Added: cfe/trunk/test/Driver/openbsd.cpp Modified: cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp cfe/trunk/lib/Driver/ToolChains/OpenBSD.h cfe/trunk/test/Driver/openbsd.c Modified: cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp?rev=344257&r1=344256&r2=344257&view=diff == --- cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp Thu Oct 11 09:13:44 2018 @@ -111,9 +111,9 @@ void openbsd::Linker::ConstructJob(Compi // handled somewhere else. Args.ClaimAllArgs(options::OPT_w); - if (getToolChain().getArch() == llvm::Triple::mips64) + if (ToolChain.getArch() == llvm::Triple::mips64) CmdArgs.push_back("-EB"); - else if (getToolChain().getArch() == llvm::Triple::mips64el) + else if (ToolChain.getArch() == llvm::Triple::mips64el) CmdArgs.push_back("-EL"); if (!Args.hasArg(options::OPT_nostdlib, options::OPT_shared)) { @@ -149,44 +149,40 @@ void openbsd::Linker::ConstructJob(Compi } if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) { +const char *crt0 = nullptr; +const char *crtbegin = nullptr; if (!Args.hasArg(options::OPT_shared)) { if (Args.hasArg(options::OPT_pg)) -CmdArgs.push_back( -Args.MakeArgString(getToolChain().GetFilePath("gcrt0.o"))); +crt0 = "gcrt0.o"; else if (Args.hasArg(options::OPT_static) && !Args.hasArg(options::OPT_nopie)) -CmdArgs.push_back( -Args.MakeArgString(getToolChain().GetFilePath("rcrt0.o"))); +crt0 = "rcrt0.o"; else -CmdArgs.push_back( -Args.MakeArgString(getToolChain().GetFilePath("crt0.o"))); - CmdArgs.push_back( - Args.MakeArgString(getToolChain().GetFilePath("crtbegin.o"))); +crt0 = "crt0.o"; + crtbegin = "crtbegin.o"; } else { - CmdArgs.push_back( - Args.MakeArgString(getToolChain().GetFilePath("crtbeginS.o"))); + crtbegin = "crtbeginS.o"; } - } - std::string Triple = getToolChain().getTripleString(); - if (Triple.substr(0, 6) == "x86_64") -Triple.replace(0, 6, "amd64"); - CmdArgs.push_back( - Args.MakeArgString("-L/usr/lib/gcc-lib/" + Triple + "/4.2.1")); - CmdArgs.push_back(Args.MakeArgString("-L/usr/lib")); +if (crt0) + CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crt0))); +CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtbegin))); + } - Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group, -options::OPT_e, options::OPT_s, options::OPT_t, + Args.AddAllArgs(CmdArgs, options::OPT_L); + ToolChain.AddFilePathLibArgs(Args, CmdArgs); + Args.AddAllArgs(CmdArgs, {options::OPT_T_Group, options::OPT_e, +options::OPT_s, options::OPT_t, options::OPT_Z_Flag, options::OPT_r}); bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs); bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs); - AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA); + AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA); if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) { if (D.CCCIsCXX()) { - if (getToolChain().ShouldLinkCXXStdlib(Args)) -getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs); + if (ToolChain.ShouldLinkCXXStdlib(Args)) +ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs); if (Args.hasArg(options::OPT_pg)) CmdArgs.push_back("-lm_p"); else @@ -202,7 +198,7 @@ void openbsd::Linker::ConstructJob(Compi } // FIXME: For some reason GCC passes -lgcc before adding // the default system libraries. Just mimic this for now. -CmdArgs.push_back("-lgcc"); +CmdArgs.push_back("-lcompiler_rt"); if (Args.hasArg(options::OPT_pthread)) { if (!Args.hasArg(options::OPT_shared) && Args.hasArg(options::OPT_pg)) @@ -218,21 +214,22 @@ void openbsd::Linker::ConstructJob(Compi CmdArgs.push_back("-lc"); } -CmdArgs.push_back("-lgcc"); +CmdArgs.push_back("-lcompiler_rt"); } if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) { +const char *crtend = nullptr; if (!Args.hasArg(options::OPT_shared)) - CmdArgs.push_back( - Args.MakeArgString(getToolChain().GetFilePath("crtend.o"))); + crtend = "crtend.o"; else - CmdArgs.push_back( - Args.MakeArgString(getToolChain().GetFilePath("crtendS.o"))); + crtend = "crtendS.o";
Fix bug 26547
This is a patch to fix bug 26547 (https://bugs.llvm.org/show_bug.cgi?id=26547) This is my first patch, so please give feedback! This should be correct though, and I've tested it on both Windows x86 (where it does nothing), and Linux x86 (where it correctly returns alignof(double) = 4, __alignof(double) = 8). I'm not sure where to put a unit test for this, and I'm also unsure how to test for CPU and OS; as far as I know, it's only really an issue with x86 SysV's double. --- diff --git a/include/clang/ASTMatchers/ASTMatchers.h b/include/clang/ASTMatchers/ASTMatchers.h index eb07ff70a9..3f8690bd8a 100644 --- a/include/clang/ASTMatchers/ASTMatchers.h +++ b/include/clang/ASTMatchers/ASTMatchers.h @@ -2425,8 +2425,9 @@ AST_MATCHER_P(UnaryExprOrTypeTraitExpr, ofKind, UnaryExprOrTypeTrait, Kind) { /// alignof. inline internal::Matcher alignOfExpr( const internal::Matcher &InnerMatcher) { - return stmt(unaryExprOrTypeTraitExpr(allOf( - ofKind(UETT_AlignOf), InnerMatcher))); + return stmt(unaryExprOrTypeTraitExpr( + allOf(anyOf(ofKind(UETT_AlignOf), ofKind(UETT_PreferredAlignOf)), +InnerMatcher))); } /// Same as unaryExprOrTypeTraitExpr, but only matching diff --git a/include/clang/Basic/LangOptions.h b/include/clang/Basic/LangOptions.h index 30ee20395b..2ac4ae52e3 100644 --- a/include/clang/Basic/LangOptions.h +++ b/include/clang/Basic/LangOptions.h @@ -124,6 +124,13 @@ public: /// whether we reuse base class tail padding in some ABIs. Ver6, +/// Attempt to be ABI-compatible with code generated by Clang 7.0.x +/// (SVN r344257). This causes alignof (C++) and _Alignof (C11) to be +/// compatible with __alignof (i.e., return the preferred alignment) +/// rather than returning the required alignment. +/// see https://bugs.llvm.org/show_bug.cgi?id=26547 for explanation +Ver7, + /// Conform to the underlying platform's C and C++ ABIs as closely /// as we can. Latest @@ -273,8 +280,8 @@ public: /// Floating point control options class FPOptions { public: - FPOptions() : fp_contract(LangOptions::FPC_Off), -fenv_access(LangOptions::FEA_Off) {} + FPOptions() + : fp_contract(LangOptions::FPC_Off), fenv_access(LangOptions::FEA_Off) {} // Used for serializing. explicit FPOptions(unsigned I) @@ -319,7 +326,7 @@ public: unsigned getInt() const { return fp_contract | (fenv_access << 2); } private: - /// Adjust BinaryOperator::FPFeatures to match the total bit-field size + /// Adjust BinaryOperator::FPFeatures to match the total bit-field size /// of these two. unsigned fp_contract : 2; unsigned fenv_access : 1; diff --git a/include/clang/Basic/TypeTraits.h b/include/clang/Basic/TypeTraits.h index bdb426834a..e4e54d4822 100644 --- a/include/clang/Basic/TypeTraits.h +++ b/include/clang/Basic/TypeTraits.h @@ -96,6 +96,12 @@ namespace clang { /// Names for the "expression or type" traits. enum UnaryExprOrTypeTrait { UETT_SizeOf, +// used for GCC's __alignof, +UETT_PreferredAlignOf, +// used for C's _Alignof and C++'s alignof +// this distinction is important because __alignof +// returns preferred alignment +// _Alignof and alignof return the required alignment UETT_AlignOf, UETT_VecStep, UETT_OpenMPRequiredSimdAlign, diff --git a/lib/AST/ASTDumper.cpp b/lib/AST/ASTDumper.cpp index 38a2fe9caf..56592b8c65 100644 --- a/lib/AST/ASTDumper.cpp +++ b/lib/AST/ASTDumper.cpp @@ -2272,6 +2272,9 @@ void ASTDumper::VisitUnaryExprOrTypeTraitExpr( case UETT_SizeOf: OS << " sizeof"; break; + case UETT_PreferredAlignOf: +OS << " __alignof"; +break; case UETT_AlignOf: OS << " alignof"; break; diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 651981374d..7ff90f176f 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -1446,7 +1446,7 @@ UnaryExprOrTypeTraitExpr::UnaryExprOrTypeTraitExpr( // Check to see if we are in the situation where alignof(decl) should be // dependent because decl's alignment is dependent. - if (ExprKind == UETT_AlignOf) { + if (ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf) { if (!isValueDependent() || !isInstantiationDependent()) { E = E->IgnoreParens(); diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index d2258cc212..4ed8198e60 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -5946,21 +5946,33 @@ bool PointerExprEvaluator::VisitCastExpr(const CastExpr *E) { return ExprEvaluatorBaseTy::VisitCastExpr(E); } -static CharUnits GetAlignOfType(EvalInfo &Info, QualType T) { +static CharUnits GetAlignOfType(EvalInfo &Info, QualType T, +bool PreferredAlignOf) { // C++ [expr.alignof]p3: // When alignof is applied to a reference type, the result is the // alignment of the referenced type. if (const ReferenceType *Ref = T->getAs()) T = Ref->getPointeeType(); - // __
r344258 - [tests] Include Python binding tests in CMake rules
Author: mgorny Date: Thu Oct 11 09:32:54 2018 New Revision: 344258 URL: http://llvm.org/viewvc/llvm-project?rev=344258&view=rev Log: [tests] Include Python binding tests in CMake rules Add a new CMake rule check-clang-python to run the Python bindings' test suite, and include it in check-all. Differential Revision: https://reviews.llvm.org/D52840 Added: cfe/trunk/bindings/python/tests/CMakeLists.txt Modified: cfe/trunk/CMakeLists.txt Modified: cfe/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=344258&r1=344257&r2=344258&view=diff == --- cfe/trunk/CMakeLists.txt (original) +++ cfe/trunk/CMakeLists.txt Thu Oct 11 09:32:54 2018 @@ -485,6 +485,7 @@ if( CLANG_INCLUDE_TESTS ) ) endif() add_subdirectory(test) + add_subdirectory(bindings/python/tests) if(CLANG_BUILT_STANDALONE) # Add a global check rule now that all subdirectories have been traversed @@ -493,11 +494,13 @@ if( CLANG_INCLUDE_TESTS ) get_property(LLVM_LIT_PARAMS GLOBAL PROPERTY LLVM_LIT_PARAMS) get_property(LLVM_LIT_DEPENDS GLOBAL PROPERTY LLVM_LIT_DEPENDS) get_property(LLVM_LIT_EXTRA_ARGS GLOBAL PROPERTY LLVM_LIT_EXTRA_ARGS) +get_property(LLVM_ADDITIONAL_TEST_TARGETS + GLOBAL PROPERTY LLVM_ADDITIONAL_TEST_TARGETS) add_lit_target(check-all "Running all regression tests" ${LLVM_LIT_TESTSUITES} PARAMS ${LLVM_LIT_PARAMS} - DEPENDS ${LLVM_LIT_DEPENDS} + DEPENDS ${LLVM_LIT_DEPENDS} ${LLVM_ADDITIONAL_TEST_TARGETS} ARGS ${LLVM_LIT_EXTRA_ARGS} ) endif() Added: cfe/trunk/bindings/python/tests/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/CMakeLists.txt?rev=344258&view=auto == --- cfe/trunk/bindings/python/tests/CMakeLists.txt (added) +++ cfe/trunk/bindings/python/tests/CMakeLists.txt Thu Oct 11 09:32:54 2018 @@ -0,0 +1,8 @@ +# Test target to run Python test suite from main build. + +add_custom_target(check-clang-python + COMMAND CLANG_LIBRARY_PATH=$ ${PYTHON_EXECUTABLE} -m unittest discover + DEPENDS libclang + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..) + +set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_TARGETS check-clang-python) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52840: Include Python binding tests in CMake rules
This revision was automatically updated to reflect the committed changes. Closed by commit rC344258: [tests] Include Python binding tests in CMake rules (authored by mgorny, committed by ). Repository: rC Clang https://reviews.llvm.org/D52840 Files: CMakeLists.txt bindings/python/tests/CMakeLists.txt Index: bindings/python/tests/CMakeLists.txt === --- bindings/python/tests/CMakeLists.txt +++ bindings/python/tests/CMakeLists.txt @@ -0,0 +1,8 @@ +# Test target to run Python test suite from main build. + +add_custom_target(check-clang-python + COMMAND CLANG_LIBRARY_PATH=$ ${PYTHON_EXECUTABLE} -m unittest discover + DEPENDS libclang + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..) + +set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_TARGETS check-clang-python) Index: CMakeLists.txt === --- CMakeLists.txt +++ CMakeLists.txt @@ -485,19 +485,22 @@ ) endif() add_subdirectory(test) + add_subdirectory(bindings/python/tests) if(CLANG_BUILT_STANDALONE) # Add a global check rule now that all subdirectories have been traversed # and we know the total set of lit testsuites. get_property(LLVM_LIT_TESTSUITES GLOBAL PROPERTY LLVM_LIT_TESTSUITES) get_property(LLVM_LIT_PARAMS GLOBAL PROPERTY LLVM_LIT_PARAMS) get_property(LLVM_LIT_DEPENDS GLOBAL PROPERTY LLVM_LIT_DEPENDS) get_property(LLVM_LIT_EXTRA_ARGS GLOBAL PROPERTY LLVM_LIT_EXTRA_ARGS) +get_property(LLVM_ADDITIONAL_TEST_TARGETS + GLOBAL PROPERTY LLVM_ADDITIONAL_TEST_TARGETS) add_lit_target(check-all "Running all regression tests" ${LLVM_LIT_TESTSUITES} PARAMS ${LLVM_LIT_PARAMS} - DEPENDS ${LLVM_LIT_DEPENDS} + DEPENDS ${LLVM_LIT_DEPENDS} ${LLVM_ADDITIONAL_TEST_TARGETS} ARGS ${LLVM_LIT_EXTRA_ARGS} ) endif() Index: bindings/python/tests/CMakeLists.txt === --- bindings/python/tests/CMakeLists.txt +++ bindings/python/tests/CMakeLists.txt @@ -0,0 +1,8 @@ +# Test target to run Python test suite from main build. + +add_custom_target(check-clang-python + COMMAND CLANG_LIBRARY_PATH=$ ${PYTHON_EXECUTABLE} -m unittest discover + DEPENDS libclang + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..) + +set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_TARGETS check-clang-python) Index: CMakeLists.txt === --- CMakeLists.txt +++ CMakeLists.txt @@ -485,19 +485,22 @@ ) endif() add_subdirectory(test) + add_subdirectory(bindings/python/tests) if(CLANG_BUILT_STANDALONE) # Add a global check rule now that all subdirectories have been traversed # and we know the total set of lit testsuites. get_property(LLVM_LIT_TESTSUITES GLOBAL PROPERTY LLVM_LIT_TESTSUITES) get_property(LLVM_LIT_PARAMS GLOBAL PROPERTY LLVM_LIT_PARAMS) get_property(LLVM_LIT_DEPENDS GLOBAL PROPERTY LLVM_LIT_DEPENDS) get_property(LLVM_LIT_EXTRA_ARGS GLOBAL PROPERTY LLVM_LIT_EXTRA_ARGS) +get_property(LLVM_ADDITIONAL_TEST_TARGETS + GLOBAL PROPERTY LLVM_ADDITIONAL_TEST_TARGETS) add_lit_target(check-all "Running all regression tests" ${LLVM_LIT_TESTSUITES} PARAMS ${LLVM_LIT_PARAMS} - DEPENDS ${LLVM_LIT_DEPENDS} + DEPENDS ${LLVM_LIT_DEPENDS} ${LLVM_ADDITIONAL_TEST_TARGETS} ARGS ${LLVM_LIT_EXTRA_ARGS} ) endif() ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r344259 - Improve -Wshadow warnings with enumerators.
Author: aaronballman Date: Thu Oct 11 09:40:18 2018 New Revision: 344259 URL: http://llvm.org/viewvc/llvm-project?rev=344259&view=rev Log: Improve -Wshadow warnings with enumerators. Addresses PR24718 by checking for enumerators that shadow other enumerators. Catches issues like: enum E1{e1}; void f(void) { enum E2{e1}; } Modified: cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/test/Sema/warn-shadow.c cfe/trunk/test/SemaCXX/warn-shadow.cpp Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=344259&r1=344258&r2=344259&view=diff == --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Oct 11 09:40:18 2018 @@ -16269,8 +16269,10 @@ Decl *Sema::ActOnEnumConstant(Scope *S, // Verify that there isn't already something declared with this name in this // scope. - NamedDecl *PrevDecl = LookupSingleName(S, Id, IdLoc, LookupOrdinaryName, - ForVisibleRedeclaration); + LookupResult R(*this, Id, IdLoc, LookupOrdinaryName, ForVisibleRedeclaration); + LookupName(R, S); + NamedDecl *PrevDecl = R.getAsSingle(); + if (PrevDecl && PrevDecl->isTemplateParameter()) { // Maybe we will complain about the shadowed template parameter. DiagnoseTemplateParameterShadow(IdLoc, PrevDecl); @@ -16293,6 +16295,11 @@ Decl *Sema::ActOnEnumConstant(Scope *S, return nullptr; if (PrevDecl) { +if (!TheEnumDecl->isScoped()) { + // Check for other kinds of shadowing not already handled. + CheckShadow(New, PrevDecl, R); +} + // When in C++, we may get a TagDecl with the same name; in this case the // enum constant will 'hide' the tag. assert((getLangOpts().CPlusPlus || !isa(PrevDecl)) && Modified: cfe/trunk/test/Sema/warn-shadow.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-shadow.c?rev=344259&r1=344258&r2=344259&view=diff == --- cfe/trunk/test/Sema/warn-shadow.c (original) +++ cfe/trunk/test/Sema/warn-shadow.c Thu Oct 11 09:40:18 2018 @@ -59,3 +59,8 @@ void rdar8883302() { void test8() { int bob; // expected-warning {{declaration shadows a variable in the global scope}} } + +enum PR24718_1{pr24718}; // expected-note {{previous declaration is here}} +void PR24718(void) { + enum PR24718_2{pr24718}; // expected-warning {{declaration shadows a variable in the global scope}} +} Modified: cfe/trunk/test/SemaCXX/warn-shadow.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-shadow.cpp?rev=344259&r1=344258&r2=344259&view=diff == --- cfe/trunk/test/SemaCXX/warn-shadow.cpp (original) +++ cfe/trunk/test/SemaCXX/warn-shadow.cpp Thu Oct 11 09:40:18 2018 @@ -222,3 +222,6 @@ void f(int a) { }; } } + +int PR24718; +enum class X { PR24718 }; // Ok, not shadowing ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52400: Improve -Wshadow warnings with enumerators
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. Committed in r344259 on @erik.pilkington 's LGTM. Self-accepting so I can close the review. https://reviews.llvm.org/D52400 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53131: [clangd] Support scope proximity in code completion.
ioeric updated this revision to Diff 169231. ioeric marked 2 inline comments as done. ioeric added a comment. - address review comments Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53131 Files: clangd/CodeComplete.cpp clangd/Quality.cpp clangd/Quality.h unittests/clangd/CodeCompleteTests.cpp unittests/clangd/QualityTests.cpp Index: unittests/clangd/QualityTests.cpp === --- unittests/clangd/QualityTests.cpp +++ unittests/clangd/QualityTests.cpp @@ -28,6 +28,7 @@ #include "llvm/Support/Casting.h" #include "gmock/gmock.h" #include "gtest/gtest.h" +#include namespace clang { namespace clangd { @@ -117,13 +118,14 @@ Relevance = {}; Relevance.merge(CodeCompletionResult(&findDecl(AST, "main"), 42)); - EXPECT_FLOAT_EQ(Relevance.SemaProximityScore, 1.0f) << "Decl in current file"; + EXPECT_FLOAT_EQ(Relevance.SemaFileProximityScore, 1.0f) + << "Decl in current file"; Relevance = {}; Relevance.merge(CodeCompletionResult(&findDecl(AST, "header"), 42)); - EXPECT_FLOAT_EQ(Relevance.SemaProximityScore, 0.6f) << "Decl from header"; + EXPECT_FLOAT_EQ(Relevance.SemaFileProximityScore, 0.6f) << "Decl from header"; Relevance = {}; Relevance.merge(CodeCompletionResult(&findDecl(AST, "header_main"), 42)); - EXPECT_FLOAT_EQ(Relevance.SemaProximityScore, 1.0f) + EXPECT_FLOAT_EQ(Relevance.SemaFileProximityScore, 1.0f) << "Current file and header"; auto constructShadowDeclCompletionResult = [&](const std::string DeclName) { @@ -146,10 +148,10 @@ Relevance = {}; Relevance.merge(constructShadowDeclCompletionResult("Bar")); - EXPECT_FLOAT_EQ(Relevance.SemaProximityScore, 1.0f) + EXPECT_FLOAT_EQ(Relevance.SemaFileProximityScore, 1.0f) << "Using declaration in main file"; Relevance.merge(constructShadowDeclCompletionResult("FLAGS_FOO")); - EXPECT_FLOAT_EQ(Relevance.SemaProximityScore, 1.0f) + EXPECT_FLOAT_EQ(Relevance.SemaFileProximityScore, 1.0f) << "Using declaration in main file"; Relevance = {}; @@ -210,9 +212,19 @@ PoorNameMatch.NameMatch = 0.2f; EXPECT_LT(PoorNameMatch.evaluate(), Default.evaluate()); - SymbolRelevanceSignals WithSemaProximity; - WithSemaProximity.SemaProximityScore = 0.2f; - EXPECT_GT(WithSemaProximity.evaluate(), Default.evaluate()); + SymbolRelevanceSignals WithSemaFileProximity; + WithSemaFileProximity.SemaFileProximityScore = 0.2f; + EXPECT_GT(WithSemaFileProximity.evaluate(), Default.evaluate()); + + SymbolRelevanceSignals WithSemaScopeProximity; + WithSemaScopeProximity.SemaScopeProximityScore = 1.2f; + EXPECT_GT(WithSemaScopeProximity.evaluate(), Default.evaluate()); + + SymbolRelevanceSignals WithIndexScopeProximity; + QueryScopeProximity ScopeProximity({"x::y::"}); + WithSemaFileProximity.ScopeProximityMatch = &ScopeProximity; + WithSemaScopeProximity.SymbolScope = "x::y::"; + EXPECT_GT(WithSemaScopeProximity.evaluate(), Default.evaluate()); SymbolRelevanceSignals IndexProximate; IndexProximate.SymbolURI = "unittest:/foo/bar.h"; @@ -242,6 +254,34 @@ EXPECT_EQ(Instance.evaluate(), Default.evaluate()); } +TEST(QualityTests, ScopeProximity) { + SymbolRelevanceSignals Default; + + SymbolRelevanceSignals Relevance; + QueryScopeProximity ScopeProximity({"x::y::", "x::", "std::", ""}); + Relevance.ScopeProximityMatch = &ScopeProximity; + + Relevance.SymbolScope = "other::"; + float NotMatched = Relevance.evaluate(); + EXPECT_EQ(NotMatched, Default.evaluate()); + + Relevance.SymbolScope = ""; + float Global = Relevance.evaluate(); + EXPECT_GT(Global, Default.evaluate()); + + Relevance.SymbolScope = "std::"; + float NonParent = Relevance.evaluate(); + EXPECT_GT(NonParent, Global); + + Relevance.SymbolScope = "x::"; + float Parent = Relevance.evaluate(); + EXPECT_EQ(Parent, NonParent); + + Relevance.SymbolScope = "x::y::"; + float Enclosing = Relevance.evaluate(); + EXPECT_GT(Enclosing, Parent); +} + TEST(QualityTests, SortText) { EXPECT_LT(sortText(std::numeric_limits::infinity()), sortText(1000.2f)); Index: unittests/clangd/CodeCompleteTests.cpp === --- unittests/clangd/CodeCompleteTests.cpp +++ unittests/clangd/CodeCompleteTests.cpp @@ -1040,6 +1040,29 @@ UnorderedElementsAre("", "ns::", "std::"; } +TEST(CompletionTest, EnclosingScopeComesFirst) { + auto Requests = captureIndexRequests(R"cpp( + namespace std {} + using namespace std; + namespace nx { + namespace ns { + namespace { + void f() { +vec^ + } + } + } + } + )cpp"); + + EXPECT_THAT(Requests, + ElementsAre(Field( + &FuzzyFindRequest::Scopes, + UnorderedElementsAre("", "std::", "nx::ns::", + "nx::ns::(anonymous)::", "nx::"; + EXPECT_EQ(Requests[0].Scopes
[PATCH] D53131: [clangd] Support scope proximity in code completion.
ioeric added inline comments. Comment at: clangd/CodeComplete.cpp:558 +if (const auto *NS = dyn_cast(Ctx)) + return NS->getQualifiedNameAsString() + "::"; + return llvm::None; sammccall wrote: > does this do the right thing if it's anonymous or inline, or a parent is? > > For indexing, we call a function in AST.h, we should probably do something > similar. > > The catch is that function relies on NamedDecl::printQualifiedName, maybe we > need to factor out the relevant part so we can call it on a DeclContext. Good catch. `NamedDecl::printQualifiedName` doesn't skip the `(anonymous)` part if the decl itself is anonymous, even with `SuppressUnwrittenScope` set. So I think we should explicitly filter those out here and then call `printQualifiedName`. Comment at: clangd/CodeComplete.cpp:559 + return NS->getQualifiedNameAsString() + "::"; + return llvm::None; +} sammccall wrote: > shouldn't this be ""? That's a definite scope, not a failure to find one. > (It's not a *namespace* scope, but I'm not sure why that's important) Make sense. I think we might still want to special-case the global scope (not here, maybe in proximity scoring) because: - if any scope is specified, it's probably more desireable than the global scope. - there are patterns like below in cpp files (instead of using enclosing namespace): ``` using namespace clang; using namespace clang::clangd; ``` Currently, if the enclosing scope is "", then we would treat it the same as the scopes from using-namespace directives. Comment at: clangd/Quality.cpp:246 +float QueryScopeProximity::proximity(llvm::StringRef Scope) const { + if (QueryScopes.empty()) sammccall wrote: > If you're going to decide these numbers directly... > > a) I think you should just return a multiplier here, rather than a 0-1 score > b) we should more aggressively downrank non-preferred symbols: currently by > only ~1/3 vs symbols from a preferred scopes > > e.g. I'd suggest returning 1, 2, 1.5, 1, 1, 1.5, 0.3 or similar > a) I think you should just return a multiplier here, rather than a 0-1 score. I tried this. Unfortunately, allowing <1 multiplier would make the default value (for sema proximity) tricky. And [0,1] proximity score seems to be less confusing as it's consistent with the file proximity scale. If [0,1] isn't enough, we could still increase the upper bound? > b) we should more aggressively downrank non-preferred symbols: currently by > only ~1/3 vs symbols from a preferred scopes It's ~1/3 only for the global scope vs non-preferred symbols, which seems reasonable to me. I worry penalizing non-preferred scopes too much can make cross-namespace completion less useable. Comment at: clangd/Quality.h:92 + private: +std::vector QueryScopes; +}; sammccall wrote: > hmm, can/should we use FileProximity for this, and just transform the strings? > > This isn't going to cache for symbols sharing a namespace, isn't going to > handle "symbol is in a child namespace of an included namespace", and some > other combinations. It seems to me that it'd be less trivial to associate scopes with up/down traverses. Currently, the query scopes contain all enclosing namespaces, so the distance seems less important here. In general, I think the characteristics of scope proximity (e.g. all enclosing namespaces are already in query scopes) allow us to get away with something more trivial than file proximity? > This isn't going to cache for symbols sharing a namespace. This seems to be less a concern if we are not calculating up/down distance. > isn't going to handle "symbol is in a child namespace of an included > namespace" This can be covered by `SymbolScope.startswith(QueryScope)`? It might not work well for `using-namespace`s, but it's unclear how important that is. Still happy to consider FileDistance-approach as I might be missing something. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D53131 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53145: [Tooling] Support src/buildroot to find the build-root, and expose it.
sammccall created this revision. Herald added a subscriber: cfe-commits. Prototype implementation, no tests yet. See http://lists.llvm.org/pipermail/cfe-dev/2018-October/059752.html Repository: rC Clang https://reviews.llvm.org/D53145 Files: include/clang/Tooling/CompilationDatabase.h include/clang/Tooling/CompilationDatabasePluginRegistry.h lib/Tooling/CommonOptionsParser.cpp lib/Tooling/CompilationDatabase.cpp lib/Tooling/JSONCompilationDatabase.cpp tools/libclang/CXCompilationDatabase.cpp Index: tools/libclang/CXCompilationDatabase.cpp === --- tools/libclang/CXCompilationDatabase.cpp +++ tools/libclang/CXCompilationDatabase.cpp @@ -14,18 +14,18 @@ std::string ErrorMsg; CXCompilationDatabase_Error Err = CXCompilationDatabase_NoError; - std::unique_ptr db = - CompilationDatabase::loadFromDirectory(BuildDir, ErrorMsg); + auto Codebase = Codebase::inDirectory(BuildDir); - if (!db) { -fprintf(stderr, "LIBCLANG TOOLING ERROR: %s\n", ErrorMsg.c_str()); + if (!Codebase) { +fprintf(stderr, "LIBCLANG TOOLING ERROR: %s\n", +llvm::toString(Codebase.takeError()).c_str()); Err = CXCompilationDatabase_CanNotLoadDatabase; } if (ErrorCode) *ErrorCode = Err; - return db.release(); + return Codebase->CompilationDatabase.release(); } void Index: lib/Tooling/JSONCompilationDatabase.cpp === --- lib/Tooling/JSONCompilationDatabase.cpp +++ lib/Tooling/JSONCompilationDatabase.cpp @@ -24,6 +24,7 @@ #include "llvm/Support/Casting.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorOr.h" +#include "llvm/Support/FileSystem.h" #include "llvm/Support/Host.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" @@ -161,12 +162,19 @@ // compile commands for files not present in the database. class JSONCompilationDatabasePlugin : public CompilationDatabasePlugin { std::unique_ptr - loadFromDirectory(StringRef Directory, std::string &ErrorMessage) override { + loadFromDirectory(StringRef &Directory, std::string &ErrorMessage) override { SmallString<1024> JSONDatabasePath(Directory); llvm::sys::path::append(JSONDatabasePath, "compile_commands.json"); auto Base = JSONCompilationDatabase::loadFromFile( JSONDatabasePath, ErrorMessage, JSONCommandLineSyntax::AutoDetect); -return Base ? inferMissingCompileCommands(std::move(Base)) : nullptr; +if (!Base) + return nullptr; +// If compile_commands.json is a symlink, target's parent is the build root. +if (llvm::sys::fs::is_symlink_file(JSONDatabasePath)) { + llvm::sys::fs::real_path(JSONDatabasePath, JSONDatabasePath); + Directory = llvm::sys::path::parent_path(JSONDatabasePath); +} +return inferMissingCompileCommands(std::move(Base)); } }; Index: lib/Tooling/CompilationDatabase.cpp === --- lib/Tooling/CompilationDatabase.cpp +++ lib/Tooling/CompilationDatabase.cpp @@ -57,80 +57,41 @@ using namespace clang; using namespace tooling; -LLVM_INSTANTIATE_REGISTRY(CompilationDatabasePluginRegistry) - -CompilationDatabase::~CompilationDatabase() = default; - -std::unique_ptr -CompilationDatabase::loadFromDirectory(StringRef BuildDirectory, - std::string &ErrorMessage) { - llvm::raw_string_ostream ErrorStream(ErrorMessage); - for (CompilationDatabasePluginRegistry::iterator - It = CompilationDatabasePluginRegistry::begin(), - Ie = CompilationDatabasePluginRegistry::end(); - It != Ie; ++It) { -std::string DatabaseErrorMessage; -std::unique_ptr Plugin(It->instantiate()); -if (std::unique_ptr DB = -Plugin->loadFromDirectory(BuildDirectory, DatabaseErrorMessage)) - return DB; -ErrorStream << It->getName() << ": " << DatabaseErrorMessage << "\n"; - } - return nullptr; +llvm::Optional +Codebase::detect(StringRef Path) { + for (; !Path.empty(); Path = llvm::sys::path::parent_path(Path)) +if (auto Info = inDirectory(Path)) + return std::move(*Info); +else + consumeError(Info.takeError()); + return llvm::None; } -static std::unique_ptr -findCompilationDatabaseFromDirectory(StringRef Directory, - std::string &ErrorMessage) { - std::stringstream ErrorStream; - bool HasErrorMessage = false; - while (!Directory.empty()) { -std::string LoadErrorMessage; - -if (std::unique_ptr DB = -CompilationDatabase::loadFromDirectory(Directory, LoadErrorMessage)) - return DB; - -if (!HasErrorMessage) { - ErrorStream << "No compilation database found in " << Directory.str() - << " or any parent directory\n" << LoadErrorMessage; - HasErrorMessage = true; -} - -Directory = llvm::sys::path::parent_path(Directory); +llvm::Expected C
[PATCH] D53079: [OPENMP] Add 'dynamic_allocators' clause to OMP5.0 'requires' directive
patricklyster closed this revision. patricklyster added a comment. Closed by commit https://reviews.llvm.org/rL344249 sha: 851f70b951e5e068b0afa6f69ec58e0e80b0a1a4 Repository: rC Clang https://reviews.llvm.org/D53079 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53125: Detect Clear Linux and apply Clear's default linker options
thiagomacieira added inline comments. Comment at: lib/Driver/Distro.cpp:139 + File = VFS.getBufferForFile("/usr/lib/os-release"); + if (File) { mgorny wrote: > Technically speaking, the spec says you are supposed to read > `/etc/os-release` first and fall back to `/usr/lib/os-release` only if the > former does not exist. You're right, I'll adapt. https://reviews.llvm.org/D53125 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51762: First part of the calendar stuff
EricWF added a comment. There also seem to be some non-ASCII characters in this changeset. Could you hunt them out and destroy them? https://reviews.llvm.org/D51762 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53125: Detect Clear Linux and apply Clear's default linker options
thiagomacieira updated this revision to Diff 169236. thiagomacieira added a comment. Updated to check for /etc/os-release first and /usr/lib/os-release if that fails https://reviews.llvm.org/D53125 Files: include/clang/Driver/Distro.h lib/Driver/Distro.cpp lib/Driver/ToolChains/Linux.cpp unittests/Driver/DistroTest.cpp Index: unittests/Driver/DistroTest.cpp === --- unittests/Driver/DistroTest.cpp +++ unittests/Driver/DistroTest.cpp @@ -302,4 +302,27 @@ ASSERT_FALSE(ArchLinux.IsDebian()); } +TEST(DistroTest, DetectClearLinux) { + vfs::InMemoryFileSystem ClearLinuxFileSystem; + ClearLinuxFileSystem.addFile("/usr/lib/os-release", 0, + llvm::MemoryBuffer::getMemBuffer("NAME=\"Clear Linux OS\"\n" + "VERSION=1\n" + "ID=clear-linux-os\n" + "VERSION_ID=25530\n" + "PRETTY_NAME=\"Clear Linux OS\"\n" + "ANSI_COLOR=\"1;35\"\n" + "HOME_URL=\"https://clearlinux.org\"\n"; + "SUPPORT_URL=\"https://clearlinux.org\"\n"; + "BUG_REPORT_URL=\"mailto:d...@lists.clearlinux.org\"\n" + "PRIVACY_POLICY_URL=\"http://www.intel.com/privacy\"\n";)); + + Distro ClearLinux{ClearLinuxFileSystem}; + ASSERT_EQ(Distro(Distro::ClearLinux), ClearLinux); + ASSERT_TRUE(ClearLinux.IsClearLinux()); + ASSERT_FALSE(ClearLinux.IsUbuntu()); + ASSERT_FALSE(ClearLinux.IsRedhat()); + ASSERT_FALSE(ClearLinux.IsOpenSUSE()); + ASSERT_FALSE(ClearLinux.IsDebian()); +} + } // end anonymous namespace Index: lib/Driver/ToolChains/Linux.cpp === --- lib/Driver/ToolChains/Linux.cpp +++ lib/Driver/ToolChains/Linux.cpp @@ -229,16 +229,19 @@ Distro Distro(D.getVFS()); - if (Distro.IsAlpineLinux()) { + if (Distro.IsAlpineLinux() || Distro.IsClearLinux()) { ExtraOpts.push_back("-z"); ExtraOpts.push_back("now"); } - if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsAlpineLinux()) { + if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsAlpineLinux() || Distro.IsClearLinux()) { ExtraOpts.push_back("-z"); ExtraOpts.push_back("relro"); } + if (Distro.IsClearLinux()) +ExtraOpts.push_back("--copy-dt-needed-entries"); + if (GCCInstallation.getParentLibPath().find("opt/rh/devtoolset") != StringRef::npos) // With devtoolset on RHEL, we want to add a bin directory that is relative @@ -283,7 +286,7 @@ ExtraOpts.push_back("--build-id"); #endif - if (IsAndroid || Distro.IsOpenSUSE()) + if (IsAndroid || Distro.IsOpenSUSE() || Distro.IsClearLinux()) ExtraOpts.push_back("--enable-new-dtags"); // The selection of paths to try here is designed to match the patterns which Index: lib/Driver/Distro.cpp === --- lib/Driver/Distro.cpp +++ lib/Driver/Distro.cpp @@ -136,6 +136,21 @@ if (VFS.exists("/etc/arch-release")) return Distro::ArchLinux; + File = VFS.getBufferForFile("/etc/os-release"); + if (!File) +File = VFS.getBufferForFile("/usr/lib/os-release"); + if (File) { +StringRef Data = File.get()->getBuffer(); +SmallVector Lines; +Data.split(Lines, "\n"); +Distro::DistroType Version = Distro::UnknownDistro; +for (StringRef Line : Lines) + if (Version == Distro::UnknownDistro && Line.startswith("ID=")) +Version = llvm::StringSwitch(Line.substr(3)) + .Case("clear-linux-os", Distro::ClearLinux); +return Version; + } + return Distro::UnknownDistro; } Index: include/clang/Driver/Distro.h === --- include/clang/Driver/Distro.h +++ include/clang/Driver/Distro.h @@ -28,6 +28,7 @@ // the first and last known member in the family, e.g. IsRedHat(). AlpineLinux, ArchLinux, +ClearLinux, DebianLenny, DebianSqueeze, DebianWheezy, @@ -122,6 +123,10 @@ return DistroVal == AlpineLinux; } + bool IsClearLinux() const { +return DistroVal == ClearLinux; + } + /// @} }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51762: First part of the calendar stuff
EricWF requested changes to this revision. EricWF added a comment. This revision now requires changes to proceed. Have you run `git clang-format` over this change set? The blocking issues I see are: - The literal's need to be guarded against older clang dialects. So do their tests. - There are a bunch of tests with meaningless `XFAIL` directives in them. They need to be removed. Comment at: include/chrono:2667 +#if _LIBCPP_STD_VER > 17 +constexpr chrono::day operator ""d(unsigned long long __d) noexcept +{ Including this file with Clang 6.0 in C++2a mode causes a compile error because of "-Wreserved-user-defined-literal". We need to wrap this block with: ``` #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wreserved-user-defined-literal" #endif [...] #if defined(__clang__) #pragma clang diagnostic pop #endif ``` https://reviews.llvm.org/D51762 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51762: First part of the calendar stuff
EricWF added a comment. Also I'm not sure we want to commit to this ABI where the representation of types like `day`, `month`, and `year` are smaller than the integer types they can be constructed from. https://reviews.llvm.org/D51762 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r344260 - [tests] Remove Python tests from check-all due to breakage
Author: mgorny Date: Thu Oct 11 10:25:05 2018 New Revision: 344260 URL: http://llvm.org/viewvc/llvm-project?rev=344260&view=rev Log: [tests] Remove Python tests from check-all due to breakage Remove the Python tests from default target in order to fix two kinds of breakage uncovered by enabling them: one failing test on Linux, and problem with the test command on Windows. Both to be addressed in followup revisions. Modified: cfe/trunk/bindings/python/tests/CMakeLists.txt Modified: cfe/trunk/bindings/python/tests/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/CMakeLists.txt?rev=344260&r1=344259&r2=344260&view=diff == --- cfe/trunk/bindings/python/tests/CMakeLists.txt (original) +++ cfe/trunk/bindings/python/tests/CMakeLists.txt Thu Oct 11 10:25:05 2018 @@ -5,4 +5,4 @@ add_custom_target(check-clang-python DEPENDS libclang WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..) -set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_TARGETS check-clang-python) +#set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_TARGETS check-clang-python) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
LLVM buildmaster will be restarted tonight
Hello everyone, LLVM buildmaster will be updated and restarted after 6PM Pacific time today. Thanks Galina ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r344262 - [Lex] TokenConcatenation now takes const Preprocessor
Author: ioeric Date: Thu Oct 11 10:35:29 2018 New Revision: 344262 URL: http://llvm.org/viewvc/llvm-project?rev=344262&view=rev Log: [Lex] TokenConcatenation now takes const Preprocessor Differential Revision: https://reviews.llvm.org/D52502 Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h?rev=344262&r1=344261&r2=344262&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h Thu Oct 11 10:35:29 2018 @@ -79,9 +79,9 @@ class FieldNode { protected: const FieldRegion *FR; - /// FieldNodes are never meant to be created on the heap, see - /// FindUninitializedFields::addFieldToUninits(). - /* non-virtual */ ~FieldNode() = default; + // TODO: This destructor shouldn't be virtual, but breaks buildbots with + // -Werror -Wnon-virtual-dtor. + virtual ~FieldNode() = default; public: FieldNode(const FieldRegion *FR) : FR(FR) {} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52971: [clang-tidy] Customize FileCheck prefix in check_clang-tidy.py to support multiple prefixes
ymandel added a comment. Hi, It looks like this change has disabled FileCheck for all clang-tidy lit tests that don't use check-prefixes. So, they all trivially pass even if their CHECK... lines are wrong. An easy repro is just to randomly modify any CHECK line in a lit file (e.g. llvm/tools/clang/tools/extra/test/clang-tidy/readability-avoid-const-params-in-decls.cpp) and run ninja check-clang-tools. In check_clang_tidy.py, if you add back (slightly modified) lines 93-95 to the else branch (line 132), it seems to fix the problem. For example, add: has_check_fixes = check_fixes_prefixes[0] in input_text has_check_messages = check_messages_prefixes[0] in input_text has_check_notes = check_notes_prefixes[0] in input_text Repository: rL LLVM https://reviews.llvm.org/D52971 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r344263 - [python] [tests] Retab CMakeLists.txt for consistency (NFC)
Author: mgorny Date: Thu Oct 11 10:45:35 2018 New Revision: 344263 URL: http://llvm.org/viewvc/llvm-project?rev=344263&view=rev Log: [python] [tests] Retab CMakeLists.txt for consistency (NFC) Modified: cfe/trunk/bindings/python/tests/CMakeLists.txt Modified: cfe/trunk/bindings/python/tests/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/CMakeLists.txt?rev=344263&r1=344262&r2=344263&view=diff == --- cfe/trunk/bindings/python/tests/CMakeLists.txt (original) +++ cfe/trunk/bindings/python/tests/CMakeLists.txt Thu Oct 11 10:45:35 2018 @@ -1,8 +1,8 @@ # Test target to run Python test suite from main build. add_custom_target(check-clang-python - COMMAND CLANG_LIBRARY_PATH=$ ${PYTHON_EXECUTABLE} -m unittest discover - DEPENDS libclang - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..) +COMMAND CLANG_LIBRARY_PATH=$ ${PYTHON_EXECUTABLE} -m unittest discover +DEPENDS libclang +WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..) #set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_TARGETS check-clang-python) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r344266 - clang-cl: set output of lit-test to a tmp file after r344234
Author: ioeric Date: Thu Oct 11 10:49:20 2018 New Revision: 344266 URL: http://llvm.org/viewvc/llvm-project?rev=344266&view=rev Log: clang-cl: set output of lit-test to a tmp file after r344234 Some test frameworks do not allow output file in CWD. Modified: cfe/trunk/test/Driver/cl-showfilenames.c Modified: cfe/trunk/test/Driver/cl-showfilenames.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-showfilenames.c?rev=344266&r1=344265&r2=344266&view=diff == --- cfe/trunk/test/Driver/cl-showfilenames.c (original) +++ cfe/trunk/test/Driver/cl-showfilenames.c Thu Oct 11 10:49:20 2018 @@ -1,8 +1,8 @@ -// RUN: %clang_cl /c /showFilenames -- %s 2>&1 | FileCheck -check-prefix=show %s -// RUN: %clang_cl /c /showFilenames -- %s %S/Inputs/wildcard*.c 2>&1 | FileCheck -check-prefix=multiple %s +// RUN: %clang_cl /c /o %t.obj /showFilenames -- %s 2>&1 | FileCheck -check-prefix=show %s +// RUN: %clang_cl /c /o %t.obj /showFilenames -- %s %S/Inputs/wildcard*.c 2>&1 | FileCheck -check-prefix=multiple %s -// RUN: %clang_cl /c -- %s 2>&1 | FileCheck -check-prefix=noshow %s -// RUN: %clang_cl /c /showFilenames /showFilenames- -- %s 2>&1 | FileCheck -check-prefix=noshow %s +// RUN: %clang_cl /c /o %t.obj -- %s 2>&1 | FileCheck -check-prefix=noshow %s +// RUN: %clang_cl /c /o %t.obj /showFilenames /showFilenames- -- %s 2>&1 | FileCheck -check-prefix=noshow %s #pragma message "Hello" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r344267 - Revert "[Lex] TokenConcatenation now takes const Preprocessor"
Author: ioeric Date: Thu Oct 11 10:50:04 2018 New Revision: 344267 URL: http://llvm.org/viewvc/llvm-project?rev=344267&view=rev Log: Revert "[Lex] TokenConcatenation now takes const Preprocessor" This reverts commit r344262. This was an unintentional commit. Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h?rev=344267&r1=344266&r2=344267&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h Thu Oct 11 10:50:04 2018 @@ -79,9 +79,9 @@ class FieldNode { protected: const FieldRegion *FR; - // TODO: This destructor shouldn't be virtual, but breaks buildbots with - // -Werror -Wnon-virtual-dtor. - virtual ~FieldNode() = default; + /// FieldNodes are never meant to be created on the heap, see + /// FindUninitializedFields::addFieldToUninits(). + /* non-virtual */ ~FieldNode() = default; public: FieldNode(const FieldRegion *FR) : FR(FR) {} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53151: [python] [tests] Fix calling pytest on Windows (hopefully)
mgorny created this revision. mgorny added a reviewer: rnk. Fix passing arguments to the pytest command to use 'env' builtin CMake command, in order to fix compatibility with Windows. NB: I don't have a Windows environment to test it Repository: rC Clang https://reviews.llvm.org/D53151 Files: bindings/python/tests/CMakeLists.txt Index: bindings/python/tests/CMakeLists.txt === --- bindings/python/tests/CMakeLists.txt +++ bindings/python/tests/CMakeLists.txt @@ -1,7 +1,9 @@ # Test target to run Python test suite from main build. add_custom_target(check-clang-python -COMMAND CLANG_LIBRARY_PATH=$ ${PYTHON_EXECUTABLE} -m unittest discover +COMMAND ${CMAKE_COMMAND} -E env +CLANG_LIBRARY_PATH=$ +${PYTHON_EXECUTABLE} -m unittest discover DEPENDS libclang WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..) Index: bindings/python/tests/CMakeLists.txt === --- bindings/python/tests/CMakeLists.txt +++ bindings/python/tests/CMakeLists.txt @@ -1,7 +1,9 @@ # Test target to run Python test suite from main build. add_custom_target(check-clang-python -COMMAND CLANG_LIBRARY_PATH=$ ${PYTHON_EXECUTABLE} -m unittest discover +COMMAND ${CMAKE_COMMAND} -E env +CLANG_LIBRARY_PATH=$ +${PYTHON_EXECUTABLE} -m unittest discover DEPENDS libclang WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53153: [OpenCL] Mark namespace scope variables and kernel functions with default visibility
scott.linder created this revision. scott.linder added reviewers: yaxunl, arsenm, kzhuravl, Anastasia. Herald added subscribers: cfe-commits, wdng. The rationale for this is that OpenCL provides programmatic access to these symbols, but not to e.g. non-kernel functions. These symbols should have default visibility even when e.g. `-fvisibility hidden` is present. This is an alternative approach to achieving the same goals as https://reviews.llvm.org/D52891 Repository: rC Clang https://reviews.llvm.org/D53153 Files: lib/AST/Decl.cpp test/CodeGenOpenCL/visibility.cl Index: test/CodeGenOpenCL/visibility.cl === --- /dev/null +++ test/CodeGenOpenCL/visibility.cl @@ -0,0 +1,56 @@ +// RUN: %clang_cc1 -fvisibility default -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck --check-prefix=FVIS-DEFAULT %s +// RUN: %clang_cc1 -fvisibility protected -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck --check-prefix=FVIS-PROTECTED %s +// RUN: %clang_cc1 -fvisibility hidden -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck --check-prefix=FVIS-HIDDEN %s + +// REQUIRES: amdgpu-registered-target + +// FVIS-DEFAULT: @globl = local_unnamed_addr +// FVIS-PROTECTED: @globl = local_unnamed_addr +// FVIS-HIDDEN: @globl = local_unnamed_addr +__constant int globl = 0; +// FVIS-DEFAULT: @default_globl = local_unnamed_addr +// FVIS-PROTECTED: @default_globl = local_unnamed_addr +// FVIS-HIDDEN: @default_globl = local_unnamed_addr +__attribute__((visibility("default"))) __constant int default_globl = 0; +// FVIS-DEFAULT: @protected_globl = protected local_unnamed_addr +// FVIS-PROTECTED: @protected_globl = protected local_unnamed_addr +// FVIS-HIDDEN: @protected_globl = protected local_unnamed_addr +__attribute__((visibility("protected"))) __constant int protected_globl = 0; +// FVIS-DEFAULT: @hidden_globl = hidden local_unnamed_addr +// FVIS-PROTECTED: @hidden_globl = hidden local_unnamed_addr +// FVIS-HIDDEN: @hidden_globl = hidden local_unnamed_addr +__attribute__((visibility("hidden"))) __constant int hidden_globl = 0; + +// FVIS-DEFAULT: define amdgpu_kernel void @kern() +// FVIS-PROTECTED: define amdgpu_kernel void @kern() +// FVIS-HIDDEN: define amdgpu_kernel void @kern() +kernel void kern() {} +// FVIS-DEFAULT: define amdgpu_kernel void @default_kern() +// FVIS-PROTECTED: define amdgpu_kernel void @default_kern() +// FVIS-HIDDEN: define amdgpu_kernel void @default_kern() +__attribute__((visibility("default"))) kernel void default_kern() {} +// FVIS-DEFAULT: define protected amdgpu_kernel void @protected_kern() +// FVIS-PROTECTED: define protected amdgpu_kernel void @protected_kern() +// FVIS-HIDDEN: define protected amdgpu_kernel void @protected_kern() +__attribute__((visibility("protected"))) kernel void protected_kern() {} +// FVIS-DEFAULT: define hidden amdgpu_kernel void @hidden_kern() +// FVIS-PROTECTED: define hidden amdgpu_kernel void @hidden_kern() +// FVIS-HIDDEN: define hidden amdgpu_kernel void @hidden_kern() +__attribute__((visibility("hidden"))) kernel void hidden_kern() {} + +// FVIS-DEFAULT: define void @func() +// FVIS-PROTECTED: define protected void @func() +// FVIS-HIDDEN: define hidden void @func() +void func() {} +// FVIS-DEFAULT: define void @default_func() +// FVIS-PROTECTED: define void @default_func() +// FVIS-HIDDEN: define void @default_func() +__attribute__((visibility("default"))) void default_func() {} +// FVIS-DEFAULT: define protected void @protected_func() +// FVIS-PROTECTED: define protected void @protected_func() +// FVIS-HIDDEN: define protected void @protected_func() +__attribute__((visibility("protected"))) void protected_func() {} +// FVIS-DEFAULT: define hidden void @hidden_func() +// FVIS-PROTECTED: define hidden void @hidden_func() +// FVIS-HIDDEN: define hidden void @hidden_func() +__attribute__((visibility("hidden"))) void hidden_func() {} Index: lib/AST/Decl.cpp === --- lib/AST/Decl.cpp +++ lib/AST/Decl.cpp @@ -556,6 +556,15 @@ FD->hasBody(Def) && Def->isInlined() && !Def->hasAttr(); } +static bool useOpenCLVisibilityDefault(const NamedDecl *D) { + const LangOptions &Opts = D->getASTContext().getLangOpts(); + if (!Opts.OpenCL) +return false; + if (const auto *FD = dyn_cast(D)) +return FD->hasAttr(); + return dyn_cast(D); +} + template static bool isFirstInExternCContext(T *D) { const T *First = D->getFirstDecl(); return First->isInExternCContext(); @@ -713,6 +722,9 @@ } } +if (!LV.isVisibilityExplicit() && useOpenCLVisibilityDefault(D)) + LV.mergeVisibility(DefaultVisibility, true); + // Add in global settings if the above didn't give us direct visibility. if (!LV.isVisibilityExplicit()) { // Use global type/value visibility as appropriate. Index: test/CodeGenOpenCL/visibility.cl =
[PATCH] D51554: [CUDA][OPENMP][NVPTX]Improve logic of the debug info support.
ABataev added a comment. Ping! Repository: rC Clang https://reviews.llvm.org/D51554 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53154: [CodeGen] Handle extern references to OBJC_CLASS_$_*
erik.pilkington created this revision. erik.pilkington added reviewers: rjmccall, ahatanak, jfb. Herald added a subscriber: dexonsmith. Some ObjC users declare a `extern` variable named `OBJC_CLASS_$_Foo`, then use it's address as a `Class`. I.e., one could define `isInstanceOfF`: BOOL isInstanceOfF(id c) { extern void OBJC_CLASS_$_F; return [c class] == (Class)&OBJC_CLASS_$_F; } This leads to asserts in clang CodeGen if there is an `@implementation` of `F` in the same TU as an instance of this pattern, because CodeGen assumes that a variable named OBJC_CLASS_$_* has the right type. This patch fixes the problem by RAUWing the old (incorrectly typed) global with a new global, then removing the old global. I know almost nothing about Objective-C runtime stuff, so take this patch with a grain of salt! Fixes rdar://45077269 Repository: rC Clang https://reviews.llvm.org/D53154 Files: clang/lib/CodeGen/CGObjCMac.cpp clang/test/CodeGenObjC/extern-void-class-decl.m Index: clang/test/CodeGenObjC/extern-void-class-decl.m === --- /dev/null +++ clang/test/CodeGenObjC/extern-void-class-decl.m @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.14.0 %s -emit-llvm -o - | FileCheck %s + +// rdar://45077269 + +extern void OBJC_CLASS_$_f; +Class c = (Class)&OBJC_CLASS_$_f; + +@implementation f @end + +// Check that we override the initializer for c, and that OBJC_CLASS_$_f gets +// the right definition. + +// CHECK: @c = global i8* bitcast (%struct._class_t* @"OBJC_CLASS_$_f" to i8*) +// CHECK: @"OBJC_CLASS_$_f" = global %struct._class_t Index: clang/lib/CodeGen/CGObjCMac.cpp === --- clang/lib/CodeGen/CGObjCMac.cpp +++ clang/lib/CodeGen/CGObjCMac.cpp @@ -7188,15 +7188,21 @@ Weak ? llvm::GlobalValue::ExternalWeakLinkage : llvm::GlobalValue::ExternalLinkage; - - llvm::GlobalVariable *GV = CGM.getModule().getGlobalVariable(Name); - if (!GV) { -GV = new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ClassnfABITy, - false, L, nullptr, Name); + if (!GV || GV->getType() != ObjCTypes.ClassnfABITy->getPointerTo()) { +auto *NewGV = new llvm::GlobalVariable(ObjCTypes.ClassnfABITy, false, L, + nullptr, Name); if (DLLImport) - GV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass); + NewGV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass); + +if (GV) { + GV->replaceAllUsesWith( + llvm::ConstantExpr::getBitCast(NewGV, GV->getType())); + GV->eraseFromParent(); +} +GV = NewGV; +CGM.getModule().getGlobalList().push_back(GV); } assert(GV->getLinkage() == L); Index: clang/test/CodeGenObjC/extern-void-class-decl.m === --- /dev/null +++ clang/test/CodeGenObjC/extern-void-class-decl.m @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.14.0 %s -emit-llvm -o - | FileCheck %s + +// rdar://45077269 + +extern void OBJC_CLASS_$_f; +Class c = (Class)&OBJC_CLASS_$_f; + +@implementation f @end + +// Check that we override the initializer for c, and that OBJC_CLASS_$_f gets +// the right definition. + +// CHECK: @c = global i8* bitcast (%struct._class_t* @"OBJC_CLASS_$_f" to i8*) +// CHECK: @"OBJC_CLASS_$_f" = global %struct._class_t Index: clang/lib/CodeGen/CGObjCMac.cpp === --- clang/lib/CodeGen/CGObjCMac.cpp +++ clang/lib/CodeGen/CGObjCMac.cpp @@ -7188,15 +7188,21 @@ Weak ? llvm::GlobalValue::ExternalWeakLinkage : llvm::GlobalValue::ExternalLinkage; - - llvm::GlobalVariable *GV = CGM.getModule().getGlobalVariable(Name); - if (!GV) { -GV = new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ClassnfABITy, - false, L, nullptr, Name); + if (!GV || GV->getType() != ObjCTypes.ClassnfABITy->getPointerTo()) { +auto *NewGV = new llvm::GlobalVariable(ObjCTypes.ClassnfABITy, false, L, + nullptr, Name); if (DLLImport) - GV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass); + NewGV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass); + +if (GV) { + GV->replaceAllUsesWith( + llvm::ConstantExpr::getBitCast(NewGV, GV->getType())); + GV->eraseFromParent(); +} +GV = NewGV; +CGM.getModule().getGlobalList().push_back(GV); } assert(GV->getLinkage() == L); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53154: [CodeGen] Handle extern references to OBJC_CLASS_$_*
jfb added a comment. Overall this seems fine, but I'm no ObjC expert either so I'll defer to @rjmccall Comment at: clang/lib/CodeGen/CGObjCMac.cpp:7193 + if (!GV || GV->getType() != ObjCTypes.ClassnfABITy->getPointerTo()) { +auto *NewGV = new llvm::GlobalVariable(ObjCTypes.ClassnfABITy, false, L, + nullptr, Name); Add `/* isConstant=*/false` Repository: rC Clang https://reviews.llvm.org/D53154 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r344273 - [OPENMP][NVPTX]Reduce memory use for globalized vars in
Author: abataev Date: Thu Oct 11 11:30:31 2018 New Revision: 344273 URL: http://llvm.org/viewvc/llvm-project?rev=344273&view=rev Log: [OPENMP][NVPTX]Reduce memory use for globalized vars in target/teams/distribute regions. Previously introduced globalization scheme that uses memory coalescing scheme may increase memory usage fr the variables that are devlared in target/teams/distribute contexts. We don't need 32 copies of such variables, just 1. Patch reduces memory use in this case. Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp cfe/trunk/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=344273&r1=344272&r2=344273&view=diff == --- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original) +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Thu Oct 11 11:30:31 2018 @@ -203,7 +203,8 @@ static RecordDecl *buildRecordForGlobali std::stable_sort(GlobalizedVars.begin(), GlobalizedVars.end(), stable_sort_comparator); // Build struct _globalized_locals_ty { - // /* globalized vars */[32] align (max(decl_align, 128)) + // /* globalized vars */[WarSize] align (max(decl_align, + // GlobalMemoryAlignment)) // /* globalized vars */ for EscapedDeclsForTeams // }; RecordDecl *GlobalizedRD = C.buildImplicitRecord("_globalized_locals_ty"); @@ -370,11 +371,16 @@ class CheckVarsEscapingDeclContext final } } - void buildRecordForGlobalizedVars() { + void buildRecordForGlobalizedVars(bool IsInTargetMasterThreadRegion) { assert(!GlobalizedRD && "Record for globalized variables is built already."); +ArrayRef EscapedDeclsForParallel, EscapedDeclsForTeams; +if (IsInTargetMasterThreadRegion) + EscapedDeclsForTeams = EscapedDecls.getArrayRef(); +else + EscapedDeclsForParallel = EscapedDecls.getArrayRef(); GlobalizedRD = ::buildRecordForGlobalizedVars( -CGF.getContext(), EscapedDecls.getArrayRef(), llvm::None, +CGF.getContext(), EscapedDeclsForParallel, EscapedDeclsForTeams, MappedDeclsFields); } @@ -521,9 +527,9 @@ public: /// Returns the record that handles all the escaped local variables and used /// instead of their original storage. - const RecordDecl *getGlobalizedRecord() { + const RecordDecl *getGlobalizedRecord(bool IsInTargetMasterThreadRegion) { if (!GlobalizedRD) - buildRecordForGlobalizedVars(); + buildRecordForGlobalizedVars(IsInTargetMasterThreadRegion); return GlobalizedRD; } @@ -4087,7 +4093,8 @@ void CGOpenMPRuntimeNVPTX::emitFunctionP return; CheckVarsEscapingDeclContext VarChecker(CGF); VarChecker.Visit(Body); - const RecordDecl *GlobalizedVarsRecord = VarChecker.getGlobalizedRecord(); + const RecordDecl *GlobalizedVarsRecord = + VarChecker.getGlobalizedRecord(IsInTargetMasterThreadRegion); ArrayRef EscapedVariableLengthDecls = VarChecker.getEscapedVariableLengthDecls(); if (!GlobalizedVarsRecord && EscapedVariableLengthDecls.empty()) @@ -4105,7 +4112,8 @@ void CGOpenMPRuntimeNVPTX::emitFunctionP for (const ValueDecl *VD : VarChecker.getEscapedDecls()) { assert(VD->isCanonicalDecl() && "Expected canonical declaration"); const FieldDecl *FD = VarChecker.getFieldForGlobalizedVar(VD); -Data.insert(std::make_pair(VD, MappedVarData(FD))); +Data.insert( +std::make_pair(VD, MappedVarData(FD, IsInTargetMasterThreadRegion))); } if (!NeedToDelayGlobalization) { emitGenericVarsProlog(CGF, D->getBeginLoc(), /*WithSPMDCheck=*/true); Modified: cfe/trunk/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp?rev=344273&r1=344272&r2=344273&view=diff == --- cfe/trunk/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp (original) +++ cfe/trunk/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp Thu Oct 11 11:30:31 2018 @@ -26,13 +26,10 @@ int main(int argc, char **argv) { // CHECK-LABEL: define internal void @__omp_offloading_{{.*}}_main_l17_worker( // CHECK: define weak void @__omp_offloading_{{.*}}_main_l17([10 x i32]* dereferenceable(40) %{{.+}}, [10 x i32]* dereferenceable(40) %{{.+}}, i32* dereferenceable(4) %{{.+}}, i{{64|32}} %{{.+}}, [10 x i32]* dereferenceable(40) %{{.+}}) -// CHECK: [[PTR:%.+]] = call i8* @__kmpc_data_sharing_push_stack(i{{64|32}} 2688, i16 0) +// CHECK: [[PTR:%.+]] = call i8* @__kmpc_data_sharing_push_stack(i{{64|32}} 84, i16 0) // CHECK: [[STACK:%.+]] = bitcast i8* [[PTR]] to %struct._globalized_locals_ty* // CHECK: [[ARGC:%.+]] = load i32, i32* %{
r344276 - Revert "clang-cl: Add /showFilenames option (PR31957)"
Author: sfertile Date: Thu Oct 11 11:40:35 2018 New Revision: 344276 URL: http://llvm.org/viewvc/llvm-project?rev=344276&view=rev Log: Revert "clang-cl: Add /showFilenames option (PR31957)" This reverts https://reviews.llvm.org/rL344234 which is causing failures on several bots due to invalid llvm.linker.options. Removed: cfe/trunk/test/Driver/cl-showfilenames.c Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td cfe/trunk/include/clang/Driver/Job.h cfe/trunk/lib/Driver/Job.cpp cfe/trunk/lib/Driver/ToolChains/Clang.cpp Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=344276&r1=344275&r2=344276&view=diff == --- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original) +++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Thu Oct 11 11:40:35 2018 @@ -158,10 +158,6 @@ def _SLASH_Qvec_ : CLFlag<"Qvec-">, def _SLASH_showIncludes : CLFlag<"showIncludes">, HelpText<"Print info about included files to stderr">, Alias; -def _SLASH_showFilenames : CLFlag<"showFilenames">, - HelpText<"Print the name of each compiled file">; -def _SLASH_showFilenames_ : CLFlag<"showFilenames-">, - HelpText<"Don't print the name of each compiled file (default)">; def _SLASH_source_charset : CLCompileJoined<"source-charset:">, HelpText<"Source encoding, supports only UTF-8">, Alias; def _SLASH_execution_charset : CLCompileJoined<"execution-charset:">, Modified: cfe/trunk/include/clang/Driver/Job.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Job.h?rev=344276&r1=344275&r2=344276&view=diff == --- cfe/trunk/include/clang/Driver/Job.h (original) +++ cfe/trunk/include/clang/Driver/Job.h Thu Oct 11 11:40:35 2018 @@ -59,9 +59,6 @@ class Command { /// The list of program arguments which are inputs. llvm::opt::ArgStringList InputFilenames; - /// Whether to print the input filenames when executing. - bool PrintInputFilenames = false; - /// Response file name, if this command is set to use one, or nullptr /// otherwise const char *ResponseFile = nullptr; @@ -131,9 +128,6 @@ public: /// Print a command argument, and optionally quote it. static void printArg(llvm::raw_ostream &OS, StringRef Arg, bool Quote); - - /// Set whether to print the input filenames when executing. - void setPrintInputFilenames(bool P) { PrintInputFilenames = P; } }; /// Like Command, but with a fallback which is executed in case Modified: cfe/trunk/lib/Driver/Job.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Job.cpp?rev=344276&r1=344275&r2=344276&view=diff == --- cfe/trunk/lib/Driver/Job.cpp (original) +++ cfe/trunk/lib/Driver/Job.cpp Thu Oct 11 11:40:35 2018 @@ -315,12 +315,6 @@ void Command::setEnvironment(llvm::Array int Command::Execute(ArrayRef> Redirects, std::string *ErrMsg, bool *ExecutionFailed) const { - if (PrintInputFilenames) { -for (const char *Arg : InputFilenames) - llvm::outs() << llvm::sys::path::filename(Arg) << "\n"; -llvm::outs().flush(); - } - SmallVector Argv; Optional> Env; Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=344276&r1=344275&r2=344276&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Oct 11 11:40:35 2018 @@ -5067,13 +5067,6 @@ void Clang::ConstructJob(Compilation &C, C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs)); } - // Make the compile command echo its inputs for /showFilenames. - if (Output.getType() == types::TY_Object && - Args.hasFlag(options::OPT__SLASH_showFilenames, - options::OPT__SLASH_showFilenames_, false)) { -C.getJobs().getJobs().back()->setPrintInputFilenames(true); - } - if (Arg *A = Args.getLastArg(options::OPT_pg)) if (!shouldUseFramePointer(Args, Triple)) D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer" Removed: cfe/trunk/test/Driver/cl-showfilenames.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-showfilenames.c?rev=344275&view=auto == --- cfe/trunk/test/Driver/cl-showfilenames.c (original) +++ cfe/trunk/test/Driver/cl-showfilenames.c (removed) @@ -1,19 +0,0 @@ -// RUN: %clang_cl /c /o %t.obj /showFilenames -- %s 2>&1 | FileCheck -check-prefix=show %s -// RUN: %clang_cl /c /o %t.obj /showFilenames -- %s %S/Inputs/wildcard*.c 2>&1 | FileCheck -check-prefix=multiple %s - -// RUN: %cla