[PATCH] D39673: Toolchain: Normalize dwarf, sjlj and seh eh

2017-11-20 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In https://reviews.llvm.org/D39673#929536, @martell wrote:

> When doing that I noticed there is something really strange about the 
> existing macro defines. I assume they should only be defined when exceptions 
> is enabled.
>  This is by default in c++ mode of with -fexceptions in c mode.
>  I moved the defines within a check of exceptions being enabled to address 
> that.


I'm not sure if this is the right thing to do. Since the exception handling 
model more or less also defines what ABI the code conforms to, I can see it 
being useful to know what exception handling mode is intended to be used, even 
if compiling plain C code without exceptions enabled. E.g. when building 
libunwind, some of the C sources there have ifdefs that check for 
`__USING_SJLJ_EXCEPTIONS__` and/or `__ARM_DWARF_EH__`. With this change, one 
has to manually start specifying it when building libunwind, to match whatever 
the default and/or manually chosen exception handling model is.


Repository:
  rL LLVM

https://reviews.llvm.org/D39673



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


[PATCH] D39673: Toolchain: Normalize dwarf, sjlj and seh eh

2017-11-20 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: lib/Frontend/InitPreprocessor.cpp:684
+else if (TI.getTriple().isThumb() || TI.getTriple().isARM())
+  Builder.defineMacro("__ARM_DWARF_EH__");
+  }

martell wrote:
> mstorsjo wrote:
> > Won't this start setting this define also on platforms where ARM EHABI is 
> > the default? (I.e. all ELF platforms except netbsd)?
> It will set it on any arm / thumb platform where exceptions are enabled and 
> the current model is dwarf.
> This includes netbsd. The issue we have is that apple set this 
> unconditionally for their watch platform.
> 
> I'm wondering if we should put this behind a `!apple` guard or just add an 
> `if windows or netbsd` guard.
> 
> Or is it okay to just generally have this macro on all platforms where dwarf 
> is exception model and the target is arm?
> 
No, it will set it on any arm/thumb platform where one hasn't indicated 
preference for any other model. And there are more models than just 
dwarf/seh/sjlj - there's also the ARM EHABI model. (According to 
MC/MCTargetOptions.h in llvm, there aren't any more than this currently though.)

Prior to this patch, `clang -x c++ -target armv7-linux-gnueabihf -E -dM - < 
/dev/null` will not include `__ARM_DWARF_EH__` - while it will after this 
patch. This will certainly break libunwind for linux on arm. (And prior to this 
patch, `clang -x c -target armv7-netbsd -E -dM - < /dev/null` did include it, 
but now it's only included when exceptions are enabled - I think the old 
behaviour is preferrable wrt that as well.)

So, similarly how we on x86_64 have a default that enables SEH unless something 
else has been specified, we need to prefer ARM EHABI on everything on ELF 
except netbsd. I guess you could fold in the apple defaults into that as well?


Repository:
  rL LLVM

https://reviews.llvm.org/D39673



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


[PATCH] D40234: [AutoComplete] Use stronger sort predicate for autocomplete candidates to remove non-deterministic ordering

2017-11-20 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang updated this revision to Diff 123546.

https://reviews.llvm.org/D40234

Files:
  lib/Driver/Driver.cpp


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1197,8 +1197,11 @@
   // deterministic order. We could sort in any way, but we chose
   // case-insensitive sorting for consistency with the -help option
   // which prints out options in the case-insensitive alphabetical order.
-  std::sort(SuggestedCompletions.begin(), SuggestedCompletions.end(),
-[](StringRef A, StringRef B) { return A.compare_lower(B) < 0; });
+  std::sort(SuggestedCompletions.begin(), SuggestedCompletions.end(),
+[](StringRef A, StringRef B) {
+  if (int X = A.compare_lower(B))
+return X < 0;
+  return A.compare(B) > 0; });
 
   llvm::outs() << llvm::join(SuggestedCompletions, "\n") << '\n';
 }


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1197,8 +1197,11 @@
   // deterministic order. We could sort in any way, but we chose
   // case-insensitive sorting for consistency with the -help option
   // which prints out options in the case-insensitive alphabetical order.
-  std::sort(SuggestedCompletions.begin(), SuggestedCompletions.end(),
-[](StringRef A, StringRef B) { return A.compare_lower(B) < 0; });
+  std::sort(SuggestedCompletions.begin(), SuggestedCompletions.end(),
+[](StringRef A, StringRef B) {
+  if (int X = A.compare_lower(B))
+return X < 0;
+  return A.compare(B) > 0; });
 
   llvm::outs() << llvm::join(SuggestedCompletions, "\n") << '\n';
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40234: [AutoComplete] Use stronger sort predicate for autocomplete candidates to remove non-deterministic ordering

2017-11-20 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

In https://reviews.llvm.org/D40234#929943, @ruiu wrote:

> Perhaps, this is a bit more straightforward.
>
>   if (int X = A.compare_lower(B))
> return X < 0;
>   return A.compare(B) < 0;


Thanks. Done.


https://reviews.llvm.org/D40234



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


[PATCH] D40234: [AutoComplete] Use stronger sort predicate for autocomplete candidates to remove non-deterministic ordering

2017-11-20 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu accepted this revision.
ruiu added a comment.

LGTM




Comment at: lib/Driver/Driver.cpp:1204
+return X < 0;
+  return A.compare(B) > 0; });
 

I believe that if you use clang-format, `});` will be put to a separate line 
like this.

  std::sort(SuggestedCompletions.begin(), SuggestedCompletions.end(),
[](StringRef A, StringRef B) {
  if (int X = A.compare_lower(B))
return X < 0;
  return A.compare(B) > 0;
});


https://reviews.llvm.org/D40234



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


[PATCH] D39722: [ASTImporter] Support TypeTraitExpr Importing

2017-11-20 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin accepted this revision.
a.sidorin added a comment.
This revision is now accepted and ready to land.

LGTM, thank you!


https://reviews.llvm.org/D39722



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


[PATCH] D35755: [Solaris] gcc toolchain handling revamp

2017-11-20 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

What's the status here?  This patch is required for my WIP 
sanitizers-on-Solaris work.


https://reviews.llvm.org/D35755



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


Notice: The buildbot bb.pgr.jp will be suspended within a few days

2017-11-20 Thread NAKAMURA Takumi via cfe-commits
Due to resource issue, I have to terminate it. As you know, it has been
working for several years and I am certain it has been useful and helpful
to guys.
I am not sure whether I could restart it or not.
I loved it.

Thank you,
Takumi Nakamura
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40185: Loosen -Wempty-body warning.

2017-11-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In https://reviews.llvm.org/D40185#928845, @rnk wrote:

> Why does passing the rparen location for the if condition fix the warning for 
> IF_ELSE? I assumed that would refer to the else clause semicolon.


Using spelling locations fixes the `else` case, but breaks some of the  `if ` 
cases involving macros (catched by `warn-empty-body.cpp` test).


Repository:
  rL LLVM

https://reviews.llvm.org/D40185



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


[PATCH] D39430: [clangd] formatting: don't ignore style

2017-11-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/ClangdServer.h:289
+  llvm::Expected>
+  formatRange(llvm::StringRef Code, PathRef File, Range Rng);
+

rwols wrote:
> rwols wrote:
> > ilya-biryukov wrote:
> > > rwols wrote:
> > > > ilya-biryukov wrote:
> > > > > Why do we accept `Code` as a parameter here instead of getting it 
> > > > > internally?
> > > > > 
> > > > > Maybe we should consider moving this method out of `ClangdServer`? 
> > > > > Its signature looks pretty self-contained now.
> > > > There are a couple intertwined problems:
> > > > 
> > > > 1. replacementsToEdits wants llvm::StringRef Code
> > > > 2. ClangdServer::formatCode wants llvm::StringRef Code
> > > > 3. ClangdServer::getDocument returns an std::string
> > > > 
> > > > So yes, in principle you can call getDocument when you need it for 
> > > > replacementsToEdits, and you can let formatCode itself call getDocument 
> > > > for clang::format::getStyle. But then we create two copies of the 
> > > > document contents for one LSP request.
> > > > 
> > > > If getDocument returned an llvm::StringRef, I'd probably vote for 
> > > > removing the Code argument everywhere and call getDocument as needed.
> > > Oh, I see. Calling `getDocument` twice does not really make sense.  
> > > Maybe we could move a call to `replacementsToEdits` into `formatOnFile` 
> > > and make it return `vector`?  Seems to be solving both problems.
> > > 
> > > We could've made `getDocument` return `StringRef`, but we'd have to be 
> > > more careful to ensure it's actually copied when we're scheduling async 
> > > operations, worth a separate review.
> > > Maybe we could move a call to replacementsToEdits into formatOnFile and 
> > > make it return vector?
> > 
> > I disagree, this will bring LSP-specific protocols into `ClangdServer`. The 
> > translation from `tooling::Replacement` to `clangd::TextEdit` should remain 
> > in `ClangdLSPServer`.
> I tried this anyway, but `ClangdLSPServer::getFixIts` also uses 
> `replacementsToEdits`. And that maintains a map with `tooling::Replacement`s. 
> So, if we want to move `replacementsToEdits` into `ClangdServer`, we would 
> have to move that map into `ClangdServer` too I think.
> I disagree, this will bring LSP-specific protocols into ClangdServer. The 
> translation from tooling::Replacement to clangd::TextEdit should remain in 
> ClangdLSPServer.
+1 to this, I'd also not make `ClangdServer` LSP-specific. However we already 
use some LSP structs from `Protocol.h` there to avoid code duplication (i.e., 
`CompletionItem`, though LSP-specific, suits `ClangdServer` pretty well). In 
principle, `Protocol.h` should not be a dependency, though, but we try to 
manage what we take from there instead. `clangd::TextEdit` seems to be in line 
with other things we take from there now (that is, `Range`s, `Location`s, etc)

> I tried this anyway, but ClangdLSPServer::getFixIts also uses 
> replacementsToEdits. And that maintains a map with tooling::Replacements. So, 
> if we want to move `replacementsToEdits` into `ClangdServer`, we would have 
> to move that map into ClangdServer too I think.
Could we change the `map` to store `clangd::TextEdit` instead? It's a bit 
unfortunate that we'll be making unnecessary `tooling::Replacement` -> 
`clangd::TextEdit` conversions and those aren't free. But honestly, I don't 
think this should bite us performance-wise.
Given that we already use LSP's `Location` and `Range` encoding in other APIs, 
we'll get a more consistent interface.


https://reviews.llvm.org/D39430



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


[PATCH] D33440: clang-format: better handle statement macros

2017-11-20 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

ping?


https://reviews.llvm.org/D33440



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


[PATCH] D37813: clang-format: better handle namespace macros

2017-11-20 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

ping?


https://reviews.llvm.org/D37813



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


r318644 - [Driver] Add a cc1 flag for the new TBAA metadata format

2017-11-20 Thread Ivan A. Kosarev via cfe-commits
Author: kosarev
Date: Mon Nov 20 03:16:16 2017
New Revision: 318644

URL: http://llvm.org/viewvc/llvm-project?rev=318644&view=rev
Log:
[Driver] Add a cc1 flag for the new TBAA metadata format

This patch starts a series of changes to add support for the new
TBAA metadata format proposed in this llvm-dev thread:

http://lists.llvm.org/pipermail/llvm-dev/2017-November/118748.html

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

Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=318644&r1=318643&r2=318644&view=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Nov 20 03:16:16 2017
@@ -244,6 +244,8 @@ def relaxed_aliasing : Flag<["-"], "rela
   HelpText<"Turn off Type Based Alias Analysis">;
 def no_struct_path_tbaa : Flag<["-"], "no-struct-path-tbaa">,
   HelpText<"Turn off struct-path aware Type Based Alias Analysis">;
+def new_struct_path_tbaa : Flag<["-"], "new-struct-path-tbaa">,
+  HelpText<"Enable enhanced struct-path aware Type Based Alias Analysis">;
 def masm_verbose : Flag<["-"], "masm-verbose">,
   HelpText<"Generate verbose assembly output">;
 def mcode_model : Separate<["-"], "mcode-model">,

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=318644&r1=318643&r2=318644&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Mon Nov 20 03:16:16 2017
@@ -144,6 +144,7 @@ ENUM_CODEGENOPT(StructReturnConvention,
 CODEGENOPT(RelaxAll  , 1, 0) ///< Relax all machine code instructions.
 CODEGENOPT(RelaxedAliasing   , 1, 0) ///< Set when -fno-strict-aliasing is 
enabled.
 CODEGENOPT(StructPathTBAA, 1, 0) ///< Whether or not to use struct-path 
TBAA.
+CODEGENOPT(NewStructPathTBAA , 1, 0) ///< Whether or not to use enhanced 
struct-path TBAA.
 CODEGENOPT(SaveTempLabels, 1, 0) ///< Save temporary labels.
 CODEGENOPT(SanitizeAddressUseAfterScope , 1, 0) ///< Enable use-after-scope 
detection
 ///< in AddressSanitizer

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=318644&r1=318643&r2=318644&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Nov 20 03:16:16 2017
@@ -546,6 +546,8 @@ static bool ParseCodeGenArgs(CodeGenOpti
 OPT_fuse_register_sized_bitfield_access);
   Opts.RelaxedAliasing = Args.hasArg(OPT_relaxed_aliasing);
   Opts.StructPathTBAA = !Args.hasArg(OPT_no_struct_path_tbaa);
+  Opts.NewStructPathTBAA = !Args.hasArg(OPT_no_struct_path_tbaa) &&
+   Args.hasArg(OPT_new_struct_path_tbaa);
   Opts.FineGrainedBitfieldAccesses =
   Args.hasFlag(OPT_ffine_grained_bitfield_accesses,
OPT_fno_fine_grained_bitfield_accesses, false);


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


[PATCH] D39955: [Driver] Add a cc1 flag for the new TBAA metadata format

2017-11-20 Thread Ivan Kosarev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318644: [Driver] Add a cc1 flag for the new TBAA metadata 
format (authored by kosarev).

Changed prior to commit:
  https://reviews.llvm.org/D39955?vs=123320&id=123555#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39955

Files:
  cfe/trunk/include/clang/Driver/CC1Options.td
  cfe/trunk/include/clang/Frontend/CodeGenOptions.def
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp


Index: cfe/trunk/include/clang/Driver/CC1Options.td
===
--- cfe/trunk/include/clang/Driver/CC1Options.td
+++ cfe/trunk/include/clang/Driver/CC1Options.td
@@ -244,6 +244,8 @@
   HelpText<"Turn off Type Based Alias Analysis">;
 def no_struct_path_tbaa : Flag<["-"], "no-struct-path-tbaa">,
   HelpText<"Turn off struct-path aware Type Based Alias Analysis">;
+def new_struct_path_tbaa : Flag<["-"], "new-struct-path-tbaa">,
+  HelpText<"Enable enhanced struct-path aware Type Based Alias Analysis">;
 def masm_verbose : Flag<["-"], "masm-verbose">,
   HelpText<"Generate verbose assembly output">;
 def mcode_model : Separate<["-"], "mcode-model">,
Index: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
===
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def
@@ -144,6 +144,7 @@
 CODEGENOPT(RelaxAll  , 1, 0) ///< Relax all machine code instructions.
 CODEGENOPT(RelaxedAliasing   , 1, 0) ///< Set when -fno-strict-aliasing is 
enabled.
 CODEGENOPT(StructPathTBAA, 1, 0) ///< Whether or not to use struct-path 
TBAA.
+CODEGENOPT(NewStructPathTBAA , 1, 0) ///< Whether or not to use enhanced 
struct-path TBAA.
 CODEGENOPT(SaveTempLabels, 1, 0) ///< Save temporary labels.
 CODEGENOPT(SanitizeAddressUseAfterScope , 1, 0) ///< Enable use-after-scope 
detection
 ///< in AddressSanitizer
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -546,6 +546,8 @@
 OPT_fuse_register_sized_bitfield_access);
   Opts.RelaxedAliasing = Args.hasArg(OPT_relaxed_aliasing);
   Opts.StructPathTBAA = !Args.hasArg(OPT_no_struct_path_tbaa);
+  Opts.NewStructPathTBAA = !Args.hasArg(OPT_no_struct_path_tbaa) &&
+   Args.hasArg(OPT_new_struct_path_tbaa);
   Opts.FineGrainedBitfieldAccesses =
   Args.hasFlag(OPT_ffine_grained_bitfield_accesses,
OPT_fno_fine_grained_bitfield_accesses, false);


Index: cfe/trunk/include/clang/Driver/CC1Options.td
===
--- cfe/trunk/include/clang/Driver/CC1Options.td
+++ cfe/trunk/include/clang/Driver/CC1Options.td
@@ -244,6 +244,8 @@
   HelpText<"Turn off Type Based Alias Analysis">;
 def no_struct_path_tbaa : Flag<["-"], "no-struct-path-tbaa">,
   HelpText<"Turn off struct-path aware Type Based Alias Analysis">;
+def new_struct_path_tbaa : Flag<["-"], "new-struct-path-tbaa">,
+  HelpText<"Enable enhanced struct-path aware Type Based Alias Analysis">;
 def masm_verbose : Flag<["-"], "masm-verbose">,
   HelpText<"Generate verbose assembly output">;
 def mcode_model : Separate<["-"], "mcode-model">,
Index: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
===
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def
@@ -144,6 +144,7 @@
 CODEGENOPT(RelaxAll  , 1, 0) ///< Relax all machine code instructions.
 CODEGENOPT(RelaxedAliasing   , 1, 0) ///< Set when -fno-strict-aliasing is enabled.
 CODEGENOPT(StructPathTBAA, 1, 0) ///< Whether or not to use struct-path TBAA.
+CODEGENOPT(NewStructPathTBAA , 1, 0) ///< Whether or not to use enhanced struct-path TBAA.
 CODEGENOPT(SaveTempLabels, 1, 0) ///< Save temporary labels.
 CODEGENOPT(SanitizeAddressUseAfterScope , 1, 0) ///< Enable use-after-scope detection
 ///< in AddressSanitizer
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -546,6 +546,8 @@
 OPT_fuse_register_sized_bitfield_access);
   Opts.RelaxedAliasing = Args.hasArg(OPT_relaxed_aliasing);
   Opts.StructPathTBAA = !Args.hasArg(OPT_no_struct_path_tbaa);
+  Opts.NewStructPathTBAA = !Args.hasArg(OPT_no_struct_path_tbaa) &&
+   Args.hasArg(OPT_new_struct_path_tbaa);
   Opts.FineGrainedBitfieldAccesses =
   Args.hasFlag(OPT_ffine_grained_bitfield_accesses,
OPT_fno_fine_grained_bitfield_accesses, false);
__

[PATCH] D40073: [Analyzer] Non-determinism: don't sort indirect goto LabelDecl's by addresses

2017-11-20 Thread Ilya Palachev via Phabricator via cfe-commits
ilya-palachev updated this revision to Diff 123558.
ilya-palachev added a comment.

Ok, I agree, this test file is rather better.


https://reviews.llvm.org/D40073

Files:
  lib/Analysis/CFG.cpp
  test/Analysis/cfg-indirect-goto-determinism.cpp

Index: test/Analysis/cfg-indirect-goto-determinism.cpp
===
--- /dev/null
+++ test/Analysis/cfg-indirect-goto-determinism.cpp
@@ -0,0 +1,96 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG %s 2>&1 | FileCheck %s
+
+void *target;
+int indirectBlockSuccessorDeterminism() {
+(void)&&L1;
+(void)&&L2;
+(void)&&L3;
+(void)&&L4;
+(void)&&L5;
+(void)&&L6;
+(void)&&L7;
+(void)&&L8;
+(void)&&L9;
+(void)&&L10;
+(void)&&L11;
+(void)&&L12;
+(void)&&L13;
+(void)&&L14;
+(void)&&L15;
+(void)&&L16;
+(void)&&L17;
+(void)&&L18;
+(void)&&L19;
+(void)&&L20;
+(void)&&L21;
+(void)&&L22;
+(void)&&L23;
+(void)&&L24;
+(void)&&L25;
+(void)&&L26;
+(void)&&L27;
+(void)&&L28;
+(void)&&L29;
+(void)&&L30;
+(void)&&L31;
+(void)&&L32;
+(void)&&L33;
+(void)&&L34;
+(void)&&L35;
+(void)&&L36;
+(void)&&L37;
+(void)&&L38;
+(void)&&L39;
+(void)&&L40;
+
+goto *target;
+  L1:
+  L2:
+  L3:
+  L4:
+  L5:
+  L6:
+  L7:
+  L8:
+  L9:
+  L10:
+  L11:
+  L12:
+  L13:
+  L14:
+  L15:
+  L16:
+  L17:
+  L18:
+  L19:
+  L20:
+  L21:
+  L22:
+  L23:
+  L24:
+  L25:
+  L26:
+  L27:
+  L28:
+  L29:
+  L30:
+  L31:
+  L32:
+  L33:
+  L34:
+  L35:
+  L36:
+  L37:
+  L38:
+  L39:
+  L40:
+return 0;
+}
+
+// CHECK-LABEL:  [B41 (INDIRECT GOTO DISPATCH)]
+// CHECK-NEXT:   Preds (1): B42
+// CHECK-NEXT:  Succs (40): B1 B2 B3 B4 B5 B6 B7 B8
+// CHECK-NEXT:   B9 B10 B11 B12 B13 B14 B15 B16 B17 B18
+// CHECK-NEXT:   B19 B20 B21 B22 B23 B24 B25 B26 B27 B28
+// CHECK-NEXT:   B29 B30 B31 B32 B33 B34 B35 B36 B37 B38
+// CHECK-NEXT:   B39 B40
Index: lib/Analysis/CFG.cpp
===
--- lib/Analysis/CFG.cpp
+++ lib/Analysis/CFG.cpp
@@ -420,7 +420,7 @@
   BackpatchBlocksTy BackpatchBlocks;
 
   // A list of labels whose address has been taken (for indirect gotos).
-  typedef llvm::SmallPtrSet LabelSetTy;
+  typedef llvm::SmallSetVector LabelSetTy;
   LabelSetTy AddressTakenLabels;
 
   bool badCFG;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40182: [clangd] Add parsing and value inspection to JSONExpr.

2017-11-20 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

Code looks good. Just some nits.




Comment at: clangd/JSONExpr.h:62
+// Array and Object also have typed indexing accessors for easy traversal:
+//   if (json::obj* Opts = O.array("options"))
+// if (Optional Font = Opts->string("font"))

It's not obvious what `O.array("options")` does. Does it convert 
`O.at("options")` to an array?



Comment at: clangd/JSONExpr.h:78
 public:
