r330926 - [ConfigFiles] Update argument strings when merging argrument lists

2018-04-25 Thread Serge Pavlov via cfe-commits
Author: sepavloff
Date: Wed Apr 25 23:28:47 2018
New Revision: 330926

URL: http://llvm.org/viewvc/llvm-project?rev=330926&view=rev
Log:
[ConfigFiles] Update argument strings when merging argrument lists

Implementation of `InputArgList` assumes its field `ArgStrings` contains
strings for each argument exactly in the same order. This condition was
broken when arguments from config file and from invocation were merged.

This change fixes https://bugs.llvm.org/show_bug.cgi?id=37196 (Clang
config files can crash argument handling).

Added:
cfe/trunk/test/Driver/Inputs/empty.cfg
cfe/trunk/test/Driver/config-file4.c
Modified:
cfe/trunk/lib/Driver/Driver.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=330926&r1=330925&r2=330926&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Wed Apr 25 23:28:47 2018
@@ -876,11 +876,14 @@ Compilation *Driver::BuildCompilation(Ar
   : std::move(*CLOptions));
   if (HasConfigFile)
 for (auto *Opt : *CLOptions) {
+  if (Opt->getOption().matches(options::OPT_config))
+continue;
+  unsigned Index = Args.MakeIndex(Opt->getSpelling());
   const Arg *BaseArg = &Opt->getBaseArg();
   if (BaseArg == Opt)
 BaseArg = nullptr;
   Arg *Copy = new llvm::opt::Arg(Opt->getOption(), Opt->getSpelling(),
- Args.size(), BaseArg);
+ Index, BaseArg);
   Copy->getValues() = Opt->getValues();
   if (Opt->isClaimed())
 Copy->claim();

Added: cfe/trunk/test/Driver/Inputs/empty.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/empty.cfg?rev=330926&view=auto
==
(empty)

Added: cfe/trunk/test/Driver/config-file4.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/config-file4.c?rev=330926&view=auto
==
--- cfe/trunk/test/Driver/config-file4.c (added)
+++ cfe/trunk/test/Driver/config-file4.c Wed Apr 25 23:28:47 2018
@@ -0,0 +1,2 @@
+// RUN: %clang --config %S/Inputs/empty.cfg -Wall -Wextra -Wformat 
-Wstrict-aliasing -Wshadow -Wpacked -Winline -Wimplicit-function-declaration -c 
%s -O2 -o /dev/null -v 2>&1 | FileCheck %s -check-prefix PR37196
+// PR37196: Configuration file: {{.*}}/empty.cfg


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45932: [clang-tidy][modernize-raw-string-literal] Don't replace upper ASCII with raw literals

2018-04-25 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis updated this revision to Diff 144066.
zinovy.nis added a comment.

- Optimized `containsEscapedCharacters` not to re-create `bitset` 
(implicitly in `StringRef::find_first_of`) for each literal.
- Merged 2 passes for testing for allowed chars into a single one.


https://reviews.llvm.org/D45932

Files:
  clang-tidy/modernize/RawStringLiteralCheck.cpp
  clang-tidy/modernize/RawStringLiteralCheck.h
  test/clang-tidy/modernize-raw-string-literal.cpp

Index: test/clang-tidy/modernize-raw-string-literal.cpp
===
--- test/clang-tidy/modernize-raw-string-literal.cpp
+++ test/clang-tidy/modernize-raw-string-literal.cpp
@@ -40,6 +40,8 @@
 char const *const Us("goink\\\037");
 char const *const HexNonPrintable("\\\x03");
 char const *const Delete("\\\177");
+char const *const MultibyteSnowman("\xE2\x98\x83");
+// CHECK-FIXES: {{^}}char const *const MultibyteSnowman("\xE2\x98\x83");{{$}}
 
 char const *const TrailingSpace("A line \\with space. \n");
 char const *const TrailingNewLine("A single \\line.\n");
Index: clang-tidy/modernize/RawStringLiteralCheck.h
===
--- clang-tidy/modernize/RawStringLiteralCheck.h
+++ clang-tidy/modernize/RawStringLiteralCheck.h
@@ -11,6 +11,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_RAW_STRING_LITERAL_H
 
 #include "../ClangTidy.h"
+#include 
 
 namespace clang {
 namespace tidy {
@@ -35,6 +36,7 @@
   const StringLiteral *Literal, StringRef Replacement);
 
   std::string DelimiterStem;
+  std::bitset<1 << CHAR_BIT> DisallowedChars;
   const bool ReplaceShorterLiterals;
 };
 
Index: clang-tidy/modernize/RawStringLiteralCheck.cpp
===
--- clang-tidy/modernize/RawStringLiteralCheck.cpp
+++ clang-tidy/modernize/RawStringLiteralCheck.cpp
@@ -41,29 +41,16 @@
   return (QuotePos > 0) && (Text[QuotePos - 1] == 'R');
 }
 
-bool containsEscapedCharacters(const MatchFinder::MatchResult &Result,
-   const StringLiteral *Literal) {
+bool containsEscapedCharacters(
+const MatchFinder::MatchResult &Result, const StringLiteral *Literal,
+const std::bitset<1 << CHAR_BIT> &DisallowedChars) {
   // FIXME: Handle L"", u8"", u"" and U"" literals.
   if (!Literal->isAscii())
 return false;
 
-  StringRef Bytes = Literal->getBytes();
-  // Non-printing characters disqualify this literal:
-  // \007 = \a bell
-  // \010 = \b backspace
-  // \011 = \t horizontal tab
-  // \012 = \n new line
-  // \013 = \v vertical tab
-  // \014 = \f form feed
-  // \015 = \r carriage return
-  // \177 = delete
-  if (Bytes.find_first_of(StringRef("\000\001\002\003\004\005\006\a"
-"\b\t\n\v\f\r\016\017"
-"\020\021\022\023\024\025\026\027"
-"\030\031\032\033\034\035\036\037"
-"\177",
-33)) != StringRef::npos)
-return false;
+  for (const unsigned char C : Literal->getBytes())
+if (DisallowedChars.test(C))
+  return false;
 
   CharSourceRange CharRange = Lexer::makeFileCharRange(
   CharSourceRange::getTokenRange(Literal->getSourceRange()),
@@ -102,7 +89,28 @@
  ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
   DelimiterStem(Options.get("DelimiterStem", "lit")),
-  ReplaceShorterLiterals(Options.get("ReplaceShorterLiterals", false)) {}
+  ReplaceShorterLiterals(Options.get("ReplaceShorterLiterals", false)) {
+  // Non-printing characters are disallowed:
+  // \007 = \a bell
+  // \010 = \b backspace
+  // \011 = \t horizontal tab
+  // \012 = \n new line
+  // \013 = \v vertical tab
+  // \014 = \f form feed
+  // \015 = \r carriage return
+  // \177 = delete
+  for (const unsigned char C : StringRef("\000\001\002\003\004\005\006\a"
+ "\b\t\n\v\f\r\016\017"
+ "\020\021\022\023\024\025\026\027"
+ "\030\031\032\033\034\035\036\037"
+ "\177",
+ 33))
+DisallowedChars.set(C);
+
+  // Upper ASCII are disallowed too.
+  for (unsigned char C = 0xFFu; C >= 0x80u; --C)
+DisallowedChars.set(C);
+}
 
 void RawStringLiteralCheck::storeOptions(ClangTidyOptions::OptionMap &Options) {
   ClangTidyCheck::storeOptions(Options);
@@ -124,7 +132,7 @@
   if (Literal->getLocStart().isMacroID())
 return;
 
-  if (containsEscapedCharacters(Result, Literal)) {
+  if (containsEscapedCharacters(Result, Literal, DisallowedChars)) {
 std::string Replacement = asRawStringLiteral(Literal, DelimiterStem);
 if (ReplaceShorterLiterals ||
 Replacement.length() <=
___
cfe-commit

r330923 - [X86] Add support for _mm512_mullox_epi64 and _mm512_mask_mullox_epi64 intrinsics to match icc.

2018-04-25 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed Apr 25 22:38:39 2018
New Revision: 330923

URL: http://llvm.org/viewvc/llvm-project?rev=330923&view=rev
Log:
[X86] Add support for _mm512_mullox_epi64 and _mm512_mask_mullox_epi64 
intrinsics to match icc.

On AVX512F targets we'll produce an emulated sequence using 3 pmuludqs with 
shifts and adds. On AVX512DQ we'll use vpmulld.

Fixes PR37140.

Modified:
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=330923&r1=330922&r2=330923&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Wed Apr 25 22:38:39 2018
@@ -1581,6 +1581,18 @@ _mm512_mask_mullo_epi32(__m512i __W, __m
  (__v16si)__W);
 }
 
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_mullox_epi64 (__m512i __A, __m512i __B) {
+  return (__m512i) ((__v8du) __A * (__v8du) __B);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_mask_mullox_epi64(__m512i __W, __mmask8 __U, __m512i __A, __m512i __B) {
+  return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U,
+ (__v8di)_mm512_mullox_epi64(__A, 
__B),
+ (__v8di)__W);
+}
+
 #define _mm512_mask_sqrt_round_pd(W, U, A, R) __extension__ ({ \
   (__m512d)__builtin_ia32_sqrtpd512_mask((__v8df)(__m512d)(A), \
  (__v8df)(__m512d)(W), (__mmask8)(U), \

Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=330923&r1=330922&r2=330923&view=diff
==
--- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c Wed Apr 25 22:38:39 2018
@@ -1952,6 +1952,19 @@ __m512i test_mm512_mullo_epi32(__m512i _
   return _mm512_mullo_epi32(__A,__B);
 }
 
+__m512i test_mm512_mullox_epi64 (__m512i __A, __m512i __B) {
+  // CHECK-LABEL: @test_mm512_mullox_epi64
+  // CHECK: mul <8 x i64>
+  return (__m512i) ((__v8di) __A * (__v8di) __B);
+}
+
+__m512i test_mm512_mask_mullox_epi64 (__m512i __W, __mmask8 __U, __m512i __A, 
__m512i __B) {
+  // CHECK-LABEL: @test_mm512_mask_mullox_epi64
+  // CHECK: mul <8 x i64> %{{.*}}, %{{.*}}
+  // CHECK: select <8 x i1> %{{.*}}, <8 x i64> %{{.*}}, <8 x i64> %{{.*}}
+  return (__m512i) _mm512_mask_mullox_epi64(__W, __U, __A, __B);
+}
+
 __m512d test_mm512_add_round_pd(__m512d __A, __m512d __B) {
   // CHECK-LABEL: @test_mm512_add_round_pd
   // CHECK: @llvm.x86.avx512.mask.add.pd.512


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D45766: [Sema] Add -Wno-self-assign-overloaded

2018-04-25 Thread Arthur O'Dwyer via cfe-commits
On Wed, Apr 25, 2018 at 7:10 PM, Richard Smith 
wrote:

> On 23 April 2018 at 20:07, John McCall via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>>
>> The issue there is that -Wnoisy-in-tests is likely to be useful as a
>> cancellation of -Wno-noisy-in-tests, which (as David suggests) might
>> reasonably be set by default by a build system.  That's completely defeated
>> if it potentially enables a bunch of unwanted warnings.
>>
>
> Yes, that's fair, but it also applies to some of the other groups I
> mentioned. Eg, how can a project undo a build system default of -Wall
> -Wextra, without turning off enabled-by-default warnings that happen to
> also be in those groups?
>
> If we want to address the broader problem here, I think we need a more
> general model for mapping from a sequence of warning flags to a set of
> enabled/disabled choices for warnings. We could let each warning specify an
> arbitrary positive unate function over warning flags that determines
> whether it's enabled, but I expect that'd be a bit too complex for
> comprehensibility. So I'm not sure what the best way forward is here, but
> I'd prefer that it's not a one-off special thing with its own unique
> semantics, at least if it's in the -W namespace. Maybe having a layer of
> "-w" flags that override the "-W" flags really is the best model.
>

I believe I know a better model (although perhaps that ship has sailed).
Simply keep track of all "-W" flags individually by name, and make
"-Wno-foo" *merely* cancel out a prior "-Wfoo" whenever "foo" is the name
of a group (as opposed to an individual diagnostic). Thus "-Wall -Wmove
-Wno-all" would be equivalent to simply "-Wmove"; whereas "-Wall
-Wno-pessimizing-move" would keep its current behavior (because
"no-pessimizing-move" is the name of an individual diagnostic); and "-Wall
-Wno-move" would be equivalent to "-Wall" (oops) unless we do something
even more clever.

Green Hills' compiler driver (which used EDG's front-end and so I think
most EDG compilers would do the same thing?) completely solves the problem
by using a diagnostic model that is different from GCC's model. In EDG's
model,
- each diagnostic has a unique permanent identifying number
- each diagnostic has a default level, chosen by the compiler-writer, from
the set {none, remark, warning, error, fatal}
- all diagnostic options are of the form "--diag-remark=1234",
"--diag-error=42", etc.
- there is a special option "--diag-default=1234" to clear out any prior
setting for diagnostic 1234
- Diagnostics with default level "fatal" are not allowed to be set to any
other level.
- Orthogonally to all of the above, there is a driver option to control the
minimum level that a diagnostic must be at, in order to be printed:
--errors-only, --warnings-only (the default), --remarks, or --everything
(which prints even the diagnostics whose level is "none").

So for example if diagnostic 42 is a remark and diagnostic 43 is a warning,
then
- "cc86" will print "Warning 43: blah."
- "cc86 --errors-only" will print nothing.
- "cc86 --diag-warning=42" will print "Warning 42: blah. Warning 43: blah."
- "cc86 --diag-error=42" will print "Error 42: blah. Warning 43: blah."
- "cc86 --diag-remark=43" will print nothing.
- "cc86 --diag-remark=43 --remarks" will print "Remark 42: blah. Remark 43:
blah."
- "cc86 --remarks" will print "Remark 42: blah. Warning 43: blah."
And, most relevantly to this discussion,
- "cc86 --diag-error=42 --diag-default=42" will print "Warning 43: blah."


This is fair.  This is certainly an early generalization.  I only think it
>> might not be premature because I think it gives us a very clear message for
>> projects: add `-wtest` when building unit tests and (maybe) unit test
>> infrastructure, and the compiler will try to avoid warning about idioms
>> that don't make sense in normal code but might be sensible in unit tests.
>> If we wait — even if we're only waiting for a second warning — we're
>> jerking project maintainers around.
>>
>
You mean because a project maintainer will upgrade their Clang, and then
it'll start warning about self-assignments in their test code, and they'll
have to shut it up by passing -Wno-self-assign, and then in the next Clang
release they'll have to change the driver option to -wtest, or something?
I'm not sure I understand.  Surely what we *hope* will happen is one of
these two scenarios instead:
(1) They upgrade Clang and it doesn't start warning about self-assignments
because we decided the signal-to-noise ratio of that particular heuristic
was too low to justify including it in -Wall. They don't have to do
anything. Everything's great.
(2) They upgrade Clang and it does start warning about self-assignments,
but the warning includes a fixit to throw parens around the second `x`, or
something. They do so, and the warning goes away for that line of code
forever. Everything's great.

In general, I think we should be doing a lot more to provide clearer "best
>> practices" recommend

[libunwind] r330921 - Creating release candidate rc1 from release_601 branch

2018-04-25 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Wed Apr 25 21:21:05 2018
New Revision: 330921

URL: http://llvm.org/viewvc/llvm-project?rev=330921&view=rev
Log:
Creating release candidate rc1 from release_601 branch

Added:
libunwind/tags/RELEASE_601/rc1/
  - copied from r330920, libunwind/branches/release_60/

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] r330920 - Creating release directory for release_601.

2018-04-25 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Wed Apr 25 21:21:02 2018
New Revision: 330920

URL: http://llvm.org/viewvc/llvm-project?rev=330920&view=rev
Log:
Creating release directory for release_601.

Added:
libunwind/tags/RELEASE_601/

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxxabi] r330909 - Creating release candidate rc1 from release_601 branch

2018-04-25 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Wed Apr 25 21:20:31 2018
New Revision: 330909

URL: http://llvm.org/viewvc/llvm-project?rev=330909&view=rev
Log:
Creating release candidate rc1 from release_601 branch

Added:
libcxxabi/tags/RELEASE_601/rc1/
  - copied from r330908, libcxxabi/branches/release_60/

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxxabi] r330908 - Creating release directory for release_601.

2018-04-25 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Wed Apr 25 21:20:28 2018
New Revision: 330908

URL: http://llvm.org/viewvc/llvm-project?rev=330908&view=rev
Log:
Creating release directory for release_601.

Added:
libcxxabi/tags/RELEASE_601/

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r330907 - Creating release candidate rc1 from release_601 branch

2018-04-25 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Wed Apr 25 21:20:26 2018
New Revision: 330907

URL: http://llvm.org/viewvc/llvm-project?rev=330907&view=rev
Log:
Creating release candidate rc1 from release_601 branch

Added:
libcxx/tags/RELEASE_601/rc1/   (props changed)
  - copied from r330906, libcxx/branches/release_60/

Propchange: libcxx/tags/RELEASE_601/rc1/
--
--- svn:mergeinfo (added)
+++ svn:mergeinfo Wed Apr 25 21:20:26 2018
@@ -0,0 +1,2 @@
+/libcxx/branches/apple:136569-137939
+/libcxx/trunk:321963,324153,324855,325147


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r330906 - Creating release directory for release_601.

2018-04-25 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Wed Apr 25 21:20:20 2018
New Revision: 330906

URL: http://llvm.org/viewvc/llvm-project?rev=330906&view=rev
Log:
Creating release directory for release_601.

Added:
libcxx/tags/RELEASE_601/

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r330894 - Diagnose missing template arguments for a variable template even when there is

2018-04-25 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Apr 25 19:10:22 2018
New Revision: 330894

URL: http://llvm.org/viewvc/llvm-project?rev=330894&view=rev
Log:
Diagnose missing template arguments for a variable template even when there is
a preceding 'template' keyword.

We only diagnose in the dependent case (wherein we used to crash). Another bug
prevents the diagnostic from appearing in the non-template case.

Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaCXX/cxx1y-variable-templates_in_class.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=330894&r1=330893&r2=330894&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Wed Apr 25 19:10:22 2018
@@ -4017,6 +4017,14 @@ ExprResult Sema::BuildTemplateIdExpr(con
   assert(!R.empty() && "empty lookup results when building templateid");
   assert(!R.isAmbiguous() && "ambiguous lookup when building templateid");
 
+  // Non-function templates require a template argument list.
+  if (auto *TD = R.getAsSingle()) {
+if (!TemplateArgs && !isa(TD)) {
+  diagnoseMissingTemplateArguments(TemplateName(TD), R.getNameLoc());
+  return ExprError();
+}
+  }
+
   auto AnyDependentArguments = [&]() -> bool {
 bool InstantiationDependent;
 return TemplateArgs &&

Modified: cfe/trunk/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1y-variable-templates_in_class.cpp?rev=330894&r1=330893&r2=330894&view=diff
==
--- cfe/trunk/test/SemaCXX/cxx1y-variable-templates_in_class.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx1y-variable-templates_in_class.cpp Wed Apr 25 
19:10:22 2018
@@ -379,3 +379,19 @@ int main() {
 
 } // end ns PR24473
 #endif // CPP1Y
+
+namespace dependent_static_var_template {
+  struct A {
+template static int n; // expected-note {{here}}
+  };
+  int &r = A::template n; // FIXME: ill-formed
+
+  template
+  int &f() { return T::template n; } // expected-error {{use of variable 
template 'n' requires template arguments}}
+  int &s = f(); // expected-note {{instantiation of}}
+
+  namespace B {
+template static int n;
+  }
+  int &t = B::template n; // FIXME: ill-formed
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D45766: [Sema] Add -Wno-self-assign-overloaded

2018-04-25 Thread Richard Smith via cfe-commits
On 23 April 2018 at 20:07, John McCall via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Mon, Apr 23, 2018 at 8:23 PM, Richard Smith 
> wrote:
>
>> On 23 April 2018 at 16:23, David Blaikie via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> On Mon, Apr 23, 2018 at 4:12 PM John McCall  wrote:
>>>
 On Mon, Apr 23, 2018 at 6:32 PM, David Blaikie 
 wrote:

> On Mon, Apr 23, 2018 at 3:29 PM John McCall via Phabricator <
> revi...@reviews.llvm.org> wrote:
>
>> rjmccall added a comment.
>>
>> In https://reviews.llvm.org/D45766#1076176, @dblaikie wrote:
>>
>> > Is there anything else in the "-w" namespace other than the literal
>> "-w" so
>> >  far?
>>
>>
>> No. This would be novel.
>>
>
> Ah, I see.
>
>
>> > I mean, I could imagine it might make more sense to default these
>> warnings
>> >  off & users can turn them on for non-test code, potentially? So
>> >  "-Wnon-test" might make sense.
>>
>> That's an interesting idea, but it's still not a warning group,
>> because you shouldn't get the self-assign warnings unless `-Wself-assign`
>> is enabled.
>>
>
> You shouldn't?
>

 I wouldn't think so.  Remember that the goal of the option is to be a
 single thing that users can add to their unit-test CFLAGS to disable these
 noisy-in-tests cases.  So if we add an opt-in/experimental
 `-Wunpredictable-foozits` warning, and it has a unit-test carve-out,
 passing `-wtest -wno-test` or whatever shouldn't turn on the carved-out
 special case of `-Wunpredictable-foozits`.

 It's probably not the worst thing to just use a `-W` spelling anyway;
 not everything in that namespace is (e.g. `-Werror`).  It could be
 `-Wnoisy-in-tests` and `-Wno-noisy-in-tests`, with a documentation note
 that `-Wnoisy-in-tests` is just a cancellation of `-Wno-noisy-in-tests` and
 doesn't actually enable any warnings by itself.  We could have the
 diagnostic printer add `-Wnoisy-in-tests` to the diagnostic-group
 annotation for diagnostics that would be suppressed under
 `-Wno-noisy-in-tests`, analogously to how it adds `-Werror` for diagnostics
 that have been promoted to an error.

>>>
>>> That sort of sounds pretty plausible to me. Poked Richard about his
>>> opinion here too.
>>>
>>
>> This is not the only warning group that has the property that only one of
>> -Wfoo and -Wno-foo seems useful. There are, for instance, plenty of
>> diagnostic groups that make sense to turn on, but not to turn off (eg,
>> -Wno-all, -Wno-extra are largely meaningless), and some that make sense to
>> turn off, but not to turn on (eg, -Wnon-gcc is only intended to be turned
>> off). So I don't think that's as special a property as is being suggested.
>> If someone uses -Wnoisy-in-tests and it turns on all warnings that are
>> noisy in tests, I think they got what they asked for.
>>
>
> The issue there is that -Wnoisy-in-tests is likely to be useful as a
> cancellation of -Wno-noisy-in-tests, which (as David suggests) might
> reasonably be set by default by a build system.  That's completely defeated
> if it potentially enables a bunch of unwanted warnings.
>

Yes, that's fair, but it also applies to some of the other groups I
mentioned. Eg, how can a project undo a build system default of -Wall
-Wextra, without turning off enabled-by-default warnings that happen to
also be in those groups?

If we want to address the broader problem here, I think we need a more
general model for mapping from a sequence of warning flags to a set of
enabled/disabled choices for warnings. We could let each warning specify an
arbitrary positive unate function over warning flags that determines
whether it's enabled, but I expect that'd be a bit too complex for
comprehensibility. So I'm not sure what the best way forward is here, but
I'd prefer that it's not a one-off special thing with its own unique
semantics, at least if it's in the -W namespace. Maybe having a layer of
"-w" flags that override the "-W" flags really is the best model.

This is also not the only warning group for which we want diagnostics to be
>> in this group and in some other group or groups. I think the idea to
>> include -Wnoisy-in-tests in the diagnostic output is very interesting, but
>> as a general feature not as a -Wnoisy-in-tests special case -- for example,
>> if I use a binary literal in C++98 mode, I'd like the warning to be tagged
>> with [-Wbinary-literal,-Wc++14-extensions,-Wgnu], rather than the
>> current [-Wc++14-binary-literal] (an artificial warning group that only
>> exists to work around the inability of our infrastructure to properly
>> represent warnings that are in multiple groups at once).
>>
>
>> As a simple way to get this effect, perhaps we could allow warning groups
>> to be tagged as artificial, and for such warning groups, recurse to the
>> warning groups including the

r330891 - Revert addition of 'concept' to diagnostics in r330890.

2018-04-25 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Apr 25 18:16:08 2018
New Revision: 330891

URL: http://llvm.org/viewvc/llvm-project?rev=330891&view=rev
Log:
Revert addition of 'concept' to diagnostics in r330890.

Matches revert in r330888 of r330794.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=330891&r1=330890&r2=330891&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Apr 25 18:16:08 
2018
@@ -1984,7 +1984,7 @@ def err_auto_not_allowed : Error<
   "%select{'auto'|'decltype(auto)'|'__auto_type'|"
   "use of "
   "%select{class template|function template|variable template|alias template|"
-  "template template parameter|concept|template}2 %3 requires template 
arguments; "
+  "template template parameter|template}2 %3 requires template arguments; "
   "argument deduction}0 not allowed "
   "%select{in function prototype"
   "|in non-static struct member|in struct member"
@@ -1998,7 +1998,7 @@ def err_auto_not_allowed : Error<
 def err_dependent_deduced_tst : Error<
   "typename specifier refers to "
   "%select{class template|function template|variable template|alias template|"
-  "template template parameter|concept|template}0 member in %1; "
+  "template template parameter|template}0 member in %1; "
   "argument deduction not allowed here">;
 def err_auto_not_allowed_var_inst : Error<
   "'auto' variable template instantiation is not allowed">;
@@ -2078,7 +2078,7 @@ def err_deduced_class_template_compound_
   "deduced class template specialization type">;
 def err_deduced_non_class_template_specialization_type : Error<
   "%select{|function template|variable template|alias template|"
-  "template template parameter|concept|template}0 %1 requires template 
arguments; "
+  "template template parameter|template}0 %1 requires template arguments; "
   "argument deduction only allowed for class templates">;
 def err_deduced_class_template_ctor_ambiguous : Error<
   "ambiguous deduction for template arguments of %0">;
@@ -2106,7 +2106,7 @@ def err_deduction_guide_invalid_specifie
 def err_deduction_guide_name_not_class_template : Error<
   "cannot specify deduction guide for "
   "%select{|function template|variable template|alias template|"
-  "template template parameter|concept|dependent template name}0 %1">;
+  "template template parameter|dependent template name}0 %1">;
 def err_deduction_guide_wrong_scope : Error<
   "deduction guide must be declared in the same scope as template %q0">;
 def err_deduction_guide_defines_function : Error<
@@ -3996,11 +3996,11 @@ def err_template_tag_noparams : Error<
 def err_template_missing_args : Error<
   "use of "
   "%select{class template|function template|variable template|alias template|"
-  "template template parameter|concept|template}0 %1 requires template 
arguments">;
+  "template template parameter|template}0 %1 requires template arguments">;
 def err_template_arg_list_different_arity : Error<
   "%select{too few|too many}0 template arguments for "
   "%select{class template|function template|variable template|alias template|"
-  "template template parameter|concept|template}1 %2">;
+  "template template parameter|template}1 %2">;
 def note_template_decl_here : Note<"template is declared here">;
 def err_template_arg_must_be_type : Error<
   "template argument for template type parameter must be a type">;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=330891&r1=330890&r2=330891&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Apr 25 18:16:08 2018
@@ -1820,7 +1820,6 @@ public:
 VarTemplate,
 AliasTemplate,
 TemplateTemplateParam,
-Concept,
 DependentTemplate
   };
   TemplateNameKindForDiagnostics

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=330891&r1=330890&r2=330891&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Apr 25 18:16:08 2018
@@ -1161,8 +1161,6 @@ Sema::getTemplateNameKindForDiagnostics(
 return TemplateNameKindForDiagnostics::AliasTemplate;
   if (isa(TD))
 return TemplateNameKindForDiagnostics::TemplateTemplateParam;
-  if (isa(TD))
-return TemplateNameKindForDiagnostics::Concept;
   return TemplateNameKindForDiagnostics::DependentTemplate;
 }
 


___
cfe-commi

r330890 - Factor out common code for diagnosing missing template arguments.

2018-04-25 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Apr 25 18:08:00 2018
New Revision: 330890

URL: http://llvm.org/viewvc/llvm-project?rev=330890&view=rev
Log:
Factor out common code for diagnosing missing template arguments.

In passing, add 'concept' to the list of template kinds in diagnostics.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprMember.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
cfe/trunk/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
cfe/trunk/test/SemaTemplate/alias-templates.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=330890&r1=330889&r2=330890&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Apr 25 18:08:00 
2018
@@ -1984,7 +1984,7 @@ def err_auto_not_allowed : Error<
   "%select{'auto'|'decltype(auto)'|'__auto_type'|"
   "use of "
   "%select{class template|function template|variable template|alias template|"
-  "template template parameter|template}2 %3 requires template arguments; "
+  "template template parameter|concept|template}2 %3 requires template 
arguments; "
   "argument deduction}0 not allowed "
   "%select{in function prototype"
   "|in non-static struct member|in struct member"
@@ -1998,7 +1998,7 @@ def err_auto_not_allowed : Error<
 def err_dependent_deduced_tst : Error<
   "typename specifier refers to "
   "%select{class template|function template|variable template|alias template|"
-  "template template parameter|template}0 member in %1; "
+  "template template parameter|concept|template}0 member in %1; "
   "argument deduction not allowed here">;
 def err_auto_not_allowed_var_inst : Error<
   "'auto' variable template instantiation is not allowed">;
@@ -2078,7 +2078,7 @@ def err_deduced_class_template_compound_
   "deduced class template specialization type">;
 def err_deduced_non_class_template_specialization_type : Error<
   "%select{|function template|variable template|alias template|"
-  "template template parameter|template}0 %1 requires template arguments; "
+  "template template parameter|concept|template}0 %1 requires template 
arguments; "
   "argument deduction only allowed for class templates">;
 def err_deduced_class_template_ctor_ambiguous : Error<
   "ambiguous deduction for template arguments of %0">;
@@ -2106,7 +2106,7 @@ def err_deduction_guide_invalid_specifie
 def err_deduction_guide_name_not_class_template : Error<
   "cannot specify deduction guide for "
   "%select{|function template|variable template|alias template|"
-  "template template parameter|dependent template name}0 %1">;
+  "template template parameter|concept|dependent template name}0 %1">;
 def err_deduction_guide_wrong_scope : Error<
   "deduction guide must be declared in the same scope as template %q0">;
 def err_deduction_guide_defines_function : Error<
@@ -3991,18 +3991,16 @@ def err_template_member_noparams : Error
   "extraneous 'template<>' in declaration of member %0">;
 def err_template_tag_noparams : Error<
   "extraneous 'template<>' in declaration of %0 %1">;
-def err_template_decl_ref : Error<
-  "cannot refer to %select{class|variable}0 template %1 without a template 
argument list">;
 
 // C++ Template Argument Lists
 def err_template_missing_args : Error<
   "use of "
   "%select{class template|function template|variable template|alias template|"
-  "template template parameter|template}0 %1 requires template arguments">;
+  "template template parameter|concept|template}0 %1 requires template 
arguments">;
 def err_template_arg_list_different_arity : Error<
   "%select{too few|too many}0 template arguments for "
   "%select{class template|function template|variable template|alias template|"
-  "template template parameter|template}1 %2">;
+  "template template parameter|concept|template}1 %2">;
 def note_template_decl_here : Note<"template is declared here">;
 def err_template_arg_must_be_type : Error<
   "template argument for template type parameter must be a type">;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=330890&r1=330889&r2=330890&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Apr 25 18:08:00 2018
@@ -1820,6 +1820,7 @@ public:
 VarTemplate,
 AliasTemplate,
 TemplateTemplateParam,
+Concept,
 DependentTemplate
   };
   TemplateNameKindForDiagnostics
@@ -6229,6 +6230,8 @@ public:
 SourceLocation T

r330889 - Fix a merge conflict that was inadvertently introduced in r330888

2018-04-25 Thread Faisal Vali via cfe-commits
Author: faisalv
Date: Wed Apr 25 18:05:05 2018
New Revision: 330889

URL: http://llvm.org/viewvc/llvm-project?rev=330889&view=rev
Log:
Fix a merge conflict that was inadvertently introduced in r330888 
- during the reversion of r330794

Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=330889&r1=330888&r2=330889&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Wed Apr 25 18:05:05 2018
@@ -4021,12 +4021,6 @@ ExprResult Sema::BuildTemplateIdExpr(con
   TemplateKWLoc, TemplateArgs);
   }
 
-  if (R.getAsSingle() && !AnyDependentArguments()) {
-return CheckConceptTemplateId(SS, R.getLookupNameInfo(),
-  R.getAsSingle(),
-  TemplateKWLoc, TemplateArgs);
-  }
-
   // We don't want lookup warnings at this point.
   R.suppressDiagnostics();
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r330888 - Revert rC330794 and some dependent tiny bug fixes

2018-04-25 Thread Faisal Vali via cfe-commits
Author: faisalv
Date: Wed Apr 25 17:42:40 2018
New Revision: 330888

URL: http://llvm.org/viewvc/llvm-project?rev=330888&view=rev
Log:
Revert rC330794 and some dependent tiny bug fixes 

See Richard's humbling feedback here: 
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180423/226482.html
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180423/226486.html

Wish I'd had the patience to solicit the feedback prior to committing :)

Sorry for the noise guys.

Thank you Richard for being the steward that clang deserves!




Added:
cfe/trunk/test/Parser/cxx-concept-declaration.cpp
  - copied unchanged from r330793, 
cfe/trunk/test/Parser/cxx-concept-declaration.cpp
Removed:
cfe/trunk/test/Parser/cxx2a-concept-declaration.cpp
Modified:
cfe/trunk/include/clang/AST/DeclTemplate.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/Basic/DeclNodes.td
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/TemplateKinds.h
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/DeclSpec.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/AST/DeclTemplate.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/lib/Parse/ParseTemplate.cpp
cfe/trunk/lib/Parse/ParseTentative.cpp
cfe/trunk/lib/Parse/Parser.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Serialization/ASTCommon.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=330888&r1=330887&r2=330888&view=diff
==
--- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
+++ cfe/trunk/include/clang/AST/DeclTemplate.h Wed Apr 25 17:42:40 2018
@@ -3015,46 +3015,6 @@ public:
   static bool classofKind(Kind K) { return K == VarTemplate; }
 };
 
