Re: [PATCH] D44883: [Sema] Extend -Wself-assign and -Wself-assign-field to warn on overloaded self-assignment (classes)

2018-04-13 Thread John McCall via cfe-commits
(Sorry for the delay in responding — I'm actually on vacation.)

On Tue, Apr 10, 2018 at 1:52 PM, David Blaikie  wrote:

> On Tue, Apr 10, 2018 at 10:20 AM John McCall  wrote:
>
>> Do you think they’re bad precedent?
>
>
> Somewhat, yes - though -Wparens is perhaps conflating a few cases too. I
> think the argument for the -Wparens for precedence is probably pretty good.
>

True.  I agree that -Wparentheses is really at least three and probably
four separate warnings, all bundled into one flag.  I was really only
thinking about the = for == warning, which is an important warning that
ends up being highly opinionated about how you write your code.

Do you have a replacement for that approach to warning about those
>> problems?
>
>
> If we were looking at a green field today (code that'd never seen the
> warning before), I don't think -Wparens for assignment in conditional would
> pass the bar (or at least the bar as Clang seemed to have 6-7 years ago
> when I would talk to Doug about warning ideas, as best as I understood the
> perspective being espoused back then). I suspect maybe in that world we
> would've found other warnings with lower-false-positive that might've been
> able to diagnose assignment-in-conditional a bit more precisely than "all
> assignments are so suspect you have to manually go and look at them to
> decide".
>

I think you might be misunderstanding -Wparentheses as primarily a warning
about confusing precedence rather than primarily a warning about
accidentally substituting = for ==.  This of course interacts with
precedence for the conditional operator because the assignment is no longer
parsed within the condition.   Admittedly, GCC's documentation doesn't
explain this well.


> Because they certainly were precedent for -Wfallthrough, and they
>> certainly catch a class of bugs at least as large and important as that
>> warning, and they certainly have exactly the same false-positive
>> characteristics as it does. I am really struggling to see a difference in
>> kind or even degree here.
>>
>> -Wself-assign is a much less important warning but it’s also far less
>> likely to see false positives, except in this pattern of unit tests for
>> data structures, which are not commonly-written code. As is, in fact,
>> evidenced by Google, a company full of programmers whom I think I can
>> fairly but affectionately describe as loving to reinvent data structures,
>> only seeing this warning eight times.
>>
>
> I think the 8 cases were in Chromium - at Google so far (& I'm not sure if
> that's across all of Google's codebase, or some subset) something in the
> 100-200 cases?
>

I see.  8 did seem rather low for all of Google.  And all 100-200 are false
positives?  Or have only the Chromium cases been investigated yet?

Nico's point that, so far, the only evidence we have is that this warning
> added false positives and didn't catch any real world bugs. Yeah, a small
> number/easy enough to cleanup, but all we have is the cost and no idea of
> the value. (usually when we roll out warnings - even the -Wparens and
> -Wfallthrough, we find checked in code that has those problems (& the false
> positive cases) & so we evaluate cost/benefit with that data)
>

I understand.

I still believe strongly that we should be warning here, but I'm certainly
open to allowing it to be disabled.  We did actually talk about this during
the review.  There are three general options here, not necessary exclusive:
1. We move it to a separate warning group.  I would argue that (a) this
should at least be a sub-group so that -Wself-assign turns it on by
default, and that (b) trivial self-assignments should still be triggered
under -Wself-assign, for C/C++ consistency if nothing else.
2. We find some way to turn it off by recognizing something about the code
that suggests that we're in test code.
3. We add a general -wtest (capitalization intentional) that says "this is
test code, please don't warn about code patterns that would be unusual in
normal code but might make sense in tests".  I'm positive I've seen other
examples of that, e.g. for some of our warnings around misuse of library
functions.  Many build systems make it fairly early to use different build
settings when building tests — IIRC that's true of Bazel.

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


[PATCH] D44888: [RISCV] Default enable linker relaxation and add -mrelax, -mno-relax flags

2018-04-13 Thread Shiva Chen via Phabricator via cfe-commits
shiva0217 updated this revision to Diff 142338.
shiva0217 added a comment.

Add help text for -mrelax, -mno-relax flags as Alex's comments.


Repository:
  rL LLVM

https://reviews.llvm.org/D44888

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Arch/RISCV.cpp
  test/Driver/riscv-features.c


Index: test/Driver/riscv-features.c
===
--- test/Driver/riscv-features.c
+++ test/Driver/riscv-features.c
@@ -2,3 +2,10 @@
 // RUN: %clang -target riscv64-unknown-elf -### %s -fsyntax-only 2>&1 | 
FileCheck %s
 
 // CHECK: fno-signed-char
+
+
+// RUN: %clang -target riscv32-unknown-elf -### %s -mrelax 2>&1 | FileCheck %s 
-check-prefix=RELAX
+// RUN: %clang -target riscv32-unknown-elf -### %s -mno-relax 2>&1 | FileCheck 
%s -check-prefix=NO-RELAX
+
+// RELAX: "-target-feature" "+relax"
+// NO-RELAX: "-target-feature" "-relax"
Index: lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- lib/Driver/ToolChains/Arch/RISCV.cpp
+++ lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -14,6 +14,7 @@
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/TargetParser.h"
 #include "llvm/Support/raw_ostream.h"
+#include "ToolChains/CommonArgs.h"
 
 using namespace clang::driver;
 using namespace clang::driver::tools;
@@ -112,6 +113,21 @@
 if (HasD && !HasF)
   D.Diag(diag::err_drv_invalid_arch_name) << MArch;
   }
+
+  // -mrelax is default, unless -mno-relax is specified.
+  bool Relax = true;
+  if (auto *A = Args.getLastArg(options::OPT_mrelax, options::OPT_mno_relax))
+if (A->getOption().matches(options::OPT_mno_relax)) {
+  Relax = false;
+  Features.push_back("-relax");
+}
+
+  if (Relax)
+Features.push_back("+relax");
+
+  // Now add any that the user explicitly requested on the command line,
+  // which may override the defaults.
+  handleTargetFeaturesGroup(Args, Features, 
options::OPT_m_riscv_Features_Group);
 }
 
 StringRef riscv::getRISCVABI(const ArgList &Args, const llvm::Triple &Triple) {
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -150,6 +150,9 @@
 def m_x86_Features_Group : OptionGroup<"">,
Group, Flags<[CoreOption]>, DocName<"X86">;
 
+def m_riscv_Features_Group : OptionGroup<"">,
+ Group, DocName<"RISCV">;
+
 def m_libc_Group : OptionGroup<"">, Group,
Flags<[HelpHidden]>;
 
@@ -1880,6 +1883,11 @@
 def meabi : Separate<["-"], "meabi">, Group, Flags<[CC1Option]>,
   HelpText<"Set EABI type, e.g. 4, 5 or gnu (default depends on triple)">, 
Values<"default,4,5,gnu">;
 
+def mrelax : Flag<["-"], "mrelax">, Group,
+  HelpText<"Enable linker relaxation">;
+def mno_relax : Flag<["-"], "mno-relax">, Group,
+  HelpText<"Disable linker relaxation">;
+
 def mno_constant_cfstrings : Flag<["-"], "mno-constant-cfstrings">, 
Group;
 def mno_global_merge : Flag<["-"], "mno-global-merge">, Group, 
Flags<[CC1Option]>,
   HelpText<"Disable merging of globals">;


Index: test/Driver/riscv-features.c
===
--- test/Driver/riscv-features.c
+++ test/Driver/riscv-features.c
@@ -2,3 +2,10 @@
 // RUN: %clang -target riscv64-unknown-elf -### %s -fsyntax-only 2>&1 | FileCheck %s
 
 // CHECK: fno-signed-char
+
+
+// RUN: %clang -target riscv32-unknown-elf -### %s -mrelax 2>&1 | FileCheck %s -check-prefix=RELAX
+// RUN: %clang -target riscv32-unknown-elf -### %s -mno-relax 2>&1 | FileCheck %s -check-prefix=NO-RELAX
+
+// RELAX: "-target-feature" "+relax"
+// NO-RELAX: "-target-feature" "-relax"
Index: lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- lib/Driver/ToolChains/Arch/RISCV.cpp
+++ lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -14,6 +14,7 @@
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/TargetParser.h"
 #include "llvm/Support/raw_ostream.h"
+#include "ToolChains/CommonArgs.h"
 
 using namespace clang::driver;
 using namespace clang::driver::tools;
@@ -112,6 +113,21 @@
 if (HasD && !HasF)
   D.Diag(diag::err_drv_invalid_arch_name) << MArch;
   }
+
+  // -mrelax is default, unless -mno-relax is specified.
+  bool Relax = true;
+  if (auto *A = Args.getLastArg(options::OPT_mrelax, options::OPT_mno_relax))
+if (A->getOption().matches(options::OPT_mno_relax)) {
+  Relax = false;
+  Features.push_back("-relax");
+}
+
+  if (Relax)
+Features.push_back("+relax");
+
+  // Now add any that the user explicitly requested on the command line,
+  // which may override the defaults.
+  handleTargetFeaturesGroup(Args, Features, options::OPT_m_riscv_Features_Group);
 }
 
 StringRef riscv::getRISCVABI(const ArgList &Args, const llvm::Triple &Triple) {
Index: include/clang/Driver/Options.td
=

[PATCH] D44984: [HIP] Add hip file type and codegen for kernel launching

2018-04-13 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGCUDANV.cpp:98
+std::string CGNVCUDARuntime::addPrefixToName(CodeGenModule &CGM,
+ std::string FuncName) const {
+  if (CGM.getLangOpts().HIP)

Can you take these as StringRefs or Twines?





Comment at: lib/CodeGen/CGCUDANV.cpp:104
+std::string CGNVCUDARuntime::addPrefixToNameBar(CodeGenModule &CGM,
+std::string FuncName) const {
+  if (CGM.getLangOpts().HIP)

I think "addUnderscoredPrefixToName" would be better.



Comment at: lib/CodeGen/CGCUDANV.cpp:134
 llvm::Constant *CGNVCUDARuntime::getLaunchFn() const {
   // cudaError_t cudaLaunch(char *)
+  if (CGM.getLangOpts().HIP)

Please move this comment down into the else clause (and terminate it with a 
semicolon) and add your own declaration comment in your clause.



Comment at: lib/Frontend/CompilerInvocation.cpp:2109
+  Opts.HIP = true;
+  }
+

Why is this done here?  We infer the language mode from the input kind 
somewhere else.


https://reviews.llvm.org/D44984



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


[PATCH] D45257: [X86] Introduce cldemote intrinsic

2018-04-13 Thread Gabor Buella via Phabricator via cfe-commits
GBuella updated this revision to Diff 142340.
GBuella added a comment.

Rebase.


https://reviews.llvm.org/D45257

Files:
  include/clang/Basic/BuiltinsX86.def
  include/clang/Driver/Options.td
  lib/Basic/Targets/X86.cpp
  lib/Basic/Targets/X86.h
  lib/Headers/CMakeLists.txt
  lib/Headers/cldemoteintrin.h
  lib/Headers/cpuid.h
  lib/Headers/x86intrin.h
  test/CodeGen/builtins-x86.c
  test/CodeGen/cldemote.c

Index: test/CodeGen/cldemote.c
===
--- /dev/null
+++ test/CodeGen/cldemote.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -ffreestanding -triple=x86_64-unknown-unknown -target-feature +cldemote -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 %s -ffreestanding -triple=i386-unknown-unknown -target-feature +cldemote -emit-llvm -o - -Wall -Werror | FileCheck %s
+
+#include 
+
+void test_cldemote(const void *p) {
+  //CHECK-LABEL: @test_cldemote
+  //CHECK: call void @llvm.x86.cldemote(i8* %{{.*}})
+  _cldemote(p);
+}
Index: test/CodeGen/builtins-x86.c
===
--- test/CodeGen/builtins-x86.c
+++ test/CodeGen/builtins-x86.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -DUSE_64 -triple x86_64-unknown-unknown -target-feature +fxsr -target-feature +avx -target-feature +xsaveopt -target-feature +xsaves -target-feature +xsavec -target-feature +mwaitx -target-feature +clzero -target-feature +ibt -target-feature +shstk -target-feature +wbnoinvd -emit-llvm -o %t %s
-// RUN: %clang_cc1 -DUSE_ALL -triple x86_64-unknown-unknown -target-feature +fxsr -target-feature +avx -target-feature +xsaveopt -target-feature +xsaves -target-feature +xsavec -target-feature +mwaitx -target-feature +ibt -target-feature +shstk -target-feature +clzero -target-feature +wbnoinvd -fsyntax-only -o %t %s
+// RUN: %clang_cc1 -DUSE_64 -triple x86_64-unknown-unknown -target-feature +fxsr -target-feature +avx -target-feature +xsaveopt -target-feature +xsaves -target-feature +xsavec -target-feature +mwaitx -target-feature +clzero -target-feature +ibt -target-feature +shstk -target-feature +wbnoinvd -target-feature +cldemote -emit-llvm -o %t %s
+// RUN: %clang_cc1 -DUSE_ALL -triple x86_64-unknown-unknown -target-feature +fxsr -target-feature +avx -target-feature +xsaveopt -target-feature +xsaves -target-feature +xsavec -target-feature +mwaitx -target-feature +ibt -target-feature +shstk -target-feature +clzero -target-feature +wbnoinvd -target-feature +cldemote -fsyntax-only -o %t %s
 
 #ifdef USE_ALL
 #define USE_3DNOW
@@ -295,6 +295,7 @@
   (void) __builtin_ia32_monitorx(tmp_vp, tmp_Ui, tmp_Ui);
   (void) __builtin_ia32_mwaitx(tmp_Ui, tmp_Ui, tmp_Ui);
   (void) __builtin_ia32_clzero(tmp_vp);
+  (void) __builtin_ia32_cldemote(tmp_vp);
 
   tmp_V4f = __builtin_ia32_cvtpi2ps(tmp_V4f, tmp_V2i);
   tmp_V2i = __builtin_ia32_cvtps2pi(tmp_V4f);
Index: lib/Headers/x86intrin.h
===
--- lib/Headers/x86intrin.h
+++ lib/Headers/x86intrin.h
@@ -92,4 +92,8 @@
 #include 
 #endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__CLDEMOTE__)
+#include 
+#endif
+
 #endif /* __X86INTRIN_H */
Index: lib/Headers/cpuid.h
===
--- lib/Headers/cpuid.h
+++ lib/Headers/cpuid.h
@@ -186,6 +186,7 @@
 #define bit_AVX512BITALG 0x1000
 #define bit_AVX512VPOPCNTDQ  0x4000
 #define bit_RDPID0x0040
+#define bit_CLDEMOTE 0x0200
 
 /* Features in %edx for leaf 7 sub-leaf 0 */
 #define bit_AVX5124VNNIW  0x0004
Index: lib/Headers/cldemoteintrin.h
===
--- /dev/null
+++ lib/Headers/cldemoteintrin.h
@@ -0,0 +1,42 @@
+/*=== cldemoteintrin.h - CLDEMOTE intrinsic ===
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ *===---

[PATCH] D45451: [ItaniumMangle] Undeduced auto type doesn't belong in the substitution table

2018-04-13 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/AST/ItaniumMangle.cpp:2342
+  if (isa(Ty))
+return false;
   return true;

I agree with your analysis that this shouldn't be a substitution candidate.  
However, I think this probably needs an ABI-compatibility guard.


Repository:
  rC Clang

https://reviews.llvm.org/D45451



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


[PATCH] D45212: [HIP] Let CUDA toolchain support HIP language mode and amdgpu

2018-04-13 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

I'd still prefer if someone with more driver-design expertise weighed in, but 
we might not have any specialists there.

LGTM, although you might consider changing your tests a bit: FileCheck recently 
added support for a -D argument where you can predefine variables in the 
command line.  But that's just a suggestion, not something I'm asking you to do 
as part of review.


https://reviews.llvm.org/D45212



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


[PATCH] D45578: Add a command line option 'fregister_dtor_with_atexit' to register destructor functions annotated with __attribute__((destructor)) using __cxa_atexit or atexit.

2018-04-13 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/Driver/Options.td:1613
+def fregister_dtor_with_atexit : Flag<["-"], "fregister-dtor-with-atexit">, 
Group, Flags<[CC1Option]>,
+  HelpText<"Use atexit or __cxa_atexit to register destructors">;
 def fuse_init_array : Flag<["-"], "fuse-init-array">, Group, 
Flags<[CC1Option]>,

Probably worth spelling out that this is for *global* destructors, at least in 
the help text and maybe in the option names.  At the very least, the option 
name should say "dtors" instead of just "dtor".



Comment at: include/clang/Frontend/CodeGenOptions.def:46
 CODEGENOPT(CXAAtExit , 1, 1) ///< Use __cxa_atexit for calling 
destructors.
+CODEGENOPT(RegisterDtorWithAtExit, 1, 1) ///< Use atexit or __cxa_atexit to 
register destructors.
 CODEGENOPT(CXXCtorDtorAliases, 1, 0) ///< Emit complete ctors/dtors as linker

Same thing: worth saying in the option name that this is just global dtors.



Comment at: lib/CodeGen/CodeGenModule.h:1339
 
+  llvm::SmallDenseMap> DtorsUsingAtExit;
+

There's an llvm::TinyPtrVector which would be useful here.



Comment at: lib/CodeGen/ItaniumCXXABI.cpp:2213
+void CodeGenModule::registerDtorsWithAtExit() {
+  for (const auto I : DtorsUsingAtExit) {
+int Priority = I.getFirst();

This is iterating over a DenseMap and therefore making the emission order 
dependent on details like how we hash ints for DenseMap.

Also, is this a correct way of handling Priority?  You should at least justify 
that in comments.


Repository:
  rC Clang

https://reviews.llvm.org/D45578



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


[PATCH] D45319: [Atomics] warn about misaligned atomic accesses using libcalls

2018-04-13 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover added a comment.

Ping.


Repository:
  rC Clang

https://reviews.llvm.org/D45319



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


[PATCH] D45257: [X86] Introduce cldemote intrinsic

2018-04-13 Thread Gabor Buella via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329993: [X86] Introduce cldemote intrinsic (authored by 
GBuella, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D45257?vs=142340&id=142345#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45257

Files:
  cfe/trunk/include/clang/Basic/BuiltinsX86.def
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Basic/Targets/X86.cpp
  cfe/trunk/lib/Basic/Targets/X86.h
  cfe/trunk/lib/Headers/CMakeLists.txt
  cfe/trunk/lib/Headers/cldemoteintrin.h
  cfe/trunk/lib/Headers/cpuid.h
  cfe/trunk/lib/Headers/x86intrin.h
  cfe/trunk/test/CodeGen/builtins-x86.c
  cfe/trunk/test/CodeGen/cldemote.c

Index: cfe/trunk/lib/Basic/Targets/X86.h
===
--- cfe/trunk/lib/Basic/Targets/X86.h
+++ cfe/trunk/lib/Basic/Targets/X86.h
@@ -91,6 +91,7 @@
   bool HasXSAVES = false;
   bool HasMWAITX = false;
   bool HasCLZERO = false;
+  bool HasCLDEMOTE = false;
   bool HasPKU = false;
   bool HasCLFLUSHOPT = false;
   bool HasCLWB = false;
Index: cfe/trunk/lib/Basic/Targets/X86.cpp
===
--- cfe/trunk/lib/Basic/Targets/X86.cpp
+++ cfe/trunk/lib/Basic/Targets/X86.cpp
@@ -800,6 +800,8 @@
   HasPREFETCHWT1 = true;
 } else if (Feature == "+clzero") {
   HasCLZERO = true;
+} else if (Feature == "+cldemote") {
+  HasCLDEMOTE = true;
 } else if (Feature == "+rdpid") {
   HasRDPID = true;
 } else if (Feature == "+retpoline") {
@@ -1154,6 +1156,8 @@
 Builder.defineMacro("__CLZERO__");
   if (HasRDPID)
 Builder.defineMacro("__RDPID__");
+  if (HasCLDEMOTE)
+Builder.defineMacro("__CLDEMOTE__");
 
   // Each case falls through to the previous one here.
   switch (SSELevel) {
@@ -1263,6 +1267,7 @@
   .Case("avx512ifma", true)
   .Case("bmi", true)
   .Case("bmi2", true)
+  .Case("cldemote", true)
   .Case("clflushopt", true)
   .Case("clwb", true)
   .Case("clzero", true)
@@ -1334,6 +1339,7 @@
   .Case("avx512ifma", HasAVX512IFMA)
   .Case("bmi", HasBMI)
   .Case("bmi2", HasBMI2)
+  .Case("cldemote", HasCLDEMOTE)
   .Case("clflushopt", HasCLFLUSHOPT)
   .Case("clwb", HasCLWB)
   .Case("clzero", HasCLZERO)
Index: cfe/trunk/lib/Headers/cldemoteintrin.h
===
--- cfe/trunk/lib/Headers/cldemoteintrin.h
+++ cfe/trunk/lib/Headers/cldemoteintrin.h
@@ -0,0 +1,42 @@
+/*=== cldemoteintrin.h - CLDEMOTE intrinsic ===
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ *===---===
+ */
+
+#ifndef __X86INTRIN_H
+#error "Never use  directly; include  instead."
+#endif
+
+#ifndef __CLDEMOTEINTRIN_H
+#define __CLDEMOTEINTRIN_H
+
+/* Define the default attributes for the functions in this file. */
+#define __DEFAULT_FN_ATTRS \
+  __attribute__((__always_inline__, __nodebug__,  __target__("cldemote")))
+
+static __inline__ void __DEFAULT_FN_ATTRS
+_cldemote(const void * __P) {
+  __builtin_ia32_cldemote(__P);
+}
+
+#undef __DEFAULT_FN_ATTRS
+
+#endif
Index: cfe/trunk/lib/Headers/CMakeLists.txt
===
--- cfe/trunk/lib/Headers/CMakeLists.txt
+++ cfe/trunk/lib/Headers/CMakeLists.txt
@@ -40,6 +40,7 @@
   __clang_cuda_math_forward_declares.h
   __clang_cuda_runtime_wrapper.h
   cetintrin.h
+  cldemoteintrin.h
   clzerointrin.h
   cpuid.h
   clflushoptintrin.h
Index: cfe/trunk/lib/Headers/x86intrin.h
===
--- cfe/trunk/lib/Headers/x86intrin.h
+++ cfe/trunk/lib/Headers/x86intrin.h
@@ -92,4 +92,8 @@
 #include 
 #endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__CLDEMOT

[clang-tools-extra] r329994 - [clang-tidy] [bugprone-parent-virtual-call] Minor cosmetic changes. NFC

2018-04-13 Thread Zinovy Nis via cfe-commits
Author: zinovy.nis
Date: Fri Apr 13 00:46:27 2018
New Revision: 329994

URL: http://llvm.org/viewvc/llvm-project?rev=329994&view=rev
Log:
[clang-tidy] [bugprone-parent-virtual-call] Minor cosmetic changes. NFC


Modified:
clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp?rev=329994&r1=329993&r2=329994&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp Fri 
Apr 13 00:46:27 2018
@@ -11,6 +11,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Tooling/FixIt.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include 
 #include 
@@ -27,13 +28,12 @@ static bool isParentOf(const CXXRecordDe
const CXXRecordDecl &ThisClass) {
   if (Parent.getCanonicalDecl() == ThisClass.getCanonicalDecl())
 return true;
-  for (const CXXBaseSpecifier &Base : ThisClass.bases()) {
-auto *BaseDecl = Base.getType()->getAsCXXRecordDecl();
-assert(BaseDecl);
-if (Parent.getCanonicalDecl() == BaseDecl->getCanonicalDecl())
-  return true;
-  }
-  return false;
+  return ThisClass.bases_end() !=
+ llvm::find_if(ThisClass.bases(), [=](const CXXBaseSpecifier &Base) {
+   auto *BaseDecl = Base.getType()->getAsCXXRecordDecl();
+   assert(BaseDecl);
+   return Parent.getCanonicalDecl() == BaseDecl->getCanonicalDecl();
+ });
 }
 
 static BasesVector getParentsByGrandParent(const CXXRecordDecl &GrandParent,
@@ -76,9 +76,9 @@ static std::string getExprAsString(const
clang::ASTContext &AC) {
   std::string Text = tooling::fixit::getText(E, AC).str();
   Text.erase(
-  std::remove_if(
-  Text.begin(), Text.end(),
-  [](char c) { return std::isspace(static_cast(c)); }),
+  llvm::remove_if(
+  Text,
+  [](char C) { return std::isspace(static_cast(C)); }),
   Text.end());
   return Text;
 }
@@ -92,16 +92,11 @@ void ParentVirtualCallCheck::registerMat
 hasSourceExpression(cxxThisExpr(hasType(
 type(anything()).bind("thisType")))
  .bind("member")),
-  callee(cxxMethodDecl(isVirtual(
-  .bind("call"),
+  callee(cxxMethodDecl(isVirtual(,
   this);
 }
 
 void ParentVirtualCallCheck::check(const MatchFinder::MatchResult &Result) {
-  const auto *MatchedDecl = Result.Nodes.getNodeAs("call");
-  (void)MatchedDecl;
-  assert(MatchedDecl);
-
   const auto *Member = Result.Nodes.getNodeAs("member");
   assert(Member);
 


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


[PATCH] D45212: [HIP] Let CUDA toolchain support HIP language mode and amdgpu

2018-04-13 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

In https://reviews.llvm.org/D45212#1066842, @rjmccall wrote:

> I'd still prefer if someone with more driver-design expertise weighed in, but 
> we might not have any specialists there.


I think you should at least give @tra the possibility to take a look. Last time 
we essentially ended up reverting a patch.


https://reviews.llvm.org/D45212



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


[PATCH] D45513: [clangd] Add line and column number to the index symbol.

2018-04-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clangd/index/Index.h:32
+// Character offset on a line in a document (zero-based).
+int Character = 0;
+  };

MaskRay wrote:
> hokein wrote:
> > sammccall wrote:
> > > sammccall wrote:
> > > > Column?
> > > > 
> > > > LSP calls this "character" but this is nonstandard and I find it very 
> > > > confusing with offset. 
> > > We should document what this is an offset into: bytes, utf-16 code units, 
> > > or unicode codepoints. (Or even grid offsets - glyphs and doublewidth are 
> > > a thing)
> > > 
> > > Given that we intend to send it over LSP without reading the source, only 
> > > utf-16 code units is really correct. Unicode codepoints is "nicer" and 
> > > will give correct results in the BMP, while bytes will be correct for 
> > > ASCII only.
> > > 
> > > I'd vote for making this utf-16 code units.
> > > 
> > > It's OK if the code populating it doesn't get this right (confuses bytes 
> > > and code units) but add a fixme.
> > Done. Added FIXME.
> I'd vote for Unicode code points.
> 
> I haven't looked into this closely. But UTF-8 vs UTF-16 vs Unicode code 
> points should not be a big issue here. Unless you use emojis or some uncommon 
> characters, the usage of UTF-16 code units in LSP does not have a lot of harm.
> 
> //  😹😹👻 anything weird hidden in line comments can be ignored because 
> they don't affect offset calculation
> 
> And Microsoft might change the spec one day 
> https://github.com/Microsoft/language-server-protocol/issues/376
Yeah, It'd be nicer if LSP spec is changed to use UTF-8. The `Column` is 
intended to align with `Character` of LSP's `Position`, let's keep it as it is 
at the moment.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45513



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


Re: r328680 - [ObjC] Make C++ triviality type traits available to non-trivial C

2018-04-13 Thread John McCall via cfe-commits
> On Apr 9, 2018, at 3:47 PM, Akira Hatanaka  wrote:
> 
> 
>> On Apr 5, 2018, at 1:25 PM, John McCall > > wrote:
>> 
>> 
>> 
>>> On Apr 5, 2018, at 3:54 PM, Akira Hatanaka >> > wrote:
>>> 
>>> 
 On Apr 5, 2018, at 12:39 PM, John McCall >>> > wrote:
 
 
 
> On Apr 4, 2018, at 7:37 PM, Akira Hatanaka  > wrote:
> 
> 
> 
>> On Apr 4, 2018, at 4:24 PM, Akira Hatanaka via cfe-commits 
>> mailto:cfe-commits@lists.llvm.org>> wrote:
>> 
>>> 
>>> On Apr 4, 2018, at 3:38 PM, Richard Smith >> > wrote:
>>> 
>>> Hi Akira,
>>> 
>>> This change has broken the C++ versions of these type traits for 
>>> classes with volatile members. Such classes are required to claim to be 
>>> trivial per C++ DR 2094 
>>> (http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2094 
>>> ) 
>>> but return false from isNonTrivialToPrimitiveCopy().
>>> 
>> 
>> Oh that’s right. The function returns false when 
>> isNonTrivialToPrimitiveCopy() returns PCK_VolatileTrivial. That is wrong.
>> 
>>> Also, exposing these __has_* traits more widely seems like a backwards 
>>> step to me: these traits are deprecated, near-useless, and we're trying 
>>> to remove them. No code should be using them under any circumstances; 
>>> the __is_* traits should be used instead.
>>> 
>> 
>> The __is_* traits (is_trivially_copy_constructible, etc.) are templates 
>> defined in libcxx, so it seems that we can’t use them when compiling in 
>> C mode. Is it OK to add their definitions to TokenKinds.def as non-C++ 
>> keywords?
>> 
> 
> Or perhaps redefine the six __has_* traits used here as non-C++ (KEYNOCXX 
> or ‘KEYC99 | KEYC11') keywords?
 
 I think Richard is talking about e.g. the __is_trivially_destructible 
 intrinsic type trait function rather than std::is_trivially_destructible.
 
 Do we have a concrete need to expose these type traits to C?
 
>>> 
>>> No, no one has asked any of these type traits to be exposed to C yet. Do 
>>> you think we should just revert the patch and wait until someone asks for 
>>> those type traits to be available in C?
>> 
>> I think that would be fine.  Although it would be nice if we could save the 
>> part of the patch that makes the trait logic sensitive to the type queries 
>> instead of needing to include duplicated checks for __strong, __weak, and 
>> whatever other non-trivial C features we eventually add.
>> 
> 
> Reverted r329289 in r329608. I wasn’t sure which part of the patch should be 
> saved. I don’t think we need to check the properties of the types calling the 
> QualType::isNonTrivialTo* functions since we aren’t exposing the type traits 
> to C anymore?

I mean that it would be nice if the queries could just consider the primitive 
type properties in the non-record case instead of having explicit extra checks 
for __strong/__weak and so on.

John.

> 
>> John.
>> 
>>> 
 John.
 
> 
>>> On 27 March 2018 at 17:12, Akira Hatanaka via cfe-commits 
>>> mailto:cfe-commits@lists.llvm.org>> wrote:
>>> Author: ahatanak
>>> Date: Tue Mar 27 17:12:08 2018
>>> New Revision: 328680
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=328680&view=rev 
>>> 
>>> Log:
>>> [ObjC] Make C++ triviality type traits available to non-trivial C
>>> structs.
>>> 
>>> r326307 and r327870 made changes that allowed using non-trivial C
>>> structs with fields qualified with __strong or __weak. This commit makes
>>> the following C++ triviality type traits available to non-trivial C
>>> structs:
>>> 
>>> __has_trivial_assign
>>> __has_trivial_move_assign
>>> __has_trivial_copy
>>> __has_trivial_move_constructor
>>> __has_trivial_constructor
>>> __has_trivial_destructor
>>> 
>>> rdar://problem/33599681 
>>> 
>>> Differential Revision: https://reviews.llvm.org/D44913 
>>> 
>>> 
>>> Added:
>>> cfe/trunk/test/SemaObjC/non-trivial-struct-traits.m
>>> Modified:
>>> cfe/trunk/include/clang/Basic/TokenKinds.def
>>> cfe/trunk/lib/Sema/SemaExprCXX.cpp
>>> 
>>> Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=328680&r1=328679&r2=328680&view=diff
>>>  
>>> 
>>> ==
>>> --- cfe/t

[PATCH] D45513: [clangd] Add line and column number to the index symbol.

2018-04-13 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE329997: [clangd] Add line and column number to the index 
symbol. (authored by hokein, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D45513?vs=142195&id=142349#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45513

Files:
  clangd/index/Index.cpp
  clangd/index/Index.h
  clangd/index/SymbolCollector.cpp
  clangd/index/SymbolYAML.cpp
  unittests/clangd/Annotations.cpp
  unittests/clangd/Annotations.h
  unittests/clangd/SymbolCollectorTests.cpp

Index: unittests/clangd/Annotations.h
===
--- unittests/clangd/Annotations.h
+++ unittests/clangd/Annotations.h
@@ -58,10 +58,6 @@
   // Returns the location of all ranges marked by [[ ]] (or $name[[ ]]).
   std::vector ranges(llvm::StringRef Name = "") const;
 
-  // The same to `range` method, but returns range in offsets [start, end).
-  std::pair
-  offsetRange(llvm::StringRef Name = "") const;
-
 private:
   std::string Code;
   llvm::StringMap> Points;
Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -51,13 +51,20 @@
 MATCHER_P(IncludeHeader, P, "") {
   return arg.Detail && arg.Detail->IncludeHeader == P;
 }
-MATCHER_P(DeclRange, Offsets, "") {
-  return arg.CanonicalDeclaration.StartOffset == Offsets.first &&
-  arg.CanonicalDeclaration.EndOffset == Offsets.second;
-}
-MATCHER_P(DefRange, Offsets, "") {
-  return arg.Definition.StartOffset == Offsets.first &&
- arg.Definition.EndOffset == Offsets.second;
+MATCHER_P(DeclRange, Pos, "") {
+  return std::tie(arg.CanonicalDeclaration.Start.Line,
+  arg.CanonicalDeclaration.Start.Column,
+  arg.CanonicalDeclaration.End.Line,
+  arg.CanonicalDeclaration.End.Column) ==
+ std::tie(Pos.start.line, Pos.start.character, Pos.end.line,
+  Pos.end.character);
+}
+MATCHER_P(DefRange, Pos, "") {
+  return std::tie(arg.Definition.Start.Line,
+  arg.Definition.Start.Column, arg.Definition.End.Line,
+  arg.Definition.End.Column) ==
+ std::tie(Pos.start.line, Pos.start.character, Pos.end.line,
+  Pos.end.character);
 }
 MATCHER_P(Refs, R, "") { return int(arg.References) == R; }
 
@@ -209,7 +216,7 @@
   )");
   runSymbolCollector(Header.code(), /*Main=*/"");
   EXPECT_THAT(Symbols, UnorderedElementsAreArray({AllOf(
-   QName("Tmpl"), DeclRange(Header.offsetRange()))}));
+   QName("Tmpl"), DeclRange(Header.range()))}));
 }
 
 TEST_F(SymbolCollectorTest, Locations) {
@@ -221,6 +228,9 @@
 
 // Declared in header, defined nowhere.
 extern int $zdecl[[Z]];
+
+void $foodecl[[fo\
+o]]();
   )cpp");
   Annotations Main(R"cpp(
 int $xdef[[X]] = 42;
@@ -234,13 +244,15 @@
   EXPECT_THAT(
   Symbols,
   UnorderedElementsAre(
-  AllOf(QName("X"), DeclRange(Header.offsetRange("xdecl")),
-DefRange(Main.offsetRange("xdef"))),
-  AllOf(QName("Cls"), DeclRange(Header.offsetRange("clsdecl")),
-DefRange(Main.offsetRange("clsdef"))),
-  AllOf(QName("print"), DeclRange(Header.offsetRange("printdecl")),
-DefRange(Main.offsetRange("printdef"))),
-  AllOf(QName("Z"), DeclRange(Header.offsetRange("zdecl");
+  AllOf(QName("X"), DeclRange(Header.range("xdecl")),
+DefRange(Main.range("xdef"))),
+  AllOf(QName("Cls"), DeclRange(Header.range("clsdecl")),
+DefRange(Main.range("clsdef"))),
+  AllOf(QName("print"), DeclRange(Header.range("printdecl")),
+DefRange(Main.range("printdef"))),
+  AllOf(QName("Z"), DeclRange(Header.range("zdecl"))),
+  AllOf(QName("foo"), DeclRange(Header.range("foodecl")))
+  ));
 }
 
 TEST_F(SymbolCollectorTest, References) {
@@ -365,9 +377,9 @@
   EXPECT_THAT(
   Symbols,
   UnorderedElementsAre(
-  AllOf(QName("abc_Test"), DeclRange(Header.offsetRange("expansion")),
+  AllOf(QName("abc_Test"), DeclRange(Header.range("expansion")),
 DeclURI(TestHeaderURI)),
-  AllOf(QName("Test"), DeclRange(Header.offsetRange("spelling")),
+  AllOf(QName("Test"), DeclRange(Header.range("spelling")),
 DeclURI(TestHeaderURI;
 }
 
@@ -382,7 +394,8 @@
  /*ExtraArgs=*/{"-DNAME=name"});
   EXPECT_THAT(Symbols,
   UnorderedElementsAre(AllOf(
-  QName("name"), DeclRange(Header.offsetRange("expansion")),
+  QName("name"),
+  DeclRange(Header.range("expansion")),
   DeclURI(TestHeaderURI;
 }
 
@@ -511,9 +524,13 @@
   Kind:Function

[clang-tools-extra] r329997 - [clangd] Add line and column number to the index symbol.

2018-04-13 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri Apr 13 01:30:39 2018
New Revision: 329997

URL: http://llvm.org/viewvc/llvm-project?rev=329997&view=rev
Log:
[clangd] Add line and column number to the index symbol.

Summary:
LSP is using Line & column as symbol position, clangd needs to transfer file
offset to Line & column when sending results back to LSP client, which is a high
cost, especially for finding workspace symbol -- we have to read the file
content from disk (if it isn't loaded in memory).

Saving these information in the index will make the clangd life eaiser.

Reviewers: sammccall

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

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

Modified:
clang-tools-extra/trunk/clangd/index/Index.cpp
clang-tools-extra/trunk/clangd/index/Index.h
clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp
clang-tools-extra/trunk/unittests/clangd/Annotations.cpp
clang-tools-extra/trunk/unittests/clangd/Annotations.h
clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp

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=329997&r1=329996&r2=329997&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Index.cpp Fri Apr 13 01:30:39 2018
@@ -19,7 +19,8 @@ using namespace llvm;
 raw_ostream &operator<<(raw_ostream &OS, const SymbolLocation &L) {
   if (!L)
 return OS << "(none)";
-  return OS << L.FileURI << "[" << L.StartOffset << "-" << L.EndOffset << ")";
+  return OS << L.FileURI << "[" << L.Start.Line << ":" << L.Start.Column << "-"
+<< L.End.Line << ":" << L.End.Column << ")";
 }
 
 SymbolID::SymbolID(StringRef USR)

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=329997&r1=329996&r2=329997&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.h (original)
+++ clang-tools-extra/trunk/clangd/index/Index.h Fri Apr 13 01:30:39 2018
@@ -24,13 +24,27 @@ namespace clang {
 namespace clangd {
 
 struct SymbolLocation {
+  // Specify a position (Line, Column) of symbol. Using Line/Column allows us 
to
+  // build LSP responses without reading the file content.
+  struct Position {
+uint32_t Line = 0; // 0-based
+// Using UTF-16 code units.
+uint32_t Column = 0; // 0-based
+  };
+
   // The URI of the source file where a symbol occurs.
   llvm::StringRef FileURI;
   // The 0-based offsets of the symbol from the beginning of the source file,
   // using half-open range, [StartOffset, EndOffset).
+  // DO NOT use these fields, as they will be removed immediately.
+  // FIXME(hokein): remove these fields in favor of Position.
   unsigned StartOffset = 0;
   unsigned EndOffset = 0;
 
+  /// The symbol range, using half-open range [Start, End).
+  Position Start;
+  Position End;
+
   operator bool() const { return !FileURI.empty(); }
 };
 llvm::raw_ostream &operator<<(llvm::raw_ostream &, const SymbolLocation &);

Modified: clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp?rev=329997&r1=329996&r2=329997&view=diff
==
--- clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp Fri Apr 13 
01:30:39 2018
@@ -192,9 +192,24 @@ llvm::Optional getSymbol
   FileURIStorage = std::move(*U);
   SymbolLocation Result;
   Result.FileURI = FileURIStorage;
-  Result.StartOffset = SM.getFileOffset(NameLoc);
-  Result.EndOffset = Result.StartOffset + clang::Lexer::MeasureTokenLength(
-  NameLoc, SM, LangOpts);
+  auto TokenLength = clang::Lexer::MeasureTokenLength(NameLoc, SM, LangOpts);
+
+  auto CreatePosition = [&SM](SourceLocation Loc) {
+auto FileIdAndOffset = SM.getDecomposedLoc(Loc);
+auto FileId = FileIdAndOffset.first;
+auto Offset = FileIdAndOffset.second;
+SymbolLocation::Position Pos;
+// Position is 0-based while SourceManager is 1-based.
+Pos.Line = SM.getLineNumber(FileId, Offset) - 1;
+// FIXME: Use UTF-16 code units, not UTF-8 bytes.
+Pos.Column = SM.getColumnNumber(FileId, Offset) - 1;
+return Pos;
+  };
+
+  Result.Start = CreatePosition(NameLoc);
+  auto EndLoc = NameLoc.getLocWithOffset(TokenLength);
+  Result.End = CreatePosition(EndLoc);
+
   return std::move(Result);
 }
 

Modified: clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/cl

[PATCH] D44882: [clangd] Implementation of workspace/symbol request

2018-04-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In https://reviews.llvm.org/D44882#1065932, @malaperle wrote:

> In https://reviews.llvm.org/D44882#1065787, @hokein wrote:
>
> > @malaperle, what's your plan of this patch? Are you going to land it before 
> > https://reviews.llvm.org/D45513? With the Line&Column info in the index, 
> > this patch could be simplified.
>
>
> I'll address the last comment and wait for review. Probably at least another 
> day of delay. So if that ends up after https://reviews.llvm.org/D45513 then 
> I'll update it to simplify. Sounds good?


Thanks, I have landed the patch today, you need to update your patch (I think 
it is mostly about removing the code of reading-file stuff).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44882



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


[PATCH] D45476: [C++2a] Implement operator<=> CodeGen and ExprConstant

2018-04-13 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: include/clang/AST/ComparisonCategories.h:77-78
+  ///   comparison category. For example 'std::strong_equality::equal'
+  const DeclRefExpr *getResultValue(ComparisonCategoryResult ValueKind) const {
+const DeclRefExpr *DR = getResultValueUnsafe(ValueKind);
+assert(DR &&

EricWF wrote:
> rsmith wrote:
> > This should deal in `DeclRefExpr*`s, not `NamedDecl*`s. We don't have an 
> > expression naming the comparison result value, and we shouldn't pretend we 
> > do.
> I'm confused. This does deal in `DeclRefExpr*`s. I'm probably being daft. 
> Could you clarify?
Sorry, while editing this comment I managed to reverse it from what I meant. 
This should deal in NamedDecl* (or perhaps ValueDecl*) , not DeclRefExpr*.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:9384-9385
+def err_spaceship_comparison_of_void_ptr : Error<
+  "three-way comparison with void pointer %select{operand type|operand types}0 
"
+  "(%1 and %2)">;
+def err_spaceship_comparison_of_invalid_comp_type : Error<

EricWF wrote:
> rsmith wrote:
> > Why are you diagnosing this case as an error?
> [expr.spaceship]p9 seems to require it. The composite pointer type is not a 
> function/member/null pointer type, neither is it a object pointer type, so 
> the program is ill-formed.
> 
> Unless I'm missing something.
void* is an object pointer type.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:9393
+def note_spaceship_operand_not_cce : Note<
+  "argument is not a constant expression">;
 } // end of sema component.

EricWF wrote:
> rsmith wrote:
> > Is this really useful? I would think almost all the cases where you'd hit 
> > the "cannot be narrowed" error, this diagnostic and the explanation of why 
> > the operand is not constant would be meaningless noise, because it was 
> > never meant to be constant, and the problem is simply that you are trying 
> > to three-way compare integers of mixed signedness.
> I'm struggling to answer that question myself. The case I was thinking of 
> that I wanted to help the user out with is:
> 
> ```
> auto cmp_sentinal(long val) {
>   int SENTINAL = 0;
>   return SENTINAL <=> val; // error, would be OK if SENTINAL were const.
> }
> ```
> 
> I'll remove these diagnostics for now, and hopefully improve them in a follow 
> up patch, if that's OK with you?
Sounds good.



Comment at: lib/Sema/SemaDeclCXX.cpp:
 
+bool Sema::BuildComparisonCategoryData(SourceLocation Loc) {
+  using CCKT = ComparisonCategoryKind;

EricWF wrote:
> rsmith wrote:
> > If you put this on Sema, you'll need to serialize it, and it's no longer 
> > just a cache.
> > 
> > I would prefer to treat this information strictly as a cache, and build it 
> > in ASTContext. Sema should then just be checking that the information is 
> > "valid" when it first makes use of such a comparison category type.
> I agree that it's preferable to just have a cache. However can you clarify 
> what you mean by "build it in ASTContext"?
> 
> Building the expressions will potentially require emitting a diagnostic, and 
> use of bits of `Sema` (like name lookup).
> I'm not sure how to do this inside `ASTContext`.
> 
> The current implementation caches the data in `ASTContext` but builds it 
> as-needed in `Sema`. Could you clarify how to go about with the 
> implementation you're suggesting?
You don't need "real" name lookup here, just calling lookup on the DeclContext 
should be fine. We don't need to support more exotic ways of declaring these 
members, nor access checks etc.

I was imagining that Sema would check that we can find suitable members on the 
comparison category types as part of semantically checking a <=> expression, 
and the ASTContext side of things would not emit diagnostics.

(Put another way, we'd act as if we look up the members each time we need them, 
Sema would check that all the necessary members actually exist, and ASTContext 
would have a caching layer only for convenience / to avoid repeatedly doing the 
same lookups.)


https://reviews.llvm.org/D45476



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


[PATCH] D45611: [analyzer] Fix filename in cross-file HTML report

2018-04-13 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons created this revision.
malcolm.parsons added reviewers: george.karpenkov, dcoughlin, vlad.tsyrklevich.
Herald added subscribers: cfe-commits, a.sidorin, szepet, xazax.hun.

The filename is currently taken from the start of the path, while the
line and column are taken from the end of the path.
This didn't matter until cross-file path reporting was added.


Repository:
  rC Clang

https://reviews.llvm.org/D45611

Files:
  lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp


Index: lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
===
--- lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -321,7 +321,9 @@
 return {};
 
   // Add CSS, header, and footer.
-  const FileEntry* Entry = SMgr.getFileEntryForID(FileIDs[0]);
+  FileID FID =
+  path.back()->getLocation().asLocation().getExpansionLoc().getFileID();
+  const FileEntry* Entry = SMgr.getFileEntryForID(FID);
   FinalizeHTML(D, R, SMgr, path, FileIDs[0], Entry, declName);
 
   std::string file;


Index: lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
===
--- lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -321,7 +321,9 @@
 return {};
 
   // Add CSS, header, and footer.
-  const FileEntry* Entry = SMgr.getFileEntryForID(FileIDs[0]);
+  FileID FID =
+  path.back()->getLocation().asLocation().getExpansionLoc().getFileID();
+  const FileEntry* Entry = SMgr.getFileEntryForID(FID);
   FinalizeHTML(D, R, SMgr, path, FileIDs[0], Entry, declName);
 
   std::string file;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r329999 - [clang-tidy] Fix ParentVirtualCallCheck for old MSVS compilers

2018-04-13 Thread Zinovy Nis via cfe-commits
Author: zinovy.nis
Date: Fri Apr 13 01:43:47 2018
New Revision: 32

URL: http://llvm.org/viewvc/llvm-project?rev=32&view=rev
Log:
[clang-tidy] Fix ParentVirtualCallCheck for old MSVS compilers


Modified:
clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp?rev=32&r1=329998&r2=32&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp Fri 
Apr 13 01:43:47 2018
@@ -28,11 +28,12 @@ static bool isParentOf(const CXXRecordDe
const CXXRecordDecl &ThisClass) {
   if (Parent.getCanonicalDecl() == ThisClass.getCanonicalDecl())
 return true;
+  const CXXRecordDecl *ParentCanonicalDecl = Parent.getCanonicalDecl();
   return ThisClass.bases_end() !=
  llvm::find_if(ThisClass.bases(), [=](const CXXBaseSpecifier &Base) {
auto *BaseDecl = Base.getType()->getAsCXXRecordDecl();
assert(BaseDecl);
-   return Parent.getCanonicalDecl() == BaseDecl->getCanonicalDecl();
+   return ParentCanonicalDecl == BaseDecl->getCanonicalDecl();
  });
 }
 


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


[PATCH] D45544: [AAch64] Add the __ARM_FEATURE_DOTPROD macro definition

2018-04-13 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer accepted this revision.
SjoerdMeijer added a comment.
This revision is now accepted and ready to land.

LGTM, thanks.


https://reviews.llvm.org/D45544



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


[PATCH] D45613: [X86] Introduce archs: goldmont-plus & tremont

2018-04-13 Thread Gabor Buella via Phabricator via cfe-commits
GBuella created this revision.
GBuella added a reviewer: craig.topper.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D45613

Files:
  include/clang/Basic/X86Target.def
  lib/Basic/Targets/X86.cpp
  test/Driver/x86-march.c
  test/Misc/target-invalid-cpu-note.c
  test/Preprocessor/predefined-arch-macros.c

Index: test/Preprocessor/predefined-arch-macros.c
===
--- test/Preprocessor/predefined-arch-macros.c
+++ test/Preprocessor/predefined-arch-macros.c
@@ -1371,6 +1371,7 @@
 // CHECK_GLM_M64: #define __PRFCHW__ 1
 // CHECK_GLM_M64: #define __RDRND__ 1
 // CHECK_GLM_M64: #define __RDSEED__ 1
+// CHECK_GLM_M64: #define __SHA__ 1
 // CHECK_GLM_M64: #define __SSE2__ 1
 // CHECK_GLM_M64: #define __SSE3__ 1
 // CHECK_GLM_M64: #define __SSE4_1__ 1
@@ -1387,6 +1388,146 @@
 // CHECK_GLM_M64: #define __x86_64 1
 // CHECK_GLM_M64: #define __x86_64__ 1
 
+// RUN: %clang -march=goldmont-plus -m32 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN:   | FileCheck %s -check-prefix=CHECK_GLMP_M32
+// CHECK_GLMP_M32: #define __AES__ 1
+// CHECK_GLMP_M32: #define __CLFLUSHOPT__ 1
+// CHECK_GLMP_M32: #define __FSGSBASE__ 1
+// CHECK_GLMP_M32: #define __FXSR__ 1
+// CHECK_GLMP_M32: #define __MMX__ 1
+// CHECK_GLMP_M32: #define __MPX__ 1
+// CHECK_GLMP_M32: #define __PCLMUL__ 1
+// CHECK_GLMP_M32: #define __POPCNT__ 1
+// CHECK_GLMP_M32: #define __PRFCHW__ 1
+// CHECK_GLMP_M32: #define __RDPID__ 1
+// CHECK_GLMP_M32: #define __RDRND__ 1
+// CHECK_GLMP_M32: #define __RDSEED__ 1
+// CHECK_GLMP_M32: #define __SGX__ 1
+// CHECK_GLMP_M32: #define __SHA__ 1
+// CHECK_GLMP_M32: #define __SSE2__ 1
+// CHECK_GLMP_M32: #define __SSE3__ 1
+// CHECK_GLMP_M32: #define __SSE4_1__ 1
+// CHECK_GLMP_M32: #define __SSE4_2__ 1
+// CHECK_GLMP_M32: #define __SSE_MATH__ 1
+// CHECK_GLMP_M32: #define __SSE__ 1
+// CHECK_GLMP_M32: #define __SSSE3__ 1
+// CHECK_GLMP_M32: #define __XSAVEC__ 1
+// CHECK_GLMP_M32: #define __XSAVEOPT__ 1
+// CHECK_GLMP_M32: #define __XSAVES__ 1
+// CHECK_GLMP_M32: #define __XSAVE__ 1
+// CHECK_GLMP_M32: #define __goldmont_plus 1
+// CHECK_GLMP_M32: #define __goldmont_plus__ 1
+// CHECK_GLMP_M32: #define __i386 1
+// CHECK_GLMP_M32: #define __i386__ 1
+// CHECK_GLMP_M32: #define __tune_goldmont_plus__ 1
+// CHECK_GLMP_M32: #define i386 1
+
+// RUN: %clang -march=goldmont-plus -m64 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN:   | FileCheck %s -check-prefix=CHECK_GLMP_M64
+// CHECK_GLMP_M64: #define __AES__ 1
+// CHECK_GLMP_M64: #define __CLFLUSHOPT__ 1
+// CHECK_GLMP_M64: #define __FSGSBASE__ 1
+// CHECK_GLMP_M64: #define __FXSR__ 1
+// CHECK_GLMP_M64: #define __MMX__ 1
+// CHECK_GLMP_M64: #define __MPX__ 1
+// CHECK_GLMP_M64: #define __PCLMUL__ 1
+// CHECK_GLMP_M64: #define __POPCNT__ 1
+// CHECK_GLMP_M64: #define __PRFCHW__ 1
+// CHECK_GLMP_M64: #define __RDPID__ 1
+// CHECK_GLMP_M64: #define __RDRND__ 1
+// CHECK_GLMP_M64: #define __RDSEED__ 1
+// CHECK_GLMP_M64: #define __SGX__ 1
+// CHECK_GLMP_M64: #define __SHA__ 1
+// CHECK_GLMP_M64: #define __SSE2__ 1
+// CHECK_GLMP_M64: #define __SSE3__ 1
+// CHECK_GLMP_M64: #define __SSE4_1__ 1
+// CHECK_GLMP_M64: #define __SSE4_2__ 1
+// CHECK_GLMP_M64: #define __SSE__ 1
+// CHECK_GLMP_M64: #define __SSSE3__ 1
+// CHECK_GLMP_M64: #define __XSAVEC__ 1
+// CHECK_GLMP_M64: #define __XSAVEOPT__ 1
+// CHECK_GLMP_M64: #define __XSAVES__ 1
+// CHECK_GLMP_M64: #define __XSAVE__ 1
+// CHECK_GLMP_M64: #define __goldmont_plus 1
+// CHECK_GLMP_M64: #define __goldmont_plus__ 1
+// CHECK_GLMP_M64: #define __tune_goldmont_plus__ 1
+// CHECK_GLMP_M64: #define __x86_64 1
+// CHECK_GLMP_M64: #define __x86_64__ 1
+
+// RUN: %clang -march=tremont -m32 -E -dM %s -o - 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN:   | FileCheck %s -check-prefix=CHECK_TRM_M32
+// CHECK_TRM_M32: #define __AES__ 1
+// CHECK_TRM_M32: #define __CLDEMOTE__ 1
+// CHECK_TRM_M32: #define __CLFLUSHOPT__ 1
+// CHECK_TRM_M32: #define __FSGSBASE__ 1
+// CHECK_TRM_M32: #define __FXSR__ 1
+// CHECK_TRM_M32: #define __GFNI__ 1
+// CHECK_TRM_M32: #define __MMX__ 1
+// CHECK_TRM_M32: #define __MPX__ 1
+// CHECK_TRM_M32: #define __PCLMUL__ 1
+// CHECK_TRM_M32: #define __POPCNT__ 1
+// CHECK_TRM_M32: #define __PRFCHW__ 1
+// CHECK_TRM_M32: #define __RDPID__ 1
+// CHECK_TRM_M32: #define __RDRND__ 1
+// CHECK_TRM_M32: #define __RDSEED__ 1
+// CHECK_TRM_M32: #define __SGX__ 1
+// CHECK_TRM_M32: #define __SHA__ 1
+// CHECK_TRM_M32: #define __SSE2__ 1
+// CHECK_TRM_M32: #define __SSE3__ 1
+// CHECK_TRM_M32: #define __SSE4_1__ 1
+// CHECK_TRM_M32: #define __SSE4_2__ 1
+// CHECK_TRM_M32: #define __SSE_MATH__ 1
+// CHECK_TRM_M32: #define __SSE__ 1
+// CHECK_TRM_M32: #define __SSSE3__ 1
+// CHECK_TRM_M32: #define __XSAVEC__ 1
+// CHECK_TRM_M32: #define __XSAVEOPT__ 1
+// CHECK_TRM_M32: #define __XSAVES__ 1
+// CHECK_TRM_M32: #define __XSAVE__ 1
+// CHECK_TRM_M32: #define __i386 1
+// C

[PATCH] D44882: [clangd] Implementation of workspace/symbol request

2018-04-13 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.

Still LG




Comment at: clangd/ClangdLSPServer.cpp:113
+  auto KindVal = static_cast(Kind);
+  if (KindVal >= SymbolKindMin && KindVal <= SymbolKindMax)
+SupportedSymbolKinds.set(KindVal);

malaperle wrote:
> sammccall wrote:
> > nit: the bounds checks at usage types, with explicit underlying type for 
> > the enum are inconsistent with what we do in other protocol enums, and seem 
> > to clutter the code.
> > 
> > All else equal, I'd prefer to have an enum/enum class with implicit type, 
> > and not have values that are out of the enum's range. It's a simpler model 
> > that matches the code we have, and doesn't need tricky casts to 
> > SymKindUnderlyingType. If we want to support clients that send higher 
> > numbers than we know about, we could either:
> >  - overload fromJSON(vector)&
> >  - just express the capabilities as vector and convert them to the 
> > enum (and check bounds) at this point.
> > WDYT?
> I think it's better to keep vector in Protocol.h, it is clearer 
> and more in line with the protocol. I overloaded fromJSON, which simplifies 
> the code here, but it still needs a static_cast to size_t for the 
> bitset.set(). Other places there still needs a static_cast, like in 
> defaultSymbolKinds for the loop, I can static_cast to size_t everywhere (or 
> int?) but having SymKindUnderlyingType seems more correct. I changed it to 
> size_t, let me know if it was something like that you had in mind.
LG, though I've commented in one place where the cast seems necessary.

Personally I usually use int here, but size_t is good too. The exact type 
doesn't matter as long as it covers all values of the enum.



Comment at: clangd/ClangdLSPServer.cpp:274
+  Sym.kind = adjustKindToCapability(Sym.kind, SupportedSymbolKinds);
+  assert(static_cast(Sym.kind) >= SymbolKindMin &&
+ static_cast(Sym.kind) < SupportedSymbolKinds.size() &&

you no longer need the min/max asserts and their casts, because we don't allow 
any values of type SymbolKind that don't have one of the enum values (i.e. 
we're just echoing the type system here)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44882



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


[PATCH] D45557: [Analyzer] Fix for SValBuilder expressions rearrangement

2018-04-13 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 142365.
baloghadamsoftware added a comment.

Updated according to the comments.


https://reviews.llvm.org/D45557

Files:
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  test/Analysis/svalbuilder-rearrange-comparisons.c


Index: test/Analysis/svalbuilder-rearrange-comparisons.c
===
--- test/Analysis/svalbuilder-rearrange-comparisons.c
+++ test/Analysis/svalbuilder-rearrange-comparisons.c
@@ -929,3 +929,8 @@
 clang_analyzer_eval(n - 126 == m + 3); // expected-warning{{UNKNOWN}}
   }
 }
+
+int mixed_integer_types(int x, int y) {
+  short a = x - 1U;
+  return a - y;
+}
Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -469,6 +469,8 @@
 // Initialize SingleTy later with a symbol's type.
   } else if (BinaryOperator::isAdditiveOp(Op)) {
 SingleTy = ResultTy;
+if (LSym->getType() != SingleTy)
+  return None;
 // Substracting unsigned integers is a nightmare.
 if (!SingleTy->isSignedIntegerOrEnumerationType())
   return None;


Index: test/Analysis/svalbuilder-rearrange-comparisons.c
===
--- test/Analysis/svalbuilder-rearrange-comparisons.c
+++ test/Analysis/svalbuilder-rearrange-comparisons.c
@@ -929,3 +929,8 @@
 clang_analyzer_eval(n - 126 == m + 3); // expected-warning{{UNKNOWN}}
   }
 }
+
+int mixed_integer_types(int x, int y) {
+  short a = x - 1U;
+  return a - y;
+}
Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -469,6 +469,8 @@
 // Initialize SingleTy later with a symbol's type.
   } else if (BinaryOperator::isAdditiveOp(Op)) {
 SingleTy = ResultTy;
+if (LSym->getType() != SingleTy)
+  return None;
 // Substracting unsigned integers is a nightmare.
 if (!SingleTy->isSignedIntegerOrEnumerationType())
   return None;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35110: [Analyzer] Constraint Manager Negates Difference

2018-04-13 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

No more pending dependency, so we can continue the review.


https://reviews.llvm.org/D35110



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


[PATCH] D45601: Warn on bool* to bool conversion

2018-04-13 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

@hiraditya I personally don't like when i'm being told so, but i'd like to see 
some numbers...
**Please** run this on //some// big C++ project (LLVM (but you'll have to 
enable this diag specifically), google chrome, ???), and analyse the results.

In https://reviews.llvm.org/D45601#1066572, @Eugene.Zelenko wrote:

> There is Clang-tidy's readability-implicit-bool-conversion 
> 
>  check.
>
> It may be reasonable to check pointers to integers too, since integers are 
> often implicitly converted to bools.


While warning on `bool*`->`bool` *might* be ok, also warning for all 
`inttype*`->`bool` will likely be *too* noisy for clang diagnostic.


https://reviews.llvm.org/D45601



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


[PATCH] D45615: [builtins] __builtin_dump_struct : added more types format

2018-04-13 Thread Paul Semel via Phabricator via cfe-commits
paulsemel created this revision.
paulsemel added a reviewer: aaron.ballman.
Herald added a subscriber: cfe-commits.

There was missing some basic types format (like uint8_t..). This patch is meant 
to print them the correct way.


Repository:
  rC Clang

https://reviews.llvm.org/D45615

Files:
  lib/CodeGen/CGBuiltin.cpp


Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -949,6 +949,10 @@
   if (Types.empty()) {
 Types[Context.CharTy] = "%c";
 Types[Context.BoolTy] = "%d";
+Types[Context.SignedCharTy] = "%d";
+Types[Context.ShortTy] = "%d";
+Types[Context.UnsignedCharTy] = "%u";
+Types[Context.UnsignedShortTy] = "%u";
 Types[Context.IntTy] = "%d";
 Types[Context.UnsignedIntTy] = "%u";
 Types[Context.LongTy] = "%ld";


Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -949,6 +949,10 @@
   if (Types.empty()) {
 Types[Context.CharTy] = "%c";
 Types[Context.BoolTy] = "%d";
+Types[Context.SignedCharTy] = "%d";
+Types[Context.ShortTy] = "%d";
+Types[Context.UnsignedCharTy] = "%u";
+Types[Context.UnsignedShortTy] = "%u";
 Types[Context.IntTy] = "%d";
 Types[Context.UnsignedIntTy] = "%u";
 Types[Context.LongTy] = "%ld";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45615: [builtins] __builtin_dump_struct : added more types format

2018-04-13 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Tests?


Repository:
  rC Clang

https://reviews.llvm.org/D45615



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


[PATCH] D45615: [builtins] __builtin_dump_struct : added more types format

2018-04-13 Thread Paul Semel via Phabricator via cfe-commits
paulsemel added a comment.

In https://reviews.llvm.org/D45615#1066973, @lebedev.ri wrote:

> Tests?


I can do this. But currently, I am not testing the formats in the tests..


Repository:
  rC Clang

https://reviews.llvm.org/D45615



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


[clang-tools-extra] r330004 - [clangd] Match AST and Index label for template Symbols

2018-04-13 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Fri Apr 13 04:03:07 2018
New Revision: 330004

URL: http://llvm.org/viewvc/llvm-project?rev=330004&view=rev
Log:
[clangd] Match AST and Index label for template Symbols

Summary:
Previsouly, class completions items from the index were missing
template parameters in both the snippet and the label.

Reviewers: sammccall, hokein

Reviewed By: sammccall

Subscribers: klimek, jkorous-apple, ioeric, MaskRay, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp

Modified: clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp?rev=330004&r1=330003&r2=330004&view=diff
==
--- clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp Fri Apr 13 
04:03:07 2018
@@ -14,6 +14,7 @@
 #include "../URI.h"
 #include "CanonicalIncludes.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclTemplate.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Index/IndexSymbol.h"
@@ -26,6 +27,19 @@ namespace clang {
 namespace clangd {
 
 namespace {
+/// If \p ND is a template specialization, returns the primary template.
+/// Otherwise, returns \p ND.
+const NamedDecl &getTemplateOrThis(const NamedDecl &ND) {
+  if (auto Cls = dyn_cast(&ND)) {
+if (auto T = Cls->getDescribedTemplate())
+  return *T;
+  } else if (auto Func = dyn_cast(&ND)) {
+if (auto T = Func->getPrimaryTemplate())
+  return *T;
+  }
+  return ND;
+}
+
 // Returns a URI of \p Path. Firstly, this makes the \p Path absolute using the
 // current working directory of the given SourceManager if the Path is not an
 // absolute path. If failed, this resolves relative paths against \p 
FallbackDir
@@ -325,7 +339,8 @@ const Symbol *SymbolCollector::addDeclar
   // Add completion info.
   // FIXME: we may want to choose a different redecl, or combine from several.
   assert(ASTCtx && PP.get() && "ASTContext and Preprocessor must be set.");
-  CodeCompletionResult SymbolCompletion(&ND, 0);
+  // We use the primary template, as clang does during code completion.
+  CodeCompletionResult SymbolCompletion(&getTemplateOrThis(ND), 0);
   const auto *CCS = SymbolCompletion.CreateCodeCompletionString(
   *ASTCtx, *PP, CodeCompletionContext::CCC_Name, *CompletionAllocator,
   *CompletionTUInfo,

Modified: clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp?rev=330004&r1=330003&r2=330004&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp Fri Apr 13 
04:03:07 2018
@@ -195,6 +195,44 @@ TEST(FileIndexTest, NoIncludeCollected)
   EXPECT_TRUE(SeenSymbol);
 }
 
+TEST(FileIndexTest, TemplateParamsInLabel) {
+  auto Source = R"cpp(
+template 
+class vector {
+};
+
+template 
+vector make_vector(Ty* begin, Ty* end) {}
+)cpp";
+
+  FileIndex M;
+  M.update("f", build("f", Source).getPointer());
+
+  FuzzyFindRequest Req;
+  Req.Query = "";
+  bool SeenVector = false;
+  bool SeenMakeVector = false;
+  M.fuzzyFind(Req, [&](const Symbol &Sym) {
+if (Sym.Name == "vector") {
+  EXPECT_EQ(Sym.CompletionLabel, "vector");
+  EXPECT_EQ(Sym.CompletionSnippetInsertText, "vector<${1:class Ty}>");
+  EXPECT_EQ(Sym.CompletionPlainInsertText, "vector");
+  SeenVector = true;
+  return;
+}
+
+if (Sym.Name == "make_vector") {
+  EXPECT_EQ(Sym.CompletionLabel, "make_vector(Ty *begin, Ty *end)");
+  EXPECT_EQ(Sym.CompletionSnippetInsertText,
+"make_vector(${1:Ty *begin}, ${2:Ty *end})");
+  EXPECT_EQ(Sym.CompletionPlainInsertText, "make_vector");
+  SeenMakeVector = true;
+}
+  });
+  EXPECT_TRUE(SeenVector);
+  EXPECT_TRUE(SeenMakeVector);
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang


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


[PATCH] D45482: [clangd] Match AST and Index label for template Symbols

2018-04-13 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 142372.
ilya-biryukov marked 2 inline comments as done.
ilya-biryukov added a comment.

- Also test plain text completion text
- Clarify the comment
- Simplify conditions in getTemplateOrThis


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45482

Files:
  clangd/index/SymbolCollector.cpp
  unittests/clangd/FileIndexTests.cpp


Index: unittests/clangd/FileIndexTests.cpp
===
--- unittests/clangd/FileIndexTests.cpp
+++ unittests/clangd/FileIndexTests.cpp
@@ -195,6 +195,44 @@
   EXPECT_TRUE(SeenSymbol);
 }
 
+TEST(FileIndexTest, TemplateParamsInLabel) {
+  auto Source = R"cpp(
+template 
+class vector {
+};
+
+template 
+vector make_vector(Ty* begin, Ty* end) {}
+)cpp";
+
+  FileIndex M;
+  M.update("f", build("f", Source).getPointer());
+
+  FuzzyFindRequest Req;
+  Req.Query = "";
+  bool SeenVector = false;
+  bool SeenMakeVector = false;
+  M.fuzzyFind(Req, [&](const Symbol &Sym) {
+if (Sym.Name == "vector") {
+  EXPECT_EQ(Sym.CompletionLabel, "vector");
+  EXPECT_EQ(Sym.CompletionSnippetInsertText, "vector<${1:class Ty}>");
+  EXPECT_EQ(Sym.CompletionPlainInsertText, "vector");
+  SeenVector = true;
+  return;
+}
+
+if (Sym.Name == "make_vector") {
+  EXPECT_EQ(Sym.CompletionLabel, "make_vector(Ty *begin, Ty *end)");
+  EXPECT_EQ(Sym.CompletionSnippetInsertText,
+"make_vector(${1:Ty *begin}, ${2:Ty *end})");
+  EXPECT_EQ(Sym.CompletionPlainInsertText, "make_vector");
+  SeenMakeVector = true;
+}
+  });
+  EXPECT_TRUE(SeenVector);
+  EXPECT_TRUE(SeenMakeVector);
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -14,6 +14,7 @@
 #include "../URI.h"
 #include "CanonicalIncludes.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclTemplate.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Index/IndexSymbol.h"
@@ -26,6 +27,19 @@
 namespace clangd {
 
 namespace {
+/// If \p ND is a template specialization, returns the primary template.
+/// Otherwise, returns \p ND.
+const NamedDecl &getTemplateOrThis(const NamedDecl &ND) {
+  if (auto Cls = dyn_cast(&ND)) {
+if (auto T = Cls->getDescribedTemplate())
+  return *T;
+  } else if (auto Func = dyn_cast(&ND)) {
+if (auto T = Func->getPrimaryTemplate())
+  return *T;
+  }
+  return ND;
+}
+
 // Returns a URI of \p Path. Firstly, this makes the \p Path absolute using the
 // current working directory of the given SourceManager if the Path is not an
 // absolute path. If failed, this resolves relative paths against \p 
FallbackDir
@@ -325,7 +339,8 @@
   // Add completion info.
   // FIXME: we may want to choose a different redecl, or combine from several.
   assert(ASTCtx && PP.get() && "ASTContext and Preprocessor must be set.");
-  CodeCompletionResult SymbolCompletion(&ND, 0);
+  // We use the primary template, as clang does during code completion.
+  CodeCompletionResult SymbolCompletion(&getTemplateOrThis(ND), 0);
   const auto *CCS = SymbolCompletion.CreateCodeCompletionString(
   *ASTCtx, *PP, CodeCompletionContext::CCC_Name, *CompletionAllocator,
   *CompletionTUInfo,


Index: unittests/clangd/FileIndexTests.cpp
===
--- unittests/clangd/FileIndexTests.cpp
+++ unittests/clangd/FileIndexTests.cpp
@@ -195,6 +195,44 @@
   EXPECT_TRUE(SeenSymbol);
 }
 
+TEST(FileIndexTest, TemplateParamsInLabel) {
+  auto Source = R"cpp(
+template 
+class vector {
+};
+
+template 
+vector make_vector(Ty* begin, Ty* end) {}
+)cpp";
+
+  FileIndex M;
+  M.update("f", build("f", Source).getPointer());
+
+  FuzzyFindRequest Req;
+  Req.Query = "";
+  bool SeenVector = false;
+  bool SeenMakeVector = false;
+  M.fuzzyFind(Req, [&](const Symbol &Sym) {
+if (Sym.Name == "vector") {
+  EXPECT_EQ(Sym.CompletionLabel, "vector");
+  EXPECT_EQ(Sym.CompletionSnippetInsertText, "vector<${1:class Ty}>");
+  EXPECT_EQ(Sym.CompletionPlainInsertText, "vector");
+  SeenVector = true;
+  return;
+}
+
+if (Sym.Name == "make_vector") {
+  EXPECT_EQ(Sym.CompletionLabel, "make_vector(Ty *begin, Ty *end)");
+  EXPECT_EQ(Sym.CompletionSnippetInsertText,
+"make_vector(${1:Ty *begin}, ${2:Ty *end})");
+  EXPECT_EQ(Sym.CompletionPlainInsertText, "make_vector");
+  SeenMakeVector = true;
+}
+  });
+  EXPECT_TRUE(SeenVector);
+  EXPECT_TRUE(SeenMakeVector);
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -14,6 

[PATCH] D45482: [clangd] Match AST and Index label for template Symbols

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



Comment at: unittests/clangd/FileIndexTests.cpp:218
+  EXPECT_EQ(Sym.CompletionLabel, "vector");
+  EXPECT_EQ(Sym.CompletionSnippetInsertText, "vector<${1:class Ty}>");
+  SeenVector = true;

sammccall wrote:
> If snippets are off, we'll get "vector", not "vector<>", right?
> 
> (Probably no need to test this explicitly, but I just want to be sure)
Yes, that's exactly the case.
Testing doesn't hurt too, added a test.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45482



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


[PATCH] D45482: [clangd] Match AST and Index label for template Symbols

2018-04-13 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE330004: [clangd] Match AST and Index label for template 
Symbols (authored by ibiryukov, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D45482?vs=142372&id=142373#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45482

Files:
  clangd/index/SymbolCollector.cpp
  unittests/clangd/FileIndexTests.cpp


Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -14,6 +14,7 @@
 #include "../URI.h"
 #include "CanonicalIncludes.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclTemplate.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Index/IndexSymbol.h"
@@ -26,6 +27,19 @@
 namespace clangd {
 
 namespace {
+/// If \p ND is a template specialization, returns the primary template.
+/// Otherwise, returns \p ND.
+const NamedDecl &getTemplateOrThis(const NamedDecl &ND) {
+  if (auto Cls = dyn_cast(&ND)) {
+if (auto T = Cls->getDescribedTemplate())
+  return *T;
+  } else if (auto Func = dyn_cast(&ND)) {
+if (auto T = Func->getPrimaryTemplate())
+  return *T;
+  }
+  return ND;
+}
+
 // Returns a URI of \p Path. Firstly, this makes the \p Path absolute using the
 // current working directory of the given SourceManager if the Path is not an
 // absolute path. If failed, this resolves relative paths against \p 
FallbackDir
@@ -325,7 +339,8 @@
   // Add completion info.
   // FIXME: we may want to choose a different redecl, or combine from several.
   assert(ASTCtx && PP.get() && "ASTContext and Preprocessor must be set.");
-  CodeCompletionResult SymbolCompletion(&ND, 0);
+  // We use the primary template, as clang does during code completion.
+  CodeCompletionResult SymbolCompletion(&getTemplateOrThis(ND), 0);
   const auto *CCS = SymbolCompletion.CreateCodeCompletionString(
   *ASTCtx, *PP, CodeCompletionContext::CCC_Name, *CompletionAllocator,
   *CompletionTUInfo,
Index: unittests/clangd/FileIndexTests.cpp
===
--- unittests/clangd/FileIndexTests.cpp
+++ unittests/clangd/FileIndexTests.cpp
@@ -195,6 +195,44 @@
   EXPECT_TRUE(SeenSymbol);
 }
 
+TEST(FileIndexTest, TemplateParamsInLabel) {
+  auto Source = R"cpp(
+template 
+class vector {
+};
+
+template 
+vector make_vector(Ty* begin, Ty* end) {}
+)cpp";
+
+  FileIndex M;
+  M.update("f", build("f", Source).getPointer());
+
+  FuzzyFindRequest Req;
+  Req.Query = "";
+  bool SeenVector = false;
+  bool SeenMakeVector = false;
+  M.fuzzyFind(Req, [&](const Symbol &Sym) {
+if (Sym.Name == "vector") {
+  EXPECT_EQ(Sym.CompletionLabel, "vector");
+  EXPECT_EQ(Sym.CompletionSnippetInsertText, "vector<${1:class Ty}>");
+  EXPECT_EQ(Sym.CompletionPlainInsertText, "vector");
+  SeenVector = true;
+  return;
+}
+
+if (Sym.Name == "make_vector") {
+  EXPECT_EQ(Sym.CompletionLabel, "make_vector(Ty *begin, Ty *end)");
+  EXPECT_EQ(Sym.CompletionSnippetInsertText,
+"make_vector(${1:Ty *begin}, ${2:Ty *end})");
+  EXPECT_EQ(Sym.CompletionPlainInsertText, "make_vector");
+  SeenMakeVector = true;
+}
+  });
+  EXPECT_TRUE(SeenVector);
+  EXPECT_TRUE(SeenMakeVector);
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang


Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -14,6 +14,7 @@
 #include "../URI.h"
 #include "CanonicalIncludes.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclTemplate.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Index/IndexSymbol.h"
@@ -26,6 +27,19 @@
 namespace clangd {
 
 namespace {
+/// If \p ND is a template specialization, returns the primary template.
+/// Otherwise, returns \p ND.
+const NamedDecl &getTemplateOrThis(const NamedDecl &ND) {
+  if (auto Cls = dyn_cast(&ND)) {
+if (auto T = Cls->getDescribedTemplate())
+  return *T;
+  } else if (auto Func = dyn_cast(&ND)) {
+if (auto T = Func->getPrimaryTemplate())
+  return *T;
+  }
+  return ND;
+}
+
 // Returns a URI of \p Path. Firstly, this makes the \p Path absolute using the
 // current working directory of the given SourceManager if the Path is not an
 // absolute path. If failed, this resolves relative paths against \p FallbackDir
@@ -325,7 +339,8 @@
   // Add completion info.
   // FIXME: we may want to choose a different redecl, or combine from several.
   assert(ASTCtx && PP.get() && "ASTContext and Preprocessor must be set.");
-  CodeCompletionResult SymbolCompletion(&ND, 0);
+  // We use the primary template, as clang does during code completion.
+  CodeCompletionResult SymbolCompletion(&getTempl

[PATCH] D45482: [clangd] Match AST and Index label for template Symbols

2018-04-13 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330004: [clangd] Match AST and Index label for template 
Symbols (authored by ibiryukov, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D45482

Files:
  clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
  clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp


Index: clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp
@@ -195,6 +195,44 @@
   EXPECT_TRUE(SeenSymbol);
 }
 
+TEST(FileIndexTest, TemplateParamsInLabel) {
+  auto Source = R"cpp(
+template 
+class vector {
+};
+
+template 
+vector make_vector(Ty* begin, Ty* end) {}
+)cpp";
+
+  FileIndex M;
+  M.update("f", build("f", Source).getPointer());
+
+  FuzzyFindRequest Req;
+  Req.Query = "";
+  bool SeenVector = false;
+  bool SeenMakeVector = false;
+  M.fuzzyFind(Req, [&](const Symbol &Sym) {
+if (Sym.Name == "vector") {
+  EXPECT_EQ(Sym.CompletionLabel, "vector");
+  EXPECT_EQ(Sym.CompletionSnippetInsertText, "vector<${1:class Ty}>");
+  EXPECT_EQ(Sym.CompletionPlainInsertText, "vector");
+  SeenVector = true;
+  return;
+}
+
+if (Sym.Name == "make_vector") {
+  EXPECT_EQ(Sym.CompletionLabel, "make_vector(Ty *begin, Ty *end)");
+  EXPECT_EQ(Sym.CompletionSnippetInsertText,
+"make_vector(${1:Ty *begin}, ${2:Ty *end})");
+  EXPECT_EQ(Sym.CompletionPlainInsertText, "make_vector");
+  SeenMakeVector = true;
+}
+  });
+  EXPECT_TRUE(SeenVector);
+  EXPECT_TRUE(SeenMakeVector);
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
@@ -14,6 +14,7 @@
 #include "../URI.h"
 #include "CanonicalIncludes.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclTemplate.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Index/IndexSymbol.h"
@@ -26,6 +27,19 @@
 namespace clangd {
 
 namespace {
+/// If \p ND is a template specialization, returns the primary template.
+/// Otherwise, returns \p ND.
+const NamedDecl &getTemplateOrThis(const NamedDecl &ND) {
+  if (auto Cls = dyn_cast(&ND)) {
+if (auto T = Cls->getDescribedTemplate())
+  return *T;
+  } else if (auto Func = dyn_cast(&ND)) {
+if (auto T = Func->getPrimaryTemplate())
+  return *T;
+  }
+  return ND;
+}
+
 // Returns a URI of \p Path. Firstly, this makes the \p Path absolute using the
 // current working directory of the given SourceManager if the Path is not an
 // absolute path. If failed, this resolves relative paths against \p 
FallbackDir
@@ -325,7 +339,8 @@
   // Add completion info.
   // FIXME: we may want to choose a different redecl, or combine from several.
   assert(ASTCtx && PP.get() && "ASTContext and Preprocessor must be set.");
-  CodeCompletionResult SymbolCompletion(&ND, 0);
+  // We use the primary template, as clang does during code completion.
+  CodeCompletionResult SymbolCompletion(&getTemplateOrThis(ND), 0);
   const auto *CCS = SymbolCompletion.CreateCodeCompletionString(
   *ASTCtx, *PP, CodeCompletionContext::CCC_Name, *CompletionAllocator,
   *CompletionTUInfo,


Index: clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp
@@ -195,6 +195,44 @@
   EXPECT_TRUE(SeenSymbol);
 }
 
+TEST(FileIndexTest, TemplateParamsInLabel) {
+  auto Source = R"cpp(
+template 
+class vector {
+};
+
+template 
+vector make_vector(Ty* begin, Ty* end) {}
+)cpp";
+
+  FileIndex M;
+  M.update("f", build("f", Source).getPointer());
+
+  FuzzyFindRequest Req;
+  Req.Query = "";
+  bool SeenVector = false;
+  bool SeenMakeVector = false;
+  M.fuzzyFind(Req, [&](const Symbol &Sym) {
+if (Sym.Name == "vector") {
+  EXPECT_EQ(Sym.CompletionLabel, "vector");
+  EXPECT_EQ(Sym.CompletionSnippetInsertText, "vector<${1:class Ty}>");
+  EXPECT_EQ(Sym.CompletionPlainInsertText, "vector");
+  SeenVector = true;
+  return;
+}
+
+if (Sym.Name == "make_vector") {
+  EXPECT_EQ(Sym.CompletionLabel, "make_vector(Ty *begin, Ty *end)");
+  EXPECT_EQ(Sym.CompletionSnippetInsertText,
+"make_vector(${1:Ty *begin}, ${2:Ty *end})");
+  EXPECT_EQ(Sym.CompletionPlainInsertText, "make_vector");
+  SeenMakeVector = true;
+}
+  });
+  EXPECT_TRUE(SeenVector);
+  EXPECT_TRUE(SeenMakeVector);
+}
+
 

[PATCH] D45616: [X86] Lower _mm[256|512]_cmp[.]_mask intrinsics to native llvm IR

2018-04-13 Thread Gabor Buella via Phabricator via cfe-commits
GBuella created this revision.
GBuella added a reviewer: craig.topper.
Herald added a subscriber: cfe-commits.

The fcmp opcode has no defined behavior with NaN operands
in the comparisions handled in this patch. Thus, these
intrinsics can only be safe lowered to fcmp opcodes
when fast-math is enabled.

This also partially reverses the commit
259aee973f1df2cba62cc3d32847dced739e9202 :
"[X86] Use native IR for immediate values 0-7 of packed fp cmp builtins."

That commit lowered 4 SSE cmp builtins to fcmp opcodes, but with
this patch, that lowering is also dependent on the -ffast-math flag.

Affected AVX512 builtins (were not lowered to fcmp before):

__builtin_ia32_cmpps128_mask
__builtin_ia32_cmpps256_mask
__builtin_ia32_cmpps512_mask
__builtin_ia32_cmppd128_mask
__builtin_ia32_cmppd256_mask
__builtin_ia32_cmppd512_mask

Affected SSE builtins (were unconditionally lowered before):

__builtin_ia32_cmpps
__builtin_ia32_cmpps256
__builtin_ia32_cmppd
__builtin_ia32_cmppd256

At the same time, recognize predicates that result in
constants with all of the above intrinsics, that was only
handled in the case of the __builtin_ia32_cmpp[s|d]256 intrinsics.


Repository:
  rC Clang

https://reviews.llvm.org/D45616

Files:
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/avx-builtins.c
  test/CodeGen/avx2-builtins-fast-math.c
  test/CodeGen/avx2-builtins.c
  test/CodeGen/avx512f-builtins-fast-math.c
  test/CodeGen/avx512f-builtins.c
  test/CodeGen/avx512vl-builtins-fast-math.c
  test/CodeGen/avx512vl-builtins.c

Index: test/CodeGen/avx512vl-builtins.c
===
--- test/CodeGen/avx512vl-builtins.c
+++ test/CodeGen/avx512vl-builtins.c
@@ -1077,6 +1077,34 @@
   return (__mmask8)_mm256_cmp_ps_mask(__A, __B, 0);
 }
 
+__mmask8 test_mm256_cmp_ps_mask_true_uq(__m256 __A, __m256 __B) {
+  // CHECK-LABEL: @test_mm256_cmp_ps_mask_true_uq
+  // CHECK-NOT: call
+  // CHECK: store i8 -1
+  return (__mmask8)_mm256_cmp_ps_mask(__A, __B, _CMP_TRUE_UQ);
+}
+
+__mmask8 test_mm256_cmp_ps_mask_true_us(__m256 __A, __m256 __B) {
+  // CHECK-LABEL: @test_mm256_cmp_ps_mask_true_us
+  // CHECK-NOT: call
+  // CHECK: store i8 -1
+  return (__mmask8)_mm256_cmp_ps_mask(__A, __B, _CMP_TRUE_US);
+}
+
+__mmask8 test_mm256_cmp_ps_mask_false_oq(__m256 __A, __m256 __B) {
+  // CHECK-LABEL: @test_mm256_cmp_ps_mask_false_oq
+  // CHECK-NOT: call
+  // CHECK: store i8 0
+  return (__mmask8)_mm256_cmp_ps_mask(__A, __B, _CMP_FALSE_OQ);
+}
+
+__mmask8 test_mm256_cmp_ps_mask_false_os(__m256 __A, __m256 __B) {
+  // CHECK-LABEL: @test_mm256_cmp_ps_mask_false_os
+  // CHECK-NOT: call
+  // CHECK: store i8 0
+  return (__mmask8)_mm256_cmp_ps_mask(__A, __B, _CMP_FALSE_OS);
+}
+
 __mmask8 test_mm256_mask_cmp_ps_mask(__mmask8 m, __m256 __A, __m256 __B) {
   // CHECK-LABEL: @test_mm256_mask_cmp_ps_mask
   // CHECK: [[CMP:%.*]] = call <8 x i1> @llvm.x86.avx512.mask.cmp.ps.256
@@ -1090,6 +1118,34 @@
   return (__mmask8)_mm_cmp_ps_mask(__A, __B, 0);
 }
 
+__mmask8 test_mm_cmp_ps_mask_true_uq(__m128 __A, __m128 __B) {
+  // CHECK-LABEL: @test_mm_cmp_ps_mask_true_uq
+  // CHECK-NOT: call
+  // CHECK: store i8 -1
+  return (__mmask8)_mm_cmp_ps_mask(__A, __B, _CMP_TRUE_UQ);
+}
+
+__mmask8 test_mm_cmp_ps_mask_true_us(__m128 __A, __m128 __B) {
+  // CHECK-LABEL: @test_mm_cmp_ps_mask_true_us
+  // CHECK-NOT: call
+  // CHECK: store i8 -1
+  return (__mmask8)_mm_cmp_ps_mask(__A, __B, _CMP_TRUE_US);
+}
+
+__mmask8 test_mm_cmp_ps_mask_false_oq(__m128 __A, __m128 __B) {
+  // CHECK-LABEL: @test_mm_cmp_ps_mask_false_oq
+  // CHECK-NOT: call
+  // CHECK: store i8 0
+  return (__mmask8)_mm_cmp_ps_mask(__A, __B, _CMP_FALSE_OQ);
+}
+
+__mmask8 test_mm_cmp_ps_mask_false_os(__m128 __A, __m128 __B) {
+  // CHECK-LABEL: @test_mm_cmp_ps_mask_false_os
+  // CHECK-NOT: call
+  // CHECK: store i8 0
+  return (__mmask8)_mm_cmp_ps_mask(__A, __B, _CMP_FALSE_OS);
+}
+
 __mmask8 test_mm_mask_cmp_ps_mask(__mmask8 m, __m128 __A, __m128 __B) {
   // CHECK-LABEL: @test_mm_mask_cmp_ps_mask
   // CHECK: [[CMP:%.*]] = call <4 x i1> @llvm.x86.avx512.mask.cmp.ps.128
@@ -1103,6 +1159,34 @@
   return (__mmask8)_mm256_cmp_pd_mask(__A, __B, 0);
 }
 
+__mmask8 test_mm256_cmp_pd_mask_true_uq(__m256d __A, __m256d __B) {
+  // CHECK-LABEL: @test_mm256_cmp_pd_mask_true_uq
+  // CHECK-NOT: call
+  // CHECK: store i8 -1
+  return (__mmask8)_mm256_cmp_pd_mask(__A, __B, _CMP_TRUE_UQ);
+}
+
+__mmask8 test_mm256_cmp_pd_mask_true_us(__m256d __A, __m256d __B) {
+  // CHECK-LABEL: @test_mm256_cmp_pd_mask_true_us
+  // CHECK-NOT: call
+  // CHECK: store i8 -1
+  return (__mmask8)_mm256_cmp_pd_mask(__A, __B, _CMP_TRUE_US);
+}
+
+__mmask8 test_mm256_cmp_pd_mask_false_oq(__m256d __A, __m256d __B) {
+  // CHECK-LABEL: @test_mm256_cmp_pd_mask_false_oq
+  // CHECK-NOT: call
+  // CHECK: store i8 0
+  return (__mmask8)_mm256_cmp_pd_mask(__A, __B, _CMP_FALSE_OQ);
+}
+
+__mmask8 test_mm256_cmp_pd_mask_false_os(__m256d __A, __m256d __B) {
+  // CHECK-LABEL: @test_mm256_cmp_pd_mask

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

2018-04-13 Thread Henry Wong via Phabricator via cfe-commits
MTC added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/CtorUninitializedMemberChecker.cpp:10
+//
+//  This file defines a checker that checks cunstructors for possibly
+//  uninitialized fields.

typo :)  `cunstructors` -> `constructors`



Comment at: lib/StaticAnalyzer/Checkers/CtorUninitializedMemberChecker.cpp:54
+  StringRef getAsString(SmallString<200> &Buf) const;
+  friend class FieldChainInfoComparator;
+};

When I apply this patch, hit a compiler warning. Maybe `friend struct` is 
better.
```
warning: 'FieldChainInfoComparator' defined as a struct here but previously 
declared as a class [-Wmismatched-tags]
```


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] D45601: Warn on bool* to bool conversion

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



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7806
+  "comparing %0 as a boolean">,
+  InGroup;
 def warn_format_argument_needs_cast : Warning<

Also, this really really should be under it's own flag, which in turn may be 
under `Extra`.


https://reviews.llvm.org/D45601



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


[PATCH] D45564: [analyzer] Fix null deref in AnyFunctionCall::getRuntimeDefinition

2018-04-13 Thread Rafael Stahl via Phabricator via cfe-commits
r.stahl updated this revision to Diff 142381.
r.stahl edited the summary of this revision.
r.stahl added a comment.

addressed review comments.

I created a new test because certain checkers would cause early exits in the 
engine (because of undefined func ptr) and not cause the crash.

Since I don't have commit access, please commit for me.


https://reviews.llvm.org/D45564

Files:
  lib/StaticAnalyzer/Core/CallEvent.cpp
  test/Analysis/undef-call.c


Index: test/Analysis/undef-call.c
===
--- test/Analysis/undef-call.c
+++ test/Analysis/undef-call.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -analyze 
-analyzer-checker=debug.ExprInspection -analyzer-config 
experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir 
-verify %s
+// expected-no-diagnostics
+
+struct S {
+  void (*fp)();
+};
+
+int main() {
+  struct S s;
+  // This will cause the analyzer to look for a function definition that has
+  // no FunctionDecl. It used to cause a crash in 
AnyFunctionCall::getRuntimeDefinition.
+  // It would only occur when CTU analysis is enabled.
+  s.fp();
+}
Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -387,31 +387,32 @@
 
 RuntimeDefinition AnyFunctionCall::getRuntimeDefinition() const {
   const FunctionDecl *FD = getDecl();
+  if (!FD)
+return {};
+
   // Note that the AnalysisDeclContext will have the FunctionDecl with
   // the definition (if one exists).
-  if (FD) {
-AnalysisDeclContext *AD =
-  getLocationContext()->getAnalysisDeclContext()->
-  getManager()->getContext(FD);
-bool IsAutosynthesized;
-Stmt* Body = AD->getBody(IsAutosynthesized);
-DEBUG({
-if (IsAutosynthesized)
-  llvm::dbgs() << "Using autosynthesized body for " << FD->getName()
-   << "\n";
-});
-if (Body) {
-  const Decl* Decl = AD->getDecl();
-  return RuntimeDefinition(Decl);
-}
+  AnalysisDeclContext *AD =
+getLocationContext()->getAnalysisDeclContext()->
+getManager()->getContext(FD);
+  bool IsAutosynthesized;
+  Stmt* Body = AD->getBody(IsAutosynthesized);
+  DEBUG({
+  if (IsAutosynthesized)
+llvm::dbgs() << "Using autosynthesized body for " << FD->getName()
+ << "\n";
+  });
+  if (Body) {
+const Decl* Decl = AD->getDecl();
+return RuntimeDefinition(Decl);
   }
 
   SubEngine *Engine = getState()->getStateManager().getOwningEngine();
   AnalyzerOptions &Opts = Engine->getAnalysisManager().options;
 
   // Try to get CTU definition only if CTUDir is provided.
   if (!Opts.naiveCTUEnabled())
-return RuntimeDefinition();
+return {};
 
   cross_tu::CrossTranslationUnitContext &CTUCtx =
   *Engine->getCrossTranslationUnitContext();


Index: test/Analysis/undef-call.c
===
--- test/Analysis/undef-call.c
+++ test/Analysis/undef-call.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -analyze -analyzer-checker=debug.ExprInspection -analyzer-config experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir -verify %s
+// expected-no-diagnostics
+
+struct S {
+  void (*fp)();
+};
+
+int main() {
+  struct S s;
+  // This will cause the analyzer to look for a function definition that has
+  // no FunctionDecl. It used to cause a crash in AnyFunctionCall::getRuntimeDefinition.
+  // It would only occur when CTU analysis is enabled.
+  s.fp();
+}
Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -387,31 +387,32 @@
 
 RuntimeDefinition AnyFunctionCall::getRuntimeDefinition() const {
   const FunctionDecl *FD = getDecl();
+  if (!FD)
+return {};
+
   // Note that the AnalysisDeclContext will have the FunctionDecl with
   // the definition (if one exists).
-  if (FD) {
-AnalysisDeclContext *AD =
-  getLocationContext()->getAnalysisDeclContext()->
-  getManager()->getContext(FD);
-bool IsAutosynthesized;
-Stmt* Body = AD->getBody(IsAutosynthesized);
-DEBUG({
-if (IsAutosynthesized)
-  llvm::dbgs() << "Using autosynthesized body for " << FD->getName()
-   << "\n";
-});
-if (Body) {
-  const Decl* Decl = AD->getDecl();
-  return RuntimeDefinition(Decl);
-}
+  AnalysisDeclContext *AD =
+getLocationContext()->getAnalysisDeclContext()->
+getManager()->getContext(FD);
+  bool IsAutosynthesized;
+  Stmt* Body = AD->getBody(IsAutosynthesized);
+  DEBUG({
+  if (IsAutosynthesized)
+llvm::dbgs() << "Using autosynthesized body for " << FD->getName()
+ << "\n";
+  });
+  if (Body) {
+const Decl* Decl = AD->getDecl(

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

2018-04-13 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/CtorUninitializedMemberChecker.cpp:35
+
+  FieldChain Chain;
+  // If this is a fieldchain whose last element is an uninitialized region of a

I was wondering, do you need the chain at all? I think a field region might be 
sufficient. The enclosing object of the field should be accessible by querying 
the super region of the field region.


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] D45601: Warn on bool* to bool conversion

2018-04-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a comment.

I'd also be interested to see the number of false positives and true positives 
when run over some large code bases (both C and C++). For instance, I would 
imagine code like this to be somewhat common and very reasonable:

  void some_func(int someArg, bool *someResult) {
if (someResult)
  *someResult = false;
  }

Especially in C code where references are not available. This makes me wary of 
making this a compiler diagnostic, but clang-tidy may still be a reasonable 
place for this functionality to live.


https://reviews.llvm.org/D45601



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


r330009 - [analyzer] Fix null deref in AnyFunctionCall::getRuntimeDefinition

2018-04-13 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Fri Apr 13 05:36:08 2018
New Revision: 330009

URL: http://llvm.org/viewvc/llvm-project?rev=330009&view=rev
Log:
[analyzer] Fix null deref in AnyFunctionCall::getRuntimeDefinition

Patch by: Rafael Stahl!

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

Added:
cfe/trunk/test/Analysis/undef-call.c
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp?rev=330009&r1=330008&r2=330009&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp Fri Apr 13 05:36:08 2018
@@ -389,23 +389,24 @@ ArrayRef AnyFunctionCall::
 
 RuntimeDefinition AnyFunctionCall::getRuntimeDefinition() const {
   const FunctionDecl *FD = getDecl();
+  if (!FD)
+return {};
+
   // Note that the AnalysisDeclContext will have the FunctionDecl with
   // the definition (if one exists).
-  if (FD) {
-AnalysisDeclContext *AD =
-  getLocationContext()->getAnalysisDeclContext()->
-  getManager()->getContext(FD);
-bool IsAutosynthesized;
-Stmt* Body = AD->getBody(IsAutosynthesized);
-DEBUG({
-if (IsAutosynthesized)
-  llvm::dbgs() << "Using autosynthesized body for " << FD->getName()
-   << "\n";
-});
-if (Body) {
-  const Decl* Decl = AD->getDecl();
-  return RuntimeDefinition(Decl);
-}
+  AnalysisDeclContext *AD =
+getLocationContext()->getAnalysisDeclContext()->
+getManager()->getContext(FD);
+  bool IsAutosynthesized;
+  Stmt* Body = AD->getBody(IsAutosynthesized);
+  DEBUG({
+  if (IsAutosynthesized)
+llvm::dbgs() << "Using autosynthesized body for " << FD->getName()
+ << "\n";
+  });
+  if (Body) {
+const Decl* Decl = AD->getDecl();
+return RuntimeDefinition(Decl);
   }
 
   SubEngine *Engine = getState()->getStateManager().getOwningEngine();
@@ -413,7 +414,7 @@ RuntimeDefinition AnyFunctionCall::getRu
 
   // Try to get CTU definition only if CTUDir is provided.
   if (!Opts.naiveCTUEnabled())
-return RuntimeDefinition();
+return {};
 
   cross_tu::CrossTranslationUnitContext &CTUCtx =
   *Engine->getCrossTranslationUnitContext();

Added: cfe/trunk/test/Analysis/undef-call.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/undef-call.c?rev=330009&view=auto
==
--- cfe/trunk/test/Analysis/undef-call.c (added)
+++ cfe/trunk/test/Analysis/undef-call.c Fri Apr 13 05:36:08 2018
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -analyze 
-analyzer-checker=debug.ExprInspection -analyzer-config 
experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir 
-verify %s
+// expected-no-diagnostics
+
+struct S {
+  void (*fp)();
+};
+
+int main() {
+  struct S s;
+  // This will cause the analyzer to look for a function definition that has
+  // no FunctionDecl. It used to cause a crash in 
AnyFunctionCall::getRuntimeDefinition.
+  // It would only occur when CTU analysis is enabled.
+  s.fp();
+}


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


[PATCH] D45615: [builtins] __builtin_dump_struct : added more types format

2018-04-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman requested changes to this revision.
aaron.ballman added a comment.
This revision now requires changes to proceed.

In https://reviews.llvm.org/D45615#1066975, @paulsemel wrote:

> In https://reviews.llvm.org/D45615#1066973, @lebedev.ri wrote:
>
> > Tests?
>
>
> I can do this. But currently, I am not testing the formats in the tests..


Now might be a good time to test that, because this patch almost added a bug by 
missing the length modifiers. Also, all patches should come with some tests to 
demonstrate the behavioral differences from the current trunk.




Comment at: lib/CodeGen/CGBuiltin.cpp:954-955
+Types[Context.ShortTy] = "%d";
+Types[Context.UnsignedCharTy] = "%u";
+Types[Context.UnsignedShortTy] = "%u";
 Types[Context.IntTy] = "%d";

Can you keep the signed/unsigned ordering?

Also, I think these should have the length modifiers added (`hh` for char).

Finally: `ShortTy` and `UnsignedShortTy` were already handled (see lines 
962-963 in this patch), so I don't think those need to be added.


Repository:
  rC Clang

https://reviews.llvm.org/D45615



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


[PATCH] D45564: [analyzer] Fix null deref in AnyFunctionCall::getRuntimeDefinition

2018-04-13 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC330009: [analyzer] Fix null deref in 
AnyFunctionCall::getRuntimeDefinition (authored by xazax, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D45564

Files:
  lib/StaticAnalyzer/Core/CallEvent.cpp
  test/Analysis/undef-call.c


Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -389,31 +389,32 @@
 
 RuntimeDefinition AnyFunctionCall::getRuntimeDefinition() const {
   const FunctionDecl *FD = getDecl();
+  if (!FD)
+return {};
+
   // Note that the AnalysisDeclContext will have the FunctionDecl with
   // the definition (if one exists).
-  if (FD) {
-AnalysisDeclContext *AD =
-  getLocationContext()->getAnalysisDeclContext()->
-  getManager()->getContext(FD);
-bool IsAutosynthesized;
-Stmt* Body = AD->getBody(IsAutosynthesized);
-DEBUG({
-if (IsAutosynthesized)
-  llvm::dbgs() << "Using autosynthesized body for " << FD->getName()
-   << "\n";
-});
-if (Body) {
-  const Decl* Decl = AD->getDecl();
-  return RuntimeDefinition(Decl);
-}
+  AnalysisDeclContext *AD =
+getLocationContext()->getAnalysisDeclContext()->
+getManager()->getContext(FD);
+  bool IsAutosynthesized;
+  Stmt* Body = AD->getBody(IsAutosynthesized);
+  DEBUG({
+  if (IsAutosynthesized)
+llvm::dbgs() << "Using autosynthesized body for " << FD->getName()
+ << "\n";
+  });
+  if (Body) {
+const Decl* Decl = AD->getDecl();
+return RuntimeDefinition(Decl);
   }
 
   SubEngine *Engine = getState()->getStateManager().getOwningEngine();
   AnalyzerOptions &Opts = Engine->getAnalysisManager().options;
 
   // Try to get CTU definition only if CTUDir is provided.
   if (!Opts.naiveCTUEnabled())
-return RuntimeDefinition();
+return {};
 
   cross_tu::CrossTranslationUnitContext &CTUCtx =
   *Engine->getCrossTranslationUnitContext();
Index: test/Analysis/undef-call.c
===
--- test/Analysis/undef-call.c
+++ test/Analysis/undef-call.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -analyze 
-analyzer-checker=debug.ExprInspection -analyzer-config 
experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir 
-verify %s
+// expected-no-diagnostics
+
+struct S {
+  void (*fp)();
+};
+
+int main() {
+  struct S s;
+  // This will cause the analyzer to look for a function definition that has
+  // no FunctionDecl. It used to cause a crash in 
AnyFunctionCall::getRuntimeDefinition.
+  // It would only occur when CTU analysis is enabled.
+  s.fp();
+}


Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -389,31 +389,32 @@
 
 RuntimeDefinition AnyFunctionCall::getRuntimeDefinition() const {
   const FunctionDecl *FD = getDecl();
+  if (!FD)
+return {};
+
   // Note that the AnalysisDeclContext will have the FunctionDecl with
   // the definition (if one exists).
-  if (FD) {
-AnalysisDeclContext *AD =
-  getLocationContext()->getAnalysisDeclContext()->
-  getManager()->getContext(FD);
-bool IsAutosynthesized;
-Stmt* Body = AD->getBody(IsAutosynthesized);
-DEBUG({
-if (IsAutosynthesized)
-  llvm::dbgs() << "Using autosynthesized body for " << FD->getName()
-   << "\n";
-});
-if (Body) {
-  const Decl* Decl = AD->getDecl();
-  return RuntimeDefinition(Decl);
-}
+  AnalysisDeclContext *AD =
+getLocationContext()->getAnalysisDeclContext()->
+getManager()->getContext(FD);
+  bool IsAutosynthesized;
+  Stmt* Body = AD->getBody(IsAutosynthesized);
+  DEBUG({
+  if (IsAutosynthesized)
+llvm::dbgs() << "Using autosynthesized body for " << FD->getName()
+ << "\n";
+  });
+  if (Body) {
+const Decl* Decl = AD->getDecl();
+return RuntimeDefinition(Decl);
   }
 
   SubEngine *Engine = getState()->getStateManager().getOwningEngine();
   AnalyzerOptions &Opts = Engine->getAnalysisManager().options;
 
   // Try to get CTU definition only if CTUDir is provided.
   if (!Opts.naiveCTUEnabled())
-return RuntimeDefinition();
+return {};
 
   cross_tu::CrossTranslationUnitContext &CTUCtx =
   *Engine->getCrossTranslationUnitContext();
Index: test/Analysis/undef-call.c
===
--- test/Analysis/undef-call.c
+++ test/Analysis/undef-call.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -analyze -analyzer-checker=debug.ExprInspection -analyzer-config experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir -verify %s
+// expected-no-di

[PATCH] D45603: Fix evaluation of `__has_include_next` during -frewrite-includes.

2018-04-13 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lg


https://reviews.llvm.org/D45603



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


r330012 - [NEON] Support vrndns_f32 intrinsic

2018-04-13 Thread Ivan A. Kosarev via cfe-commits
Author: kosarev
Date: Fri Apr 13 05:46:02 2018
New Revision: 330012

URL: http://llvm.org/viewvc/llvm-project?rev=330012&view=rev
Log:
[NEON] Support vrndns_f32 intrinsic

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

Modified:
cfe/trunk/include/clang/Basic/arm_neon.td
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/arm-neon-directed-rounding.c

Modified: cfe/trunk/include/clang/Basic/arm_neon.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=330012&r1=330011&r2=330012&view=diff
==
--- cfe/trunk/include/clang/Basic/arm_neon.td (original)
+++ cfe/trunk/include/clang/Basic/arm_neon.td Fri Apr 13 05:46:02 2018
@@ -1116,6 +1116,12 @@ def SCALAR_FCVTZU_N_U64 : SInst<"vcvt_n_
 }
 
 

+// Scalar Floating-point Round to Integral
+let ArchGuard = "__ARM_ARCH >= 8 && defined(__ARM_FEATURE_DIRECTED_ROUNDING)" 
in {
+def SCALAR_FRINTN_S32 : SInst<"vrndn", "ss", "Sf">;
+}
+
+
 // Scalar Reduce Pairwise Addition (Scalar and Floating Point)
 def SCALAR_ADDP  : SInst<"vpadd", "sd", "SfSHlSHdSHUl">;
 

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=330012&r1=330011&r2=330012&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Apr 13 05:46:02 2018
@@ -5590,6 +5590,12 @@ Value *CodeGenFunction::EmitARMBuiltinEx
   case NEON::BI__builtin_neon_vgetq_lane_f32:
 return Builder.CreateExtractElement(Ops[0], Ops[1], "vget_lane");
 
+  case NEON::BI__builtin_neon_vrndns_f32: {
+Value *Arg = EmitScalarExpr(E->getArg(0));
+llvm::Type *Tys[] = {Arg->getType()};
+Function *F = CGM.getIntrinsic(Intrinsic::arm_neon_vrintn, Tys);
+return Builder.CreateCall(F, {Arg}, "vrndn"); }
+
   case NEON::BI__builtin_neon_vset_lane_i8:
   case NEON::BI__builtin_neon_vset_lane_i16:
   case NEON::BI__builtin_neon_vset_lane_i32:

Modified: cfe/trunk/test/CodeGen/arm-neon-directed-rounding.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-neon-directed-rounding.c?rev=330012&r1=330011&r2=330012&view=diff
==
--- cfe/trunk/test/CodeGen/arm-neon-directed-rounding.c (original)
+++ cfe/trunk/test/CodeGen/arm-neon-directed-rounding.c Fri Apr 13 05:46:02 2018
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a57 
-ffreestanding -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | 
FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a57 \
+// RUN: -ffreestanding -disable-O0-optnone -emit-llvm %s -o - | \
+// RUN: opt -S -mem2reg | FileCheck %s
 
 #include 
 
@@ -85,3 +87,10 @@ float32x2_t test_vrnd_f32(float32x2_t a)
 float32x4_t test_vrndq_f32(float32x4_t a) {
   return vrndq_f32(a);
 }
+
+// CHECK-LABEL: define float @test_vrndns_f32(float %a) #0 {
+// CHECK:   [[VRNDN_I:%.*]] = call float @llvm.arm.neon.vrintn.f32(float %a) #2
+// CHECK:   ret float [[VRNDN_I]]
+float32_t test_vrndns_f32(float32_t a) {
+  return vrndns_f32(a);
+}


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


[PATCH] D45515: [NEON] Support vrndns_f32 intrinsic

2018-04-13 Thread Ivan Kosarev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC330012: [NEON] Support vrndns_f32 intrinsic (authored by 
kosarev, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D45515

Files:
  include/clang/Basic/arm_neon.td
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/arm-neon-directed-rounding.c


Index: test/CodeGen/arm-neon-directed-rounding.c
===
--- test/CodeGen/arm-neon-directed-rounding.c
+++ test/CodeGen/arm-neon-directed-rounding.c
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a57 
-ffreestanding -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | 
FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a57 \
+// RUN: -ffreestanding -disable-O0-optnone -emit-llvm %s -o - | \
+// RUN: opt -S -mem2reg | FileCheck %s
 
 #include 
 
@@ -85,3 +87,10 @@
 float32x4_t test_vrndq_f32(float32x4_t a) {
   return vrndq_f32(a);
 }
+
+// CHECK-LABEL: define float @test_vrndns_f32(float %a) #0 {
+// CHECK:   [[VRNDN_I:%.*]] = call float @llvm.arm.neon.vrintn.f32(float %a) #2
+// CHECK:   ret float [[VRNDN_I]]
+float32_t test_vrndns_f32(float32_t a) {
+  return vrndns_f32(a);
+}
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -5590,6 +5590,12 @@
   case NEON::BI__builtin_neon_vgetq_lane_f32:
 return Builder.CreateExtractElement(Ops[0], Ops[1], "vget_lane");
 
+  case NEON::BI__builtin_neon_vrndns_f32: {
+Value *Arg = EmitScalarExpr(E->getArg(0));
+llvm::Type *Tys[] = {Arg->getType()};
+Function *F = CGM.getIntrinsic(Intrinsic::arm_neon_vrintn, Tys);
+return Builder.CreateCall(F, {Arg}, "vrndn"); }
+
   case NEON::BI__builtin_neon_vset_lane_i8:
   case NEON::BI__builtin_neon_vset_lane_i16:
   case NEON::BI__builtin_neon_vset_lane_i32:
Index: include/clang/Basic/arm_neon.td
===
--- include/clang/Basic/arm_neon.td
+++ include/clang/Basic/arm_neon.td
@@ -1116,6 +1116,12 @@
 }
 
 

+// Scalar Floating-point Round to Integral
+let ArchGuard = "__ARM_ARCH >= 8 && defined(__ARM_FEATURE_DIRECTED_ROUNDING)" 
in {
+def SCALAR_FRINTN_S32 : SInst<"vrndn", "ss", "Sf">;
+}
+
+
 // Scalar Reduce Pairwise Addition (Scalar and Floating Point)
 def SCALAR_ADDP  : SInst<"vpadd", "sd", "SfSHlSHdSHUl">;
 


Index: test/CodeGen/arm-neon-directed-rounding.c
===
--- test/CodeGen/arm-neon-directed-rounding.c
+++ test/CodeGen/arm-neon-directed-rounding.c
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a57 -ffreestanding -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a57 \
+// RUN: -ffreestanding -disable-O0-optnone -emit-llvm %s -o - | \
+// RUN: opt -S -mem2reg | FileCheck %s
 
 #include 
 
@@ -85,3 +87,10 @@
 float32x4_t test_vrndq_f32(float32x4_t a) {
   return vrndq_f32(a);
 }
+
+// CHECK-LABEL: define float @test_vrndns_f32(float %a) #0 {
+// CHECK:   [[VRNDN_I:%.*]] = call float @llvm.arm.neon.vrintn.f32(float %a) #2
+// CHECK:   ret float [[VRNDN_I]]
+float32_t test_vrndns_f32(float32_t a) {
+  return vrndns_f32(a);
+}
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -5590,6 +5590,12 @@
   case NEON::BI__builtin_neon_vgetq_lane_f32:
 return Builder.CreateExtractElement(Ops[0], Ops[1], "vget_lane");
 
+  case NEON::BI__builtin_neon_vrndns_f32: {
+Value *Arg = EmitScalarExpr(E->getArg(0));
+llvm::Type *Tys[] = {Arg->getType()};
+Function *F = CGM.getIntrinsic(Intrinsic::arm_neon_vrintn, Tys);
+return Builder.CreateCall(F, {Arg}, "vrndn"); }
+
   case NEON::BI__builtin_neon_vset_lane_i8:
   case NEON::BI__builtin_neon_vset_lane_i16:
   case NEON::BI__builtin_neon_vset_lane_i32:
Index: include/clang/Basic/arm_neon.td
===
--- include/clang/Basic/arm_neon.td
+++ include/clang/Basic/arm_neon.td
@@ -1116,6 +1116,12 @@
 }
 
 
+// Scalar Floating-point Round to Integral
+let ArchGuard = "__ARM_ARCH >= 8 && defined(__ARM_FEATURE_DIRECTED_ROUNDING)" in {
+def SCALAR_FRINTN_S32 : SInst<"vrndn", "ss", "Sf">;
+}
+
+
 // Scalar Reduce Pairwise Addition (Scalar and Floating Point)
 def SCALAR_ADDP  : SInst<"vpadd", "sd", "SfSHlSHdSHUl">;
 

[PATCH] D45619: [Time-report] (1) Use special new Clang flag 'FrontendTimesIsEnabled' instead of 'llvm::TimePassesIsEnabled' inside -ftime-report feature

2018-04-13 Thread Andrew V. Tischenko via Phabricator via cfe-commits
avt77 created this revision.
avt77 added reviewers: mgorny, russell.gallop, efriedma, rsmith, thakis, 
davezarzycki, RKSimon, simon.f.whittaker.

To simplify the review and commit of D43578  I 
decided to spilt it in several small parts.

This patch is the first part of the new series of patches. This patch 
introduces a dedicated boolean to deal with -ftime-report Clang switch (instead 
of 'llvm::TimePassesIsEnabled' which was LLVM dependent and potentionally could 
increase Clang compilation time).

Next patch will show usage of llvm::NamedRegionTimer instead of 
llvm::TimeRegion - it will really improve the generating output of the given 
feature.

Then I'll show the new class to deal with reqursive time counters (instead of 
approach shown in CodeGenAction.cpp).

And then we'll try new time counters (Preprocessor, Include Files, Parsing, 
Sema, CodeGen, etc.) The final list of counters will grow in dpendence of 
possible future requirements.

Finally, I'm going to introduce the feature which is similar to this one 
.

Hope, all these efforts could be interesting for many of us.


https://reviews.llvm.org/D45619

Files:
  include/clang/Frontend/Utils.h
  lib/Basic/CMakeLists.txt
  lib/Basic/FrontendTiming.cpp
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CodeGenAction.cpp
  test/Frontend/ftime-report-template-decl.cpp

Index: test/Frontend/ftime-report-template-decl.cpp
===
--- test/Frontend/ftime-report-template-decl.cpp
+++ test/Frontend/ftime-report-template-decl.cpp
@@ -0,0 +1,159 @@
+// RUN: %clang %s -S -o - -ftime-report  2>&1 | FileCheck %s
+// RUN: %clang %s -S -o - -fdelayed-template-parsing -DDELAYED_TEMPLATE_PARSING -ftime-report  2>&1 | FileCheck %s
+
+// Template function declarations
+template 
+void foo();
+template 
+void foo();
+
+// Template function definitions.
+template 
+void foo() {}
+
+// Template class (forward) declarations
+template 
+struct A;
+template 
+struct b;
+template 
+struct C;
+template 
+struct D;
+
+// Forward declarations with default parameters?
+template 
+class X1;
+template 
+class X2;
+
+// Forward declarations w/template template parameters
+template  class T>
+class TTP1;
+template  class>
+class TTP2;
+template  class T>
+class TTP5;
+
+// Forward declarations with non-type params
+template 
+class NTP0;
+template 
+class NTP1;
+template 
+class NTP2;
+template 
+class NTP3;
+template 
+class NTP4;
+template 
+class NTP5;
+template 
+class NTP6;
+template 
+class NTP7;
+
+// Template class declarations
+template 
+struct A {};
+template 
+struct B {};
+
+namespace PR6184 {
+namespace N {
+template 
+void bar(typename T::x);
+}
+
+template 
+void N::bar(typename T::x) {}
+}
+
+// This PR occurred only in template parsing mode.
+namespace PR17637 {
+template 
+struct L {
+  template 
+  struct O {
+template 
+static void Fun(U);
+  };
+};
+
+template 
+template 
+template 
+void L::O::Fun(U) {}
+
+void Instantiate() { L<0>::O::Fun(0); }
+}
+
+namespace explicit_partial_specializations {
+typedef char (&oneT)[1];
+typedef char (&twoT)[2];
+typedef char (&threeT)[3];
+typedef char (&fourT)[4];
+typedef char (&fiveT)[5];
+typedef char (&sixT)[6];
+
+char one[1];
+char two[2];
+char three[3];
+char four[4];
+char five[5];
+char six[6];
+
+template 
+struct bool_ { typedef int type; };
+template <>
+struct bool_ {};
+
+#define XCAT(x, y) x##y
+#define CAT(x, y) XCAT(x, y)
+#define sassert(_b_) bool_<(_b_)>::type CAT(var, __LINE__);
+
+template 
+struct L {
+  template 
+  struct O {
+template 
+static oneT Fun(U);
+  };
+};
+template 
+template 
+template 
+oneT L::O::Fun(U) { return one; }
+
+template <>
+template <>
+template 
+oneT L<0>::O::Fun(U) { return one; }
+
+void Instantiate() {
+  sassert(sizeof(L<0>::O::Fun(0)) == sizeof(one));
+  sassert(sizeof(L<0>::O::Fun(0)) == sizeof(one));
+}
+}
+
+template 
+struct Foo {
+  template 
+  using rebind_alloc = _Other;
+};
+template 
+struct _Wrap_alloc {
+  template 
+  using rebind_alloc = typename Foo<_Alloc>::template rebind_alloc<_Other>;
+  template 
+  using rebind = _Wrap_alloc;
+};
+_Wrap_alloc::rebind w;
+
+// CHECK: Miscellaneous Ungrouped Timers
+// CHECK: Code Generation Time
+// CHECK: LLVM IR Generation Time
+// CHECK: Total
+// CHECK: Clang front-end time report
+// CHECK: Clang front-end timer
+// CHECK: Total
Index: lib/CodeGen/CodeGenAction.cpp
===
--- lib/CodeGen/CodeGenAction.cpp
+++ lib/CodeGen/CodeGenAction.cpp
@@ -126,7 +126,7 @@
   Gen(CreateLLVMCodeGen(Diags, InFile, HeaderSearchOpts, PPOpts,
 CodeGenOpts, C, CoverageInfo)),
   LinkModules(std::move(LinkModules)) {
-  llvm::TimePassesIsEnabled = TimePasses;
+  FrontendTimesIsEnabled = TimePasses;
 }
 llvm::Module *getModule() cons

r329995 - [X86] Fix cldemote builtin signature

2018-04-13 Thread Gabor Buella via cfe-commits
Author: gbuella
Date: Fri Apr 13 01:14:21 2018
New Revision: 329995

URL: http://llvm.org/viewvc/llvm-project?rev=329995&view=rev
Log:
[X86] Fix cldemote builtin signature

Fix for r329993

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=329995&r1=329994&r2=329995&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Fri Apr 13 01:14:21 2018
@@ -1884,7 +1884,7 @@ TARGET_BUILTIN(__builtin_ia32_mwaitx, "v
 TARGET_BUILTIN(__builtin_ia32_clzero, "vv*", "", "clzero")
 
 // CLDEMOTE
-TARGET_BUILTIN(__builtin_ia32_cldemote, "vCv*", "", "cldemote")
+TARGET_BUILTIN(__builtin_ia32_cldemote, "vvC*", "", "cldemote")
 
 // MSVC
 TARGET_HEADER_BUILTIN(_BitScanForward, "UcUNi*UNi", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")


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


r329993 - [X86] Introduce cldemote intrinsic

2018-04-13 Thread Gabor Buella via cfe-commits
Author: gbuella
Date: Fri Apr 13 00:37:24 2018
New Revision: 329993

URL: http://llvm.org/viewvc/llvm-project?rev=329993&view=rev
Log:
[X86] Introduce cldemote intrinsic

Reviewers: craig.topper, zvi

Reviewed By: craig.topper

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

Added:
cfe/trunk/lib/Headers/cldemoteintrin.h   (with props)
cfe/trunk/test/CodeGen/cldemote.c   (with props)
Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Basic/Targets/X86.cpp
cfe/trunk/lib/Basic/Targets/X86.h
cfe/trunk/lib/Headers/CMakeLists.txt
cfe/trunk/lib/Headers/cpuid.h
cfe/trunk/lib/Headers/x86intrin.h
cfe/trunk/test/CodeGen/builtins-x86.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=329993&r1=329992&r2=329993&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Fri Apr 13 00:37:24 2018
@@ -1883,6 +1883,9 @@ TARGET_BUILTIN(__builtin_ia32_mwaitx, "v
 // CLZERO
 TARGET_BUILTIN(__builtin_ia32_clzero, "vv*", "", "clzero")
 
+// CLDEMOTE
+TARGET_BUILTIN(__builtin_ia32_cldemote, "vCv*", "", "cldemote")
+
 // MSVC
 TARGET_HEADER_BUILTIN(_BitScanForward, "UcUNi*UNi", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(_BitScanReverse, "UcUNi*UNi", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=329993&r1=329992&r2=329993&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri Apr 13 00:37:24 2018
@@ -2599,6 +2599,8 @@ def mbmi : Flag<["-"], "mbmi">, Group, Group;
 def mbmi2 : Flag<["-"], "mbmi2">, Group;
 def mno_bmi2 : Flag<["-"], "mno-bmi2">, Group;
+def mcldemote : Flag<["-"], "mcldemote">, Group;
+def mno_cldemote : Flag<["-"], "mno-cldemote">, Group;
 def mclflushopt : Flag<["-"], "mclflushopt">, Group;
 def mno_clflushopt : Flag<["-"], "mno-clflushopt">, 
Group;
 def mclwb : Flag<["-"], "mclwb">, Group;

Modified: cfe/trunk/lib/Basic/Targets/X86.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.cpp?rev=329993&r1=329992&r2=329993&view=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/X86.cpp Fri Apr 13 00:37:24 2018
@@ -800,6 +800,8 @@ bool X86TargetInfo::handleTargetFeatures
   HasPREFETCHWT1 = true;
 } else if (Feature == "+clzero") {
   HasCLZERO = true;
+} else if (Feature == "+cldemote") {
+  HasCLDEMOTE = true;
 } else if (Feature == "+rdpid") {
   HasRDPID = true;
 } else if (Feature == "+retpoline") {
@@ -1154,6 +1156,8 @@ void X86TargetInfo::getTargetDefines(con
 Builder.defineMacro("__CLZERO__");
   if (HasRDPID)
 Builder.defineMacro("__RDPID__");
+  if (HasCLDEMOTE)
+Builder.defineMacro("__CLDEMOTE__");
 
   // Each case falls through to the previous one here.
   switch (SSELevel) {
@@ -1263,6 +1267,7 @@ bool X86TargetInfo::isValidFeatureName(S
   .Case("avx512ifma", true)
   .Case("bmi", true)
   .Case("bmi2", true)
+  .Case("cldemote", true)
   .Case("clflushopt", true)
   .Case("clwb", true)
   .Case("clzero", true)
@@ -1334,6 +1339,7 @@ bool X86TargetInfo::hasFeature(StringRef
   .Case("avx512ifma", HasAVX512IFMA)
   .Case("bmi", HasBMI)
   .Case("bmi2", HasBMI2)
+  .Case("cldemote", HasCLDEMOTE)
   .Case("clflushopt", HasCLFLUSHOPT)
   .Case("clwb", HasCLWB)
   .Case("clzero", HasCLZERO)

Modified: cfe/trunk/lib/Basic/Targets/X86.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.h?rev=329993&r1=329992&r2=329993&view=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.h (original)
+++ cfe/trunk/lib/Basic/Targets/X86.h Fri Apr 13 00:37:24 2018
@@ -91,6 +91,7 @@ class LLVM_LIBRARY_VISIBILITY X86TargetI
   bool HasXSAVES = false;
   bool HasMWAITX = false;
   bool HasCLZERO = false;
+  bool HasCLDEMOTE = false;
   bool HasPKU = false;
   bool HasCLFLUSHOPT = false;
   bool HasCLWB = false;

Modified: cfe/trunk/lib/Headers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/CMakeLists.txt?rev=329993&r1=329992&r2=329993&view=diff
==
--- cfe/trunk/lib/Headers/CMakeLists.txt (original)
+++ cfe/trunk/lib/Headers/CMakeLists.txt Fri Apr 13 00:37:24 2018
@@ -40,6 +40,7 @@ set(files
   __clang_cuda_math_forward_declares.h
   __clang_cuda_runtime_wrapper.h

[PATCH] D45615: [builtins] __builtin_dump_struct : added more types format

2018-04-13 Thread Paul Semel via Phabricator via cfe-commits
paulsemel added a comment.

In https://reviews.llvm.org/D45615#1067068, @aaron.ballman wrote:

> In https://reviews.llvm.org/D45615#1066975, @paulsemel wrote:
>
> > In https://reviews.llvm.org/D45615#1066973, @lebedev.ri wrote:
> >
> > > Tests?
> >
> >
> > I can do this. But currently, I am not testing the formats in the tests..
>
>
> Now might be a good time to test that, because this patch almost added a bug 
> by missing the length modifiers. Also, all patches should come with some 
> tests to demonstrate the behavioral differences from the current trunk.


Sure. I will do another review for the existing format testing, and then go 
back to this one to finish the type handling !


Repository:
  rC Clang

https://reviews.llvm.org/D45615



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


[PATCH] D45620: [clangd][tests] Fix handling of EOF in delimited input

2018-04-13 Thread Jan Korous via Phabricator via cfe-commits
jkorous-apple created this revision.
Herald added subscribers: cfe-commits, MaskRay, ioeric, ilya-biryukov.

Request in delimited input ended by EOF shouldn't be an error state.
Comments should be allowed at the end of test files.
Input mirroring should work for the last request in delimited test file.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45620

Files:
  JSONRPCDispatcher.cpp
  clangd/delimited-input-comment-at-the-end.test


Index: clangd/delimited-input-comment-at-the-end.test
===
--- /dev/null
+++ clangd/delimited-input-comment-at-the-end.test
@@ -0,0 +1,12 @@
+# RUN: clangd -input-style=delimited -run-synchronously -input-mirror-file %t 
< %s
+# RUN: grep '{"jsonrpc":"2.0","id":3,"method":"exit"}' %t
+#
+# RUN: clangd -lit-test -input-mirror-file %t < %s
+# RUN: grep '{"jsonrpc":"2.0","id":3,"method":"exit"}' %t
+#
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+---
+{"jsonrpc":"2.0","id":3,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","id":3,"method":"exit"}
+# comment at the end
Index: JSONRPCDispatcher.cpp
===
--- JSONRPCDispatcher.cpp
+++ JSONRPCDispatcher.cpp
@@ -277,21 +277,19 @@
 if (LineRef.startswith("#")) // comment
   continue;
 
-bool IsDelim = LineRef.find_first_not_of('-') == llvm::StringRef::npos;
-if (!IsDelim) // Line is part of a JSON message.
-  JSON += Line;
-if (IsDelim) {
-  Out.mirrorInput(
-  llvm::formatv("Content-Length: {0}\r\n\r\n{1}", JSON.size(), JSON));
-  return std::move(JSON);
-}
+// found a delimiter
+if (LineRef.find_first_not_of('-') == llvm::StringRef::npos)
+  break;
+
+JSON += Line;
   }
 
   if (In.bad()) {
 log("Input error while reading message!");
 return llvm::None;
   } else {
-log("Input message terminated by EOF");
+Out.mirrorInput(
+llvm::formatv("Content-Length: {0}\r\n\r\n{1}", JSON.size(), JSON));
 return std::move(JSON);
   }
 }


Index: clangd/delimited-input-comment-at-the-end.test
===
--- /dev/null
+++ clangd/delimited-input-comment-at-the-end.test
@@ -0,0 +1,12 @@
+# RUN: clangd -input-style=delimited -run-synchronously -input-mirror-file %t < %s
+# RUN: grep '{"jsonrpc":"2.0","id":3,"method":"exit"}' %t
+#
+# RUN: clangd -lit-test -input-mirror-file %t < %s
+# RUN: grep '{"jsonrpc":"2.0","id":3,"method":"exit"}' %t
+#
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+---
+{"jsonrpc":"2.0","id":3,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","id":3,"method":"exit"}
+# comment at the end
Index: JSONRPCDispatcher.cpp
===
--- JSONRPCDispatcher.cpp
+++ JSONRPCDispatcher.cpp
@@ -277,21 +277,19 @@
 if (LineRef.startswith("#")) // comment
   continue;
 
-bool IsDelim = LineRef.find_first_not_of('-') == llvm::StringRef::npos;
-if (!IsDelim) // Line is part of a JSON message.
-  JSON += Line;
-if (IsDelim) {
-  Out.mirrorInput(
-  llvm::formatv("Content-Length: {0}\r\n\r\n{1}", JSON.size(), JSON));
-  return std::move(JSON);
-}
+// found a delimiter
+if (LineRef.find_first_not_of('-') == llvm::StringRef::npos)
+  break;
+
+JSON += Line;
   }
 
   if (In.bad()) {
 log("Input error while reading message!");
 return llvm::None;
   } else {
-log("Input message terminated by EOF");
+Out.mirrorInput(
+llvm::formatv("Content-Length: {0}\r\n\r\n{1}", JSON.size(), JSON));
 return std::move(JSON);
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45601: Warn on bool* to bool conversion

2018-04-13 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In https://reviews.llvm.org/D45601#1067057, @aaron.ballman wrote:

> ...
>  This makes me wary of making this a compiler diagnostic, but clang-tidy may 
> still be a reasonable place for this functionality to live.




In https://reviews.llvm.org/D45601#1066572, @Eugene.Zelenko wrote:

> There is Clang-tidy's readability-implicit-bool-conversion 
> 
>  check.



https://reviews.llvm.org/D45601



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


[PATCH] D45621: [clangd][tests] Fix delimiter handling

2018-04-13 Thread Jan Korous via Phabricator via cfe-commits
jkorous-apple created this revision.
jkorous-apple added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, MaskRay, ioeric, ilya-biryukov.
jkorous-apple edited the summary of this revision.

Empty line shouldn't be considered a delimiter

Following
https://reviews.llvm.org/D45620


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45621

Files:
  JSONRPCDispatcher.cpp
  clangd/spaces-in-delimited-input.test


Index: clangd/spaces-in-delimited-input.test
===
--- /dev/null
+++ clangd/spaces-in-delimited-input.test
@@ -0,0 +1,13 @@
+# RUN: clangd -input-style=delimited -run-synchronously < %s 2>&1 | FileCheck 
%s
+# RUN: clangd -lit-test -run-synchronously < %s 2>&1 | FileCheck %s
+#
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+---
+
+{"jsonrpc":"2.0","id":3,"method":"shutdown"}
+
+---
+
+{"jsonrpc":"2.0","id":3,"method":"exit"}
+# CHECK-NOT: JSON parse error
Index: JSONRPCDispatcher.cpp
===
--- JSONRPCDispatcher.cpp
+++ JSONRPCDispatcher.cpp
@@ -278,7 +278,7 @@
   continue;
 
 // found a delimiter
-if (LineRef.find_first_not_of('-') == llvm::StringRef::npos)
+if (LineRef.rtrim() == "---")
   break;
 
 JSON += Line;


Index: clangd/spaces-in-delimited-input.test
===
--- /dev/null
+++ clangd/spaces-in-delimited-input.test
@@ -0,0 +1,13 @@
+# RUN: clangd -input-style=delimited -run-synchronously < %s 2>&1 | FileCheck %s
+# RUN: clangd -lit-test -run-synchronously < %s 2>&1 | FileCheck %s
+#
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+---
+
+{"jsonrpc":"2.0","id":3,"method":"shutdown"}
+
+---
+
+{"jsonrpc":"2.0","id":3,"method":"exit"}
+# CHECK-NOT: JSON parse error
Index: JSONRPCDispatcher.cpp
===
--- JSONRPCDispatcher.cpp
+++ JSONRPCDispatcher.cpp
@@ -278,7 +278,7 @@
   continue;
 
 // found a delimiter
-if (LineRef.find_first_not_of('-') == llvm::StringRef::npos)
+if (LineRef.rtrim() == "---")
   break;
 
 JSON += Line;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44203: [clang-format] Improve Incomplete detection for (text) protos

2018-04-13 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 142394.
krasimir marked an inline comment as done.
krasimir added a comment.

- Address review comments


Repository:
  rC Clang

https://reviews.llvm.org/D44203

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestProto.cpp
  unittests/Format/FormatTestTextProto.cpp

Index: unittests/Format/FormatTestTextProto.cpp
===
--- unittests/Format/FormatTestTextProto.cpp
+++ unittests/Format/FormatTestTextProto.cpp
@@ -19,12 +19,20 @@
 
 class FormatTestTextProto : public ::testing::Test {
 protected:
+  enum StatusCheck { SC_ExpectComplete, SC_ExpectIncomplete };
+
   static std::string format(llvm::StringRef Code, unsigned Offset,
-unsigned Length, const FormatStyle &Style) {
+unsigned Length, const FormatStyle &Style,
+StatusCheck CheckComplete = SC_ExpectComplete) {
 DEBUG(llvm::errs() << "---\n");
 DEBUG(llvm::errs() << Code << "\n\n");
 std::vector Ranges(1, tooling::Range(Offset, Length));
-tooling::Replacements Replaces = reformat(Style, Code, Ranges);
+FormattingAttemptStatus Status;
+tooling::Replacements Replaces =
+reformat(Style, Code, Ranges, "", &Status);
+bool ExpectedCompleteFormat = CheckComplete == SC_ExpectComplete;
+EXPECT_EQ(ExpectedCompleteFormat, Status.FormatComplete)
+<< Code << "\n\n";
 auto Result = applyAllReplacements(Code, Replaces);
 EXPECT_TRUE(static_cast(Result));
 DEBUG(llvm::errs() << "\n" << *Result << "\n\n");
@@ -45,6 +53,12 @@
 Style.ColumnLimit = 60; // To make writing tests easier.
 verifyFormat(Code, Style);
   }
+
+  static void verifyIncompleteFormat(llvm::StringRef Code) {
+FormatStyle Style = getGoogleStyle(FormatStyle::LK_TextProto);
+EXPECT_EQ(Code.str(),
+  format(Code, 0, Code.size(), Style, SC_ExpectIncomplete));
+  }
 };
 
 TEST_F(FormatTestTextProto, KeepsTopLevelEntriesFittingALine) {
@@ -495,5 +509,38 @@
"}", Style);
 }
 
+TEST_F(FormatTestTextProto, IncompleteFormat) {
+  verifyIncompleteFormat("data {");
+  verifyIncompleteFormat("data <");
+  verifyIncompleteFormat("data [");
+  verifyIncompleteFormat("data: {");
+  verifyIncompleteFormat("data: <");
+  verifyIncompleteFormat("data: [");
+  verifyIncompleteFormat("key:");
+  verifyIncompleteFormat("key:}");
+  verifyIncompleteFormat("key: ]");
+  verifyIncompleteFormat("key: >");
+  verifyIncompleteFormat(": value");
+  verifyIncompleteFormat(": {}");
+  verifyIncompleteFormat(": <>");
+  verifyIncompleteFormat(": []");
+  verifyIncompleteFormat("}\n"
+ "key: value");
+  verifyIncompleteFormat("]\n"
+ "key: value");
+  verifyIncompleteFormat("> key: value");
+  verifyIncompleteFormat("data { key: {");
+  verifyIncompleteFormat("data < key: [");
+  verifyIncompleteFormat("data [ key: {");
+  verifyIncompleteFormat("> key: value {");
+  verifyIncompleteFormat("> key: [");
+  verifyIncompleteFormat("}\n"
+ "key: {");
+  verifyIncompleteFormat("data { key: 1 id:");
+  verifyIncompleteFormat("}\n"
+ "key {");
+  verifyIncompleteFormat("> <");
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: unittests/Format/FormatTestProto.cpp
===
--- unittests/Format/FormatTestProto.cpp
+++ unittests/Format/FormatTestProto.cpp
@@ -18,13 +18,21 @@
 namespace format {
 
 class FormatTestProto : public ::testing::Test {
+  enum StatusCheck { SC_ExpectComplete, SC_ExpectIncomplete };
+
 protected:
   static std::string format(llvm::StringRef Code, unsigned Offset,
-unsigned Length, const FormatStyle &Style) {
+unsigned Length, const FormatStyle &Style,
+StatusCheck CheckComplete = SC_ExpectComplete) {
 DEBUG(llvm::errs() << "---\n");
 DEBUG(llvm::errs() << Code << "\n\n");
 std::vector Ranges(1, tooling::Range(Offset, Length));
-tooling::Replacements Replaces = reformat(Style, Code, Ranges);
+FormattingAttemptStatus Status;
+tooling::Replacements Replaces =
+reformat(Style, Code, Ranges, "", &Status);
+bool ExpectedCompleteFormat = CheckComplete == SC_ExpectComplete;
+EXPECT_EQ(ExpectedCompleteFormat, Status.FormatComplete)
+<< Code << "\n\n";
 auto Result = applyAllReplacements(Code, Replaces);
 EXPECT_TRUE(static_cast(Result));
 DEBUG(llvm::errs() << "\n" << *Result << "\n\n");
@@ -41,6 +49,12 @@
 EXPECT_EQ(Code.str(), format(Code)) << "Expected code is not stable";
 EXPECT_EQ(Code.str(), format(test::messUp(Code)));
   }
+
+  static void verifyIncompleteFormat(llvm::StringRef Code) {
+FormatStyle Style = getGoogleStyle(FormatStyle::LK_Proto);
+EXPECT_EQ(Code.str(),
+  format(Code, 0,

[PATCH] D44203: [clang-format] Improve Incomplete detection for (text) protos

2018-04-13 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC330016: [clang-format] Improve Incomplete detection for 
(text) protos (authored by krasimir, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44203?vs=142394&id=142396#toc

Repository:
  rC Clang

https://reviews.llvm.org/D44203

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestProto.cpp
  unittests/Format/FormatTestTextProto.cpp

Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -592,7 +592,8 @@
   return false;
   }
 }
-return true;
+// There are no top-level unbalanced braces in text protos.
+return Style.Language != FormatStyle::LK_TextProto;
   }
 
   void updateParameterCount(FormatToken *Left, FormatToken *Current) {
@@ -712,6 +713,11 @@
   } else if (Contexts.back().ContextKind == tok::l_paren) {
 Tok->Type = TT_InlineASMColon;
   }
+  // Detects trailing pieces like key:
+  if ((Style.Language == FormatStyle::LK_Proto ||
+   Style.Language == FormatStyle::LK_TextProto) &&
+  !CurrentToken)
+return false;
   break;
 case tok::pipe:
 case tok::amp:
@@ -798,6 +804,10 @@
   if (Previous && Previous->Type != TT_DictLiteral)
 Previous->Type = TT_SelectorName;
 }
+  } else if (Style.Language == FormatStyle::LK_TextProto ||
+ Style.Language == FormatStyle::LK_Proto) {
+// In TT_Proto and TT_TextProto, tok::less cannot be a binary operator.
+return false;
   } else {
 Tok->Type = TT_BinaryOperator;
 NonTemplateLess.insert(Tok);
@@ -809,13 +819,16 @@
 case tok::r_square:
   return false;
 case tok::r_brace:
-  // Lines can start with '}'.
-  if (Tok->Previous)
+  // Lines can start with '}' except in text protos.
+  if (Tok->Previous || Style.Language == FormatStyle::LK_TextProto)
 return false;
   break;
 case tok::greater:
-  if (Style.Language != FormatStyle::LK_TextProto)
-Tok->Type = TT_BinaryOperator;
+  // In protos and text protos tok::greater cannot be a binary operator.
+  if (Style.Language == FormatStyle::LK_Proto ||
+  Style.Language == FormatStyle::LK_TextProto)
+return false;
+  Tok->Type = TT_BinaryOperator;
   break;
 case tok::kw_operator:
   if (Style.Language == FormatStyle::LK_TextProto ||
Index: unittests/Format/FormatTestTextProto.cpp
===
--- unittests/Format/FormatTestTextProto.cpp
+++ unittests/Format/FormatTestTextProto.cpp
@@ -19,12 +19,20 @@
 
 class FormatTestTextProto : public ::testing::Test {
 protected:
+  enum StatusCheck { SC_ExpectComplete, SC_ExpectIncomplete };
+
   static std::string format(llvm::StringRef Code, unsigned Offset,
-unsigned Length, const FormatStyle &Style) {
+unsigned Length, const FormatStyle &Style,
+StatusCheck CheckComplete = SC_ExpectComplete) {
 DEBUG(llvm::errs() << "---\n");
 DEBUG(llvm::errs() << Code << "\n\n");
 std::vector Ranges(1, tooling::Range(Offset, Length));
-tooling::Replacements Replaces = reformat(Style, Code, Ranges);
+FormattingAttemptStatus Status;
+tooling::Replacements Replaces =
+reformat(Style, Code, Ranges, "", &Status);
+bool ExpectedCompleteFormat = CheckComplete == SC_ExpectComplete;
+EXPECT_EQ(ExpectedCompleteFormat, Status.FormatComplete)
+<< Code << "\n\n";
 auto Result = applyAllReplacements(Code, Replaces);
 EXPECT_TRUE(static_cast(Result));
 DEBUG(llvm::errs() << "\n" << *Result << "\n\n");
@@ -45,6 +53,12 @@
 Style.ColumnLimit = 60; // To make writing tests easier.
 verifyFormat(Code, Style);
   }
+
+  static void verifyIncompleteFormat(llvm::StringRef Code) {
+FormatStyle Style = getGoogleStyle(FormatStyle::LK_TextProto);
+EXPECT_EQ(Code.str(),
+  format(Code, 0, Code.size(), Style, SC_ExpectIncomplete));
+  }
 };
 
 TEST_F(FormatTestTextProto, KeepsTopLevelEntriesFittingALine) {
@@ -495,5 +509,38 @@
"}", Style);
 }
 
+TEST_F(FormatTestTextProto, IncompleteFormat) {
+  verifyIncompleteFormat("data {");
+  verifyIncompleteFormat("data <");
+  verifyIncompleteFormat("data [");
+  verifyIncompleteFormat("data: {");
+  verifyIncompleteFormat("data: <");
+  verifyIncompleteFormat("data: [");
+  verifyIncompleteFormat("key:");
+  verifyIncompleteFormat("key:}");
+  verifyIncompleteFormat("key: ]");
+  verifyIncompleteFormat("key: >");
+  verifyIncompleteFormat(": value");
+  verifyIncompleteFormat(": {}");
+  verifyIncompleteFormat(": <>");
+  verifyIncompleteFormat(": []");
+  verifyIncompleteFormat("}\n"
+ "key: value");
+  veri

r330016 - [clang-format] Improve Incomplete detection for (text) protos

2018-04-13 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Fri Apr 13 06:37:09 2018
New Revision: 330016

URL: http://llvm.org/viewvc/llvm-project?rev=330016&view=rev
Log:
[clang-format] Improve Incomplete detection for (text) protos

Summary:
This patch improves detection of incomplete code for protos and text protos.
This is especially important for text protos in raw string literals, since they
might be partial strings concatenated, and we'd like to disable formatting in
these cases.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestProto.cpp
cfe/trunk/unittests/Format/FormatTestTextProto.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=330016&r1=330015&r2=330016&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Apr 13 06:37:09 2018
@@ -592,7 +592,8 @@ private:
   return false;
   }
 }
-return true;
+// There are no top-level unbalanced braces in text protos.
+return Style.Language != FormatStyle::LK_TextProto;
   }
 
   void updateParameterCount(FormatToken *Left, FormatToken *Current) {
@@ -712,6 +713,11 @@ private:
   } else if (Contexts.back().ContextKind == tok::l_paren) {
 Tok->Type = TT_InlineASMColon;
   }
+  // Detects trailing pieces like key:
+  if ((Style.Language == FormatStyle::LK_Proto ||
+   Style.Language == FormatStyle::LK_TextProto) &&
+  !CurrentToken)
+return false;
   break;
 case tok::pipe:
 case tok::amp:
@@ -798,6 +804,10 @@ private:
   if (Previous && Previous->Type != TT_DictLiteral)
 Previous->Type = TT_SelectorName;
 }
+  } else if (Style.Language == FormatStyle::LK_TextProto ||
+ Style.Language == FormatStyle::LK_Proto) {
+// In TT_Proto and TT_TextProto, tok::less cannot be a binary operator.
+return false;
   } else {
 Tok->Type = TT_BinaryOperator;
 NonTemplateLess.insert(Tok);
@@ -809,13 +819,16 @@ private:
 case tok::r_square:
   return false;
 case tok::r_brace:
-  // Lines can start with '}'.
-  if (Tok->Previous)
+  // Lines can start with '}' except in text protos.
+  if (Tok->Previous || Style.Language == FormatStyle::LK_TextProto)
 return false;
   break;
 case tok::greater:
-  if (Style.Language != FormatStyle::LK_TextProto)
-Tok->Type = TT_BinaryOperator;
+  // In protos and text protos tok::greater cannot be a binary operator.
+  if (Style.Language == FormatStyle::LK_Proto ||
+  Style.Language == FormatStyle::LK_TextProto)
+return false;
+  Tok->Type = TT_BinaryOperator;
   break;
 case tok::kw_operator:
   if (Style.Language == FormatStyle::LK_TextProto ||

Modified: cfe/trunk/unittests/Format/FormatTestProto.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestProto.cpp?rev=330016&r1=330015&r2=330016&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestProto.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestProto.cpp Fri Apr 13 06:37:09 2018
@@ -18,13 +18,21 @@ namespace clang {
 namespace format {
 
 class FormatTestProto : public ::testing::Test {
+  enum StatusCheck { SC_ExpectComplete, SC_ExpectIncomplete };
+
 protected:
   static std::string format(llvm::StringRef Code, unsigned Offset,
-unsigned Length, const FormatStyle &Style) {
+unsigned Length, const FormatStyle &Style,
+StatusCheck CheckComplete = SC_ExpectComplete) {
 DEBUG(llvm::errs() << "---\n");
 DEBUG(llvm::errs() << Code << "\n\n");
 std::vector Ranges(1, tooling::Range(Offset, Length));
-tooling::Replacements Replaces = reformat(Style, Code, Ranges);
+FormattingAttemptStatus Status;
+tooling::Replacements Replaces =
+reformat(Style, Code, Ranges, "", &Status);
+bool ExpectedCompleteFormat = CheckComplete == SC_ExpectComplete;
+EXPECT_EQ(ExpectedCompleteFormat, Status.FormatComplete)
+<< Code << "\n\n";
 auto Result = applyAllReplacements(Code, Replaces);
 EXPECT_TRUE(static_cast(Result));
 DEBUG(llvm::errs() << "\n" << *Result << "\n\n");
@@ -41,6 +49,12 @@ protected:
 EXPECT_EQ(Code.str(), format(Code)) << "Expected code is not stable";
 EXPECT_EQ(Code.str(), format(test::messUp(Code)));
   }
+
+  static void verifyIncompleteFormat(llvm::StringRef Code) {
+FormatStyle Style = getGoogleStyle(FormatStyle::LK_Proto);
+EXPECT_EQ(Code.str(),
+  format(Code, 0, Code.size(), 

[PATCH] D44203: [clang-format] Improve Incomplete detection for (text) protos

2018-04-13 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: lib/Format/TokenAnnotator.cpp:773
 case tok::r_brace:
-  // Lines can start with '}'.
-  if (Tok->Previous)
+  // Lines can start with '}' except in text protos.
+  if (Tok->Previous || Style.Language == FormatStyle::LK_TextProto)

sammccall wrote:
> krasimir wrote:
> > sammccall wrote:
> > > In what sense of "line" is this true?
> > This is the UnwrappedLine concept of clang-format: roughly a maximal 
> > sequence of tokens that we could have put on the same line if there was no 
> > column limit.
> I still don't understand why it's true for say C or JS then.
> (kinda relevant here because I would like to understand why proto is an 
> exception)
In C++ stuff like global functions or namespaces result in multiple unwrapped 
lines, like:
```
line 1: namespace a {
line 2: int x = 3;
line 3: }
```

In text protos, the top-level essentially can only contain key-value pairs, 
where the value can be a submessage, which is like an init list, which is put 
on a single unwrapped line, like:
```
line 1: key: { item: data }
```

I don't know too much more about why this is the case.



Comment at: unittests/Format/FormatTestProto.cpp:21
 class FormatTestProto : public ::testing::Test {
+  enum StatusCheck { SC_ExpectComplete, SC_ExpectIncomplete, SC_DoNotCheck };
+

sammccall wrote:
> sammccall wrote:
> > DoNotCheck is never used, consider removing it
> (nit: is the SC_ prefix really needed in tests?)
The `SC_` prefix is consistent with other test files here, like:
https://github.com/llvm-mirror/clang/blob/456e35cbb384bd7fb97cf995163fd9d17e319b77/unittests/Format/FormatTest.cpp#L34


Repository:
  rC Clang

https://reviews.llvm.org/D44203



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


[PATCH] D45160: [clang-apply-replacements] Make clang-apply-replacements installable

2018-04-13 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis added a comment.

Gentle ping.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45160



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


[PATCH] D17741: adds __FILE_BASENAME__ builtin macro

2018-04-13 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith requested changes to this revision.
dexonsmith added a comment.
This revision now requires changes to proceed.

Hal requested splitting the patch in two, since the two features are separable, 
but they both still seem to be here.  Perhaps start with the prefix patch?




Comment at: include/clang/Driver/Options.td:828
 
+def FILE_prefix_to_remove : Joined<["-"], "ffile-macro-prefix-to-remove=">,
+  Group, Flags<[DriverOption, CC1Option]>,

This opt name doesn’t match the command line option. 



Comment at: include/clang/Driver/Options.td:831
+  HelpText<"prefix to be removed from expanded string of __FILE__ macro">;
+def FILE_basename_only : Flag <["-"], "ffile-macro-basename-only">,
+  Group, Flags<[DriverOption, CC1Option]>,

Same here. 



Comment at: include/clang/Lex/PreprocessorOptions.h:122
+  /// matches the prefix of __FILE__, the matched part won't be expanded.
+  std::string __FILE__PrefixToRemove;
+

This identifier name is reserved for the implementation.



Comment at: include/clang/Lex/PreprocessorOptions.h:126
+  /// basename part of __FILE__ will be expanded.
+  bool __FILE__BasenameOnly;
+

Same here. 



Comment at: lib/Lex/PPMacroExpansion.cpp:1608
 if (PLoc.isValid()) {
-  FN += PLoc.getFilename();
+  StringRef Filename(PLoc.getFilename());
+  if (II == Ident__FILE__) {

Why not use =?


https://reviews.llvm.org/D17741



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


[PATCH] D44882: [clangd] Implementation of workspace/symbol request

2018-04-13 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle updated this revision to Diff 142403.
malaperle marked 2 inline comments as done.
malaperle added a comment.

Address comments. Simplify with using line/col from index.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44882

Files:
  clangd/CMakeLists.txt
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/FindSymbols.cpp
  clangd/FindSymbols.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  clangd/SourceCode.cpp
  clangd/SourceCode.h
  clangd/XRefs.cpp
  clangd/index/SymbolCollector.cpp
  clangd/tool/ClangdMain.cpp
  test/clangd/initialize-params-invalid.test
  test/clangd/initialize-params.test
  test/clangd/symbols.test
  unittests/clangd/CMakeLists.txt
  unittests/clangd/FindSymbolsTests.cpp
  unittests/clangd/SyncAPI.cpp
  unittests/clangd/SyncAPI.h

Index: unittests/clangd/SyncAPI.h
===
--- unittests/clangd/SyncAPI.h
+++ unittests/clangd/SyncAPI.h
@@ -41,6 +41,10 @@
 
 std::string runDumpAST(ClangdServer &Server, PathRef File);
 
+llvm::Expected>
+runWorkspaceSymbols(ClangdServer &Server, StringRef Query, int Limit,
+const DraftStore &DS);
+
 } // namespace clangd
 } // namespace clang
 
Index: unittests/clangd/SyncAPI.cpp
===
--- unittests/clangd/SyncAPI.cpp
+++ unittests/clangd/SyncAPI.cpp
@@ -110,5 +110,13 @@
   return std::move(*Result);
 }
 
+llvm::Expected>
+runWorkspaceSymbols(ClangdServer &Server, StringRef Query, int Limit,
+const DraftStore &DS) {
+  llvm::Optional>> Result;
+  Server.workspaceSymbols(Query, Limit, DS, capture(Result));
+  return std::move(*Result);
+}
+
 } // namespace clangd
 } // namespace clang
Index: unittests/clangd/FindSymbolsTests.cpp
===
--- /dev/null
+++ unittests/clangd/FindSymbolsTests.cpp
@@ -0,0 +1,249 @@
+//===-- FindSymbolsTests.cpp -*- C++ -*===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+#include "Annotations.h"
+#include "ClangdServer.h"
+#include "DraftStore.h"
+#include "FindSymbols.h"
+#include "SyncAPI.h"
+#include "TestFS.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+
+namespace {
+
+using ::testing::AllOf;
+using ::testing::AnyOf;
+using ::testing::ElementsAre;
+using ::testing::IsEmpty;
+using ::testing::UnorderedElementsAre;
+
+class IgnoreDiagnostics : public DiagnosticsConsumer {
+  void onDiagnosticsReady(PathRef File,
+  std::vector Diagnostics) override {}
+};
+
+// GMock helpers for matching SymbolInfos items.
+MATCHER_P(Named, Name, "") { return arg.name == Name; }
+MATCHER_P(InContainer, ContainerName, "") {
+  return arg.containerName == ContainerName;
+}
+MATCHER_P(WithKind, Kind, "") { return arg.kind == Kind; }
+
+ClangdServer::Options optsForTests() {
+  auto ServerOpts = ClangdServer::optsForTest();
+  ServerOpts.BuildDynamicSymbolIndex = true;
+  return ServerOpts;
+}
+
+class WorkspaceSymbolsTest : public ::testing::Test {
+public:
+  WorkspaceSymbolsTest()
+  : Server(CDB, FSProvider, DiagConsumer, optsForTests()) {}
+
+protected:
+  MockFSProvider FSProvider;
+  MockCompilationDatabase CDB;
+  IgnoreDiagnostics DiagConsumer;
+  ClangdServer Server;
+  int Limit;
+  DraftStore DS;
+
+  std::vector getSymbols(StringRef Query) {
+EXPECT_TRUE(Server.blockUntilIdleForTest()) << "Waiting for preamble";
+auto SymbolInfos = runWorkspaceSymbols(Server, Query, Limit, DS);
+EXPECT_TRUE(bool(SymbolInfos)) << "workspaceSymbols returned an error";
+return *SymbolInfos;
+  }
+
+  void addFile(StringRef FileName, StringRef Contents) {
+auto Path = testPath(FileName);
+FSProvider.Files[Path] = Contents;
+Server.addDocument(Path, Contents);
+  }
+};
+
+} // namespace
+
+TEST_F(WorkspaceSymbolsTest, NoMacro) {
+  addFile("foo.cpp", R"cpp(
+  #define MACRO X
+  )cpp");
+
+  // Macros are not in the index.
+  EXPECT_THAT(getSymbols("macro"), IsEmpty());
+}
+
+TEST_F(WorkspaceSymbolsTest, NoLocals) {
+  addFile("foo.cpp", R"cpp(
+  void test(int FirstParam, int SecondParam) {
+struct LocalClass {};
+int local_var;
+  })cpp");
+  EXPECT_THAT(getSymbols("l"), IsEmpty());
+  EXPECT_THAT(getSymbols("p"), IsEmpty());
+}
+
+TEST_F(WorkspaceSymbolsTest, Globals) {
+  addFile("foo.h", R"cpp(
+  int global_var;
+
+  int global_func();
+
+  struct GlobalStruct {};)cpp");
+  addFile("foo.cpp", R"cpp(
+  #include "foo.h"
+  )cpp");
+  EXPECT_THAT(getSymbols("global"),
+

[PATCH] D44882: [clangd] Implementation of workspace/symbol request

2018-04-13 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added a comment.

In https://reviews.llvm.org/D44882#1066883, @hokein wrote:

> Thanks, I have landed the patch today, you need to update your patch (I think 
> it is mostly about removing the code of reading-file stuff).


I updated the patch using the new line/col from the index. This is great!


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44882



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


[PATCH] D44381: [mips] Prevent PIC to be set to level 2

2018-04-13 Thread Aleksandar Beserminji via Phabricator via cfe-commits
abeserminji updated this revision to Diff 142406.
abeserminji marked an inline comment as done.
abeserminji edited the summary of this revision.
abeserminji added a comment.

Comments resolved.


Repository:
  rC Clang

https://reviews.llvm.org/D44381

Files:
  lib/Driver/ToolChains/CommonArgs.cpp
  test/Driver/pic.c


Index: test/Driver/pic.c
===
--- test/Driver/pic.c
+++ test/Driver/pic.c
@@ -292,9 +292,9 @@
 // RUN: %clang -c %s -target mipsel-linux-android14 -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIC1
 // RUN: %clang -c %s -target mipsel-linux-android16 -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE1
 // RUN: %clang -c %s -target mipsel-linux-android24 -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE1
 //
 // 64-bit Android targets are always PIE.
 // RUN: %clang -c %s -target aarch64-linux-android -### 2>&1 \
Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -1007,12 +1007,17 @@
   if ((ROPI || RWPI) && (PIC || PIE))
 ToolChain.getDriver().Diag(diag::err_drv_ropi_rwpi_incompatible_with_pic);
 
-  // When targettng MIPS64 with N64, the default is PIC, unless -mno-abicalls 
is
-  // used.
-  if ((Triple.getArch() == llvm::Triple::mips64 ||
-   Triple.getArch() == llvm::Triple::mips64el) &&
-  Args.hasArg(options::OPT_mno_abicalls))
-return std::make_tuple(llvm::Reloc::Static, 0U, false);
+  if (Triple.getArch() == llvm::Triple::mips ||
+   Triple.getArch() == llvm::Triple::mipsel ||
+   Triple.getArch() == llvm::Triple::mips64 ||
+   Triple.getArch() == llvm::Triple::mips64el) {
+// When targettng MIPS with -mno-abicalls, it's always static.
+if(Args.hasArg(options::OPT_mno_abicalls))
+  return std::make_tuple(llvm::Reloc::Static, 0U, false);
+// Unlike other architectures, MIPS, even with -fPIC/-mxgot/multigot,
+// does not use PIC level 2 for historical reasons.
+IsPICLevelTwo = false;
+  }
 
   if (PIC)
 return std::make_tuple(llvm::Reloc::PIC_, IsPICLevelTwo ? 2U : 1U, PIE);


Index: test/Driver/pic.c
===
--- test/Driver/pic.c
+++ test/Driver/pic.c
@@ -292,9 +292,9 @@
 // RUN: %clang -c %s -target mipsel-linux-android14 -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIC1
 // RUN: %clang -c %s -target mipsel-linux-android16 -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE1
 // RUN: %clang -c %s -target mipsel-linux-android24 -### 2>&1 \
-// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE1
 //
 // 64-bit Android targets are always PIE.
 // RUN: %clang -c %s -target aarch64-linux-android -### 2>&1 \
Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -1007,12 +1007,17 @@
   if ((ROPI || RWPI) && (PIC || PIE))
 ToolChain.getDriver().Diag(diag::err_drv_ropi_rwpi_incompatible_with_pic);
 
-  // When targettng MIPS64 with N64, the default is PIC, unless -mno-abicalls is
-  // used.
-  if ((Triple.getArch() == llvm::Triple::mips64 ||
-   Triple.getArch() == llvm::Triple::mips64el) &&
-  Args.hasArg(options::OPT_mno_abicalls))
-return std::make_tuple(llvm::Reloc::Static, 0U, false);
+  if (Triple.getArch() == llvm::Triple::mips ||
+   Triple.getArch() == llvm::Triple::mipsel ||
+   Triple.getArch() == llvm::Triple::mips64 ||
+   Triple.getArch() == llvm::Triple::mips64el) {
+// When targettng MIPS with -mno-abicalls, it's always static.
+if(Args.hasArg(options::OPT_mno_abicalls))
+  return std::make_tuple(llvm::Reloc::Static, 0U, false);
+// Unlike other architectures, MIPS, even with -fPIC/-mxgot/multigot,
+// does not use PIC level 2 for historical reasons.
+IsPICLevelTwo = false;
+  }
 
   if (PIC)
 return std::make_tuple(llvm::Reloc::PIC_, IsPICLevelTwo ? 2U : 1U, PIE);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45451: [ItaniumMangle] Undeduced auto type doesn't belong in the substitution table

2018-04-13 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington updated this revision to Diff 142402.
erik.pilkington marked an inline comment as done.
erik.pilkington added a comment.

Add an ABI compatibility guard. Thanks!


https://reviews.llvm.org/D45451

Files:
  clang/lib/AST/ItaniumMangle.cpp
  clang/test/CodeGenCXX/lambda-expressions-inside-auto-functions.cpp


Index: clang/test/CodeGenCXX/lambda-expressions-inside-auto-functions.cpp
===
--- clang/test/CodeGenCXX/lambda-expressions-inside-auto-functions.cpp
+++ clang/test/CodeGenCXX/lambda-expressions-inside-auto-functions.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fblocks -emit-llvm -o - 
%s -fexceptions -std=c++1y | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fblocks -emit-llvm -o - 
%s -fexceptions -std=c++1y | FileCheck --check-prefix CHECK_ABI_LATEST %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fblocks -emit-llvm -o - 
%s -fexceptions -std=c++1y -fclang-abi-compat=6.0 | FileCheck --check-prefix 
CHECK_ABIV6 %s
 
 // CHECK-LABEL: define void @_ZN19non_inline_function3fooEv
 // CHECK-LABEL: define internal void 
@"_ZZN19non_inline_function3fooEvENK3$_0clEi"(%class.anon
@@ -52,10 +53,12 @@
   
   template auto foo() { return [](const T&) { return 42; }; }
 };
-//CHECK-LABEL: define linkonce_odr i32 
@_ZZN22inline_member_function1AIdE14default_lambdaIdEEDavENKUlRKdE_clES5_(%class.anon
+//CHECK_ABIV6: define linkonce_odr i32 
@_ZZN22inline_member_function1AIdE14default_lambdaIdEEDavENKUlRKdE_clES5_(%class.anon
+//CHECK_ABI_LATEST: define linkonce_odr i32 
@_ZZN22inline_member_function1AIdE14default_lambdaIdEEDavENKUlRKdE_clES4_(%class.anon
 int run2 = A{}.func()(3.14);
 
-//CHECK-LABEL: define linkonce_odr i32 
@_ZZN22inline_member_function1AIcE14default_lambdaIcEEDavENKUlRKcE_clES5_(%class.anon
+//CHECK_ABIV6: define linkonce_odr i32 
@_ZZN22inline_member_function1AIcE14default_lambdaIcEEDavENKUlRKcE_clES5_(%class.anon
+//CHECK_ABI_LATEST: define linkonce_odr i32 
@_ZZN22inline_member_function1AIcE14default_lambdaIcEEDavENKUlRKcE_clES4_(%class.anon
 int run3 = A{}.func()('a');
 } // end inline_member_function
 
Index: clang/lib/AST/ItaniumMangle.cpp
===
--- clang/lib/AST/ItaniumMangle.cpp
+++ clang/lib/AST/ItaniumMangle.cpp
@@ -2329,16 +2329,19 @@
   Context.mangleObjCMethodName(MD, Out);
 }
 
-static bool isTypeSubstitutable(Qualifiers Quals, const Type *Ty) {
+static bool isTypeSubstitutable(Qualifiers Quals, const Type *Ty,
+ASTContext &Ctx) {
   if (Quals)
 return true;
   if (Ty->isSpecificBuiltinType(BuiltinType::ObjCSel))
 return true;
   if (Ty->isOpenCLSpecificType())
 return true;
   if (Ty->isBuiltinType())
 return false;
-
+  if (Ctx.getLangOpts().getClangABICompat() > LangOptions::ClangABI::Ver6 &&
+  isa(Ty))
+return false;
   return true;
 }
 
@@ -2399,7 +2402,8 @@
   Qualifiers quals = split.Quals;
   const Type *ty = split.Ty;
 
-  bool isSubstitutable = isTypeSubstitutable(quals, ty);
+  bool isSubstitutable =
+isTypeSubstitutable(quals, ty, Context.getASTContext());
   if (isSubstitutable && mangleSubstitution(T))
 return;
 
@@ -3250,14 +3254,13 @@
 }
 
 void CXXNameMangler::mangleType(const AutoType *T) {
-  QualType D = T->getDeducedType();
-  //  ::= Da  # dependent auto
-  if (D.isNull()) {
-assert(T->getKeyword() != AutoTypeKeyword::GNUAutoType &&
-   "shouldn't need to mangle __auto_type!");
-Out << (T->isDecltypeAuto() ? "Dc" : "Da");
-  } else
-mangleType(D);
+  assert(T->getDeducedType().isNull() &&
+ "Deduced AutoType shouldn't be handled here!");
+  assert(T->getKeyword() != AutoTypeKeyword::GNUAutoType &&
+ "shouldn't need to mangle __auto_type!");
+  //  ::= Da # auto
+  //::= Dc # decltype(auto)
+  Out << (T->isDecltypeAuto() ? "Dc" : "Da");
 }
 
 void CXXNameMangler::mangleType(const DeducedTemplateSpecializationType *T) {


Index: clang/test/CodeGenCXX/lambda-expressions-inside-auto-functions.cpp
===
--- clang/test/CodeGenCXX/lambda-expressions-inside-auto-functions.cpp
+++ clang/test/CodeGenCXX/lambda-expressions-inside-auto-functions.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fblocks -emit-llvm -o - %s -fexceptions -std=c++1y | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fblocks -emit-llvm -o - %s -fexceptions -std=c++1y | FileCheck --check-prefix CHECK_ABI_LATEST %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fblocks -emit-llvm -o - %s -fexceptions -std=c++1y -fclang-abi-compat=6.0 | FileCheck --check-prefix CHECK_ABIV6 %s
 
 // CHECK-LABEL: define void @_ZN19non_inline_function3fooEv
 // CHECK-LABEL: define internal void @"_ZZN19non_inline_function3fooEvENK3$_0clEi"(%class.anon
@@ -52,10 +53,12 @@
   
   template auto f

[PATCH] D45613: [X86] Introduce archs: goldmont-plus & tremont

2018-04-13 Thread Gabor Buella via Phabricator via cfe-commits
GBuella added a comment.

I was not sure about what predefined macros to add for goldmont-plus & tremont.
I found this conversation: https://reviews.llvm.org/D38824 which seems to 
suggest no new arch specifix macros.
But apparently atom archs have their own macros.


Repository:
  rC Clang

https://reviews.llvm.org/D45613



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


[PATCH] D43281: [AMDGPU] fixes for lds f32 builtins

2018-04-13 Thread Daniil Fukalov via Phabricator via cfe-commits
dfukalov updated this revision to Diff 142412.
dfukalov edited the summary of this revision.

Repository:
  rC Clang

https://reviews.llvm.org/D43281

Files:
  include/clang/Basic/BuiltinsAMDGPU.def
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGenOpenCL/builtins-amdgcn-vi.cl
  test/SemaOpenCL/builtins-amdgcn-error.cl

Index: test/SemaOpenCL/builtins-amdgcn-error.cl
===
--- test/SemaOpenCL/builtins-amdgcn-error.cl
+++ test/SemaOpenCL/builtins-amdgcn-error.cl
@@ -102,3 +102,20 @@
   *out = __builtin_amdgcn_mov_dpp(a, 0, 0, 0, e); // expected-error {{argument to '__builtin_amdgcn_mov_dpp' must be a constant integer}}
 }
 
+void test_ds_faddf(local float *out, float src, int a) {
+  *out = __builtin_amdgcn_ds_faddf(out, src, a, 0, false); // expected-error {{argument to '__builtin_amdgcn_ds_faddf' must be a constant integer}}
+  *out = __builtin_amdgcn_ds_faddf(out, src, 0, a, false); // expected-error {{argument to '__builtin_amdgcn_ds_faddf' must be a constant integer}}
+  *out = __builtin_amdgcn_ds_faddf(out, src, 0, 0, a); // expected-error {{argument to '__builtin_amdgcn_ds_faddf' must be a constant integer}}
+}
+
+void test_ds_fminf(local float *out, float src, int a) {
+  *out = __builtin_amdgcn_ds_fminf(out, src, a, 0, false); // expected-error {{argument to '__builtin_amdgcn_ds_fminf' must be a constant integer}}
+  *out = __builtin_amdgcn_ds_fminf(out, src, 0, a, false); // expected-error {{argument to '__builtin_amdgcn_ds_fminf' must be a constant integer}}
+  *out = __builtin_amdgcn_ds_fminf(out, src, 0, 0, a); // expected-error {{argument to '__builtin_amdgcn_ds_fminf' must be a constant integer}}
+}
+
+void test_ds_fmaxf(local float *out, float src, int a) {
+  *out = __builtin_amdgcn_ds_fmaxf(out, src, a, 0, false); // expected-error {{argument to '__builtin_amdgcn_ds_fmaxf' must be a constant integer}}
+  *out = __builtin_amdgcn_ds_fmaxf(out, src, 0, a, false); // expected-error {{argument to '__builtin_amdgcn_ds_fmaxf' must be a constant integer}}
+  *out = __builtin_amdgcn_ds_fmaxf(out, src, 0, 0, a); // expected-error {{argument to '__builtin_amdgcn_ds_fmaxf' must be a constant integer}}
+}
Index: test/CodeGenOpenCL/builtins-amdgcn-vi.cl
===
--- test/CodeGenOpenCL/builtins-amdgcn-vi.cl
+++ test/CodeGenOpenCL/builtins-amdgcn-vi.cl
@@ -91,18 +91,18 @@
 
 // CHECK-LABEL: @test_ds_fadd
 // CHECK: call float @llvm.amdgcn.ds.fadd(float addrspace(3)* %out, float %src, i32 0, i32 0, i1 false)
-void test_ds_fadd(__attribute__((address_space(3))) float *out, float src) {
-  *out = __builtin_amdgcn_ds_fadd(out, src, 0, 0, false);
+void test_ds_faddf(local float *out, float src) {
+  *out = __builtin_amdgcn_ds_faddf(out, src, 0, 0, false);
 }
 
 // CHECK-LABEL: @test_ds_fmin
 // CHECK: call float @llvm.amdgcn.ds.fmin(float addrspace(3)* %out, float %src, i32 0, i32 0, i1 false)
-void test_ds_fmin(__attribute__((address_space(3))) float *out, float src) {
-  *out = __builtin_amdgcn_ds_fmin(out, src, 0, 0, false);
+void test_ds_fminf(local float *out, float src) {
+  *out = __builtin_amdgcn_ds_fminf(out, src, 0, 0, false);
 }
 
 // CHECK-LABEL: @test_ds_fmax
 // CHECK: call float @llvm.amdgcn.ds.fmax(float addrspace(3)* %out, float %src, i32 0, i32 0, i1 false)
-void test_ds_fmax(__attribute__((address_space(3))) float *out, float src) {
-  *out = __builtin_amdgcn_ds_fmax(out, src, 0, 0, false);
+void test_ds_fmaxf(local float *out, float src) {
+  *out = __builtin_amdgcn_ds_fmaxf(out, src, 0, 0, false);
 }
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -9897,6 +9897,49 @@
 CI->setConvergent();
 return CI;
   }
+  case AMDGPU::BI__builtin_amdgcn_ds_faddf:
+  case AMDGPU::BI__builtin_amdgcn_ds_fminf:
+  case AMDGPU::BI__builtin_amdgcn_ds_fmaxf: {
+llvm::SmallVector Args;
+for (unsigned I = 0; I != 5; ++I)
+  Args.push_back(EmitScalarExpr(E->getArg(I)));
+const llvm::Type *PtrTy = Args[0]->getType();
+// check pointer parameter
+if (!PtrTy->isPointerTy() ||
+LangAS::opencl_local != E->getArg(0)
+->getType()
+->getPointeeType()
+.getQualifiers()
+.getAddressSpace() ||
+!PtrTy->getPointerElementType()->isFloatTy()) {
+  CGM.Error(E->getArg(0)->getLocStart(),
+"parameter should have type \"local float*\"");
+  return nullptr;
+}
+// check float parameter
+if (!Args[1]->getType()->isFloatTy()) {
+  CGM.Error(E->getArg(1)->getLocStart(),
+"parameter should have type \"float\"");
+  return nullptr;
+}
+
+Intrinsic::ID ID;
+switch (BuiltinID) {
+case AMDGPU::BI__builtin_amdgcn_ds_faddf:
+  ID = Intrinsic::amdgcn_

[PATCH] D44381: [mips] Prevent PIC to be set to level 2

2018-04-13 Thread Simon Dardis via Phabricator via cfe-commits
sdardis accepted this revision.
sdardis added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rC Clang

https://reviews.llvm.org/D44381



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


[PATCH] D45046: hwasan: add -fsanitize=kernel-hwaddress

2018-04-13 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added a comment.

LGTM (+missing *-commits MLs)


https://reviews.llvm.org/D45046



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


[PATCH] D44984: [HIP] Add hip file type and codegen for kernel launching

2018-04-13 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 4 inline comments as done.
yaxunl added inline comments.



Comment at: lib/Frontend/CompilerInvocation.cpp:2109
+  Opts.HIP = true;
+  }
+

rjmccall wrote:
> Why is this done here?  We infer the language mode from the input kind 
> somewhere else.
It is usually done through CompilerInvocation::setLangDefaults. However, HIP 
does not have its own input kind nor is it defined as a language standard. 
Therefore it cannot use CompilerInvocation::setLangDefaults to set Opts.HIP. 


https://reviews.llvm.org/D44984



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


[PATCH] D44984: [HIP] Add hip file type and codegen for kernel launching

2018-04-13 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 142422.
yaxunl marked an inline comment as done.
yaxunl added a comment.

Revised by John's comments.


https://reviews.llvm.org/D44984

Files:
  include/clang/Basic/LangOptions.def
  lib/CodeGen/CGCUDANV.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/InitPreprocessor.cpp
  lib/Sema/SemaCUDA.cpp
  lib/Sema/SemaDecl.cpp
  test/CodeGenCUDA/device-stub.cu

Index: test/CodeGenCUDA/device-stub.cu
===
--- test/CodeGenCUDA/device-stub.cu
+++ test/CodeGenCUDA/device-stub.cu
@@ -1,8 +1,11 @@
 // RUN: echo "GPU binary would be here" > %t
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -fcuda-include-gpubinary %t -o - | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -fcuda-include-gpubinary %t -o -  -DNOGLOBALS \
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
+// RUN:   -fcuda-include-gpubinary %t -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
+// RUN:   -fcuda-include-gpubinary %t -o -  -DNOGLOBALS \
 // RUN:   | FileCheck %s -check-prefix=NOGLOBALS
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=NOGPUBIN
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - \
+// RUN:   | FileCheck %s -check-prefix=NOGPUBIN
 
 #include "Inputs/cuda.h"
 
@@ -77,10 +80,14 @@
 // Test that we've built a function to register kernels and global vars.
 // CHECK: define internal void @__cuda_register_globals
 // CHECK: call{{.*}}cudaRegisterFunction(i8** %0, {{.*}}kernelfunc
-// CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}device_var{{.*}}i32 0, i32 4, i32 0, i32 0
-// CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}constant_var{{.*}}i32 0, i32 4, i32 1, i32 0
-// CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}ext_device_var{{.*}}i32 1, i32 4, i32 0, i32 0
-// CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}ext_constant_var{{.*}}i32 1, i32 4, i32 1, i32 0
+// CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}device_var{{.*}}
+// CHECK-DAG-SAME:  i32 0, i32 4, i32 0, i32 0
+// CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}constant_var{{.*}}
+// CHECK-DAG-SAME:  i32 0, i32 4, i32 1, i32 0
+// CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}ext_device_var{{.*}}
+// CHECK-DAG-SAME:  i32 1, i32 4, i32 0, i32 0
+// CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}ext_constant_var{{.*}}
+// CHECK-DAG-SAME:  i32 1, i32 4, i32 1, i32 0
 // CHECK: ret void
 
 // Test that we've built contructor..
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -9048,11 +9048,13 @@
 
   if (getLangOpts().CUDA) {
 IdentifierInfo *II = NewFD->getIdentifier();
-if (II && II->isStr("cudaConfigureCall") && !NewFD->isInvalidDecl() &&
+if (II &&
+((getLangOpts().HIP && II->isStr("hipConfigureCall")) ||
+ (!getLangOpts().HIP && II->isStr("cudaConfigureCall"))) &&
+!NewFD->isInvalidDecl() &&
 NewFD->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
   if (!R->getAs()->getReturnType()->isScalarType())
 Diag(NewFD->getLocation(), diag::err_config_scalar_return);
-
   Context.setcudaConfigureCallDecl(NewFD);
 }
 
Index: lib/Sema/SemaCUDA.cpp
===
--- lib/Sema/SemaCUDA.cpp
+++ lib/Sema/SemaCUDA.cpp
@@ -42,8 +42,9 @@
  SourceLocation GGGLoc) {
   FunctionDecl *ConfigDecl = Context.getcudaConfigureCallDecl();
   if (!ConfigDecl)
-return ExprError(Diag(oc, diag::err_undeclared_var_use)
- << "cudaConfigureCall");
+return ExprError(
+Diag(oc, diag::err_undeclared_var_use)
+<< (getLangOpts().HIP ? "hipConfigureCall" : "cudaConfigureCall"));
   QualType ConfigQTy = ConfigDecl->getType();
 
   DeclRefExpr *ConfigDR = new (Context)
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -465,6 +465,8 @@
 Builder.defineMacro("__ASSEMBLER__");
   if (LangOpts.CUDA)
 Builder.defineMacro("__CUDA__");
+  if (LangOpts.HIP)
+Builder.defineMacro("__HIP__");
 }
 
 /// Initialize the predefined C++ language feature test macros defined in
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1564,6 +1564,7 @@
 .Case("c", InputKind::C)
 .Case("cl", InputKind::OpenCL)
 .Case("cuda", InputKind::CUDA)
+.Case("hip", InputKind::CUDA)
 .Case("c++", InputKind::CXX)
 .Ca

r330041 - Fix evaluation of `__has_include_next` during -frewrite-includes.

2018-04-13 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Fri Apr 13 10:43:15 2018
New Revision: 330041

URL: http://llvm.org/viewvc/llvm-project?rev=330041&view=rev
Log:
Fix evaluation of `__has_include_next` during -frewrite-includes.

`__has_include_next` requires correct DirectoryLookup for being
evaluated correctly. We were using Preprocessor::GetCurDirLookup() but
we were calling it after the preprocessor finished its work. And in this
case CurDirLookup is always nullptr which makes `__has_include_next`
behave as `__has_include`.

Fix by storing and using CurDirLookup when preprocessor enters a file,
not when we rewrite the includes.

rdar://problem/36305026

Reviewers: bkramer

Reviewed By: bkramer

Subscribers: jkorous-apple, cfe-commits

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

Added:
cfe/trunk/test/Frontend/Inputs/NextIncludes/
cfe/trunk/test/Frontend/Inputs/NextIncludes/rewrite-includes9.h
cfe/trunk/test/Frontend/Inputs/rewrite-includes9.h
Modified:
cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp
cfe/trunk/test/Frontend/rewrite-includes.c

Modified: cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp?rev=330041&r1=330040&r2=330041&view=diff
==
--- cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp (original)
+++ cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp Fri Apr 13 10:43:15 
2018
@@ -32,8 +32,10 @@ class InclusionRewriter : public PPCallb
   struct IncludedFile {
 FileID Id;
 SrcMgr::CharacteristicKind FileType;
-IncludedFile(FileID Id, SrcMgr::CharacteristicKind FileType)
-: Id(Id), FileType(FileType) {}
+const DirectoryLookup *DirLookup;
+IncludedFile(FileID Id, SrcMgr::CharacteristicKind FileType,
+ const DirectoryLookup *DirLookup)
+: Id(Id), FileType(FileType), DirLookup(DirLookup) {}
   };
   Preprocessor &PP; ///< Used to find inclusion directives.
   SourceManager &SM; ///< Used to read and manage source files.
@@ -54,7 +56,8 @@ class InclusionRewriter : public PPCallb
 public:
   InclusionRewriter(Preprocessor &PP, raw_ostream &OS, bool ShowLineMarkers,
 bool UseLineDirectives);
-  void Process(FileID FileId, SrcMgr::CharacteristicKind FileType);
+  void Process(FileID FileId, SrcMgr::CharacteristicKind FileType,
+   const DirectoryLookup *DirLookup);
   void setPredefinesBuffer(const llvm::MemoryBuffer *Buf) {
 PredefinesBuffer = Buf;
   }
@@ -156,8 +159,9 @@ void InclusionRewriter::FileChanged(Sour
 // we didn't reach this file (eg: the main file) via an inclusion directive
 return;
   FileID Id = FullSourceLoc(Loc, SM).getFileID();
-  auto P = FileIncludes.insert(std::make_pair(
-  LastInclusionLocation.getRawEncoding(), IncludedFile(Id, NewFileType)));
+  auto P = FileIncludes.insert(
+  std::make_pair(LastInclusionLocation.getRawEncoding(),
+ IncludedFile(Id, NewFileType, PP.GetCurDirLookup(;
   (void)P;
   assert(P.second && "Unexpected revisitation of the same include directive");
   LastInclusionLocation = SourceLocation();
@@ -408,7 +412,7 @@ bool InclusionRewriter::HandleHasInclude
   Includers.push_back(std::make_pair(FileEnt, FileEnt->getDir()));
   // FIXME: Why don't we call PP.LookupFile here?
   const FileEntry *File = PP.getHeaderSearchInfo().LookupFile(
-  Filename, SourceLocation(), isAngled, nullptr, CurDir, Includers, 
nullptr,
+  Filename, SourceLocation(), isAngled, Lookup, CurDir, Includers, nullptr,
   nullptr, nullptr, nullptr, nullptr);
 
   FileExists = File != nullptr;
@@ -418,7 +422,8 @@ bool InclusionRewriter::HandleHasInclude
 /// Use a raw lexer to analyze \p FileId, incrementally copying parts of it
 /// and including content of included files recursively.
 void InclusionRewriter::Process(FileID FileId,
-SrcMgr::CharacteristicKind FileType) {
+SrcMgr::CharacteristicKind FileType,
+const DirectoryLookup *DirLookup) {
   bool Invalid;
   const MemoryBuffer &FromFile = *SM.getBuffer(FileId, &Invalid);
   assert(!Invalid && "Attempting to process invalid inclusion");
@@ -475,7 +480,7 @@ void InclusionRewriter::Process(FileID F
<< Mod->getFullModuleName(true) << "\n";
 
   // Include and recursively process the file.
-  Process(Inc->Id, Inc->FileType);
+  Process(Inc->Id, Inc->FileType, Inc->DirLookup);
 
   if (Mod)
 OS << "#pragma clang module end /*"
@@ -532,11 +537,10 @@ void InclusionRewriter::Process(FileID F
   // Rewrite __has_include_next(x)
 } else if (RawToken.getIdentifierInfo()->isStr(
"__has_include_next")) {
-  const DirectoryLookup *Lookup = PP.GetCurDirLookup();
- 

[PATCH] D45603: Fix evaluation of `__has_include_next` during -frewrite-includes.

2018-04-13 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC330041: Fix evaluation of `__has_include_next` during 
-frewrite-includes. (authored by vsapsai, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D45603?vs=142299&id=142438#toc

Repository:
  rC Clang

https://reviews.llvm.org/D45603

Files:
  lib/Frontend/Rewrite/InclusionRewriter.cpp
  test/Frontend/Inputs/NextIncludes/rewrite-includes9.h
  test/Frontend/Inputs/rewrite-includes9.h
  test/Frontend/rewrite-includes.c

Index: test/Frontend/rewrite-includes.c
===
--- test/Frontend/rewrite-includes.c
+++ test/Frontend/rewrite-includes.c
@@ -1,5 +1,5 @@
-// RUN: not %clang_cc1 -verify -E -frewrite-includes -DFIRST -I %S/Inputs %s -o - | FileCheck -strict-whitespace %s
-// RUN: not %clang_cc1 -verify -E -frewrite-includes -P -DFIRST -I %S/Inputs %s -o - | FileCheck -check-prefix=CHECKNL -strict-whitespace %s
+// RUN: not %clang_cc1 -verify -E -frewrite-includes -DFIRST -I %S/Inputs -I %S/Inputs/NextIncludes %s -o - | FileCheck -strict-whitespace %s
+// RUN: not %clang_cc1 -verify -E -frewrite-includes -P -DFIRST -I %S/Inputs -I %S/Inputs/NextIncludes %s -o - | FileCheck -check-prefix=CHECKNL -strict-whitespace %s
 // STARTCOMPARE
 #define A(a,b) a ## b
 A(1,2)
@@ -20,6 +20,7 @@
 #include "rewrite-includes7.h"
 #include "rewrite-includes7.h"
 #include "rewrite-includes8.h"
+#include "rewrite-includes9.h"
 // ENDCOMPARE
 // CHECK: {{^}}# 1 "{{.*}}rewrite-includes.c"{{$}}
 // CHECK: {{^}}// STARTCOMPARE{{$}}
@@ -109,15 +110,31 @@
 // CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
 // CHECK-NEXT: {{^}}# 22 "{{.*}}rewrite-includes.c"{{$}}
 // CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs(/|)}}rewrite-includes8.h" 1{{$}}
-// CHECK-NEXT: {{^}}#if (1)/*__has_include_next()*/{{$}}
+// CHECK-NEXT: {{^}}#if (0)/*__has_include_next()*/{{$}}
 // CHECK-NEXT: {{^}}#elif (0)/*__has_include()*/{{$}}
 // CHECK-NEXT: {{^}}# 3 "{{.*[/\\]Inputs(/|)}}rewrite-includes8.h"{{$}}
 // CHECK-NEXT: {{^}}#endif{{$}}
 // CHECK-NEXT: {{^}}# 4 "{{.*[/\\]Inputs(/|)}}rewrite-includes8.h"{{$}}
 // CHECK-NEXT: {{^}}#if !(1)/*__has_include("rewrite-includes8.h")*/{{$}}
 // CHECK-NEXT: {{^}}#endif{{$}}
 // CHECK-NEXT: {{^}}# 6 "{{.*[/\\]Inputs(/|)}}rewrite-includes8.h"{{$}}
 // CHECK-NEXT: {{^}}# 23 "{{.*}}rewrite-includes.c" 2{{$}}
+// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
+// CHECK-NEXT: {{^}}#include "rewrite-includes9.h"{{$}}
+// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
+// CHECK-NEXT: {{^}}# 23 "{{.*}}rewrite-includes.c"{{$}}
+// CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs(/|)}}rewrite-includes9.h" 1{{$}}
+// CHECK-NEXT: {{^}}#if (1)/*__has_include_next()*/{{$}}
+// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
+// CHECK-NEXT: {{^}}#include_next {{$}}
+// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
+// CHECK-NEXT: {{^}}# 2 "{{.*[/\\]Inputs(/|)}}rewrite-includes9.h"{{$}}
+// CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs(/|)NextIncludes(/|)}}rewrite-includes9.h" 1{{$}}
+// CHECK-NEXT: {{^}}included_line9{{$}}
+// CHECK-NEXT: {{^}}# 3 "{{.*[/\\]Inputs(/|)}}rewrite-includes9.h" 2{{$}}
+// CHECK-NEXT: {{^}}#endif{{$}}
+// CHECK-NEXT: {{^}}# 4 "{{.*[/\\]Inputs(/|)}}rewrite-includes9.h"{{$}}
+// CHECK-NEXT: {{^}}# 24 "{{.*}}rewrite-includes.c" 2{{$}}
 // CHECK-NEXT: {{^}}// ENDCOMPARE{{$}}
 
 // CHECKNL: {{^}}// STARTCOMPARE{{$}}
@@ -176,9 +193,18 @@
 // CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
 // CHECKNL-NEXT: {{^}}#include "rewrite-includes8.h"{{$}}
 // CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
-// CHECKNL-NEXT: {{^}}#if (1)/*__has_include_next()*/{{$}}
+// CHECKNL-NEXT: {{^}}#if (0)/*__has_include_next()*/{{$}}
 // CHECKNL-NEXT: {{^}}#elif (0)/*__has_include()*/{{$}}
 // CHECKNL-NEXT: {{^}}#endif{{$}}
 // CHECKNL-NEXT: {{^}}#if !(1)/*__has_include("rewrite-includes8.h")*/{{$}}
 // CHECKNL-NEXT: {{^}}#endif{{$}}
+// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
+// CHECKNL-NEXT: {{^}}#include "rewrite-includes9.h"{{$}}
+// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
+// CHECKNL-NEXT: {{^}}#if (1)/*__has_include_next()*/{{$}}
+// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
+// CHECKNL-NEXT: {{^}}#include_next {{$}}
+// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
+// CHECKNL-NEXT: {{^}}included_line9{{$}}
+// CHECKNL-NEXT: {{^}}#endif{{$}}
 // CHECKNL-NEXT: {{^}}// ENDCOMPARE{{$}}
Index: test/Frontend/Inputs/NextIncludes/rewrite-includes9.h
===
--- test/Frontend/Inputs/NextIncludes/rewrite-includes9.h
+++ test/Frontend/Inputs/NextIncludes/rewrite-includes9.h
@@ -0,0 +1 @@
+included_line9
Index: test/Frontend/Inputs/rewrite-includes9.h
==

[PATCH] D45603: Fix evaluation of `__has_include_next` during -frewrite-includes.

2018-04-13 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Thanks for the prompt review.


Repository:
  rC Clang

https://reviews.llvm.org/D45603



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


r330042 - [OPENMP] Replace push_back by emplace_back, NFC.

2018-04-13 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Apr 13 10:48:43 2018
New Revision: 330042

URL: http://llvm.org/viewvc/llvm-project?rev=330042&view=rev
Log:
[OPENMP] Replace push_back by emplace_back, NFC.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=330042&r1=330041&r2=330042&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Fri Apr 13 10:48:43 2018
@@ -1285,7 +1285,7 @@ void CGOpenMPRuntime::emitUserDefinedRed
 cast(D->lookup(Priv).front()),
 /*IsCombiner=*/false);
   }
-  UDRMap.insert(std::make_pair(D, std::make_pair(Combiner, Initializer)));
+  UDRMap.try_emplace(D, Combiner, Initializer);
   if (CGF) {
 auto &Decls = FunctionUDRMap.FindAndConstruct(CGF->CurFn);
 Decls.second.push_back(D);
@@ -2817,7 +2817,7 @@ CGOpenMPRuntime::getOrCreateInternalVari
   llvm::raw_svector_ostream Out(Buffer);
   Out << Name;
   auto RuntimeName = Out.str();
-  auto &Elem = *InternalVars.insert(std::make_pair(RuntimeName, 
nullptr)).first;
+  auto &Elem = *InternalVars.try_emplace(RuntimeName, nullptr).first;
   if (Elem.second) {
 assert(Elem.second->getType()->getPointerElementType() == Ty &&
"OMP internal variable has different type than requested");
@@ -4659,31 +4659,31 @@ CGOpenMPRuntime::emitTaskInit(CodeGenFun
   auto I = Data.PrivateCopies.begin();
   for (auto *E : Data.PrivateVars) {
 auto *VD = cast(cast(E)->getDecl());
-Privates.push_back(std::make_pair(
+Privates.emplace_back(
 C.getDeclAlign(VD),
 PrivateHelpersTy(VD, cast(cast(*I)->getDecl()),
- /*PrivateElemInit=*/nullptr)));
+ /*PrivateElemInit=*/nullptr));
 ++I;
   }
   I = Data.FirstprivateCopies.begin();
   auto IElemInitRef = Data.FirstprivateInits.begin();
   for (auto *E : Data.FirstprivateVars) {
 auto *VD = cast(cast(E)->getDecl());
-Privates.push_back(std::make_pair(
+Privates.emplace_back(
 C.getDeclAlign(VD),
 PrivateHelpersTy(
 VD, cast(cast(*I)->getDecl()),
-cast(cast(*IElemInitRef)->getDecl();
+cast(cast(*IElemInitRef)->getDecl(;
 ++I;
 ++IElemInitRef;
   }
   I = Data.LastprivateCopies.begin();
   for (auto *E : Data.LastprivateVars) {
 auto *VD = cast(cast(E)->getDecl());
-Privates.push_back(std::make_pair(
+Privates.emplace_back(
 C.getDeclAlign(VD),
 PrivateHelpersTy(VD, cast(cast(*I)->getDecl()),
- /*PrivateElemInit=*/nullptr)));
+ /*PrivateElemInit=*/nullptr));
 ++I;
   }
   std::stable_sort(Privates.begin(), Privates.end(), stable_sort_comparator);
@@ -7240,7 +7240,7 @@ emitOffloadingArrays(CodeGenFunction &CG
 
   if (Info.requiresDevicePointerInfo())
 if (auto *DevVD = BasePointers[i].getDevicePtrDecl())
-  Info.CaptureDeviceAddrMap.insert(std::make_pair(DevVD, BPAddr));
+  Info.CaptureDeviceAddrMap.try_emplace(DevVD, BPAddr);
 
   llvm::Value *PVal = Pointers[i];
   llvm::Value *P = CGF.Builder.CreateConstInBoundsGEP2_32(

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=330042&r1=330041&r2=330042&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Fri Apr 13 10:48:43 2018
@@ -2832,7 +2832,7 @@ void CodeGenFunction::EmitOMPTaskBasedDi
   // Build list of dependences.
   for (const auto *C : S.getClausesOfKind())
 for (const Expr *IRef : C->varlists())
-  Data.Dependences.push_back(std::make_pair(C->getDependencyKind(), IRef));
+  Data.Dependences.emplace_back(C->getDependencyKind(), IRef);
   auto &&CodeGen = [&Data, &S, CS, &BodyGen, &LastprivateDstsOrigs,
 CapturedRegion](CodeGenFunction &CGF,
 PrePostActionTy &Action) {
@@ -3068,7 +3068,7 @@ void CodeGenFunction::EmitOMPTargetTaskB
   // Build list of dependences.
   for (const auto *C : S.getClausesOfKind())
 for (const Expr *IRef : C->varlists())
-  Data.Dependences.push_back(std::make_pair(C->getDependencyKind(), IRef));
+  Data.Dependences.emplace_back(C->getDependencyKind(), IRef);
   auto &&CodeGen = [&Data, &S, CS, &BodyGen, BPVD, PVD, SVD,
 &InputInfo](CodeGenFunction &CGF, PrePostActionTy &Action) 
{
 // Set proper addresses for generated private copies.

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=330042&r1=330041

[PATCH] D45557: [Analyzer] Fix for SValBuilder expressions rearrangement

2018-04-13 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Yup thanks!


https://reviews.llvm.org/D45557



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


[PATCH] D45046: hwasan: add -fsanitize=kernel-hwaddress

2018-04-13 Thread Andrey Konovalov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC330044: hwasan: add -fsanitize=kernel-hwaddress flag 
(authored by andreyknvl, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D45046?vs=142196&id=142440#toc

Repository:
  rC Clang

https://reviews.llvm.org/D45046

Files:
  include/clang/Basic/Sanitizers.def
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/SanitizerMetadata.cpp
  lib/Driver/SanitizerArgs.cpp
  lib/Driver/ToolChains/Linux.cpp
  lib/Lex/PPMacroExpansion.cpp
  test/CodeGen/address-safety-attr-flavors.cpp
  test/Driver/asan.c
  test/Driver/fsanitize-coverage.c
  test/Driver/fsanitize.c
  test/Lexer/has_feature_address_sanitizer.cpp

Index: include/clang/Basic/Sanitizers.def
===
--- include/clang/Basic/Sanitizers.def
+++ include/clang/Basic/Sanitizers.def
@@ -44,8 +44,12 @@
 // Kernel AddressSanitizer (KASan)
 SANITIZER("kernel-address", KernelAddress)
 
+// Hardware-assisted AddressSanitizer
 SANITIZER("hwaddress", HWAddress)
 
+// Kernel Hardware-assisted AddressSanitizer (KHWASan)
+SANITIZER("kernel-hwaddress", KernelHWAddress)
+
 // MemorySanitizer
 SANITIZER("memory", Memory)
 
Index: test/Lexer/has_feature_address_sanitizer.cpp
===
--- test/Lexer/has_feature_address_sanitizer.cpp
+++ test/Lexer/has_feature_address_sanitizer.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -E -fsanitize=address %s -o - | FileCheck --check-prefix=CHECK-ASAN %s
 // RUN: %clang_cc1 -E -fsanitize=kernel-address %s -o - | FileCheck --check-prefix=CHECK-ASAN %s
 // RUN: %clang_cc1 -E -fsanitize=hwaddress %s -o - | FileCheck --check-prefix=CHECK-HWASAN %s
+// RUN: %clang_cc1 -E -fsanitize=kernel-hwaddress %s -o - | FileCheck --check-prefix=CHECK-HWASAN %s
 // RUN: %clang_cc1 -E  %s -o - | FileCheck --check-prefix=CHECK-NO-ASAN %s
 
 #if __has_feature(address_sanitizer)
Index: test/CodeGen/address-safety-attr-flavors.cpp
===
--- test/CodeGen/address-safety-attr-flavors.cpp
+++ test/CodeGen/address-safety-attr-flavors.cpp
@@ -2,6 +2,8 @@
 // HWASan. Either __attribute__((no_sanitize("address")) or
 // __attribute__((no_sanitize("kernel-address")) disables both ASan and KASan
 // instrumentation.
+// Same for __attribute__((no_sanitize("hwaddress")) and
+// __attribute__((no_sanitize("kernel-hwddress")) and HWASan and KHWASan.
 
 // RUN: %clang_cc1 -triple i386-unknown-linux -disable-O0-optnone \
 // RUN:   -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-NOASAN %s
@@ -18,38 +20,56 @@
 // RUN:   -disable-O0-optnone -emit-llvm -o - %s | \
 // RUN:   FileCheck -check-prefix=CHECK-HWASAN %s
 
+// RUN: %clang_cc1 -triple i386-unknown-linux -fsanitize=kernel-hwaddress \
+// RUN:   -disable-O0-optnone -emit-llvm -o - %s | \
+// RUN:   FileCheck -check-prefix=CHECK-KHWASAN %s
+
 int HasSanitizeAddress() { return 1; }
 // CHECK-NOASAN: {{Function Attrs: noinline nounwind$}}
 // CHECK-ASAN: Function Attrs: noinline nounwind sanitize_address
 // CHECK-KASAN: Function Attrs: noinline nounwind sanitize_address
 // CHECK-HWASAN: Function Attrs: noinline nounwind sanitize_hwaddress
+// CHECK-KHWASAN: Function Attrs: noinline nounwind sanitize_hwaddress
 
 __attribute__((no_sanitize("address"))) int NoSanitizeQuoteAddress() {
   return 0;
 }
 // CHECK-NOASAN: {{Function Attrs: noinline nounwind$}}
 // CHECK-ASAN: {{Function Attrs: noinline nounwind$}}
 // CHECK-KASAN: {{Function Attrs: noinline nounwind$}}
 // CHECK-HWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress$}}
+// CHECK-KHWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress$}}
 
 __attribute__((no_sanitize_address)) int NoSanitizeAddress() { return 0; }
 // CHECK-NOASAN: {{Function Attrs: noinline nounwind$}}
 // CHECK-ASAN: {{Function Attrs: noinline nounwind$}}
 // CHECK-KASAN: {{Function Attrs: noinline nounwind$}}
 // CHECK-HWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress$}}
+// CHECK-KHWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress$}}
 
 __attribute__((no_sanitize("kernel-address"))) int NoSanitizeKernelAddress() {
   return 0;
 }
 // CHECK-NOASAN: {{Function Attrs: noinline nounwind$}}
 // CHECK-ASAN: {{Function Attrs: noinline nounwind$}}
 // CHECK-KASAN: {{Function Attrs: noinline nounwind$}}
 // CHECK-HWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress$}}
+// CHECK-KHWASAN: {{Function Attrs: noinline nounwind sanitize_hwaddress$}}
 
 __attribute__((no_sanitize("hwaddress"))) int NoSanitizeHWAddress() {
   return 0;
 }
 // CHECK-NOASAN: {{Function Attrs: noinline nounwind$}}
 // CHECK-ASAN: {{Function Attrs: noinline nounwind sanitize_address$}}
 // CHECK-KASAN: {{Function Attrs: noinline nounwind sanitize_address$}}
 // CHECK-HWASAN: {{Function Attrs: noinline nounwind$}}

[libcxx] r330045 - support: add missing locale stubs for android L, M

2018-04-13 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Fri Apr 13 11:14:57 2018
New Revision: 330045

URL: http://llvm.org/viewvc/llvm-project?rev=330045&view=rev
Log:
support: add missing locale stubs for android L, M

The strto* family was introduced in android O (API Level 26).  However,
the support headers were adjusted to indicate that all locale aware
functions were added in L.  Provide stubs for the locale aware strto*
family until O.

Modified:
libcxx/trunk/include/__locale
libcxx/trunk/include/support/android/locale_bionic.h

Modified: libcxx/trunk/include/__locale
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__locale?rev=330045&r1=330044&r2=330045&view=diff
==
--- libcxx/trunk/include/__locale (original)
+++ libcxx/trunk/include/__locale Fri Apr 13 11:14:57 2018
@@ -24,11 +24,7 @@
 #elif defined(_AIX)
 # include 
 #elif defined(__ANDROID__)
-// Android gained the locale aware functions in L (API level 21)
-# include 
-# if __ANDROID_API__ <= 20
-#  include 
-# endif
+# include 
 #elif defined(__sun__)
 # include 
 # include 

Modified: libcxx/trunk/include/support/android/locale_bionic.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/android/locale_bionic.h?rev=330045&r1=330044&r2=330045&view=diff
==
--- libcxx/trunk/include/support/android/locale_bionic.h (original)
+++ libcxx/trunk/include/support/android/locale_bionic.h Fri Apr 13 11:14:57 
2018
@@ -24,7 +24,44 @@ extern "C" {
 }
 #endif
 
+#if defined(__ANDROID__)
+
+#include 
+
+// Android gained most locale aware functions in L (API level 21)
+#if __ANDROID_API__ < 21
 #include 
+#endif
+
+// The strto* family was added in O (API Level 26)
+#if __ANDROID_API__ < 26
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+inline _LIBCPP_ALWAYS_INLINE float strtof_l(const char* __nptr, char** 
__endptr,
+locale_t) {
+  return ::strtof(__nptr, __endptr);
+}
+
+inline _LIBCPP_ALWAYS_INLINE double strtod_l(const char* __nptr,
+ char** __endptr, locale_t) {
+  return ::strtod(__nptr, __endptr);
+}
+
+inline _LIBCPP_ALWAYS_INLINE long strtol_l(const char* __nptr, char** __endptr,
+   int __base, locale_t) {
+  return ::strtol(__nptr, __endptr, __base);
+}
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif // __ANDROID_API__ < 26
+
+#endif // defined(__ANDROID__)
 
 #endif // defined(__BIONIC__)
 #endif // _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H


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


[PATCH] D45591: Clean carriage returns from lib/ and include/. NFC.

2018-04-13 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons accepted this revision.
malcolm.parsons added a comment.
This revision is now accepted and ready to land.

LGTM. Can't commit right now - using phone.


Repository:
  rC Clang

https://reviews.llvm.org/D45591



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


[PATCH] D45619: [Time-report] (1) Use special new Clang flag 'FrontendTimesIsEnabled' instead of 'llvm::TimePassesIsEnabled' inside -ftime-report feature

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

This makes sense.




Comment at: include/clang/Frontend/Utils.h:241
+/// then the value of this boolean will be true, otherwise false.
+extern bool FrontendTimesIsEnabled;
+

Don't really like global variables, but I guess timers are global state anyway, 
so this isn't really making anything worse.



Comment at: lib/Basic/FrontendTiming.cpp:18
+
+bool FrontendTimesIsEnabled = false;
+

Why is this in lib/Basic, when the declaration is in include/clang/Frontend/?


https://reviews.llvm.org/D45619



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


[PATCH] D45476: [C++2a] Implement operator<=> CodeGen and ExprConstant

2018-04-13 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:9384-9385
+def err_spaceship_comparison_of_void_ptr : Error<
+  "three-way comparison with void pointer %select{operand type|operand types}0 
"
+  "(%1 and %2)">;
+def err_spaceship_comparison_of_invalid_comp_type : Error<

rsmith wrote:
> EricWF wrote:
> > rsmith wrote:
> > > Why are you diagnosing this case as an error?
> > [expr.spaceship]p9 seems to require it. The composite pointer type is not a 
> > function/member/null pointer type, neither is it a object pointer type, so 
> > the program is ill-formed.
> > 
> > Unless I'm missing something.
> void* is an object pointer type.
Oh. right. 'object pointer' vs 'pointer-to-object'.


https://reviews.llvm.org/D45476



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


[PATCH] D45476: [C++2a] Implement operator<=> CodeGen and ExprConstant

2018-04-13 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: lib/Sema/SemaDeclCXX.cpp:
 
+bool Sema::BuildComparisonCategoryData(SourceLocation Loc) {
+  using CCKT = ComparisonCategoryKind;

rsmith wrote:
> EricWF wrote:
> > rsmith wrote:
> > > If you put this on Sema, you'll need to serialize it, and it's no longer 
> > > just a cache.
> > > 
> > > I would prefer to treat this information strictly as a cache, and build 
> > > it in ASTContext. Sema should then just be checking that the information 
> > > is "valid" when it first makes use of such a comparison category type.
> > I agree that it's preferable to just have a cache. However can you clarify 
> > what you mean by "build it in ASTContext"?
> > 
> > Building the expressions will potentially require emitting a diagnostic, 
> > and use of bits of `Sema` (like name lookup).
> > I'm not sure how to do this inside `ASTContext`.
> > 
> > The current implementation caches the data in `ASTContext` but builds it 
> > as-needed in `Sema`. Could you clarify how to go about with the 
> > implementation you're suggesting?
> You don't need "real" name lookup here, just calling lookup on the 
> DeclContext should be fine. We don't need to support more exotic ways of 
> declaring these members, nor access checks etc.
> 
> I was imagining that Sema would check that we can find suitable members on 
> the comparison category types as part of semantically checking a <=> 
> expression, and the ASTContext side of things would not emit diagnostics.
> 
> (Put another way, we'd act as if we look up the members each time we need 
> them, Sema would check that all the necessary members actually exist, and 
> ASTContext would have a caching layer only for convenience / to avoid 
> repeatedly doing the same lookups.)
That's pretty much how this currently works, right?

The only difference is that Sema still eagerly builds the potential result 
values eagerly, because they'll be needed later.


https://reviews.llvm.org/D45476



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


[PATCH] D45616: [X86] Lower _mm[256|512]_cmp[.]_mask intrinsics to native llvm IR

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

> The fcmp opcode has no defined behavior with NaN operands in the comparisions 
> handled in this patch.

Could you describe the problem here in a bit more detail?  As far as I know, 
the LLVM IR fcmp should return the same result as the x86 CMPPD, even without 
fast-math.


Repository:
  rC Clang

https://reviews.llvm.org/D45616



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


r330044 - hwasan: add -fsanitize=kernel-hwaddress flag

2018-04-13 Thread Andrey Konovalov via cfe-commits
Author: andreyknvl
Date: Fri Apr 13 11:05:21 2018
New Revision: 330044

URL: http://llvm.org/viewvc/llvm-project?rev=330044&view=rev
Log:
hwasan: add -fsanitize=kernel-hwaddress flag

This patch adds -fsanitize=kernel-hwaddress flag, that essentially enables
-hwasan-kernel=1 -hwasan-recover=1 -hwasan-match-all-tag=0xff.

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

Modified:
cfe/trunk/include/clang/Basic/Sanitizers.def
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Driver/ToolChains/Linux.cpp
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/test/CodeGen/address-safety-attr-flavors.cpp
cfe/trunk/test/Driver/asan.c
cfe/trunk/test/Driver/fsanitize-coverage.c
cfe/trunk/test/Driver/fsanitize.c
cfe/trunk/test/Lexer/has_feature_address_sanitizer.cpp

Modified: cfe/trunk/include/clang/Basic/Sanitizers.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Sanitizers.def?rev=330044&r1=330043&r2=330044&view=diff
==
--- cfe/trunk/include/clang/Basic/Sanitizers.def (original)
+++ cfe/trunk/include/clang/Basic/Sanitizers.def Fri Apr 13 11:05:21 2018
@@ -44,8 +44,12 @@ SANITIZER("address", Address)
 // Kernel AddressSanitizer (KASan)
 SANITIZER("kernel-address", KernelAddress)
 
+// Hardware-assisted AddressSanitizer
 SANITIZER("hwaddress", HWAddress)
 
+// Kernel Hardware-assisted AddressSanitizer (KHWASan)
+SANITIZER("kernel-hwaddress", KernelHWAddress)
+
 // MemorySanitizer
 SANITIZER("memory", Memory)
 

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=330044&r1=330043&r2=330044&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Apr 13 11:05:21 2018
@@ -233,10 +233,9 @@ static void addAddressSanitizerPasses(co
 static void addKernelAddressSanitizerPasses(const PassManagerBuilder &Builder,
 legacy::PassManagerBase &PM) {
   PM.add(createAddressSanitizerFunctionPass(
-  /*CompileKernel*/ true,
-  /*Recover*/ true, /*UseAfterScope*/ false));
-  PM.add(createAddressSanitizerModulePass(/*CompileKernel*/true,
-  /*Recover*/true));
+  /*CompileKernel*/ true, /*Recover*/ true, /*UseAfterScope*/ false));
+  PM.add(createAddressSanitizerModulePass(
+  /*CompileKernel*/ true, /*Recover*/ true));
 }
 
 static void addHWAddressSanitizerPasses(const PassManagerBuilder &Builder,
@@ -245,7 +244,13 @@ static void addHWAddressSanitizerPasses(
   static_cast(Builder);
   const CodeGenOptions &CGOpts = BuilderWrapper.getCGOpts();
   bool Recover = CGOpts.SanitizeRecover.has(SanitizerKind::HWAddress);
-  PM.add(createHWAddressSanitizerPass(Recover));
+  PM.add(createHWAddressSanitizerPass(/*CompileKernel*/ false, Recover));
+}
+
+static void addKernelHWAddressSanitizerPasses(const PassManagerBuilder 
&Builder,
+legacy::PassManagerBase &PM) {
+  PM.add(createHWAddressSanitizerPass(
+  /*CompileKernel*/ true, /*Recover*/ true));
 }
 
 static void addMemorySanitizerPass(const PassManagerBuilder &Builder,
@@ -581,6 +586,13 @@ void EmitAssemblyHelper::CreatePasses(le
addHWAddressSanitizerPasses);
   }
 
+  if (LangOpts.Sanitize.has(SanitizerKind::KernelHWAddress)) {
+PMBuilder.addExtension(PassManagerBuilder::EP_OptimizerLast,
+   addKernelHWAddressSanitizerPasses);
+PMBuilder.addExtension(PassManagerBuilder::EP_EnabledOnOptLevel0,
+   addKernelHWAddressSanitizerPasses);
+  }
+
   if (LangOpts.Sanitize.has(SanitizerKind::Memory)) {
 PMBuilder.addExtension(PassManagerBuilder::EP_OptimizerLast,
addMemorySanitizerPass);

Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=330044&r1=330043&r2=330044&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Fri Apr 13 11:05:21 2018
@@ -332,6 +332,10 @@ llvm::Function *CodeGenModule::CreateGlo
   !isInSanitizerBlacklist(SanitizerKind::HWAddress, Fn, Loc))
 Fn->addFnAttr(llvm::Attribute::SanitizeHWAddress);
 
+  if (getLangOpts().Sanitize.has(SanitizerKind::KernelHWAddress) &&
+  !isInSanitizerBlacklist(SanitizerKind::KernelHWAddress, Fn, Loc))
+Fn->addFnAttr(llvm::Attribute::SanitizeHWAddress);
+
   if (getLangOpts().Sanitize.has(SanitizerKind::T

Re: [PATCH] D44883: [Sema] Extend -Wself-assign and -Wself-assign-field to warn on overloaded self-assignment (classes)

2018-04-13 Thread Nico Weber via cfe-commits
In the interest of completeness, we now had our first true positive with
this warning, here:
https://github.com/KhronosGroup/VK-GL-CTS/blob/master/framework/referencerenderer/rrFragmentOperations.cpp#L603
(and another self-assign operator= unittest in that repo).

On Fri, Apr 13, 2018 at 3:00 AM, John McCall  wrote:

> (Sorry for the delay in responding — I'm actually on vacation.)
>
> On Tue, Apr 10, 2018 at 1:52 PM, David Blaikie  wrote:
>
>> On Tue, Apr 10, 2018 at 10:20 AM John McCall  wrote:
>>
>>> Do you think they’re bad precedent?
>>
>>
>> Somewhat, yes - though -Wparens is perhaps conflating a few cases too. I
>> think the argument for the -Wparens for precedence is probably pretty good.
>>
>
> True.  I agree that -Wparentheses is really at least three and probably
> four separate warnings, all bundled into one flag.  I was really only
> thinking about the = for == warning, which is an important warning that
> ends up being highly opinionated about how you write your code.
>
> Do you have a replacement for that approach to warning about those
>>> problems?
>>
>>
>> If we were looking at a green field today (code that'd never seen the
>> warning before), I don't think -Wparens for assignment in conditional would
>> pass the bar (or at least the bar as Clang seemed to have 6-7 years ago
>> when I would talk to Doug about warning ideas, as best as I understood the
>> perspective being espoused back then). I suspect maybe in that world we
>> would've found other warnings with lower-false-positive that might've been
>> able to diagnose assignment-in-conditional a bit more precisely than "all
>> assignments are so suspect you have to manually go and look at them to
>> decide".
>>
>
> I think you might be misunderstanding -Wparentheses as primarily a warning
> about confusing precedence rather than primarily a warning about
> accidentally substituting = for ==.  This of course interacts with
> precedence for the conditional operator because the assignment is no longer
> parsed within the condition.   Admittedly, GCC's documentation doesn't
> explain this well.
>
>
>> Because they certainly were precedent for -Wfallthrough, and they
>>> certainly catch a class of bugs at least as large and important as that
>>> warning, and they certainly have exactly the same false-positive
>>> characteristics as it does. I am really struggling to see a difference in
>>> kind or even degree here.
>>>
>>> -Wself-assign is a much less important warning but it’s also far less
>>> likely to see false positives, except in this pattern of unit tests for
>>> data structures, which are not commonly-written code. As is, in fact,
>>> evidenced by Google, a company full of programmers whom I think I can
>>> fairly but affectionately describe as loving to reinvent data structures,
>>> only seeing this warning eight times.
>>>
>>
>> I think the 8 cases were in Chromium - at Google so far (& I'm not sure
>> if that's across all of Google's codebase, or some subset) something in the
>> 100-200 cases?
>>
>
> I see.  8 did seem rather low for all of Google.  And all 100-200 are
> false positives?  Or have only the Chromium cases been investigated yet?
>
> Nico's point that, so far, the only evidence we have is that this warning
>> added false positives and didn't catch any real world bugs. Yeah, a small
>> number/easy enough to cleanup, but all we have is the cost and no idea of
>> the value. (usually when we roll out warnings - even the -Wparens and
>> -Wfallthrough, we find checked in code that has those problems (& the false
>> positive cases) & so we evaluate cost/benefit with that data)
>>
>
> I understand.
>
> I still believe strongly that we should be warning here, but I'm certainly
> open to allowing it to be disabled.  We did actually talk about this during
> the review.  There are three general options here, not necessary exclusive:
> 1. We move it to a separate warning group.  I would argue that (a) this
> should at least be a sub-group so that -Wself-assign turns it on by
> default, and that (b) trivial self-assignments should still be triggered
> under -Wself-assign, for C/C++ consistency if nothing else.
> 2. We find some way to turn it off by recognizing something about the code
> that suggests that we're in test code.
> 3. We add a general -wtest (capitalization intentional) that says "this is
> test code, please don't warn about code patterns that would be unusual in
> normal code but might make sense in tests".  I'm positive I've seen other
> examples of that, e.g. for some of our warnings around misuse of library
> functions.  Many build systems make it fairly early to use different build
> settings when building tests — IIRC that's true of Bazel.
>
> John.
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45476: [C++2a] Implement operator<=> CodeGen and ExprConstant

2018-04-13 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: include/clang/AST/ComparisonCategories.h:77-78
+  ///   comparison category. For example 'std::strong_equality::equal'
+  const DeclRefExpr *getResultValue(ComparisonCategoryResult ValueKind) const {
+const DeclRefExpr *DR = getResultValueUnsafe(ValueKind);
+assert(DR &&

rsmith wrote:
> EricWF wrote:
> > rsmith wrote:
> > > This should deal in `DeclRefExpr*`s, not `NamedDecl*`s. We don't have an 
> > > expression naming the comparison result value, and we shouldn't pretend 
> > > we do.
> > I'm confused. This does deal in `DeclRefExpr*`s. I'm probably being daft. 
> > Could you clarify?
> Sorry, while editing this comment I managed to reverse it from what I meant. 
> This should deal in NamedDecl* (or perhaps ValueDecl*) , not DeclRefExpr*.
OK, so I tried changing this to `VarDecl` but it made the `ExprConstant` and 
`GCExprAgg` implementations a lot harder, since we actually want to evaluate 
the result as a `DeclRefExpr` as we're not evaluating the actual `Decl`. 

Since we don't want to be building dummy `DeclRefExpr`s during evaluation just 
to throw them away, I think it makes sense to eagerly build the results as 
`DeclRefExpr`s.

Does that make sense?


https://reviews.llvm.org/D45476



___
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-13 Thread Ana Pazos via Phabricator via cfe-commits
apazos updated this revision to Diff 142459.
apazos added a comment.

- Simplified hasOtherExtensions() now that we clarified non-standard extensions 
are separated by '_'. We just need to find the first occurrence of the prefixes.
- updated error message, removed "unsupported" from some messages.


https://reviews.llvm.org/D45284

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

Index: test/Driver/riscv-arch.c
===
--- test/Driver/riscv-arch.c
+++ test/Driver/riscv-arch.c
@@ -1,89 +1,245 @@
-// 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 -target riscv64-unknown-elf -march=rv64g -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -target riscv64-unknown-elf -march=rv64gc -### %s -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -target riscv32-unknown-elf -march=rv32i -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -target riscv32-unknown-elf -march=rv32im -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -target riscv32-unknown-elf -march=rv32ima -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -target riscv32-unknown-elf -march=rv32imaf -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -target riscv32-unknown-elf -march=rv32imafd -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+
+// RUN: %clang -target riscv32-unknown-elf -march=rv32ic -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -target riscv3

[PATCH] D17741: adds __FILE_BASENAME__ builtin macro

2018-04-13 Thread Rick Mann via Phabricator via cfe-commits
JetForMe added a comment.

Just want to comment that this functionality is also good for security, as it 
enables hiding of path information in final builds (while still allowing 
logging to show file and line number).


https://reviews.llvm.org/D17741



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


r330064 - [Analyzer] Fix for SValBuilder expressions rearrangement

2018-04-13 Thread Adam Balogh via cfe-commits
Author: baloghadamsoftware
Date: Fri Apr 13 13:23:02 2018
New Revision: 330064

URL: http://llvm.org/viewvc/llvm-project?rev=330064&view=rev
Log:
[Analyzer] Fix for SValBuilder expressions rearrangement

Expression rearrangement in SValBuilder (see rL329780) crashes with an assert 
if the type of the integer is different from the type of the symbol. This fix 
adds a check that prevents rearrangement in such cases.

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


Modified:
cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
cfe/trunk/test/Analysis/svalbuilder-rearrange-comparisons.c

Modified: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp?rev=330064&r1=330063&r2=330064&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp Fri Apr 13 13:23:02 
2018
@@ -469,6 +469,8 @@ static Optional tryRearrange(Pro
 // Initialize SingleTy later with a symbol's type.
   } else if (BinaryOperator::isAdditiveOp(Op)) {
 SingleTy = ResultTy;
+if (LSym->getType() != SingleTy)
+  return None;
 // Substracting unsigned integers is a nightmare.
 if (!SingleTy->isSignedIntegerOrEnumerationType())
   return None;

Modified: cfe/trunk/test/Analysis/svalbuilder-rearrange-comparisons.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/svalbuilder-rearrange-comparisons.c?rev=330064&r1=330063&r2=330064&view=diff
==
--- cfe/trunk/test/Analysis/svalbuilder-rearrange-comparisons.c (original)
+++ cfe/trunk/test/Analysis/svalbuilder-rearrange-comparisons.c Fri Apr 13 
13:23:02 2018
@@ -929,3 +929,8 @@ void overflow(signed char n, signed char
 clang_analyzer_eval(n - 126 == m + 3); // expected-warning{{UNKNOWN}}
   }
 }
+
+int mixed_integer_types(int x, int y) {
+  short a = x - 1U;
+  return a - y;
+}


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


[PATCH] D45557: [Analyzer] Fix for SValBuilder expressions rearrangement

2018-04-13 Thread Balogh , Ádám via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC330064: [Analyzer] Fix for SValBuilder expressions 
rearrangement (authored by baloghadamsoftware, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D45557

Files:
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  test/Analysis/svalbuilder-rearrange-comparisons.c


Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -469,6 +469,8 @@
 // Initialize SingleTy later with a symbol's type.
   } else if (BinaryOperator::isAdditiveOp(Op)) {
 SingleTy = ResultTy;
+if (LSym->getType() != SingleTy)
+  return None;
 // Substracting unsigned integers is a nightmare.
 if (!SingleTy->isSignedIntegerOrEnumerationType())
   return None;
Index: test/Analysis/svalbuilder-rearrange-comparisons.c
===
--- test/Analysis/svalbuilder-rearrange-comparisons.c
+++ test/Analysis/svalbuilder-rearrange-comparisons.c
@@ -929,3 +929,8 @@
 clang_analyzer_eval(n - 126 == m + 3); // expected-warning{{UNKNOWN}}
   }
 }
+
+int mixed_integer_types(int x, int y) {
+  short a = x - 1U;
+  return a - y;
+}


Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -469,6 +469,8 @@
 // Initialize SingleTy later with a symbol's type.
   } else if (BinaryOperator::isAdditiveOp(Op)) {
 SingleTy = ResultTy;
+if (LSym->getType() != SingleTy)
+  return None;
 // Substracting unsigned integers is a nightmare.
 if (!SingleTy->isSignedIntegerOrEnumerationType())
   return None;
Index: test/Analysis/svalbuilder-rearrange-comparisons.c
===
--- test/Analysis/svalbuilder-rearrange-comparisons.c
+++ test/Analysis/svalbuilder-rearrange-comparisons.c
@@ -929,3 +929,8 @@
 clang_analyzer_eval(n - 126 == m + 3); // expected-warning{{UNKNOWN}}
   }
 }
+
+int mixed_integer_types(int x, int y) {
+  short a = x - 1U;
+  return a - y;
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44788: Add an option to support debug fission on implicit ThinLTO.

2018-04-13 Thread Yunlian Jiang via Phabricator via cfe-commits
yunlian added a comment.

I prefer to have a dedicated directory to store all the .dwo files. As dblaikie 
 said, all the .dwo files are temporary files. In addition, in order to 
differentiate the .dwo files generated by different link stage with the same 
.o, we need to add
some suffixes to the .dwo file. So for a file a.o, we may need to generate a 
.dwo named a._${number}_${random_string}.dwo, which is not neat. Furthermore, 
we need to dealing with archive files. In this case, we may need to generate
multiple .dwo files for a single archive files.


https://reviews.llvm.org/D44788



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


r330067 - Use InitLLVM in clang as well.

2018-04-13 Thread Rui Ueyama via cfe-commits
Author: ruiu
Date: Fri Apr 13 13:57:57 2018
New Revision: 330067

URL: http://llvm.org/viewvc/llvm-project?rev=330067&view=rev
Log:
Use InitLLVM in clang as well.

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

Modified:
cfe/trunk/tools/clang-format/ClangFormat.cpp
cfe/trunk/tools/driver/driver.cpp

Modified: cfe/trunk/tools/clang-format/ClangFormat.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/ClangFormat.cpp?rev=330067&r1=330066&r2=330067&view=diff
==
--- cfe/trunk/tools/clang-format/ClangFormat.cpp (original)
+++ cfe/trunk/tools/clang-format/ClangFormat.cpp Fri Apr 13 13:57:57 2018
@@ -22,8 +22,8 @@
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Process.h"
-#include "llvm/Support/Signals.h"
 
 using namespace llvm;
 using clang::tooling::Replacements;
@@ -338,21 +338,13 @@ static void PrintVersion(raw_ostream &OS
 }
 
 int main(int argc, const char **argv) {
-  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
-
-  SmallVector Args;
-  llvm::SpecificBumpPtrAllocator ArgAllocator;
-  std::error_code EC = llvm::sys::Process::GetArgumentVector(
-  Args, llvm::makeArrayRef(argv, argc), ArgAllocator);
-  if (EC) {
-llvm::errs() << "error: couldn't get arguments: " << EC.message() << '\n';
-  }
+  llvm::InitLLVM X(argc, argv);
 
   cl::HideUnrelatedOptions(ClangFormatCategory);
 
   cl::SetVersionPrinter(PrintVersion);
   cl::ParseCommandLineOptions(
-  Args.size(), &Args[0],
+  argc, argv,
   "A tool to format C/C++/Java/JavaScript/Objective-C/Protobuf code.\n\n"
   "If no arguments are specified, it formats the code from standard 
input\n"
   "and writes the result to the standard output.\n"

Modified: cfe/trunk/tools/driver/driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/driver.cpp?rev=330067&r1=330066&r2=330067&view=diff
==
--- cfe/trunk/tools/driver/driver.cpp (original)
+++ cfe/trunk/tools/driver/driver.cpp Fri Apr 13 13:57:57 2018
@@ -12,9 +12,9 @@
 //
 
//===--===//
 
+#include "clang/Driver/Driver.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Driver/Compilation.h"
-#include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
 #include "clang/Driver/ToolChain.h"
@@ -34,9 +34,8 @@
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Host.h"
-#include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Path.h"
-#include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/Regex.h"
@@ -322,22 +321,12 @@ static int ExecuteCC1Tool(ArrayRef argv(argv_, argv_ + argc_);
 
   if (llvm::sys::Process::FixupStandardFileDescriptors())
 return 1;
 
-  SmallVector argv;
-  llvm::SpecificBumpPtrAllocator ArgAllocator;
-  std::error_code EC = llvm::sys::Process::GetArgumentVector(
-  argv, llvm::makeArrayRef(argv_, argc_), ArgAllocator);
-  if (EC) {
-llvm::errs() << "error: couldn't get arguments: " << EC.message() << '\n';
-return 1;
-  }
-
   llvm::InitializeAllTargets();
   auto TargetAndMode = ToolChain::getTargetAndModeFromProgramName(argv[0]);
 


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


[PATCH] D45634: Use InitLLVM in clang as well.

2018-04-13 Thread Rui Ueyama via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC330067: Use InitLLVM in clang as well. (authored by ruiu, 
committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D45634?vs=142462&id=142463#toc

Repository:
  rC Clang

https://reviews.llvm.org/D45634

Files:
  tools/clang-format/ClangFormat.cpp
  tools/driver/driver.cpp


Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -12,9 +12,9 @@
 //
 
//===--===//
 
+#include "clang/Driver/Driver.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Driver/Compilation.h"
-#include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
 #include "clang/Driver/ToolChain.h"
@@ -34,9 +34,8 @@
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Host.h"
-#include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Path.h"
-#include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/Regex.h"
@@ -322,22 +321,12 @@
 }
 
 int main(int argc_, const char **argv_) {
-  llvm::sys::PrintStackTraceOnErrorSignal(argv_[0]);
-  llvm::PrettyStackTraceProgram X(argc_, argv_);
-  llvm::llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
+  llvm::InitLLVM X(argc_, argv_);
+  SmallVector argv(argv_, argv_ + argc_);
 
   if (llvm::sys::Process::FixupStandardFileDescriptors())
 return 1;
 
-  SmallVector argv;
-  llvm::SpecificBumpPtrAllocator ArgAllocator;
-  std::error_code EC = llvm::sys::Process::GetArgumentVector(
-  argv, llvm::makeArrayRef(argv_, argc_), ArgAllocator);
-  if (EC) {
-llvm::errs() << "error: couldn't get arguments: " << EC.message() << '\n';
-return 1;
-  }
-
   llvm::InitializeAllTargets();
   auto TargetAndMode = ToolChain::getTargetAndModeFromProgramName(argv[0]);
 
Index: tools/clang-format/ClangFormat.cpp
===
--- tools/clang-format/ClangFormat.cpp
+++ tools/clang-format/ClangFormat.cpp
@@ -22,8 +22,8 @@
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Process.h"
-#include "llvm/Support/Signals.h"
 
 using namespace llvm;
 using clang::tooling::Replacements;
@@ -338,21 +338,13 @@
 }
 
 int main(int argc, const char **argv) {
-  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
-
-  SmallVector Args;
-  llvm::SpecificBumpPtrAllocator ArgAllocator;
-  std::error_code EC = llvm::sys::Process::GetArgumentVector(
-  Args, llvm::makeArrayRef(argv, argc), ArgAllocator);
-  if (EC) {
-llvm::errs() << "error: couldn't get arguments: " << EC.message() << '\n';
-  }
+  llvm::InitLLVM X(argc, argv);
 
   cl::HideUnrelatedOptions(ClangFormatCategory);
 
   cl::SetVersionPrinter(PrintVersion);
   cl::ParseCommandLineOptions(
-  Args.size(), &Args[0],
+  argc, argv,
   "A tool to format C/C++/Java/JavaScript/Objective-C/Protobuf code.\n\n"
   "If no arguments are specified, it formats the code from standard 
input\n"
   "and writes the result to the standard output.\n"


Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -12,9 +12,9 @@
 //
 //===--===//
 
+#include "clang/Driver/Driver.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Driver/Compilation.h"
-#include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
 #include "clang/Driver/ToolChain.h"
@@ -34,9 +34,8 @@
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Host.h"
-#include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Path.h"
-#include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/Regex.h"
@@ -322,22 +321,12 @@
 }
 
 int main(int argc_, const char **argv_) {
-  llvm::sys::PrintStackTraceOnErrorSignal(argv_[0]);
-  llvm::PrettyStackTraceProgram X(argc_, argv_);
-  llvm::llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
+  llvm::InitLLVM X(argc_, argv_);
+  SmallVector argv(argv_, argv_ + argc_);
 
   if (llvm::sys::Process::FixupStandardFileDescriptors())
 return 1;
 
-  SmallVector argv;
-  llvm::SpecificBumpPtrAllocator ArgAllocator;
-  std::error_code EC = llvm::sys::Process::GetArgumentVector(
-  argv, llvm::makeArrayRef(argv_, argc_), ArgAllocator);
-  if (EC) {
-

r330068 - [Serialization] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

2018-04-13 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Fri Apr 13 14:12:33 2018
New Revision: 330068

URL: http://llvm.org/viewvc/llvm-project?rev=330068&view=rev
Log:
[Serialization] Fix some Clang-tidy modernize and Include What You Use 
warnings; other minor fixes (NFC).

Modified:
cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=330068&r1=330067&r2=330068&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Apr 13 14:12:33 2018
@@ -71,6 +71,7 @@
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Lex/Token.h"
+#include "clang/Sema/DeclSpec.h"
 #include "clang/Sema/ObjCMethodList.h"
 #include "clang/Sema/Scope.h"
 #include "clang/Sema/Sema.h"
@@ -97,11 +98,11 @@
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/ADT/iterator_range.h"
+#include "llvm/Bitcode/BitCodes.h"
 #include "llvm/Bitcode/BitstreamReader.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Compression.h"
@@ -133,8 +134,8 @@
 #include 
 
 using namespace clang;
-using namespace clang::serialization;
-using namespace clang::serialization::reader;
+using namespace serialization;
+using namespace reader;
 using llvm::BitstreamCursor;
 
 
//===--===//
@@ -463,7 +464,7 @@ static bool checkDiagnosticGroupMappings
   // errors because of options like -Werror.
   DiagnosticsEngine *MappingSources[] = { &Diags, &StoredDiags };
 
-  for (DiagnosticsEngine *MappingSource : MappingSources) {
+  for (auto *MappingSource : MappingSources) {
 for (auto DiagIDMappingPair : MappingSource->getDiagnosticMappings()) {
   diag::kind DiagID = DiagIDMappingPair.first;
   Level CurLevel = Diags.getDiagnosticLevel(DiagID, SourceLocation());
@@ -581,9 +582,9 @@ static void
 collectMacroDefinitions(const PreprocessorOptions &PPOpts,
 MacroDefinitionsMap &Macros,
 SmallVectorImpl *MacroNames = nullptr) {
-  for (unsigned I = 0, N = PPOpts.Macros.size(); I != N; ++I) {
-StringRef Macro = PPOpts.Macros[I].first;
-bool IsUndef = PPOpts.Macros[I].second;
+  for (const auto &I : PPOpts.Macros) {
+StringRef Macro = I.first;
+bool IsUndef = I.second;
 
 std::pair MacroPair = Macro.split('=');
 StringRef MacroName = MacroPair.first;
@@ -634,9 +635,8 @@ static bool checkPreprocessorOptions(con
   SmallVector ExistingMacroNames;
   collectMacroDefinitions(ExistingPPOpts, ExistingMacros, &ExistingMacroNames);
 
-  for (unsigned I = 0, N = ExistingMacroNames.size(); I != N; ++I) {
+  for (auto MacroName : ExistingMacroNames) {
 // Dig out the macro definition in the existing preprocessor options.
-StringRef MacroName = ExistingMacroNames[I];
 std::pair Existing = ExistingMacros[MacroName];
 
 // Check whether we know anything about this macro name or not.
@@ -702,8 +702,7 @@ static bool checkPreprocessorOptions(con
   }
 
   // Compute the #include and #include_macros lines we need.
-  for (unsigned I = 0, N = ExistingPPOpts.Includes.size(); I != N; ++I) {
-StringRef File = ExistingPPOpts.Includes[I];
+  for (const auto &File : ExistingPPOpts.Includes) {
 if (File == ExistingPPOpts.ImplicitPCHInclude)
   continue;
 
@@ -716,8 +715,7 @@ static bool checkPreprocessorOptions(con
 SuggestedPredefines += "\"\n";
   }
 
-  for (unsigned I = 0, N = ExistingPPOpts.MacroIncludes.size(); I != N; ++I) {
-StringRef File = ExistingPPOpts.MacroIncludes[I];
+  for (const auto &File : ExistingPPOpts.MacroIncludes) {
 if (std::find(PPOpts.MacroIncludes.begin(), PPOpts.MacroIncludes.end(),
   File)
 != PPOpts.MacroIncludes.end())
@@ -855,14 +853,14 @@ ASTSelectorLookupTrait::ReadData(Selecto
 
   // Load instance methods
   for (unsigned I = 0; I != NumInstanceMethods; ++I) {
-if (ObjCMethodDecl *Method = Reader.GetLocalDeclAs(
+if (auto *Method = Reader.GetLocalDeclAs(
 F, endian::readNext(d)))
   Result.Instance.push_back(Method);
   }
 
   // Load factory methods
   for (unsigned I = 0; I != NumFactoryMethods; ++I) {
-if (ObjCMethodDecl *Method = Reader.GetLocalDeclAs(
+if (auto *Method = Reader.GetLocalDeclAs(
 F, endian::readNext(d)))
   Result.Factory.push_back(Method);
   }
@@ -1087,7 +1085,7 @@ ASTDeclContextNameLookupTrait::internal_
 ASTDeclContextNameLookupTrait::ReadKey(const unsigned char *d, unsigned) {
   using namespace llvm::support;
 
-  auto Kind = (DeclarationName::NameKind)*d++;
+  auto Kind = static_cast(*d++

[PATCH] D45476: [C++2a] Implement operator<=> CodeGen and ExprConstant

2018-04-13 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: include/clang/AST/ComparisonCategories.h:77-78
+  ///   comparison category. For example 'std::strong_equality::equal'
+  const DeclRefExpr *getResultValue(ComparisonCategoryResult ValueKind) const {
+const DeclRefExpr *DR = getResultValueUnsafe(ValueKind);
+assert(DR &&

EricWF wrote:
> rsmith wrote:
> > EricWF wrote:
> > > rsmith wrote:
> > > > This should deal in `DeclRefExpr*`s, not `NamedDecl*`s. We don't have 
> > > > an expression naming the comparison result value, and we shouldn't 
> > > > pretend we do.
> > > I'm confused. This does deal in `DeclRefExpr*`s. I'm probably being daft. 
> > > Could you clarify?
> > Sorry, while editing this comment I managed to reverse it from what I 
> > meant. This should deal in NamedDecl* (or perhaps ValueDecl*) , not 
> > DeclRefExpr*.
> OK, so I tried changing this to `VarDecl` but it made the `ExprConstant` and 
> `GCExprAgg` implementations a lot harder, since we actually want to evaluate 
> the result as a `DeclRefExpr` as we're not evaluating the actual `Decl`. 
> 
> Since we don't want to be building dummy `DeclRefExpr`s during evaluation 
> just to throw them away, I think it makes sense to eagerly build the results 
> as `DeclRefExpr`s.
> 
> Does that make sense?
Not really; forming a value that denotes an arbitrary (non-reference) variable 
in both those places seems like it should be straightforward. If you really 
want a DeclRefExpr in those places as an implementation convenience, you could 
synthesize one on the stack. But that'd be an implementation detail of those 
consumers of this information, not something we should be exposing here, and 
seems like it should be easy to avoid.



Comment at: lib/Sema/SemaDeclCXX.cpp:
 
+bool Sema::BuildComparisonCategoryData(SourceLocation Loc) {
+  using CCKT = ComparisonCategoryKind;

EricWF wrote:
> rsmith wrote:
> > EricWF wrote:
> > > rsmith wrote:
> > > > If you put this on Sema, you'll need to serialize it, and it's no 
> > > > longer just a cache.
> > > > 
> > > > I would prefer to treat this information strictly as a cache, and build 
> > > > it in ASTContext. Sema should then just be checking that the 
> > > > information is "valid" when it first makes use of such a comparison 
> > > > category type.
> > > I agree that it's preferable to just have a cache. However can you 
> > > clarify what you mean by "build it in ASTContext"?
> > > 
> > > Building the expressions will potentially require emitting a diagnostic, 
> > > and use of bits of `Sema` (like name lookup).
> > > I'm not sure how to do this inside `ASTContext`.
> > > 
> > > The current implementation caches the data in `ASTContext` but builds it 
> > > as-needed in `Sema`. Could you clarify how to go about with the 
> > > implementation you're suggesting?
> > You don't need "real" name lookup here, just calling lookup on the 
> > DeclContext should be fine. We don't need to support more exotic ways of 
> > declaring these members, nor access checks etc.
> > 
> > I was imagining that Sema would check that we can find suitable members on 
> > the comparison category types as part of semantically checking a <=> 
> > expression, and the ASTContext side of things would not emit diagnostics.
> > 
> > (Put another way, we'd act as if we look up the members each time we need 
> > them, Sema would check that all the necessary members actually exist, and 
> > ASTContext would have a caching layer only for convenience / to avoid 
> > repeatedly doing the same lookups.)
> That's pretty much how this currently works, right?
> 
> The only difference is that Sema still eagerly builds the potential result 
> values eagerly, because they'll be needed later.
You can't rely on Sema existing or having done this in the case where we're 
loading from an AST file.


https://reviews.llvm.org/D45476



___
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-13 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: dexonsmith, compnerd.
Herald added a reviewer: EricWF.
Herald added a subscriber: cfe-commits.

Darwin driver currently uses libc++ headers that are part of Clang
toolchain when available (by default ../include/c++/v1 relative to
executable), but it completely ignores the libc++ library itself
because it doesn't pass the location of libc++ library that's part
of Clang (by default ../lib relative to the exceutable) to the linker
always using the system copy of libc++.

This may lead to subtle issues when the compilation fails because the
headers that are part of Clang toolchain are incompatible with the
system library. Either the driver should ignore both headers as well as
the library, or it should always try to use both when available.

This patch changes the driver behavior to do the latter which seems more
reasonable, it makes it easy to test and use custom libc++ build on
Darwin while still allowing the use of system version. This also matches
the Clang driver behavior on other systems.


Repository:
  rC Clang

https://reviews.llvm.org/D45639

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp


Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -508,6 +508,8 @@
 
   Args.AddAllArgs(CmdArgs, options::OPT_L);
 
+  getToolChain().AddFilePathLibArgs(Args, CmdArgs);
+
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
   // Build the input file for -filelist (list of linker input files) in case we
   // need it later
@@ -668,6 +670,7 @@
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir)
 getProgramPaths().push_back(getDriver().Dir);
+  getFilePaths().push_back(getDriver().Dir + "/../lib");
 }
 
 /// Darwin - Darwin tool chain for i386 and x86_64.


Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -508,6 +508,8 @@
 
   Args.AddAllArgs(CmdArgs, options::OPT_L);
 
+  getToolChain().AddFilePathLibArgs(Args, CmdArgs);
+
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
   // Build the input file for -filelist (list of linker input files) in case we
   // need it later
@@ -668,6 +670,7 @@
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir)
 getProgramPaths().push_back(getDriver().Dir);
+  getFilePaths().push_back(getDriver().Dir + "/../lib");
 }
 
 /// Darwin - Darwin tool chain for i386 and x86_64.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r330074 - [ODRHash] Support pointer and reference types.

2018-04-13 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Apr 13 15:34:43 2018
New Revision: 330074

URL: http://llvm.org/viewvc/llvm-project?rev=330074&view=rev
Log:
[ODRHash] Support pointer and reference types.

Recommit r328404 which was reverted in rL328404.  r329869 fixed the issue that
caused the revert.

Modified:
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=330074&r1=330073&r2=330074&view=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Fri Apr 13 15:34:43 2018
@@ -642,6 +642,24 @@ public:
 VisitFunctionType(T);
   }
 
+  void VisitPointerType(const PointerType *T) {
+AddQualType(T->getPointeeType());
+VisitType(T);
+  }
+
+  void VisitReferenceType(const ReferenceType *T) {
+AddQualType(T->getPointeeTypeAsWritten());
+VisitType(T);
+  }
+
+  void VisitLValueReferenceType(const LValueReferenceType *T) {
+VisitReferenceType(T);
+  }
+
+  void VisitRValueReferenceType(const RValueReferenceType *T) {
+VisitReferenceType(T);
+  }
+
   void VisitTypedefType(const TypedefType *T) {
 AddDecl(T->getDecl());
 QualType UnderlyingType = T->getDecl()->getUnderlyingType();

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=330074&r1=330073&r2=330074&view=diff
==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Fri Apr 13 15:34:43 2018
@@ -2286,6 +2286,127 @@ Invalid1 i1;
 #undef DECLS
 }  // namespace BaseClass
 
+namespace PointersAndReferences {
+#if defined(FIRST) || defined(SECOND)
+template struct Wrapper{};
+#endif
+
+#if defined(FIRST)
+struct S1 {
+  Wrapper x;
+};
+#elif defined(SECOND)
+struct S1 {
+  Wrapper x;
+};
+#else
+S1 s1;
+// expected-error@first.h:* {{PointersAndReferences::S1::x' from module 
'FirstModule' is not present in definition of 'PointersAndReferences::S1' in 
module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
+#endif
+
+#if defined(FIRST)
+struct S2 {
+  Wrapper x;
+};
+#elif defined(SECOND)
+struct S2 {
+  Wrapper x;
+};
+#else
+S2 s2;
+// expected-error@first.h:* {{PointersAndReferences::S2::x' from module 
'FirstModule' is not present in definition of 'PointersAndReferences::S2' in 
module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
+#endif
+
+#if defined(FIRST)
+struct S3 {
+  Wrapper x;
+};
+#elif defined(SECOND)
+struct S3 {
+  Wrapper x;
+};
+#else
+S3 s3;
+// expected-error@first.h:* {{PointersAndReferences::S3::x' from module 
'FirstModule' is not present in definition of 'PointersAndReferences::S3' in 
module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
+#endif
+
+#if defined(FIRST)
+struct S4 {
+  Wrapper x;
+};
+#elif defined(SECOND)
+struct S4 {
+  Wrapper x;
+};
+#else
+S4 s4;
+// expected-error@first.h:* {{PointersAndReferences::S4::x' from module 
'FirstModule' is not present in definition of 'PointersAndReferences::S4' in 
module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
+#endif
+
+#if defined(FIRST)
+struct S5 {
+  Wrapper x;
+};
+#elif defined(SECOND)
+struct S5 {
+  Wrapper x;
+};
+#else
+S5 s5;
+// expected-error@second.h:* {{'PointersAndReferences::S5::x' from module 
'SecondModule' is not present in definition of 'PointersAndReferences::S5' in 
module 'FirstModule'}}
+// expected-note@first.h:* {{declaration of 'x' does not match}}
+#endif
+
+#if defined(FIRST)
+struct S6 {
+  Wrapper x;
+};
+#elif defined(SECOND)
+struct S6 {
+  Wrapper x;
+};
+#else
+S6 s6;
+// expected-error@first.h:* {{PointersAndReferences::S6::x' from module 
'FirstModule' is not present in definition of 'PointersAndReferences::S6' in 
module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
+#endif
+
+#define DECLS\
+  Wrapper x1; \
+  Wrapper x2;   \
+  Wrapper x3; \
+  Wrapper x4; \
+  Wrapper x5;\
+  Wrapper x6;   \
+  Wrapper x7;  \
+  Wrapper x8;  \
+  Wrapper x9;
+
+#if defined(FIRST) || defined(SECOND)
+struct Valid1 {
+  DECLS
+};
+#else
+Valid1 v1;
+#endif
+
+#if defined(FIRST) || defined(SECOND)
+struct Invalid1 {
+  DECLS
+  ACCESS
+};
+#else
+Invalid1 i1;
+// expected-error@second.h:* {{'PointersAndReferences::Invalid1' has different 
definitions in different modules; first difference is definition in module 
'SecondModule' found private access specifier}}
+// expected-note@first.h:* {{but in 'FirstModule' found public access 
specifier}}
+#endif
+#undef DECLS
+}  // namespace PointersAndReferences
+
 
 // Collection of interesting cases below.
 


___

[PATCH] D45643: [Failing one test] Reword [-Wreturn-type] messages to "non-void x does not return a value"

2018-04-13 Thread easyaspi314 (Devin) via Phabricator via cfe-commits
easyaspi314 created this revision.
easyaspi314 added a project: clang.
Herald added a subscriber: cfe-commits.

Replace [-Wreturn-type] messages, "control reaches/may reach end of non-void 
x", to "non-void x does/might not return a value".

F5962917: Screen Shot 2018-04-13 at 6.56.17 PM.png 


That warning is a very cryptic error copied from GCC, and I had to memorize the 
real meaning of the message in order to make sense of it.

If you were to merge this, 'Clang :: Misc/serialized-diags-stable.c' will fail.

I need some help on this one, as 
clang/test/Misc/Inputs/serialized-diags-stable.dia is a binary which needs to 
be regenerated, and I don't exactly know how to do that.


Repository:
  rC Clang

https://reviews.llvm.org/D45643

Files:
  bindings/python/tests/cindex/test_diagnostics.py
  docs/DiagnosticsReference.rst
  include/clang/Basic/DiagnosticASTKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  test/Analysis/const-method-call.cpp
  test/Analysis/logical-ops.c
  test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
  test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
  test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp
  test/CodeGenObjCXX/property-dot-reference.mm
  test/Driver/cc-log-diagnostics.c
  test/Frontend/absolute-paths.c
  test/Frontend/ast-main.cpp
  test/Index/warning-flags.c
  test/Misc/serialized-diags-stable.c
  test/Modules/redecl-merge.m
  test/PCH/late-parsed-instantiations.cpp
  test/Sema/block-return-1.c
  test/Sema/block-return-3.c
  test/Sema/freemain.c
  test/Sema/return.c
  test/SemaCXX/attr-noreturn.cpp
  test/SemaCXX/constant-expression-cxx1y.cpp
  test/SemaCXX/coreturn.cpp
  test/SemaCXX/cxx1y-deduced-return-type.cpp
  test/SemaCXX/return-noreturn.cpp
  test/SemaCXX/warn-missing-noreturn.cpp
  test/SemaTemplate/late-parsing-eager-instantiation.cpp

Index: test/SemaTemplate/late-parsing-eager-instantiation.cpp
===
--- test/SemaTemplate/late-parsing-eager-instantiation.cpp
+++ test/SemaTemplate/late-parsing-eager-instantiation.cpp
@@ -15,8 +15,8 @@
   char data() {
 visit([](auto buffer) -> char { // expected-note {{in instantiation}}
   buffer->data();
-}); // expected-warning {{control reaches end of non-void lambda}}
-  } // expected-warning {{control reaches end of non-void function}}
+}); // expected-warning {{non-void lambda does not return a value}}
+  } // expected-warning {{non-void function does not return a value}}
 };
 
 // pr34185
Index: test/SemaCXX/warn-missing-noreturn.cpp
===
--- test/SemaCXX/warn-missing-noreturn.cpp
+++ test/SemaCXX/warn-missing-noreturn.cpp
@@ -91,7 +91,7 @@
 
 int rdar8875247_test() {
   rdar8875247 f;
-} // expected-warning{{control reaches end of non-void function}}
+} // expected-warning{{non-void function does not return a value}}
 
 struct rdar8875247_B {
   rdar8875247_B();
Index: test/SemaCXX/return-noreturn.cpp
===
--- test/SemaCXX/return-noreturn.cpp
+++ test/SemaCXX/return-noreturn.cpp
@@ -26,7 +26,7 @@
   }
   int f2_positive(int x) {
 switch (x) { default: ; }
-  } // expected-warning {{control reaches end of non-void function}}
+  } // expected-warning {{non-void function does not return a value}}
   int f3(int x) {
 switch (x) { default: { pr6884_abort_struct(); } }
   }
@@ -46,7 +46,7 @@
   pr6884_abort_struct *p = new pr6884_abort_struct();
   delete p;
 }
-  } // expected-warning {{control reaches end of non-void function}}
+  } // expected-warning {{non-void function does not return a value}}
 
   // Test that these constructs work even when extraneous blocks are created
   // before and after the switch due to implicit destructors.
@@ -61,7 +61,7 @@
   int g2_positive(int x) {
 other o;
 switch (x) { default: ; }
-  } // expected-warning {{control reaches end of non-void function}}
+  } // expected-warning {{non-void function does not return a value}}
   int g3(int x) {
 other o;
 switch (x) { default: { pr6884_abort_struct(); } }
@@ -140,7 +140,7 @@
 default:
 break;
   }
-} // expected-warning {{control reaches end of non-void function}}
+} // expected-warning {{non-void function does not return a value}}
 
 void PR9412_f() {
 PR9412_t(); // expected-note {{in instantiation of function template specialization 'PR9412_t' requested here}}
@@ -165,7 +165,7 @@
 
 int testTernaryStaticallyConditionalRetrunOnTrue() {
   true ? Return() : NoReturn();
-} // expected-warning {{control reaches end of non-void function}}
+} // expected-warning {{non-void function does not return a value}}
 
 int testTernaryStaticallyConditionalNoretrunOnFalse() {
   false ? Return() : NoReturn();
@@ -173,23 +173,23 @@
 
 int testTernaryStaticallyConditionalRetrunOnFalse() {
   false ? NoReturn() : Return();
-} // expected-warning {{control 

r330077 - [Driver] Export profiling symbols for -exported_symbols_list

2018-04-13 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Fri Apr 13 16:43:59 2018
New Revision: 330077

URL: http://llvm.org/viewvc/llvm-project?rev=330077&view=rev
Log:
[Driver] Export profiling symbols for -exported_symbols_list

When profiling is enabled and -exported_symbols_list is specified for
the Darwin linker, export the requisite set of profiling symbols.

rdar://39427167

Modified:
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/test/Driver/darwin-ld.c

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=330077&r1=330076&r2=330077&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Fri Apr 13 16:43:59 2018
@@ -988,6 +988,8 @@ StringRef Darwin::getOSLibraryNameSuffix
 /// Check if the link command contains a symbol export directive.
 static bool hasExportSymbolDirective(const ArgList &Args) {
   for (Arg *A : Args) {
+if (A->getOption().matches(options::OPT_exported__symbols__list))
+  return true;
 if (!A->getOption().matches(options::OPT_Wl_COMMA) &&
 !A->getOption().matches(options::OPT_Xlinker))
   continue;

Modified: cfe/trunk/test/Driver/darwin-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-ld.c?rev=330077&r1=330076&r2=330077&view=diff
==
--- cfe/trunk/test/Driver/darwin-ld.c (original)
+++ cfe/trunk/test/Driver/darwin-ld.c Fri Apr 13 16:43:59 2018
@@ -356,6 +356,8 @@
 // RUN: FileCheck -check-prefix=LINK_PROFILE_FIRST %s < %t.log
 // LINK_PROFILE_FIRST: {{ld(.exe)?"}} 
"{{[^"]+}}libclang_rt.profile_{{[a-z]+}}.a"
 
+// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate 
-exported_symbols_list /dev/null -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
 // RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate 
-Wl,-exported_symbols_list,/dev/null -### %t.o 2> %t.log
 // RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
 // RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate 
-Wl,-exported_symbol,foo -### %t.o 2> %t.log


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


[PATCH] D43578: -ftime-report switch support in Clang

2018-04-13 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Last time I looked at doing this, I found that LLVM's timer infrastructure was 
fundamentally unsuitable for adding timers like these to Clang. The big 
problems are that Clang switches between "layers" and pieces that should be 
independently accounted at a very large number of call sites (eg, there are 
hundreds of functions on Sema that the Parser calls), and that Clang makes 
heavy use of recursion and delegation between functions that we might want to 
time (and generally has a very complex call graph, matching the complexity of 
the grammars that it parses). Unless there have been major changes, none of 
that actually works in LLVM's timer infrastructure: the time allocated to 
recursive and mutually-recursive functions is misaccounted (double-counted or 
worse), and there's no real way to extract the amount of time spent parsing a 
particular kind of declaration without including all the time spent in nested 
subactions (such as instantiating unrelated templates, generating code, and so 
on) -- and even enumerating all the barriers between "time spent in parsing" 
and "time spent in semantic analysis" does not seem reasonable. Generating 
user-friendly but misleading and likely wrong timing data seems like it would 
be a big problem here.

So I don't think this patch is reasonable for that reason. I'm also not sure 
whether this, as is, is addressing a pressing use case -- for Clang developers, 
existing non-invasive profiling tools (such as linux-perftools) are likely to 
work a lot better for identifying where in the Clang source code we're spending 
time. And Clang users typically don't care which function we're in (unless 
they're filing a bug, where again a profiler is probably a better tool).

However, I do think we could make `-ftime-report` vastly more useful to Clang 
users. Specifically, I think the useful, actionable feedback we can give to 
users would be to tell them which parts of //their source code// are taking a 
long time to compile. Profiling information that can describe -- for instance 
-- the time spent instantiating the N slowest templates, or handling the N 
slowest functions, or evaluating the N slowest constant expressions, or parsing 
the N slowest `#include`d files, seems like it would be incredibly valuable. To 
make that work, I think we'll need to teach LLVM's timer infrastructure to 
properly separate out "self" time from "children" time for timers in the same 
group, and may need other infrastructure improvements.


https://reviews.llvm.org/D43578



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


[PATCH] D45121: [coroutines] Add noop_coroutine to

2018-04-13 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov closed this revision.
GorNishanov added a comment.

Committed as:

https://reviews.llvm.org/rCXX329237

and a flurry of cleanup fixes:

https://reviews.llvm.org/rCXX329239
https://reviews.llvm.org/rCXX329240
https://reviews.llvm.org/rCXX329245


https://reviews.llvm.org/D45121



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


[PATCH] D17741: adds __FILE_BASENAME__ builtin macro

2018-04-13 Thread Weiming Zhao via Phabricator via cfe-commits
weimingz updated this revision to Diff 142499.
weimingz edited the summary of this revision.
weimingz added a comment.

split the original into two parts. This one supports 
-ffile-macro-prefix-to-remove function.

I locally verified it.  To add a test case, do we need to use VFS?


https://reviews.llvm.org/D17741

Files:
  include/clang/Driver/Options.td
  include/clang/Lex/PreprocessorOptions.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Lex/PPMacroExpansion.cpp

Index: lib/Lex/PPMacroExpansion.cpp
===
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -26,25 +26,27 @@
 #include "clang/Lex/LexDiagnostic.h"
 #include "clang/Lex/MacroArgs.h"
 #include "clang/Lex/MacroInfo.h"
+#include "clang/Lex/PTHLexer.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/PreprocessorLexer.h"
-#include "clang/Lex/PTHLexer.h"
+#include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Lex/Token.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -1717,7 +1719,16 @@
 // Escape this filename.  Turn '\' -> '\\' '"' -> '\"'
 SmallString<128> FN;
 if (PLoc.isValid()) {
-  FN += PLoc.getFilename();
+  StringRef Filename = PLoc.getFilename();
+  if (II == Ident__FILE__) {
+const std::string &PrefixToRemove =
+getPreprocessorOpts().FileMacroPrefixToRemove;
+if (Filename.startswith(PrefixToRemove))
+  FN += Filename.substr(PrefixToRemove.size());
+else
+  FN += Filename;
+  } else
+FN += Filename;
   Lexer::Stringify(FN);
   OS << '"' << FN << '"';
 }
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2826,6 +2826,10 @@
   Opts.ObjCXXARCStandardLibrary = (ObjCXXARCStandardLibraryKind)Library;
   }
 
+  if (Arg *A = Args.getLastArg(OPT_ffile_macro_prefix_to_remove)) {
+Opts.FileMacroPrefixToRemove = A->getValue();
+  }
+
   // Always avoid lexing editor placeholders when we're just running the
   // preprocessor as we never want to emit the
   // "editor placeholder in source file" error in PP only mode.
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -1264,6 +1264,15 @@
 // For IAMCU add special include arguments.
 getToolChain().AddIAMCUIncludeArgs(Args, CmdArgs);
   }
+
+  // Add FILE macro prefix removing arguments or basename only flags.
+  if (const Arg *A =
+  Args.getLastArg(options::OPT_ffile_macro_prefix_to_remove)) {
+StringRef PrefixToRemove(A->getValue());
+if (!PrefixToRemove.empty())
+  CmdArgs.push_back(Args.MakeArgString("-ffile-macro-prefix-to-remove=" +
+   PrefixToRemove));
+  }
 }
 
 // FIXME: Move to target hook.
Index: include/clang/Lex/PreprocessorOptions.h
===
--- include/clang/Lex/PreprocessorOptions.h
+++ include/clang/Lex/PreprocessorOptions.h
@@ -127,12 +127,16 @@
   /// manipulation of the compiler invocation object, in cases where the 
   /// compiler invocation and its buffers will be reused.
   bool RetainRemappedFileBuffers = false;
-  
+
   /// \brief The Objective-C++ ARC standard library that we should support,
   /// by providing appropriate definitions to retrofit the standard library
   /// with support for lifetime-qualified pointers.
   ObjCXXARCStandardLibraryKind ObjCXXARCStandardLibrary = ARCXX_nolib;
-
+
+  /// \brief This string will be used in expanding __FILE__ macro. If it
+  /// matches the prefix of __FILE__, the matched part won't be expanded.
+  std::string FileMacroPrefixToRemove;
+
   /// \brief Records the set of modules
   class FailedModulesSet {
 llvm::StringSet<> Failed;
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1246,6 +1246,9 @@
   Flag <["-"], "fno-implicit-modules">,
   Group, Flags<[DriverOption, CC1Option]>;
 def fretain_comments_from_system_headers : Flag<["-"], "fretain-comments-from-system-headers">, Group, Fl

[PATCH] D45643: [Failing one test] Reword [-Wreturn-type] messages to "non-void x does not return a value"

2018-04-13 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: bindings/python/tests/cindex/test_diagnostics.py:18
 self.assertEqual(tu.diagnostics[0].spelling,
-'control reaches end of non-void function')
+'non-void function does not return a value')
 

It seems like part of the problem here is that "non-void function" is sort-of 
nonsense due to a few missing words. How about:

> "control can reach end of function with non-void return type"

or similar?

I think we still need the mention of control flow, because we're *not* saying 
the function contains no return statements, we're saying there's a control flow 
path that reaches the end of the function.



Comment at: docs/DiagnosticsReference.rst:9097
 |   |++|   
  |
 
+---+--+-+

This is a generated file; please don't manually update it. (Though we should 
regenerate it, it's probably quite stale...)


Repository:
  rC Clang

https://reviews.llvm.org/D45643



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


  1   2   >