-  class Object;
+  enum Kind {
+Null,

I wonder if we could merge `Kind` and `ExprType`.


https://reviews.llvm.org/D40182



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


[PATCH] D39834: [clangd] -foptimization-record-file= should imply -fsave-optimization-record

2017-11-20 Thread Dmitry Venikov via Phabricator via cfe-commits
Quolyk updated this revision to Diff 123559.

https://reviews.llvm.org/D39834

Files:
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/opt-record.c


Index: test/Driver/opt-record.c
===
--- test/Driver/opt-record.c
+++ test/Driver/opt-record.c
@@ -9,6 +9,7 @@
 // RUN: %clang -### -S -fsave-optimization-record -x cuda -nocudainc 
-nocudalib %s 2>&1 | FileCheck %s -check-prefix=CHECK-NO-O 
-check-prefix=CHECK-CUDA-DEV
 // RUN: %clang -### -fsave-optimization-record -x cuda -nocudainc -nocudalib 
%s 2>&1 | FileCheck %s -check-prefix=CHECK-NO-O -check-prefix=CHECK-CUDA-DEV
 // RUN: %clang -### -S -o FOO -fsave-optimization-record 
-foptimization-record-file=BAR.txt %s 2>&1 | FileCheck %s -check-prefix=CHECK-EQ
+// RUN: %clang -### -S -o FOO -foptimization-record-file=BAR.txt %s 2>&1 | 
FileCheck %s -check-prefix=CHECK-EQ
 
 // CHECK: "-cc1"
 // CHECK: "-opt-record-file" "FOO.opt.yaml"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4378,6 +4378,14 @@
 }
   }
 
+  if (!Args.hasFlag(options::OPT_fsave_optimization_record,
+options::OPT_fno_save_optimization_record, false)) {
+if (const Arg *A = 
Args.getLastArg(options::OPT_foptimization_record_file_EQ)) {
+  CmdArgs.push_back("-opt-record-file");
+  CmdArgs.push_back(A->getValue());
+}
+  }
+
   bool RewriteImports = Args.hasFlag(options::OPT_frewrite_imports,
  options::OPT_fno_rewrite_imports, false);
   if (RewriteImports)


Index: test/Driver/opt-record.c
===
--- test/Driver/opt-record.c
+++ test/Driver/opt-record.c
@@ -9,6 +9,7 @@
 // RUN: %clang -### -S -fsave-optimization-record -x cuda -nocudainc -nocudalib %s 2>&1 | FileCheck %s -check-prefix=CHECK-NO-O -check-prefix=CHECK-CUDA-DEV
 // RUN: %clang -### -fsave-optimization-record -x cuda -nocudainc -nocudalib %s 2>&1 | FileCheck %s -check-prefix=CHECK-NO-O -check-prefix=CHECK-CUDA-DEV
 // RUN: %clang -### -S -o FOO -fsave-optimization-record -foptimization-record-file=BAR.txt %s 2>&1 | FileCheck %s -check-prefix=CHECK-EQ
+// RUN: %clang -### -S -o FOO -foptimization-record-file=BAR.txt %s 2>&1 | FileCheck %s -check-prefix=CHECK-EQ
 
 // CHECK: "-cc1"
 // CHECK: "-opt-record-file" "FOO.opt.yaml"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4378,6 +4378,14 @@
 }
   }
 
+  if (!Args.hasFlag(options::OPT_fsave_optimization_record,
+options::OPT_fno_save_optimization_record, false)) {
+if (const Arg *A = Args.getLastArg(options::OPT_foptimization_record_file_EQ)) {
+  CmdArgs.push_back("-opt-record-file");
+  CmdArgs.push_back(A->getValue());
+}
+  }
+
   bool RewriteImports = Args.hasFlag(options::OPT_frewrite_imports,
  options::OPT_fno_rewrite_imports, false);
   if (RewriteImports)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40242: Do not perform the analysis based warning if all warnings are ignored

2017-11-20 Thread Olivier Goffart via Phabricator via cfe-commits
ogoffart created this revision.

Do not perform the analysis based warning if all warnings are ignored.

This saves some cycles when compiling with "-w".

But more importantly, for my tool, this fixes a potential crash which may 
happen on invalid code. Because the analysis might compute the CFG which 
crashes if the code contains invalid declaration. This does not happen normally 
with because we also don't perform these analysis if there was an error.  But 
the tool is better at recovering and hit this condition.


https://reviews.llvm.org/D40242

Files:
  lib/Sema/AnalysisBasedWarnings.cpp


Index: lib/Sema/AnalysisBasedWarnings.cpp
===
--- lib/Sema/AnalysisBasedWarnings.cpp
+++ lib/Sema/AnalysisBasedWarnings.cpp
@@ -2080,10 +2080,10 @@
   // time.
   DiagnosticsEngine &Diags = S.getDiagnostics();
 
-  // Do not do any analysis for declarations in system headers if we are
-  // going to just ignore them.
-  if (Diags.getSuppressSystemWarnings() &&
-  S.SourceMgr.isInSystemHeader(D->getLocation()))
+  // Do not do any analysis if we are going to just ignore them.
+  if (Diags.getIgnoreAllWarnings() ||
+  (Diags.getSuppressSystemWarnings() &&
+   S.SourceMgr.isInSystemHeader(D->getLocation(
 return;
 
   // For code in dependent contexts, we'll do this at instantiation time.


Index: lib/Sema/AnalysisBasedWarnings.cpp
===
--- lib/Sema/AnalysisBasedWarnings.cpp
+++ lib/Sema/AnalysisBasedWarnings.cpp
@@ -2080,10 +2080,10 @@
   // time.
   DiagnosticsEngine &Diags = S.getDiagnostics();
 
-  // Do not do any analysis for declarations in system headers if we are
-  // going to just ignore them.
-  if (Diags.getSuppressSystemWarnings() &&
-  S.SourceMgr.isInSystemHeader(D->getLocation()))
+  // Do not do any analysis if we are going to just ignore them.
+  if (Diags.getIgnoreAllWarnings() ||
+  (Diags.getSuppressSystemWarnings() &&
+   S.SourceMgr.isInSystemHeader(D->getLocation(
 return;
 
   // For code in dependent contexts, we'll do this at instantiation time.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37903: Fix assume-filename handling in clang-format.el

2017-11-20 Thread Philipp via Phabricator via cfe-commits
phi added a comment.

Hi, do you need anything more from us? This patch looks fine and can be 
submitted.


https://reviews.llvm.org/D37903



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


[PATCH] D40242: Do not perform the analysis based warning if all warnings are ignored

2017-11-20 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

You probably want to add a test for this.


https://reviews.llvm.org/D40242



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


[PATCH] D40242: Do not perform the analysis based warning if all warnings are ignored

2017-11-20 Thread Olivier Goffart via Phabricator via cfe-commits
ogoffart added a comment.

I do not know how to add a test: there is no real visible change for clang. It 
just should be faster when passing "-w".


https://reviews.llvm.org/D40242



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


[PATCH] D37903: Fix assume-filename handling in clang-format.el

2017-11-20 Thread Philipp via Phabricator via cfe-commits
phi added a comment.

The patch doesn't apply any more to upstream head:

  $ arc patch D37903
  patching file tools/clang-format/clang-format.el
  Hunk #1 FAILED at 122.
  Hunk #2 FAILED at 193.

Could you please rebase it?


https://reviews.llvm.org/D37903



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


[PATCH] D38445: [x86][inline-asm] allow recognition of MPX regs inside ms inline-asm blob

2017-11-20 Thread coby via Phabricator via cfe-commits
coby added a comment.

Reid,
can you please have a look?


Repository:
  rL LLVM

https://reviews.llvm.org/D38445



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


[PATCH] D40242: Do not perform the analysis based warning if all warnings are ignored

2017-11-20 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In https://reviews.llvm.org/D40242#930125, @ogoffart wrote:

> I do not know how to add a test: there is no real visible change for clang. 
> It just should be faster when passing "-w".


Oh right, i was thinking of something else there.




Comment at: lib/Sema/AnalysisBasedWarnings.cpp:2084
+  // Do not do any analysis if we are going to just ignore them.
+  if (Diags.getIgnoreAllWarnings() ||
+  (Diags.getSuppressSystemWarnings() &&

I guess you can try commenting-out that entire check and seeing whether any 
test fails.


https://reviews.llvm.org/D40242



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


[PATCH] D39953: [CodeGen] Generate TBAA type descriptors in a more reliable manner

2017-11-20 Thread Ivan Kosarev via Phabricator via cfe-commits
kosarev updated this revision to Diff 123563.
kosarev retitled this revision from "[CodeGen] Do not lookup for cached TBAA 
metadata nodes twice" to "[CodeGen] Generate TBAA type descriptors in a more 
reliable manner".
kosarev edited the summary of this revision.
kosarev added a comment.

Reworked to use helper functions to separate producing metadata nodes from 
other code.


https://reviews.llvm.org/D39953

Files:
  lib/CodeGen/CodeGenTBAA.cpp
  lib/CodeGen/CodeGenTBAA.h

Index: lib/CodeGen/CodeGenTBAA.h
===
--- lib/CodeGen/CodeGenTBAA.h
+++ lib/CodeGen/CodeGenTBAA.h
@@ -143,6 +143,14 @@
   /// pointer to another node in the type DAG.
   llvm::MDNode *createTBAAScalarType(StringRef Name, llvm::MDNode *Parent);
 
+  /// getTypeInfoHelper - An internal helper function to generate metadata used
+  /// to describe accesses to objects of the given type.
+  llvm::MDNode *getTypeInfoHelper(const Type *Ty);
+
+  /// getBaseTypeInfoHelper - An internal helper function to generate metadata
+  /// used to describe accesses to objects of the given base type.
+  llvm::MDNode *getBaseTypeInfoHelper(const Type *Ty);
+
 public:
   CodeGenTBAA(ASTContext &Ctx, llvm::LLVMContext &VMContext,
   const CodeGenOptions &CGO,
Index: lib/CodeGen/CodeGenTBAA.cpp
===
--- lib/CodeGen/CodeGenTBAA.cpp
+++ lib/CodeGen/CodeGenTBAA.cpp
@@ -107,29 +107,7 @@
   return false;
 }
 
-llvm::MDNode *CodeGenTBAA::getTypeInfo(QualType QTy) {
-  // At -O0 or relaxed aliasing, TBAA is not emitted for regular types.
-  if (CodeGenOpts.OptimizationLevel == 0 || CodeGenOpts.RelaxedAliasing)
-return nullptr;
-
-  // If the type has the may_alias attribute (even on a typedef), it is
-  // effectively in the general char alias class.
-  if (TypeHasMayAlias(QTy))
-return getChar();
-
-  // We need this function to not fall back to returning the "omnipotent char"
-  // type node for aggregate and union types. Otherwise, any dereference of an
-  // aggregate will result into the may-alias access descriptor, meaning all
-  // subsequent accesses to direct and indirect members of that aggregate will
-  // be considered may-alias too.
-  // TODO: Combine getTypeInfo() and getBaseTypeInfo() into a single function.
-  if (isValidBaseType(QTy))
-return getBaseTypeInfo(QTy);
-
-  const Type *Ty = Context.getCanonicalType(QTy).getTypePtr();
-  if (llvm::MDNode *N = MetadataCache[Ty])
-return N;
-
+llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) {
   // Handle builtin types.
   if (const BuiltinType *BTy = dyn_cast(Ty)) {
 switch (BTy->getKind()) {
@@ -160,23 +138,21 @@
 // treating wchar_t, char16_t, and char32_t as distinct from their
 // "underlying types".
 default:
-  return MetadataCache[Ty] =
-createTBAAScalarType(BTy->getName(Features), getChar());
+  return createTBAAScalarType(BTy->getName(Features), getChar());
 }
   }
 
   // C++1z [basic.lval]p10: "If a program attempts to access the stored value of
   // an object through a glvalue of other than one of the following types the
   // behavior is undefined: [...] a char, unsigned char, or std::byte type."
   if (Ty->isStdByteType())
-return MetadataCache[Ty] = getChar();
+return getChar();
 
   // Handle pointers and references.
   // TODO: Implement C++'s type "similarity" and consider dis-"similar"
   // pointers distinct.
   if (Ty->isPointerType() || Ty->isReferenceType())
-return MetadataCache[Ty] = createTBAAScalarType("any pointer",
-getChar());
+return createTBAAScalarType("any pointer", getChar());
 
   // Enum types are distinct types. In C++ they have "underlying types",
   // however they aren't related for TBAA.
@@ -186,16 +162,46 @@
 // TODO: Is there a way to get a program-wide unique name for a
 // decl with local linkage or no linkage?
 if (!Features.CPlusPlus || !ETy->getDecl()->isExternallyVisible())
-  return MetadataCache[Ty] = getChar();
+  return getChar();
 
 SmallString<256> OutName;
 llvm::raw_svector_ostream Out(OutName);
 MContext.mangleTypeName(QualType(ETy, 0), Out);
-return MetadataCache[Ty] = createTBAAScalarType(OutName, getChar());
+return createTBAAScalarType(OutName, getChar());
   }
 
   // For now, handle any other kind of type conservatively.
-  return MetadataCache[Ty] = getChar();
+  return getChar();
+}
+
+llvm::MDNode *CodeGenTBAA::getTypeInfo(QualType QTy) {
+  // At -O0 or relaxed aliasing, TBAA is not emitted for regular types.
+  if (CodeGenOpts.OptimizationLevel == 0 || CodeGenOpts.RelaxedAliasing)
+return nullptr;
+
+  // If the type has the may_alias attribute (even on a typedef), it is
+  // effectively in the general char alias class.
+  if (TypeHasMayAlias(QTy))
+return getChar();
+
+  // We need this function to not fall back to return

[PATCH] D39953: [CodeGen] Generate TBAA type descriptors in a more reliable manner

2017-11-20 Thread Ivan Kosarev via Phabricator via cfe-commits
kosarev added a comment.

In https://reviews.llvm.org/D39953#929144, @rjmccall wrote:

> I think there might be some cases that intentionally don't cache their normal 
> result, though, so it might be harder than you think.


My understanding is that conceptually every canonical type has a single 
corresponding type node; we shall never return different nodes for the same 
type. With the updated patch we cache nodes for all types, including different 
versions of char. This is supposed to be an improvement saving us some 
execution time.


https://reviews.llvm.org/D39953



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


[PATCH] D35755: [Solaris] gcc toolchain handling revamp

2017-11-20 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added inline comments.



Comment at: lib/Driver/ToolChains/Gnu.cpp:1840
+// Yet, still look for RHEL devtoolsets
+// (should it be done Linux-only??)
+Prefixes.push_back("/opt/rh/devtoolset-6/root/usr");

fedor.sergeev wrote:
> aaron.ballman wrote:
> > This is a good question to get an answer to before committing. :-) I don't 
> > know the answer myself, unfortunately.
> So we need somebody that could answer it! :)
> Last person who touched these paths was Tom Stellard.
> Adding as a reviewer.
Yes, this can be linux only.


https://reviews.llvm.org/D35755



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


[PATCH] D40127: [Driver][ARM] For assembler files recognize -Xassembler or -Wa, -mthumb

2017-11-20 Thread Peter Smith via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318647: [ARM] For assembler files recognize -Xassembler or 
-Wa, -mthumb (authored by psmith).

Changed prior to commit:
  https://reviews.llvm.org/D40127?vs=123310&id=123571#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40127

Files:
  cfe/trunk/lib/Driver/ToolChain.cpp
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/test/Driver/arm-target-as-mthumb.s


Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -1889,6 +1889,15 @@
   switch (C.getDefaultToolChain().getArch()) {
   default:
 break;
+  case llvm::Triple::thumb:
+  case llvm::Triple::thumbeb:
+  case llvm::Triple::arm:
+  case llvm::Triple::armeb:
+if (Value == "-mthumb")
+  // -mthumb has already been processed in ComputeLLVMTriple()
+  // recognize but skip over here.
+  continue;
+
   case llvm::Triple::mips:
   case llvm::Triple::mipsel:
   case llvm::Triple::mips64:
Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -541,11 +541,30 @@
   << tools::arm::getARMArch(MArch, getTriple()) << "ARM";
 }
 
-// Assembly files should start in ARM mode, unless arch is M-profile.
-// Windows is always thumb.
-if ((InputType != types::TY_PP_Asm && Args.hasFlag(options::OPT_mthumb,
- options::OPT_mno_thumb, ThumbDefault)) || IsMProfile ||
- getTriple().isOSWindows()) {
+// Check to see if an explicit choice to use thumb has been made via
+// -mthumb. For assembler files we must check for -mthumb in the options
+// passed to the assember via -Wa or -Xassembler.
+bool IsThumb = false;
+if (InputType != types::TY_PP_Asm)
+  IsThumb = Args.hasFlag(options::OPT_mthumb, options::OPT_mno_thumb,
+  ThumbDefault);
+else {
+  // Ideally we would check for these flags in
+  // CollectArgsForIntegratedAssembler but we can't change the ArchName at
+  // that point. There is no assembler equivalent of -mno-thumb, -marm, or
+  // -mno-arm.
+  for (const Arg *A :
+   Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler)) {
+for (StringRef Value : A->getValues()) {
+  if (Value == "-mthumb")
+IsThumb = true;
+}
+  }
+}
+// Assembly files should start in ARM mode, unless arch is M-profile, or
+// -mthumb has been passed explicitly to the assembler. Windows is always
+// thumb.
+if (IsThumb || IsMProfile || getTriple().isOSWindows()) {
   if (IsBigEndian)
 ArchName = "thumbeb";
   else
Index: cfe/trunk/test/Driver/arm-target-as-mthumb.s
===
--- cfe/trunk/test/Driver/arm-target-as-mthumb.s
+++ cfe/trunk/test/Driver/arm-target-as-mthumb.s
@@ -0,0 +1,17 @@
+// Make sure -mthumb does not affect assembler triple, but -Wa,-mthumb or
+// -Xassembler -mthumb does. Also check that -Wa,-mthumb or -Xassembler -mthumb
+// does not affect non assembler files.
+
+// RUN: %clang -target armv7a-linux-gnueabi -### -c -mthumb %s 2>&1 | \
+// RUN: FileCheck -check-prefix=TRIPLE-ARM %s
+// RUN: %clang -target armv7a-linux-gnueabi -### -c -Wa,-mthumb \
+// RUN: %S/Inputs/wildcard1.c  2>&1 | FileCheck -check-prefix=TRIPLE-ARM %s
+
+// TRIPLE-ARM: "-triple" "armv7--linux-gnueabi"
+
+// RUN: %clang -target armv7a-linux-gnueabi -### -c -Wa,-mthumb %s 2>&1 | \
+// RUN: FileCheck -check-prefix=TRIPLE-THUMB %s
+// RUN: %clang -target armv7a-linux-gnueabi -### -c -Xassembler -mthumb %s \
+// RUN: 2>&1 | FileCheck -check-prefix=TRIPLE-THUMB %s
+
+// TRIPLE-THUMB: "-triple" "thumbv7--linux-gnueabi"


Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -1889,6 +1889,15 @@
   switch (C.getDefaultToolChain().getArch()) {
   default:
 break;
+  case llvm::Triple::thumb:
+  case llvm::Triple::thumbeb:
+  case llvm::Triple::arm:
+  case llvm::Triple::armeb:
+if (Value == "-mthumb")
+  // -mthumb has already been processed in ComputeLLVMTriple()
+  // recognize but skip over here.
+  continue;
+
   case llvm::Triple::mips:
   case llvm::Triple::mipsel:
   case llvm::Triple::mips64:
Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -541,11 +541,30 @@
   << tools::arm::getARMArch(MArch, getTriple

r318647 - [ARM] For assembler files recognize -Xassembler or -Wa, -mthumb

2017-11-20 Thread Peter Smith via cfe-commits
Author: psmith
Date: Mon Nov 20 05:43:55 2017
New Revision: 318647

URL: http://llvm.org/viewvc/llvm-project?rev=318647&view=rev
Log:
[ARM] For assembler files recognize -Xassembler or -Wa, -mthumb

The Unified Arm Assembler Language is designed so that the majority of
assembler files can be assembled for both Arm and Thumb with the choice
made as a compilation option.

The way this is done in gcc is to pass -mthumb to the assembler with either
-Wa,-mthumb or -Xassembler -mthumb. This change adds support for these
options to clang. There is no assembler equivalent of -mno-thumb, -marm or
-mno-arm so we don't need to recognize these.

Ideally we would do all of the processing in
CollectArgsForIntegratedAssembler(). Unfortunately we need to change the
triple and at that point it is too late. Instead we look for the option
earlier in ComputeLLVMTriple().

Fixes PR34519

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


Added:
cfe/trunk/test/Driver/arm-target-as-mthumb.s
Modified:
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=318647&r1=318646&r2=318647&view=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Mon Nov 20 05:43:55 2017
@@ -541,11 +541,30 @@ std::string ToolChain::ComputeLLVMTriple
   << tools::arm::getARMArch(MArch, getTriple()) << "ARM";
 }
 
-// Assembly files should start in ARM mode, unless arch is M-profile.
-// Windows is always thumb.
-if ((InputType != types::TY_PP_Asm && Args.hasFlag(options::OPT_mthumb,
- options::OPT_mno_thumb, ThumbDefault)) || IsMProfile ||
- getTriple().isOSWindows()) {
+// Check to see if an explicit choice to use thumb has been made via
+// -mthumb. For assembler files we must check for -mthumb in the options
+// passed to the assember via -Wa or -Xassembler.
+bool IsThumb = false;
+if (InputType != types::TY_PP_Asm)
+  IsThumb = Args.hasFlag(options::OPT_mthumb, options::OPT_mno_thumb,
+  ThumbDefault);
+else {
+  // Ideally we would check for these flags in
+  // CollectArgsForIntegratedAssembler but we can't change the ArchName at
+  // that point. There is no assembler equivalent of -mno-thumb, -marm, or
+  // -mno-arm.
+  for (const Arg *A :
+   Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler)) {
+for (StringRef Value : A->getValues()) {
+  if (Value == "-mthumb")
+IsThumb = true;
+}
+  }
+}
+// Assembly files should start in ARM mode, unless arch is M-profile, or
+// -mthumb has been passed explicitly to the assembler. Windows is always
+// thumb.
+if (IsThumb || IsMProfile || getTriple().isOSWindows()) {
   if (IsBigEndian)
 ArchName = "thumbeb";
   else

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=318647&r1=318646&r2=318647&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon Nov 20 05:43:55 2017
@@ -1889,6 +1889,15 @@ static void CollectArgsForIntegratedAsse
   switch (C.getDefaultToolChain().getArch()) {
   default:
 break;
+  case llvm::Triple::thumb:
+  case llvm::Triple::thumbeb:
+  case llvm::Triple::arm:
+  case llvm::Triple::armeb:
+if (Value == "-mthumb")
+  // -mthumb has already been processed in ComputeLLVMTriple()
+  // recognize but skip over here.
+  continue;
+
   case llvm::Triple::mips:
   case llvm::Triple::mipsel:
   case llvm::Triple::mips64:

Added: cfe/trunk/test/Driver/arm-target-as-mthumb.s
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arm-target-as-mthumb.s?rev=318647&view=auto
==
--- cfe/trunk/test/Driver/arm-target-as-mthumb.s (added)
+++ cfe/trunk/test/Driver/arm-target-as-mthumb.s Mon Nov 20 05:43:55 2017
@@ -0,0 +1,17 @@
+// Make sure -mthumb does not affect assembler triple, but -Wa,-mthumb or
+// -Xassembler -mthumb does. Also check that -Wa,-mthumb or -Xassembler -mthumb
+// does not affect non assembler files.
+
+// RUN: %clang -target armv7a-linux-gnueabi -### -c -mthumb %s 2>&1 | \
+// RUN: FileCheck -check-prefix=TRIPLE-ARM %s
+// RUN: %clang -target armv7a-linux-gnueabi -### -c -Wa,-mthumb \
+// RUN: %S/Inputs/wildcard1.c  2>&1 | FileCheck -check-prefix=TRIPLE-ARM %s
+
+// TRIPLE-ARM: "-triple" "armv7--linux-gnueabi"
+
+// RUN: %clang -target armv7a-linux-gnueabi -### -c -Wa,-mthumb %s 2>&1 | \
+// RUN: File

[PATCH] D40127: [Driver][ARM] For assembler files recognize -Xassembler or -Wa, -mthumb

2017-11-20 Thread Peter Smith via Phabricator via cfe-commits
peter.smith added a comment.

In https://reviews.llvm.org/D40127#929578, @compnerd wrote:

> Would be nice to rename the variable prior to commit.


Thanks for the review, I've renamed the variable as suggested.


https://reviews.llvm.org/D40127



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


r318648 - [ARM] For assembler files recognize -Xassembler or -Wa, -mthumb

2017-11-20 Thread Peter Smith via cfe-commits
Author: psmith
Date: Mon Nov 20 05:53:55 2017
New Revision: 318648

URL: http://llvm.org/viewvc/llvm-project?rev=318648&view=rev
Log:
[ARM] For assembler files recognize -Xassembler or -Wa, -mthumb

Attempt to fix warning picked up by buildbot.


Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=318648&r1=318647&r2=318648&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon Nov 20 05:53:55 2017
@@ -1897,7 +1897,7 @@ static void CollectArgsForIntegratedAsse
   // -mthumb has already been processed in ComputeLLVMTriple()
   // recognize but skip over here.
   continue;
-
+break;
   case llvm::Triple::mips:
   case llvm::Triple::mipsel:
   case llvm::Triple::mips64:


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


[PATCH] D39834: [clangd] -foptimization-record-file= should imply -fsave-optimization-record

2017-11-20 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added a comment.

Hi! You put "[clangd]" in the title, but I don't believe it's related to clangd 
but rather just "clang"?


https://reviews.llvm.org/D39834



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


[PATCH] D40230: Add -mprefer-vector-width driver option and attribute during CodeGen.

2017-11-20 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added a reviewer: hfinkel.
spatel added inline comments.



Comment at: include/clang/Frontend/CodeGenOptions.h:254
 
+  /// The prefered vector width.
+  std::string PreferVectorWidth;

typo - 'preferred'. Should add a bit more to the explanation. "The preferred 
width for auto-vectorization transforms. This is intended to override default 
transforms based on the width of the architected vector registers." ?



Comment at: lib/Driver/ToolChains/Clang.cpp:277
 
+/// The -mpreferred
+static void ParseMPreferVectorWidth(const Driver &D, const ArgList &Args,

Comment got chopped off? Should we also include an explanation in the clang 
manual?



Comment at: lib/Driver/ToolChains/Clang.cpp:285-286
+  StringRef Value = A->getValue();
+  if (Value == "none") {
+CmdArgs.push_back("-mprefer-vector-width=none");
+  } else {

What is the intended functionality when specifying 'none'? If it's equivalent 
to passing "-vectorize-slp" + "-vectorize-loops", can we use the existing flags?


https://reviews.llvm.org/D40230



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


[PATCH] D38425: [clangd] Document highlights for clangd

2017-11-20 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added a comment.

Hi William, can you quickly go over the diff before I do a review? There are a 
few more-obvious things that can be addressed, i.e. commented lines, extra 
new/deleted lines, temporary code, lower case variable names, etc.


https://reviews.llvm.org/D38425



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


[PATCH] D40226: [CodeGen] Move Reciprocals option from TargetOptions to CodeGenOptions

2017-11-20 Thread Sanjay Patel via Phabricator via cfe-commits
spatel accepted this revision.
spatel added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D40226



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


[PATCH] D40242: Do not perform the analysis based warning if all warnings are ignored

2017-11-20 Thread Olivier Goffart via Phabricator via cfe-commits
ogoffart marked an inline comment as done.
ogoffart added inline comments.



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:2084
+  // Do not do any analysis if we are going to just ignore them.
+  if (Diags.getIgnoreAllWarnings() ||
+  (Diags.getSuppressSystemWarnings() &&

lebedev.ri wrote:
> I guess you can try commenting-out that entire check and seeing whether any 
> test fails.
Commenting out the entire if does not cause any test to fail.


https://reviews.llvm.org/D40242



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


[PATCH] D39857: [AMDGPU] Late parsed / dependent arguments for AMDGPU kernel attributes

2017-11-20 Thread Alex Voicu via Phabricator via cfe-commits
AlexVlx updated this revision to Diff 123577.
AlexVlx added a comment.

Apologies for the delayed update. The new version tries to deal with two issues:

1. the non-compliant style identified by Aaron in various spots, hopefully this 
is correct now;
2. there was an issue with the existing logic, which only came up with 
additional testing:
  - for AMDGPUFlatWorkGroupSizeAttr and AMDGPUWavesPerEU, it is valid for the 
user to have passed an integer literal for the minimum and a dependent 
expression for the maximum;
  - in this case, iff the expression for the maximum could not be evaluated in 
Sema, then a spurious error case would obtain in which the minimum would 
signalled as greater than the maximum, which would have been pegged at 0;
  - this is fixed by having the maximum be at least equal to the minimum before 
any attempt of evaluating it is made - iff the actual user passed arguments to 
the attribute violate its invariants the error is signalled.
  - the relevant changes are on lines 5495 and 5529 in SemaDeclAttr.cpp.


https://reviews.llvm.org/D39857

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/CodeGen/TargetInfo.cpp
  lib/Sema/SemaDeclAttr.cpp

Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5469,16 +5469,33 @@
   }
 }
 
+static bool checkAllAreIntegral(Sema &S, const AttributeList &Attr) {
+  for (unsigned i = 0u; i != Attr.getNumArgs(); ++i) {
+Expr *E = Attr.getArgAsExpr(i);
+if (E && !E->getType()->isIntegralOrEnumerationType()) {
+  S.Diag(getAttrLoc(Attr), diag::err_attribute_argument_n_type)
+<< getAttrName(Attr) << i << AANT_ArgumentIntegerConstant
+<< E->getSourceRange();
+
+  return false;
+}
+  }
+
+  return true;
+}
+
 static void handleAMDGPUFlatWorkGroupSizeAttr(Sema &S, Decl *D,
   const AttributeList &Attr) {
   uint32_t Min = 0;
   Expr *MinExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, MinExpr, Min))
+  if (MinExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, MinExpr, Min))
 return;
 
-  uint32_t Max = 0;
+  uint32_t Max = Min;
   Expr *MaxExpr = Attr.getArgAsExpr(1);
-  if (!checkUInt32Argument(S, Attr, MaxExpr, Max))
+  if (MaxExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, MaxExpr, Max))
 return;
 
   if (Min == 0 && Max != 0) {
@@ -5493,21 +5510,28 @@
   }
 
   D->addAttr(::new (S.Context)
- AMDGPUFlatWorkGroupSizeAttr(Attr.getLoc(), S.Context, Min, Max,
- Attr.getAttributeSpellingListIndex()));
+ AMDGPUFlatWorkGroupSizeAttr(
+   Attr.getLoc(), S.Context, MinExpr, MaxExpr,
+   Attr.getAttributeSpellingListIndex()));
 }
 
 static void handleAMDGPUWavesPerEUAttr(Sema &S, Decl *D,
const AttributeList &Attr) {
+  if (!checkAllAreIntegral(S, Attr))
+return;
+
   uint32_t Min = 0;
   Expr *MinExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, MinExpr, Min))
+  if (MinExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, MinExpr, Min))
 return;
 
-  uint32_t Max = 0;
+  uint32_t Max = Min;
+  Expr *MaxExpr = MinExpr;
   if (Attr.getNumArgs() == 2) {
 Expr *MaxExpr = Attr.getArgAsExpr(1);
-if (!checkUInt32Argument(S, Attr, MaxExpr, Max))
+if (MaxExpr->isEvaluatable(S.Context) &&
+!checkUInt32Argument(S, Attr, MaxExpr, Max))
   return;
   }
 
@@ -5523,31 +5547,39 @@
   }
 
   D->addAttr(::new (S.Context)
- AMDGPUWavesPerEUAttr(Attr.getLoc(), S.Context, Min, Max,
+ AMDGPUWavesPerEUAttr(Attr.getLoc(), S.Context, MinExpr, MaxExpr,
   Attr.getAttributeSpellingListIndex()));
 }
 
 static void handleAMDGPUNumSGPRAttr(Sema &S, Decl *D,
 const AttributeList &Attr) {
+  if (!checkAllAreIntegral(S, Attr))
+return;
+
   uint32_t NumSGPR = 0;
   Expr *NumSGPRExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, NumSGPRExpr, NumSGPR))
+  if (NumSGPRExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, NumSGPRExpr, NumSGPR))
 return;
 
   D->addAttr(::new (S.Context)
- AMDGPUNumSGPRAttr(Attr.getLoc(), S.Context, NumSGPR,
+ AMDGPUNumSGPRAttr(Attr.getLoc(), S.Context, NumSGPRExpr,
Attr.getAttributeSpellingListIndex()));
 }
 
 static void handleAMDGPUNumVGPRAttr(Sema &S, Decl *D,
 const AttributeList &Attr) {
+  if (!checkAllAreIntegral(S, Attr))
+return;
+
   uint32_t NumVGPR = 0;
   Expr *NumVGPRExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, NumVGPRExpr, NumVGPR))
+  if (NumVGPRExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, NumVGPRExpr, NumVGPR))
  

[PATCH] D38976: [OpenMP] Add implicit data sharing support when offloading to NVIDIA GPUs using OpenMP device offloading

2017-11-20 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.

LG




Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:474
   CodeGenFunction CGF(CGM, /*suppressNewContext=*/true);
   CGF.disableDebugInfo();
   CGF.StartFunction(GlobalDecl(), Ctx.VoidTy, WST.WorkerFn, *WST.CGFI, {});

Later we should remove it from the code.


https://reviews.llvm.org/D38976



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


[PATCH] D39834: [clangd] -foptimization-record-file= should imply -fsave-optimization-record

2017-11-20 Thread Dmitry Venikov via Phabricator via cfe-commits
Quolyk added a comment.

In https://reviews.llvm.org/D39834#930165, @malaperle wrote:

> Hi! You put "[clangd]" in the title, but I don't believe it's related to 
> clangd but rather just "clang"?


I thought patch to clang option is supposed to be marked as "clangd".


https://reviews.llvm.org/D39834



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


Re: Clang-format: add finer-grained options for putting all arguments on one line.

2017-11-20 Thread Russell McClellan via cfe-commits
Hi -

Just pinging this after a week; let me know if there's a better way to
submit patches, I'm a first time contributor.

On Mon, Nov 13, 2017 at 6:55 PM, Russell McClellan
 wrote:
> Attached is a patch that adds two new options,
> AllowAllArgumentsOnNextLine and
> AllowAllConstructorInitializersOnNextLine.  These mirror the existing
> AllowAllParametersOfDeclarationOnNextLine and allow me to support an
> internal style guide where I work.  I think this would be generally
> useful, some have asked for it on stackoverflow:
>
> https://stackoverflow.com/questions/30057534/clang-format-binpackarguments-not-working-as-expected
>
> https://stackoverflow.com/questions/38635106/clang-format-how-to-prevent-all-function-arguments-on-next-line
>
> Thanks for your consideration, and let me know if there's anything I
> can do to improve the patch; I'm a first-time contributor.
>
> Thanks,
> -Russell
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40250: [OpenMP] Consistently use cubin extension for nvlink

2017-11-20 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

A different approach would be to completely replace the type in 
`Driver::ConstructPhaseAction` but

1. this was previously considered a too radical change,
2. we currently don't have the necessary information (ToolChain, OffloadKind) 
to take that decision,
3. this might break in subtle places that compare the type with `TY_Object`.


https://reviews.llvm.org/D40250



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


[PATCH] D39438: [analyzer] Diagnose stack leaks via block captures

2017-11-20 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.

Thanks, looks great, please commit!~


Repository:
  rL LLVM

https://reviews.llvm.org/D39438



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


[PATCH] D39834: [clang] -foptimization-record-file= should imply -fsave-optimization-record

2017-11-20 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added a comment.

This also ensures that if `fno_save_optimization_record` is specified, you 
don't overwrite it by setting the file. This is definitely something you'd want 
to add to your test case.


https://reviews.llvm.org/D39834



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


[PATCH] D39834: [clang] -foptimization-record-file= should imply -fsave-optimization-record

2017-11-20 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added a comment.

I think you can achieve the same result with less code by checking for the 
flag's presence higher up, where currently `OPT_fsave_optimization_record` is 
handled (Clang.cpp:4329). Something like:

  if (Args.hasFlag(options::OPT_fsave_optimization_record,
   options::OPT_fno_save_optimization_record, false) || 
  Args.hasFlag(options::OPT_foptimization_record_file_EQ, 
   options::OPT_fno_save_optimization_record, false)) {

The test looks good to me.


https://reviews.llvm.org/D39834



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


[PATCH] D40250: [OpenMP] Consistently use cubin extension for nvlink

2017-11-20 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld created this revision.

This was previously done in some places, but for example not for
bundling so that single object compilation with -c failed. In
addition cubin was used for all file types during unbundling which
is incorrect for assembly files that are passed to ptxas.
Tighten up the tests so that we can't regress in that area.


https://reviews.llvm.org/D40250

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/Cuda.cpp
  lib/Driver/ToolChains/Cuda.h
  test/Driver/openmp-offload-gpu.c

Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -28,43 +28,61 @@
 /// ###
 
 /// Check cubin file generation and usage by nvlink
-// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHK-CUBIN %s
+// RUN:   %clang -### -no-canonical-prefixes -target powerpc64le-unknown-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-CUBIN-NVLINK %s
+/// Check cubin file generation and usage by nvlink when toolchain has BindArchAction
+// RUN:   %clang -### -no-canonical-prefixes -target x86_64-apple-darwin17.0.0 -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-CUBIN-NVLINK %s
+
+// CHK-CUBIN-NVLINK: clang{{.*}}" "-o" "[[PTX:.*\.s]]"
+// CHK-CUBIN-NVLINK-NEXT: ptxas{{.*}}" "--output-file" "[[CUBIN:.*\.cubin]]" {{.*}}"[[PTX]]"
+// CHK-CUBIN-NVLINK-NEXT: nvlink{{.*}}" {{.*}}"[[CUBIN]]"
+
+/// ###
 
-// CHK-CUBIN: clang{{.*}}" "-o" "{{.*}}.s"
-// CHK-CUBIN-NEXT: ptxas{{.*}}" "--output-file" {{.*}}.cubin" {{.*}}.s"
-// CHK-CUBIN-NEXT: nvlink" {{.*}}.cubin"
+/// Check unbundlink of assembly file, cubin file generation and usage by nvlink
+// RUN:   touch %t.s
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps %t.s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-UNBUNDLING-PTXAS-CUBIN-NVLINK %s
 
+/// Use DAG to ensure that assembly file has been unbundled.
+// CHK-UNBUNDLING-PTXAS-CUBIN-NVLINK-DAG: ptxas{{.*}}" "--output-file" "[[CUBIN:.*\.cubin]]" {{.*}}"[[PTX:.*\.s]]"
+// CHK-UNBUNDLING-PTXAS-CUBIN-NVLINK-DAG: clang-offload-bundler{{.*}}" "-type=s" {{.*}}"-outputs={{.*}}[[PTX]]
+// CHK-UNBUNDLING-PTXAS-CUBIN-NVLINK: nvlink{{.*}}" {{.*}}"[[CUBIN]]"
 
 /// ###
 
-/// Check cubin file generation and usage by nvlink when toolchain has BindArchAction
-// RUN:   %clang -### -no-canonical-prefixes -target x86_64-apple-darwin17.0.0 -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHK-CUBIN-DARWIN %s
+/// Check cubin file generation and bundling
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps %s -c 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS-CUBIN-BUNDLING %s
 
-// CHK-CUBIN-DARWIN: clang{{.*}}" "-o" "{{.*}}.s"
-// CHK-CUBIN-DARWIN-NEXT: ptxas{{.*}}" "--output-file" {{.*}}.cubin" {{.*}}.s"
-// CHK-CUBIN-DARWIN-NEXT: nvlink" {{.*}}.cubin"
+// CHK-PTXAS-CUBIN-BUNDLING: clang{{.*}}" "-o" "[[PTX:.*\.s]]"
+// CHK-PTXAS-CUBIN-BUNDLING-NEXT: ptxas{{.*}}" "--output-file" "[[CUBIN:.*\.cubin]]" {{.*}}"[[PTX]]"
+// CHK-PTXAS-CUBIN-BUNDLING: clang-offload-bundler{{.*}}" "-type=o" {{.*}}"-inputs={{.*}}[[CUBIN]]
 
 /// ###
 
-/// Check cubin file generation and usage by nvlink
-// RUN:   touch %t1.o
-// RUN:   touch %t2.o
-// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda %t1.o %t2.o 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHK-TWOCUBIN %s
+/// Check cubin file unbundling and usage by nvlink
+// RUN:   touch %t.o
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-CUBIN-UNBUNDLING-NVLINK %s
 
-// CHK-TWOCUBIN: nvlink{{.*}}openmp-offload-{{.*}}.cubin" "{{.*}}openmp-offload-{{.*}}.cubin"
+/// Use DAG to ensure that cubin file has been unbundled.
+// CHK-CUBIN-UNBUNDLING-NVLINK-DAG: nvlink{{.*}}" {{.*}}"[[CUBIN:.*\.cubin]]"
+// CHK-CUBIN-UNBUNDLING-NVLINK-DAG: clang-offload-bundler{{.*}}" "-type=o" {{.*}}"-outputs={{.*}}[[CUBIN]]
 
 /// ###
 
-/// Check cubin file generation and usage by nvlink when toolchain has BindArchAction
+/// Check cubin file generation and usage by nvlink
 // RUN:   touch %t1.o
 // RUN:   touch %

[PATCH] D20124: [PCH] Serialize skipped preprocessor ranges

2017-11-20 Thread Cameron via Phabricator via cfe-commits
cameron314 added a comment.

In https://reviews.llvm.org/D20124#928552, @ilya-biryukov wrote:

> Why do we store raw source locations in `PPSkippedRange`? Would storing 
> `SourceLocation` and using  `ASTWriter::AddSourceLocation` and `ASTReader:: 
> ReadSourceLocation` do the trick?


I followed the pattern used to store `PPEntityOffset`s; it allows the entire 
array to be written in one chunk. Using 
`AddSourceLocation`/`ReadSourceLocation` boils down to the same thing -- 
`AddSourceLocation` simply rotates by one bit, and `ReadSourceLocation` simply 
rotates back and calls `ASTReader::TranslateSourceLocation` (which I call from 
`AST::ReadSkippedRange` explicitly instead). So the source location translation 
path is exactly the same either way.

The thing is, the PCH created for the preamble is imported as a module, meaning 
the part of the source code that overlaps the preamble of the entry file has a 
different file ID from the entry file itself. Is there any way to force source 
locations in the preamble to map to the actual entry file instead of the 
module's version of the entry file?


https://reviews.llvm.org/D20124



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


[PATCH] D40250: [OpenMP] Consistently use cubin extension for nvlink

2017-11-20 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added inline comments.



Comment at: lib/Driver/ToolChains/Clang.cpp:5340
+
+const ToolChain *CurTC = &getToolChain();
+if (const auto *OA = dyn_cast(JA.getInputs()[I])) {

Please add a comment here describing what this entire code snippet is doing.



Comment at: lib/Driver/ToolChains/Cuda.cpp:431
 
-SmallString<256> Name(II.getFilename());
-llvm::sys::path::replace_extension(Name, "cubin");
-
-const char *CubinF =
-C.addTempFile(C.getArgs().MakeArgString(Name));
+const char *CubinF = C.addTempFile(
+C.getArgs().MakeArgString(getToolChain().getInputFilename(II)));

Is this always a cubin?



Comment at: lib/Driver/ToolChains/Cuda.cpp:461
+std::string CudaToolChain::getInputFilename(const InputInfo &Input) const {
+  if (OK != Action::OFK_OpenMP || Input.getType() != types::TY_Object)
+return ToolChain::getInputFilename(Input);

When does this situation occur?


https://reviews.llvm.org/D40250



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


[PATCH] D40250: [OpenMP] Consistently use cubin extension for nvlink

2017-11-20 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld marked 2 inline comments as done.
Hahnfeld added inline comments.



Comment at: lib/Driver/ToolChains/Cuda.cpp:431
 
-SmallString<256> Name(II.getFilename());
-llvm::sys::path::replace_extension(Name, "cubin");
-
-const char *CubinF =
-C.addTempFile(C.getArgs().MakeArgString(Name));
+const char *CubinF = C.addTempFile(
+C.getArgs().MakeArgString(getToolChain().getInputFilename(II)));

gtbercea wrote:
> Is this always a cubin?
Probably because the linker always takes object files...



Comment at: lib/Driver/ToolChains/Cuda.cpp:461
+std::string CudaToolChain::getInputFilename(const InputInfo &Input) const {
+  if (OK != Action::OFK_OpenMP || Input.getType() != types::TY_Object)
+return ToolChain::getInputFilename(Input);

gtbercea wrote:
> When does this situation occur?
Well, if that condition fires:
1. For CUDA
2. For other types. For example, the bundler might need to bundle / unbundle 
assembly files.


https://reviews.llvm.org/D40250



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


[PATCH] D40256: [ARM] disable FPU features when using soft floating point.

2017-11-20 Thread Keith Walker via Phabricator via cfe-commits
keith.walker.arm created this revision.
Herald added subscribers: kristof.beyls, javed.absar, aemerson.

To be compatible with GCC if soft floating point is in effect any FPU
specified is effectively ignored, eg,

  -mfloat-abi=soft -fpu=neon

If any floating point features which require FPU hardware are enabled
they must be disable.

There was some support for doing this for NEON, but it did not handle
VFP, nor did it prevent the backend from emitting the build attribute
Tag_FP_arch describing the generated code as using the floating point
hardware if a FPU was specified (even though soft float does not use
the FPU).

Disabling the hardware floating point features for targets which are
compiling for soft float has meant that some tests which were incorrectly
checking for hardware support also needed to be updated.  In such cases,
where appropriate the tests have been updated to check compiling for
soft float and a non-soft float variant (usually softfp).  This was
usually because the target specified in the test defaulted to soft float.


https://reviews.llvm.org/D40256

Files:
  lib/Driver/ToolChains/Arch/ARM.cpp
  test/Driver/arm-cortex-cpus.c
  test/Driver/arm-dotprod.c
  test/Driver/arm-mfpu.c
  test/Preprocessor/arm-target-features.c

Index: test/Driver/arm-dotprod.c
===
--- test/Driver/arm-dotprod.c
+++ test/Driver/arm-dotprod.c
@@ -4,8 +4,19 @@
 // RUN: %clang -### -target arm -march=armv8.3a %s 2>&1 | FileCheck %s --check-prefix=CHECK-NONE
 // CHECK-NONE-NOT: "-target-feature" "+dotprod"
 
-// RUN: %clang -### -target arm -march=armv8.2a+dotprod %s 2>&1 | FileCheck %s
-// RUN: %clang -### -target arm -march=armv8.3a+dotprod %s 2>&1 | FileCheck %s
-// RUN: %clang -### -target arm -mcpu=cortex-a75 %s 2>&1 | FileCheck %s
-// RUN: %clang -### -target arm -mcpu=cortex-a55 %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target arm-linux-eabi -march=armv8.2a+dotprod %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target arm-linux-eabi -march=armv8.3a+dotprod %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target arm-linux-eabi -mcpu=cortex-a75 %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target arm-linux-eabi -mcpu=cortex-a55 %s 2>&1 | FileCheck %s
 // CHECK: "+dotprod"
+
+// The following default to -msoft-float
+// RUN: %clang -### -target arm -march=armv8.2a+dotprod %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-DOTPROD
+// RUN: %clang -### -target arm -march=armv8.3a+dotprod %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-DOTPROD
+// RUN: %clang -### -target arm -mcpu=cortex-a75 %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-DOTPROD
+// RUN: %clang -### -target arm -mcpu=cortex-a55 %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-DOTPROD
+// CHECK-NO-DOTPROD: "-dotprod"
Index: test/Driver/arm-cortex-cpus.c
===
--- test/Driver/arm-cortex-cpus.c
+++ test/Driver/arm-cortex-cpus.c
@@ -284,13 +284,13 @@
 // RUN: %clang -target arm -march=armebv8.2-a -mbig-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V82A-THUMB %s
 // CHECK-BE-V82A-THUMB: "-cc1"{{.*}} "-triple" "thumbebv8.2a-{{.*}}" "-target-cpu" "generic"
 
-// RUN: %clang -target armv8a -march=armv8.2-a+fp16 -### -c %s 2>&1 | FileCheck --check-prefix CHECK-V82A-FP16 %s
+// RUN: %clang -target armv8a-linux-eabi -march=armv8.2-a+fp16 -### -c %s 2>&1 | FileCheck --check-prefix CHECK-V82A-FP16 %s
 // CHECK-V82A-FP16: "-cc1"{{.*}} "-triple" "armv8.2{{.*}}" "-target-cpu" "generic" {{.*}}"-target-feature" "+fullfp16"
 
 // Once we have CPUs with optional v8.2-A FP16, we will need a way to turn it
 // on and off. Cortex-A53 is a placeholder for now.
-// RUN: %clang -target armv8a -mcpu=cortex-a53+fp16 -### -c %s 2>&1 | FileCheck --check-prefix CHECK-CORTEX-A53-FP16 %s
-// RUN: %clang -target armv8a -mcpu=cortex-a53+nofp16 -### -c %s 2>&1 | FileCheck --check-prefix CHECK-CORTEX-A53-NOFP16 %s
+// RUN: %clang -target armv8a-linux-eabi -mcpu=cortex-a53+fp16 -### -c %s 2>&1 | FileCheck --check-prefix CHECK-CORTEX-A53-FP16 %s
+// RUN: %clang -target armv8a-linux-eabi -mcpu=cortex-a53+nofp16 -### -c %s 2>&1 | FileCheck --check-prefix CHECK-CORTEX-A53-NOFP16 %s
 // CHECK-CORTEX-A53-FP16: "-cc1" {{.*}}"-target-cpu" "cortex-a53" {{.*}}"-target-feature" "+fullfp16"
 // CHECK-CORTEX-A53-NOFP16: "-cc1" {{.*}}"-target-cpu" "cortex-a53" {{.*}}"-target-feature" "-fullfp16"
 
Index: test/Driver/arm-mfpu.c
===
--- test/Driver/arm-mfpu.c
+++ test/Driver/arm-mfpu.c
@@ -2,6 +2,8 @@
 
 // RUN: %clang -target arm-linux-eabi %s -### -o %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-DEFAULT %s
+// CHECK-DEFAULT-NOT: "-target-feature" "+soft-float"
+// CHECK-DEFAULT: "-target-feature" "+soft-float-abi"
 // CHECK-DEFAULT-NOT: "-target-feature" "+vfp2"
 // CHECK-DEFAULT-NOT: "-target-feature" "+vfp3"
 // CHECK-DEFAULT-NOT: "-target-feature"

[PATCH] D40250: [OpenMP] Consistently use cubin extension for nvlink

2017-11-20 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added inline comments.



Comment at: lib/Driver/ToolChains/Cuda.cpp:431
 
-SmallString<256> Name(II.getFilename());
-llvm::sys::path::replace_extension(Name, "cubin");
-
-const char *CubinF =
-C.addTempFile(C.getArgs().MakeArgString(Name));
+const char *CubinF = C.addTempFile(
+C.getArgs().MakeArgString(getToolChain().getInputFilename(II)));

Hahnfeld wrote:
> gtbercea wrote:
> > Is this always a cubin?
> Probably because the linker always takes object files...
Considering that the function may also return an object file can you add an 
assert here that getInputFileName(II) returns a cubin in this case?



Comment at: lib/Driver/ToolChains/Cuda.cpp:461
+std::string CudaToolChain::getInputFilename(const InputInfo &Input) const {
+  if (OK != Action::OFK_OpenMP || Input.getType() != types::TY_Object)
+return ToolChain::getInputFilename(Input);

Hahnfeld wrote:
> gtbercea wrote:
> > When does this situation occur?
> Well, if that condition fires:
> 1. For CUDA
> 2. For other types. For example, the bundler might need to bundle / unbundle 
> assembly files.
Can you put this info in a comment just before the if statement?



Comment at: test/Driver/openmp-offload-gpu.c:51
+// CHK-UNBUNDLING-PTXAS-CUBIN-NVLINK-DAG: clang-offload-bundler{{.*}}" 
"-type=s" {{.*}}"-outputs={{.*}}[[PTX]]
+// CHK-UNBUNDLING-PTXAS-CUBIN-NVLINK: nvlink{{.*}}" {{.*}}"[[CUBIN]]"
 

This is kind of optional but since the name of the tool contains the word 
"bundler" and you are performing an unbundling operation, could you also check 
that the -unbundle flag is passed?


https://reviews.llvm.org/D40250



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


[PATCH] D40257: [CMake] Use LIST_SEPARATOR rather than escaping in ExternalProject_Add

2017-11-20 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
Herald added a subscriber: mgorny.

Escaping ; in list arguments passed to ExternalProject_Add doesn't seem
to be working in newer versions of CMake (see
https://public.kitware.com/Bug/view.php?id=16137 for more details). Use
a custom LIST_SEPARATOR instead which is the officially supported way.


Repository:
  rL LLVM

https://reviews.llvm.org/D40257

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -669,7 +669,7 @@
   if("${${variableName}}" STREQUAL "")
 set(value "")
   else()
-string(REPLACE ";" "\;" value ${${variableName}})
+string(REPLACE ";" "," value ${${variableName}})
   endif()
   list(APPEND PASSTHROUGH_VARIABLES
 -D${variableName}=${value})
@@ -697,6 +697,7 @@
 USES_TERMINAL_CONFIGURE 1
 USES_TERMINAL_BUILD 1
 USES_TERMINAL_INSTALL 1
+LIST_SEPARATOR ,
 )
 
   # exclude really-install from main target


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -669,7 +669,7 @@
   if("${${variableName}}" STREQUAL "")
 set(value "")
   else()
-string(REPLACE ";" "\;" value ${${variableName}})
+string(REPLACE ";" "," value ${${variableName}})
   endif()
   list(APPEND PASSTHROUGH_VARIABLES
 -D${variableName}=${value})
@@ -697,6 +697,7 @@
 USES_TERMINAL_CONFIGURE 1
 USES_TERMINAL_BUILD 1
 USES_TERMINAL_INSTALL 1
+LIST_SEPARATOR ,
 )
 
   # exclude really-install from main target
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40258: [CMake] Support side-by-side checkouts in multi-stage build

2017-11-20 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
Herald added a subscriber: mgorny.

Passthrough LLVM_ENABLE_{PROJECTS,RUNTIMES} to followup stages to
support the side-by-side checkouts (aka monorepo layout).


Repository:
  rL LLVM

https://reviews.llvm.org/D40258

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -603,7 +603,9 @@
 LLVM_BINUTILS_INCDIR
 CLANG_REPOSITORY_STRING
 CMAKE_MAKE_PROGRAM
-CMAKE_OSX_ARCHITECTURES)
+CMAKE_OSX_ARCHITECTURES
+LLVM_ENABLE_PROJECTS
+LLVM_ENABLE_RUNTIMES)
 
   # We don't need to depend on compiler-rt if we're building instrumented
   # because the next stage will use the same compiler used to build this stage.


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -603,7 +603,9 @@
 LLVM_BINUTILS_INCDIR
 CLANG_REPOSITORY_STRING
 CMAKE_MAKE_PROGRAM
-CMAKE_OSX_ARCHITECTURES)
+CMAKE_OSX_ARCHITECTURES
+LLVM_ENABLE_PROJECTS
+LLVM_ENABLE_RUNTIMES)
 
   # We don't need to depend on compiler-rt if we're building instrumented
   # because the next stage will use the same compiler used to build this stage.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40250: [OpenMP] Consistently use cubin extension for nvlink

2017-11-20 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld marked 2 inline comments as done.
Hahnfeld added inline comments.



Comment at: lib/Driver/ToolChains/Cuda.cpp:431
 
-SmallString<256> Name(II.getFilename());
-llvm::sys::path::replace_extension(Name, "cubin");
-
-const char *CubinF =
-C.addTempFile(C.getArgs().MakeArgString(Name));
+const char *CubinF = C.addTempFile(
+C.getArgs().MakeArgString(getToolChain().getInputFilename(II)));

gtbercea wrote:
> Hahnfeld wrote:
> > gtbercea wrote:
> > > Is this always a cubin?
> > Probably because the linker always takes object files...
> Considering that the function may also return an object file can you add an 
> assert here that getInputFileName(II) returns a cubin in this case?
Hmm, that's a string. I've never seen asserts that say "this string should 
contain...". IMO that's what we have tests for



Comment at: lib/Driver/ToolChains/Cuda.cpp:461
+std::string CudaToolChain::getInputFilename(const InputInfo &Input) const {
+  if (OK != Action::OFK_OpenMP || Input.getType() != types::TY_Object)
+return ToolChain::getInputFilename(Input);

gtbercea wrote:
> Hahnfeld wrote:
> > gtbercea wrote:
> > > When does this situation occur?
> > Well, if that condition fires:
> > 1. For CUDA
> > 2. For other types. For example, the bundler might need to bundle / 
> > unbundle assembly files.
> Can you put this info in a comment just before the if statement?
I'd say this condition is not the most difficult that I've ever seen, but can do


https://reviews.llvm.org/D40250



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


r318662 - [CodeGen] Move Reciprocals option from TargetOptions to CodeGenOptions

2017-11-20 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Mon Nov 20 09:09:22 2017
New Revision: 318662

URL: http://llvm.org/viewvc/llvm-project?rev=318662&view=rev
Log:
[CodeGen] Move Reciprocals option from TargetOptions to CodeGenOptions

Diffrential Revision: https://reviews.llvm.org/D40226

Modified:
cfe/trunk/include/clang/Basic/TargetOptions.h
cfe/trunk/include/clang/Frontend/CodeGenOptions.h
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Basic/TargetOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetOptions.h?rev=318662&r1=318661&r2=318662&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetOptions.h (original)
+++ cfe/trunk/include/clang/Basic/TargetOptions.h Mon Nov 20 09:09:22 2017
@@ -54,8 +54,6 @@ public:
   /// be a list of strings starting with by '+' or '-'.
   std::vector Features;
 
-  std::vector Reciprocals;
-
   /// Supported OpenCL extensions and optional core features.
   OpenCLOptions SupportedOpenCLOptions;
 

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.h?rev=318662&r1=318661&r2=318662&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.h Mon Nov 20 09:09:22 2017
@@ -251,6 +251,8 @@ public:
   /// \brief A list of all -fno-builtin-* function names (e.g., memset).
   std::vector NoBuiltinFuncs;
 
+  std::vector Reciprocals;
+
 public:
   // Define accessors/mutators for code generation options of enumeration type.
 #define CODEGENOPT(Name, Bits, Default)

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=318662&r1=318661&r2=318662&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Mon Nov 20 09:09:22 2017
@@ -1739,7 +1739,7 @@ void CodeGenModule::ConstructDefaultFnAt
 llvm::toStringRef(CodeGenOpts.CorrectlyRoundedDivSqrt));
 
 // TODO: Reciprocal estimate codegen options should apply to instructions?
-std::vector &Recips = getTarget().getTargetOpts().Reciprocals;
+const std::vector &Recips = CodeGenOpts.Reciprocals;
 if (!Recips.empty())
   FuncAttrs.addAttribute("reciprocal-estimates",
  llvm::join(Recips, ","));

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=318662&r1=318661&r2=318662&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Nov 20 09:09:22 2017
@@ -642,6 +642,7 @@ static bool ParseCodeGenArgs(CodeGenOpti
   Opts.FlushDenorm = Args.hasArg(OPT_cl_denorms_are_zero);
   Opts.CorrectlyRoundedDivSqrt =
   Args.hasArg(OPT_cl_fp32_correctly_rounded_divide_sqrt);
+  Opts.Reciprocals = Args.getAllArgValues(OPT_mrecip_EQ);
   Opts.ReciprocalMath = Args.hasArg(OPT_freciprocal_math);
   Opts.NoTrappingMath = Args.hasArg(OPT_fno_trapping_math);
   Opts.NoZeroInitializedInBSS = Args.hasArg(OPT_mno_zero_initialized_in_bss);
@@ -2667,7 +2668,6 @@ static void ParseTargetArgs(TargetOption
   Opts.FeaturesAsWritten = Args.getAllArgValues(OPT_target_feature);
   Opts.LinkerVersion = Args.getLastArgValue(OPT_target_linker_version);
   Opts.Triple = llvm::Triple::normalize(Args.getLastArgValue(OPT_triple));
-  Opts.Reciprocals = Args.getAllArgValues(OPT_mrecip_EQ);
   // Use the default target triple if unspecified.
   if (Opts.Triple.empty())
 Opts.Triple = llvm::sys::getDefaultTargetTriple();


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


[PATCH] D40073: [Analyzer] Non-determinism: don't sort indirect goto LabelDecl's by addresses

2017-11-20 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

Thanks! Do you have commit access, or do you need someone to commit this for 
you?


https://reviews.llvm.org/D40073



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


[PATCH] D40226: [CodeGen] Move Reciprocals option from TargetOptions to CodeGenOptions

2017-11-20 Thread Craig Topper via Phabricator via cfe-commits
craig.topper closed this revision.
craig.topper added a comment.

Committed in r318662, but I botched the "Differential Revision" in the commit 
message.


https://reviews.llvm.org/D40226



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


[PATCH] D39114: [XRay][darwin] Initial XRay in Darwin Support

2017-11-20 Thread Kuba (Brecka) Mracek via Phabricator via cfe-commits
kubamracek added a comment.

Hi, can you split the patch and send individual changes as separate patches? 
It's getting hard to follow. And I think we should land the parts that are 
"safe to land", e.g. the ASM changes or some of the NFC whitespace changes. The 
Darwin-specific changes in tests can also be landed (but don't enable the tests 
on Darwin, yet).


https://reviews.llvm.org/D39114



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


Re: [clang-tools-extra] r318600 - [clang-tidy] Add new hicpp-multiway-paths-covered check for missing branches

2017-11-20 Thread Mike Edwards via cfe-commits
Hi,
We are seeing a bot failure with this commit.  Please see the bot page here:
http://green.lab.llvm.org/green/job/clang-stage2-cmake-RgSan/5470/consoleFull#17462642768254eaf0-7326-4999-85b0-388101f2d404

Please let me know if you will be able to provide a patch for this in the
next couple of hours, otherwise I will need to revert your commit.  Thank
you for your assistance in keeping our bots green.

Respectfully,
Mike Edwards

On Sat, Nov 18, 2017 at 11:48 AM, Jonas Toth via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: jonastoth
> Date: Sat Nov 18 11:48:33 2017
> New Revision: 318600
>
> URL: http://llvm.org/viewvc/llvm-project?rev=318600&view=rev
> Log:
> [clang-tidy] Add new hicpp-multiway-paths-covered check for missing
> branches
>
> Summary:
> This check searches for missing `else` branches in `if-else if`-chains and
> missing `default` labels in `switch` statements, that use integers as
> condition.
>
> It is very similar to -Wswitch, but concentrates on integers only, since
> enums are
> already covered.
>
> The option to warn for missing `else` branches is deactivated by default,
> since it is
> very noise on larger code bases.
>
> Running it on LLVM:
> {F5354858} for default configuration
> {F5354866} just for llvm/lib/Analysis/ScalarEvolution.cpp, the else-path
> checker is very noisy!
>
> Reviewers: alexfh, aaron.ballman, hokein
>
> Reviewed By: aaron.ballman
>
> Subscribers: lebedev.ri, Eugene.Zelenko, cfe-commits, mgorny,
> JDevlieghere, xazax.hun
>
> Tags: #clang-tools-extra
>
> Differential Revision: https://reviews.llvm.org/D37808
>
>
> Added:
> clang-tools-extra/trunk/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
> clang-tools-extra/trunk/clang-tidy/hicpp/MultiwayPathsCoveredCheck.h
> clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-
> multiway-paths-covered.rst
> clang-tools-extra/trunk/test/clang-tidy/hicpp-multiway-
> paths-covered-else.cpp
> clang-tools-extra/trunk/test/clang-tidy/hicpp-multiway-
> paths-covered.cpp
> Modified:
> clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt
> clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp
> clang-tools-extra/trunk/docs/ReleaseNotes.rst
> clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
>
> Modified: clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-tidy/hicpp/CMakeLists.txt?rev=318600&r1=
> 318599&r2=318600&view=diff
> 
> ==
> --- clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt (original)
> +++ clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt Sat Nov 18
> 11:48:33 2017
> @@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS support)
>
>  add_clang_library(clangTidyHICPPModule
>ExceptionBaseclassCheck.cpp
> +  MultiwayPathsCoveredCheck.cpp
>NoAssemblerCheck.cpp
>HICPPTidyModule.cpp
>SignedBitwiseCheck.cpp
>
> Modified: clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-tidy/hicpp/HICPPTidyModule.cpp?rev=318600&r1=318599&r2=318600&
> view=diff
> 
> ==
> --- clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp
> (original)
> +++ clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp Sat Nov
> 18 11:48:33 2017
> @@ -35,6 +35,7 @@
>  #include "../readability/FunctionSizeCheck.h"
>  #include "../readability/IdentifierNamingCheck.h"
>  #include "ExceptionBaseclassCheck.h"
> +#include "MultiwayPathsCoveredCheck.h"
>  #include "NoAssemblerCheck.h"
>  #include "SignedBitwiseCheck.h"
>
> @@ -53,6 +54,8 @@ public:
>  "hicpp-exception-baseclass");
>  CheckFactories.registerCheck(
>  "hicpp-signed-bitwise");
> +CheckFactories.registerCheck(
> +"hicpp-multiway-paths-covered");
>  CheckFactories.registerCheck(
>  "hicpp-explicit-conversions");
>  CheckFactories.registerCheck(
>
> Added: clang-tools-extra/trunk/clang-tidy/hicpp/
> MultiwayPathsCoveredCheck.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp?rev=318600&view=auto
> 
> ==
> --- clang-tools-extra/trunk/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
> (added)
> +++ clang-tools-extra/trunk/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
> Sat Nov 18 11:48:33 2017
> @@ -0,0 +1,179 @@
> +//===--- MultiwayPathsCoveredCheck.cpp - clang-tidy
> ===//
> +//
> +// The LLVM Compiler Infrastructure
> +//
> +// This file is distributed under the University of Illinois Open Source
> +// License. See LICENSE.TXT for details.
> +//
> +//===--
> ===//
> +
> +#include "MultiwayPathsCoveredC

[PATCH] D40073: [Analyzer] Non-determinism: don't sort indirect goto LabelDecl's by addresses

2017-11-20 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

Thank you, Devin!

Ilya doesn't have commit access so please commit the patch (or leave it for me, 
I'm going to commit some patches tomorrow).
By the way, is there a common way to write tests for non-determinism for LLVM 
test suite?


https://reviews.llvm.org/D40073



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


r318665 - Revert r318556 "Loosen -Wempty-body warning"

2017-11-20 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Mon Nov 20 09:38:16 2017
New Revision: 318665

URL: http://llvm.org/viewvc/llvm-project?rev=318665&view=rev
Log:
Revert r318556 "Loosen -Wempty-body warning"

It seems this somehow made -Wempty-body fire in some macro cases where
it didn't before, e.g.

  ../../third_party/ffmpeg/libavcodec/bitstream.c(169,5):  error: if statement 
has empty body [-Werror,-Wempty-body]
  ff_dlog(NULL, "new table index=%d size=%d\n", table_index, table_size);
  ^
  ../../third_party/ffmpeg\libavutil/internal.h(276,80):  note: expanded from 
macro 'ff_dlog'
  #   define ff_dlog(ctx, ...) do { if (0) av_log(ctx, AV_LOG_DEBUG, 
__VA_ARGS__); } while (0)

 ^
  ../../third_party/ffmpeg/libavcodec/bitstream.c(169,5):  note: put the
  semicolon on a separate line to silence this warning

Reverting until this can be figured out.

> Do not show it when `if` or `else` come from macros.
> E.g.,
>
> #define USED(A) if (A); else
> #define SOME_IF(A) if (A)
>
> void test() {
>   // No warnings are shown in those cases now.
>   USED(0);
>   SOME_IF(0);
> }
>
> Patch by Ilya Biryukov!
>
> Differential Revision: https://reviews.llvm.org/D40185

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/test/SemaCXX/warn-empty-body.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=318665&r1=318664&r2=318665&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Nov 20 09:38:16 2017
@@ -9698,7 +9698,6 @@ public:
   class ConditionResult {
 Decl *ConditionVar;
 FullExprArg Condition;
-SourceLocation RParenLoc;
 bool Invalid;
 bool HasKnownValue;
 bool KnownValue;
@@ -9722,9 +9721,6 @@ public:
   return std::make_pair(cast_or_null(ConditionVar),
 Condition.get());
 }
-
-void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; }
-
 llvm::Optional getKnownValue() const {
   if (!HasKnownValue)
 return None;

Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=318665&r1=318664&r2=318665&view=diff
==
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmt.cpp Mon Nov 20 09:38:16 2017
@@ -1101,7 +1101,6 @@ bool Parser::ParseParenExprOrCondition(S
 
   // Otherwise the condition is valid or the rparen is present.
   T.consumeClose();
-  Cond.setRParenLoc(T.getCloseLocation());
 
   // Check for extraneous ')'s to catch things like "if (foo())) {".  We know
   // that all callers are looking for a statement after the condition, so ")"

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=318665&r1=318664&r2=318665&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Nov 20 09:38:16 2017
@@ -11821,7 +11821,7 @@ static bool ShouldDiagnoseEmptyStmtBody(
 
   // Get line numbers of statement and body.
   bool StmtLineInvalid;
-  unsigned StmtLine = SourceMgr.getSpellingLineNumber(StmtLoc,
+  unsigned StmtLine = SourceMgr.getPresumedLineNumber(StmtLoc,
   &StmtLineInvalid);
   if (StmtLineInvalid)
 return false;

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=318665&r1=318664&r2=318665&view=diff
==
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Mon Nov 20 09:38:16 2017
@@ -530,7 +530,8 @@ Sema::ActOnIfStmt(SourceLocation IfLoc,
   if (elseStmt)
 DiagnoseEmptyStmtBody(ElseLoc, elseStmt, diag::warn_empty_else_body);
   else
-DiagnoseEmptyStmtBody(Cond.RParenLoc, thenStmt, diag::warn_empty_if_body);
+DiagnoseEmptyStmtBody(CondExpr->getLocEnd(), thenStmt,
+  diag::warn_empty_if_body);
 
   return BuildIfStmt(IfLoc, IsConstexpr, InitStmt, Cond, thenStmt, ElseLoc,
  elseStmt);

Modified: cfe/trunk/test/SemaCXX/warn-empty-body.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-empty-body.cpp?rev=318665&r1=318664&r2=318665&view=diff
==
--- cfe/trunk/test/SemaCXX/warn-empty-body.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-empty-body.cpp Mon Nov 20 09:38:16 2017
@@ 

Re: r318556 - Loosen -Wempty-body warning

2017-11-20 Thread Hans Wennborg via cfe-commits
I've reverted in r318665 to get the buildbots green until this is figured out.



On Sat, Nov 18, 2017 at 11:55 AM, Hans Wennborg  wrote:
> We're still seeing some in macro-related code. From Chromium:
>
> ../../third_party/ffmpeg/libavcodec/bitstream.c(169,5):  error: if
> statement has empty body [-Werror,-Wempty-body]
> ff_dlog(NULL, "new table index=%d size=%d\n", table_index, table_size);
> ^
> ../../third_party/ffmpeg\libavutil/internal.h(276,80):  note: expanded
> from macro 'ff_dlog'
> #   define ff_dlog(ctx, ...) do { if (0) av_log(ctx, AV_LOG_DEBUG,
> __VA_ARGS__); } while (0)
>   
>  ^
> ../../third_party/ffmpeg/libavcodec/bitstream.c(169,5):  note: put the
> semicolon on a separate line to silence this warning
>
> (See https://build.chromium.org/p/chromium.clang/builders/ToTWin/builds/420)
>
> On Fri, Nov 17, 2017 at 1:33 PM, Reid Kleckner via cfe-commits
>  wrote:
>> Author: rnk
>> Date: Fri Nov 17 13:33:28 2017
>> New Revision: 318556
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=318556&view=rev
>> Log:
>> Loosen -Wempty-body warning
>>
>> Do not show it when `if` or `else` come from macros.
>> E.g.,
>>
>> #define USED(A) if (A); else
>> #define SOME_IF(A) if (A)
>>
>> void test() {
>>   // No warnings are shown in those cases now.
>>   USED(0);
>>   SOME_IF(0);
>> }
>>
>> Patch by Ilya Biryukov!
>>
>> Differential Revision: https://reviews.llvm.org/D40185
>>
>> Modified:
>> cfe/trunk/include/clang/Sema/Sema.h
>> cfe/trunk/lib/Parse/ParseStmt.cpp
>> cfe/trunk/lib/Sema/SemaChecking.cpp
>> cfe/trunk/lib/Sema/SemaStmt.cpp
>> cfe/trunk/test/SemaCXX/warn-empty-body.cpp
>>
>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=318556&r1=318555&r2=318556&view=diff
>> ==
>> --- cfe/trunk/include/clang/Sema/Sema.h (original)
>> +++ cfe/trunk/include/clang/Sema/Sema.h Fri Nov 17 13:33:28 2017
>> @@ -9690,6 +9690,7 @@ public:
>>class ConditionResult {
>>  Decl *ConditionVar;
>>  FullExprArg Condition;
>> +SourceLocation RParenLoc;
>>  bool Invalid;
>>  bool HasKnownValue;
>>  bool KnownValue;
>> @@ -9713,6 +9714,9 @@ public:
>>return std::make_pair(cast_or_null(ConditionVar),
>>  Condition.get());
>>  }
>> +
>> +void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; }
>> +
>>  llvm::Optional getKnownValue() const {
>>if (!HasKnownValue)
>>  return None;
>>
>> Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=318556&r1=318555&r2=318556&view=diff
>> ==
>> --- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
>> +++ cfe/trunk/lib/Parse/ParseStmt.cpp Fri Nov 17 13:33:28 2017
>> @@ -1101,6 +1101,7 @@ bool Parser::ParseParenExprOrCondition(S
>>
>>// Otherwise the condition is valid or the rparen is present.
>>T.consumeClose();
>> +  Cond.setRParenLoc(T.getCloseLocation());
>>
>>// Check for extraneous ')'s to catch things like "if (foo())) {".  We 
>> know
>>// that all callers are looking for a statement after the condition, so 
>> ")"
>>
>> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=318556&r1=318555&r2=318556&view=diff
>> ==
>> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Nov 17 13:33:28 2017
>> @@ -11821,7 +11821,7 @@ static bool ShouldDiagnoseEmptyStmtBody(
>>
>>// Get line numbers of statement and body.
>>bool StmtLineInvalid;
>> -  unsigned StmtLine = SourceMgr.getPresumedLineNumber(StmtLoc,
>> +  unsigned StmtLine = SourceMgr.getSpellingLineNumber(StmtLoc,
>>&StmtLineInvalid);
>>if (StmtLineInvalid)
>>  return false;
>>
>> Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=318556&r1=318555&r2=318556&view=diff
>> ==
>> --- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaStmt.cpp Fri Nov 17 13:33:28 2017
>> @@ -530,8 +530,7 @@ Sema::ActOnIfStmt(SourceLocation IfLoc,
>>if (elseStmt)
>>  DiagnoseEmptyStmtBody(ElseLoc, elseStmt, diag::warn_empty_else_body);
>>else
>> -DiagnoseEmptyStmtBody(CondExpr->getLocEnd(), thenStmt,
>> -  diag::warn_empty_if_body);
>> +DiagnoseEmptyStmtBody(Cond.RParenLoc, thenStmt, 
>> diag::warn_empty_if_body);
>>
>>return BuildIfS

[PATCH] D39114: [XRay][darwin] Initial XRay in Darwin Support

2017-11-20 Thread Kuba (Brecka) Mracek via Phabricator via cfe-commits
kubamracek added a comment.

And we should probably introduce files named `xray_linux.cc` and `xray_mac.cc` 
to contain platform-specific functions.


https://reviews.llvm.org/D39114



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


r318667 - Revert r318456 "Issue -Wempty-body warnings for else blocks"

2017-11-20 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Mon Nov 20 09:48:54 2017
New Revision: 318667

URL: http://llvm.org/viewvc/llvm-project?rev=318667&view=rev
Log:
Revert r318456 "Issue -Wempty-body warnings for else blocks"

This caused warnings also when the if or else comes from macros. There was an
attempt to fix this in r318556, but that introduced new problems and was
reverted. Reverting this too until the whole issue is sorted.

> This looks like it was just an oversight.
>
> Fixes http://llvm.org/pr35319
>
> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@318456 
> 91177308-0d34-0410-b5e6-96231b3b80d8

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/test/SemaCXX/warn-empty-body.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=318667&r1=318666&r2=318667&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Nov 20 09:48:54 
2017
@@ -8094,8 +8094,6 @@ def err_switch_incomplete_class_type : E
 
 def warn_empty_if_body : Warning<
   "if statement has empty body">, InGroup;
-def warn_empty_else_body : Warning<
-  "else clause has empty body">, InGroup;
 def warn_empty_for_body : Warning<
   "for loop has empty body">, InGroup;
 def warn_empty_range_based_for_body : Warning<

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=318667&r1=318666&r2=318667&view=diff
==
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Mon Nov 20 09:48:54 2017
@@ -527,9 +527,7 @@ Sema::ActOnIfStmt(SourceLocation IfLoc,
CondExpr->getExprLoc()))
 CommaVisitor(*this).Visit(CondExpr);
 
-  if (elseStmt)
-DiagnoseEmptyStmtBody(ElseLoc, elseStmt, diag::warn_empty_else_body);
-  else
+  if (!elseStmt)
 DiagnoseEmptyStmtBody(CondExpr->getLocEnd(), thenStmt,
   diag::warn_empty_if_body);
 

Modified: cfe/trunk/test/SemaCXX/warn-empty-body.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-empty-body.cpp?rev=318667&r1=318666&r2=318667&view=diff
==
--- cfe/trunk/test/SemaCXX/warn-empty-body.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-empty-body.cpp Mon Nov 20 09:48:54 2017
@@ -238,26 +238,6 @@ void test6(int x, int y) {
   }
 }
 
-void test_if_else(int x) {
-  if (x); // expected-warning{{if statement has empty body}} 
expected-note{{separate line}}
-
-  if (x)
-; // no-warning
-
-  if (x)
-; // no-warning
-  else
-; // no-warning
-
-  if (x)
-; // no-warning
-  else; // expected-warning{{else clause has empty body}} 
expected-note{{separate line}}
-
-  if (x)
-; // no-warning
-  else EMPTY(x); // no-warning
-}
-
 void test_errors(int x) {
   if (1)
 aa; // expected-error{{use of undeclared identifier}}


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


Re: r318556 - Loosen -Wempty-body warning

2017-11-20 Thread Hans Wennborg via cfe-commits
Reverted the original patch too, in r318667 since I assume that was
breaking Ilya's build.

Hopefully this is easy to fix and they can be re-landed together.

On Mon, Nov 20, 2017 at 9:39 AM, Hans Wennborg  wrote:
> I've reverted in r318665 to get the buildbots green until this is figured out.
>
>
>
> On Sat, Nov 18, 2017 at 11:55 AM, Hans Wennborg  wrote:
>> We're still seeing some in macro-related code. From Chromium:
>>
>> ../../third_party/ffmpeg/libavcodec/bitstream.c(169,5):  error: if
>> statement has empty body [-Werror,-Wempty-body]
>> ff_dlog(NULL, "new table index=%d size=%d\n", table_index, table_size);
>> ^
>> ../../third_party/ffmpeg\libavutil/internal.h(276,80):  note: expanded
>> from macro 'ff_dlog'
>> #   define ff_dlog(ctx, ...) do { if (0) av_log(ctx, AV_LOG_DEBUG,
>> __VA_ARGS__); } while (0)
>>  
>>   ^
>> ../../third_party/ffmpeg/libavcodec/bitstream.c(169,5):  note: put the
>> semicolon on a separate line to silence this warning
>>
>> (See https://build.chromium.org/p/chromium.clang/builders/ToTWin/builds/420)
>>
>> On Fri, Nov 17, 2017 at 1:33 PM, Reid Kleckner via cfe-commits
>>  wrote:
>>> Author: rnk
>>> Date: Fri Nov 17 13:33:28 2017
>>> New Revision: 318556
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=318556&view=rev
>>> Log:
>>> Loosen -Wempty-body warning
>>>
>>> Do not show it when `if` or `else` come from macros.
>>> E.g.,
>>>
>>> #define USED(A) if (A); else
>>> #define SOME_IF(A) if (A)
>>>
>>> void test() {
>>>   // No warnings are shown in those cases now.
>>>   USED(0);
>>>   SOME_IF(0);
>>> }
>>>
>>> Patch by Ilya Biryukov!
>>>
>>> Differential Revision: https://reviews.llvm.org/D40185
>>>
>>> Modified:
>>> cfe/trunk/include/clang/Sema/Sema.h
>>> cfe/trunk/lib/Parse/ParseStmt.cpp
>>> cfe/trunk/lib/Sema/SemaChecking.cpp
>>> cfe/trunk/lib/Sema/SemaStmt.cpp
>>> cfe/trunk/test/SemaCXX/warn-empty-body.cpp
>>>
>>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=318556&r1=318555&r2=318556&view=diff
>>> ==
>>> --- cfe/trunk/include/clang/Sema/Sema.h (original)
>>> +++ cfe/trunk/include/clang/Sema/Sema.h Fri Nov 17 13:33:28 2017
>>> @@ -9690,6 +9690,7 @@ public:
>>>class ConditionResult {
>>>  Decl *ConditionVar;
>>>  FullExprArg Condition;
>>> +SourceLocation RParenLoc;
>>>  bool Invalid;
>>>  bool HasKnownValue;
>>>  bool KnownValue;
>>> @@ -9713,6 +9714,9 @@ public:
>>>return std::make_pair(cast_or_null(ConditionVar),
>>>  Condition.get());
>>>  }
>>> +
>>> +void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; }
>>> +
>>>  llvm::Optional getKnownValue() const {
>>>if (!HasKnownValue)
>>>  return None;
>>>
>>> Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=318556&r1=318555&r2=318556&view=diff
>>> ==
>>> --- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
>>> +++ cfe/trunk/lib/Parse/ParseStmt.cpp Fri Nov 17 13:33:28 2017
>>> @@ -1101,6 +1101,7 @@ bool Parser::ParseParenExprOrCondition(S
>>>
>>>// Otherwise the condition is valid or the rparen is present.
>>>T.consumeClose();
>>> +  Cond.setRParenLoc(T.getCloseLocation());
>>>
>>>// Check for extraneous ')'s to catch things like "if (foo())) {".  We 
>>> know
>>>// that all callers are looking for a statement after the condition, so 
>>> ")"
>>>
>>> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=318556&r1=318555&r2=318556&view=diff
>>> ==
>>> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
>>> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Nov 17 13:33:28 2017
>>> @@ -11821,7 +11821,7 @@ static bool ShouldDiagnoseEmptyStmtBody(
>>>
>>>// Get line numbers of statement and body.
>>>bool StmtLineInvalid;
>>> -  unsigned StmtLine = SourceMgr.getPresumedLineNumber(StmtLoc,
>>> +  unsigned StmtLine = SourceMgr.getSpellingLineNumber(StmtLoc,
>>>&StmtLineInvalid);
>>>if (StmtLineInvalid)
>>>  return false;
>>>
>>> Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=318556&r1=318555&r2=318556&view=diff
>>> ==
>>> --- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
>>> +++ cfe/trunk/lib/Sema/SemaStmt.cpp Fri Nov 17 13:33:28 2017
>>> @@ -530,8 +530,7 @@ Sema::ActOnIfStmt(SourceLocation IfLoc,
>>> 

Re: r318456 - Issue -Wempty-body warnings for else blocks

2017-11-20 Thread Hans Wennborg via cfe-commits
Reverted in r318667.

See coments on the r318556 thread.

On Thu, Nov 16, 2017 at 3:32 PM, Richard Smith via cfe-commits
 wrote:
> This is kicking up false positives on code that does the following:
>
> #define USED(x) if(x);else
> // ...
> assert(x);
> USED(x);
>
> It's a bit of a weird pattern, but it occurs in some open-source code and
> seems easy enough for us to detect (if the semicolon and the preceding token
> aren't from the same FileID, we shouldn't be diagnosing, because they aren't
> actually adjacent).
>
> On 16 November 2017 at 13:26, Reid Kleckner via cfe-commits
>  wrote:
>>
>> Author: rnk
>> Date: Thu Nov 16 13:26:18 2017
>> New Revision: 318456
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=318456&view=rev
>> Log:
>> Issue -Wempty-body warnings for else blocks
>>
>> This looks like it was just an oversight.
>>
>> Fixes http://llvm.org/pr35319
>>
>> Modified:
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/lib/Sema/SemaStmt.cpp
>> cfe/trunk/test/SemaCXX/warn-empty-body.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=318456&r1=318455&r2=318456&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Nov 16
>> 13:26:18 2017
>> @@ -8090,6 +8090,8 @@ def err_switch_incomplete_class_type : E
>>
>>  def warn_empty_if_body : Warning<
>>"if statement has empty body">, InGroup;
>> +def warn_empty_else_body : Warning<
>> +  "else clause has empty body">, InGroup;
>>  def warn_empty_for_body : Warning<
>>"for loop has empty body">, InGroup;
>>  def warn_empty_range_based_for_body : Warning<
>>
>> Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=318456&r1=318455&r2=318456&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaStmt.cpp Thu Nov 16 13:26:18 2017
>> @@ -527,7 +527,9 @@ Sema::ActOnIfStmt(SourceLocation IfLoc,
>> CondExpr->getExprLoc()))
>>  CommaVisitor(*this).Visit(CondExpr);
>>
>> -  if (!elseStmt)
>> +  if (elseStmt)
>> +DiagnoseEmptyStmtBody(ElseLoc, elseStmt, diag::warn_empty_else_body);
>> +  else
>>  DiagnoseEmptyStmtBody(CondExpr->getLocEnd(), thenStmt,
>>diag::warn_empty_if_body);
>>
>>
>> Modified: cfe/trunk/test/SemaCXX/warn-empty-body.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-empty-body.cpp?rev=318456&r1=318455&r2=318456&view=diff
>>
>> ==
>> --- cfe/trunk/test/SemaCXX/warn-empty-body.cpp (original)
>> +++ cfe/trunk/test/SemaCXX/warn-empty-body.cpp Thu Nov 16 13:26:18 2017
>> @@ -238,6 +238,26 @@ void test6(int x, int y) {
>>}
>>  }
>>
>> +void test_if_else(int x) {
>> +  if (x); // expected-warning{{if statement has empty body}}
>> expected-note{{separate line}}
>> +
>> +  if (x)
>> +; // no-warning
>> +
>> +  if (x)
>> +; // no-warning
>> +  else
>> +; // no-warning
>> +
>> +  if (x)
>> +; // no-warning
>> +  else; // expected-warning{{else clause has empty body}}
>> expected-note{{separate line}}
>> +
>> +  if (x)
>> +; // no-warning
>> +  else EMPTY(x); // no-warning
>> +}
>> +
>>  void test_errors(int x) {
>>if (1)
>>  aa; // expected-error{{use of undeclared identifier}}
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r318669 - For Linux/gnu compatibility, preinclude if the file is available

2017-11-20 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon Nov 20 09:57:42 2017
New Revision: 318669

URL: http://llvm.org/viewvc/llvm-project?rev=318669&view=rev
Log:
For Linux/gnu compatibility, preinclude  if the file is available

As reported in llvm bugzilla 32377.
Here’s a patch to add preinclude of stdc-predef.h.

The gcc documentation says “On GNU/Linux,  is pre-included.” 
See https://gcc.gnu.org/gcc-4.8/porting_to.html;

The preinclude is inhibited with –ffreestanding.

Basically I fixed the failing test cases by adding –ffreestanding which inhibits
this behavior.

I fixed all the failing tests, including some in extra/test, there's a separate
patch for that which is linked here

Patch By: mibintc

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

Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Lex/PreprocessorOptions.h
cfe/trunk/lib/Driver/Job.cpp
cfe/trunk/lib/Driver/ToolChains/Linux.cpp
cfe/trunk/lib/Driver/ToolChains/Linux.h
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/Driver/crash-report-header.h
cfe/trunk/test/Driver/crash-report-spaces.c
cfe/trunk/test/Driver/crash-report.c
cfe/trunk/test/Driver/rewrite-map-in-diagnostics.c
cfe/trunk/test/Index/IBOutletCollection.m
cfe/trunk/test/Index/annotate-macro-args.m
cfe/trunk/test/Index/annotate-tokens-pp.c
cfe/trunk/test/Index/annotate-tokens.c
cfe/trunk/test/Index/c-index-getCursor-test.m
cfe/trunk/test/Index/get-cursor-macro-args.m
cfe/trunk/test/Index/get-cursor.cpp
cfe/trunk/test/Preprocessor/ignore-pragmas.c
cfe/trunk/unittests/Tooling/TestVisitor.h

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=318669&r1=318668&r2=318669&view=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Nov 20 09:57:42 2017
@@ -769,6 +769,8 @@ def token_cache : Separate<["-"], "token
   HelpText<"Use specified token cache file">;
 def detailed_preprocessing_record : Flag<["-"], 
"detailed-preprocessing-record">,
   HelpText<"include a detailed record of preprocessing actions">;
+def fsystem_include_if_exists : Separate<["-"], "fsystem-include-if-exists">, 
MetaVarName<"">,
+  HelpText<"Include system file before parsing if file exists">;
 
 
//===--===//
 // OpenCL Options

Modified: cfe/trunk/include/clang/Lex/PreprocessorOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PreprocessorOptions.h?rev=318669&r1=318668&r2=318669&view=diff
==
--- cfe/trunk/include/clang/Lex/PreprocessorOptions.h (original)
+++ cfe/trunk/include/clang/Lex/PreprocessorOptions.h Mon Nov 20 09:57:42 2017
@@ -60,6 +60,9 @@ public:
   /// \brief Headers that will be converted to chained PCHs in memory.
   std::vector ChainedIncludes;
 
+  /// \brief System Headers that are pre-included if they exist.
+  std::vector FSystemIncludeIfExists;
+
   /// \brief When true, disables most of the normal validation performed on
   /// precompiled headers.
   bool DisablePCHValidation;
@@ -190,6 +193,7 @@ public:
 DumpDeserializedPCHDecls = false;
 ImplicitPCHInclude.clear();
 ImplicitPTHInclude.clear();
+FSystemIncludeIfExists.clear();
 TokenCache.clear();
 SingleFileParseMode = false;
 LexEditorPlaceholders = true;

Modified: cfe/trunk/lib/Driver/Job.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Job.cpp?rev=318669&r1=318668&r2=318669&view=diff
==
--- cfe/trunk/lib/Driver/Job.cpp (original)
+++ cfe/trunk/lib/Driver/Job.cpp Mon Nov 20 09:57:42 2017
@@ -64,7 +64,7 @@ static bool skipArgs(const char *Flag, b
 .Cases("-internal-externc-isystem", "-iprefix", true)
 .Cases("-iwithprefixbefore", "-isystem", "-iquote", true)
 .Cases("-isysroot", "-I", "-F", "-resource-dir", true)
-.Cases("-iframework", "-include-pch", true)
+.Cases("-iframework", "-include-pch", "-fsystem-include-if-exists", true)
 .Default(false);
   if (IsInclude)
 return HaveCrashVFS ? false : true;

Modified: cfe/trunk/lib/Driver/ToolChains/Linux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Linux.cpp?rev=318669&r1=318668&r2=318669&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Linux.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp Mon Nov 20 09:57:42 2017
@@ -710,6 +710,8 @@ void Linux::AddClangSystemIncludeArgs(co
   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/include");
 
   addExternCSystemInclude(Driver

[clang-tools-extra] r318668 - extra test modifications for D34158

2017-11-20 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon Nov 20 09:57:20 2017
New Revision: 318668

URL: http://llvm.org/viewvc/llvm-project?rev=318668&view=rev
Log:
extra test modifications for D34158

When adding support for D34158 which changes preprocessed output, I needed to 
make tiny test corrections for these. Adding the option -ffreestanding 
suppresses the new behavior, and that's the change I made to fix the tests.

Patch By: mibintc

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


Modified:
clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-general.cpp
clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-opencl.cpp

Modified: clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-general.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-general.cpp?rev=318668&r1=318667&r2=318668&view=diff
==
--- clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-general.cpp (original)
+++ clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-general.cpp Mon Nov 
20 09:57:20 2017
@@ -1,4 +1,4 @@
-// RUN: pp-trace -ignore FileChanged,MacroDefined %s | FileCheck 
--strict-whitespace %s
+// RUN: pp-trace -ignore FileChanged,MacroDefined %s -ffreestanding | 
FileCheck --strict-whitespace %s
 
 #pragma clang diagnostic push
 #pragma clang diagnostic pop

Modified: clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-opencl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-opencl.cpp?rev=318668&r1=318667&r2=318668&view=diff
==
--- clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-opencl.cpp (original)
+++ clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-opencl.cpp Mon Nov 20 
09:57:20 2017
@@ -1,4 +1,4 @@
-// RUN: pp-trace -ignore FileChanged,MacroDefined %s -x cl | FileCheck 
--strict-whitespace %s
+// RUN: pp-trace -ignore FileChanged,MacroDefined %s -ffreestanding -x cl | 
FileCheck --strict-whitespace %s
 
 #pragma OPENCL EXTENSION all : disable
 #pragma OPENCL EXTENSION cl_khr_int64_base_atomics : disable


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


[PATCH] D34624: extra test modifications for D34158

2017-11-20 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318668: extra test modifications for D34158 (authored by 
erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D34624?vs=120584&id=123612#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34624

Files:
  clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-general.cpp
  clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-opencl.cpp


Index: clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-opencl.cpp
===
--- clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-opencl.cpp
+++ clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-opencl.cpp
@@ -1,4 +1,4 @@
-// RUN: pp-trace -ignore FileChanged,MacroDefined %s -x cl | FileCheck 
--strict-whitespace %s
+// RUN: pp-trace -ignore FileChanged,MacroDefined %s -ffreestanding -x cl | 
FileCheck --strict-whitespace %s
 
 #pragma OPENCL EXTENSION all : disable
 #pragma OPENCL EXTENSION cl_khr_int64_base_atomics : disable
Index: clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-general.cpp
===
--- clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-general.cpp
+++ clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-general.cpp
@@ -1,4 +1,4 @@
-// RUN: pp-trace -ignore FileChanged,MacroDefined %s | FileCheck 
--strict-whitespace %s
+// RUN: pp-trace -ignore FileChanged,MacroDefined %s -ffreestanding | 
FileCheck --strict-whitespace %s
 
 #pragma clang diagnostic push
 #pragma clang diagnostic pop


Index: clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-opencl.cpp
===
--- clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-opencl.cpp
+++ clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-opencl.cpp
@@ -1,4 +1,4 @@
-// RUN: pp-trace -ignore FileChanged,MacroDefined %s -x cl | FileCheck --strict-whitespace %s
+// RUN: pp-trace -ignore FileChanged,MacroDefined %s -ffreestanding -x cl | FileCheck --strict-whitespace %s
 
 #pragma OPENCL EXTENSION all : disable
 #pragma OPENCL EXTENSION cl_khr_int64_base_atomics : disable
Index: clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-general.cpp
===
--- clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-general.cpp
+++ clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-general.cpp
@@ -1,4 +1,4 @@
-// RUN: pp-trace -ignore FileChanged,MacroDefined %s | FileCheck --strict-whitespace %s
+// RUN: pp-trace -ignore FileChanged,MacroDefined %s -ffreestanding | FileCheck --strict-whitespace %s
 
 #pragma clang diagnostic push
 #pragma clang diagnostic pop
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34158: For Linux/gnu compatibility, preinclude if the file is available

2017-11-20 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318669: For Linux/gnu compatibility, preinclude 
 if the file is available (authored by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D34158?vs=120581&id=123613#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34158

Files:
  cfe/trunk/include/clang/Driver/CC1Options.td
  cfe/trunk/include/clang/Lex/PreprocessorOptions.h
  cfe/trunk/lib/Driver/Job.cpp
  cfe/trunk/lib/Driver/ToolChains/Linux.cpp
  cfe/trunk/lib/Driver/ToolChains/Linux.h
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/lib/Frontend/InitPreprocessor.cpp
  cfe/trunk/test/Driver/crash-report-header.h
  cfe/trunk/test/Driver/crash-report-spaces.c
  cfe/trunk/test/Driver/crash-report.c
  cfe/trunk/test/Driver/rewrite-map-in-diagnostics.c
  cfe/trunk/test/Index/IBOutletCollection.m
  cfe/trunk/test/Index/annotate-macro-args.m
  cfe/trunk/test/Index/annotate-tokens-pp.c
  cfe/trunk/test/Index/annotate-tokens.c
  cfe/trunk/test/Index/c-index-getCursor-test.m
  cfe/trunk/test/Index/get-cursor-macro-args.m
  cfe/trunk/test/Index/get-cursor.cpp
  cfe/trunk/test/Preprocessor/ignore-pragmas.c
  cfe/trunk/unittests/Tooling/TestVisitor.h

Index: cfe/trunk/unittests/Tooling/TestVisitor.h
===
--- cfe/trunk/unittests/Tooling/TestVisitor.h
+++ cfe/trunk/unittests/Tooling/TestVisitor.h
@@ -52,6 +52,7 @@
   /// \brief Runs the current AST visitor over the given code.
   bool runOver(StringRef Code, Language L = Lang_CXX) {
 std::vector Args;
+Args.push_back("-ffreestanding");
 switch (L) {
   case Lang_C:
 Args.push_back("-x");
Index: cfe/trunk/include/clang/Driver/CC1Options.td
===
--- cfe/trunk/include/clang/Driver/CC1Options.td
+++ cfe/trunk/include/clang/Driver/CC1Options.td
@@ -769,6 +769,8 @@
   HelpText<"Use specified token cache file">;
 def detailed_preprocessing_record : Flag<["-"], "detailed-preprocessing-record">,
   HelpText<"include a detailed record of preprocessing actions">;
+def fsystem_include_if_exists : Separate<["-"], "fsystem-include-if-exists">, MetaVarName<"">,
+  HelpText<"Include system file before parsing if file exists">;
 
 //===--===//
 // OpenCL Options
Index: cfe/trunk/include/clang/Lex/PreprocessorOptions.h
===
--- cfe/trunk/include/clang/Lex/PreprocessorOptions.h
+++ cfe/trunk/include/clang/Lex/PreprocessorOptions.h
@@ -60,6 +60,9 @@
   /// \brief Headers that will be converted to chained PCHs in memory.
   std::vector ChainedIncludes;
 
+  /// \brief System Headers that are pre-included if they exist.
+  std::vector FSystemIncludeIfExists;
+
   /// \brief When true, disables most of the normal validation performed on
   /// precompiled headers.
   bool DisablePCHValidation;
@@ -190,6 +193,7 @@
 DumpDeserializedPCHDecls = false;
 ImplicitPCHInclude.clear();
 ImplicitPTHInclude.clear();
+FSystemIncludeIfExists.clear();
 TokenCache.clear();
 SingleFileParseMode = false;
 LexEditorPlaceholders = true;
Index: cfe/trunk/test/Preprocessor/ignore-pragmas.c
===
--- cfe/trunk/test/Preprocessor/ignore-pragmas.c
+++ cfe/trunk/test/Preprocessor/ignore-pragmas.c
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -E %s -Wall -verify
-// RUN: %clang_cc1 -Eonly %s -Wall -verify
-// RUN: %clang -M -Wall %s -Xclang -verify
-// RUN: %clang -E -frewrite-includes %s -Wall -Xclang -verify
-// RUN: %clang -E -dD -dM %s -Wall -Xclang -verify
+// RUN: %clang_cc1 -E %s -Wall -ffreestanding -verify
+// RUN: %clang_cc1 -Eonly %s -Wall -ffreestanding -verify
+// RUN: %clang -M -Wall -ffreestanding %s -Xclang -verify
+// RUN: %clang -E -frewrite-includes %s -Wall -ffreestanding -Xclang -verify
+// RUN: %clang -E -dD -dM %s -Wall -ffreestanding -Xclang -verify
 // expected-no-diagnostics
 
 #pragma GCC visibility push (default)
Index: cfe/trunk/test/Index/IBOutletCollection.m
===
--- cfe/trunk/test/Index/IBOutletCollection.m
+++ cfe/trunk/test/Index/IBOutletCollection.m
@@ -5,10 +5,10 @@
 }
 @end
 
-// RUN: c-index-test -cursor-at=%s:4:24 %s | FileCheck -check-prefix=CHECK-CURSOR %s
+// RUN: c-index-test -cursor-at=%s:4:24 -ffreestanding %s | FileCheck -check-prefix=CHECK-CURSOR %s
 // CHECK-CURSOR: ObjCClassRef=Test:3:12
 
-// RUN: c-index-test -test-annotate-tokens=%s:4:1:5:1 %s | FileCheck -check-prefix=CHECK-TOK %s
+// RUN: c-index-test -test-annotate-tokens=%s:4:1:5:1 -ffreestanding %s | FileCheck -check-prefix=CHECK-TOK %s
 // CHECK-TOK: Identifier: "IBOutletCollection" [4:3 - 4:21] macro expansion=IBOutletCollection:1:9
 // FIXME: The following token should belong to the macro expansion cursor.
 // CHECK-TOK

[PATCH] D40230: Add -mprefer-vector-width driver option and attribute during CodeGen.

2017-11-20 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 123614.
craig.topper added a comment.

Address comments.

The value of 'none' is intended to cancel out any other option specified. I've 
changed it so that we no longer pass 'none' to llvm and instead suppress the 
attribute.


https://reviews.llvm.org/D40230

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/CGCall.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/attr-mprefer-vector-width.c
  test/Driver/mprefer-vector-width.c

Index: test/Driver/mprefer-vector-width.c
===
--- /dev/null
+++ test/Driver/mprefer-vector-width.c
@@ -0,0 +1,24 @@
+
+ Verify that valid options for the -mprefer-vector-width flag are passed through and invalid options cause an error.
+
+
+ If there are no options, convert to 'all'.
+
+// RUN: %clang -### -S %s -mprefer-vector-width=none  2>&1 | FileCheck --check-prefix=WIDTHNONE %s
+// WIDTHNONE: "-mprefer-vector-width=none"
+
+ Check options that cover all types.
+
+// RUN: %clang -### -S %s -mprefer-vector-width=128  2>&1 | FileCheck --check-prefix=WIDTH128 %s
+// WIDTH128: "-mprefer-vector-width=128"
+
+ Check invalid parameters.
+
+// RUN: %clang -### -S %s -mprefer-vector-width=one  2>&1 | FileCheck --check-prefix=WIDTHONE %s
+// WIDTHONE: invalid value 'one' in 'mprefer-vector-width='
+
+// RUN: %clang -### -S %s -mprefer-vector-width=128.5  2>&1 | FileCheck --check-prefix=WIDTH128p5 %s
+// WIDTH128p5: invalue value '128.5' in 'mprefer-vector-width='
+
+// RUN: %clang -### -S %s -mprefer-vector-width=-128  2>&1 | FileCheck --check-prefix=WIDTHNEG128 %s
+// WIDTHNEG128: invalid value '-128' in 'mprefer-vector-width='
Index: test/CodeGen/attr-mprefer-vector-width.c
===
--- /dev/null
+++ test/CodeGen/attr-mprefer-vector-width.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -mprefer-vector-width=128 -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK128
+// RUN: %clang_cc1 -mprefer-vector-width=256 -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK256
+// RUN: %clang_cc1 -mprefer-vector-width=none -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECKNONE
+
+int baz(int a) { return 4; }
+
+// CHECK128: baz{{.*}} #0
+// CHECK128: #0 = {{.*}}"prefer-vector-width"="128"
+
+// CHECK256: baz{{.*}} #0
+// CHECK256: #0 = {{.*}}"prefer-vector-width"="256"
+
+// CHECKNONE: baz{{.*}} #0
+// CHECKNONE-NOT: #0 = {{.*}}"prefer-vector-width"="none"
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -713,6 +713,8 @@
   Opts.VectorizeLoop = Args.hasArg(OPT_vectorize_loops);
   Opts.VectorizeSLP = Args.hasArg(OPT_vectorize_slp);
 
+  Opts.PreferVectorWidth = Args.getLastArgValue(OPT_mprefer_vector_width_EQ);
+
   Opts.MainFileName = Args.getLastArgValue(OPT_main_file_name);
   Opts.VerifyModule = !Args.hasArg(OPT_disable_llvm_verifier);
 
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -274,6 +274,27 @@
   OutStrings.push_back(Args.MakeArgString(Out));
 }
 
+/// The -mprefer-vector-width option accepts either a positive integer
+/// or the string "none".
+static void ParseMPreferVectorWidth(const Driver &D, const ArgList &Args,
+ArgStringList &CmdArgs) {
+  Arg *A = Args.getLastArg(options::OPT_mprefer_vector_width_EQ);
+  if (!A)
+return;
+
+  StringRef Value = A->getValue();
+  if (Value == "none") {
+CmdArgs.push_back("-mprefer-vector-width=none");
+  } else {
+unsigned Width;
+if (Value.getAsInteger(10, Width)) {
+  D.Diag(diag::err_drv_invalid_value) << A->getOption().getName() << Value;
+  return;
+}
+CmdArgs.push_back(Args.MakeArgString("-mprefer-vector-width=" + Value));
+  }
+}
+
 static void getWebAssemblyTargetFeatures(const ArgList &Args,
  std::vector &Features) {
   handleTargetFeaturesGroup(Args, Features, options::OPT_m_wasm_Features_Group);
@@ -4306,6 +4327,8 @@
options::OPT_fno_slp_vectorize, EnableSLPVec))
 CmdArgs.push_back("-vectorize-slp");
 
+  ParseMPreferVectorWidth(D, Args, CmdArgs);
+
   if (Arg *A = Args.getLastArg(options::OPT_fshow_overloads_EQ))
 A->render(Args, CmdArgs);
 
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1744,6 +1744,11 @@
   FuncAttrs.addAttribute("reciprocal-estimates",
  llvm::join(Recips, ","));
 
+if (!CodeGenOpts.PreferVectorWidth.empty() &&
+CodeGenOpts.PreferVectorWidth !

[clang-tools-extra] r318670 - [clang-tidy] revert hicpp-multiway-paths-covered

2017-11-20 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Mon Nov 20 10:01:35 2017
New Revision: 318670

URL: http://llvm.org/viewvc/llvm-project?rev=318670&view=rev
Log:
[clang-tidy] revert hicpp-multiway-paths-covered

The address sanitizer found a stackoverflow with this patch.
There is no obvious fix. This patch will be reapplied when the problem
is found.

Removed:
clang-tools-extra/trunk/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
clang-tools-extra/trunk/clang-tidy/hicpp/MultiwayPathsCoveredCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-multiway-paths-covered.rst

clang-tools-extra/trunk/test/clang-tidy/hicpp-multiway-paths-covered-else.cpp
clang-tools-extra/trunk/test/clang-tidy/hicpp-multiway-paths-covered.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt?rev=318670&r1=318669&r2=318670&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt Mon Nov 20 10:01:35 
2017
@@ -2,7 +2,6 @@ set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyHICPPModule
   ExceptionBaseclassCheck.cpp
-  MultiwayPathsCoveredCheck.cpp
   NoAssemblerCheck.cpp
   HICPPTidyModule.cpp
   SignedBitwiseCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp?rev=318670&r1=318669&r2=318670&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp Mon Nov 20 
10:01:35 2017
@@ -35,7 +35,6 @@
 #include "../readability/FunctionSizeCheck.h"
 #include "../readability/IdentifierNamingCheck.h"
 #include "ExceptionBaseclassCheck.h"
-#include "MultiwayPathsCoveredCheck.h"
 #include "NoAssemblerCheck.h"
 #include "SignedBitwiseCheck.h"
 
@@ -54,8 +53,6 @@ public:
 "hicpp-exception-baseclass");
 CheckFactories.registerCheck(
 "hicpp-signed-bitwise");
-CheckFactories.registerCheck(
-"hicpp-multiway-paths-covered");
 CheckFactories.registerCheck(
 "hicpp-explicit-conversions");
 CheckFactories.registerCheck(

Removed: clang-tools-extra/trunk/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp?rev=318669&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp 
(removed)
@@ -1,179 +0,0 @@
-//===--- MultiwayPathsCoveredCheck.cpp - 
clang-tidy===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-#include "MultiwayPathsCoveredCheck.h"
-#include "clang/AST/ASTContext.h"
-
-#include 
-
-using namespace clang::ast_matchers;
-
-namespace clang {
-namespace tidy {
-namespace hicpp {
-
-void MultiwayPathsCoveredCheck::storeOptions(
-ClangTidyOptions::OptionMap &Opts) {
-  Options.store(Opts, "WarnOnMissingElse", WarnOnMissingElse);
-}
-
-void MultiwayPathsCoveredCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(
-  stmt(allOf(
-  anyOf(switchStmt(forEachSwitchCase(defaultStmt()))
-.bind("switch-default"),
-switchStmt(unless(hasDescendant(switchCase(
-.bind("degenerate-switch"),
-// This matcher must be the last one of the three
-// 'switchStmt' options.
-// Otherwise the cases 'switch-default' and
-// 'degenerate-switch' are not found correctly.
-switchStmt(forEachSwitchCase(unless(defaultStmt(
-.bind("switch-no-default")),
-  switchStmt(hasCondition(allOf(
-  // Match on switch statements that have either a bit-field or an
-  // integer condition. The ordering in 'anyOf()' is important
-  // because the last condition is the most general.
-  anyOf(ignoringImpCasts(memberExpr(hasDeclaration(
-fieldDecl(isBitField()).bind("bitfield",
-hasDescendant

r318672 - [Docs] Regenerate the command line option reference.

2017-11-20 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Mon Nov 20 10:07:43 2017
New Revision: 318672

URL: http://llvm.org/viewvc/llvm-project?rev=318672&view=rev
Log:
[Docs] Regenerate the command line option reference.

Modified:
cfe/trunk/docs/ClangCommandLineReference.rst

Modified: cfe/trunk/docs/ClangCommandLineReference.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangCommandLineReference.rst?rev=318672&r1=318671&r2=318672&view=diff
==
--- cfe/trunk/docs/ClangCommandLineReference.rst (original)
+++ cfe/trunk/docs/ClangCommandLineReference.rst Mon Nov 20 10:07:43 2017
@@ -524,10 +524,10 @@ Serialize compiler diagnostics to a file
 
 .. option:: -shared, --shared
 
-.. option:: -shared-libasan
-
 .. option:: -shared-libgcc
 
+.. option:: -shared-libsan, -shared-libasan
+
 .. option:: -single\_module
 
 .. option:: -specs=, --specs=
@@ -536,6 +536,8 @@ Serialize compiler diagnostics to a file
 
 .. option:: -static-libgcc
 
+.. option:: -static-libsan
+
 .. option:: -static-libstdc++
 
 .. option:: -std-default=
@@ -588,6 +590,8 @@ Verify the binary representation of debu
 
 .. option:: --version
 
+Print version information
+
 .. option:: -w, --no-warnings
 
 Suppress all warnings
@@ -702,6 +706,10 @@ Print source range spans in numeric form
 
 Enables an experimental new pass manager in LLVM.
 
+.. option:: -ffine-grained-bitfield-accesses, 
-fno-fine-grained-bitfield-accesses
+
+Use separate accesses for bitfields with legal widths and alignments.
+
 .. option:: -finline-functions, -fno-inline-functions
 
 Inline suitable functions
@@ -742,7 +750,7 @@ Enable control flow integrity (CFI) chec
 
 .. option:: -fsanitize-cfi-icall-generalize-pointers
 
-Generalize pointers in function type signatures used for Control Flow 
Integrity (CFI) indirect call checking
+Generalize pointers in CFI indirect call type signature checks
 
 .. option:: -fsanitize-coverage=,..., 
-fno-sanitize-coverage=,...
 
@@ -760,7 +768,7 @@ Enable origins tracking in MemorySanitiz
 
 Enable origins tracking in MemorySanitizer
 
-.. option:: -fsanitize-memory-use-after-dtor
+.. option:: -fsanitize-memory-use-after-dtor, 
-fno-sanitize-memory-use-after-dtor
 
 Enable use-after-destroy detection in MemorySanitizer
 
@@ -1267,6 +1275,10 @@ Print a template comparison tree for dif
 
 Allow '$' in identifiers
 
+.. option:: -fdouble-square-bracket-attributes, 
-fno-double-square-bracket-attributes
+
+Enable '\[\[\]\]' attributes in all C and C++ language modes
+
 .. option:: -fdwarf-directory-asm, -fno-dwarf-directory-asm
 
 .. option:: -felide-constructors, -fno-elide-constructors
@@ -1349,6 +1361,10 @@ Implicitly search the file system for mo
 
 Generate calls to instrument function entry and exit
 
+.. option:: -finstrument-functions-after-inlining
+
+Like -finstrument-functions, but insert the calls after inlining
+
 .. option:: -fintegrated-as, -fno-integrated-as, -integrated-as
 
 Enable the integrated assembler
@@ -1561,6 +1577,10 @@ Override the default ABI to return all s
 
 .. option:: -fpie, -fno-pie
 
+.. option:: -fplt, -fno-plt
+
+Use the PLT to make function calls
+
 .. option:: -fplugin=
 
 Load the named plugin (dynamic shared object)
@@ -2166,6 +2186,10 @@ Generate code which only uses the genera
 
 AMDGPU
 --
+.. option:: -mxnack, -mno-xnack
+
+Enable XNACK (AMDGPU only)
+
 ARM
 ---
 .. option:: -ffixed-r9
@@ -2196,12 +2220,20 @@ Disallow use of CRC instructions (ARM on
 
 Disallow generation of deprecated IT blocks for ARMv8. It is on by default for 
ARMv8 Thumb mode.
 
+.. option:: -mtp=
+
+Read thread pointer from coprocessor register (ARM only)
+
 .. option:: -munaligned-access, -mno-unaligned-access
 
 Allow memory accesses to be unaligned (AArch32/AArch64 only)
 
 Hexagon
 ---
+.. option:: -mieee-rnd-near
+
+Hexagon
+---
 .. option:: -mhvx, -mno-hvx
 
 Enable Hexagon Vector eXtensions
@@ -2210,7 +2242,15 @@ Enable Hexagon Vector eXtensions
 
 Enable Hexagon Double Vector eXtensions
 
-.. option:: -mieee-rnd-near
+.. option:: -mhvx-length=
+
+Set Hexagon Vector Length
+
+.. program:: clang1
+.. option:: -mhvx=
+.. program:: clang
+
+Enable Hexagon Vector eXtensions
 
 PowerPC
 ---


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


[PATCH] D40259: [libcxx] LWG2993: reference_wrapper

2017-11-20 Thread Agustín Bergé via Phabricator via cfe-commits
K-ballo created this revision.

Implement LWG2993, `reference_wrapper` conversion from `T&&`.

The conversion fail test currently fails to fail (passes), due to 
https://bugs.llvm.org/show_bug.cgi?id=35332. Flagging it `XFAIL` does not seem 
to have any effect.


https://reviews.llvm.org/D40259

Files:
  include/__functional_base
  
test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp
  
test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor.fail.cpp
  
test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor.pass.cpp

Index: test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor.pass.cpp
===
--- /dev/null
+++ test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor.pass.cpp
@@ -0,0 +1,58 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// reference_wrapper
+
+// template  reference_wrapper(U&&);
+
+// XFAIL: c++98, c++03, c++11, c++14, c++17
+
+#include 
+#include 
+
+struct convertible_to_int_ref {
+int val = 0;
+operator int&() { return val; }
+operator int const&() const { return val; }
+};
+
+struct convertible_from_int {
+convertible_from_int(int) {}
+};
+
+void meow(std::reference_wrapper) {}
+void meow(convertible_from_int) {}
+
+int gi;
+std::reference_wrapper purr() { return gi; };
+
+template 
+void
+test(T& t)
+{
+std::reference_wrapper r(t);
+assert(&r.get() == &t);
+}
+
+void f() {}
+
+int main()
+{
+convertible_to_int_ref convi;
+test(convi);
+convertible_to_int_ref const convic;
+test(convic);
+
+{
+meow(0);
+(true) ? purr() : 0;
+}
+}
Index: test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor.fail.cpp
===
--- /dev/null
+++ test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor.fail.cpp
@@ -0,0 +1,30 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// reference_wrapper
+
+// template  reference_wrapper(U&&);
+
+// XFAIL: c++98, c++03, c++11, c++14, c++17
+
+#include 
+#include 
+
+struct convertible_to_float_ref {
+float val = 0;
+operator float const&() const { return val; }
+};
+
+int main()
+{
+convertible_to_float_ref convf;
+std::reference_wrapper r(convf);
+}
Index: test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp
===
--- test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp
+++ test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp
@@ -20,6 +20,12 @@
 {
 };
 
+struct convertible_to_int_ref {
+int val = 0;
+operator int&() { return val; }
+operator int const&() const { return val; }
+};
+
 template 
 void
 test(T& t)
@@ -54,4 +60,11 @@
 test(i);
 const int j = 0;
 test(j);
+
+#if TEST_STD_VER > 17
+convertible_to_int_ref convi;
+test(convi);
+convertible_to_int_ref const convic;
+test(convic);
+#endif
 }
Index: include/__functional_base
===
--- include/__functional_base
+++ include/__functional_base
@@ -371,6 +371,15 @@
 #endif
 };
 
+#if _LIBCPP_STD_VER > 17
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp& __lvref_bind(_Tp& r) _NOEXCEPT { return r; }
+
+template 
+_Tp& __lvref_bind(_Tp&& r) = delete;
+#endif
+
 template 
 class _LIBCPP_TEMPLATE_VIS reference_wrapper
 : public __weak_result_type<_Tp>
@@ -383,11 +392,22 @@
 
 public:
 // construct/copy/destroy
+#if _LIBCPP_STD_VER > 17
+template , reference_wrapper>::value
+>, class = typename __void_t<
+decltype(_VSTD::__lvref_bind<_Tp>(_VSTD::declval<_Up>()))
+>::type>
+_LIBCPP_INLINE_VISIBILITY reference_wrapper(_Up&& __u)
+_NOEXCEPT_(noexcept(_VSTD::__lvref_bind<_Tp>(_VSTD::forward<_Up>(__u
+: __f_(_VSTD::addressof(_VSTD::__lvref_bind<_Tp>(_VSTD::forward<_Up>(__u {}
+#else
 _LIBCPP_INLINE_VISIBILITY reference_wrapper(type& __f) _NOEXCEPT
 : __f_(_VSTD::addressof(__f)) {}
 #ifndef _LIBCPP_CXX03_LANG
 private: reference_wrapper(type&&); public: // = delete; // do not bind to temps
 #endif
+#endif
 
 // access
 _LIBCPP_INLINE_VISIBILITY opera

[PATCH] D40250: [OpenMP] Consistently use cubin extension for nvlink

2017-11-20 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added inline comments.



Comment at: lib/Driver/ToolChains/Cuda.cpp:431
 
-SmallString<256> Name(II.getFilename());
-llvm::sys::path::replace_extension(Name, "cubin");
-
-const char *CubinF =
-C.addTempFile(C.getArgs().MakeArgString(Name));
+const char *CubinF = C.addTempFile(
+C.getArgs().MakeArgString(getToolChain().getInputFilename(II)));

Hahnfeld wrote:
> gtbercea wrote:
> > Hahnfeld wrote:
> > > gtbercea wrote:
> > > > Is this always a cubin?
> > > Probably because the linker always takes object files...
> > Considering that the function may also return an object file can you add an 
> > assert here that getInputFileName(II) returns a cubin in this case?
> Hmm, that's a string. I've never seen asserts that say "this string should 
> contain...". IMO that's what we have tests for
Ok no problem then let's leave it up to the test :)



Comment at: lib/Driver/ToolChains/Cuda.cpp:461
+std::string CudaToolChain::getInputFilename(const InputInfo &Input) const {
+  if (OK != Action::OFK_OpenMP || Input.getType() != types::TY_Object)
+return ToolChain::getInputFilename(Input);

Hahnfeld wrote:
> gtbercea wrote:
> > Hahnfeld wrote:
> > > gtbercea wrote:
> > > > When does this situation occur?
> > > Well, if that condition fires:
> > > 1. For CUDA
> > > 2. For other types. For example, the bundler might need to bundle / 
> > > unbundle assembly files.
> > Can you put this info in a comment just before the if statement?
> I'd say this condition is not the most difficult that I've ever seen, but can 
> do
Thanks!


https://reviews.llvm.org/D40250



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


[PATCH] D40250: [OpenMP] Consistently use cubin extension for nvlink

2017-11-20 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: lib/Driver/ToolChains/Clang.cpp:5341-5344
+if (const auto *OA = dyn_cast(JA.getInputs()[I])) {
+  OA->doOnEachDependence(
+  [&](Action *, const ToolChain *TC, const char *) { CurTC = TC; });
+}

Can we ever have more than one dependence? If not, perhaps add an assert.
Otherwise, can dependencies have different toolchains? 
If so, which one do we really want?






Comment at: lib/Driver/ToolChains/Cuda.cpp:461
+std::string CudaToolChain::getInputFilename(const InputInfo &Input) const {
+  if (OK != Action::OFK_OpenMP || Input.getType() != types::TY_Object)
+return ToolChain::getInputFilename(Input);

Hahnfeld wrote:
> gtbercea wrote:
> > Hahnfeld wrote:
> > > gtbercea wrote:
> > > > When does this situation occur?
> > > Well, if that condition fires:
> > > 1. For CUDA
> > > 2. For other types. For example, the bundler might need to bundle / 
> > > unbundle assembly files.
> > Can you put this info in a comment just before the if statement?
> I'd say this condition is not the most difficult that I've ever seen, but can 
> do
I usually find conditions expressed in positive terms are much easier to 
understand at a glance.
I.e. `if (!(OK == Action::OFK_OpenMP && Input.getType() == types::TY_Object))` 
is, IMO, almost obvious in its meaning, while the condition above required 
conscious effort to understand its purpose.



Comment at: lib/Driver/ToolChains/Cuda.h:144
 
+  virtual std::string getInputFilename(const InputInfo &Input) const override;
+

`virtual` is redundant here.


https://reviews.llvm.org/D40250



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


r318681 - [AutoComplete] Use stronger sort predicate for autocomplete candidates to remove non-deterministic ordering

2017-11-20 Thread Mandeep Singh Grang via cfe-commits
Author: mgrang
Date: Mon Nov 20 10:49:14 2017
New Revision: 318681

URL: http://llvm.org/viewvc/llvm-project?rev=318681&view=rev
Log:
[AutoComplete] Use stronger sort predicate for autocomplete candidates to 
remove non-deterministic ordering

Summary: This fixes the failure in test/Driver/autocomplete.c uncovered by 
D39245.

Reviewers: yamaguchi, teemperor, ruiu

Reviewed By: yamaguchi, ruiu

Subscribers: cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/Driver/Driver.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=318681&r1=318680&r2=318681&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Mon Nov 20 10:49:14 2017
@@ -1198,7 +1198,11 @@ void Driver::handleAutocompletions(Strin
   // case-insensitive sorting for consistency with the -help option
   // which prints out options in the case-insensitive alphabetical order.
   std::sort(SuggestedCompletions.begin(), SuggestedCompletions.end(),
-[](StringRef A, StringRef B) { return A.compare_lower(B) < 0; });
+[](StringRef A, StringRef B) {
+  if (int X = A.compare_lower(B))
+return X < 0;
+  return A.compare(B) > 0;
+});
 
   llvm::outs() << llvm::join(SuggestedCompletions, "\n") << '\n';
 }


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


[PATCH] D40234: [AutoComplete] Use stronger sort predicate for autocomplete candidates to remove non-deterministic ordering

2017-11-20 Thread Mandeep Singh Grang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318681: [AutoComplete] Use stronger sort predicate for 
autocomplete candidates to… (authored by mgrang).

Changed prior to commit:
  https://reviews.llvm.org/D40234?vs=123546&id=123623#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40234

Files:
  cfe/trunk/lib/Driver/Driver.cpp


Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -1198,7 +1198,11 @@
   // case-insensitive sorting for consistency with the -help option
   // which prints out options in the case-insensitive alphabetical order.
   std::sort(SuggestedCompletions.begin(), SuggestedCompletions.end(),
-[](StringRef A, StringRef B) { return A.compare_lower(B) < 0; });
+[](StringRef A, StringRef B) {
+  if (int X = A.compare_lower(B))
+return X < 0;
+  return A.compare(B) > 0;
+});
 
   llvm::outs() << llvm::join(SuggestedCompletions, "\n") << '\n';
 }


Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -1198,7 +1198,11 @@
   // case-insensitive sorting for consistency with the -help option
   // which prints out options in the case-insensitive alphabetical order.
   std::sort(SuggestedCompletions.begin(), SuggestedCompletions.end(),
-[](StringRef A, StringRef B) { return A.compare_lower(B) < 0; });
+[](StringRef A, StringRef B) {
+  if (int X = A.compare_lower(B))
+return X < 0;
+  return A.compare(B) > 0;
+});
 
   llvm::outs() << llvm::join(SuggestedCompletions, "\n") << '\n';
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39947: [OpenMP] Stable sort Privates to remove non-deterministic ordering

2017-11-20 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

Ping for reviews please.


Repository:
  rL LLVM

https://reviews.llvm.org/D39947



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


Re: [PATCH] Ensure std::getline always 0-terminates string.

2017-11-20 Thread Volodymyr Sapsai via cfe-commits
On Nov 19, 2017, at 08:07, Reimar Döffinger  wrote:
> 
> On Wed, Nov 15, 2017 at 11:35:56AM -0800, Volodymyr Sapsai wrote:
>> On Nov 12, 2017, at 12:37, Reimar Döffinger  wrote:
>> libc++ can be built with exceptions enabled or disabled (see 
>> LIBCXX_ENABLE_EXCEPTIONS 
>> )
>>  and we need to support both configurations. The problem with your 
>> _LIBCPP_NO_EXCEPTIONS approach is that it won't work when exceptions are 
>> disabled. Various exception-related tests are usually guarded with 
>> TEST_HAS_NO_EXCEPTIONS macro defined in “test_macros.h”. You can check other 
>> tests for examples of TEST_HAS_NO_EXCEPTIONS usage, I had in mind something 
>> like
>> 
>> #ifndef TEST_HAS_NO_EXCEPTIONS
>>{
>>testbuf sb(" ");
>>std::istream is(&sb);
>>char s[5] = "test";
>>is.exceptions(std::istream::eofbit | std::istream::badbit);
>>try
>>{
>>is.getline(s, 5);
>>assert(false);
> 
> That doesn't make sense to me, the whole point is to test the
> code-path in getline that swallows the exception.
> So if you meant for that assert to be there, you're
> not trying to test what I am trying to test.
> Note that the intent is not to ensure 0-termination
> when getline actually exits via an exception, I doubt
> that would be safe to do really (except maybe at the start
> of the loop before the code that might trigger an exception,
> but that would cost performance) and anyway code
> handling exceptions can be expected to not make assumptions
> that the result is in a "safe" state.
> The problem is when the code just swallows the exception
> (when exceptions are disabled, presumably for interoperability
> with code compiled with exceptions enabled? There is no documentation
> why getline catches exceptions when they are disabled),
> then I think the only reasonable choice is to 0-terminate,
> even if it is risky.
> Looking at the other tests it seems that generally functionality
> simply isn't tested at all when exceptions are disabled
> (e.g. stoul.pass.cpp), which seems unfortunate.
> That level of testing is easy to achieve here as well,
> just leave out the test file I added.
> If you want it though, I updated it to not fail (though
> not actually test anything either) if exceptions are
> disabled, and added a comment on what a huge hack it is
> (as the code-path for disabled exceptions is tested if and
> only if exceptions are actually enabled).
> <0001-Ensure-std-istream-getline-always-0-terminates-strin.patch>

I got confused here. When you mention "code path for disabled exceptions”, what 
exactly code do you have in mind? Is that

> -if (__n > 0)
> -*__s = char_type();
>  if (__gc_ == 0)
> __err |= ios_base::failbit;
>  this->setstate(__err);
>  }
> +if (__n > 0)
> +*__s = char_type();

or

>  catch (...)
>  {
> +if (__n > 0)
> +*__s = char_type();
>  this->__set_badbit_and_consider_rethrow();
>  }

or maybe something else?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


LLVM buildmaster will be updated and restarted tonight

2017-11-20 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be updated and restarted after 7 PM Pacific time.

Thanks

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


[PATCH] D39947: [OpenMP] Stable sort Privates to remove non-deterministic ordering

2017-11-20 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rL LLVM

https://reviews.llvm.org/D39947



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


[PATCH] D40218: [Clang] Add __builtin_launder

2017-11-20 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 123627.
EricWF added a comment.

- Improve quality of tests.
- Format code.


https://reviews.llvm.org/D40218

Files:
  include/clang/Basic/Builtins.def
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/Sema/SemaChecking.cpp
  test/CodeGen/builtins.c
  test/Preprocessor/feature_tests.c
  test/Sema/builtins.c
  test/SemaCXX/builtins.cpp

Index: test/SemaCXX/builtins.cpp
===
--- test/SemaCXX/builtins.cpp
+++ test/SemaCXX/builtins.cpp
@@ -53,3 +53,52 @@
 void synchronize_args() {
   __sync_synchronize(0); // expected-error {{too many arguments}}
 }
+
+namespace test_launder {
+
+void test_builtin_launder(char *p, void *vp, const volatile int *ip, const float *&fp,
+  double *__restrict dp) {
+  int x;
+  __builtin_launder(x); // expected-error {{non-pointer argument to '__builtin_launder'}}
+#define TEST_TYPE(Ptr, Type) \
+  static_assert(__is_same(decltype(__builtin_launder(Ptr)), Type), "expected same type")
+  TEST_TYPE(p, char*);
+  TEST_TYPE(vp, void*);
+  TEST_TYPE(ip, const volatile int*);
+  TEST_TYPE(fp, const float*);
+  TEST_TYPE(dp, double *__restrict);
+#undef TEST_TYPE
+  char *d = __builtin_launder(p);
+  void *vd = __builtin_launder(vp);
+  const volatile int *id = __builtin_launder(ip);
+  int *id2 = __builtin_launder(ip); // expected-error {{cannot initialize a variable of type 'int *' with an rvalue of type 'const volatile int *'}}
+  const float* fd = __builtin_launder(fp);
+}
+
+template 
+constexpr Tp *test_constexpr_launder(Tp *tp) {
+  return __builtin_launder(tp);
+}
+constexpr int const_int = 42;
+constexpr int const_int2 = 101;
+constexpr const int *const_ptr = test_constexpr_launder(&const_int);
+static_assert(&const_int == const_ptr, "");
+static_assert(const_ptr != test_constexpr_launder(&const_int2), "");
+
+void test_non_constexpr() {
+  constexpr int i = 42;// expected-note {{declared here}}
+  constexpr const int *ip = __builtin_launder(&i); // expected-error {{constexpr variable 'ip' must be initialized by a constant expression}}
+  // expected-note@-1 {{pointer to 'i' is not a constant expression}}
+}
+
+constexpr bool test_in_constexpr(const int &i) {
+  return (__builtin_launder(&i) == &i);
+}
+static_assert(test_in_constexpr(const_int), "");
+void f() {
+  constexpr int i = 42;
+  // FIXME: Should this work? Since `&i` doesn't.
+  static_assert(test_in_constexpr(i), "");
+}
+
+} // end namespace test_launder
Index: test/Sema/builtins.c
===
--- test/Sema/builtins.c
+++ test/Sema/builtins.c
@@ -248,3 +248,15 @@
 
 return buf;
 }
+
+void test_builtin_launder(char *p, void *vp, const volatile int *ip, float *restrict fp) {
+  __builtin_launder(); // expected-error {{too few arguments to function call, expected 1, have 0}}
+  __builtin_launder(p, p); // expected-error {{too many arguments to function call, expected 1, have 2}}
+  int x;
+  __builtin_launder(x); // expected-error {{non-pointer argument to '__builtin_launder'}}
+  char *d = __builtin_launder(p);
+  void *vd = __builtin_launder(vp);
+  const volatile int *id = __builtin_launder(ip);
+  int *id2 = __builtin_launder(ip); // expected-warning {{discards qualifiers}}
+  float *fd = __builtin_launder(fp);
+}
Index: test/Preprocessor/feature_tests.c
===
--- test/Preprocessor/feature_tests.c
+++ test/Preprocessor/feature_tests.c
@@ -14,6 +14,7 @@
  !__has_builtin(__builtin_convertvector) || \
  !__has_builtin(__builtin_trap) || \
  !__has_builtin(__c11_atomic_init) || \
+ !__has_builtin(__builtin_launder) || \
  !__has_feature(attribute_analyzer_noreturn) || \
  !__has_feature(attribute_overloadable)
 #error Clang should have these
Index: test/CodeGen/builtins.c
===
--- test/CodeGen/builtins.c
+++ test/CodeGen/builtins.c
@@ -132,6 +132,8 @@
   R(extract_return_addr, (&N));
   P(signbit, (1.0));
 
+  R(launder, (&N));
+
   return 0;
 }
 
@@ -396,6 +398,20 @@
   return __builtin_readcyclecounter();
 }
 
+// CHECK-LABEL: define void @test_builtin_launder
+void test_builtin_launder(int *p) {
+  // CHECK: entry
+  // CHECK-NEXT: %p.addr = alloca i32*
+  // CHECK-NEXT: %d = alloca i32*
+  // CHECK-NEXT: store i32* %p, i32** %p.addr, align 8
+  // CHECK-NEXT: [[TMP:%.*]] = load i32*, i32** %p.addr
+  // CHECK-NEXT: [[TMP1:%.*]] = bitcast i32* [[TMP]] to i8*
+  // CHECK-NEXT: [[TMP2:%.*]] = call i8* @llvm.invariant.group.barrier.p0i8(i8* [[TMP1]])
+  // CHECK-NEXT: [[TMP3:%.*]] = bitcast i8* [[TMP2]] to i32*
+  // CHECK-NEXT: store i32* [[TMP3]], i32** %d
+  int *d = __builtin_launder(p);
+}
+
 // Behavior of __builtin_os_log differs between platforms, so only test on X86
 #ifdef __x86_64__
 
Index: lib/Sem

Re: [PATCH] Ensure std::getline always 0-terminates string.

2017-11-20 Thread Reimar Döffinger via cfe-commits
On Mon, Nov 20, 2017 at 11:02:13AM -0800, Volodymyr Sapsai wrote:
> >  catch (...)
> >  {
> > +if (__n > 0)
> > +*__s = char_type();
> >  this->__set_badbit_and_consider_rethrow();
> >  }
> 
> or maybe something else?

That one (note that the __set_badbit_and_consider_rethrow
will never re-throw in this case).
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40259: [libcxx] LWG2993: reference_wrapper

2017-11-20 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF requested changes to this revision.
EricWF added a comment.
This revision now requires changes to proceed.

I would much rather take this change in all dialects except for C++03.




Comment at: include/__functional_base:398
+!is_same<__uncvref_t<_Up>, reference_wrapper>::value
+>, class = typename __void_t<
+decltype(_VSTD::__lvref_bind<_Tp>(_VSTD::declval<_Up>()))

The `__void_t` isn't necessary here. Plus I think we can be clever and write 
this condition as:

```
bool _IsNoexcept = noexcept()
```

And then we can re-use `_Noexcept` to make the function conditionally 
`noexcept` instead of duplicating the expression.


https://reviews.llvm.org/D40259



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


[PATCH] D40259: [libcxx] LWG2993: reference_wrapper

2017-11-20 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

Also, you're lacking tests for `noexcept` and the deduction guide.


https://reviews.llvm.org/D40259



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


[PATCH] D35470: [libcxx] Implement std::to_address for C++20

2017-11-20 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: test/std/utilities/memory/pointer.conversion/to_address.pass.cpp:119
+ASSERT_NOEXCEPT(std::to_address(p4));
+assert(std::to_address(p4) == &i);
+}

Shouldn't one of these tests hit a non-noexcept function?


https://reviews.llvm.org/D35470



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


[PATCH] D40261: Add default argument AST matcher

2017-11-20 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett created this revision.
Herald added a subscriber: klimek.

Adds AST matcher for declarations with default arguments.


https://reviews.llvm.org/D40261

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp


Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1991,5 +1991,12 @@
   namedDecl(hasExternalFormalLinkage(;
 }
 
+TEST(HasDefaultArgument, Basic) {
+  EXPECT_TRUE(matches("void x(int val = 0) {};", 
+  parmVarDecl(hasDefaultArgument(;
+  EXPECT_TRUE(notMatches("void x(int val) {};",
+  parmVarDecl(hasDefaultArgument(;
+}
+
 } // namespace ast_matchers
 } // namespace clang
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -5818,6 +5818,17 @@
   return Node.hasExternalFormalLinkage();
 }
 
+/// \brief Matches a declaration that has default arguments.
+///
+/// Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
+/// \code
+/// void x(int val) {};
+/// void y(int val = 0) {};
+/// \endcode
+AST_MATCHER(ParmVarDecl, hasDefaultArgument) { 
+  return Node.hasDefaultArg(); 
+}
+
 } // namespace ast_matchers
 } // namespace clang
 
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -3183,6 +3183,15 @@
 
 
 
+MatcherParmVarDecl>hasDefaultArgument
+Matches a 
declaration that has default arguments.
+
+Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
+void x(int val) {};
+void y(int val = 0) {};
+
+
+
 MatcherQualType>asStringstd::string Name
 Matches if the matched 
type is represented by the given string.
 


Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1991,5 +1991,12 @@
   namedDecl(hasExternalFormalLinkage(;
 }
 
+TEST(HasDefaultArgument, Basic) {
+  EXPECT_TRUE(matches("void x(int val = 0) {};", 
+  parmVarDecl(hasDefaultArgument(;
+  EXPECT_TRUE(notMatches("void x(int val) {};",
+  parmVarDecl(hasDefaultArgument(;
+}
+
 } // namespace ast_matchers
 } // namespace clang
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -5818,6 +5818,17 @@
   return Node.hasExternalFormalLinkage();
 }
 
+/// \brief Matches a declaration that has default arguments.
+///
+/// Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
+/// \code
+/// void x(int val) {};
+/// void y(int val = 0) {};
+/// \endcode
+AST_MATCHER(ParmVarDecl, hasDefaultArgument) { 
+  return Node.hasDefaultArg(); 
+}
+
 } // namespace ast_matchers
 } // namespace clang
 
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -3183,6 +3183,15 @@
 
 
 
+MatcherParmVarDecl>hasDefaultArgument
+Matches a declaration that has default arguments.
+
+Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
+void x(int val) {};
+void y(int val = 0) {};
+
+
+
 MatcherQualType>asStringstd::string Name
 Matches if the matched type is represented by the given string.
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40181: [libcxx] Allow to set locale on Windows.

2017-11-20 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

This LGTM. I would love if another party interested in Windows could review it 
though.


https://reviews.llvm.org/D40181



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


[PATCH] D40259: [libcxx] LWG2993: reference_wrapper

2017-11-20 Thread Tim Song via Phabricator via cfe-commits
tcanens added inline comments.



Comment at: include/__functional_base:377
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp& __lvref_bind(_Tp& r) _NOEXCEPT { return r; }
+

I'd make these member functions of a class template, to avoid having to reason 
about partial ordering in overload resolution.


https://reviews.llvm.org/D40259



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


[PATCH] D40181: [libcxx] Allow to set locale on Windows.

2017-11-20 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In https://reviews.llvm.org/D40181#930602, @EricWF wrote:

> This LGTM. I would love if another party interested in Windows could review 
> it though.


I can test this in a MinGW context and see if what it uses happens to be 
available there or not.


https://reviews.llvm.org/D40181



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


[libcxx] r318690 - Fix std::string::data() symbol during library build.

2017-11-20 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Nov 20 12:23:27 2017
New Revision: 318690

URL: http://llvm.org/viewvc/llvm-project?rev=318690&view=rev
Log:
Fix std::string::data() symbol during library build.

The non-const data() member of std::string is only exposed
in C++17 and beyond. However std::string is externally instantiated
and so the member function needs to be exposed to be externally instantiated.

On Linux and OS X this shouldn't cause a problem, because
_LIBCPP_INLINE_VISIBILITY ensures the symbol is always inlined.

However on Windows, the symbol gets marked dllimport, but
there is no definition to import, causing link errors.

Modified:
libcxx/trunk/include/string

Modified: libcxx/trunk/include/string
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=318690&r1=318689&r2=318690&view=diff
==
--- libcxx/trunk/include/string (original)
+++ libcxx/trunk/include/string Mon Nov 20 12:23:27 2017
@@ -1128,7 +1128,7 @@ public:
 const value_type* c_str() const _NOEXCEPT {return data();}
 _LIBCPP_INLINE_VISIBILITY
 const value_type* data() const _NOEXCEPT  {return 
_VSTD::__to_raw_pointer(__get_pointer());}
-#if _LIBCPP_STD_VER > 14
+#if _LIBCPP_STD_VER > 14 || defined(_LIBCPP_BUILDING_LIBRARY)
 _LIBCPP_INLINE_VISIBILITY
 value_type* data() _NOEXCEPT  {return 
_VSTD::__to_raw_pointer(__get_pointer());}
 #endif


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


[PATCH] D29930: Add `__reference_binds_to_temporary` trait for checking safe reference initialization.

2017-11-20 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

@rsmith Ping.


https://reviews.llvm.org/D29930



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


[PATCH] D40261: Add default argument AST matcher

2017-11-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

You should also update lib\ASTMatchers\Dynamic\Registry.cpp to have the new 
matcher (be sure to keep the new matcher alphabetized as well).


https://reviews.llvm.org/D40261



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


[PATCH] D40242: Do not perform the analysis based warning if all warnings are ignored

2017-11-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

You should add a test case that demonstrates code which would otherwise trigger 
an analysis-based warning but doesn't due to disabling all warnings.


https://reviews.llvm.org/D40242



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


[PATCH] D40257: [CMake] Use LIST_SEPARATOR rather than escaping in ExternalProject_Add

2017-11-20 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 123640.

Repository:
  rL LLVM

https://reviews.llvm.org/D40257

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -653,7 +653,7 @@
   foreach(variableName ${variableNames})
 if(variableName MATCHES "^BOOTSTRAP_")
   string(SUBSTRING ${variableName} 10 -1 varName)
-  string(REPLACE ";" "\;" value "${${variableName}}")
+  string(REPLACE ";" "," value "${${variableName}}")
   list(APPEND PASSTHROUGH_VARIABLES
 -D${varName}=${value})
 endif()
@@ -669,7 +669,7 @@
   if("${${variableName}}" STREQUAL "")
 set(value "")
   else()
-string(REPLACE ";" "\;" value ${${variableName}})
+string(REPLACE ";" "," value ${${variableName}})
   endif()
   list(APPEND PASSTHROUGH_VARIABLES
 -D${variableName}=${value})
@@ -697,6 +697,7 @@
 USES_TERMINAL_CONFIGURE 1
 USES_TERMINAL_BUILD 1
 USES_TERMINAL_INSTALL 1
+LIST_SEPARATOR ,
 )
 
   # exclude really-install from main target


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -653,7 +653,7 @@
   foreach(variableName ${variableNames})
 if(variableName MATCHES "^BOOTSTRAP_")
   string(SUBSTRING ${variableName} 10 -1 varName)
-  string(REPLACE ";" "\;" value "${${variableName}}")
+  string(REPLACE ";" "," value "${${variableName}}")
   list(APPEND PASSTHROUGH_VARIABLES
 -D${varName}=${value})
 endif()
@@ -669,7 +669,7 @@
   if("${${variableName}}" STREQUAL "")
 set(value "")
   else()
-string(REPLACE ";" "\;" value ${${variableName}})
+string(REPLACE ";" "," value ${${variableName}})
   endif()
   list(APPEND PASSTHROUGH_VARIABLES
 -D${variableName}=${value})
@@ -697,6 +697,7 @@
 USES_TERMINAL_CONFIGURE 1
 USES_TERMINAL_BUILD 1
 USES_TERMINAL_INSTALL 1
+LIST_SEPARATOR ,
 )
 
   # exclude really-install from main target
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40256: [ARM] disable FPU features when using soft floating point.

2017-11-20 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

-mfpu controls what floating-point/vector instructions the compiler generates.  
-mfloat-abi controls whether floating-point arguments to functions are passed 
in floating-point registers.  These are completely independent, and we need to 
support using both of them together to generate NEON code with a soft-float 
ABI.  (Android is built like this.)


https://reviews.llvm.org/D40256



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


[PATCH] D40144: Implement `std::launder`

2017-11-20 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists updated this revision to Diff 123644.
mclow.lists added a comment.

Made an internal function `__launder` which is not c++17 specific.
Fixed some wording for the standard asserts.


https://reviews.llvm.org/D40144

Files:
  include/__config
  include/new
  
test/std/language.support/support.dynamic/ptr.launder/launder.nodiscard.fail.cpp
  test/std/language.support/support.dynamic/ptr.launder/launder.pass.cpp
  test/std/language.support/support.dynamic/ptr.launder/launder.types.fail.cpp
  www/cxx1z_status.html

Index: www/cxx1z_status.html
===
--- www/cxx1z_status.html
+++ www/cxx1z_status.html
@@ -104,6 +104,7 @@
 	https://wg21.link/p0083r3";>p0083r3LWGSplicing Maps and SetsOulu
 	https://wg21.link/p0084r2";>p0084r2LWGEmplace Return TypeOuluComplete4.0
 	https://wg21.link/p0088r3";>p0088r3LWGVariant: a type-safe union for C++17OuluComplete4.0
+	https://wg21.link/p0137r1";>p0137r1CWGCore Issue 1776: Replacement of class objects containing reference membersOuluComplete6.0
 	https://wg21.link/p0163r0";>p0163r0LWGshared_ptr::weak_typeOuluComplete3.9
 	https://wg21.link/p0174r2";>p0174r2LWGDeprecating Vestigial Library Parts in C++17Oulu
 	https://wg21.link/p0175r1";>p0175r1LWGSynopses for the C libraryOulu
Index: test/std/language.support/support.dynamic/ptr.launder/launder.types.fail.cpp
===
--- test/std/language.support/support.dynamic/ptr.launder/launder.types.fail.cpp
+++ test/std/language.support/support.dynamic/ptr.launder/launder.types.fail.cpp
@@ -0,0 +1,34 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// template  constexpr T* launder(T* p) noexcept;
+// The program is ill-formed if T is a function type or cv void.
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#include 
+#include 
+
+#include "test_macros.h"
+
+void foo() {}
+
+int main ()
+{
+void *p = nullptr;
+(void) std::launder((   void *) nullptr);  // expected-error-re@new:* {{static_assert failed{{.*}} "can't launder cv-void"}}
+(void) std::launder((const  void *) nullptr);  // expected-error-re@new:* {{static_assert failed{{.*}} "can't launder cv-void"}}
+(void) std::launder((  volatile void *) nullptr);  // expected-error-re@new:* {{static_assert failed{{.*}} "can't launder cv-void"}}
+(void) std::launder((const volatile void *) nullptr);  // expected-error-re@new:* {{static_assert failed{{.*}} "can't launder cv-void"}}
+
+(void) std::launder(foo);  // expected-error-re@new:* 1 {{static_assert failed{{.*}} "can't launder functions"}}
+}
Index: test/std/language.support/support.dynamic/ptr.launder/launder.pass.cpp
===
--- test/std/language.support/support.dynamic/ptr.launder/launder.pass.cpp
+++ test/std/language.support/support.dynamic/ptr.launder/launder.pass.cpp
@@ -0,0 +1,35 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// template  constexpr T* launder(T* p) noexcept;
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#include 
+#include 
+
+#include "test_macros.h"
+
+constexpr int gi = 5;
+constexpr float gf = 8.f;
+
+int main() {
+	static_assert(std::launder(&gi) == &gi, "" );
+	static_assert(std::launder(&gf) == &gf, "" );
+
+  	const int *i = &gi;
+  	const float *f = &gf;
+static_assert(std::is_same::value, "");
+static_assert(std::is_same::value, "");
+
+	assert(std::launder(i) == i);
+	assert(std::launder(f) == f);
+}
Index: test/std/language.support/support.dynamic/ptr.launder/launder.nodiscard.fail.cpp
===
--- test/std/language.support/support.dynamic/ptr.launder/launder.nodiscard.fail.cpp
+++ test/std/language.support/support.dynamic/ptr.launder/launder.nodiscard.fail.cpp
@@ -0,0 +1,27 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// template  constexpr T* launder(T* p) noexc

r318694 - Include test files for rL318668

2017-11-20 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon Nov 20 13:15:01 2017
New Revision: 318694

URL: http://llvm.org/viewvc/llvm-project?rev=318694&view=rev
Log:
Include test files for  rL318668

Forgotten when doing my SVN commit.

Added:
cfe/trunk/test/Driver/Inputs/stdc-predef/
cfe/trunk/test/Driver/Inputs/stdc-predef/usr/
cfe/trunk/test/Driver/Inputs/stdc-predef/usr/include/
cfe/trunk/test/Driver/Inputs/stdc-predef/usr/include/stdc-predef.h   (with 
props)
cfe/trunk/test/Driver/stdc-predef.c   (with props)
cfe/trunk/test/Driver/stdc-predef.i

Added: cfe/trunk/test/Driver/Inputs/stdc-predef/usr/include/stdc-predef.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/stdc-predef/usr/include/stdc-predef.h?rev=318694&view=auto
==
--- cfe/trunk/test/Driver/Inputs/stdc-predef/usr/include/stdc-predef.h (added)
+++ cfe/trunk/test/Driver/Inputs/stdc-predef/usr/include/stdc-predef.h Mon Nov 
20 13:15:01 2017
@@ -0,0 +1,12 @@
+#ifndef_STDC_PREDEF_H
+#define_STDC_PREDEF_H  1
+
+#define DUMMY_STDC_PREDEF 1
+
+#endif
+#ifndef_STDC_PREDEF_H
+#define_STDC_PREDEF_H  1
+
+#define DUMMY_STDC_PREDEF 1
+
+#endif

Propchange: cfe/trunk/test/Driver/Inputs/stdc-predef/usr/include/stdc-predef.h
--
svn:eol-style = native

Propchange: cfe/trunk/test/Driver/Inputs/stdc-predef/usr/include/stdc-predef.h
--
svn:keywords = Author Date Id Rev URL

Propchange: cfe/trunk/test/Driver/Inputs/stdc-predef/usr/include/stdc-predef.h
--
svn:mime-type = text/plain

Added: cfe/trunk/test/Driver/stdc-predef.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/stdc-predef.c?rev=318694&view=auto
==
--- cfe/trunk/test/Driver/stdc-predef.c (added)
+++ cfe/trunk/test/Driver/stdc-predef.c Mon Nov 20 13:15:01 2017
@@ -0,0 +1,25 @@
+// Test that clang preincludes stdc-predef.h, if the include file is available
+//
+// RUN: %clang %s -### -c 2>&1 \
+// RUN: --sysroot=%S/Inputs/stdc-predef \
+// RUN: | FileCheck -check-prefix CHECK-PREDEF %s
+// RUN: %clang %s -### -c -ffreestanding 2>&1 \
+// RUN: --sysroot=%S/Inputs/stdc-predef \
+// RUN: | FileCheck --implicit-check-not "stdc-predef.h" %s
+// RUN: %clang %s -c -E 2>&1 \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: | FileCheck --implicit-check-not "stdc-predef.h" %s
+// RUN: %clang -c %s -Xclang -verify -DCHECK_DUMMY=1 \
+// RUN: --sysroot=%S/Inputs/stdc-predef
+// expected-no-diagnostics
+// RUN: %clang -x cpp-output %s -### -c 2>&1 \
+// RUN: --sysroot=%S/Inputs/stdc-predef \
+// RUN: | FileCheck --implicit-check-not "stdc-predef.h" %s
+
+// CHECK-PREDEF: "-fsystem-include-if-exists" "stdc-predef.h"
+int i;
+#if CHECK_DUMMY
+#if !DUMMY_STDC_PREDEF 
+  #error "Expected macro symbol DUMMY_STDC_PREDEF is not defined."
+#endif
+#endif

Propchange: cfe/trunk/test/Driver/stdc-predef.c
--
svn:eol-style = native

Propchange: cfe/trunk/test/Driver/stdc-predef.c
--
svn:keywords = Author Date Id Rev URL

Propchange: cfe/trunk/test/Driver/stdc-predef.c
--
svn:mime-type = text/plain

Added: cfe/trunk/test/Driver/stdc-predef.i
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/stdc-predef.i?rev=318694&view=auto
==
--- cfe/trunk/test/Driver/stdc-predef.i (added)
+++ cfe/trunk/test/Driver/stdc-predef.i Mon Nov 20 13:15:01 2017
@@ -0,0 +1,16 @@
+// The automatic preinclude of stdc-predef.h should not occur if
+// the source filename indicates a preprocessed file.
+//
+// RUN: %clang %s -### -c 2>&1 \
+// RUN: --sysroot=%S/Inputs/stdc-predef \
+// RUN: | FileCheck --implicit-check-not "stdc-predef.h" %s
+
+int i;
+// The automatic preinclude of stdc-predef.h should not occur if
+// the source filename indicates a preprocessed file.
+//
+// RUN: %clang %s -### -c 2>&1 \
+// RUN: --sysroot=%S/Inputs/stdc-predef \
+// RUN: | FileCheck --implicit-check-not "stdc-predef.h" %s
+
+int i;


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


Re: [PATCH] Ensure std::getline always 0-terminates string.

2017-11-20 Thread Volodymyr Sapsai via cfe-commits
On Nov 20, 2017, at 11:32, Reimar Döffinger  wrote:
> 
> On Mon, Nov 20, 2017 at 11:02:13AM -0800, Volodymyr Sapsai wrote:
>>> catch (...)
>>> {
>>> +if (__n > 0)
>>> +*__s = char_type();
>>> this->__set_badbit_and_consider_rethrow();
>>> }
>> 
>> or maybe something else?
> 
> That one (note that the __set_badbit_and_consider_rethrow
> will never re-throw in this case).

But by #define _LIBCPP_NO_EXCEPTIONS 1 you exclude this block at preprocessing 
step

>  #ifndef _LIBCPP_NO_EXCEPTIONS
>  }
>  catch (...)
>  {
> +if (__n > 0)
> +*__s = char_type();
>  this->__set_badbit_and_consider_rethrow();
>  }
>  #endif  // _LIBCPP_NO_EXCEPTIONS

And looks like getline_pointer_size_exception.pass.cpp doesn’t execute this 
code.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40261: Add default argument AST matcher

2017-11-20 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 123646.
juliehockett added a comment.

Updated Registry.cpp to include new matcher.


https://reviews.llvm.org/D40261

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp


Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1991,5 +1991,12 @@
   namedDecl(hasExternalFormalLinkage(;
 }
 
+TEST(HasDefaultArgument, Basic) {
+  EXPECT_TRUE(matches("void x(int val = 0) {};", 
+  parmVarDecl(hasDefaultArgument(;
+  EXPECT_TRUE(notMatches("void x(int val) {};",
+  parmVarDecl(hasDefaultArgument(;
+}
+
 } // namespace ast_matchers
 } // namespace clang
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -248,6 +248,7 @@
   REGISTER_MATCHER(hasDeclaration);
   REGISTER_MATCHER(hasDeclContext);
   REGISTER_MATCHER(hasDeducedType);
+  REGISTER_MATCHER(hasDefaultArgument);
   REGISTER_MATCHER(hasDescendant);
   REGISTER_MATCHER(hasDestinationType);
   REGISTER_MATCHER(hasDynamicExceptionSpec);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -5818,6 +5818,17 @@
   return Node.hasExternalFormalLinkage();
 }
 
+/// \brief Matches a declaration that has default arguments.
+///
+/// Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
+/// \code
+/// void x(int val) {};
+/// void y(int val = 0) {};
+/// \endcode
+AST_MATCHER(ParmVarDecl, hasDefaultArgument) { 
+  return Node.hasDefaultArg(); 
+}
+
 } // namespace ast_matchers
 } // namespace clang
 
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -3183,6 +3183,15 @@
 
 
 
+MatcherParmVarDecl>hasDefaultArgument
+Matches a 
declaration that has default arguments.
+
+Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
+void x(int val) {};
+void y(int val = 0) {};
+
+
+
 MatcherQualType>asStringstd::string Name
 Matches if the matched 
type is represented by the given string.
 


Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1991,5 +1991,12 @@
   namedDecl(hasExternalFormalLinkage(;
 }
 
+TEST(HasDefaultArgument, Basic) {
+  EXPECT_TRUE(matches("void x(int val = 0) {};", 
+  parmVarDecl(hasDefaultArgument(;
+  EXPECT_TRUE(notMatches("void x(int val) {};",
+  parmVarDecl(hasDefaultArgument(;
+}
+
 } // namespace ast_matchers
 } // namespace clang
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -248,6 +248,7 @@
   REGISTER_MATCHER(hasDeclaration);
   REGISTER_MATCHER(hasDeclContext);
   REGISTER_MATCHER(hasDeducedType);
+  REGISTER_MATCHER(hasDefaultArgument);
   REGISTER_MATCHER(hasDescendant);
   REGISTER_MATCHER(hasDestinationType);
   REGISTER_MATCHER(hasDynamicExceptionSpec);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -5818,6 +5818,17 @@
   return Node.hasExternalFormalLinkage();
 }
 
+/// \brief Matches a declaration that has default arguments.
+///
+/// Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
+/// \code
+/// void x(int val) {};
+/// void y(int val = 0) {};
+/// \endcode
+AST_MATCHER(ParmVarDecl, hasDefaultArgument) { 
+  return Node.hasDefaultArg(); 
+}
+
 } // namespace ast_matchers
 } // namespace clang
 
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -3183,6 +3183,15 @@
 
 
 
+MatcherParmVarDecl>hasDefaultArgument
+Matches a declaration that has default arguments.
+
+Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
+void x(int val) {};
+void y(int val = 0) {};
+

  1   2   >