-/// \brief Represents a C++2a ([temp] p1) concept-definition.
-class ConceptDecl : public TemplateDecl {
-protected:
-  Expr *ConstraintExpr;
-
-  ConceptDecl(DeclContext *DC,
-  SourceLocation NameLoc, DeclarationName Name,
-  TemplateParameterList *Params,
-  Expr *ConstraintExpr)
-  : TemplateDecl(nullptr, Concept, DC, NameLoc, Name, Params),
-ConstraintExpr(ConstraintExpr) {};
-public:
-  static ConceptDecl *Create(ASTContext &C, DeclContext *DC,
- SourceLocation NameLoc, DeclarationName Name,
- TemplateParameterList *Params,
- Expr *ConstraintExpr);
-  static ConceptDecl *CreateDeserialized(ASTContext &C, unsigned ID);
-
-  Expr *getConstraintExpr() const {
-return ConstraintExpr;
-  }
-
-  void setConstraintExpr(Expr *CE) {
-ConstraintExpr = CE;
-  }
-
-  SourceRange getSourceRange() const override LLVM_READONLY {
-return SourceRange(getTemplateParameters()->getTemplateLoc(),
-   getConstraintExpr()->getLocEnd());
-  }
-
-  // Implement isa/cast/dyncast/etc.
-  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
-  static bool classofKind(Kind K) { return K == Concept; }
-
-  friend class ASTReader;
-  friend class ASTDeclReader;
-  friend class ASTDeclWriter;
-};
-
 inline NamedDecl *getAsNamedDecl(TemplateParameter P) {
   if (auto *PD = P.dyn_cast())
 return PD;

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=330888&r1=330887&r2=330888&view=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Wed Apr 25 17:42:40 2018
@@ -1722,13 +1722,6 @@ DEF_TRAVERSE_TMPL_DECL(Class)
 DEF_TRAVERSE_TMPL_DECL(Var)
 DEF_TRAVERSE_TMPL_DECL(Function)
 
-DEF_TRAVERSE_DECL(ConceptDecl, {
-  TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters()));
-  TRY_TO(TraverseStmt(D->getConstraintExpr()));
-  // FIXME: Traverse all the concept specializations (once we implement forming
-  // template-ids with them).
-})
-
 DEF_TRAVERSE_DECL(TemplateTemplateParmDecl, {
   // D is the "T" in something l

[PATCH] D45997: [CMake] Pass additional CMake flags in Fuchsia cache files

2018-04-25 Thread Kostya Kortchinsky via Phabricator via cfe-commits
cryptoad added inline comments.



Comment at: clang/cmake/caches/Fuchsia-stage2.cmake:89
   set(RUNTIMES_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} 
CACHE PATH "")
-  set(RUNTIMES_${target}-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
-  set(RUNTIMES_${target}-fuchsia_UNIX 1 CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia_COMPILER_RT_ENABLE_WERROR ON CACHE BOOL "")
+  set(RUNTIMES_${target}-fuchsia_COMPILER_RT_TEST_COMPILER_CFLAGS 
${FUCHSIA_${target}_C_FLAGS} CACHE PATH "")

This should probably go away for now if we want to have D46079.
Then I can go through the remaining warnings if that's important to have it and 
fix them.


Repository:
  rC Clang

https://reviews.llvm.org/D45997



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r330887 - Switch to Clang's isDigit function.

2018-04-25 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Apr 25 16:50:55 2018
New Revision: 330887

URL: http://llvm.org/viewvc/llvm-project?rev=330887&view=rev
Log:
Switch to Clang's isDigit function.

std::isdigit can be overloaded, causing the template deduction to fail.  Use
Clang's isDigit function which to avoid this.  Switch the other calls for
consistency.

Modified:
cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp?rev=330887&r1=330886&r2=330887&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp Wed Apr 25 16:50:55 2018
@@ -8,13 +8,13 @@
 
//===--===//
 
 #include "RISCV.h"
+#include "clang/Basic/CharInfo.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/TargetParser.h"
 #include "llvm/Support/raw_ostream.h"
-#include 
 
 using namespace clang::driver;
 using namespace clang::driver::tools;
@@ -57,7 +57,7 @@ static bool getExtensionVersion(const Dr
   auto I = In.begin();
   auto E = In.end();
 
-  while (I != E && isdigit(*I))
+  while (I != E && isDigit(*I))
 Major.append(1, *I++);
 
   if (Major.empty())
@@ -66,7 +66,7 @@ static bool getExtensionVersion(const Dr
   if (I != E && *I == 'p') {
 ++I;
 
-while (I != E && isdigit(*I))
+while (I != E && isDigit(*I))
   Minor.append(1, *I++);
 
 // Expected 'p' to be followed by minor version number.
@@ -161,7 +161,7 @@ static void getExtensionFeatures(const D
 }
 
 std::string Major, Minor;
-auto Pos = Name.find_if(std::isdigit);
+auto Pos = Name.find_if(isDigit);
 if (Pos != StringRef::npos) {
   auto Next =  Name.substr(Pos);
   Name = Name.substr(0, Pos);


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34331: func.wrap.func.con: Unset function before destroying anything

2018-04-25 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rCXX330885: [libcxx] func.wrap.func.con: Unset function before 
destroying anything (authored by vsapsai, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D34331?vs=143797&id=144037#toc

Repository:
  rCXX libc++

https://reviews.llvm.org/D34331

Files:
  include/__functional_03
  include/functional
  
test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/move_reentrant.pass.cpp
  
test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign_reentrant.pass.cpp

Index: include/__functional_03
===
--- include/__functional_03
+++ include/__functional_03
@@ -600,19 +600,23 @@
 function<_Rp()>&
 function<_Rp()>::operator=(const function& __f)
 {
-function(__f).swap(*this);
+if (__f)
+function(__f).swap(*this);
+else
+*this = nullptr;
 return *this;
 }
 
 template
 function<_Rp()>&
 function<_Rp()>::operator=(nullptr_t)
 {
-if (__f_ == (__base*)&__buf_)
-__f_->destroy();
-else if (__f_)
-__f_->destroy_deallocate();
+__base* __t = __f_;
 __f_ = 0;
+if (__t == (__base*)&__buf_)
+__t->destroy();
+else if (__t)
+__t->destroy_deallocate();
 return *this;
 }
 
@@ -876,19 +880,23 @@
 function<_Rp(_A0)>&
 function<_Rp(_A0)>::operator=(const function& __f)
 {
-function(__f).swap(*this);
+if (__f)
+function(__f).swap(*this);
+else
+*this = nullptr;
 return *this;
 }
 
 template
 function<_Rp(_A0)>&
 function<_Rp(_A0)>::operator=(nullptr_t)
 {
-if (__f_ == (__base*)&__buf_)
-__f_->destroy();
-else if (__f_)
-__f_->destroy_deallocate();
+__base* __t = __f_;
 __f_ = 0;
+if (__t == (__base*)&__buf_)
+__t->destroy();
+else if (__t)
+__t->destroy_deallocate();
 return *this;
 }
 
@@ -1152,19 +1160,23 @@
 function<_Rp(_A0, _A1)>&
 function<_Rp(_A0, _A1)>::operator=(const function& __f)
 {
-function(__f).swap(*this);
+if (__f)
+function(__f).swap(*this);
+else
+*this = nullptr;
 return *this;
 }
 
 template
 function<_Rp(_A0, _A1)>&
 function<_Rp(_A0, _A1)>::operator=(nullptr_t)
 {
-if (__f_ == (__base*)&__buf_)
-__f_->destroy();
-else if (__f_)
-__f_->destroy_deallocate();
+__base* __t = __f_;
 __f_ = 0;
+if (__t == (__base*)&__buf_)
+__t->destroy();
+else if (__t)
+__t->destroy_deallocate();
 return *this;
 }
 
@@ -1428,19 +1440,23 @@
 function<_Rp(_A0, _A1, _A2)>&
 function<_Rp(_A0, _A1, _A2)>::operator=(const function& __f)
 {
-function(__f).swap(*this);
+if (__f)
+function(__f).swap(*this);
+else
+*this = nullptr;
 return *this;
 }
 
 template
 function<_Rp(_A0, _A1, _A2)>&
 function<_Rp(_A0, _A1, _A2)>::operator=(nullptr_t)
 {
-if (__f_ == (__base*)&__buf_)
-__f_->destroy();
-else if (__f_)
-__f_->destroy_deallocate();
+__base* __t = __f_;
 __f_ = 0;
+if (__t == (__base*)&__buf_)
+__t->destroy();
+else if (__t)
+__t->destroy_deallocate();
 return *this;
 }
 
Index: include/functional
===
--- include/functional
+++ include/functional
@@ -1818,11 +1818,7 @@
 function<_Rp(_ArgTypes...)>&
 function<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT
 {
-if ((void *)__f_ == &__buf_)
-__f_->destroy();
-else if (__f_)
-__f_->destroy_deallocate();
-__f_ = 0;
+*this = nullptr;
 if (__f.__f_ == 0)
 __f_ = 0;
 else if ((void *)__f.__f_ == &__f.__buf_)
@@ -1842,11 +1838,12 @@
 function<_Rp(_ArgTypes...)>&
 function<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT
 {
-if ((void *)__f_ == &__buf_)
-__f_->destroy();
-else if (__f_)
-__f_->destroy_deallocate();
+__base* __t = __f_;
 __f_ = 0;
+if ((void *)__t == &__buf_)
+__t->destroy();
+else if (__t)
+__t->destroy_deallocate();
 return *this;
 }
 
Index: test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/move_reentrant.pass.cpp
===
--- test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/move_reentrant.pass.cpp
+++ test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/move_reentrant.pass.cpp
@@ -0,0 +1,46 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===

r330886 - Include to get std::isdigit, fixes MSVC STL build

2018-04-25 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Wed Apr 25 16:38:54 2018
New Revision: 330886

URL: http://llvm.org/viewvc/llvm-project?rev=330886&view=rev
Log:
Include  to get std::isdigit, fixes MSVC STL build

Modified:
cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp?rev=330886&r1=330885&r2=330886&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp Wed Apr 25 16:38:54 2018
@@ -14,6 +14,7 @@
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/TargetParser.h"
 #include "llvm/Support/raw_ostream.h"
+#include 
 
 using namespace clang::driver;
 using namespace clang::driver::tools;


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r330885 - [libcxx] func.wrap.func.con: Unset function before destroying anything

2018-04-25 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Wed Apr 25 16:38:41 2018
New Revision: 330885

URL: http://llvm.org/viewvc/llvm-project?rev=330885&view=rev
Log:
[libcxx] func.wrap.func.con: Unset function before destroying anything

Be defensive against a reentrant std::function::operator=(nullptr_t), in case
the held function object has a non-trivial destructor.  Destroying the function
object in-place can lead to the destructor being called twice.

Patch by Duncan P. N. Exon Smith. C++03 support by Volodymyr Sapsai.

rdar://problem/32836603

Reviewers: EricWF, mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits, arphaman

Differential Revision: https://reviews.llvm.org/D34331

Added:

libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/move_reentrant.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign_reentrant.pass.cpp
Modified:
libcxx/trunk/include/__functional_03
libcxx/trunk/include/functional

Modified: libcxx/trunk/include/__functional_03
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__functional_03?rev=330885&r1=330884&r2=330885&view=diff
==
--- libcxx/trunk/include/__functional_03 (original)
+++ libcxx/trunk/include/__functional_03 Wed Apr 25 16:38:41 2018
@@ -600,7 +600,10 @@ template
 function<_Rp()>&
 function<_Rp()>::operator=(const function& __f)
 {
-function(__f).swap(*this);
+if (__f)
+function(__f).swap(*this);
+else
+*this = nullptr;
 return *this;
 }
 
@@ -608,11 +611,12 @@ template
 function<_Rp()>&
 function<_Rp()>::operator=(nullptr_t)
 {
-if (__f_ == (__base*)&__buf_)
-__f_->destroy();
-else if (__f_)
-__f_->destroy_deallocate();
+__base* __t = __f_;
 __f_ = 0;
+if (__t == (__base*)&__buf_)
+__t->destroy();
+else if (__t)
+__t->destroy_deallocate();
 return *this;
 }
 
@@ -876,7 +880,10 @@ template
 function<_Rp(_A0)>&
 function<_Rp(_A0)>::operator=(const function& __f)
 {
-function(__f).swap(*this);
+if (__f)
+function(__f).swap(*this);
+else
+*this = nullptr;
 return *this;
 }
 
@@ -884,11 +891,12 @@ template
 function<_Rp(_A0)>&
 function<_Rp(_A0)>::operator=(nullptr_t)
 {
-if (__f_ == (__base*)&__buf_)
-__f_->destroy();
-else if (__f_)
-__f_->destroy_deallocate();
+__base* __t = __f_;
 __f_ = 0;
+if (__t == (__base*)&__buf_)
+__t->destroy();
+else if (__t)
+__t->destroy_deallocate();
 return *this;
 }
 
@@ -1152,7 +1160,10 @@ template&
 function<_Rp(_A0, _A1)>::operator=(const function& __f)
 {
-function(__f).swap(*this);
+if (__f)
+function(__f).swap(*this);
+else
+*this = nullptr;
 return *this;
 }
 
@@ -1160,11 +1171,12 @@ template&
 function<_Rp(_A0, _A1)>::operator=(nullptr_t)
 {
-if (__f_ == (__base*)&__buf_)
-__f_->destroy();
-else if (__f_)
-__f_->destroy_deallocate();
+__base* __t = __f_;
 __f_ = 0;
+if (__t == (__base*)&__buf_)
+__t->destroy();
+else if (__t)
+__t->destroy_deallocate();
 return *this;
 }
 
@@ -1428,7 +1440,10 @@ template&
 function<_Rp(_A0, _A1, _A2)>::operator=(const function& __f)
 {
-function(__f).swap(*this);
+if (__f)
+function(__f).swap(*this);
+else
+*this = nullptr;
 return *this;
 }
 
@@ -1436,11 +1451,12 @@ template&
 function<_Rp(_A0, _A1, _A2)>::operator=(nullptr_t)
 {
-if (__f_ == (__base*)&__buf_)
-__f_->destroy();
-else if (__f_)
-__f_->destroy_deallocate();
+__base* __t = __f_;
 __f_ = 0;
+if (__t == (__base*)&__buf_)
+__t->destroy();
+else if (__t)
+__t->destroy_deallocate();
 return *this;
 }
 

Modified: libcxx/trunk/include/functional
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/functional?rev=330885&r1=330884&r2=330885&view=diff
==
--- libcxx/trunk/include/functional (original)
+++ libcxx/trunk/include/functional Wed Apr 25 16:38:41 2018
@@ -1818,11 +1818,7 @@ template
 function<_Rp(_ArgTypes...)>&
 function<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT
 {
-if ((void *)__f_ == &__buf_)
-__f_->destroy();
-else if (__f_)
-__f_->destroy_deallocate();
-__f_ = 0;
+*this = nullptr;
 if (__f.__f_ == 0)
 __f_ = 0;
 else if ((void *)__f.__f_ == &__f.__buf_)
@@ -1842,11 +1838,12 @@ template
 function<_Rp(_ArgTypes...)>&
 function<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT
 {
-if ((void *)__f_ == &__buf_)
-__f_->destroy();
-else if (__f_)
-__f_->destroy_deallocate();
+__base* __t = __f_;
 __f_ = 0;
+if ((void *)__t == &__buf_)
+__t->destroy();
+else if (__t)
+__t->destr

[PATCH] D46037: [analyzer] pr37166, pr37139: Disable constructor inlining when lifetime extension through aggregate initialization occurs.

2018-04-25 Thread Phabricator via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330882: [analyzer] Fix a crash on lifetime extension through 
aggregate initialization. (authored by dergachev, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46037?vs=143850&id=144032#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46037

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  cfe/trunk/test/Analysis/lifetime-extension.cpp

Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
@@ -110,6 +110,11 @@
 /// 'const int &x = C().x;'.
 bool IsTemporaryLifetimeExtendedViaSubobject = false;
 
+/// This call is a constructor for a temporary that is lifetime-extended
+/// by binding it to a reference-type field within an aggregate,
+/// for example 'A { const C &c; }; A a = { C() };'
+bool IsTemporaryLifetimeExtendedViaAggregate = false;
+
 EvalCallOptions() {}
   };
 
Index: cfe/trunk/test/Analysis/lifetime-extension.cpp
===
--- cfe/trunk/test/Analysis/lifetime-extension.cpp
+++ cfe/trunk/test/Analysis/lifetime-extension.cpp
@@ -147,6 +147,37 @@
   // FIXME: Should be TRUE. Should not warn about garbage value.
   clang_analyzer_eval(after == before); // expected-warning{{UNKNOWN}}
 }
+
+struct A { // A is an aggregate.
+  const C &c;
+};
+
+void f6() {
+  C *after, *before;
+  {
+A a{C(true, &after, &before)};
+  }
+  // FIXME: Should be TRUE. Should not warn about garbage value.
+  clang_analyzer_eval(after == before); // expected-warning{{UNKNOWN}}
+}
+
+void f7() {
+  C *after, *before;
+  {
+A a = {C(true, &after, &before)};
+  }
+  // FIXME: Should be TRUE. Should not warn about garbage value.
+  clang_analyzer_eval(after == before); // expected-warning{{UNKNOWN}}
+}
+
+void f8() {
+  C *after, *before;
+  {
+A a[2] = {C(false, nullptr, nullptr), C(true, &after, &before)};
+  }
+  // FIXME: Should be TRUE. Should not warn about garbage value.
+  clang_analyzer_eval(after == before); // expected-warning{{UNKNOWN}}
+}
 } // end namespace maintain_original_object_address_on_lifetime_extension
 
 namespace maintain_original_object_address_on_move {
Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -180,14 +180,25 @@
 }
 case ConstructionContext::TemporaryObjectKind: {
   const auto *TOCC = cast(CC);
-  // See if we're lifetime-extended via our field. If so, take a note.
-  // Because automatic destructors aren't quite working in this case.
   if (const auto *MTE = TOCC->getMaterializedTemporaryExpr()) {
 if (const ValueDecl *VD = MTE->getExtendingDecl()) {
-  assert(VD->getType()->isReferenceType());
-  if (VD->getType()->getPointeeType().getCanonicalType() !=
-  MTE->GetTemporaryExpr()->getType().getCanonicalType()) {
-CallOpts.IsTemporaryLifetimeExtendedViaSubobject = true;
+  // Pattern-match various forms of lifetime extension that aren't
+  // currently supported by the CFG.
+  // FIXME: Is there a better way to retrieve this information from
+  // the MaterializeTemporaryExpr?
+  assert(MTE->getStorageDuration() != SD_FullExpression);
+  if (VD->getType()->isReferenceType()) {
+assert(VD->getType()->isReferenceType());
+if (VD->getType()->getPointeeType().getCanonicalType() !=
+MTE->GetTemporaryExpr()->getType().getCanonicalType()) {
+  // We're lifetime-extended via our field. Automatic destructors
+  // aren't quite working in this case.
+  CallOpts.IsTemporaryLifetimeExtendedViaSubobject = true;
+}
+  } else {
+// We're lifetime-extended by a surrounding aggregate.
+// Automatic destructors aren't quite working in this case.
+CallOpts.IsTemporaryLifetimeExtendedViaAggregate = true;
   }
 }
   }
Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -699,6 +699,11 @@
   // within it to a reference

r330882 - [analyzer] Fix a crash on lifetime extension through aggregate initialization.

2018-04-25 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Apr 25 16:02:06 2018
New Revision: 330882

URL: http://llvm.org/viewvc/llvm-project?rev=330882&view=rev
Log:
[analyzer] Fix a crash on lifetime extension through aggregate initialization.

If 'A' is a C++ aggregate with a reference field of type 'C', in code like
  A a = { C() };
C() is lifetime-extended by 'a'. The analyzer wasn't expecting this pattern and
crashing. Additionally, destructors aren't added in the CFG for this case,
so for now we shouldn't be inlining the constructor for C().

Differential Revision: https://reviews.llvm.org/D46037

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
cfe/trunk/test/Analysis/lifetime-extension.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h?rev=330882&r1=330881&r2=330882&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h Wed 
Apr 25 16:02:06 2018
@@ -110,6 +110,11 @@ public:
 /// 'const int &x = C().x;'.
 bool IsTemporaryLifetimeExtendedViaSubobject = false;
 
+/// This call is a constructor for a temporary that is lifetime-extended
+/// by binding it to a reference-type field within an aggregate,
+/// for example 'A { const C &c; }; A a = { C() };'
+bool IsTemporaryLifetimeExtendedViaAggregate = false;
+
 EvalCallOptions() {}
   };
 

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp?rev=330882&r1=330881&r2=330882&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp Wed Apr 25 16:02:06 2018
@@ -180,14 +180,25 @@ ExprEngine::getRegionForConstructedObjec
 }
 case ConstructionContext::TemporaryObjectKind: {
   const auto *TOCC = cast(CC);
-  // See if we're lifetime-extended via our field. If so, take a note.
-  // Because automatic destructors aren't quite working in this case.
   if (const auto *MTE = TOCC->getMaterializedTemporaryExpr()) {
 if (const ValueDecl *VD = MTE->getExtendingDecl()) {
-  assert(VD->getType()->isReferenceType());
-  if (VD->getType()->getPointeeType().getCanonicalType() !=
-  MTE->GetTemporaryExpr()->getType().getCanonicalType()) {
-CallOpts.IsTemporaryLifetimeExtendedViaSubobject = true;
+  // Pattern-match various forms of lifetime extension that aren't
+  // currently supported by the CFG.
+  // FIXME: Is there a better way to retrieve this information from
+  // the MaterializeTemporaryExpr?
+  assert(MTE->getStorageDuration() != SD_FullExpression);
+  if (VD->getType()->isReferenceType()) {
+assert(VD->getType()->isReferenceType());
+if (VD->getType()->getPointeeType().getCanonicalType() !=
+MTE->GetTemporaryExpr()->getType().getCanonicalType()) {
+  // We're lifetime-extended via our field. Automatic destructors
+  // aren't quite working in this case.
+  CallOpts.IsTemporaryLifetimeExtendedViaSubobject = true;
+}
+  } else {
+// We're lifetime-extended by a surrounding aggregate.
+// Automatic destructors aren't quite working in this case.
+CallOpts.IsTemporaryLifetimeExtendedViaAggregate = true;
   }
 }
   }

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp?rev=330882&r1=330881&r2=330882&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp Wed Apr 25 
16:02:06 2018
@@ -699,6 +699,11 @@ ExprEngine::mayInlineCallKind(const Call
   // within it to a reference, automatic destructors don't work properly.
   if (CallOpts.IsTemporaryLifetimeExtendedViaSubobject)
 return CIP_DisallowedOnce;
+
+  // If the temporary is lifetime-extended by binding it to a reference-typ
+  // field within an aggregate, automatic destructors don't work properly.
+  if (CallOpts.IsTemporaryLifetimeExtendedViaAggregate)
+return CIP_DisallowedOnce;
 }
 
 break;

Modified: cfe/trunk/test/Analysis/lifetime-extension.cpp
URL: 
http://l

r330881 - Fix crash on qualified template name instantiation if the template name has no

2018-04-25 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Apr 25 15:58:55 2018
New Revision: 330881

URL: http://llvm.org/viewvc/llvm-project?rev=330881&view=rev
Log:
Fix crash on qualified template name instantiation if the template name has no
template argument list.

Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaTemplate/dependent-names.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=330881&r1=330880&r2=330881&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Wed Apr 25 15:58:55 2018
@@ -4022,18 +4022,21 @@ ExprResult Sema::BuildTemplateIdExpr(con
   assert(!R.empty() && "empty lookup results when building templateid");
   assert(!R.isAmbiguous() && "ambiguous lookup when building templateid");
 
+  auto AnyDependentArguments = [&]() -> bool {
+bool InstantiationDependent;
+return TemplateArgs &&
+   TemplateSpecializationType::anyDependentTemplateArguments(
+   *TemplateArgs, InstantiationDependent);
+  };
+
   // In C++1y, check variable template ids.
-  bool InstantiationDependent;
-  const bool DependentArguments =
-TemplateSpecializationType::anyDependentTemplateArguments(
-  *TemplateArgs, InstantiationDependent);
-  if (R.getAsSingle() && !DependentArguments) {
+  if (R.getAsSingle() && !AnyDependentArguments()) {
 return CheckVarTemplateId(SS, R.getLookupNameInfo(),
   R.getAsSingle(),
   TemplateKWLoc, TemplateArgs);
   }
 
-  if (R.getAsSingle() && !DependentArguments) {
+  if (R.getAsSingle() && !AnyDependentArguments()) {
 return CheckConceptTemplateId(SS, R.getLookupNameInfo(),
   R.getAsSingle(),
   TemplateKWLoc, TemplateArgs);

Modified: cfe/trunk/test/SemaTemplate/dependent-names.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/dependent-names.cpp?rev=330881&r1=330880&r2=330881&view=diff
==
--- cfe/trunk/test/SemaTemplate/dependent-names.cpp (original)
+++ cfe/trunk/test/SemaTemplate/dependent-names.cpp Wed Apr 25 15:58:55 2018
@@ -419,3 +419,11 @@ template  struct CT2 {
   template  struct X;
 };
 template  int CT2::X<>; // expected-error {{template 
parameter list matching the non-templated nested type 'CT2' should be 
empty}}
+
+namespace DependentTemplateIdWithNoArgs {
+  template void f() { T::template f(); }
+  struct X {
+template static void f();
+  };
+  void g() { f(); }
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45284: [RISCV] More validations on the input value of -march=

2018-04-25 Thread Ana Pazos via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330880: [RISCV] More validations on the input value of 
-march= (authored by apazos, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D45284?vs=143674&id=144031#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45284

Files:
  cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
  cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp
  cfe/trunk/test/Driver/riscv-arch.c

Index: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
@@ -24,6 +24,10 @@
 def err_drv_unknown_language : Error<"language not recognized: '%0'">;
 def err_drv_invalid_arch_name : Error<
   "invalid arch name '%0'">;
+def err_drv_invalid_riscv_arch_name : Error<
+  "invalid arch name '%0', %1">;
+def err_drv_invalid_riscv_ext_arch_name : Error<
+  "invalid arch name '%0', %1 '%2'">;
 def err_drv_cuda_bad_gpu_arch : Error<"Unsupported CUDA gpu architecture: %0">;
 def err_drv_no_cuda_installation : Error<
   "cannot find CUDA installation.  Provide its path via --cuda-path, or pass "
Index: cfe/trunk/test/Driver/riscv-arch.c
===
--- cfe/trunk/test/Driver/riscv-arch.c
+++ cfe/trunk/test/Driver/riscv-arch.c
@@ -1,89 +1,317 @@
-// RUN: %clang -target riscv32-unknown-elf -march=rv32i -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32im -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32ima -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32imaf -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32imafd -### %s -fsyntax-only 2>&1 | FileCheck %s
-
-// RUN: %clang -target riscv32-unknown-elf -march=rv32ic -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32imc -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32imac -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32imafc -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32imafdc -### %s -fsyntax-only 2>&1 | FileCheck %s
-
-// RUN: %clang -target riscv32-unknown-elf -march=rv32ia -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32iaf -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32iafd -### %s -fsyntax-only 2>&1 | FileCheck %s
-
-// RUN: %clang -target riscv32-unknown-elf -march=rv32iac -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32iafc -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32iafdc -### %s -fsyntax-only 2>&1 | FileCheck %s
-
-// RUN: %clang -target riscv32-unknown-elf -march=rv32g -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-unknown-elf -march=rv32gc -### %s -fsyntax-only 2>&1 | FileCheck %s
-
-// RUN: %clang -target riscv64-unknown-elf -march=rv64i -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv64-unknown-elf -march=rv64im -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv64-unknown-elf -march=rv64ima -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv64-unknown-elf -march=rv64imaf -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv64-unknown-elf -march=rv64imafd -### %s -fsyntax-only 2>&1 | FileCheck %s
-
-// RUN: %clang -target riscv64-unknown-elf -march=rv64ic -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv64-unknown-elf -march=rv64imc -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv64-unknown-elf -march=rv64imac -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv64-unknown-elf -march=rv64imafc -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv64-unknown-elf -march=rv64imafdc -### %s -fsyntax-only 2>&1 | FileCheck %s
-
-// RUN: %clang -target riscv64-unknown-elf -march=rv64ia -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv64-unknown-elf -march=rv64iaf -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv64-unknown-elf -march=rv64iafd -### %s -fsyntax-only 2>&1 | FileCheck %s
-
-// RUN: %clang -target riscv64-unknown-elf -march=rv64iac -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv64-unknown-elf -march=rv64iafc -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv64-unknown-elf -march=rv64iafdc -### %s -fsyntax-only 2>&1 | FileCheck %s
-
-// RUN: %clang -t

r330880 - [RISCV] More validations on the input value of -march=

2018-04-25 Thread Ana Pazos via cfe-commits
Author: apazos
Date: Wed Apr 25 15:42:38 2018
New Revision: 330880

URL: http://llvm.org/viewvc/llvm-project?rev=330880&view=rev
Log:
[RISCV] More validations on the input value of -march=

Supporting additional rules for parsing ISA string.

- RISC-V ISA strings must be lowercase.
E.g.: rv32IMC is not supported, rv32imc is correct.

- Multi-letter extensions are to be separated by a single
underscore '_'. The extension prefix counts as a letter.
This means extensions that start with 's', 'sx' and 'sx'
are all multi-letter.
E.g.:
xasb is a single non-standard extension named 'xasb'
xa_sb are two extensions, the non-standard user level extension
'xa', and the supervisor level extension 'sb'.

- Standard user-level extensions are specified following
a canonical order, according to Table 22.1 in
RISC-V User-Level ISA V2.2.

- Non-standard user-level 'x' extensions,
standard supervisor-level 's' extensions and
non-standard supervisor-level 'sx' extensions
are also specified following a canonical order according
to Table 22.1 in RISC-V User-Level ISA V2.2:
'x' extensions, follwed by 's' extensions and then 'sx' extensions.

- Extensions might have a version number.
Underscores may be used to separate ISA subset components to
improve readability and to provide disambiguation.
E.g.: rv32i2_m3_a1_f2_d2

- Version numbers are divided into major and minor numbers,
separated by a 'p'. If the minor version is 0, then 'p0' can
be omitted.

- Additional checks for dependent extensions and invalid
extensions combinations.
E.g.:
'e' requires rv32
'e' can't be combined with 'f' nor 'd'
'q' requires rv64

- TODO items have also been marked with comments in the code.

Reviewers: asb, kito-cheng

Reviewed By: asb

Subscribers: edward-jones, mgrang, zzheng, rbar, johnrusso, simoncook, 
jordy.potman.lists, sabuasal, niosHD, shiva0217, cfe-commits

Differential Revision: https://reviews.llvm.org/D45284

Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp
cfe/trunk/test/Driver/riscv-arch.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=330880&r1=330879&r2=330880&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Wed Apr 25 15:42:38 
2018
@@ -24,6 +24,10 @@ def err_drv_unknown_stdin_type_clang_cl
 def err_drv_unknown_language : Error<"language not recognized: '%0'">;
 def err_drv_invalid_arch_name : Error<
   "invalid arch name '%0'">;
+def err_drv_invalid_riscv_arch_name : Error<
+  "invalid arch name '%0', %1">;
+def err_drv_invalid_riscv_ext_arch_name : Error<
+  "invalid arch name '%0', %1 '%2'">;
 def err_drv_cuda_bad_gpu_arch : Error<"Unsupported CUDA gpu architecture: %0">;
 def err_drv_no_cuda_installation : Error<
   "cannot find CUDA installation.  Provide its path via --cuda-path, or pass "

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp?rev=330880&r1=330879&r2=330880&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp Wed Apr 25 15:42:38 2018
@@ -20,32 +20,232 @@ using namespace clang::driver::tools;
 using namespace clang;
 using namespace llvm::opt;
 
+static StringRef getExtensionTypeDesc(StringRef Ext) {
+  if (Ext.startswith("sx"))
+return "non-standard supervisor-level extension";
+  if (Ext.startswith("s"))
+return "standard supervisor-level extension";
+  if (Ext.startswith("x"))
+return "non-standard user-level extension";
+  return StringRef();
+}
+
+static StringRef getExtensionType(StringRef Ext) {
+  if (Ext.startswith("sx"))
+return "sx";
+  if (Ext.startswith("s"))
+return "s";
+  if (Ext.startswith("x"))
+return "x";
+  return StringRef();
+}
+
+static bool isSupportedExtension(StringRef Ext) {
+  // LLVM does not support "sx", "s" nor "x" extensions.
+  return false;
+}
+
+// Extensions may have a version number, and may be separated by
+// an underscore '_' e.g.: rv32i2_m2.
+// Version number is divided into major and minor version numbers,
+// separated by a 'p'. If the minor version is 0 then 'p0' can be
+// omitted from the version string. E.g., rv32i2p0, rv32i2, rv32i2p1.
+static bool getExtensionVersion(const Driver &D, StringRef MArch,
+StringRef Ext, StringRef In,
+std::string &Major, std::string &Minor) {
+  auto I = In.begin();
+  auto E = In.end();
+
+  while (I != E && isdigit(*I))
+Major.append(1, *I++);
+
+  if (Major.empty())
+return true;
+
+  if (I != E && *I == 'p') {
+++I;
+
+while (I 

[PATCH] D43341: [clang-doc] Implement reducer portion of the frontend framework

2018-04-25 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang-doc/BitcodeWriter.h:129
 // Check that the static size is large-enough.
 assert(Record.capacity() > BitCodeConstants::RecordSize);
   }

juliehockett wrote:
> lebedev.ri wrote:
> > lebedev.ri wrote:
> > > juliehockett wrote:
> > > > lebedev.ri wrote:
> > > > > Isn't that the opposite of what was that assert supposed to do?
> > > > > It would have been better to just `// disable` it, and add a `FIXME` 
> > > > > note.
> > > > I'm not sure I'm understanding you -- my understanding was that it 
> > > > existed to check that the record size was large enough.
> > > https://reviews.llvm.org/D41102?id=136520#inline-384087
> > > ```
> > > #ifndef NDEBUG // Don't want explicit dtor unless needed
> > > ~ClangDocBitcodeWriter() {
> > >   // Check that the static size is large-enough.
> > >   assert(Record.capacity() == BitCodeConstants::RecordSize);
> > > }
> > > #endif
> > > ```
> > > I.e. it checked that it still only had the static size, and did not 
> > > transform into normal `vector` with data stored on heap-allocated buffer.
> > Ok, let me use more words this time.
> > There are several storage container types with contiguous storage:
> > * `array` - fixed-size stack storage, size == capacity == compile-time 
> > constant
> > * `vector` - dynamic heap storage, size <= capacity
> > * `smallvector` - fixed-size stack storage, and if the data does not fit, 
> > it degrades into the `vector`.
> > 
> > But there is also one more option:
> > * `fixedvector` - which is a `array` - has only fixed-size stack storage 
> > (capacity == compile-time constant), but with vector-like interface, i.e. 
> > size <= capacity, and size can be changed at run-time.
> > 
> > In llvm, i'm not aware of existence of `llvm::fixedvector`, so that assert 
> > was ensuring that the `smallvector` behaved like the `fixedvector` - it 
> > only had the fixed-size stack storage, and 'did not have' the heap buffer.
> > 
> > This is a kinda ugly hack, but i think the current assert clearly does 
> > something different...
> > 
> > Does that make any sense?
> Ah, yes. I see what you're trying to do, but the issue with that is it 
> assumes that the record must be a certain size (or smaller). However, there 
> is no guarantee of the size of the record (i.e. there may and will be records 
> of variable size getting written), so it's not unreasonable to think that the 
> record may need to be resized to accommodate that.
> However, there is no guarantee of the size of the record (i.e. there may and 
> will be records of variable size getting written), so it's not unreasonable 
> to think that the record may need to be resized to accommodate that.

Yes, but *currently* that was correct assumption.
All variable-length records (well, blobs) are (were?) emitted directly, without 
using this intermediate `Record` container.


https://reviews.llvm.org/D43341



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43341: [clang-doc] Implement reducer portion of the frontend framework

2018-04-25 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett marked 5 inline comments as done.
juliehockett added inline comments.



Comment at: clang-doc/BitcodeReader.h:59
+
+  void storeData(llvm::SmallVectorImpl &Field, llvm::StringRef Blob);
+  void storeData(bool &Field, llvm::StringRef Blob);

sammccall wrote:
> Comment for these like "decodes the blob part of a record" - or just rename 
> these `decodeBlob` or similar?
In general they decode the record abbrev of the field, which is a single blob 
in many, but not all, cases. I've changed it to `decodeRecord`, but is too 
similar to the above?



Comment at: clang-doc/BitcodeWriter.h:129
 // Check that the static size is large-enough.
 assert(Record.capacity() > BitCodeConstants::RecordSize);
   }

lebedev.ri wrote:
> lebedev.ri wrote:
> > juliehockett wrote:
> > > lebedev.ri wrote:
> > > > Isn't that the opposite of what was that assert supposed to do?
> > > > It would have been better to just `// disable` it, and add a `FIXME` 
> > > > note.
> > > I'm not sure I'm understanding you -- my understanding was that it 
> > > existed to check that the record size was large enough.
> > https://reviews.llvm.org/D41102?id=136520#inline-384087
> > ```
> > #ifndef NDEBUG // Don't want explicit dtor unless needed
> > ~ClangDocBitcodeWriter() {
> >   // Check that the static size is large-enough.
> >   assert(Record.capacity() == BitCodeConstants::RecordSize);
> > }
> > #endif
> > ```
> > I.e. it checked that it still only had the static size, and did not 
> > transform into normal `vector` with data stored on heap-allocated buffer.
> Ok, let me use more words this time.
> There are several storage container types with contiguous storage:
> * `array` - fixed-size stack storage, size == capacity == compile-time 
> constant
> * `vector` - dynamic heap storage, size <= capacity
> * `smallvector` - fixed-size stack storage, and if the data does not fit, it 
> degrades into the `vector`.
> 
> But there is also one more option:
> * `fixedvector` - which is a `array` - has only fixed-size stack storage 
> (capacity == compile-time constant), but with vector-like interface, i.e. 
> size <= capacity, and size can be changed at run-time.
> 
> In llvm, i'm not aware of existence of `llvm::fixedvector`, so that assert 
> was ensuring that the `smallvector` behaved like the `fixedvector` - it only 
> had the fixed-size stack storage, and 'did not have' the heap buffer.
> 
> This is a kinda ugly hack, but i think the current assert clearly does 
> something different...
> 
> Does that make any sense?
Ah, yes. I see what you're trying to do, but the issue with that is it assumes 
that the record must be a certain size (or smaller). However, there is no 
guarantee of the size of the record (i.e. there may and will be records of 
variable size getting written), so it's not unreasonable to think that the 
record may need to be resized to accommodate that.


https://reviews.llvm.org/D43341



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r330878 - [driver][darwin] Do not infer -simulator environment for OS version env vars

2018-04-25 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Apr 25 15:23:26 2018
New Revision: 330878

URL: http://llvm.org/viewvc/llvm-project?rev=330878&view=rev
Log:
[driver][darwin] Do not infer -simulator environment for OS version env vars
with non-simulator SDKs

rdar://37955008

Modified:
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/test/Driver/darwin-infer-simulator-sdkroot.c

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=330878&r1=330877&r2=330878&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Wed Apr 25 15:23:26 2018
@@ -1197,6 +1197,11 @@ struct DarwinPlatform {
 
   DarwinEnvironmentKind getEnvironment() const { return Environment; }
 
+  void setEnvironment(DarwinEnvironmentKind Kind) {
+Environment = Kind;
+InferSimulatorFromArch = false;
+  }
+
   StringRef getOSVersion() const {
 if (Kind == OSVersionArg)
   return Argument->getValue();
@@ -1214,7 +1219,7 @@ struct DarwinPlatform {
   bool isExplicitlySpecified() const { return Kind <= DeploymentTargetEnv; }
 
   /// Returns true if the simulator environment can be inferred from the arch.
-  bool canInferSimulatorFromArch() const { return Kind != InferredFromSDK; }
+  bool canInferSimulatorFromArch() const { return InferSimulatorFromArch; }
 
   /// Adds the -m-version-min argument to the compiler invocation.
   void addOSVersionMinArgument(DerivedArgList &Args, const OptTable &Opts) {
@@ -1290,6 +1295,7 @@ struct DarwinPlatform {
 DarwinPlatform Result(InferredFromSDK, Platform, Value);
 if (IsSimulator)
   Result.Environment = DarwinEnvironmentKind::Simulator;
+Result.InferSimulatorFromArch = false;
 return Result;
   }
   static DarwinPlatform createFromArch(llvm::Triple::OSType OS,
@@ -1324,7 +1330,7 @@ private:
   DarwinPlatformKind Platform;
   DarwinEnvironmentKind Environment = DarwinEnvironmentKind::NativeEnvironment;
   std::string OSVersion;
-  bool HasOSVersion = true;
+  bool HasOSVersion = true, InferSimulatorFromArch = true;
   Arg *Argument;
   StringRef EnvVarName;
 };
@@ -1593,9 +1599,16 @@ void Darwin::AddDeploymentTarget(Derived
 OSTarget = getDeploymentTargetFromOSVersionArg(Args, getDriver());
 // If no deployment target was specified on the command line, check for
 // environment defines.
-if (!OSTarget)
+if (!OSTarget) {
   OSTarget =
   getDeploymentTargetFromEnvironmentVariables(getDriver(), 
getTriple());
+  if (OSTarget) {
+// Don't infer simulator from the arch when the SDK is also specified.
+Optional SDKTarget = 
inferDeploymentTargetFromSDK(Args);
+if (SDKTarget)
+  OSTarget->setEnvironment(SDKTarget->getEnvironment());
+  }
+}
 // If there is no command-line argument to specify the Target version and
 // no environment variable defined, see if we can set the default based
 // on -isysroot.

Modified: cfe/trunk/test/Driver/darwin-infer-simulator-sdkroot.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-infer-simulator-sdkroot.c?rev=330878&r1=330877&r2=330878&view=diff
==
--- cfe/trunk/test/Driver/darwin-infer-simulator-sdkroot.c (original)
+++ cfe/trunk/test/Driver/darwin-infer-simulator-sdkroot.c Wed Apr 25 15:23:26 
2018
@@ -6,6 +6,8 @@
 // RUN: mkdir -p %t/SDKs/iPhoneOS8.0.0.sdk
 // RUN: env SDKROOT=%t/SDKs/iPhoneOS8.0.0.sdk %clang %s -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-IPHONE %s
+// RUN: env SDKROOT=%t/SDKs/iPhoneOS8.0.0.sdk IPHONEOS_DEPLOYMENT_TARGET=8.0 
%clang %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-IPHONE %s
 // CHECK-IPHONE: clang
 // CHECK-IPHONE: "-cc1"
 // CHECK-IPHONE: -apple-ios8.0.0"
@@ -29,6 +31,8 @@
 // RUN: mkdir -p %t/SDKs/WatchOS3.0.sdk
 // RUN: env SDKROOT=%t/SDKs/WatchOS3.0.sdk %clang %s -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-WATCH %s
+// RUN: env WATCHOS_DEPLOYMENT_TARGET=3.0 %clang %s -isysroot 
%t/SDKs/WatchOS3.0.sdk -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-WATCH %s
 //
 // CHECK-WATCH: clang
 // CHECK-WATCH: "-cc1"


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45839: [analyzer] Add support for WebKit "unified sources".

2018-04-25 Thread Phabricator via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330876: [analyzer] Enable analysis of WebKit "unified 
sources". (authored by dergachev, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D45839?vs=143416&id=144015#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45839

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
  cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  cfe/trunk/test/Analysis/unified-sources/UnifiedSource-1.cpp
  cfe/trunk/test/Analysis/unified-sources/container.h
  cfe/trunk/test/Analysis/unified-sources/source1.cpp
  cfe/trunk/test/Analysis/unified-sources/source2.cpp

Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
@@ -126,6 +126,36 @@
   AnalysisDeclContext *getAnalysisDeclContext(const Decl *D) {
 return AnaCtxMgr.getContext(D);
   }
+
+  static bool isInCodeFile(SourceLocation SL, const SourceManager &SM) {
+if (SM.isInMainFile(SL))
+  return true;
+
+// Support the "unified sources" compilation method (eg. WebKit) that
+// involves producing non-header files that include other non-header files.
+// We should be included directly from a UnifiedSource* file
+// and we shouldn't be a header - which is a very safe defensive check.
+SourceLocation IL = SM.getIncludeLoc(SM.getFileID(SL));
+if (!IL.isValid() || !SM.isInMainFile(IL))
+  return false;
+// Should rather be "file name starts with", but the current .getFilename
+// includes the full path.
+if (SM.getFilename(IL).contains("UnifiedSource")) {
+  // It might be great to reuse FrontendOptions::getInputKindForExtension()
+  // but for now it doesn't discriminate between code and header files.
+  return llvm::StringSwitch(SM.getFilename(SL).rsplit('.').second)
+  .Cases("c", "m", "mm", "C", "cc", "cp", true)
+  .Cases("cpp", "CPP", "c++", "cxx", "cppm", true)
+  .Default(false);
+}
+
+return false;
+  }
+
+  bool isInCodeFile(SourceLocation SL) {
+const SourceManager &SM = getASTContext().getSourceManager();
+return isInCodeFile(SL, SM);
+  }
 };
 
 } // enAnaCtxMgrspace
Index: cfe/trunk/test/Analysis/unified-sources/container.h
===
--- cfe/trunk/test/Analysis/unified-sources/container.h
+++ cfe/trunk/test/Analysis/unified-sources/container.h
@@ -0,0 +1,10 @@
+class ContainerInHeaderFile {
+  class Iterator {
+  };
+
+public:
+  Iterator begin() const;
+  Iterator end() const;
+
+  int method() { return 0; }
+};
Index: cfe/trunk/test/Analysis/unified-sources/source2.cpp
===
--- cfe/trunk/test/Analysis/unified-sources/source2.cpp
+++ cfe/trunk/test/Analysis/unified-sources/source2.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+
+// This test tests that the warning is here when it is included from
+// the unified sources file. The run-line in this file is there
+// only to suppress LIT warning for the complete lack of run-line.
+int testNullDereference() {
+  int *x = 0;
+  return *x; // expected-warning{{}}
+}
+
+// Let's see if the container inlining heuristic still works.
+class ContainerInCodeFile {
+  class Iterator {
+  };
+
+public:
+  Iterator begin() const;
+  Iterator end() const;
+
+  int method() { return 0; }
+};
+
+int testContainerMethodInCodeFile(ContainerInCodeFile Cont) {
+  return 1 / Cont.method(); // expected-warning{{}}
+}
Index: cfe/trunk/test/Analysis/unified-sources/UnifiedSource-1.cpp
===
--- cfe/trunk/test/Analysis/unified-sources/UnifiedSource-1.cpp
+++ cfe/trunk/test/Analysis/unified-sources/UnifiedSource-1.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+
+// There should still be diagnostics within included files.
+#include "source1.cpp"
+#include "source2.cpp"
Index: cfe/trunk/test/Analysis/unified-sources/source1.cpp
===
--- cfe/trunk/test/Analysis/unified-sources/source1.cpp
+++ cfe/trunk/test/Analysis/unified-sources/source1.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+
+// This test tests that the warning is here when it is included from
+// the unified sources file. The run-line i

[PATCH] D45839: [analyzer] Add support for WebKit "unified sources".

2018-04-25 Thread Phabricator via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rC330876: [analyzer] Enable analysis of WebKit "unified 
sources". (authored by dergachev, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D45839

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
  lib/StaticAnalyzer/Core/CallEvent.cpp
  lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  test/Analysis/unified-sources/UnifiedSource-1.cpp
  test/Analysis/unified-sources/container.h
  test/Analysis/unified-sources/source1.cpp
  test/Analysis/unified-sources/source2.cpp

Index: include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
@@ -126,6 +126,36 @@
   AnalysisDeclContext *getAnalysisDeclContext(const Decl *D) {
 return AnaCtxMgr.getContext(D);
   }
+
+  static bool isInCodeFile(SourceLocation SL, const SourceManager &SM) {
+if (SM.isInMainFile(SL))
+  return true;
+
+// Support the "unified sources" compilation method (eg. WebKit) that
+// involves producing non-header files that include other non-header files.
+// We should be included directly from a UnifiedSource* file
+// and we shouldn't be a header - which is a very safe defensive check.
+SourceLocation IL = SM.getIncludeLoc(SM.getFileID(SL));
+if (!IL.isValid() || !SM.isInMainFile(IL))
+  return false;
+// Should rather be "file name starts with", but the current .getFilename
+// includes the full path.
+if (SM.getFilename(IL).contains("UnifiedSource")) {
+  // It might be great to reuse FrontendOptions::getInputKindForExtension()
+  // but for now it doesn't discriminate between code and header files.
+  return llvm::StringSwitch(SM.getFilename(SL).rsplit('.').second)
+  .Cases("c", "m", "mm", "C", "cc", "cp", true)
+  .Cases("cpp", "CPP", "c++", "cxx", "cppm", true)
+  .Default(false);
+}
+
+return false;
+  }
+
+  bool isInCodeFile(SourceLocation SL) {
+const SourceManager &SM = getASTContext().getSourceManager();
+return isInCodeFile(SL, SM);
+  }
 };
 
 } // enAnaCtxMgrspace
Index: test/Analysis/unified-sources/container.h
===
--- test/Analysis/unified-sources/container.h
+++ test/Analysis/unified-sources/container.h
@@ -0,0 +1,10 @@
+class ContainerInHeaderFile {
+  class Iterator {
+  };
+
+public:
+  Iterator begin() const;
+  Iterator end() const;
+
+  int method() { return 0; }
+};
Index: test/Analysis/unified-sources/source2.cpp
===
--- test/Analysis/unified-sources/source2.cpp
+++ test/Analysis/unified-sources/source2.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+
+// This test tests that the warning is here when it is included from
+// the unified sources file. The run-line in this file is there
+// only to suppress LIT warning for the complete lack of run-line.
+int testNullDereference() {
+  int *x = 0;
+  return *x; // expected-warning{{}}
+}
+
+// Let's see if the container inlining heuristic still works.
+class ContainerInCodeFile {
+  class Iterator {
+  };
+
+public:
+  Iterator begin() const;
+  Iterator end() const;
+
+  int method() { return 0; }
+};
+
+int testContainerMethodInCodeFile(ContainerInCodeFile Cont) {
+  return 1 / Cont.method(); // expected-warning{{}}
+}
Index: test/Analysis/unified-sources/UnifiedSource-1.cpp
===
--- test/Analysis/unified-sources/UnifiedSource-1.cpp
+++ test/Analysis/unified-sources/UnifiedSource-1.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+
+// There should still be diagnostics within included files.
+#include "source1.cpp"
+#include "source2.cpp"
Index: test/Analysis/unified-sources/source1.cpp
===
--- test/Analysis/unified-sources/source1.cpp
+++ test/Analysis/unified-sources/source1.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+
+// This test tests that the warning is here when it is included from
+// the unified sources file. The run-line in this file is there
+// only to suppress LIT warning for the complete lack of run-line.
+int foo(int x) {
+  if (x) {}
+  return 1 / x; // expected-warning{{}}
+}
+
+// Let's see if the container inlining heuristic still works.
+#include "container.h"
+int testContainerMethodInHeaderFile(ContainerInHeaderFile Cont) {
+  return 1 / Cont.method(); // no-warning
+

r330876 - [analyzer] Enable analysis of WebKit "unified sources".

2018-04-25 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Apr 25 14:51:26 2018
New Revision: 330876

URL: http://llvm.org/viewvc/llvm-project?rev=330876&view=rev
Log:
[analyzer] Enable analysis of WebKit "unified sources".

Normally the analyzer begins path-sensitive analysis from functions within
the main file, even though the path is allowed to go through any functions
within the translation unit.

When a recent version of WebKit is compiled, the "unified sources" technique
is used, that assumes #including multiple code files into a single main file.
Such file would have no functions defined in it, so the analyzer wouldn't be
able to find any entry points for path-sensitive analysis.

This patch pattern-matches unified file names that are similar to those
used by WebKit and allows the analyzer to find entry points in the included
code files. A more aggressive/generic approach is being planned as well.

Differential Revision: https://reviews.llvm.org/D45839

Added:
cfe/trunk/test/Analysis/unified-sources/
cfe/trunk/test/Analysis/unified-sources/UnifiedSource-1.cpp
cfe/trunk/test/Analysis/unified-sources/container.h
cfe/trunk/test/Analysis/unified-sources/source1.cpp
cfe/trunk/test/Analysis/unified-sources/source2.cpp
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h?rev=330876&r1=330875&r2=330876&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h 
Wed Apr 25 14:51:26 2018
@@ -126,6 +126,36 @@ public:
   AnalysisDeclContext *getAnalysisDeclContext(const Decl *D) {
 return AnaCtxMgr.getContext(D);
   }
+
+  static bool isInCodeFile(SourceLocation SL, const SourceManager &SM) {
+if (SM.isInMainFile(SL))
+  return true;
+
+// Support the "unified sources" compilation method (eg. WebKit) that
+// involves producing non-header files that include other non-header files.
+// We should be included directly from a UnifiedSource* file
+// and we shouldn't be a header - which is a very safe defensive check.
+SourceLocation IL = SM.getIncludeLoc(SM.getFileID(SL));
+if (!IL.isValid() || !SM.isInMainFile(IL))
+  return false;
+// Should rather be "file name starts with", but the current .getFilename
+// includes the full path.
+if (SM.getFilename(IL).contains("UnifiedSource")) {
+  // It might be great to reuse FrontendOptions::getInputKindForExtension()
+  // but for now it doesn't discriminate between code and header files.
+  return llvm::StringSwitch(SM.getFilename(SL).rsplit('.').second)
+  .Cases("c", "m", "mm", "C", "cc", "cp", true)
+  .Cases("cpp", "CPP", "c++", "cxx", "cppm", true)
+  .Default(false);
+}
+
+return false;
+  }
+
+  bool isInCodeFile(SourceLocation SL) {
+const SourceManager &SM = getASTContext().getSourceManager();
+return isInCodeFile(SL, SM);
+  }
 };
 
 } // enAnaCtxMgrspace

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp?rev=330876&r1=330875&r2=330876&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp Wed Apr 25 14:51:26 2018
@@ -939,15 +939,14 @@ const ObjCPropertyDecl *ObjCMethodCall::
 bool ObjCMethodCall::canBeOverridenInSubclass(ObjCInterfaceDecl *IDecl,
  Selector Sel) const {
   assert(IDecl);
-  const SourceManager &SM =
-getState()->getStateManager().getContext().getSourceManager();
-
+  AnalysisManager &AMgr =
+  getState()->getStateManager().getOwningEngine()->getAnalysisManager();
   // If the class interface is declared inside the main file, assume it is not
   // subcassed.
   // TODO: It could actually be subclassed if the subclass is private as well.
   // This is probably very rare.
   SourceLocation InterfLoc = IDecl->getEndOfDefinitionLoc();
-  if (InterfLoc.isValid() && SM.isInMainFile(InterfLoc))
+  if (InterfLoc.isValid() && AMgr.isInCodeFile(InterfLoc))
 return false;
 
   // Assume that property accessors are not overridden.
@@ -969,7 +968,7 @@ bool ObjCMethodCall::canBeOverridenInSub
   return false;
 
 // If outside the main file,
-if (D->getLocation().isValid() && !SM.isInMai

[PATCH] D43341: [clang-doc] Implement reducer portion of the frontend framework

2018-04-25 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 144011.
juliehockett marked 17 inline comments as done.
juliehockett added a comment.

Reorganizing and streamlining, particularly in decoupling the reader from the 
reduce process and redesigning a bit to allow for more flexible reducing. 
Currently implements an in-memory reducer, but could (theoretically) be 
extended.


https://reviews.llvm.org/D43341

Files:
  clang-doc/BitcodeReader.cpp
  clang-doc/BitcodeReader.h
  clang-doc/BitcodeWriter.cpp
  clang-doc/BitcodeWriter.h
  clang-doc/CMakeLists.txt
  clang-doc/Index.cpp
  clang-doc/Index.h
  clang-doc/Reducer.cpp
  clang-doc/Reducer.h
  clang-doc/Representation.cpp
  clang-doc/Representation.h
  clang-doc/tool/ClangDocMain.cpp
  docs/ReleaseNotes.rst
  test/clang-doc/bc-comment.cpp
  test/clang-doc/bc-namespace.cpp
  test/clang-doc/bc-record.cpp

Index: test/clang-doc/bc-record.cpp
===
--- /dev/null
+++ test/clang-doc/bc-record.cpp
@@ -0,0 +1,183 @@
+// This test requires Linux due to the system-dependent USR for the
+// inner class in function H.
+// REQUIRES: system-linux
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/bc/ACE81AFA6627B4CEF2B456FB6E1252925674AF7E.bc --dump | FileCheck %s --check-prefix CHECK-A
+// RUN: llvm-bcanalyzer %t/docs/bc/FC07BD34D5E77782C263FA97929EA8753740.bc --dump | FileCheck %s --check-prefix CHECK-B
+// RUN: llvm-bcanalyzer %t/docs/bc/1E3438A08BA22025C0B46289FF0686F92C8924C5.bc --dump | FileCheck %s --check-prefix CHECK-BC
+// RUN: llvm-bcanalyzer %t/docs/bc/06B5F6A19BA9F6A832E127C9968282B94619B210.bc --dump | FileCheck %s --check-prefix CHECK-C
+// RUN: llvm-bcanalyzer %t/docs/bc/0921737541208B8FA9BB42B60F78AC1D779AA054.bc --dump | FileCheck %s --check-prefix CHECK-D
+// RUN: llvm-bcanalyzer %t/docs/bc/289584A8E0FF4178A794622A547AA622503967A1.bc --dump | FileCheck %s --check-prefix CHECK-E
+// RUN: llvm-bcanalyzer %t/docs/bc/DEB4AC1CD9253CD9EF7FBE6BCAC506D77984ABD4.bc --dump | FileCheck %s --check-prefix CHECK-ECON
+// RUN: llvm-bcanalyzer %t/docs/bc/BD2BDEBD423F80BACCEA75DE6D6622D355FC2D17.bc --dump | FileCheck %s --check-prefix CHECK-EDES
+// RUN: llvm-bcanalyzer %t/docs/bc/E3B54702FABFF4037025BA194FC27C47006330B5.bc --dump | FileCheck %s --check-prefix CHECK-F
+// RUN: llvm-bcanalyzer %t/docs/bc/B6AC4C5C9F2EA3F2B3ECE1A33D349F4EE502B24E.bc --dump | FileCheck %s --check-prefix CHECK-H
+// RUN: llvm-bcanalyzer %t/docs/bc/E81CE07BB3FCCC7A88D059FC33F4140DF74F63DA.bc --dump | FileCheck %s --check-prefix CHECK-I
+// RUN: llvm-bcanalyzer %t/docs/bc/5093D428CDC62096A67547BA52566E4FB9404EEE.bc --dump | FileCheck %s --check-prefix CHECK-PM
+// RUN: llvm-bcanalyzer %t/docs/bc/CA7C7935730B5EACD25F080E9C83FA087CCDC75E.bc --dump | FileCheck %s --check-prefix CHECK-X
+// RUN: llvm-bcanalyzer %t/docs/bc/641AB4A3D36399954ACDE29C7A8833032BF40472.bc --dump | FileCheck %s --check-prefix CHECK-Y
+
+union A { int X; int Y; };
+// CHECK-A: 
+  // CHECK-A-NEXT: 
+  // CHECK-A-NEXT:  blob data = 'A'
+  // CHECK-A-NEXT:  blob data = '{{.*}}'
+  // CHECK-A-NEXT: 
+  // CHECK-A-NEXT: 
+// CHECK-A-NEXT:  blob data = 'int'
+// CHECK-A-NEXT:  blob data = 'A::X'
+// CHECK-A-NEXT: 
+  // CHECK-A-NEXT: 
+  // CHECK-A-NEXT: 
+// CHECK-A-NEXT:  blob data = 'int'
+// CHECK-A-NEXT:  blob data = 'A::Y'
+// CHECK-A-NEXT: 
+  // CHECK-A-NEXT: 
+// CHECK-A-NEXT: 
+
+enum B { X, Y };
+// CHECK-B: 
+  // CHECK-B-NEXT: 
+  // CHECK-B-NEXT:  blob data = 'B'
+  // CHECK-B-NEXT:  blob data = '{{.*}}'
+  // CHECK-B-NEXT:  blob data = 'X'
+  // CHECK-B-NEXT:  blob data = 'Y'
+// CHECK-B-NEXT: 
+
+enum class Bc { A, B };
+// CHECK-BC: 
+  // CHECK-BC-NEXT: 
+  // CHECK-BC-NEXT:  blob data = 'Bc'
+  // CHECK-BC-NEXT:  blob data = '{{.*}}'
+  // CHECK-BC-NEXT: 
+  // CHECK-BC-NEXT:  blob data = 'A'
+  // CHECK-BC-NEXT:  blob data = 'B'
+// CHECK-BC-NEXT: 
+
+struct C { int i; };
+// CHECK-C: 
+  // CHECK-C-NEXT: 
+  // CHECK-C-NEXT:  blob data = 'C'
+  // CHECK-C-NEXT:  blob data = '{{.*}}'
+  // CHECK-C-NEXT: 
+// CHECK-C-NEXT:  blob data = 'int'
+// CHECK-C-NEXT:  blob data = 'C::i'
+// CHECK-C-NEXT: 
+  // CHECK-C-NEXT: 
+// CHECK-C-NEXT: 
+
+class D {};
+// CHECK-D: 
+  // CHECK-D-NEXT: 
+  // CHECK-D-NEXT:  blob data = 'D'
+  // CHECK-D-NEXT:  blob data = '{{.*}}'
+  // CHECK-D-NEXT: 
+// CHECK-D-NEXT: 
+
+class E {
+public:
+  E() {}
+  ~E() {}
+
+protected:
+  void ProtectedMethod();
+};
+// CHECK-E: 
+  // CHECK-E-NEXT: 
+  // CHECK-E-NEXT:  blob data = 'E'
+  // CHECK-E-NEXT:  blob data = '{{.*}}'
+  // CHECK-E-NEXT: 
+// CHECK-E-NEXT: 
+
+// CHECK-ECON: 
+  // CHECK-ECON-NEXT: 
+  // CHECK-ECON-NEXT:  blob data = 'E'
+  // CHECK-ECON-NEXT:  blob data = '289584A8E0FF4178A794622A547AA622503967A1'
+  // CHECK-ECON-NEXT: 
+  // CHECK-ECON-NEXT:  blob data = '{{

[PATCH] D46084: Addition of the Fixed Point _Accum type

2018-04-25 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added reviewers: phosek, mcgrathr.
leonardchan added a project: clang.

This diff includes changes for supporting the following types.

  // Primary fixed point types
  signed short _Accum s_short_accum;
  signed _Accum s_accum;
  signed long _Accum s_long_accum;
  unsigned short _Accum u_short_accum;
  unsigned _Accum u_accum;
  unsigned long _Accum u_long_accum;
  
  // Aliased fixed point types
  short _Accum short_accum;
  _Accum accum;
  long _Accum long_accum;

This diff only allows for declaration of the fixed point types. Assignment and 
other operations done on fixed point types according to 
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1169.pdf will be added in 
future patches. The saturated versions of these types and the equivalent 
`_Fract` types will also be added in future patches.

The tests included are for asserting that we can declare these types.


Repository:
  rC Clang

https://reviews.llvm.org/D46084

Files:
  include/clang-c/Index.h
  include/clang/AST/ASTContext.h
  include/clang/AST/BuiltinTypes.def
  include/clang/Basic/Specifiers.h
  include/clang/Basic/TokenKinds.def
  include/clang/Sema/DeclSpec.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/NSAPI.cpp
  lib/AST/Type.cpp
  lib/AST/TypeLoc.cpp
  lib/Analysis/PrintfFormatString.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Index/USRGeneration.cpp
  lib/Parse/ParseDecl.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReader.cpp
  test/Frontend/accum.cpp
  test/Frontend/accum_errors.cpp
  tools/libclang/CXType.cpp

Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -53,6 +53,12 @@
 BTCASE(Float);
 BTCASE(Double);
 BTCASE(LongDouble);
+BTCASE(ShortAccum);
+BTCASE(Accum);
+BTCASE(LongAccum);
+BTCASE(UShortAccum);
+BTCASE(UAccum);
+BTCASE(ULongAccum);
 BTCASE(Float16);
 BTCASE(Float128);
 BTCASE(NullPtr);
@@ -542,6 +548,12 @@
 TKIND(Float);
 TKIND(Double);
 TKIND(LongDouble);
+TKIND(ShortAccum);
+TKIND(Accum);
+TKIND(LongAccum);
+TKIND(UShortAccum);
+TKIND(UAccum);
+TKIND(ULongAccum);
 TKIND(Float16);
 TKIND(Float128);
 TKIND(NullPtr);
Index: test/Frontend/accum_errors.cpp
===
--- /dev/null
+++ test/Frontend/accum_errors.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
+
+long long _Accum longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
+unsigned long long _Accum u_longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
Index: test/Frontend/accum.cpp
===
--- /dev/null
+++ test/Frontend/accum.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -std=c++11 -ast-dump %s | FileCheck %s --strict-whitespace
+
+/*  Various contexts where type _Accum can appear. */
+
+// Primary fixed point types
+signed short _Accum s_short_accum;
+signed _Accum s_accum;
+signed long _Accum s_long_accum;
+unsigned short _Accum u_short_accum;
+unsigned _Accum u_accum;
+unsigned long _Accum u_long_accum;
+
+// Aliased fixed point types
+short _Accum short_accum;
+_Accum accum;
+long _Accum long_accum;
+
+//CHECK:  |-VarDecl {{.*}} s_short_accum 'short _Accum'
+//CHECK-NEXT: |-VarDecl {{.*}} s_accum '_Accum'
+//CHECK-NEXT: |-VarDecl {{.*}} s_long_accum 'long _Accum'
+//CHECK-NEXT: |-VarDecl {{.*}} u_short_accum 'unsigned short _Accum'
+//CHECK-NEXT: |-VarDecl {{.*}} u_accum 'unsigned _Accum'
+//CHECK-NEXT: |-VarDecl {{.*}} u_long_accum 'unsigned long _Accum'
+//CHECK-NEXT: |-VarDecl {{.*}} short_accum 'short _Accum'
+//CHECK-NEXT: |-VarDecl {{.*}} accum '_Accum'
+//CHECK-NEXT: `-VarDecl {{.*}} long_accum 'long _Accum'
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -6816,6 +6816,24 @@
 case PREDEF_TYPE_LONGDOUBLE_ID:
   T = Context.LongDoubleTy;
   break;
+case PREDEF_TYPE_SHORT_ACCUM_ID:
+  T = Context.ShortAccumTy;
+  break;
+case PREDEF_TYPE_ACCUM_ID:
+  T = Context.AccumTy;
+  break;
+case PREDEF_TYPE_LONG_ACCUM_ID:
+  T = Context.LongAccumTy;
+  break;
+case PREDEF_TYPE_USHORT_ACCUM_ID:
+  T = Context.UnsignedShortAccumTy;
+  break;
+case PREDEF_TYPE_UACCUM_ID:
+  T = Context.UnsignedAccumTy;
+  break;
+case PREDEF_TYPE_ULONG_ACCUM_ID:
+  T = Context.UnsignedLongAccumTy;
+  break;
 case PREDEF_TYPE_FLOAT16_ID:
   T = Context.Float16Ty;
   

[PATCH] D45964: [Driver] Fix implicit config files from prefixed symlinks

2018-04-25 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330871: [Driver] Fix implicit config files from prefixed 
symlinks (authored by mstorsjo, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D45964?vs=143794&id=144007#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45964

Files:
  cfe/trunk/include/clang/Driver/ToolChain.h
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/test/Driver/config-file3.c


Index: cfe/trunk/include/clang/Driver/ToolChain.h
===
--- cfe/trunk/include/clang/Driver/ToolChain.h
+++ cfe/trunk/include/clang/Driver/ToolChain.h
@@ -78,6 +78,10 @@
   bool IsRegistered)
   : TargetPrefix(Target), ModeSuffix(Suffix), DriverMode(Mode),
 TargetIsValid(IsRegistered) {}
+
+  bool isEmpty() const {
+return TargetPrefix.empty() && ModeSuffix.empty() && DriverMode == nullptr;
+  }
 };
 
 /// ToolChain - Access to tools for a single platform.
Index: cfe/trunk/test/Driver/config-file3.c
===
--- cfe/trunk/test/Driver/config-file3.c
+++ cfe/trunk/test/Driver/config-file3.c
@@ -27,6 +27,14 @@
 // FULL-NAME: -Wundefined-func-template
 // FULL-NAME-NOT: -Werror
 //
+//--- Invocation qqq-clang-g++ tries to find config file qqq-clang-g++.cfg 
even without -no-canonical-prefixes.
+// (As the clang executable and symlink are in different directories, this
+// requires specifying the path via --config-*-dir= though.)
+//
+// RUN: %T/testdmode/qqq-clang-g++ --config-system-dir= 
--config-user-dir=%T/testdmode -c %s -### 2>&1 | FileCheck %s -check-prefix 
SYMLINK
+//
+// SYMLINK: Configuration file: {{.*}}/testdmode/qqq-clang-g++.cfg
+//
 //--- File specified by --config overrides config inferred from clang 
executable.
 //
 // RUN: %T/testdmode/qqq-clang-g++ --config-system-dir=%S/Inputs/config 
--config-user-dir= --config i386-qqq -c -no-canonical-prefixes %s -### 2>&1 | 
FileCheck %s -check-prefix CHECK-EXPLICIT
Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -129,7 +129,8 @@
 
 void Driver::ParseDriverMode(StringRef ProgramName,
  ArrayRef Args) {
-  ClangNameParts = ToolChain::getTargetAndModeFromProgramName(ProgramName);
+  if (ClangNameParts.isEmpty())
+ClangNameParts = ToolChain::getTargetAndModeFromProgramName(ProgramName);
   setDriverModeFromOption(ClangNameParts.DriverMode);
 
   for (const char *ArgPtr : Args) {


Index: cfe/trunk/include/clang/Driver/ToolChain.h
===
--- cfe/trunk/include/clang/Driver/ToolChain.h
+++ cfe/trunk/include/clang/Driver/ToolChain.h
@@ -78,6 +78,10 @@
   bool IsRegistered)
   : TargetPrefix(Target), ModeSuffix(Suffix), DriverMode(Mode),
 TargetIsValid(IsRegistered) {}
+
+  bool isEmpty() const {
+return TargetPrefix.empty() && ModeSuffix.empty() && DriverMode == nullptr;
+  }
 };
 
 /// ToolChain - Access to tools for a single platform.
Index: cfe/trunk/test/Driver/config-file3.c
===
--- cfe/trunk/test/Driver/config-file3.c
+++ cfe/trunk/test/Driver/config-file3.c
@@ -27,6 +27,14 @@
 // FULL-NAME: -Wundefined-func-template
 // FULL-NAME-NOT: -Werror
 //
+//--- Invocation qqq-clang-g++ tries to find config file qqq-clang-g++.cfg even without -no-canonical-prefixes.
+// (As the clang executable and symlink are in different directories, this
+// requires specifying the path via --config-*-dir= though.)
+//
+// RUN: %T/testdmode/qqq-clang-g++ --config-system-dir= --config-user-dir=%T/testdmode -c %s -### 2>&1 | FileCheck %s -check-prefix SYMLINK
+//
+// SYMLINK: Configuration file: {{.*}}/testdmode/qqq-clang-g++.cfg
+//
 //--- File specified by --config overrides config inferred from clang executable.
 //
 // RUN: %T/testdmode/qqq-clang-g++ --config-system-dir=%S/Inputs/config --config-user-dir= --config i386-qqq -c -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-EXPLICIT
Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -129,7 +129,8 @@
 
 void Driver::ParseDriverMode(StringRef ProgramName,
  ArrayRef Args) {
-  ClangNameParts = ToolChain::getTargetAndModeFromProgramName(ProgramName);
+  if (ClangNameParts.isEmpty())
+ClangNameParts = ToolChain::getTargetAndModeFromProgramName(ProgramName);
   setDriverModeFromOption(ClangNameParts.DriverMode);
 
   for (const char *ArgPtr : Args) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mai

r330873 - [Driver] Reland "Android triples are not aliases for other triples."

2018-04-25 Thread Dan Albert via cfe-commits
Author: danalbert
Date: Wed Apr 25 14:26:06 2018
New Revision: 330873

URL: http://llvm.org/viewvc/llvm-project?rev=330873&view=rev
Log:
[Driver] Reland "Android triples are not aliases for other triples."

Fixed directory separators in tests to be compatible with both
Windows and !Windows.

This reverts commit aa423850afa4c16a53c4c492fe254dcad3d5a53e.

Modified:
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/test/Driver/android-ndk-standalone.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=330873&r1=330872&r2=330873&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Wed Apr 25 14:26:06 2018
@@ -1816,22 +1816,20 @@ void Generic_GCC::GCCInstallationDetecto
   // lifetime or initialization issues.
   static const char *const AArch64LibDirs[] = {"/lib64", "/lib"};
   static const char *const AArch64Triples[] = {
-  "aarch64-none-linux-gnu", "aarch64-linux-gnu", "aarch64-linux-android",
-  "aarch64-redhat-linux", "aarch64-suse-linux"};
+  "aarch64-none-linux-gnu", "aarch64-linux-gnu", "aarch64-redhat-linux",
+  "aarch64-suse-linux"};
   static const char *const AArch64beLibDirs[] = {"/lib"};
   static const char *const AArch64beTriples[] = {"aarch64_be-none-linux-gnu",
  "aarch64_be-linux-gnu"};
 
   static const char *const ARMLibDirs[] = {"/lib"};
-  static const char *const ARMTriples[] = {"arm-linux-gnueabi",
-   "arm-linux-androideabi"};
+  static const char *const ARMTriples[] = {"arm-linux-gnueabi"};
   static const char *const ARMHFTriples[] = {"arm-linux-gnueabihf",
  "armv7hl-redhat-linux-gnueabi",
  "armv6hl-suse-linux-gnueabi",
  "armv7hl-suse-linux-gnueabi"};
   static const char *const ARMebLibDirs[] = {"/lib"};
-  static const char *const ARMebTriples[] = {"armeb-linux-gnueabi",
- "armeb-linux-androideabi"};
+  static const char *const ARMebTriples[] = {"armeb-linux-gnueabi"};
   static const char *const ARMebHFTriples[] = {
   "armeb-linux-gnueabihf", "armebv7hl-redhat-linux-gnueabi"};
 
@@ -1841,16 +1839,14 @@ void Generic_GCC::GCCInstallationDetecto
   "x86_64-pc-linux-gnu","x86_64-redhat-linux6E",
   "x86_64-redhat-linux","x86_64-suse-linux",
   "x86_64-manbo-linux-gnu", "x86_64-linux-gnu",
-  "x86_64-slackware-linux", "x86_64-linux-android",
-  "x86_64-unknown-linux"};
+  "x86_64-slackware-linux", "x86_64-unknown-linux"};
   static const char *const X32LibDirs[] = {"/libx32"};
   static const char *const X86LibDirs[] = {"/lib32", "/lib"};
   static const char *const X86Triples[] = {
   "i686-linux-gnu",   "i686-pc-linux-gnu", "i486-linux-gnu",
   "i386-linux-gnu",   "i386-redhat-linux6E",   "i686-redhat-linux",
   "i586-redhat-linux","i386-redhat-linux", "i586-suse-linux",
-  "i486-slackware-linux", "i686-montavista-linux", "i686-linux-android",
-  "i586-linux-gnu"};
+  "i486-slackware-linux", "i686-montavista-linux", "i586-linux-gnu"};
 
   static const char *const MIPSLibDirs[] = {"/lib"};
   static const char *const MIPSTriples[] = {"mips-linux-gnu", "mips-mti-linux",
@@ -1869,13 +1865,6 @@ void Generic_GCC::GCCInstallationDetecto
   "mips64el-linux-gnu", "mips-mti-linux-gnu", "mips-img-linux-gnu",
   "mips64el-linux-gnuabi64"};
 
-  static const char *const MIPSELAndroidLibDirs[] = {"/lib", "/libr2",
- "/libr6"};
-  static const char *const MIPSELAndroidTriples[] = {"mipsel-linux-android"};
-  static const char *const MIPS64ELAndroidLibDirs[] = {"/lib64", "/lib",
-   "/libr2", "/libr6"};
-  static const char *const MIPS64ELAndroidTriples[] = {
-  "mips64el-linux-android"};
 
   static const char *const PPCLibDirs[] = {"/lib32", "/lib"};
   static const char *const PPCTriples[] = {
@@ -1952,6 +1941,66 @@ void Generic_GCC::GCCInstallationDetecto
 return;
   }
 
+  // Android targets should not use GNU/Linux tools or libraries.
+  if (TargetTriple.isAndroid()) {
+static const char *const AArch64AndroidTriples[] = {
+"aarch64-linux-android"};
+static const char *const ARMAndroidTriples[] = {"arm-linux-androideabi"};
+static const char *const MIPSELAndroidTriples[] = {"mipsel-linux-android"};
+static const char *const MIPS64ELAndroidTriples[] = {
+"mips64el-linux-android"};
+static const char *const X86AndroidTriples[] = {"i686-linux-android"};
+static const char *const X86_64AndroidTriples[] = {"x86_64-linux-android"};
+
+switch (TargetTrip

[PATCH] D45985: [test] Add a testcase for MinGW sysroot detections from SVN r330244. NFC.

2018-04-25 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330872: [test] Add a testcase for MinGW sysroot detections 
from SVN r330244. NFC. (authored by mstorsjo, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D45985?vs=143633&id=144008#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45985

Files:
  cfe/trunk/test/Driver/mingw-sysroot.cpp


Index: cfe/trunk/test/Driver/mingw-sysroot.cpp
===
--- cfe/trunk/test/Driver/mingw-sysroot.cpp
+++ cfe/trunk/test/Driver/mingw-sysroot.cpp
@@ -0,0 +1,42 @@
+// REQUIRES: shell
+// UNSUPPORTED: system-windows
+
+// RUN: mkdir -p %T/testroot-gcc/bin
+// RUN: [ ! -s %T/testroot-gcc/bin/x86_64-w64-mingw32-gcc ] || rm 
%T/testroot-gcc/bin/x86_64-w64-mingw32-gcc
+// RUN: [ ! -s %T/testroot-gcc/bin/x86_64-w64-mingw32-clang ] || rm 
%T/testroot-gcc/bin/x86_64-w64-mingw32-clang
+// RUN: [ ! -s %T/testroot-gcc/x86_64-w64-mingw32 ] || rm 
%T/testroot-gcc/x86_64-w64-mingw32
+// RUN: [ ! -s %T/testroot-gcc/lib ] || rm %T/testroot-gcc/lib
+// RUN: ln -s %clang %T/testroot-gcc/bin/x86_64-w64-mingw32-gcc
+// RUN: ln -s %clang %T/testroot-gcc/bin/x86_64-w64-mingw32-clang
+// RUN: ln -s %S/Inputs/mingw_ubuntu_posix_tree/usr/x86_64-w64-mingw32 
%T/testroot-gcc/x86_64-w64-mingw32
+// RUN: ln -s %S/Inputs/mingw_ubuntu_posix_tree/usr/lib %T/testroot-gcc/lib
+
+// RUN: mkdir -p %T/testroot-clang/bin
+// RUN: [ ! -s %T/testroot-clang/bin/x86_64-w64-mingw32-clang ] || rm 
%T/testroot-clang/bin/x86_64-w64-mingw32-clang
+// RUN: [ ! -s %T/testroot-clang/x86_64-w64-mingw32 ] || rm 
%T/testroot-clang/x86_64-w64-mingw32
+// RUN: ln -s %clang %T/testroot-clang/bin/x86_64-w64-mingw32-clang
+// RUN: ln -s %S/Inputs/mingw_ubuntu_posix_tree/usr/x86_64-w64-mingw32 
%T/testroot-clang/x86_64-w64-mingw32
+
+
+// If we find a gcc in the path with the right triplet prefix, pick that as
+// sysroot:
+
+// RUN: env "PATH=%T/testroot-gcc/bin:%PATH%" %clang -target 
x86_64-w64-mingw32 -rtlib=platform -stdlib=libstdc++ -c -### %s 2>&1 | 
FileCheck -check-prefix=CHECK_TESTROOT_GCC %s
+// CHECK_TESTROOT_GCC: 
"{{.*}}/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.3-posix{{/|}}include{{/|}}c++"
+// CHECK_TESTROOT_GCC: 
"{{.*}}/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.3-posix{{/|}}include{{/|}}c++{{/|}}x86_64-w64-mingw32"
+// CHECK_TESTROOT_GCC: 
"{{.*}}/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.3-posix{{/|}}include{{/|}}c++{{/|}}backward"
+// CHECK_TESTROOT_GCC: 
"{{.*}}/testroot-gcc{{/|}}x86_64-w64-mingw32{{/|}}include"
+
+
+// If there's a matching sysroot next to the clang binary itself, prefer that
+// over a gcc in the path:
+
+// RUN: env "PATH=%T/testroot-gcc/bin:%PATH%" 
%T/testroot-clang/bin/x86_64-w64-mingw32-clang -target x86_64-w64-mingw32 
-rtlib=compiler-rt -stdlib=libstdc++ -c -### %s 2>&1 | FileCheck 
-check-prefix=CHECK_TESTROOT_CLANG %s
+// CHECK_TESTROOT_CLANG: 
"{{.*}}/testroot-clang{{/|}}x86_64-w64-mingw32{{/|}}include"
+
+
+// If we pick a root based on a sysroot next to the clang binary, which also
+// happens to be in the same directory as gcc, make sure we still can pick up
+// the libgcc directory:
+
+// RUN: env "PATH=%T/testroot-gcc/bin:%PATH%" 
%T/testroot-gcc/bin/x86_64-w64-mingw32-clang -target x86_64-w64-mingw32 
-rtlib=platform -stdlib=libstdc++ -c -### %s 2>&1 | FileCheck 
-check-prefix=CHECK_TESTROOT_GCC %s


Index: cfe/trunk/test/Driver/mingw-sysroot.cpp
===
--- cfe/trunk/test/Driver/mingw-sysroot.cpp
+++ cfe/trunk/test/Driver/mingw-sysroot.cpp
@@ -0,0 +1,42 @@
+// REQUIRES: shell
+// UNSUPPORTED: system-windows
+
+// RUN: mkdir -p %T/testroot-gcc/bin
+// RUN: [ ! -s %T/testroot-gcc/bin/x86_64-w64-mingw32-gcc ] || rm %T/testroot-gcc/bin/x86_64-w64-mingw32-gcc
+// RUN: [ ! -s %T/testroot-gcc/bin/x86_64-w64-mingw32-clang ] || rm %T/testroot-gcc/bin/x86_64-w64-mingw32-clang
+// RUN: [ ! -s %T/testroot-gcc/x86_64-w64-mingw32 ] || rm %T/testroot-gcc/x86_64-w64-mingw32
+// RUN: [ ! -s %T/testroot-gcc/lib ] || rm %T/testroot-gcc/lib
+// RUN: ln -s %clang %T/testroot-gcc/bin/x86_64-w64-mingw32-gcc
+// RUN: ln -s %clang %T/testroot-gcc/bin/x86_64-w64-mingw32-clang
+// RUN: ln -s %S/Inputs/mingw_ubuntu_posix_tree/usr/x86_64-w64-mingw32 %T/testroot-gcc/x86_64-w64-mingw32
+// RUN: ln -s %S/Inputs/mingw_ubuntu_posix_tree/usr/lib %T/testroot-gcc/lib
+
+// RUN: mkdir -p %T/testroot-clang/bin
+// RUN: [ ! -s %T/testroot-clang/bin/x86_64-w64-mingw32-clang ] || rm %T/testroot-clang/bin/x86_64-w64-mingw32-clang
+// RUN: [ ! -s %T/testroot-clang/x86_64-w64-mingw32 ] || rm %T/testroot-clang/x86_64-w64-mingw32
+// RUN: ln -s %clang %T/testroot-clang/bin/x86_64-w64-mingw32-clang
+// RUN: ln -s %S/Inputs/mingw_ubuntu_posix_tree/

r330872 - [test] Add a testcase for MinGW sysroot detections from SVN r330244. NFC.

2018-04-25 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Wed Apr 25 14:24:04 2018
New Revision: 330872

URL: http://llvm.org/viewvc/llvm-project?rev=330872&view=rev
Log:
[test] Add a testcase for MinGW sysroot detections from SVN r330244. NFC.

Differential Revision: https://reviews.llvm.org/D45985

Added:
cfe/trunk/test/Driver/mingw-sysroot.cpp

Added: cfe/trunk/test/Driver/mingw-sysroot.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mingw-sysroot.cpp?rev=330872&view=auto
==
--- cfe/trunk/test/Driver/mingw-sysroot.cpp (added)
+++ cfe/trunk/test/Driver/mingw-sysroot.cpp Wed Apr 25 14:24:04 2018
@@ -0,0 +1,42 @@
+// REQUIRES: shell
+// UNSUPPORTED: system-windows
+
+// RUN: mkdir -p %T/testroot-gcc/bin
+// RUN: [ ! -s %T/testroot-gcc/bin/x86_64-w64-mingw32-gcc ] || rm 
%T/testroot-gcc/bin/x86_64-w64-mingw32-gcc
+// RUN: [ ! -s %T/testroot-gcc/bin/x86_64-w64-mingw32-clang ] || rm 
%T/testroot-gcc/bin/x86_64-w64-mingw32-clang
+// RUN: [ ! -s %T/testroot-gcc/x86_64-w64-mingw32 ] || rm 
%T/testroot-gcc/x86_64-w64-mingw32
+// RUN: [ ! -s %T/testroot-gcc/lib ] || rm %T/testroot-gcc/lib
+// RUN: ln -s %clang %T/testroot-gcc/bin/x86_64-w64-mingw32-gcc
+// RUN: ln -s %clang %T/testroot-gcc/bin/x86_64-w64-mingw32-clang
+// RUN: ln -s %S/Inputs/mingw_ubuntu_posix_tree/usr/x86_64-w64-mingw32 
%T/testroot-gcc/x86_64-w64-mingw32
+// RUN: ln -s %S/Inputs/mingw_ubuntu_posix_tree/usr/lib %T/testroot-gcc/lib
+
+// RUN: mkdir -p %T/testroot-clang/bin
+// RUN: [ ! -s %T/testroot-clang/bin/x86_64-w64-mingw32-clang ] || rm 
%T/testroot-clang/bin/x86_64-w64-mingw32-clang
+// RUN: [ ! -s %T/testroot-clang/x86_64-w64-mingw32 ] || rm 
%T/testroot-clang/x86_64-w64-mingw32
+// RUN: ln -s %clang %T/testroot-clang/bin/x86_64-w64-mingw32-clang
+// RUN: ln -s %S/Inputs/mingw_ubuntu_posix_tree/usr/x86_64-w64-mingw32 
%T/testroot-clang/x86_64-w64-mingw32
+
+
+// If we find a gcc in the path with the right triplet prefix, pick that as
+// sysroot:
+
+// RUN: env "PATH=%T/testroot-gcc/bin:%PATH%" %clang -target 
x86_64-w64-mingw32 -rtlib=platform -stdlib=libstdc++ -c -### %s 2>&1 | 
FileCheck -check-prefix=CHECK_TESTROOT_GCC %s
+// CHECK_TESTROOT_GCC: 
"{{.*}}/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.3-posix{{/|}}include{{/|}}c++"
+// CHECK_TESTROOT_GCC: 
"{{.*}}/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.3-posix{{/|}}include{{/|}}c++{{/|}}x86_64-w64-mingw32"
+// CHECK_TESTROOT_GCC: 
"{{.*}}/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.3-posix{{/|}}include{{/|}}c++{{/|}}backward"
+// CHECK_TESTROOT_GCC: 
"{{.*}}/testroot-gcc{{/|}}x86_64-w64-mingw32{{/|}}include"
+
+
+// If there's a matching sysroot next to the clang binary itself, prefer that
+// over a gcc in the path:
+
+// RUN: env "PATH=%T/testroot-gcc/bin:%PATH%" 
%T/testroot-clang/bin/x86_64-w64-mingw32-clang -target x86_64-w64-mingw32 
-rtlib=compiler-rt -stdlib=libstdc++ -c -### %s 2>&1 | FileCheck 
-check-prefix=CHECK_TESTROOT_CLANG %s
+// CHECK_TESTROOT_CLANG: 
"{{.*}}/testroot-clang{{/|}}x86_64-w64-mingw32{{/|}}include"
+
+
+// If we pick a root based on a sysroot next to the clang binary, which also
+// happens to be in the same directory as gcc, make sure we still can pick up
+// the libgcc directory:
+
+// RUN: env "PATH=%T/testroot-gcc/bin:%PATH%" 
%T/testroot-gcc/bin/x86_64-w64-mingw32-clang -target x86_64-w64-mingw32 
-rtlib=platform -stdlib=libstdc++ -c -### %s 2>&1 | FileCheck 
-check-prefix=CHECK_TESTROOT_GCC %s


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r330871 - [Driver] Fix implicit config files from prefixed symlinks

2018-04-25 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Wed Apr 25 14:23:59 2018
New Revision: 330871

URL: http://llvm.org/viewvc/llvm-project?rev=330871&view=rev
Log:
[Driver] Fix implicit config files from prefixed symlinks

If -no-canonical-prefixes isn't used, the clang executable name used
is the one of the actual executable, not the name of the symlink that
the user invoked.

In these cases, the target prefix was overridden based on the clang
executable name. (On the other hand the implicit -target option
that such a symlink adds, is added as an actual command line parameter
in tools/driver/driver.cop, before resolving the symlink and finding
the actual clang executable.

Use the original ClangNameParts (set from argv[0] in
tools/driver/driver.cpp) if it seems to be initialized propery.

All existing tests of this feature used -no-canonical-prefixes
(possibly because it also makes the driver look in the directory
of the symlink instead of the directory of the executable); add
another one that uses --config-user-dir= to specify the directory
instead. (For actual users of such symlinks, outisde of the test
suite, the directory is probably the same for both.)

This makes this feature work more like what the documentation
describes.

Differential Revision: https://reviews.llvm.org/D45964

Modified:
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/test/Driver/config-file3.c

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=330871&r1=330870&r2=330871&view=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Wed Apr 25 14:23:59 2018
@@ -78,6 +78,10 @@ struct ParsedClangName {
   bool IsRegistered)
   : TargetPrefix(Target), ModeSuffix(Suffix), DriverMode(Mode),
 TargetIsValid(IsRegistered) {}
+
+  bool isEmpty() const {
+return TargetPrefix.empty() && ModeSuffix.empty() && DriverMode == nullptr;
+  }
 };
 
 /// ToolChain - Access to tools for a single platform.

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=330871&r1=330870&r2=330871&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Wed Apr 25 14:23:59 2018
@@ -129,7 +129,8 @@ Driver::Driver(StringRef ClangExecutable
 
 void Driver::ParseDriverMode(StringRef ProgramName,
  ArrayRef Args) {
-  ClangNameParts = ToolChain::getTargetAndModeFromProgramName(ProgramName);
+  if (ClangNameParts.isEmpty())
+ClangNameParts = ToolChain::getTargetAndModeFromProgramName(ProgramName);
   setDriverModeFromOption(ClangNameParts.DriverMode);
 
   for (const char *ArgPtr : Args) {

Modified: cfe/trunk/test/Driver/config-file3.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/config-file3.c?rev=330871&r1=330870&r2=330871&view=diff
==
--- cfe/trunk/test/Driver/config-file3.c (original)
+++ cfe/trunk/test/Driver/config-file3.c Wed Apr 25 14:23:59 2018
@@ -27,6 +27,14 @@
 // FULL-NAME: -Wundefined-func-template
 // FULL-NAME-NOT: -Werror
 //
+//--- Invocation qqq-clang-g++ tries to find config file qqq-clang-g++.cfg 
even without -no-canonical-prefixes.
+// (As the clang executable and symlink are in different directories, this
+// requires specifying the path via --config-*-dir= though.)
+//
+// RUN: %T/testdmode/qqq-clang-g++ --config-system-dir= 
--config-user-dir=%T/testdmode -c %s -### 2>&1 | FileCheck %s -check-prefix 
SYMLINK
+//
+// SYMLINK: Configuration file: {{.*}}/testdmode/qqq-clang-g++.cfg
+//
 //--- File specified by --config overrides config inferred from clang 
executable.
 //
 // RUN: %T/testdmode/qqq-clang-g++ --config-system-dir=%S/Inputs/config 
--config-user-dir= --config i386-qqq -c -no-canonical-prefixes %s -### 2>&1 | 
FileCheck %s -check-prefix CHECK-EXPLICIT


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46066: [analyzer] Add checker for underflowing unsigned integers

2018-04-25 Thread Paul Fultz II via Phabricator via cfe-commits
pfultz2 abandoned this revision.
pfultz2 added a comment.

So I submitted my change to the ConversionChecker, instead.


Repository:
  rC Clang

https://reviews.llvm.org/D46066



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46081: [analyzer] Expand conversion check to check more expressions for overflow and underflow

2018-04-25 Thread Paul Fultz II via Phabricator via cfe-commits
pfultz2 created this revision.
pfultz2 added reviewers: NoQ, xazax.hun, dkrupp, whisperity.
pfultz2 added a project: clang.
Herald added subscribers: cfe-commits, a.sidorin, rnkovacs, szepet.
Herald added a reviewer: george.karpenkov.

This expands checking for more expressions. This will check underflow and loss 
of precision when using call expressions like:

  void foo(unsigned);
  int i = -1;
  foo(i);

This also includes other expressions as well, so it can catch negative indices 
to `std::vector` since it uses unsigned integers for `[]` and `.at()` function.


Repository:
  rC Clang

https://reviews.llvm.org/D46081

Files:
  lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
  test/Analysis/conversion.c


Index: test/Analysis/conversion.c
===
--- test/Analysis/conversion.c
+++ test/Analysis/conversion.c
@@ -102,6 +102,23 @@
 S = U / S; // expected-warning {{Loss of sign}}
 }
 
+void f(unsigned x) {}
+void g(unsigned x) {}
+
+void functioncall1() {
+  long x = -1;
+  int y = 0;
+  f(x); // expected-warning {{Loss of sign in implicit conversion}}
+  f(y);
+}
+
+void functioncall2(int x, int y) {
+  if (x < 0)
+f(x); // expected-warning {{Loss of sign in implicit conversion}}
+  f(y);
+  f(x); // expected-warning {{Loss of sign in implicit conversion}}
+}
+
 void dontwarn1(unsigned U, signed S) {
   U8 = S; // It might be known that S is always 0x00-0xff.
   S8 = U; // It might be known that U is always 0x00-0xff.
@@ -129,12 +146,17 @@
   DOSTUFF;
 }
 
-// don't warn for calculations
-// seen some fp. For instance:  c2 = (c2 >= 'A' && c2 <= 'Z') ? c2 - 'A' + 'a' 
: c2;
-// there is a todo in the checker to handle calculations
 void dontwarn5() {
-  signed S = -32;
-  U8 = S + 10;
+  unsigned char c1 = 'A';
+  c1 = (c1 >= 'A' && c1 <= 'Z') ? c1 - 'A' + 'a' : c1;
+  unsigned char c2 = 0;
+  c2 = (c2 >= 'A' && c2 <= 'Z') ? c2 - 'A' + 'a' : c2;
+  unsigned char c3 = 'Z';
+  c3 = (c3 >= 'A' && c3 <= 'Z') ? c3 - 'A' + 'a' : c3;
+  unsigned char c4 = 'a';
+  c4 = (c4 >= 'A' && c4 <= 'Z') ? c4 - 'A' + 'a' : c4;
+  unsigned char c5 = '@';
+  c5 = (c5 >= 'A' && c5 <= 'Z') ? c5 - 'A' + 'a' : c5;
 }
 
 
Index: lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
+++ lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
@@ -53,9 +53,8 @@
 
 void ConversionChecker::checkPreStmt(const ImplicitCastExpr *Cast,
  CheckerContext &C) const {
-  // TODO: For now we only warn about DeclRefExpr, to avoid noise. Warn for
-  // calculations also.
-  if (!isa(Cast->IgnoreParenImpCasts()))
+  // Don't warn for implicit conversions to bool
+  if (Cast->getType()->isBooleanType())
 return;
 
   // Don't warn for loss of sign/precision in macros.
@@ -75,8 +74,10 @@
   if (const auto *B = dyn_cast(Parent)) {
 BinaryOperator::Opcode Opc = B->getOpcode();
 if (Opc == BO_Assign) {
-  LossOfSign = isLossOfSign(Cast, C);
-  LossOfPrecision = isLossOfPrecision(Cast, Cast->getType(), C);
+  if (!B->getRHS()->isIntegerConstantExpr(C.getASTContext())) {
+LossOfSign = isLossOfSign(Cast, C);
+LossOfPrecision = isLossOfPrecision(Cast, Cast->getType(), C);
+  }
 } else if (Opc == BO_AddAssign || Opc == BO_SubAssign) {
   // No loss of sign.
   LossOfPrecision = isLossOfPrecision(Cast, B->getLHS()->getType(), C);
@@ -95,7 +96,7 @@
 } else if (B->isRelationalOp() || B->isMultiplicativeOp()) {
   LossOfSign = isLossOfSign(Cast, C);
 }
-  } else if (isa(Parent)) {
+  } else {
 LossOfSign = isLossOfSign(Cast, C);
 LossOfPrecision = isLossOfPrecision(Cast, Cast->getType(), C);
   }


Index: test/Analysis/conversion.c
===
--- test/Analysis/conversion.c
+++ test/Analysis/conversion.c
@@ -102,6 +102,23 @@
 S = U / S; // expected-warning {{Loss of sign}}
 }
 
+void f(unsigned x) {}
+void g(unsigned x) {}
+
+void functioncall1() {
+  long x = -1;
+  int y = 0;
+  f(x); // expected-warning {{Loss of sign in implicit conversion}}
+  f(y);
+}
+
+void functioncall2(int x, int y) {
+  if (x < 0)
+f(x); // expected-warning {{Loss of sign in implicit conversion}}
+  f(y);
+  f(x); // expected-warning {{Loss of sign in implicit conversion}}
+}
+
 void dontwarn1(unsigned U, signed S) {
   U8 = S; // It might be known that S is always 0x00-0xff.
   S8 = U; // It might be known that U is always 0x00-0xff.
@@ -129,12 +146,17 @@
   DOSTUFF;
 }
 
-// don't warn for calculations
-// seen some fp. For instance:  c2 = (c2 >= 'A' && c2 <= 'Z') ? c2 - 'A' + 'a' : c2;
-// there is a todo in the checker to handle calculations
 void dontwarn5() {
-  signed S = -32;
-  U8 = S + 10;
+  unsigned char c1 = 'A';
+  c1 = (c1 >= 'A' && c1 <= 'Z') ? c1 - 'A' + 'a' : c1;
+  unsigned char c2 = 0;
+  c2 = (c2 >= 'A' && c2 <= '

Re: r330794 - [c++2a] [concepts] Add rudimentary parsing support for template concept declarations

2018-04-25 Thread Faisal Vali via cfe-commits
On Wed, Apr 25, 2018 at 3:37 PM, Richard Smith  wrote:
> On 24 April 2018 at 19:42, Faisal Vali via cfe-commits
>  wrote:
>>
>> Author: faisalv
>> Date: Tue Apr 24 19:42:26 2018
>> New Revision: 330794
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=330794&view=rev
>> Log:
>> [c++2a] [concepts] Add rudimentary parsing support for template concept
>> declarations
>>
>>
>> This patch is a tweak of changyu's patch: https://reviews.llvm.org/D40381.
>> It differs in that the recognition of the 'concept' token is moved into the
>> machinery that recognizes declaration-specifiers - this allows us to
>> leverage the attribute handling machinery more seamlessly.
>
>
> Is that really worth it? This seems to add complexity to decl-specifier-seq
> / declarator parsing for a construct that has nothing to do with those
> things. I prefer the simpler approach in changyu's patch. I don't think the
> diagnostics you're producing are worthwhile -- the problem is not that
> "concept" can't be combined with other specifiers, it's that it's a
> fundamentally different kind of construct (just like "using X = ...", which
> it's much more like than it is like a declarator declaration).
>

I wouldn't say that I'm certain it's worth it - but then it also
didn't seem to me that the complexity tax being paid was that high
(but probably because my bias leans towards overly-diagnosticating for
users who are still learning the syntax of the language - and i can
imagine folks trying to add types to concept declarations or
attributes - which we may choose to allow in the future..)

Eitherway - I really don't feel strongly about this - just felt it
might be a better service to provide our users - but I do see your
point and the coherence concerns regarding our structure and since you
do feel strongly about it, i'll replace it with changyu's approach.

Sorry about that and thanks for the feedback!


>> See the test file to get a sense of the basic parsing that this patch
>> supports.
>>
>> There is much more work to be done before concepts are usable...
>>
>> Thanks Changyu!
>>
>> Added:
>> cfe/trunk/test/Parser/cxx2a-concept-declaration.cpp
>> Removed:
>> cfe/trunk/test/Parser/cxx-concept-declaration.cpp
>> Modified:
>> cfe/trunk/include/clang/AST/DeclTemplate.h
>> cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
>> cfe/trunk/include/clang/Basic/DeclNodes.td
>> cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/include/clang/Basic/TemplateKinds.h
>> cfe/trunk/include/clang/Parse/Parser.h
>> cfe/trunk/include/clang/Sema/DeclSpec.h
>> cfe/trunk/include/clang/Sema/Sema.h
>> cfe/trunk/include/clang/Serialization/ASTBitCodes.h
>> cfe/trunk/lib/AST/ASTDumper.cpp
>> cfe/trunk/lib/AST/DeclBase.cpp
>> cfe/trunk/lib/AST/DeclTemplate.cpp
>> cfe/trunk/lib/CodeGen/CGDecl.cpp
>> cfe/trunk/lib/CodeGen/CodeGenModule.cpp
>> cfe/trunk/lib/Parse/ParseDecl.cpp
>> cfe/trunk/lib/Parse/ParseDeclCXX.cpp
>> cfe/trunk/lib/Parse/ParseObjc.cpp
>> cfe/trunk/lib/Parse/ParseTemplate.cpp
>> cfe/trunk/lib/Parse/ParseTentative.cpp
>> cfe/trunk/lib/Parse/Parser.cpp
>> cfe/trunk/lib/Sema/DeclSpec.cpp
>> cfe/trunk/lib/Sema/SemaDecl.cpp
>> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>> cfe/trunk/lib/Sema/SemaTemplate.cpp
>> cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
>> cfe/trunk/lib/Serialization/ASTCommon.cpp
>> cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>> cfe/trunk/lib/Serialization/ASTWriter.cpp
>> cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
>> cfe/trunk/tools/libclang/CIndex.cpp
>>
>> Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=330794&r1=330793&r2=330794&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
>> +++ cfe/trunk/include/clang/AST/DeclTemplate.h Tue Apr 24 19:42:26 2018
>> @@ -3015,6 +3015,46 @@ public:
>>static bool classofKind(Kind K) { return K == VarTemplate; }
>>  };
>>
>> +/// \brief Represents a C++2a ([temp] p1) concept-definition.
>> +class ConceptDecl : public TemplateDecl {
>> +protected:
>> +  Expr *ConstraintExpr;
>> +
>> +  ConceptDecl(DeclContext *DC,
>> +  SourceLocation NameLoc, DeclarationName Name,
>> +  TemplateParameterList *Params,
>> +  Expr *ConstraintExpr)
>> +  : TemplateDecl(nullptr, Concept, DC, NameLoc, Name, Params),
>> +ConstraintExpr(ConstraintExpr) {};
>> +public:
>> +  static ConceptDecl *Create(ASTContext &C, DeclContext *DC,
>> + SourceLocation NameLoc, DeclarationName
>> Name,
>> + TemplateParameterList *Params,
>> + Expr *ConstraintExpr);
>> +  static ConceptDecl *CreateDeserialize

[PATCH] D46052: GNUstep Objective-C ABI version 2

2018-04-25 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Are you asking for a code review or a design review of the ABI?  The second 
would be much easier to do from a design document.




Comment at: lib/CodeGen/CGObjCGNU.cpp:502
+for (const auto *I : Methods)
+  if (I->getImplementationControl() == ObjCMethodDecl::Optional)
+OptionalMethods.push_back(I);

There's an `isOptional()` method now.


Repository:
  rC Clang

https://reviews.llvm.org/D46052



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46071: Representing the target device information in the LLVM IR

2018-04-25 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I agree this needs an RFC; I don't understand how you plan to use this 
information.


Repository:
  rOMP OpenMP

https://reviews.llvm.org/D46071



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46015: [OpenCL] Add separate read_only and write_only pipe IR types

2018-04-25 Thread Alexey Sotkin via Phabricator via cfe-commits
AlexeySotkin added a comment.

In https://reviews.llvm.org/D46015#1078317, @stuart wrote:

> In https://reviews.llvm.org/D46015#1078260, @AlexeySotkin wrote:
>
> > In https://reviews.llvm.org/D46015#1078235, @stuart wrote:
> >
> > > In https://reviews.llvm.org/D46015#1078217, @AlexeySotkin wrote:
> > >
> > > > There should not be need for bitcast. Could give an example ? Thanks.
> > >
> > >
> > > If I have a `write_only` pipe as the argument to 
> > > `get_pipe_max_packets()`, and this uses a single 
> > > `__get_pipe_num_packets()` function taking a `read_only` pipe, we will 
> > > automatically get a bitcast:
> > >
> > >   %20 = call i32 bitcast (i32 (%opencl.pipe_ro_t*, i32, i32)* 
> > > @__get_pipe_max_packets to i32 (%opencl.pipe_wo_t*, i32, 
> > > i32)*)(%opencl.pipe_wo_t* %19, i32 4, i32 4)
> > >
> >
> >
> > Sorry, but I don't quite understand what does  `get_pipe_max_packets()`, 
> > **uses** `__get_pipe_num_packets()`  mean. Could you clarify? Possibly 
> > OpenCL C source example could help.
>
>
> I mean that without these two separate versions, the call to 
> `__get_pipe_num_packets()` that is emitted can include a bitcast.
>
> For example:
>
>   void foo(read_only pipe int r, write_only pipe int w) {
> get_pipe_num_packets(w);
> get_pipe_num_packets(r);
>   }
>
>
> `get_pipe_num_packets(w)` is seen first, causing `i32 
> @__get_pipe_num_packets(%opencl.pipe_wo_t*, i32, i32)` to be implicitly 
> declared.
>
> When the call to `__get_pipe_num_packets()` is emitted, this will be with an 
> autogenerated bitcast from the type of the implicit declaration, i.e. `i32 
> (%opencl.pipe_wo_t*, i32, i32)*` to the type in the emitted expression, i.e. 
> `i32 (%opencl.pipe_ro_t*, i32, i32)*`.
>
> Here is the relevant section of IR:
>
>   %0 = load %opencl.pipe_wo_t*, %opencl.pipe_wo_t** %w.addr, align 8
>   %1 = call i32 @__get_pipe_num_packets(%opencl.pipe_wo_t* %0, i32 4, i32 4)
>   %2 = load %opencl.pipe_ro_t*, %opencl.pipe_ro_t** %r.addr, align 8
>   %3 = call i32 bitcast (i32 (%opencl.pipe_wo_t*, i32, i32)* 
> @__get_pipe_num_packets to i32 (%opencl.pipe_ro_t*, i32, 
> i32)*)(%opencl.pipe_ro_t* %2, i32 4, i32 4)
>   
>
> If we swap the two uses of `get_pipe_num_packets()` in the example above, 
> then the type of the implicit declaration will be `i32 (%opencl.pipe_ro_t*, 
> i32, i32)*` and bitcasts will instead be automatically generated when using 
> `get_pipe_num_packets()` with a `write_only` pipe. It seems especially 
> unfortunate that the type of the implicit declaration varies depending on the 
> access qualifier of the first use.


Oh I see. LGTM then. Thanks.


https://reviews.llvm.org/D46015



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38845: [ASTImporter] Support importing UnresolvedMemberExpr, DependentNameType, DependentScopeDeclRefExpr

2018-04-25 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: unittests/AST/ASTImporterTest.cpp:1556
+  // Converting code texts into TUs
+  std::transform(Codes.begin(), Codes.end(), std::back_inserter(FromTUs),
+ [this](StringRef Code) {

Instead of having 4 `FromTUs`, perhaps a simpler alternative would be to have 
only one, which contains all the code snippets with `declToImport0` ... 
`declToImport3` (Or just skip declToImport since we no longer need that 
phabricated name, so we could just have a simple name like `X`) and importing 
them one by one later with `ASTImporterTestBase::Import`.
This would spare the need for the transform and the for cycle below.



Comment at: unittests/AST/ASTImporterTest.cpp:1569
+FirstDeclMatcher().match(*TB, Pattern);
+if (!FromDSDRE)
+  return;

I think, this `if` would be needed only if the test suite would be 
parameterized also with `ArgVector{"-fdelayed-template-parsing"}`, but that is 
not.



Comment at: unittests/AST/ASTImporterTest.cpp:1573
+auto To = cast(Import(FromDSDRE, Lang_CXX));
+EXPECT_TRUE(FirstDeclMatcher().match(To, Pattern));
+  }

It will be hard to notice based on the test output which DSDRE's import was 
unsuccessful. Therefore I'd unroll the for loop instead, also please see the 
above comment that it would be more practical to have one FromTU.


https://reviews.llvm.org/D38845



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45639: [Driver] Support default libc++ library location on Darwin

2018-04-25 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In https://reviews.llvm.org/D45639#1078494, @thakis wrote:

> > because the headers that are part of Clang toolchain are incompatible with 
> > the system library
>
> Do you have details on this? This isn't supposed to be the case as far as I 
> know. We link chrome/mac against system libc++ with the bundled headers, and 
> it at least seems to work fine (and, from what I understand, is supposed to 
> work as well).


We haven't ran into any incompatibility issue yet AFAIK. If backwards and 
forwards compatibility for libc++ headers is guaranteed, this shouldn't be an 
issue. The problem I'm dealing with is actually slightly different. We would 
like to start using C++17 and C++2a features already supported by libc++, but 
it's unclear which of them are already supported by libc++ shipped on macOS and 
we're in this case at the whim of Apple. The way we address this on Linux is by 
always statically linking libc++ that's shipped with Clang, but on Darwin 
that's currently not possible because of https://reviews.llvm.org/D44671 and 
this issue. Neither of those seems like a technical problem, with these two 
patches applied, I can statically link our copy of libc++ on Darwin and 
everything seems working fine.


Repository:
  rC Clang

https://reviews.llvm.org/D45639



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r330861 - [TargetInfo] Sort target features before passing them to the backend

2018-04-25 Thread Eli Friedman via cfe-commits
Author: efriedma
Date: Wed Apr 25 12:14:05 2018
New Revision: 330861

URL: http://llvm.org/viewvc/llvm-project?rev=330861&view=rev
Log:
[TargetInfo] Sort target features before passing them to the backend

Passing the features in random order will lead to unpredictable results
when some of the features are related (like the architecture-version
features on ARM).

It might be possible to fix this particular case in the ARM target code,
to avoid adding overlapping target features. But we should probably be
sorting in any case: the behavior shouldn't depend on StringMap's
hashing algorithm.

Differential Revision: https://reviews.llvm.org/D46030


Added:
cfe/trunk/test/CodeGen/arm-build-attributes.c
Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=330861&r1=330860&r2=330861&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Apr 25 12:14:05 2018
@@ -638,6 +638,9 @@ TargetInfo::CreateTargetInfo(Diagnostics
   Opts->Features.clear();
   for (const auto &F : Features)
 Opts->Features.push_back((F.getValue() ? "+" : "-") + F.getKey().str());
+  // Sort here, so we handle the features in a predictable order. (This matters
+  // when we're dealing with features that overlap.)
+  llvm::sort(Opts->Features.begin(), Opts->Features.end());
 
   if (!Target->handleTargetFeatures(Opts->Features, Diags))
 return nullptr;

Added: cfe/trunk/test/CodeGen/arm-build-attributes.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-build-attributes.c?rev=330861&view=auto
==
--- cfe/trunk/test/CodeGen/arm-build-attributes.c (added)
+++ cfe/trunk/test/CodeGen/arm-build-attributes.c Wed Apr 25 12:14:05 2018
@@ -0,0 +1,4 @@
+// RUN: %clang --target=arm-none-eabi -x c - -o - -S < %s -mcpu=cortex-a5 
-mfpu=vfpv4-d16 | FileCheck %s
+// REQUIRES: arm-registered-target
+// CHECK: .fpu vfpv4-d16
+void foo() {}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46030: [TargetInfo] Sort target features before passing them to the backend

2018-04-25 Thread Eli Friedman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330861: [TargetInfo] Sort target features before passing 
them to the backend (authored by efriedma, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46030?vs=143821&id=143984#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46030

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/CodeGen/arm-build-attributes.c


Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -638,6 +638,9 @@
   Opts->Features.clear();
   for (const auto &F : Features)
 Opts->Features.push_back((F.getValue() ? "+" : "-") + F.getKey().str());
+  // Sort here, so we handle the features in a predictable order. (This matters
+  // when we're dealing with features that overlap.)
+  llvm::sort(Opts->Features.begin(), Opts->Features.end());
 
   if (!Target->handleTargetFeatures(Opts->Features, Diags))
 return nullptr;
Index: cfe/trunk/test/CodeGen/arm-build-attributes.c
===
--- cfe/trunk/test/CodeGen/arm-build-attributes.c
+++ cfe/trunk/test/CodeGen/arm-build-attributes.c
@@ -0,0 +1,4 @@
+// RUN: %clang --target=arm-none-eabi -x c - -o - -S < %s -mcpu=cortex-a5 
-mfpu=vfpv4-d16 | FileCheck %s
+// REQUIRES: arm-registered-target
+// CHECK: .fpu vfpv4-d16
+void foo() {}


Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -638,6 +638,9 @@
   Opts->Features.clear();
   for (const auto &F : Features)
 Opts->Features.push_back((F.getValue() ? "+" : "-") + F.getKey().str());
+  // Sort here, so we handle the features in a predictable order. (This matters
+  // when we're dealing with features that overlap.)
+  llvm::sort(Opts->Features.begin(), Opts->Features.end());
 
   if (!Target->handleTargetFeatures(Opts->Features, Diags))
 return nullptr;
Index: cfe/trunk/test/CodeGen/arm-build-attributes.c
===
--- cfe/trunk/test/CodeGen/arm-build-attributes.c
+++ cfe/trunk/test/CodeGen/arm-build-attributes.c
@@ -0,0 +1,4 @@
+// RUN: %clang --target=arm-none-eabi -x c - -o - -S < %s -mcpu=cortex-a5 -mfpu=vfpv4-d16 | FileCheck %s
+// REQUIRES: arm-registered-target
+// CHECK: .fpu vfpv4-d16
+void foo() {}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45860: [Coroutines] Catch exceptions in await_resume

2018-04-25 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov added a comment.

Thank you for doing this. It looks very elegant, but, it is a little bit wrong. 
It creates two different initial_suspend objects.
Run this example:

https://wandbox.org/permlink/Q1Zd2NUlolmw9YmX

You will observe that in trunk we are getting the output:

  0x216808c: constructed(initial)
  0x216808c: await_ready
  0x216808c: await_suspend
  0x216808c: await_resume
  0x216808c: destroyed
  0x21680b8: constructed(final)
  0x21680b8: await_ready
  0x21680b8: await_suspend
  consumed 10 values with sum 45
  0x21680b8: destroyed
  promise destroyed

With this change, the output becomes:

  0x1965c4c: constructed(initial)
  0x1965c4c: await_ready
  0x1965c4c: await_suspend
  0x1965c4c: destroyed
  0x1965c60: constructed(initial)
  0x1965c60: await_resume
  0x1965c60: destroyed
  0x1965c80: constructed(final)
  0x1965c80: await_ready
  0x1965c80: await_suspend
  consumed 10 values with sum 45
  0x1965c80: destroyed
  0x1965c60: destroyed
  promise destroyed

I suggest, first modify the unit test to check that we do not create two 
initial_suspend objects. Then to fix it :-)




Comment at: lib/CodeGen/CGCoroutine.cpp:595
 
+auto InitSuspend = S.getInitSuspendStmt();
 CurCoro.Data->CurrentAwaitKind = AwaitKind::Init;

auto *InitialSuspend = ...

See: 
https://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable




Comment at: lib/CodeGen/CGCoroutine.cpp:605
   auto Loc = S.getLocStart();
+  auto AwaitExpr =
+  cast(cast(InitSuspend)->getSubExpr());

auto *AwaitExpr =



Comment at: lib/CodeGen/CGCoroutine.cpp:608
+
+  SmallVector Stmts;
+  Stmts.push_back(AwaitExpr->getResumeExpr());

Consider:
```
 std::array Stmts = {AwaitExpr->getResumeExpr(), S.getBody()};
```
instead


Repository:
  rC Clang

https://reviews.llvm.org/D45860



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46071: Representing the target device information in the LLVM IR

2018-04-25 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Hmm, I don't think this is correct. I think it is against the OpenMP standard.
According to OpenMP 4.5:
When an original variable is mapped to a device data environment and the 
associated 19 corresponding variable is not present in the device data 
environment, a new corresponding variable 20 (of the same type and size as the 
original variable) is created in the device data environment.

If you try to offload the code from x86_64 to i386 with long int type, for 
example, you won't be able to create the variable of the same size. I think, 
that this kind of offloading should be just not allowed.

Also, it means, that the code generated by the backend will be different rather 
than the code emitted by the frontend. You're going to break the ABI using some 
LLVM transformations.

That's very strange that you started with the patches. This is a very important 
thing that requires a discussion. I think you'd better start with the RFC. 
Currently, all this stuff looks like some kind of a hack.


Repository:
  rOMP OpenMP

https://reviews.llvm.org/D46071



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45639: [Driver] Support default libc++ library location on Darwin

2018-04-25 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

In https://reviews.llvm.org/D45639#1078494, @thakis wrote:

> > because the headers that are part of Clang toolchain are incompatible with 
> > the system library
>
> Do you have details on this? This isn't supposed to be the case as far as I 
> know. We link chrome/mac against system libc++ with the bundled headers, and 
> it at least seems to work fine (and, from what I understand, is supposed to 
> work as well).


Agreed; this sounds bad. libc++ goes to great pains to maintain both forward 
and backward compatibility in its headers; @dexonsmith should weigh in here.


Repository:
  rC Clang

https://reviews.llvm.org/D45639



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45639: [Driver] Support default libc++ library location on Darwin

2018-04-25 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

> because the headers that are part of Clang toolchain are incompatible with 
> the system library

Do you have details on this? This isn't supposed to be the case as far as I 
know. We link chrome/mac against system libc++ with the bundled headers, and it 
at least seems to work fine (and, from what I understand, is supposed to work 
as well).


Repository:
  rC Clang

https://reviews.llvm.org/D45639



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46000: [AST] Added a helper to extract a user-friendly text of a comment.

2018-04-25 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: include/clang/AST/RawCommentList.h:118
+  /// //   Parts of it  might be indented.
+  /// /* The comments styles might be mixed. */
+  ///  into

I'm trying to understand how these cases and RawComment work.

For this case, are the `// ... ` block and `/* ... */` merged in one 
`RawComment` by default?



Comment at: include/clang/AST/RawCommentList.h:126
+  ///  *   This is a second line. It is indented.
+  ///  * This is a third line. */
+  /// and

Are the `*`s in each lines automatically consumed by the lexer?



Comment at: lib/AST/CommentLexer.cpp:301
+
+bool Lexer::tryLexCommands(Token &T) {
   assert(CommentState == LCS_InsideBCPLComment ||

I think we could avoid the "somewhat non-trivial" control flow by merging 
command and command-less cases in one function:

Something like:
```
  const char *TokenPtr = ...;
  auto HandleNonCommandToken = ...;
  if (!ParseComand) {
 HandleNonCommandToken(...);
 return;
  }
  ... 
  switch (...) {
   // after all command cases 
  default:
 HandleNonCommandToken(...);
   }
```



Comment at: lib/AST/CommentLexer.cpp:331
   assert(TokenPtr < CommentEnd);
-  while (TokenPtr != CommentEnd) {
-switch(*TokenPtr) {
-  case '\\':
-  case '@': {
-// Commands that start with a backslash and commands that start with
-// 'at' have equivalent semantics.  But we keep information about the
-// exact syntax in AST for comments.
-tok::TokenKind CommandKind =
-(*TokenPtr == '@') ? tok::at_command : tok::backslash_command;
+  switch(*TokenPtr) {
+case '\\':

We should be extra careful about removing the loop... (It does seem to be 
redundant though)



Comment at: lib/AST/RawCommentList.cpp:380
+SourceMgr.getSpellingColumnNumber(Tok.getLocation(), &LocInvalid);
+if (LocInvalid)
+  TokColumn = 0;

ilya-biryukov wrote:
> ilya-biryukov wrote:
> > ioeric wrote:
> > > Explain when this would be invalid and why `TokColumn = 0` is used?
> > I don't know whether this can be even be invalid, but I'm not confident 
> > enough to add an assert there.
> > `TokColumn = 0` seems like a reasonable way to recover if we can't compute 
> > the column number, i.e. assume the line starts at the first column if 
> > SourceLocation of the line was invalid for any reason.
> > 
> > This whole column thing looks weird to me, maybe I should just remove it 
> > altogether and just remove the same amount of whitespace in all the lines. 
> > WDYT?
> On a second thought, now I remember why I added this in the first place.
> To support the following example we want to take column numbers into account:
> 
> ```
> class Foo {
> /* A block comment
>spanning multiple lines
>has too many spaces on the all lines except the first one.
> */
> int func();
> };
> ```
So I think you would want to force `MaxSkip` to 0 if token loc is invalid to 
make sure no comment is accidentally eaten?



Comment at: lib/AST/RawCommentList.cpp:383
+// Compute the length of whitespace we're allowed to skip.
+unsigned MaxSkip;
+if (IsFirstLine) {

ilya-biryukov wrote:
> ioeric wrote:
> > nit: `unsigned MaxSkip = IsFirstLine ? ... : ...;`
> That would force to get rid of the comments in the if branches, but they seem 
> to be useful.
> Am I missing an obvious style that would preserve the comments?
You could simply merge the comments, which doesn't seem to compromise 
readability.



Comment at: lib/AST/RawCommentList.cpp:343
+  if (CommentText.empty())
+return ""; // we couldn't retreive the comment.
+

nit: We don't really know if there was a failure or the comment is simply 
empty. So I'd probably leave out the comment here to avoid confusion.



Comment at: lib/AST/RawCommentList.cpp:349
+CommentText.begin(), CommentText.end(),
+/*ParseCommentText=*/false);
+

`s/ParseCommentText/ParseCommands/`?



Comment at: lib/AST/RawCommentList.cpp:352
+  std::string Result;
+  unsigned IndentColumn = 0;
+

This variable could use a comment.



Comment at: lib/AST/RawCommentList.cpp:393
+
+llvm::StringRef Trimmed = TokText.drop_front(std::min(MaxSkip, 
WhitespaceLen));
+Result += Trimmed;

I think `MaxSkip` could be removed with:

```
llvm::StringRef Trimmed = TokText.drop_front(IsFirstLine ? WhitespaceLen : 
 std::max((int)IndentColumn - 
(int)TokColumn, 0)));
```


Repository:
  rC Clang

https://reviews.llvm.org/D46000



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-

[PATCH] D45964: [Driver] Fix implicit config files from prefixed symlinks

2018-04-25 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

In https://reviews.llvm.org/D45964#1077217, @mstorsjo wrote:

> Added an isEmpty() method.


This variant is more readable.

> Btw, did you see https://bugs.llvm.org/show_bug.cgi?id=37196? That one feels 
> quite a bit more convolved so I don't really know (so far) how to approach 
> fixing that.

Indeed, that bug looked mysterious. The reason is that `InputArgList` assumes 
its field `ArgStrings` contains strings for each argument exactly in the same 
order, this condition was broken when arguments from config file and from 
invocation were merged. I will commit the patch soon.


https://reviews.llvm.org/D45964



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45639: [Driver] Support default libc++ library location on Darwin

2018-04-25 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In https://reviews.llvm.org/D45639#1068086, @compnerd wrote:

> I'm not sure I understand this.  The proper location for libc++ on the darwin 
> layout is in the SDK, not relative to the driver.  The default behaviour is 
> similar to cross-compiling, and with a (derived) SDK.  This definitely needs 
> to be reviewed by @dexonsmith


Yes, but the location of libc++ headers on Darwin is always relative to the 
driver. How do you then ensure the consistency between the libc++ library and 
headers when using your own build of Clang?


Repository:
  rC Clang

https://reviews.llvm.org/D45639



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46075: [CMake] Enable libc++ for Fuchsia toolchain on Darwin

2018-04-25 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC330855: [CMake] Enable libc++ for Fuchsia toolchain on 
Darwin (authored by phosek, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D46075?vs=143970&id=143974#toc

Repository:
  rC Clang

https://reviews.llvm.org/D46075

Files:
  cmake/caches/Fuchsia-stage2.cmake


Index: cmake/caches/Fuchsia-stage2.cmake
===
--- cmake/caches/Fuchsia-stage2.cmake
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -38,16 +38,7 @@
 set(LLVM_RUNTIME_TARGETS 
"default;x86_64-fuchsia;aarch64-fuchsia;x86_64-fuchsia-asan:x86_64-fuchsia;aarch64-fuchsia-asan:aarch64-fuchsia"
 CACHE STRING "")
 
 # Set the default target runtimes options.
-if(APPLE)
-  # Disable installing libc++, libc++abi or libunwind on Darwin, since Clang
-  # driver doesn't know how to use libraries that are part of the toolchain.
-  set(LIBUNWIND_INSTALL_HEADERS OFF CACHE BOOL "")
-  set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
-  set(LIBCXXABI_INSTALL_HEADERS OFF CACHE BOOL "")
-  set(LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
-  set(LIBCXX_INSTALL_HEADERS OFF CACHE BOOL "")
-  set(LIBCXX_INSTALL_LIBRARY OFF CACHE BOOL "")
-else()
+if(NOT APPLE)
   set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
   set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
   set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")


Index: cmake/caches/Fuchsia-stage2.cmake
===
--- cmake/caches/Fuchsia-stage2.cmake
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -38,16 +38,7 @@
 set(LLVM_RUNTIME_TARGETS "default;x86_64-fuchsia;aarch64-fuchsia;x86_64-fuchsia-asan:x86_64-fuchsia;aarch64-fuchsia-asan:aarch64-fuchsia" CACHE STRING "")
 
 # Set the default target runtimes options.
-if(APPLE)
-  # Disable installing libc++, libc++abi or libunwind on Darwin, since Clang
-  # driver doesn't know how to use libraries that are part of the toolchain.
-  set(LIBUNWIND_INSTALL_HEADERS OFF CACHE BOOL "")
-  set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
-  set(LIBCXXABI_INSTALL_HEADERS OFF CACHE BOOL "")
-  set(LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
-  set(LIBCXX_INSTALL_HEADERS OFF CACHE BOOL "")
-  set(LIBCXX_INSTALL_LIBRARY OFF CACHE BOOL "")
-else()
+if(NOT APPLE)
   set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
   set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
   set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r330855 - [CMake] Enable libc++ for Fuchsia toolchain on Darwin

2018-04-25 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Wed Apr 25 11:30:55 2018
New Revision: 330855

URL: http://llvm.org/viewvc/llvm-project?rev=330855&view=rev
Log:
[CMake] Enable libc++ for Fuchsia toolchain on Darwin

This is necessary in order to get a working C++ compiler on Darwin
since Clang expects libc++ headers to be part of the toolchain.

Differential Revision: https://reviews.llvm.org/D46075

Modified:
cfe/trunk/cmake/caches/Fuchsia-stage2.cmake

Modified: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Fuchsia-stage2.cmake?rev=330855&r1=330854&r2=330855&view=diff
==
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake Wed Apr 25 11:30:55 2018
@@ -38,16 +38,7 @@ endforeach()
 set(LLVM_RUNTIME_TARGETS 
"default;x86_64-fuchsia;aarch64-fuchsia;x86_64-fuchsia-asan:x86_64-fuchsia;aarch64-fuchsia-asan:aarch64-fuchsia"
 CACHE STRING "")
 
 # Set the default target runtimes options.
-if(APPLE)
-  # Disable installing libc++, libc++abi or libunwind on Darwin, since Clang
-  # driver doesn't know how to use libraries that are part of the toolchain.
-  set(LIBUNWIND_INSTALL_HEADERS OFF CACHE BOOL "")
-  set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
-  set(LIBCXXABI_INSTALL_HEADERS OFF CACHE BOOL "")
-  set(LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
-  set(LIBCXX_INSTALL_HEADERS OFF CACHE BOOL "")
-  set(LIBCXX_INSTALL_LIBRARY OFF CACHE BOOL "")
-else()
+if(NOT APPLE)
   set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
   set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
   set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45532: [StaticAnalyzer] Checker to find uninitialized fields after a constructor call

2018-04-25 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/CtorUninitializedMemberChecker.cpp:72
+  const FieldDecl *getEndOfChain() const { return Chain.back()->getDecl(); }
+  template  void toString(SmallString &Buf) const;
+  friend struct FieldChainInfoComparator;

This can be rewritten like `void toString(SmallVectorImpl &Buf) const;



Comment at: lib/StaticAnalyzer/Checkers/CtorUninitializedMemberChecker.cpp:306
+
+  const RecordDecl *RD =
+  R->getValueType()->getAs()->getDecl()->getDefinition();

What will happen if we analyze a member which is a pointer to a structure type 
and the structure is of incomplete type?



Comment at: lib/StaticAnalyzer/Checkers/CtorUninitializedMemberChecker.cpp:534
+
+  while (T.getTypePtrOrNull()) {
+if (T->isVoidPointerType())

while (!T.isNull())



Comment at: test/Analysis/ctor-uninitialized-member.cpp:554
+
+void f23p15() {
+  void *vptr = malloc(sizeof(int));

Could you please explain what is the logic of test naming?


https://reviews.llvm.org/D45532



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46075: [CMake] Enable libc++ for Fuchsia toolchain on Darwin

2018-04-25 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added a reviewer: mcgrathr.
Herald added subscribers: cfe-commits, mgorny.
Herald added a reviewer: EricWF.

This is necessary in order to get a working C++ compiler on Darwin
since Clang expects libc++ headers to be part of the toolchain.


Repository:
  rC Clang

https://reviews.llvm.org/D46075

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -38,16 +38,7 @@
 set(LLVM_RUNTIME_TARGETS 
"default;x86_64-fuchsia;aarch64-fuchsia;x86_64-fuchsia-asan:x86_64-fuchsia;aarch64-fuchsia-asan:aarch64-fuchsia"
 CACHE STRING "")
 
 # Set the default target runtimes options.
-if(APPLE)
-  # Disable installing libc++, libc++abi or libunwind on Darwin, since Clang
-  # driver doesn't know how to use libraries that are part of the toolchain.
-  set(LIBUNWIND_INSTALL_HEADERS OFF CACHE BOOL "")
-  set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
-  set(LIBCXXABI_INSTALL_HEADERS OFF CACHE BOOL "")
-  set(LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
-  set(LIBCXX_INSTALL_HEADERS OFF CACHE BOOL "")
-  set(LIBCXX_INSTALL_LIBRARY OFF CACHE BOOL "")
-else()
+if(NOT APPLE)
   set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
   set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
   set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -38,16 +38,7 @@
 set(LLVM_RUNTIME_TARGETS "default;x86_64-fuchsia;aarch64-fuchsia;x86_64-fuchsia-asan:x86_64-fuchsia;aarch64-fuchsia-asan:aarch64-fuchsia" CACHE STRING "")
 
 # Set the default target runtimes options.
-if(APPLE)
-  # Disable installing libc++, libc++abi or libunwind on Darwin, since Clang
-  # driver doesn't know how to use libraries that are part of the toolchain.
-  set(LIBUNWIND_INSTALL_HEADERS OFF CACHE BOOL "")
-  set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
-  set(LIBCXXABI_INSTALL_HEADERS OFF CACHE BOOL "")
-  set(LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
-  set(LIBCXX_INSTALL_HEADERS OFF CACHE BOOL "")
-  set(LIBCXX_INSTALL_LIBRARY OFF CACHE BOOL "")
-else()
+if(NOT APPLE)
   set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
   set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
   set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46074: Representing the target device information in the LLVM IR ( CLANG changes)

2018-04-25 Thread Jin Lin via Phabricator via cfe-commits
jinlin created this revision.
jinlin added a reviewer: hfinkel.
Herald added a subscriber: cfe-commits.

The target device information needs to be passed to the LLVM backend when the 
OMP backend outlining is enabled. For example, for multiple target devices, the 
target compilation has to generate one single host to support all the targets. 
In order to make sure all the target outline function have the same interface, 
the information of all the target architecture are needed during host and 
target compilation. In the following example, the firstprivate variable d is 
represented as passing by value under x86_64 mic and passing by reference under 
i386-pc-linux-gnu. In order to fix this inconsistency issue, the compiler can 
change the form of firstprivate d from passing by value under x86_64 mic to 
passing by reference after the compiler has all the target architecture 
information.

Existing code: 64-bit firstprivate variable

void foo() {
 double d = 1.0;
 #pragma omp target firstprivate(d)
 {}
}

$clang –fopenmp-backend -fopenmp-targets=x86_64-mic, i386-pc-linux-gnu …

x86_64-mic

define void @__omp_offloading…(i64 %d) #0 {
entry:
…
}

i386-pc-linux-gnu

define void @__omp_offloading…(double* dereferenceable(8) %d) #0 {
entry:
 …
}

There is an inconsistency between host and target part(s) of the program!

We proposed new module level attribute to represent target device information.

/// Get the target device information which is a string separated by the
/// comma to describe one or more than one device.
const std::string &getTargetDevices() const { return TargetDevices; }

/// set the target device information.
void setTargetDevices(StringRef T) { TargetDevices = T; }

IR Dump (the extension indicated in red font)
target triple = "x86_64-unknown-linux-gnu"
target device_triples = "x86_64-mic,i386-pc-linux-gnu"


Repository:
  rC Clang

https://reviews.llvm.org/D46074

Files:
  lib/CodeGen/ModuleBuilder.cpp


Index: lib/CodeGen/ModuleBuilder.cpp
===
--- lib/CodeGen/ModuleBuilder.cpp
+++ lib/CodeGen/ModuleBuilder.cpp
@@ -131,6 +131,18 @@
   Ctx = &Context;
 
   M->setTargetTriple(Ctx->getTargetInfo().getTriple().getTriple());
+
+  // The target device information is represented as module level
+  // attribute.
+  SmallString<128> Res;
+  for (auto &Device : Ctx->getLangOpts().OMPTargetTriples) {
+if (!Res.empty())
+  Res += ",";
+Res += Device.getTriple();
+  }
+  if (!Res.empty())
+M->setTargetDevices(Res);
+
   M->setDataLayout(Ctx->getTargetInfo().getDataLayout());
   Builder.reset(new CodeGen::CodeGenModule(Context, HeaderSearchOpts,
PreprocessorOpts, CodeGenOpts,


Index: lib/CodeGen/ModuleBuilder.cpp
===
--- lib/CodeGen/ModuleBuilder.cpp
+++ lib/CodeGen/ModuleBuilder.cpp
@@ -131,6 +131,18 @@
   Ctx = &Context;
 
   M->setTargetTriple(Ctx->getTargetInfo().getTriple().getTriple());
+
+  // The target device information is represented as module level
+  // attribute.
+  SmallString<128> Res;
+  for (auto &Device : Ctx->getLangOpts().OMPTargetTriples) {
+if (!Res.empty())
+  Res += ",";
+Res += Device.getTriple();
+  }
+  if (!Res.empty())
+M->setTargetDevices(Res);
+
   M->setDataLayout(Ctx->getTargetInfo().getDataLayout());
   Builder.reset(new CodeGen::CodeGenModule(Context, HeaderSearchOpts,
PreprocessorOpts, CodeGenOpts,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46071: Representing the target device information in the LLVM IR

2018-04-25 Thread Jin Lin via Phabricator via cfe-commits
jinlin updated this revision to Diff 143967.

https://reviews.llvm.org/D46071

Files:
  docs/LangRef.rst
  include/llvm/Bitcode/LLVMBitCodes.h
  include/llvm/IR/Module.h
  lib/AsmParser/LLLexer.cpp
  lib/AsmParser/LLParser.cpp
  lib/AsmParser/LLToken.h
  lib/Bitcode/Reader/BitcodeReader.cpp
  lib/Bitcode/Writer/BitcodeWriter.cpp
  lib/IR/AsmWriter.cpp
  lib/Transforms/Utils/CloneModule.cpp

Index: lib/Transforms/Utils/CloneModule.cpp
===
--- lib/Transforms/Utils/CloneModule.cpp
+++ lib/Transforms/Utils/CloneModule.cpp
@@ -53,6 +53,7 @@
   New->setSourceFileName(M.getSourceFileName());
   New->setDataLayout(M.getDataLayout());
   New->setTargetTriple(M.getTargetTriple());
+  New->setTargetDevices(M.getTargetDevices());
   New->setModuleInlineAsm(M.getModuleInlineAsm());
 
   // Loop over all of the global variables, making corresponding globals in the
@@ -110,7 +111,7 @@
 GA->copyAttributesFrom(&*I);
 VMap[&*I] = GA;
   }
-  
+
   // Now that all of the things that global variable initializer can refer to
   // have been created, loop through and copy the global variable referrers
   // over...  We also set the attributes on the global now.
Index: lib/IR/AsmWriter.cpp
===
--- lib/IR/AsmWriter.cpp
+++ lib/IR/AsmWriter.cpp
@@ -2392,6 +2392,9 @@
   if (!M->getTargetTriple().empty())
 Out << "target triple = \"" << M->getTargetTriple() << "\"\n";
 
+  if (!M->getTargetDevices().empty())
+Out << "target device_triples = \"" << M->getTargetDevices() << "\"\n";
+
   if (!M->getModuleInlineAsm().empty()) {
 Out << '\n';
 
Index: lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- lib/Bitcode/Writer/BitcodeWriter.cpp
+++ lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -1108,6 +1108,9 @@
   if (!M.getTargetTriple().empty())
 writeStringRecord(Stream, bitc::MODULE_CODE_TRIPLE, M.getTargetTriple(),
   0 /*TODO*/);
+  if (!M.getTargetDevices().empty())
+writeStringRecord(Stream, bitc::MODULE_CODE_DEVICES, M.getTargetDevices(),
+  0 /*TODO*/);
   const std::string &DL = M.getDataLayoutStr();
   if (!DL.empty())
 writeStringRecord(Stream, bitc::MODULE_CODE_DATALAYOUT, DL, 0 /*TODO*/);
Index: lib/Bitcode/Reader/BitcodeReader.cpp
===
--- lib/Bitcode/Reader/BitcodeReader.cpp
+++ lib/Bitcode/Reader/BitcodeReader.cpp
@@ -3257,6 +3257,13 @@
   TheModule->setTargetTriple(S);
   break;
 }
+case bitc::MODULE_CODE_DEVICES: { // TRIPLE: [strchr x N, ..., strchr x N]
+  std::string S;
+  if (convertToString(Record, 0, S))
+return error("Invalid record");
+  TheModule->setTargetDevices(S);
+  break;
+}
 case bitc::MODULE_CODE_DATALAYOUT: {  // DATALAYOUT: [strchr x N]
   std::string S;
   if (convertToString(Record, 0, S))
Index: lib/AsmParser/LLToken.h
===
--- lib/AsmParser/LLToken.h
+++ lib/AsmParser/LLToken.h
@@ -84,6 +84,7 @@
   kw_notail,
   kw_target,
   kw_triple,
+  kw_device_triples,
   kw_source_filename,
   kw_unwind,
   kw_deplibs, // FIXME: Remove in 4.0
Index: lib/AsmParser/LLParser.cpp
===
--- lib/AsmParser/LLParser.cpp
+++ lib/AsmParser/LLParser.cpp
@@ -322,6 +322,13 @@
   return true;
 M->setTargetTriple(Str);
 return false;
+  case lltok::kw_device_triples:
+Lex.Lex();
+if (ParseToken(lltok::equal, "expected '=' after target devices") ||
+ParseStringConstant(Str))
+  return true;
+M->setTargetDevices(Str);
+return false;
   case lltok::kw_datalayout:
 Lex.Lex();
 if (ParseToken(lltok::equal, "expected '=' after target datalayout") ||
Index: lib/AsmParser/LLLexer.cpp
===
--- lib/AsmParser/LLLexer.cpp
+++ lib/AsmParser/LLLexer.cpp
@@ -533,6 +533,7 @@
   KEYWORD(notail);
   KEYWORD(target);
   KEYWORD(triple);
+  KEYWORD(device_triples);
   KEYWORD(source_filename);
   KEYWORD(unwind);
   KEYWORD(deplibs); // FIXME: Remove in 4.0.
Index: include/llvm/IR/Module.h
===
--- include/llvm/IR/Module.h
+++ include/llvm/IR/Module.h
@@ -187,6 +187,8 @@
   void *NamedMDSymTab;///< NamedMDNode names.
   DataLayout DL;  ///< DataLayout associated with the module
 
+  std::string TargetDevices;  ///< Target devices
+
   friend class Constant;
 
 /// @}
@@ -232,6 +234,10 @@
   /// @returns a string containing the target triple.
   const std::string &getTargetTriple() const { return TargetTriple; }
 
+  /// Get the target device information which is a comma-separated string
+  /// describing one or more devices.
+  const std::string

[PATCH] D46071: Representing the target device information in the LLVM IR

2018-04-25 Thread Jin Lin via Phabricator via cfe-commits
jinlin updated this revision to Diff 143966.

https://reviews.llvm.org/D46071

Files:
  docs/LangRef.rst
  include/llvm/Bitcode/LLVMBitCodes.h
  include/llvm/IR/Module.h
  lib/AsmParser/LLLexer.cpp
  lib/AsmParser/LLParser.cpp
  lib/AsmParser/LLToken.h
  lib/Bitcode/Reader/BitcodeReader.cpp
  lib/Bitcode/Writer/BitcodeWriter.cpp
  lib/IR/AsmWriter.cpp
  lib/Transforms/Utils/CloneModule.cpp

Index: lib/Transforms/Utils/CloneModule.cpp
===
--- lib/Transforms/Utils/CloneModule.cpp
+++ lib/Transforms/Utils/CloneModule.cpp
@@ -53,6 +53,7 @@
   New->setSourceFileName(M.getSourceFileName());
   New->setDataLayout(M.getDataLayout());
   New->setTargetTriple(M.getTargetTriple());
+  New->setTargetDevices(M.getTargetDevices());
   New->setModuleInlineAsm(M.getModuleInlineAsm());
 
   // Loop over all of the global variables, making corresponding globals in the
@@ -110,7 +111,7 @@
 GA->copyAttributesFrom(&*I);
 VMap[&*I] = GA;
   }
-  
+
   // Now that all of the things that global variable initializer can refer to
   // have been created, loop through and copy the global variable referrers
   // over...  We also set the attributes on the global now.
Index: lib/IR/AsmWriter.cpp
===
--- lib/IR/AsmWriter.cpp
+++ lib/IR/AsmWriter.cpp
@@ -2392,6 +2392,9 @@
   if (!M->getTargetTriple().empty())
 Out << "target triple = \"" << M->getTargetTriple() << "\"\n";
 
+  if (!M->getTargetDevices().empty())
+Out << "target device_triples = \"" << M->getTargetDevices() << "\"\n";
+
   if (!M->getModuleInlineAsm().empty()) {
 Out << '\n';
 
Index: lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- lib/Bitcode/Writer/BitcodeWriter.cpp
+++ lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -1108,6 +1108,9 @@
   if (!M.getTargetTriple().empty())
 writeStringRecord(Stream, bitc::MODULE_CODE_TRIPLE, M.getTargetTriple(),
   0 /*TODO*/);
+  if (!M.getTargetDevices().empty())
+writeStringRecord(Stream, bitc::MODULE_CODE_DEVICES, M.getTargetDevices(),
+  0 /*TODO*/);
   const std::string &DL = M.getDataLayoutStr();
   if (!DL.empty())
 writeStringRecord(Stream, bitc::MODULE_CODE_DATALAYOUT, DL, 0 /*TODO*/);
Index: lib/Bitcode/Reader/BitcodeReader.cpp
===
--- lib/Bitcode/Reader/BitcodeReader.cpp
+++ lib/Bitcode/Reader/BitcodeReader.cpp
@@ -3257,6 +3257,13 @@
   TheModule->setTargetTriple(S);
   break;
 }
+case bitc::MODULE_CODE_DEVICES: { // TRIPLE: [strchr x N, ..., strchr x N]
+  std::string S;
+  if (convertToString(Record, 0, S))
+return error("Invalid record");
+  TheModule->setTargetDevices(S);
+  break;
+}
 case bitc::MODULE_CODE_DATALAYOUT: {  // DATALAYOUT: [strchr x N]
   std::string S;
   if (convertToString(Record, 0, S))
Index: lib/AsmParser/LLToken.h
===
--- lib/AsmParser/LLToken.h
+++ lib/AsmParser/LLToken.h
@@ -84,6 +84,7 @@
   kw_notail,
   kw_target,
   kw_triple,
+  kw_device_triples,
   kw_source_filename,
   kw_unwind,
   kw_deplibs, // FIXME: Remove in 4.0
Index: lib/AsmParser/LLParser.cpp
===
--- lib/AsmParser/LLParser.cpp
+++ lib/AsmParser/LLParser.cpp
@@ -322,6 +322,13 @@
   return true;
 M->setTargetTriple(Str);
 return false;
+  case lltok::kw_device_triples:
+Lex.Lex();
+if (ParseToken(lltok::equal, "expected '=' after target devices") ||
+ParseStringConstant(Str))
+  return true;
+M->setTargetDevices(Str);
+return false;
   case lltok::kw_datalayout:
 Lex.Lex();
 if (ParseToken(lltok::equal, "expected '=' after target datalayout") ||
Index: lib/AsmParser/LLLexer.cpp
===
--- lib/AsmParser/LLLexer.cpp
+++ lib/AsmParser/LLLexer.cpp
@@ -533,6 +533,7 @@
   KEYWORD(notail);
   KEYWORD(target);
   KEYWORD(triple);
+  KEYWORD(device_triples);
   KEYWORD(source_filename);
   KEYWORD(unwind);
   KEYWORD(deplibs); // FIXME: Remove in 4.0.
Index: include/llvm/IR/Module.h
===
--- include/llvm/IR/Module.h
+++ include/llvm/IR/Module.h
@@ -187,6 +187,8 @@
   void *NamedMDSymTab;///< NamedMDNode names.
   DataLayout DL;  ///< DataLayout associated with the module
 
+  std::string TargetDevices;  ///< Target devices
+
   friend class Constant;
 
 /// @}
@@ -232,6 +234,10 @@
   /// @returns a string containing the target triple.
   const std::string &getTargetTriple() const { return TargetTriple; }
 
+  /// Get the target device information which is a comma-separated string
+  /// describing one or more devices.
+  const std::string

[PATCH] D46071: Representing the target device information in the LLVM IR

2018-04-25 Thread Jin Lin via Phabricator via cfe-commits
jinlin updated this revision to Diff 143965.

https://reviews.llvm.org/D46071

Files:
  docs/LangRef.rst
  include/llvm/Bitcode/LLVMBitCodes.h
  include/llvm/IR/Module.h
  lib/AsmParser/LLLexer.cpp
  lib/AsmParser/LLParser.cpp
  lib/AsmParser/LLToken.h
  lib/Bitcode/Reader/BitcodeReader.cpp
  lib/Bitcode/Writer/BitcodeWriter.cpp
  lib/IR/AsmWriter.cpp
  lib/Transforms/Utils/CloneModule.cpp

Index: lib/IR/AsmWriter.cpp
===
--- lib/IR/AsmWriter.cpp
+++ lib/IR/AsmWriter.cpp
@@ -2392,6 +2392,9 @@
   if (!M->getTargetTriple().empty())
 Out << "target triple = \"" << M->getTargetTriple() << "\"\n";
 
+  if (!M->getTargetDevices().empty())
+Out << "target device_triples = \"" << M->getTargetDevices() << "\"\n";
+
   if (!M->getModuleInlineAsm().empty()) {
 Out << '\n';
 
Index: lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- lib/Bitcode/Writer/BitcodeWriter.cpp
+++ lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -1108,6 +1108,9 @@
   if (!M.getTargetTriple().empty())
 writeStringRecord(Stream, bitc::MODULE_CODE_TRIPLE, M.getTargetTriple(),
   0 /*TODO*/);
+  if (!M.getTargetDevices().empty())
+writeStringRecord(Stream, bitc::MODULE_CODE_DEVICES, M.getTargetDevices(),
+  0 /*TODO*/);
   const std::string &DL = M.getDataLayoutStr();
   if (!DL.empty())
 writeStringRecord(Stream, bitc::MODULE_CODE_DATALAYOUT, DL, 0 /*TODO*/);
Index: lib/Bitcode/Reader/BitcodeReader.cpp
===
--- lib/Bitcode/Reader/BitcodeReader.cpp
+++ lib/Bitcode/Reader/BitcodeReader.cpp
@@ -3257,6 +3257,13 @@
   TheModule->setTargetTriple(S);
   break;
 }
+case bitc::MODULE_CODE_DEVICES: { // TRIPLE: [strchr x N, ..., strchr x N]
+  std::string S;
+  if (convertToString(Record, 0, S))
+return error("Invalid record");
+  TheModule->setTargetDevices(S);
+  break;
+}
 case bitc::MODULE_CODE_DATALAYOUT: {  // DATALAYOUT: [strchr x N]
   std::string S;
   if (convertToString(Record, 0, S))
Index: lib/Transforms/Utils/CloneModule.cpp
===
--- lib/Transforms/Utils/CloneModule.cpp
+++ lib/Transforms/Utils/CloneModule.cpp
@@ -53,6 +53,7 @@
   New->setSourceFileName(M.getSourceFileName());
   New->setDataLayout(M.getDataLayout());
   New->setTargetTriple(M.getTargetTriple());
+  New->setTargetDevices(M.getTargetDevices());
   New->setModuleInlineAsm(M.getModuleInlineAsm());
 
   // Loop over all of the global variables, making corresponding globals in the
@@ -110,7 +111,7 @@
 GA->copyAttributesFrom(&*I);
 VMap[&*I] = GA;
   }
-  
+
   // Now that all of the things that global variable initializer can refer to
   // have been created, loop through and copy the global variable referrers
   // over...  We also set the attributes on the global now.
Index: lib/AsmParser/LLToken.h
===
--- lib/AsmParser/LLToken.h
+++ lib/AsmParser/LLToken.h
@@ -84,6 +84,7 @@
   kw_notail,
   kw_target,
   kw_triple,
+  kw_device_triples,
   kw_source_filename,
   kw_unwind,
   kw_deplibs, // FIXME: Remove in 4.0
Index: lib/AsmParser/LLLexer.cpp
===
--- lib/AsmParser/LLLexer.cpp
+++ lib/AsmParser/LLLexer.cpp
@@ -533,6 +533,7 @@
   KEYWORD(notail);
   KEYWORD(target);
   KEYWORD(triple);
+  KEYWORD(device_triples);
   KEYWORD(source_filename);
   KEYWORD(unwind);
   KEYWORD(deplibs); // FIXME: Remove in 4.0.
Index: lib/AsmParser/LLParser.cpp
===
--- lib/AsmParser/LLParser.cpp
+++ lib/AsmParser/LLParser.cpp
@@ -322,6 +322,13 @@
   return true;
 M->setTargetTriple(Str);
 return false;
+  case lltok::kw_device_triples:
+Lex.Lex();
+if (ParseToken(lltok::equal, "expected '=' after target devices") ||
+ParseStringConstant(Str))
+  return true;
+M->setTargetDevices(Str);
+return false;
   case lltok::kw_datalayout:
 Lex.Lex();
 if (ParseToken(lltok::equal, "expected '=' after target datalayout") ||
Index: docs/LangRef.rst
===
--- docs/LangRef.rst
+++ docs/LangRef.rst
@@ -2064,6 +2064,25 @@
 code for the proper architecture. It's possible to override this on the
 command line with the ``-mtriple`` command line option.
 
+.. _target_devices_triples:
+
+Devices Triples
+---
+A module may specify comma-separated list of triples that describes the
+OpenMP offloading targets to be supported. The list of triples is denoted
+as devices triple, whose syntax is simply:
+
+.. code-block:: llvm
+
+target device_triples = "x86_64-mic,i386-pc-linux-gnu"
+
+The *devices triples* string consists of a series of subst

[PATCH] D46022: [OpenCL] Restrict various keywords in OpenCL C++ mode

2018-04-25 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Yeah, if there are actually differences in the set of keywords, that's a 
totally reasonable thing to handle in the lexer.




Comment at: include/clang/Basic/TokenKinds.def:255
+//   KEYNOOPENCL  - This is a keyword that is not supported in OpenCL C
+//  nor in OpenCL C++.
 //   KEYALTIVEC - This is a keyword in AltiVec

`KEYNOOPENCL` is dead now, I think.



Comment at: lib/Sema/DeclSpec.cpp:621
+// OpenCL C++ 1.0 s2.9: the thread_local storage qualifier is not
+// supported.
+case TSCS_thread_local:

Do you really care about the spelling of the specifier?  Presumably `__thread` 
(the GNU extension) and `_Thread_local` (the C11 feature) are unsupported; 
where are those diagnosed?


https://reviews.llvm.org/D46022



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46071: Representing the target device information in the LLVM IR

2018-04-25 Thread Jin Lin via Phabricator via cfe-commits
jinlin updated this revision to Diff 143964.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D46071

Files:
  lib/CodeGen/ModuleBuilder.cpp


Index: lib/CodeGen/ModuleBuilder.cpp
===
--- lib/CodeGen/ModuleBuilder.cpp
+++ lib/CodeGen/ModuleBuilder.cpp
@@ -131,6 +131,18 @@
   Ctx = &Context;
 
   M->setTargetTriple(Ctx->getTargetInfo().getTriple().getTriple());
+
+  // The target device information is represented as module level
+  // attribute.
+  SmallString<128> Res;
+  for (auto &Device : Ctx->getLangOpts().OMPTargetTriples) {
+if (!Res.empty())
+  Res += ",";
+Res += Device.getTriple();
+  }
+  if (!Res.empty())
+M->setTargetDevices(Res);
+
   M->setDataLayout(Ctx->getTargetInfo().getDataLayout());
   Builder.reset(new CodeGen::CodeGenModule(Context, HeaderSearchOpts,
PreprocessorOpts, CodeGenOpts,


Index: lib/CodeGen/ModuleBuilder.cpp
===
--- lib/CodeGen/ModuleBuilder.cpp
+++ lib/CodeGen/ModuleBuilder.cpp
@@ -131,6 +131,18 @@
   Ctx = &Context;
 
   M->setTargetTriple(Ctx->getTargetInfo().getTriple().getTriple());
+
+  // The target device information is represented as module level
+  // attribute.
+  SmallString<128> Res;
+  for (auto &Device : Ctx->getLangOpts().OMPTargetTriples) {
+if (!Res.empty())
+  Res += ",";
+Res += Device.getTriple();
+  }
+  if (!Res.empty())
+M->setTargetDevices(Res);
+
   M->setDataLayout(Ctx->getTargetInfo().getDataLayout());
   Builder.reset(new CodeGen::CodeGenModule(Context, HeaderSearchOpts,
PreprocessorOpts, CodeGenOpts,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46019: [ASTImporter] Fix isa cast assert

2018-04-25 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

Confirming LGTM, no objections. Thank you!


Repository:
  rC Clang

https://reviews.llvm.org/D46019



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libclc] r330851 - relational/select: Condition types for half are short/ushort, not char/uchar

2018-04-25 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Wed Apr 25 10:36:36 2018
New Revision: 330851

URL: http://llvm.org/viewvc/llvm-project?rev=330851&view=rev
Log:
relational/select: Condition types for half are short/ushort, not char/uchar

Signed-off-by: Jan Vesely 
Reviewed-by: Aaron Watry 

Modified:
libclc/trunk/generic/include/clc/relational/select.inc

Modified: libclc/trunk/generic/include/clc/relational/select.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/relational/select.inc?rev=330851&r1=330850&r2=330851&view=diff
==
--- libclc/trunk/generic/include/clc/relational/select.inc (original)
+++ libclc/trunk/generic/include/clc/relational/select.inc Wed Apr 25 10:36:36 
2018
@@ -9,8 +9,8 @@
 #define __CLC_S_GENTYPE __CLC_XCONCAT(int, __CLC_VECSIZE)
 #define __CLC_U_GENTYPE __CLC_XCONCAT(uint, __CLC_VECSIZE)
 #elif __CLC_FPSIZE == 16
-#define __CLC_S_GENTYPE __CLC_XCONCAT(char, __CLC_VECSIZE)
-#define __CLC_U_GENTYPE __CLC_XCONCAT(uchar, __CLC_VECSIZE)
+#define __CLC_S_GENTYPE __CLC_XCONCAT(short, __CLC_VECSIZE)
+#define __CLC_U_GENTYPE __CLC_XCONCAT(ushort, __CLC_VECSIZE)
 #endif
 
 _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE select(__CLC_GENTYPE x, __CLC_GENTYPE y, 
__CLC_S_GENTYPE z);


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r330847 - [ASTImporter] FriendDecl importing improvements

2018-04-25 Thread Peter Szecsi via cfe-commits
Author: szepet
Date: Wed Apr 25 10:28:03 2018
New Revision: 330847

URL: http://llvm.org/viewvc/llvm-project?rev=330847&view=rev
Log:
[ASTImporter] FriendDecl importing improvements

There are only a few cases of importing a frienddecl which is currently 
supported.
This patch aims to improve the friend import process.
Set FriendObjectKind in case of decls, insert friend into the friend chain
correctly, checks structurally equivalent in a more advanced manner.
Test cases added as well.  


Modified:
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
cfe/trunk/test/ASTMerge/class/Inputs/class1.cpp
cfe/trunk/test/ASTMerge/class/Inputs/class2.cpp
cfe/trunk/test/ASTMerge/class/test.cpp

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=330847&r1=330846&r2=330847&view=diff
==
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Wed Apr 25 10:28:03 2018
@@ -309,6 +309,7 @@ private:
 protected:
   friend class ASTDeclReader;
   friend class ASTDeclWriter;
+  friend class ASTImporter;
   friend class ASTReader;
   friend class CXXClassMemberWrapper;
   friend class LinkageComputer;

Modified: cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td?rev=330847&r1=330846&r2=330847&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td Wed Apr 25 10:28:03 2018
@@ -273,6 +273,8 @@ def note_odr_objc_synthesize_ivar_here :
   "property is synthesized to ivar %0 here">;
 
 // Importing C++ ASTs
+def note_odr_friend : Note<"friend declared here">;
+def note_odr_missing_friend : Note<"no corresponding friend here">;
 def err_odr_different_num_template_parameters : Error<
   "template parameter lists have a different number of parameters (%0 vs %1)">;
 def note_odr_template_parameter_list : Note<

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=330847&r1=330846&r2=330847&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Wed Apr 25 10:28:03 2018
@@ -2709,9 +2709,14 @@ Decl *ASTNodeImporter::VisitFriendDecl(F
 
   // Not found. Create it.
   FriendDecl::FriendUnion ToFU;
-  if (NamedDecl *FriendD = D->getFriendDecl())
-ToFU = cast_or_null(Importer.Import(FriendD));
-  else
+  if (NamedDecl *FriendD = D->getFriendDecl()) {
+auto *ToFriendD = cast_or_null(Importer.Import(FriendD));
+if (ToFriendD && FriendD->getFriendObjectKind() != Decl::FOK_None &&
+!(FriendD->isInIdentifierNamespace(Decl::IDNS_NonMemberOperator)))
+  ToFriendD->setObjectOfFriendDecl(false);
+
+ToFU = ToFriendD;
+  }  else // The friend is a type, not a decl.
 ToFU = Importer.Import(D->getFriendType());
   if (!ToFU)
 return nullptr;
@@ -2731,7 +2736,6 @@ Decl *ASTNodeImporter::VisitFriendDecl(F
ToTPLists);
 
   Importer.Imported(D, FrD);
-  RD->pushFriendDecl(FrD);
 
   FrD->setAccess(D->getAccess());
   FrD->setLexicalDeclContext(LexicalDC);
@@ -6596,7 +6600,7 @@ Decl *ASTImporter::Import(Decl *FromD) {
 
   // Record the imported declaration.
   ImportedDecls[FromD] = ToD;
-
+  ToD->IdentifierNamespace = FromD->IdentifierNamespace;
   return ToD;
 }
 

Modified: cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp?rev=330847&r1=330846&r2=330847&view=diff
==
--- cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp (original)
+++ cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp Wed Apr 25 10:28:03 2018
@@ -18,6 +18,7 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclFriend.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/NestedNameSpecifier.h"
@@ -942,6 +943,44 @@ static bool IsStructurallyEquivalent(Str
   return false;
 }
   }
+
+  // Check the friends for consistency.
+  CXXRecordDecl::friend_iterator Friend2 = D2CXX->friend_begin(),
+  Friend2End = D2CXX->friend_end();
+  for (CXXRecordDecl::friend_iterator Friend1 = D1CXX->friend_begin(),
+   Friend1End = D1CXX->friend_end();
+   Friend1 != Friend1End; ++Friend1, ++Friend2) {
+if (Friend2 == Friend2End) {

[PATCH] D45416: [analyzer] ExprEngine: model GCC inline asm rvalue cast outputs

2018-04-25 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin updated this revision to Diff 143959.
a.sidorin added a comment.

Add a test for CFG dump; replace static_cast with an initialization.
No test failures on check-all were observed.


Repository:
  rC Clang

https://reviews.llvm.org/D45416

Files:
  include/clang/Analysis/CFG.h
  lib/Analysis/CFG.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/Analysis/asm.cpp
  test/Analysis/cfg.cpp

Index: test/Analysis/cfg.cpp
===
--- test/Analysis/cfg.cpp
+++ test/Analysis/cfg.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG -triple x86_64-apple-darwin12 -analyzer-config cfg-temporary-dtors=true -std=c++11 -analyzer-config cfg-rich-constructors=false %s > %t 2>&1
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG -triple x86_64-apple-darwin12 -fheinous-gnu-extensions -analyzer-config cfg-temporary-dtors=true -std=c++11 -analyzer-config cfg-rich-constructors=false %s > %t 2>&1
 // RUN: FileCheck --input-file=%t -check-prefixes=CHECK,WARNINGS %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG -triple x86_64-apple-darwin12 -analyzer-config cfg-temporary-dtors=true -std=c++11 -analyzer-config cfg-rich-constructors=true %s > %t 2>&1
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG -triple x86_64-apple-darwin12 -fheinous-gnu-extensions -analyzer-config cfg-temporary-dtors=true -std=c++11 -analyzer-config cfg-rich-constructors=true %s > %t 2>&1
 // RUN: FileCheck --input-file=%t -check-prefixes=CHECK,ANALYZER %s
 
 // This file tests how we construct two different flavors of the Clang CFG -
@@ -84,6 +84,23 @@
   static_assert(1, "abc");
 }
 
+
+// CHECK-LABEL: void checkGCCAsmRValueOutput()
+// CHECK: [B2 (ENTRY)]
+// CHECK-NEXT: Succs (1): B1
+// CHECK: [B1]
+// CHECK-NEXT:   1: int arg
+// CHECK-NEXT:   2: arg
+// CHECK-NEXT:   3: asm ("" : "=r" ([B1.2]));
+// CHECK-NEXT:   4: arg
+// CHECK-NEXT:   5: asm ("" : "=r" ([B1.4]));
+void checkGCCAsmRValueOutput() {
+  int arg;
+  __asm__("" : "=r"((int)arg));  // rvalue output operand
+  __asm__("" : "=r"(arg));   // lvalue output operand
+}
+
+
 // CHECK-LABEL: void F(EmptyE e)
 // CHECK: ENTRY
 // CHECK-NEXT: Succs (1): B1
Index: test/Analysis/asm.cpp
===
--- /dev/null
+++ test/Analysis/asm.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker debug.ExprInspection -fheinous-gnu-extensions -w %s -verify
+
+int clang_analyzer_eval(int);
+
+int global;
+void testRValueOutput() {
+  int &ref = global;
+  ref = 1;
+  __asm__("" : "=r"((int)global));  // don't crash on rvalue output operand
+  clang_analyzer_eval(global == 1); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(ref == 1);// expected-warning{{UNKNOWN}}
+}
Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -3058,13 +3058,14 @@
   // outputs.
 
   ProgramStateRef state = Pred->getState();
+  const auto *LCtx = Pred->getLocationContext();
 
   for (const Expr *O : A->outputs()) {
-SVal X = state->getSVal(O, Pred->getLocationContext());
+SVal X = state->getSVal(O, LCtx);
 assert(!X.getAs());  // Should be an Lval, or unknown, undef.
 
 if (Optional LV = X.getAs())
-  state = state->bindLoc(*LV, UnknownVal(), Pred->getLocationContext());
+  state = state->bindLoc(*LV, UnknownVal(), LCtx);
   }
 
   Bldr.generateNode(A, Pred, state);
Index: lib/Analysis/CFG.cpp
===
--- lib/Analysis/CFG.cpp
+++ lib/Analysis/CFG.cpp
@@ -548,6 +548,7 @@
   CFGBlock *VisitDoStmt(DoStmt *D);
   CFGBlock *VisitExprWithCleanups(ExprWithCleanups *E, AddStmtChoice asc);
   CFGBlock *VisitForStmt(ForStmt *F);
+  CFGBlock *VisitGCCAsmStmt(GCCAsmStmt *GCCAsmS, AddStmtChoice asc);
   CFGBlock *VisitGotoStmt(GotoStmt *G);
   CFGBlock *VisitIfStmt(IfStmt *I);
   CFGBlock *VisitImplicitCastExpr(ImplicitCastExpr *E, AddStmtChoice asc);
@@ -587,6 +588,16 @@
   CFGBlock *VisitChildren(Stmt *S);
   CFGBlock *VisitNoRecurse(Expr *E, AddStmtChoice asc);
 
+  GCCAsmStmt *getOrCreateGCCAsmStmtWithoutGnuExtensions(GCCAsmStmt *GCCAsmS);
+
+  template  void *allocateMemForStmt() {
+// Get the alignment of the new Stmt, padding out to >=8 bytes.
+unsigned Align = std::max(alignof(StmtTy), size_t{8});
+// Allocate a new Stmt using the BumpPtrAllocator. It will get
+// automatically freed with the CFG.
+return cfg->getAllocator().Allocate(sizeof(StmtTy), Align);
+  }
+
   void maybeAddScopeBeginForVarDecl(CFGBlock *B, const VarDecl *VD,
 const Stmt *S) {
 if (ScopePos && (VD == ScopePos.getFirstVarInScope()))
@@ -2039,6 +2050,9 @@
 case Stmt::ForStmtClass:
   return VisitForStmt(cast(S));
 
+case Stmt::GCCAsmStmtClass:
+  return VisitGCC

Re: r329804 - [Sema] Fix built-in decrement operator overload resolution

2018-04-25 Thread Richard Smith via cfe-commits
On 12 April 2018 at 07:20, Jan Korous via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hi Richard,
>
> Here you are:
> https://reviews.llvm.org/D45569
>
> I am now thinking if it makes sense to output this warning for pre-17
> standards:
>
> warning: incrementing expression of type bool is deprecated and
> incompatible with C++17
>
> Produced in:
>
> SemaExpr.cpp
>
> static QualType CheckIncrementDecrementOperand
>
> // Increment of bool sets it to true, but is deprecated.
> S.Diag(OpLoc, S.getLangOpts().CPlusPlus17 ? diag::ext_increment_bool
>   : diag::warn_increment_bool)
>
> What do you think?
>

Seems like a good idea to me, thanks!


> Jan
>
> On 11 Apr 2018, at 15:19, Richard Smith  wrote:
>
> While you're here... ++ should not be available for bool in C++17 onwards.
> :)
>
> On Wed, 11 Apr 2018, 14:39 Jan Korous via cfe-commits, <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: jkorous
>> Date: Wed Apr 11 06:36:29 2018
>> New Revision: 329804
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=329804&view=rev
>> Log:
>> [Sema] Fix built-in decrement operator overload resolution
>>
>> C++ [over.built] p4:
>>
>> "For every pair (T, VQ), where T is an arithmetic type other than bool,
>> and VQ is either volatile or empty, there exist candidate operator
>> functions of the form
>>
>>   VQ T&  operator--(VQ T&);
>>   T  operator--(VQ T&, int);
>> "
>> The bool type is in position LastPromotedIntegralType in
>> BuiltinOperatorOverloadBuilder::getArithmeticType::ArithmeticTypes, but
>> addPlusPlusMinusMinusArithmeticOverloads() was expecting it at position
>> 0.
>>
>> Differential Revision: https://reviews.llvm.org/D44988
>>
>> rdar://problem/34255516
>>
>> Modified:
>> cfe/trunk/lib/Sema/SemaOverload.cpp
>> cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
>> SemaOverload.cpp?rev=329804&r1=329803&r2=329804&view=diff
>> 
>> ==
>> --- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Apr 11 06:36:29 2018
>> @@ -7796,10 +7796,12 @@ public:
>>  if (!HasArithmeticOrEnumeralCandidateType)
>>return;
>>
>> -for (unsigned Arith = (Op == OO_PlusPlus? 0 : 1);
>> - Arith < NumArithmeticTypes; ++Arith) {
>> +for (unsigned Arith = 0; Arith < NumArithmeticTypes; ++Arith) {
>> +  const auto TypeOfT = ArithmeticTypes[Arith];
>> +  if (Op == OO_MinusMinus && TypeOfT == S.Context.BoolTy)
>> +continue;
>>addPlusPlusMinusMinusStyleOverloads(
>> -ArithmeticTypes[Arith],
>> +TypeOfT,
>>  VisibleTypeConversionsQuals.hasVolatile(),
>>  VisibleTypeConversionsQuals.hasRestrict());
>>  }
>>
>> Modified: cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
>> SemaCXX/overloaded-builtin-operators.cpp?rev=329804&r1=
>> 329803&r2=329804&view=diff
>> 
>> ==
>> --- cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp (original)
>> +++ cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp Wed Apr 11
>> 06:36:29 2018
>> @@ -62,6 +62,10 @@ void f(Short s, Long l, Enum1 e1, Enum2
>>// FIXME: should pass (void)static_cast(islong(e1 % e2));
>>  }
>>
>> +struct BoolRef {
>> +  operator bool&();
>> +};
>> +
>>  struct ShortRef { // expected-note{{candidate function (the implicit
>> copy assignment operator) not viable}}
>>  #if __cplusplus >= 201103L // C++11 or later
>>  // expected-note@-2 {{candidate function (the implicit move assignment
>> operator) not viable}}
>> @@ -73,6 +77,10 @@ struct LongRef {
>>operator volatile long&();
>>  };
>>
>> +struct FloatRef {
>> +  operator float&();
>> +};
>> +
>>  struct XpmfRef { // expected-note{{candidate function (the implicit copy
>> assignment operator) not viable}}
>>  #if __cplusplus >= 201103L // C++11 or later
>>  // expected-note@-2 {{candidate function (the implicit move assignment
>> operator) not viable}}
>> @@ -84,13 +92,19 @@ struct E2Ref {
>>operator E2&();
>>  };
>>
>> -void g(ShortRef sr, LongRef lr, E2Ref e2_ref, XpmfRef pmf_ref) {
>> +void g(BoolRef br, ShortRef sr, LongRef lr, FloatRef fr, E2Ref e2_ref,
>> XpmfRef pmf_ref) {
>>// C++ [over.built]p3
>>short s1 = sr++;
>>
>> -  // C++ [over.built]p3
>> +  // C++ [over.built]p4
>>long l1 = lr--;
>>
>> +  // C++ [over.built]p4
>> +  float f1 = fr--;
>> +
>> +  // C++ [over.built]p4
>> +  bool b2 = br--; // expected-error{{cannot decrement value of type
>> 'BoolRef'}}
>> +
>>// C++ [over.built]p18
>>short& sr1 = (sr *= lr);
>>volatile long& lr1 = (lr *= sr);
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@li

[PATCH] D46022: [OpenCL] Restrict various keywords in OpenCL C++ mode

2018-04-25 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh updated this revision to Diff 143951.
svenvh edited the summary of this revision.
svenvh added a comment.

Implemented most of the restrictions as parser or Sema checks instead.  This 
results in nicer diagnostics too, thanks for the suggestion!

For the address space qualifiers such as global / __global / local / ..., I 
still think we should differentiate them in the lexer, as "global", "local" 
etc. are not reserved keywords in OpenCL C++.


https://reviews.llvm.org/D46022

Files:
  include/clang/Basic/DiagnosticCommonKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/TokenKinds.def
  include/clang/Sema/DeclSpec.h
  lib/Basic/IdentifierTable.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseStmtAsm.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaCast.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaStmt.cpp
  test/Parser/opencl-cl20.cl
  test/Parser/opencl-cxx-keywords.cl
  test/Parser/opencl-storage-class.cl
  test/SemaOpenCL/storageclass.cl
  test/SemaOpenCLCXX/restricted.cl

Index: test/SemaOpenCLCXX/restricted.cl
===
--- /dev/null
+++ test/SemaOpenCLCXX/restricted.cl
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -pedantic -verify -fsyntax-only
+
+// This test checks that various C/C++/OpenCL C constructs are not available in
+// OpenCL C++, according to OpenCL C++ 1.0 Specification Section 2.9.
+
+// Test that typeid is not available in OpenCL C++.
+namespace std {
+  // Provide a dummy std::type_info so that we can use typeid.
+  class type_info {
+int a;
+  };
+}
+__constant std::type_info int_ti = typeid(int);
+// expected-error@-1 {{'typeid' is not supported in OpenCL C++}}
+
+// Test that dynamic_cast is not available in OpenCL C++.
+class A {
+public:
+  int a;
+};
+
+class B : public A {
+  int b;
+};
+
+B *test_dynamic_cast(B *p) {
+  return dynamic_cast(p);
+  // expected-error@-1 {{'dynamic_cast' is not supported in OpenCL C++}}
+}
+
+// Test storage class qualifiers.
+kernel void test_storage_classes() {
+  register int x;
+  // expected-error@-1 {{OpenCL C++ version 1.0 does not support the 'register' storage class specifier}}
+  thread_local int y;
+  // expected-error@-1 {{OpenCL C++ version 1.0 does not support the 'thread_local' storage class specifier}}
+}
+
+// Test other keywords that are not available in OpenCL C++.
+kernel void test_misc() {
+  goto label;
+  // expected-error@-1 {{'goto' is not supported in OpenCL C++}}
+label:
+  asm("");
+  // expected-error@-1 {{'asm' is not supported in OpenCL C++}}
+  // expected-warning@-2 {{expression result unused}}
+}
Index: test/SemaOpenCL/storageclass.cl
===
--- test/SemaOpenCL/storageclass.cl
+++ test/SemaOpenCL/storageclass.cl
@@ -10,14 +10,14 @@
 static global float g_global_static_var = 0;   // expected-error {{program scope variable must reside in constant address space}}
 static local float g_local_static_var = 0; // expected-error {{program scope variable must reside in constant address space}}
 static private float g_private_static_var = 0; // expected-error {{program scope variable must reside in constant address space}}
-static generic float g_generic_static_var = 0; // expected-error{{OpenCL version 1.2 does not support the 'generic' type qualifier}} // expected-error {{program scope variable must reside in constant address space}}
+static generic float g_generic_static_var = 0; // expected-error{{OpenCL C version 1.2 does not support the 'generic' type qualifier}} // expected-error {{program scope variable must reside in constant address space}}
 
 extern float g_implicit_extern_var; // expected-error {{extern variable must reside in constant address space}}
 extern constant float g_constant_extern_var;
 extern global float g_global_extern_var;   // expected-error {{extern variable must reside in constant address space}}
 extern local float g_local_extern_var; // expected-error {{extern variable must reside in constant address space}}
 extern private float g_private_extern_var; // expected-error {{extern variable must reside in constant address space}}
-extern generic float g_generic_extern_var; // expected-error{{OpenCL version 1.2 does not support the 'generic' type qualifier}} // expected-error {{extern variable must reside in constant address space}}
+extern generic float g_generic_extern_var; // expected-error{{OpenCL C version 1.2 does not support the 'generic' type qualifier}} // expected-error {{extern variable must reside in constant address space}}
 
 void kernel foo(int x) {
   // static is not allowed at local scope before CL2.0
@@ -32,7 +32,7 @@
 constant int L1 = 42; // expected-error {{variables in the constant address space can only be declared in the outermost scope of a kernel function}}
   }
 
-  auto int L3 = 7;// expected-error{{OpenCL vers

[PATCH] D46066: [analyzer] Add checker for underflowing unsigned integers

2018-04-25 Thread Paul Fultz II via Phabricator via cfe-commits
pfultz2 added a comment.

> Isn't this case already covered by conversion checker?

I was unaware of this. This looks like it only works for binary operators. So 
`f(-1)` won't get caught.


Repository:
  rC Clang

https://reviews.llvm.org/D46066



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46019: [ASTImporter] Fix isa cast assert

2018-04-25 Thread Peter Szecsi via Phabricator via cfe-commits
szepet accepted this revision.
szepet added a comment.

Yepp, pretty straightforward check for something we were not aware previously 
(but unfortunately encountered it).


Repository:
  rC Clang

https://reviews.llvm.org/D46019



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r330842 - [Builtins] Fix typos in a comment. NFC

2018-04-25 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed Apr 25 09:57:46 2018
New Revision: 330842

URL: http://llvm.org/viewvc/llvm-project?rev=330842&view=rev
Log:
[Builtins] Fix typos in a comment. NFC

Modified:
cfe/trunk/include/clang/Basic/Builtins.h

Modified: cfe/trunk/include/clang/Basic/Builtins.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.h?rev=330842&r1=330841&r2=330842&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.h (original)
+++ cfe/trunk/include/clang/Basic/Builtins.h Wed Apr 25 09:57:46 2018
@@ -211,7 +211,7 @@ public:
 return ID >= (Builtin::FirstTSBuiltin + TSRecords.size());
   }
 
-  /// Return real buitin ID (i.e. ID it would have furing compilation
+  /// Return real builtin ID (i.e. ID it would have during compilation
   /// for AuxTarget).
   unsigned getAuxBuiltinID(unsigned ID) const { return ID - TSRecords.size(); }
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46015: [OpenCL] Add separate read_only and write_only pipe IR types

2018-04-25 Thread Stuart Brady via Phabricator via cfe-commits
stuart added a comment.

In https://reviews.llvm.org/D46015#1078260, @AlexeySotkin wrote:

> In https://reviews.llvm.org/D46015#1078235, @stuart wrote:
>
> > In https://reviews.llvm.org/D46015#1078217, @AlexeySotkin wrote:
> >
> > > There should not be need for bitcast. Could give an example ? Thanks.
> >
> >
> > If I have a `write_only` pipe as the argument to `get_pipe_max_packets()`, 
> > and this uses a single `__get_pipe_num_packets()` function taking a 
> > `read_only` pipe, we will automatically get a bitcast:
> >
> >   %20 = call i32 bitcast (i32 (%opencl.pipe_ro_t*, i32, i32)* 
> > @__get_pipe_max_packets to i32 (%opencl.pipe_wo_t*, i32, 
> > i32)*)(%opencl.pipe_wo_t* %19, i32 4, i32 4)
> >
>
>
> Sorry, but I don't quite understand what does  `get_pipe_max_packets()`, 
> **uses** `__get_pipe_num_packets()`  mean. Could you clarify? Possibly OpenCL 
> C source example could help.


I mean that without these two separate versions, the call to 
`__get_pipe_num_packets()` that is emitted can include a bitcast.

For example:

  void foo(read_only pipe int r, write_only pipe int w) {
get_pipe_num_packets(w);
get_pipe_num_packets(r);
  }

`get_pipe_num_packets(w)` is seen first, causing `i32 
@__get_pipe_num_packets(%opencl.pipe_wo_t*, i32, i32)` to be implicitly 
declared.

When the call to `__get_pipe_num_packets()` is emitted, this will be with an 
autogenerated bitcast from the type of the implicit declaration, i.e. `i32 
(%opencl.pipe_wo_t*, i32, i32)*` to the type in the emitted expression, i.e. 
`i32 (%opencl.pipe_ro_t*, i32, i32)*`.

Here is the relevant section of IR:

  %0 = load %opencl.pipe_wo_t*, %opencl.pipe_wo_t** %w.addr, align 8
  %1 = call i32 @__get_pipe_num_packets_ro(%opencl.pipe_wo_t* %0, i32 4, i32 4)
  %2 = load %opencl.pipe_ro_t*, %opencl.pipe_ro_t** %r.addr, align 8
  %3 = call i32 bitcast (i32 (%opencl.pipe_wo_t*, i32, i32)* 
@__get_pipe_num_packets_ro to i32 (%opencl.pipe_ro_t*, i32, 
i32)*)(%opencl.pipe_ro_t* %2, i32 4, i32 4)

If we swap the two calls to `__get_pipe_num_packets()` in the example above, 
then the type of the implicit declaration will be `i32 (%opencl.pipe_ro_t*, 
i32, i32)*` and bitcasts will instead be automatically generated when using 
`get_pipe_num_packets()` with a `write_only` pipe. It seems especially 
unfortunate that the type of the implicit declaration varies depending on the 
access qualifier of the first use.


https://reviews.llvm.org/D46015



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44387: [x86] Introduce the pconfig/encl[u|s|v] intrinsics

2018-04-25 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: lib/Headers/pconfigintrin.h:28
+
+#ifndef _PCONFIGINTRIN_H
+#define _PCONFIGINTRIN_H

I think all our other headers use double underscore here.



Comment at: lib/Headers/sgxintrin.h:28
+
+#ifndef _SGXINTRIN_H
+#define _SGXINTRIN_H

double underscore


https://reviews.llvm.org/D44387



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45722: [X86] Lowering SAD (sum of absolute differences) intrinsics to native IR (clang side)

2018-04-25 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D45722



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40937: [clang-tidy] Infinite loop checker

2018-04-25 Thread Peter Szecsi via Phabricator via cfe-commits
szepet updated this revision to Diff 143949.
szepet marked 2 inline comments as done.
szepet added a comment.

Changes made based on comments.
The CFG recreating problem is handled the following (only for this check):
Always store the last visited function and its CFG* (in form of the Sequence*) 
and check if we are visiting it again. If so, then the check reuses the 
previous one, if not, then replaces them. As far as I know the AST traverse 
done by the tidy fits this model (at least for this check, since it not uses 
narrowing matchers to other functions).
Sure, it would be better to find a general solution to this problem, and make 
the CFG reusable by every check which needs it, but I would left it for a 
follow-up (and a change like this probably would worth an own patch/review 
anyway).


https://reviews.llvm.org/D40937

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/InfiniteLoopCheck.cpp
  clang-tidy/bugprone/InfiniteLoopCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-infinite-loop.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/bugprone-infinite-loop.cpp

Index: test/clang-tidy/bugprone-infinite-loop.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-infinite-loop.cpp
@@ -0,0 +1,121 @@
+// RUN: %check_clang_tidy %s bugprone-infinite-loop %t
+
+void simple_infinite_loop1() {
+  int i = 0;
+  int j = 0;
+  while (i < 10) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the condition variable (i) is not updated in the loop body [bugprone-infinite-loop]
+j++;
+  }
+
+  do {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the condition variable (i) is not updated in the loop body
+j++;
+  } while (i < 10);
+
+  for (i = 0; i < 10; ++j) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the condition variable (i) is not updated in the loop body
+  }
+}
+
+void simple_infinite_loop2() {
+  int i = 0;
+  int j = 0;
+  int Limit = 10;
+  while (i < Limit) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: none of the condition variables (i, Limit) are updated in the loop body [bugprone-infinite-loop]
+j++;
+  }
+
+  do {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: none of the condition variables (i, Limit) are updated in the loop body
+j++;
+  } while (i < Limit);
+
+  for (i = 0; i < Limit; ++j) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: none of the condition variables (i, Limit) are updated in the loop body
+  }
+}
+
+void simple_not_infinite() {
+  int i = 0;
+  int Limit = 100;
+  while (i < Limit) { // Not an error since 'Limit' is updated
+Limit--;
+  }
+  do {
+Limit--;
+  } while (i < Limit);
+
+  for (i = 0; i < Limit; Limit--) {
+  }
+}
+
+void escape_before1() {
+  int i = 0;
+  int Limit = 100;
+  int *p = &i;
+  while (i < Limit) { // Not an error, since p is alias of i.
+*++p;
+  }
+
+  do {
+*++p;
+  } while (i < Limit);
+
+  for (i = 0; i < Limit; *++p) {
+;
+  }
+}
+
+void escape_before2() {
+  int i = 0;
+  int Limit = 100;
+  int *p = &i;
+  while (i < Limit) { // We do not warn since the var 'i' is escaped but it is
+  // an actual error, since the pointer 'p' is increased.
+*(p++);
+  }
+}
+
+void escape_after() {
+  int i = 0;
+  int j = 0;
+  int Limit = 10;
+
+  while (i < Limit) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: none of the condition variables (i, Limit) are updated in the loop body
+  }
+  int *p = &i;
+}
+
+int glob;
+void glob_var(int &x) {
+  int i = 0, Limit = 100;
+  while (x < Limit) { // Not an error since 'x' can be an alias of glob.
+glob++;
+  }
+}
+
+void glob_var2() {
+  int i = 0, Limit = 100;
+  while (glob < Limit) { // Since 'glob' is declared out of the function we do not warn.
+i++;
+  }
+}
+
+struct X {
+  void memberExpr_test(int i) {
+while (i < m) { // False negative: No warning, since skipping the case where
+// a memberExpr can be found in the condition.
+  ;
+}
+  }
+
+  void memberExpr_test2(int i) {
+while (i < m) {
+  --m;
+}
+  }
+  int m;
+};
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -28,6 +28,7 @@
bugprone-forwarding-reference-overload
bugprone-inaccurate-erase
bugprone-incorrect-roundings
+   bugprone-infinite-loop
bugprone-integer-division
bugprone-lambda-function-name
bugprone-macro-parentheses
Index: docs/clang-tidy/checks/bugprone-infinite-loop.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/bugprone-infinite-loop.rst
@@ -0,0 +1,30 @@
+.. title:: clang-tidy - bugprone-infinite-loop
+
+bugprone-infinite-loop
+==
+
+Finds loops where none of the condition variables are updated in the body. This
+performs a ver

r330839 - Make add_clang_unittest formatting a bit more consistent.

2018-04-25 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Apr 25 09:20:43 2018
New Revision: 330839

URL: http://llvm.org/viewvc/llvm-project?rev=330839&view=rev
Log:
Make add_clang_unittest formatting a bit more consistent.

Modified:
cfe/trunk/unittests/ASTMatchers/CMakeLists.txt
cfe/trunk/unittests/ASTMatchers/Dynamic/CMakeLists.txt

Modified: cfe/trunk/unittests/ASTMatchers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/CMakeLists.txt?rev=330839&r1=330838&r2=330839&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/CMakeLists.txt (original)
+++ cfe/trunk/unittests/ASTMatchers/CMakeLists.txt Wed Apr 25 09:20:43 2018
@@ -15,7 +15,8 @@ add_clang_unittest(ASTMatchersTests
   ASTMatchersInternalTest.cpp
   ASTMatchersNodeTest.cpp
   ASTMatchersNarrowingTest.cpp
-  ASTMatchersTraversalTest.cpp)
+  ASTMatchersTraversalTest.cpp
+  )
 
 target_link_libraries(ASTMatchersTests
   PRIVATE

Modified: cfe/trunk/unittests/ASTMatchers/Dynamic/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/Dynamic/CMakeLists.txt?rev=330839&r1=330838&r2=330839&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/Dynamic/CMakeLists.txt (original)
+++ cfe/trunk/unittests/ASTMatchers/Dynamic/CMakeLists.txt Wed Apr 25 09:20:43 
2018
@@ -5,7 +5,8 @@ set(LLVM_LINK_COMPONENTS
 add_clang_unittest(DynamicASTMatchersTests
   VariantValueTest.cpp
   ParserTest.cpp
-  RegistryTest.cpp)
+  RegistryTest.cpp
+  )
 
 target_link_libraries(DynamicASTMatchersTests
   PRIVATE


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r330838 - Disable the test I just added when testing C++03.

2018-04-25 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Apr 25 09:09:47 2018
New Revision: 330838

URL: http://llvm.org/viewvc/llvm-project?rev=330838&view=rev
Log:
Disable the test I just added when testing C++03.

Modified:
libcxx/trunk/test/libcxx/atomics/atomics.flag/init_bool.pass.cpp

Modified: libcxx/trunk/test/libcxx/atomics/atomics.flag/init_bool.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/atomics/atomics.flag/init_bool.pass.cpp?rev=330838&r1=330837&r2=330838&view=diff
==
--- libcxx/trunk/test/libcxx/atomics/atomics.flag/init_bool.pass.cpp (original)
+++ libcxx/trunk/test/libcxx/atomics/atomics.flag/init_bool.pass.cpp Wed Apr 25 
09:09:47 2018
@@ -18,15 +18,21 @@
 #include 
 #include 
 
- // Ensure that static initialization happens; this is PR#37226
+#include "test_macros.h"
+
+#if TEST_STD_VER >= 11
+// Ensure that static initialization happens; this is PR#37226
 extern std::atomic_flag global;
 struct X { X() { global.test_and_set(); }};
 X x;
 std::atomic_flag global = ATOMIC_FLAG_INIT;
+#endif
 
 int main()
 {
+#if TEST_STD_VER >= 11
 assert(global.test_and_set() == 1);
+#endif
 {
 std::atomic_flag f(false);
 assert(f.test_and_set() == 0);


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46015: [OpenCL] Add separate read_only and write_only pipe IR types

2018-04-25 Thread Alexey Sotkin via Phabricator via cfe-commits
AlexeySotkin added a comment.

In https://reviews.llvm.org/D46015#1078235, @stuart wrote:

> In https://reviews.llvm.org/D46015#1078217, @AlexeySotkin wrote:
>
> > There should not be need for bitcast. Could give an example ? Thanks.
>
>
> If I have a `write_only` pipe as the argument to `get_pipe_max_packets()`, 
> and this uses a single `__get_pipe_num_packets()` function taking a 
> `read_only` pipe, we will automatically get a bitcast:
>
>   %20 = call i32 bitcast (i32 (%opencl.pipe_ro_t*, i32, i32)* 
> @__get_pipe_max_packets to i32 (%opencl.pipe_wo_t*, i32, 
> i32)*)(%opencl.pipe_wo_t* %19, i32 4, i32 4)
>


Sorry, but I don't quite understand what does  `get_pipe_max_packets()`, 
**uses** `__get_pipe_num_packets()`  mean. Could you clarify? Possibly OpenCL C 
source example could help.
Thanks


https://reviews.llvm.org/D46015



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46066: [analyzer] Add checker for underflowing unsigned integers

2018-04-25 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

Isn't this case already covered by conversion checker? 
https://github.com/llvm-mirror/clang/blob/master/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp


Repository:
  rC Clang

https://reviews.llvm.org/D46066



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46015: [OpenCL] Add separate read_only and write_only pipe IR types

2018-04-25 Thread Stuart Brady via Phabricator via cfe-commits
stuart added a comment.

In https://reviews.llvm.org/D46015#1078217, @AlexeySotkin wrote:

> There should not be need for bitcast. Could give an example ? Thanks.


If I have a `write_only` pipe as the argument to `get_pipe_max_packets()`, and 
this uses a single `__get_pipe_num_packets()` function taking a `read_only` 
pipe, we will automatically get a bitcast:

  %20 = call i32 bitcast (i32 (%opencl.pipe_ro_t*, i32, i32)* 
@__get_pipe_max_packets to i32 (%opencl.pipe_wo_t*, i32, 
i32)*)(%opencl.pipe_wo_t* %19, i32 4, i32 4)


https://reviews.llvm.org/D46015



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46000: [AST] Added a helper to extract a user-friendly text of a comment.

2018-04-25 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: lib/AST/RawCommentList.cpp:380
+SourceMgr.getSpellingColumnNumber(Tok.getLocation(), &LocInvalid);
+if (LocInvalid)
+  TokColumn = 0;

ilya-biryukov wrote:
> ioeric wrote:
> > Explain when this would be invalid and why `TokColumn = 0` is used?
> I don't know whether this can be even be invalid, but I'm not confident 
> enough to add an assert there.
> `TokColumn = 0` seems like a reasonable way to recover if we can't compute 
> the column number, i.e. assume the line starts at the first column if 
> SourceLocation of the line was invalid for any reason.
> 
> This whole column thing looks weird to me, maybe I should just remove it 
> altogether and just remove the same amount of whitespace in all the lines. 
> WDYT?
On a second thought, now I remember why I added this in the first place.
To support the following example we want to take column numbers into account:

```
class Foo {
/* A block comment
   spanning multiple lines
   has too many spaces on the all lines except the first one.
*/
int func();
};
```


Repository:
  rC Clang

https://reviews.llvm.org/D46000



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46065: [clangd] Add "str()" method to SymbolID.

2018-04-25 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
hokein marked an inline comment as done.
Closed by commit rL330835: [clangd] Add "str()" method to SymbolID. 
(authored by hokein, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D46065

Files:
  
clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
  clang-tools-extra/trunk/clangd/index/Index.cpp
  clang-tools-extra/trunk/clangd/index/Index.h


Index: 
clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
===
--- 
clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
+++ 
clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
@@ -78,10 +78,7 @@
 
 auto Symbols = Collector->takeSymbols();
 for (const auto &Sym : Symbols) {
-  std::string IDStr;
-  llvm::raw_string_ostream OS(IDStr);
-  OS << Sym.ID;
-  Ctx->reportResult(OS.str(), SymbolToYAML(Sym));
+  Ctx->reportResult(Sym.ID.str(), SymbolToYAML(Sym));
 }
   }
 
Index: clang-tools-extra/trunk/clangd/index/Index.h
===
--- clang-tools-extra/trunk/clangd/index/Index.h
+++ clang-tools-extra/trunk/clangd/index/Index.h
@@ -69,6 +69,9 @@
 return HashValue < Sym.HashValue;
   }
 
+  // Returns a 40-bytes hex encoded string.
+  std::string str() const;
+
 private:
   static constexpr unsigned HashByteLength = 20;
 
Index: clang-tools-extra/trunk/clangd/index/Index.cpp
===
--- clang-tools-extra/trunk/clangd/index/Index.cpp
+++ clang-tools-extra/trunk/clangd/index/Index.cpp
@@ -31,6 +31,13 @@
   return OS;
 }
 
+std::string SymbolID::str() const {
+  std::string ID;
+  llvm::raw_string_ostream OS(ID);
+  OS << *this;
+  return OS.str();
+}
+
 void operator>>(StringRef Str, SymbolID &ID) {
   std::string HexString = fromHex(Str);
   assert(HexString.size() == ID.HashValue.size());


Index: clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
===
--- clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
+++ clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
@@ -78,10 +78,7 @@
 
 auto Symbols = Collector->takeSymbols();
 for (const auto &Sym : Symbols) {
-  std::string IDStr;
-  llvm::raw_string_ostream OS(IDStr);
-  OS << Sym.ID;
-  Ctx->reportResult(OS.str(), SymbolToYAML(Sym));
+  Ctx->reportResult(Sym.ID.str(), SymbolToYAML(Sym));
 }
   }
 
Index: clang-tools-extra/trunk/clangd/index/Index.h
===
--- clang-tools-extra/trunk/clangd/index/Index.h
+++ clang-tools-extra/trunk/clangd/index/Index.h
@@ -69,6 +69,9 @@
 return HashValue < Sym.HashValue;
   }
 
+  // Returns a 40-bytes hex encoded string.
+  std::string str() const;
+
 private:
   static constexpr unsigned HashByteLength = 20;
 
Index: clang-tools-extra/trunk/clangd/index/Index.cpp
===
--- clang-tools-extra/trunk/clangd/index/Index.cpp
+++ clang-tools-extra/trunk/clangd/index/Index.cpp
@@ -31,6 +31,13 @@
   return OS;
 }
 
+std::string SymbolID::str() const {
+  std::string ID;
+  llvm::raw_string_ostream OS(ID);
+  OS << *this;
+  return OS.str();
+}
+
 void operator>>(StringRef Str, SymbolID &ID) {
   std::string HexString = fromHex(Str);
   assert(HexString.size() == ID.HashValue.size());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46065: [clangd] Add "str()" method to SymbolID.

2018-04-25 Thread Haojian Wu via Phabricator via cfe-commits
hokein marked an inline comment as done.
hokein added inline comments.



Comment at: clangd/index/Index.h:72
 
+  // Returns a 40-bytes hex encoded string.
+  std::string str() const;

ioeric wrote:
> I think Sam wants to reduce the size to 20 bytes. Maybe just drop the 
> "40-bytes" part? 
The comment clarifies the current behavior of the method, I prefer to keep it. 
We can change it at the time when we reduce the size :)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46065



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r330835 - [clangd] Add "str()" method to SymbolID.

2018-04-25 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Wed Apr 25 08:27:09 2018
New Revision: 330835

URL: http://llvm.org/viewvc/llvm-project?rev=330835&view=rev
Log:
[clangd] Add "str()" method to SymbolID.

Summary:
This is a convenient function when we try to get std::string of
SymbolID.

Reviewers: ioeric

Subscribers: klimek, ilya-biryukov, MaskRay, jkorous, cfe-commits

Differential Revision: https://reviews.llvm.org/D46065

Modified:

clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
clang-tools-extra/trunk/clangd/index/Index.cpp
clang-tools-extra/trunk/clangd/index/Index.h

Modified: 
clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp?rev=330835&r1=330834&r2=330835&view=diff
==
--- 
clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
 (original)
+++ 
clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
 Wed Apr 25 08:27:09 2018
@@ -78,10 +78,7 @@ public:
 
 auto Symbols = Collector->takeSymbols();
 for (const auto &Sym : Symbols) {
-  std::string IDStr;
-  llvm::raw_string_ostream OS(IDStr);
-  OS << Sym.ID;
-  Ctx->reportResult(OS.str(), SymbolToYAML(Sym));
+  Ctx->reportResult(Sym.ID.str(), SymbolToYAML(Sym));
 }
   }
 

Modified: clang-tools-extra/trunk/clangd/index/Index.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.cpp?rev=330835&r1=330834&r2=330835&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Index.cpp Wed Apr 25 08:27:09 2018
@@ -31,6 +31,13 @@ raw_ostream &operator<<(raw_ostream &OS,
   return OS;
 }
 
+std::string SymbolID::str() const {
+  std::string ID;
+  llvm::raw_string_ostream OS(ID);
+  OS << *this;
+  return OS.str();
+}
+
 void operator>>(StringRef Str, SymbolID &ID) {
   std::string HexString = fromHex(Str);
   assert(HexString.size() == ID.HashValue.size());

Modified: clang-tools-extra/trunk/clangd/index/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.h?rev=330835&r1=330834&r2=330835&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.h (original)
+++ clang-tools-extra/trunk/clangd/index/Index.h Wed Apr 25 08:27:09 2018
@@ -69,6 +69,9 @@ public:
 return HashValue < Sym.HashValue;
   }
 
+  // Returns a 40-bytes hex encoded string.
+  std::string str() const;
+
 private:
   static constexpr unsigned HashByteLength = 20;
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46015: [OpenCL] Add separate read_only and write_only pipe IR types

2018-04-25 Thread Stuart Brady via Phabricator via cfe-commits
stuart added a comment.

In https://reviews.llvm.org/D46015#1077401, @AlexeySotkin wrote:

> It is not clear why we need two versions of get_pipe_num_packets and 
> get_pipe_max_packets builtins. There is only one instruction per builtin in 
> the SPIR-V spec. I think splitting the IR type is enough for translation to 
> SPIR-V purposes.


This is so that when we emit the builtin expression, we can call a function 
that matches the access qualifier of the argument to the builtin, without the 
need for a bitcast of either the builtin's argument or the 
__get_pipe_max/num_packets() function itself.




Comment at: lib/CodeGen/CGOpenCLRuntime.h:65
   virtual llvm::Type *getPipeType(const PipeType *T);
+  virtual llvm::Type *getPipeType(const PipeType *T, StringRef Name,
+  llvm::Type *&PipeTy);

AlexeySotkin wrote:
> I'm not sure that it is a good idea to make this function public, as its 
> parameter supposed to be a reference to protected member.
That's a good point. I have changed the function to be protected, to match the 
visibility of the data member.


https://reviews.llvm.org/D46015



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46015: [OpenCL] Add separate read_only and write_only pipe IR types

2018-04-25 Thread Alexey Sotkin via Phabricator via cfe-commits
AlexeySotkin added a comment.

There should not be need for bitcast. Could give an example ? Thanks.


https://reviews.llvm.org/D46015



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46066: [analyzer] Add checker for underflowing unsigned integers

2018-04-25 Thread Paul Fultz II via Phabricator via cfe-commits
pfultz2 created this revision.
pfultz2 added reviewers: NoQ, xazax.hun, dkrupp, whisperity, george.karpenkov.
pfultz2 added a project: clang.
Herald added subscribers: cfe-commits, a.sidorin, rnkovacs, szepet, mgorny.

This will check for when assigning a negative value to an unsigned integer, 
when it happens implicitly.


Repository:
  rC Clang

https://reviews.llvm.org/D46066

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/UnderflowChecker.cpp
  test/Analysis/underflow.cpp

Index: test/Analysis/underflow.cpp
===
--- /dev/null
+++ test/Analysis/underflow.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.core.Underflow -verify %s
+
+void foo(unsigned int i);
+
+void f1() {
+  unsigned int i = -1; // expected-warning {{Underflow unsigned integer}}
+  unsigned int j = 0;
+}
+
+void f2() {
+  foo(-1); // expected-warning {{Underflow unsigned integer}}
+  foo(0);
+}
+
+void f3() {
+  long x = -1;
+  int y = 0;
+  foo(x); // expected-warning {{Underflow unsigned integer}}
+  foo(y);
+}
Index: lib/StaticAnalyzer/Checkers/UnderflowChecker.cpp
===
--- /dev/null
+++ lib/StaticAnalyzer/Checkers/UnderflowChecker.cpp
@@ -0,0 +1,93 @@
+//== UnderflowCheck.cpp - Division by zero checker --*- C++ -*--==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This defines UnderflowCheck, a builtin check in ExprEngine that performs
+// checks for assigning negative values to unsigned integers
+//
+//===--===//
+
+#include "ClangSACheckers.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+class UnderflowCheck : public Checker> {
+  mutable std::unique_ptr BT;
+  void reportBug(const char *Msg, ProgramStateRef StateZero,
+ CheckerContext &C) const;
+
+public:
+  void checkPreStmt(const ImplicitCastExpr *CE, CheckerContext &C) const;
+};
+} // end anonymous namespace
+
+void UnderflowCheck::reportBug(const char *Msg, ProgramStateRef StateZero,
+   CheckerContext &C) const {
+  if (ExplodedNode *N = C.generateErrorNode(StateZero)) {
+if (!BT)
+  BT.reset(new BuiltinBug(this, "Underflow unsigned integer"));
+C.emitReport(llvm::make_unique(*BT, BT->getDescription(), N));
+  }
+}
+
+void UnderflowCheck::checkPreStmt(const ImplicitCastExpr *CE,
+  CheckerContext &C) const {
+
+  if (!CE->getType()->isUnsignedIntegerType() || CE->getType()->isBooleanType())
+return;
+
+  const Expr *E = CE->getSubExpr();
+  if (!E)
+return;
+  QualType valTy = E->getType();
+  if (valTy->isUnsignedIntegerType())
+return;
+  Optional DV = C.getSVal(E).getAs();
+
+  if (!DV)
+return;
+
+  // Check for negative
+  ProgramStateRef state = C.getState();
+  SValBuilder &svalBuilder = C.getSValBuilder();
+  ConstraintManager &CM = C.getConstraintManager();
+
+  // First, ensure that the value is >= 0.
+  DefinedSVal zeroVal = svalBuilder.makeIntVal(0, valTy);
+  SVal greaterThanOrEqualToZeroVal = svalBuilder.evalBinOp(
+  state, BO_GE, *DV, zeroVal, svalBuilder.getConditionType());
+
+  Optional greaterThanEqualToZero =
+  greaterThanOrEqualToZeroVal.getAs();
+
+  if (!greaterThanEqualToZero) {
+// The SValBuilder cannot construct a valid SVal for this condition.
+// This means we cannot properly reason about it.
+return;
+  }
+
+  ProgramStateRef stateLT, stateGE;
+  std::tie(stateGE, stateLT) = CM.assumeDual(state, *greaterThanEqualToZero);
+
+  // Is it possible for the value to be less than zero?
+  if (stateLT && !stateGE) {
+reportBug("Underflow unsigned integer", stateLT, C);
+// In either case, we are done.
+return;
+  }
+}
+
+void ento::registerUnderflowChecker(CheckerManager &mgr) {
+  mgr.registerChecker();
+}
Index: lib/StaticAnalyzer/Checkers/CMakeLists.txt
===
--- lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -91,6 +91,7 @@
   UndefResultChecker.cpp
   UndefinedArraySubscriptChecker.cpp
   UndefinedAssignmentChecker.cpp
+  UnderflowChecker.cpp
   UnixAPIChecker.cpp
   UnreachableCodeChecker.cpp
   VforkChecker.cpp
Index: include/clang/StaticAnalyzer/Checkers/Checkers.td
===

[PATCH] D46065: [clangd] Add "str()" method to SymbolID.

2018-04-25 Thread Eric Liu via Phabricator via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

lgtm with a nit




Comment at: clangd/index/Index.h:72
 
+  // Returns a 40-bytes hex encoded string.
+  std::string str() const;

I think Sam wants to reduce the size to 20 bytes. Maybe just drop the 
"40-bytes" part? 


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46065



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44932: [CodeComplete] Fix completion in the middle of ident in ctor lists.

2018-04-25 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC330833: [CodeComplete] Fix completion in the middle of ident 
in ctor lists. (authored by ibiryukov, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44932?vs=143935&id=143942#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44932

Files:
  lib/Lex/Lexer.cpp
  test/CodeCompletion/ctor-initializer.cpp
  test/CodeCompletion/end-of-file.cpp


Index: test/CodeCompletion/ctor-initializer.cpp
===
--- test/CodeCompletion/ctor-initializer.cpp
+++ test/CodeCompletion/ctor-initializer.cpp
@@ -58,5 +58,9 @@
   // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:57:9 %s 
-o - | FileCheck -check-prefix=CHECK-CC7 %s
   // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:57:9 %s 
-o - | FileCheck -check-prefix=CHECK-CC7 %s
   // CHECK-CC7: COMPLETION: Pattern : member1(<#args#>
+  // Check in the middle and at the end of identifier too.
+  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:57:13 %s 
-o - | FileCheck -check-prefix=CHECK-CC8 %s
+  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:57:16 %s 
-o - | FileCheck -check-prefix=CHECK-CC8 %s
+  // CHECK-CC8: COMPLETION: Pattern : member2(<#args#>
   int member1, member2;
 };
Index: test/CodeCompletion/end-of-file.cpp
===
--- test/CodeCompletion/end-of-file.cpp
+++ test/CodeCompletion/end-of-file.cpp
@@ -0,0 +1,7 @@
+// Check that clang does not crash when completing at the last char in the
+// buffer.
+// NOTE: This file must *NOT* have newline at the end.
+// RUN: %clang_cc1 -code-completion-at=%s:7:2 %s | FileCheck %s
+// CHECK: COMPLETION: foo
+using foo = int***;
+f
\ No newline at end of file
Index: lib/Lex/Lexer.cpp
===
--- lib/Lex/Lexer.cpp
+++ lib/Lex/Lexer.cpp
@@ -1654,7 +1654,21 @@
 if (isCodeCompletionPoint(CurPtr)) {
   // Return the code-completion token.
   Result.setKind(tok::code_completion);
-  cutOffLexing();
+  // Skip the code-completion char and all immediate identifier characters.
+  // This ensures we get consistent behavior when completing at any point 
in
+  // an identifier (i.e. at the start, in the middle, at the end). Note 
that
+  // only simple cases (i.e. [a-zA-Z0-9_]) are supported to keep the code
+  // simpler.
+  assert(*CurPtr == 0 && "Completion character must be 0");
+  ++CurPtr;
+  // Note that code completion token is not added as a separate character
+  // when the completion point is at the end of the buffer. Therefore, we 
need
+  // to check if the buffer has ended.
+  if (CurPtr < BufferEnd) {
+while (isIdentifierBody(*CurPtr))
+  ++CurPtr;
+  }
+  BufferPtr = CurPtr;
   return true;
 }
 


Index: test/CodeCompletion/ctor-initializer.cpp
===
--- test/CodeCompletion/ctor-initializer.cpp
+++ test/CodeCompletion/ctor-initializer.cpp
@@ -58,5 +58,9 @@
   // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:57:9 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s
   // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:57:9 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s
   // CHECK-CC7: COMPLETION: Pattern : member1(<#args#>
+  // Check in the middle and at the end of identifier too.
+  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:57:13 %s -o - | FileCheck -check-prefix=CHECK-CC8 %s
+  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:57:16 %s -o - | FileCheck -check-prefix=CHECK-CC8 %s
+  // CHECK-CC8: COMPLETION: Pattern : member2(<#args#>
   int member1, member2;
 };
Index: test/CodeCompletion/end-of-file.cpp
===
--- test/CodeCompletion/end-of-file.cpp
+++ test/CodeCompletion/end-of-file.cpp
@@ -0,0 +1,7 @@
+// Check that clang does not crash when completing at the last char in the
+// buffer.
+// NOTE: This file must *NOT* have newline at the end.
+// RUN: %clang_cc1 -code-completion-at=%s:7:2 %s | FileCheck %s
+// CHECK: COMPLETION: foo
+using foo = int***;
+f
\ No newline at end of file
Index: lib/Lex/Lexer.cpp
===
--- lib/Lex/Lexer.cpp
+++ lib/Lex/Lexer.cpp
@@ -1654,7 +1654,21 @@
 if (isCodeCompletionPoint(CurPtr)) {
   // Return the code-completion token.
   Result.setKind(tok::code_completion);
-  cutOffLexing();
+  // Skip the code-completion char and all immediate identifier characters.
+  // This ensures we get consistent behavior when completing at any point in
+  // an identifier (i.e. at the start, in the middle, at the end). Note that
+  // only simple cases (i.e. [a-zA-Z0

[PATCH] D44932: [CodeComplete] Fix completion in the middle of ident in ctor lists.

2018-04-25 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330833: [CodeComplete] Fix completion in the middle of ident 
in ctor lists. (authored by ibiryukov, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D44932

Files:
  cfe/trunk/lib/Lex/Lexer.cpp
  cfe/trunk/test/CodeCompletion/ctor-initializer.cpp
  cfe/trunk/test/CodeCompletion/end-of-file.cpp


Index: cfe/trunk/lib/Lex/Lexer.cpp
===
--- cfe/trunk/lib/Lex/Lexer.cpp
+++ cfe/trunk/lib/Lex/Lexer.cpp
@@ -1654,7 +1654,21 @@
 if (isCodeCompletionPoint(CurPtr)) {
   // Return the code-completion token.
   Result.setKind(tok::code_completion);
-  cutOffLexing();
+  // Skip the code-completion char and all immediate identifier characters.
+  // This ensures we get consistent behavior when completing at any point 
in
+  // an identifier (i.e. at the start, in the middle, at the end). Note 
that
+  // only simple cases (i.e. [a-zA-Z0-9_]) are supported to keep the code
+  // simpler.
+  assert(*CurPtr == 0 && "Completion character must be 0");
+  ++CurPtr;
+  // Note that code completion token is not added as a separate character
+  // when the completion point is at the end of the buffer. Therefore, we 
need
+  // to check if the buffer has ended.
+  if (CurPtr < BufferEnd) {
+while (isIdentifierBody(*CurPtr))
+  ++CurPtr;
+  }
+  BufferPtr = CurPtr;
   return true;
 }
 
Index: cfe/trunk/test/CodeCompletion/ctor-initializer.cpp
===
--- cfe/trunk/test/CodeCompletion/ctor-initializer.cpp
+++ cfe/trunk/test/CodeCompletion/ctor-initializer.cpp
@@ -58,5 +58,9 @@
   // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:57:9 %s 
-o - | FileCheck -check-prefix=CHECK-CC7 %s
   // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:57:9 %s 
-o - | FileCheck -check-prefix=CHECK-CC7 %s
   // CHECK-CC7: COMPLETION: Pattern : member1(<#args#>
+  // Check in the middle and at the end of identifier too.
+  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:57:13 %s 
-o - | FileCheck -check-prefix=CHECK-CC8 %s
+  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:57:16 %s 
-o - | FileCheck -check-prefix=CHECK-CC8 %s
+  // CHECK-CC8: COMPLETION: Pattern : member2(<#args#>
   int member1, member2;
 };
Index: cfe/trunk/test/CodeCompletion/end-of-file.cpp
===
--- cfe/trunk/test/CodeCompletion/end-of-file.cpp
+++ cfe/trunk/test/CodeCompletion/end-of-file.cpp
@@ -0,0 +1,7 @@
+// Check that clang does not crash when completing at the last char in the
+// buffer.
+// NOTE: This file must *NOT* have newline at the end.
+// RUN: %clang_cc1 -code-completion-at=%s:7:2 %s | FileCheck %s
+// CHECK: COMPLETION: foo
+using foo = int***;
+f
\ No newline at end of file


Index: cfe/trunk/lib/Lex/Lexer.cpp
===
--- cfe/trunk/lib/Lex/Lexer.cpp
+++ cfe/trunk/lib/Lex/Lexer.cpp
@@ -1654,7 +1654,21 @@
 if (isCodeCompletionPoint(CurPtr)) {
   // Return the code-completion token.
   Result.setKind(tok::code_completion);
-  cutOffLexing();
+  // Skip the code-completion char and all immediate identifier characters.
+  // This ensures we get consistent behavior when completing at any point in
+  // an identifier (i.e. at the start, in the middle, at the end). Note that
+  // only simple cases (i.e. [a-zA-Z0-9_]) are supported to keep the code
+  // simpler.
+  assert(*CurPtr == 0 && "Completion character must be 0");
+  ++CurPtr;
+  // Note that code completion token is not added as a separate character
+  // when the completion point is at the end of the buffer. Therefore, we need
+  // to check if the buffer has ended.
+  if (CurPtr < BufferEnd) {
+while (isIdentifierBody(*CurPtr))
+  ++CurPtr;
+  }
+  BufferPtr = CurPtr;
   return true;
 }
 
Index: cfe/trunk/test/CodeCompletion/ctor-initializer.cpp
===
--- cfe/trunk/test/CodeCompletion/ctor-initializer.cpp
+++ cfe/trunk/test/CodeCompletion/ctor-initializer.cpp
@@ -58,5 +58,9 @@
   // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:57:9 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s
   // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:57:9 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s
   // CHECK-CC7: COMPLETION: Pattern : member1(<#args#>
+  // Check in the middle and at the end of identifier too.
+  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:57:13 %s -o - | FileCheck -check-prefix=CHECK-CC8 %s
+  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-comple

r330833 - [CodeComplete] Fix completion in the middle of ident in ctor lists.

2018-04-25 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Apr 25 08:13:34 2018
New Revision: 330833

URL: http://llvm.org/viewvc/llvm-project?rev=330833&view=rev
Log:
[CodeComplete] Fix completion in the middle of ident in ctor lists.

Summary:
The example that was broken before (^ designates completion points):

class Foo {
  Foo() : fie^ld^() {} // no completions were provided here.
  int field;
};

To fix it we don't cut off lexing after an identifier followed by code
completion token is lexed. Instead we skip the rest of identifier and
continue lexing.
This is consistent with behavior of completion when completion token is
right before the identifier.

Reviewers: sammccall, aaron.ballman, bkramer, sepavloff, arphaman, rsmith

Reviewed By: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D44932

Added:
cfe/trunk/test/CodeCompletion/end-of-file.cpp
Modified:
cfe/trunk/lib/Lex/Lexer.cpp
cfe/trunk/test/CodeCompletion/ctor-initializer.cpp

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=330833&r1=330832&r2=330833&view=diff
==
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Wed Apr 25 08:13:34 2018
@@ -1654,7 +1654,21 @@ FinishIdentifier:
 if (isCodeCompletionPoint(CurPtr)) {
   // Return the code-completion token.
   Result.setKind(tok::code_completion);
-  cutOffLexing();
+  // Skip the code-completion char and all immediate identifier characters.
+  // This ensures we get consistent behavior when completing at any point 
in
+  // an identifier (i.e. at the start, in the middle, at the end). Note 
that
+  // only simple cases (i.e. [a-zA-Z0-9_]) are supported to keep the code
+  // simpler.
+  assert(*CurPtr == 0 && "Completion character must be 0");
+  ++CurPtr;
+  // Note that code completion token is not added as a separate character
+  // when the completion point is at the end of the buffer. Therefore, we 
need
+  // to check if the buffer has ended.
+  if (CurPtr < BufferEnd) {
+while (isIdentifierBody(*CurPtr))
+  ++CurPtr;
+  }
+  BufferPtr = CurPtr;
   return true;
 }
 

Modified: cfe/trunk/test/CodeCompletion/ctor-initializer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/ctor-initializer.cpp?rev=330833&r1=330832&r2=330833&view=diff
==
--- cfe/trunk/test/CodeCompletion/ctor-initializer.cpp (original)
+++ cfe/trunk/test/CodeCompletion/ctor-initializer.cpp Wed Apr 25 08:13:34 2018
@@ -58,5 +58,9 @@ struct B {
   // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:57:9 %s 
-o - | FileCheck -check-prefix=CHECK-CC7 %s
   // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:57:9 %s 
-o - | FileCheck -check-prefix=CHECK-CC7 %s
   // CHECK-CC7: COMPLETION: Pattern : member1(<#args#>
+  // Check in the middle and at the end of identifier too.
+  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:57:13 %s 
-o - | FileCheck -check-prefix=CHECK-CC8 %s
+  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:57:16 %s 
-o - | FileCheck -check-prefix=CHECK-CC8 %s
+  // CHECK-CC8: COMPLETION: Pattern : member2(<#args#>
   int member1, member2;
 };

Added: cfe/trunk/test/CodeCompletion/end-of-file.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/end-of-file.cpp?rev=330833&view=auto
==
--- cfe/trunk/test/CodeCompletion/end-of-file.cpp (added)
+++ cfe/trunk/test/CodeCompletion/end-of-file.cpp Wed Apr 25 08:13:34 2018
@@ -0,0 +1,7 @@
+// Check that clang does not crash when completing at the last char in the
+// buffer.
+// NOTE: This file must *NOT* have newline at the end.
+// RUN: %clang_cc1 -code-completion-at=%s:7:2 %s | FileCheck %s
+// CHECK: COMPLETION: foo
+using foo = int***;
+f
\ No newline at end of file


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46015: [OpenCL] Add separate read_only and write_only pipe IR types

2018-04-25 Thread Stuart Brady via Phabricator via cfe-commits
stuart updated this revision to Diff 143938.
stuart edited the summary of this revision.
stuart added a comment.

Changed new getPipeType() method to have protected visibility.

Updated summary to explain the need for the extra builtin implementation 
functions.


https://reviews.llvm.org/D46015

Files:
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/CGOpenCLRuntime.h
  test/CodeGenOpenCL/opencl_types.cl
  test/CodeGenOpenCL/pipe_builtin.cl
  test/CodeGenOpenCL/pipe_types.cl
  test/Index/pipe-size.cl

Index: test/Index/pipe-size.cl
===
--- test/Index/pipe-size.cl
+++ test/Index/pipe-size.cl
@@ -5,12 +5,12 @@
 __kernel void testPipe( pipe int test )
 {
 int s = sizeof(test);
-// X86: store %opencl.pipe_t* %test, %opencl.pipe_t** %test.addr, align 8
+// X86: store %opencl.pipe_ro_t* %test, %opencl.pipe_ro_t** %test.addr, align 8
 // X86: store i32 8, i32* %s, align 4
-// SPIR: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t addrspace(1)** %test.addr, align 4
+// SPIR: store %opencl.pipe_ro_t addrspace(1)* %test, %opencl.pipe_ro_t addrspace(1)** %test.addr, align 4
 // SPIR: store i32 4, i32* %s, align 4
-// SPIR64: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t addrspace(1)** %test.addr, align 8
+// SPIR64: store %opencl.pipe_ro_t addrspace(1)* %test, %opencl.pipe_ro_t addrspace(1)** %test.addr, align 8
 // SPIR64: store i32 8, i32* %s, align 4
-// AMDGCN: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t addrspace(1)* addrspace(5)* %test.addr, align 8
+// AMDGCN: store %opencl.pipe_ro_t addrspace(1)* %test, %opencl.pipe_ro_t addrspace(1)* addrspace(5)* %test.addr, align 8
 // AMDGCN: store i32 8, i32 addrspace(5)* %s, align 4
 }
Index: test/CodeGenOpenCL/pipe_types.cl
===
--- test/CodeGenOpenCL/pipe_types.cl
+++ test/CodeGenOpenCL/pipe_types.cl
@@ -1,34 +1,35 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
 
-// CHECK: %opencl.pipe_t = type opaque
+// CHECK: %opencl.pipe_ro_t = type opaque
+// CHECK: %opencl.pipe_wo_t = type opaque
 typedef unsigned char __attribute__((ext_vector_type(3))) uchar3;
 typedef int __attribute__((ext_vector_type(4))) int4;
 
 void test1(read_only pipe int p) {
-// CHECK: define void @test1(%opencl.pipe_t* %p)
+// CHECK: define void @test1(%opencl.pipe_ro_t* %p)
   reserve_id_t rid;
 // CHECK: %rid = alloca %opencl.reserve_id_t
 }
 
 void test2(write_only pipe float p) {
-// CHECK: define void @test2(%opencl.pipe_t* %p)
+// CHECK: define void @test2(%opencl.pipe_wo_t* %p)
 }
 
 void test3(read_only pipe const int p) {
-// CHECK: define void @test3(%opencl.pipe_t* %p)
+// CHECK: define void @test3(%opencl.pipe_ro_t* %p)
 }
 
 void test4(read_only pipe uchar3 p) {
-// CHECK: define void @test4(%opencl.pipe_t* %p)
+// CHECK: define void @test4(%opencl.pipe_ro_t* %p)
 }
 
 void test5(read_only pipe int4 p) {
-// CHECK: define void @test5(%opencl.pipe_t* %p)
+// CHECK: define void @test5(%opencl.pipe_ro_t* %p)
 }
 
 typedef read_only pipe int MyPipe;
 kernel void test6(MyPipe p) {
-// CHECK: define spir_kernel void @test6(%opencl.pipe_t* %p)
+// CHECK: define spir_kernel void @test6(%opencl.pipe_ro_t* %p)
 }
 
 struct Person {
@@ -41,7 +42,7 @@
  read_only pipe struct Person SPipe) {
 // CHECK: define void @test_reserved_read_pipe
   read_pipe (SPipe, SDst);
-  // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}, i32 16, i32 8)
+  // CHECK: call i32 @__read_pipe_2(%opencl.pipe_ro_t* %{{.*}}, i8* %{{.*}}, i32 16, i32 8)
   read_pipe (SPipe, SDst);
-  // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}, i32 16, i32 8)
+  // CHECK: call i32 @__read_pipe_2(%opencl.pipe_ro_t* %{{.*}}, i8* %{{.*}}, i32 16, i32 8)
 }
Index: test/CodeGenOpenCL/pipe_builtin.cl
===
--- test/CodeGenOpenCL/pipe_builtin.cl
+++ test/CodeGenOpenCL/pipe_builtin.cl
@@ -1,79 +1,93 @@
 // RUN: %clang_cc1 -emit-llvm -cl-ext=+cl_khr_subgroups -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
 
-// CHECK: %opencl.pipe_t = type opaque
-// CHECK: %opencl.reserve_id_t = type opaque
+// CHECK-DAG: %opencl.pipe_ro_t = type opaque
+// CHECK-DAG: %opencl.pipe_wo_t = type opaque
+// CHECK-DAG: %opencl.reserve_id_t = type opaque
 
 #pragma OPENCL EXTENSION cl_khr_subgroups : enable
 
 void test1(read_only pipe int p, global int *ptr) {
-  // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}, i32 4, i32 4)
+  // CHECK: call i32 @__read_pipe_2(%opencl.pipe_ro_t* %{{.*}}, i8* %{{.*}}, i32 4, i32 4)
   read_pipe(p, ptr);
-  // CHECK: call %opencl.reserve_id_t* @__reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4)
+  // CHECK: call %opencl.reserve_id_t* @__reserve_read_pipe(%opencl.pipe_ro_t* %

[PATCH] D46064: [llvm-objcopy] Add --localize-symbol option

2018-04-25 Thread Paul Semel via Phabricator via cfe-commits
paulsemel created this revision.
paulsemel added reviewers: jakehehrlich, echristo.
Herald added a subscriber: llvm-commits.

This option permit to localize a symbol by given its name.


Repository:
  rL LLVM

https://reviews.llvm.org/D46064

Files:
  test/tools/llvm-objcopy/localize.test
  tools/llvm-objcopy/Opts.td
  tools/llvm-objcopy/llvm-objcopy.cpp

Index: tools/llvm-objcopy/llvm-objcopy.cpp
===
--- tools/llvm-objcopy/llvm-objcopy.cpp
+++ tools/llvm-objcopy/llvm-objcopy.cpp
@@ -118,6 +118,7 @@
   std::vector Keep;
   std::vector OnlyKeep;
   std::vector AddSection;
+  std::vector LocalizeSymbol;
   bool StripAll;
   bool StripAllGNU;
   bool StripDebug;
@@ -196,6 +197,14 @@
 });
   }
 
+  if (!Config.LocalizeSymbol.empty()) {
+Obj.SymbolTable->localize([&Config](const Symbol &Sym) {
+  return std::find(std::begin(Config.LocalizeSymbol),
+   std::end(Config.LocalizeSymbol),
+   Sym.Name) != std::end(Config.LocalizeSymbol);
+});
+  }
+
   SectionPred RemovePred = [](const SectionBase &) { return false; };
 
   // Removes:
@@ -398,6 +407,8 @@
   Config.StripNonAlloc = InputArgs.hasArg(OBJCOPY_strip_non_alloc);
   Config.ExtractDWO = InputArgs.hasArg(OBJCOPY_extract_dwo);
   Config.LocalizeHidden = InputArgs.hasArg(OBJCOPY_localize_hidden);
+  for (auto Arg : InputArgs.filtered(OBJCOPY_localize_symbol))
+Config.LocalizeSymbol.push_back(Arg->getValue());
 
   return Config;
 }
Index: tools/llvm-objcopy/Opts.td
===
--- tools/llvm-objcopy/Opts.td
+++ tools/llvm-objcopy/Opts.td
@@ -56,3 +56,8 @@
   HelpText<"Remove all sections that are not DWARF .dwo sections from file">;
 def localize_hidden : Flag<["-", "--"], "localize-hidden">,
   HelpText<"Mark all symbols that have hidden or internal visibility as local">;
+defm localize_symbol : Eq<"localize-symbol">,
+ MetaVarName<"symbol">,
+ HelpText<"Localize ">;
+def L : JoinedOrSeparate<["-"], "L">,
+Alias;
Index: test/tools/llvm-objcopy/localize.test
===
--- /dev/null
+++ test/tools/llvm-objcopy/localize.test
@@ -0,0 +1,104 @@
+# RUN: yaml2obj %s > %t
+# RUN: llvm-objcopy --localize-symbol defaultGlobal  %t %t2
+# RUN: llvm-readobj -symbols %t2 | FileCheck %s
+
+!ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_REL
+  Machine: EM_X86_64
+Sections:
+  - Name:.text
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
+Address: 0x1000
+AddressAlign:0x0010
+Size:64
+  - Name:.data
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC ]
+Address: 0x2000
+AddressAlign:0x0010
+Content: ""
+Symbols:
+  Local:
+- Name: hiddenLocal
+  Type: STT_FUNC
+  Section:  .text
+  Value:0x1008
+  Size: 8
+  Visibility: STV_HIDDEN
+  Weak:
+- Name: hiddenWeak
+  Type: STT_FUNC
+  Section:  .text
+  Value:0x1010
+  Size: 8
+  Visibility: STV_HIDDEN
+  Global:
+- Name: defaultGlobal
+  Type: STT_FUNC
+  Size: 8
+  Section:  .text
+  Value:0x1000
+- Name: hiddenGlobal
+  Type: STT_OBJECT
+  Section:  .data
+  Value:0x2006
+  Size: 2
+  Visibility: STV_HIDDEN
+
+#CHECK: Symbols [
+#CHECK-NEXT:  Symbol {
+#CHECK-NEXT:Name:
+#CHECK-NEXT:Value: 0x0
+#CHECK-NEXT:Size: 0
+#CHECK-NEXT:Binding: Local
+#CHECK-NEXT:Type: None
+#CHECK-NEXT:Other: 0
+#CHECK-NEXT:Section: Undefined
+#CHECK-NEXT:  }
+#CHECK-NEXT:  Symbol {
+#CHECK-NEXT:Name: hiddenLocal
+#CHECK-NEXT:Value: 0x1008
+#CHECK-NEXT:Size: 8
+#CHECK-NEXT:Binding: Local
+#CHECK-NEXT:Type: Function
+#CHECK-NEXT:Other [
+#CHECK-NEXT:  STV_HIDDEN
+#CHECK-NEXT:]
+#CHECK-NEXT:Section: .text
+#CHECK-NEXT:  }
+#CHECK-NEXT:  Symbol {
+#CHECK-NEXT:Name: defaultGlobal
+#CHECK-NEXT:Value: 0x1000
+#CHECK-NEXT:Size: 8
+#CHECK-NEXT:Binding: Local
+#CHECK-NEXT:Type: Function
+#CHECK-NEXT:Other: 0
+#CHECK-NEXT:Section: .text
+#CHECK-NEXT:  }
+#CHECK-NEXT:  Symbol {
+#CHECK-NEXT:Name: hiddenGlobal
+#CHECK-NEXT:Value: 0x2006
+#CHECK-NEXT:Size: 2
+#CHECK-NEXT:Binding: Global
+#CHECK-NEXT:Type: Object
+#CHECK-NEXT:Other [
+#CHECK-NEXT:  STV_HIDDEN
+#CHECK-NEXT:]
+#CHECK-NEXT:Section: .data
+#CHECK-NEXT:  }
+#CHECK-NEXT:  Symbol {
+#CHECK-NEXT:Name: hiddenWeak
+#CHECK-NEXT:Value: 0x1010
+#CHECK-NEXT:Size: 8
+#CHECK-NEXT:Binding: Weak
+#CHECK-NEXT:Type: Function
+#CHECK-NEXT:Other [
+#CHECK-NEXT:

[PATCH] D46065: [clangd] Add "str()" method to SymbolID.

2018-04-25 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: ioeric.
Herald added subscribers: jkorous, MaskRay, ilya-biryukov, klimek.

This is a convenient function when we try to get std::string of
SymbolID.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46065

Files:
  clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
  clangd/index/Index.cpp
  clangd/index/Index.h


Index: clangd/index/Index.h
===
--- clangd/index/Index.h
+++ clangd/index/Index.h
@@ -69,6 +69,9 @@
 return HashValue < Sym.HashValue;
   }
 
+  // Returns a 40-bytes hex encoded string.
+  std::string str() const;
+
 private:
   static constexpr unsigned HashByteLength = 20;
 
Index: clangd/index/Index.cpp
===
--- clangd/index/Index.cpp
+++ clangd/index/Index.cpp
@@ -31,6 +31,13 @@
   return OS;
 }
 
+std::string SymbolID::str() const {
+  std::string ID;
+  llvm::raw_string_ostream OS(ID);
+  OS << *this;
+  return OS.str();
+}
+
 void operator>>(StringRef Str, SymbolID &ID) {
   std::string HexString = fromHex(Str);
   assert(HexString.size() == ID.HashValue.size());
Index: clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
===
--- clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
+++ clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
@@ -78,10 +78,7 @@
 
 auto Symbols = Collector->takeSymbols();
 for (const auto &Sym : Symbols) {
-  std::string IDStr;
-  llvm::raw_string_ostream OS(IDStr);
-  OS << Sym.ID;
-  Ctx->reportResult(OS.str(), SymbolToYAML(Sym));
+  Ctx->reportResult(Sym.ID.str(), SymbolToYAML(Sym));
 }
   }
 


Index: clangd/index/Index.h
===
--- clangd/index/Index.h
+++ clangd/index/Index.h
@@ -69,6 +69,9 @@
 return HashValue < Sym.HashValue;
   }
 
+  // Returns a 40-bytes hex encoded string.
+  std::string str() const;
+
 private:
   static constexpr unsigned HashByteLength = 20;
 
Index: clangd/index/Index.cpp
===
--- clangd/index/Index.cpp
+++ clangd/index/Index.cpp
@@ -31,6 +31,13 @@
   return OS;
 }
 
+std::string SymbolID::str() const {
+  std::string ID;
+  llvm::raw_string_ostream OS(ID);
+  OS << *this;
+  return OS.str();
+}
+
 void operator>>(StringRef Str, SymbolID &ID) {
   std::string HexString = fromHex(Str);
   assert(HexString.size() == ID.HashValue.size());
Index: clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
===
--- clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
+++ clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
@@ -78,10 +78,7 @@
 
 auto Symbols = Collector->takeSymbols();
 for (const auto &Sym : Symbols) {
-  std::string IDStr;
-  llvm::raw_string_ostream OS(IDStr);
-  OS << Sym.ID;
-  Ctx->reportResult(OS.str(), SymbolToYAML(Sym));
+  Ctx->reportResult(Sym.ID.str(), SymbolToYAML(Sym));
 }
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44932: [CodeComplete] Fix completion in the middle of ident in ctor lists.

2018-04-25 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 143935.
ilya-biryukov marked an inline comment as done.
ilya-biryukov added a comment.

- Fix the comment


Repository:
  rC Clang

https://reviews.llvm.org/D44932

Files:
  lib/Lex/Lexer.cpp
  test/CodeCompletion/ctor-initializer.cpp
  test/CodeCompletion/end-of-file.cpp


Index: test/CodeCompletion/end-of-file.cpp
===
--- /dev/null
+++ test/CodeCompletion/end-of-file.cpp
@@ -0,0 +1,7 @@
+// Check that clang does not crash when completing at the last char in the
+// buffer.
+// NOTE: This file must *NOT* have newline at the end.
+// RUN: %clang_cc1 -code-completion-at=%s:7:2 %s | FileCheck %s
+// CHECK: COMPLETION: foo
+using foo = int***;
+f
\ No newline at end of file
Index: test/CodeCompletion/ctor-initializer.cpp
===
--- test/CodeCompletion/ctor-initializer.cpp
+++ test/CodeCompletion/ctor-initializer.cpp
@@ -58,5 +58,9 @@
   // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:57:9 %s 
-o - | FileCheck -check-prefix=CHECK-CC7 %s
   // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:57:9 %s 
-o - | FileCheck -check-prefix=CHECK-CC7 %s
   // CHECK-CC7: COMPLETION: Pattern : member1(<#args#>
+  // Check in the middle and at the end of identifier too.
+  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:57:13 %s 
-o - | FileCheck -check-prefix=CHECK-CC8 %s
+  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:57:16 %s 
-o - | FileCheck -check-prefix=CHECK-CC8 %s
+  // CHECK-CC8: COMPLETION: Pattern : member2(<#args#>
   int member1, member2;
 };
Index: lib/Lex/Lexer.cpp
===
--- lib/Lex/Lexer.cpp
+++ lib/Lex/Lexer.cpp
@@ -1654,7 +1654,21 @@
 if (isCodeCompletionPoint(CurPtr)) {
   // Return the code-completion token.
   Result.setKind(tok::code_completion);
-  cutOffLexing();
+  // Skip the code-completion char and all immediate identifier characters.
+  // This ensures we get consistent behavior when completing at any point 
in
+  // an identifier (i.e. at the start, in the middle, at the end). Note 
that
+  // only simple cases (i.e. [a-zA-Z0-9_]) are supported to keep the code
+  // simpler.
+  assert(*CurPtr == 0 && "Completion character must be 0");
+  ++CurPtr;
+  // Note that code completion token is not added as a separate character
+  // when the completion point is at the end of the buffer. Therefore, we 
need
+  // to check if the buffer has ended.
+  if (CurPtr < BufferEnd) {
+while (isIdentifierBody(*CurPtr))
+  ++CurPtr;
+  }
+  BufferPtr = CurPtr;
   return true;
 }
 


Index: test/CodeCompletion/end-of-file.cpp
===
--- /dev/null
+++ test/CodeCompletion/end-of-file.cpp
@@ -0,0 +1,7 @@
+// Check that clang does not crash when completing at the last char in the
+// buffer.
+// NOTE: This file must *NOT* have newline at the end.
+// RUN: %clang_cc1 -code-completion-at=%s:7:2 %s | FileCheck %s
+// CHECK: COMPLETION: foo
+using foo = int***;
+f
\ No newline at end of file
Index: test/CodeCompletion/ctor-initializer.cpp
===
--- test/CodeCompletion/ctor-initializer.cpp
+++ test/CodeCompletion/ctor-initializer.cpp
@@ -58,5 +58,9 @@
   // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:57:9 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s
   // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:57:9 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s
   // CHECK-CC7: COMPLETION: Pattern : member1(<#args#>
+  // Check in the middle and at the end of identifier too.
+  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:57:13 %s -o - | FileCheck -check-prefix=CHECK-CC8 %s
+  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:57:16 %s -o - | FileCheck -check-prefix=CHECK-CC8 %s
+  // CHECK-CC8: COMPLETION: Pattern : member2(<#args#>
   int member1, member2;
 };
Index: lib/Lex/Lexer.cpp
===
--- lib/Lex/Lexer.cpp
+++ lib/Lex/Lexer.cpp
@@ -1654,7 +1654,21 @@
 if (isCodeCompletionPoint(CurPtr)) {
   // Return the code-completion token.
   Result.setKind(tok::code_completion);
-  cutOffLexing();
+  // Skip the code-completion char and all immediate identifier characters.
+  // This ensures we get consistent behavior when completing at any point in
+  // an identifier (i.e. at the start, in the middle, at the end). Note that
+  // only simple cases (i.e. [a-zA-Z0-9_]) are supported to keep the code
+  // simpler.
+  assert(*CurPtr == 0 && "Completion character must be 0");
+  ++CurPtr;
+  // Note that code completion token is not added a

[PATCH] D46050: [Frontend] Avoid running plugins during code completion parse

2018-04-25 Thread John Brawn via Phabricator via cfe-commits
john.brawn added a comment.

I know very little about how code completion works, but it's not immediately 
obvious to me that disabling plugin ast consumers when code completion is 
enabled is necessarily correct. In what kind of scenario would we both have a 
plugin loaded that wants to insert an ast consumer before/after the main one, 
and also be doing code completion?


Repository:
  rC Clang

https://reviews.llvm.org/D46050



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >