[PATCH] D35454: [c++2a] Add option -std=c++2a to enable support for potential/transitional C++2a features

2017-07-15 Thread Faisal Vali via Phabricator via cfe-commits
faisalv closed this revision.
faisalv marked an inline comment as done.
faisalv added a comment.

Committed here https://reviews.llvm.org/rL308118

Thanks!


https://reviews.llvm.org/D35454



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


r308118 - [c++2a] Add option -std=c++2a to enable support for potential/transitional C++2a features

2017-07-15 Thread Faisal Vali via cfe-commits
Author: faisalv
Date: Sat Jul 15 17:23:04 2017
New Revision: 308118

URL: http://llvm.org/viewvc/llvm-project?rev=308118&view=rev
Log:
[c++2a] Add option -std=c++2a to enable support for potential/transitional 
C++2a features

- as usual C++2a implies all the C++'s that came before it.

Thank you Aaron for the feedback here: https://reviews.llvm.org/D35454 

Modified:
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Frontend/LangStandard.h
cfe/trunk/include/clang/Frontend/LangStandards.def
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/Driver/std.cpp
cfe/trunk/test/Driver/unknown-std.cpp
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=308118&r1=308117&r2=308118&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Sat Jul 15 17:23:04 2017
@@ -90,6 +90,7 @@ LANGOPT(CPlusPlus , 1, 0, "C++")
 LANGOPT(CPlusPlus11   , 1, 0, "C++11")
 LANGOPT(CPlusPlus14   , 1, 0, "C++14")
 LANGOPT(CPlusPlus1z   , 1, 0, "C++1z")
+LANGOPT(CPlusPlus2a   , 1, 0, "C++2a")
 LANGOPT(ObjC1 , 1, 0, "Objective-C 1")
 LANGOPT(ObjC2 , 1, 0, "Objective-C 2")
 BENIGN_LANGOPT(ObjCDefaultSynthProperties , 1, 0,

Modified: cfe/trunk/include/clang/Frontend/LangStandard.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/LangStandard.h?rev=308118&r1=308117&r2=308118&view=diff
==
--- cfe/trunk/include/clang/Frontend/LangStandard.h (original)
+++ cfe/trunk/include/clang/Frontend/LangStandard.h Sat Jul 15 17:23:04 2017
@@ -26,11 +26,12 @@ enum LangFeatures {
   CPlusPlus11 = (1 << 4),
   CPlusPlus14 = (1 << 5),
   CPlusPlus1z = (1 << 6),
-  Digraphs = (1 << 7),
-  GNUMode = (1 << 8),
-  HexFloat = (1 << 9),
-  ImplicitInt = (1 << 10),
-  OpenCL = (1 << 11)
+  CPlusPlus2a = (1 << 7),
+  Digraphs = (1 << 8),
+  GNUMode = (1 << 9),
+  HexFloat = (1 << 10),
+  ImplicitInt = (1 << 11),
+  OpenCL = (1 << 12)
 };
 
 }
@@ -81,6 +82,10 @@ public:
   /// isCPlusPlus1z - Language is a C++17 variant (or later).
   bool isCPlusPlus1z() const { return Flags & frontend::CPlusPlus1z; }
 
+  /// isCPlusPlus2a - Language is a post-C++17 variant (or later).
+  bool isCPlusPlus2a() const { return Flags & frontend::CPlusPlus2a; }
+
+
   /// hasDigraphs - Language supports digraphs.
   bool hasDigraphs() const { return Flags & frontend::Digraphs; }
 

Modified: cfe/trunk/include/clang/Frontend/LangStandards.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/LangStandards.def?rev=308118&r1=308117&r2=308118&view=diff
==
--- cfe/trunk/include/clang/Frontend/LangStandards.def (original)
+++ cfe/trunk/include/clang/Frontend/LangStandards.def Sat Jul 15 17:23:04 2017
@@ -119,6 +119,16 @@ LANGSTANDARD(gnucxx1z, "gnu++1z",
  LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus1z 
|
  Digraphs | HexFloat | GNUMode)
 
+LANGSTANDARD(cxx2a, "c++2a",
+ CXX, "Working draft for ISO C++ 2020",
+ LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus1z 
|
+ CPlusPlus2a | Digraphs | HexFloat)
+
+LANGSTANDARD(gnucxx2a, "gnu++2a",
+ CXX, "Working draft for ISO C++ 2020 with GNU extensions",
+ LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus1z 
|
+ CPlusPlus2a | Digraphs | HexFloat | GNUMode)
+
 // OpenCL
 LANGSTANDARD(opencl10, "cl1.0",
  OpenCL, "OpenCL 1.0",

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=308118&r1=308117&r2=308118&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Sat Jul 15 17:23:04 2017
@@ -1683,6 +1683,7 @@ void CompilerInvocation::setLangDefaults
   Opts.CPlusPlus11 = Std.isCPlusPlus11();
   Opts.CPlusPlus14 = Std.isCPlusPlus14();
   Opts.CPlusPlus1z = Std.isCPlusPlus1z();
+  Opts.CPlusPlus2a = Std.isCPlusPlus2a();
   Opts.Digraphs = Std.hasDigraphs();
   Opts.GNUMode = Std.isGNUMode();
   Opts.GNUInline = !Opts.C99 && !Opts.CPlusPlus;

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=308118&r1=308117&r2=308118&view=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original

[PATCH] D35454: [c++2a] Add option -std=c++2a to enable support for potential/transitional C++2a features

2017-07-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM with a small commenting nit.




Comment at: lib/Frontend/InitPreprocessor.cpp:377
   } else {
+// FIXME: Use correct value for C++20
+if (LangOpts.CPlusPlus2a)

Missing full stop at the end of the comment.


https://reviews.llvm.org/D35454



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


[PATCH] D35449: [X86] Implement __builtin_cpu_is

2017-07-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

I think gcc supports __builtin_cpu_supports and __builtin_cpu_is for non-x86. 
We already have an x86 only implementation of __builtin_cpu_supports so I did 
the same here.


https://reviews.llvm.org/D35449



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


[PATCH] D28954: [analyzer] Add support for symbolic float expressions

2017-07-15 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

This looks like a very solid start!

One area that I'm very worried about is that in various places the analyzer 
makes assumptions about algebraic simplifications that don't hold for floating 
point because of NaN and other floating point oddities. I think it really 
important to write a fairly comprehensive set of tests for these gotchas to 
make sure we're not applying for floating point. We should test for these both 
with and without the Z3 solver.

Here are some examples that should all be UNKNOWN (right?) but are not in the 
current patch, assuming `a` and `b` hold unconstrained symbols of 
floating-point type:

  clang_analyzer_eval(a != 4.0 || a == 4.0);
  clang_analyzer_eval(a < 4.0 || a >= 4.0);
  clang_analyzer_eval((a != b) == !(a == b));
  clang_analyzer_eval((a != 4.0) == !(a == 4.0));






Comment at: include/clang/StaticAnalyzer/Checkers/Checkers.td:150
 
+def FloatingPointMathChecker : Checker<"FPMath">,
+  HelpText<"Check for domain errors in floating-point math functions">,

It is fine to have this in alpha now. What package to do envision this in after 
it is ready? Is this something that should always be on, or should be opted 
into on a per-project basis?



Comment at: lib/StaticAnalyzer/Checkers/FloatingPointMath.cpp:47
+C.emitReport(llvm::make_unique(
+*BT, "Argument value is out of valid domain for function call", N));
+  }

I think it would be a better user experience if the diagnostic could (1) 
mention the function name and (2) tell the programmer what the valid domain is. 
(1) should be easy. Do you think (2) is feasible for floating point?



Comment at: lib/StaticAnalyzer/Checkers/FloatingPointMath.cpp:105
+// Skip if known to be NaN, otherwise assume to be not NaN
+SVal notNaN = SVB.evalBinOp(State, BO_EQ, V, V, SVB.getConditionType());
+if (notNaN.isUnknown() || notNaN.isZeroConstant()) {

Can the checking for not NaN be factored out? It looks there is similar 
checking in multiple places.



Comment at: lib/StaticAnalyzer/Core/BasicValueFactory.cpp:331
+case BO_Div:
+  // Divide by zero
+  if (V1.isFinite() && V2.isInfinity())

Is this comment correct? Is this really a divide by zero?

I'm also a bit surprised APFloat::divide() doesn't handle this case.



Comment at: lib/StaticAnalyzer/Core/BasicValueFactory.cpp:359
+
+  // TODO: Fix sign of special results
+  if (Status & llvm::APFloat::opOverflow)

Could you add a little more context to this TODO? This way if you don't get 
around to it someone can pick it up.



Comment at: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:378
+  return false;
+} else if (const SymExpr *SE = SymVal->getSymbol()) {
+  if (const SymIntExpr *SIE = dyn_cast(SE)) {

LLVM style generally discourages putting an 'else' after a return. 
http://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return Here 
you can just use 'if'.



Comment at: lib/StaticAnalyzer/Core/SValBuilder.cpp:46
+
+  // FIXME: Handle structs.
   return UnknownVal();

Aren't structs already handled by the isRecordType() disjunct above that makes 
a compound value? Can you provide more detail in the FIXME about what needs to 
be fixed?



Comment at: lib/StaticAnalyzer/Core/SValBuilder.cpp:70
+   const llvm::APFloat& rhs, QualType type) {
+  // The Environment ensures we always get a persistent APSInt in
+  // BasicValueFactory, so we don't need to get the APSInt from

Should this say 'APFloat' in the comment?



Comment at: lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp:133
+#ifndef NDEBUG
+assert(BVF.Convert(FromF, From) && "Integer failed to convert to float!");
+assert(BVF.Convert(ToF, To) && "Integer failed to convert to float!");

I guess this is safe, but it seems quite strange to have operations with side 
effects inside an assert(). Can you store the return value from convert in a 
local use and `(void)local;` to suppress the unused variable diagnostic?



Comment at: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:160
+ !castTy->isSignedIntegerOrEnumerationType());
+  // Cannot be represented in destination type, this is undefined behavior
+  if (!BasicValueFactory::Convert(Value, CF->getValue()))

Is this the kind of thing it could eventually be a good idea to issue a 
diagnostic for?



Comment at: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:1092
 
+  assert(!V.isFloat());
+

I'm wondering whether we should rename this method to "getKnownIntValue()" and 
then just return nullptr here. What are the merits of trapping vs. returning 
nullptr here? 


===

Getting Started docs need updating with libcxxabi

2017-07-15 Thread Howard Hinnant via cfe-commits
http://clang.llvm.org/get_started.html

Missing instructions to checkout llvm/projects/libcxxabi (now needed).

Howard



signature.asc
Description: Message signed with OpenPGP
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35454: [c++2a] Add option -std=c++2a to enable support for potential/transitional C++2a features

2017-07-15 Thread Faisal Vali via Phabricator via cfe-commits
faisalv added a comment.

Hmm - good point - not sure about the best way to confirm that...

I'm fairly sure Jason said something during a discussion with me (about the 
additional template syntax to lambdas) in which he referred to gcc as already 
having a "C++2a feature" - and so i just inferred that that's what they were 
calling it ...


https://reviews.llvm.org/D35454



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


[PATCH] D35454: [c++2a] Add option -std=c++2a to enable support for potential/transitional C++2a features

2017-07-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Has GCC picked the same name for their language standard? I want to make sure 
we're consistent there (and think this is the correct name).


https://reviews.llvm.org/D35454



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


[PATCH] D35449: [X86] Implement __builtin_cpu_is

2017-07-15 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

I don't have much experience with this builtin - does gcc use it for anything 
but x86? google didn't turn up much.


https://reviews.llvm.org/D35449



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


[PATCH] D35447: [Bash-autocompletion] Add support for -W and -Wno

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

LGTM




Comment at: clang/lib/Driver/Driver.cpp:1283
+  for (StringRef S : DiagnosticIDs::getDiagnosticFlags())
+if (StringRef(S).startswith(PassedFlags))
+  SuggestedCompletions.push_back(S);

nit: StringRef(S) -> S as S is already a StringRef.


https://reviews.llvm.org/D35447



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


[PATCH] D35447: [Bash-autocompletion] Add support for -W and -Wno

2017-07-15 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

I have a last request in my inline comment regarding the documentation, 
otherwise this is good to go. Nice work!




Comment at: clang/include/clang/Basic/DiagnosticIDs.h:267
 
+  /// \brief Get the string of all diagnostic flags
+  static std::vector getDiagnosticFlags();

Let's add an example to make it clear that we want to have the command line 
flags here, something like this:
```
/// \brief Get the list of all diagnostic flags.
/// \returns A list of all diagnostics flags as they would be written in a 
command line invocation
///  including their `no-` variants. For example: `{"-Wempty-body", 
"-Wno-empty-body", ...}`
```


https://reviews.llvm.org/D35447



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


[PATCH] D34955: [Basic] Detect Git submodule version in CMake

2017-07-15 Thread Brian Gesiak via Phabricator via cfe-commits
modocache added a comment.

Friendly ping! I'm pretty excited about this change, it helps a pet project of 
mine, which builds Clang and LLVM checked out as submodules, display correct 
revision information. Let me know if I can modify this change at all, to make 
it easier to accept.


https://reviews.llvm.org/D34955



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


[PATCH] D34824: clang-format: add an option -verbose to list the files being processed

2017-07-15 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru marked 7 inline comments as done.
sylvestre.ledru added inline comments.



Comment at: test/Format/verbose.cpp:2
+// RUN: clang-format %s -verbose | FileCheck %s
+// CHECK: Formatting
+

djasper wrote:
> This seems like a pretty minimal test to me. Consider adding the filename 
> (with a regex like "Formatting{{.*}}verbose.cpp"). There might be reasons not 
> to do that though.
I changed the structure and added more checks to it.



https://reviews.llvm.org/D34824



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


[PATCH] D34824: clang-format: add an option -verbose to list the files being processed

2017-07-15 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru updated this revision to Diff 106778.

https://reviews.llvm.org/D34824

Files:
  docs/ClangFormat.rst
  docs/ReleaseNotes.rst
  test/Format/verbose.cpp
  tools/clang-format/ClangFormat.cpp


Index: tools/clang-format/ClangFormat.cpp
===
--- tools/clang-format/ClangFormat.cpp
+++ tools/clang-format/ClangFormat.cpp
@@ -102,6 +102,10 @@
  "SortIncludes style flag"),
 cl::cat(ClangFormatCategory));
 
+static cl::opt
+Verbose("verbose", cl::desc("If set, shows the list of processed files"),
+cl::cat(ClangFormatCategory));
+
 static cl::list FileNames(cl::Positional, cl::desc("[ 
...]"),
cl::cat(ClangFormatCategory));
 
@@ -365,23 +369,19 @@
   }
 
   bool Error = false;
-  switch (FileNames.size()) {
-  case 0:
+  if (FileNames.empty()) {
 Error = clang::format::format("-");
-break;
-  case 1:
-Error = clang::format::format(FileNames[0]);
-break;
-  default:
-if (!Offsets.empty() || !Lengths.empty() || !LineRanges.empty()) {
-  errs() << "error: -offset, -length and -lines can only be used for "
-"single file.\n";
-  return 1;
-}
-for (unsigned i = 0; i < FileNames.size(); ++i)
-  Error |= clang::format::format(FileNames[i]);
-break;
+return Error ? 1 : 0;
   }
+  if (!Offsets.empty() || !Lengths.empty() || !LineRanges.empty()) {
+errs() << "error: -offset, -length and -lines can only be used for "
+  "single file.\n";
+return 1;
+  }
+  for (const auto &FileName : FileNames) {
+if (Verbose)
+  errs() << "Formatting " << FileName << "\n";
+Error |= clang::format::format(FileName);
+  }
   return Error ? 1 : 0;
 }
-
Index: test/Format/verbose.cpp
===
--- test/Format/verbose.cpp
+++ test/Format/verbose.cpp
@@ -0,0 +1,8 @@
+// RUN: clang-format %s  2> %t.stderr
+// RUN: not grep "Formatting" %t.stderr
+// RUN: clang-format %s -verbose 2> %t.stderr
+// RUN: grep -E "Formatting (.*)verbose.cpp(.*)" %t.stderr
+// RUN: clang-format %s -verbose=false 2> %t.stderr
+// RUN: not grep "Formatting" %t.stderr
+
+int a;
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -191,6 +191,9 @@
 * Comment reflow support added. Overly long comment lines will now be reflown 
with the rest of
   the paragraph instead of just broken. Option **ReflowComments** added and 
enabled by default.
 
+* Option -verbose added to the command line.
+  Shows the list of processed files.
+
 libclang
 
 
Index: docs/ClangFormat.rst
===
--- docs/ClangFormat.rst
+++ docs/ClangFormat.rst
@@ -71,6 +71,7 @@
 Use -style="{key: value, ...}" to set specific
 parameters, e.g.:
   -style="{BasedOnStyle: llvm, IndentWidth: 8}"
+-verbose  - If set, shows the list of processed files
 
   Generic Options:
 


Index: tools/clang-format/ClangFormat.cpp
===
--- tools/clang-format/ClangFormat.cpp
+++ tools/clang-format/ClangFormat.cpp
@@ -102,6 +102,10 @@
  "SortIncludes style flag"),
 cl::cat(ClangFormatCategory));
 
+static cl::opt
+Verbose("verbose", cl::desc("If set, shows the list of processed files"),
+cl::cat(ClangFormatCategory));
+
 static cl::list FileNames(cl::Positional, cl::desc("[ ...]"),
cl::cat(ClangFormatCategory));
 
@@ -365,23 +369,19 @@
   }
 
   bool Error = false;
-  switch (FileNames.size()) {
-  case 0:
+  if (FileNames.empty()) {
 Error = clang::format::format("-");
-break;
-  case 1:
-Error = clang::format::format(FileNames[0]);
-break;
-  default:
-if (!Offsets.empty() || !Lengths.empty() || !LineRanges.empty()) {
-  errs() << "error: -offset, -length and -lines can only be used for "
-"single file.\n";
-  return 1;
-}
-for (unsigned i = 0; i < FileNames.size(); ++i)
-  Error |= clang::format::format(FileNames[i]);
-break;
+return Error ? 1 : 0;
   }
+  if (!Offsets.empty() || !Lengths.empty() || !LineRanges.empty()) {
+errs() << "error: -offset, -length and -lines can only be used for "
+  "single file.\n";
+return 1;
+  }
+  for (const auto &FileName : FileNames) {
+if (Verbose)
+  errs() << "Formatting " << FileName << "\n";
+Error |= clang::format::format(FileName);
+  }
   return Error ? 1 : 0;
 }
-
Index: test/Format/verbose.cpp
===
--- test/Format/verbose.cpp
+++ test/Format/verbose.cpp
@@ -0,0 +1,8 @@
+// RUN: clang-format %s  2> %t.stderr
+// RUN: not gre

[PATCH] D35454: [c++2a] Add option -std=c++2a to enable support for potential/transitional C++2a features

2017-07-15 Thread Faisal Vali via Phabricator via cfe-commits
faisalv updated this revision to Diff 106777.
faisalv added a comment.

Remove some erroneously included fragments (patches to Sema) of a future 
potential patch.


https://reviews.llvm.org/D35454

Files:
  include/clang/Basic/LangOptions.def
  include/clang/Frontend/LangStandard.h
  include/clang/Frontend/LangStandards.def
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/InitPreprocessor.cpp
  test/Driver/std.cpp
  test/Driver/unknown-std.cpp
  test/Preprocessor/init.c

Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -9,6 +9,15 @@
 // BLOCKS:#define __block __attribute__((__blocks__(byref)))
 //
 //
+// RUN: %clang_cc1 -x c++ -std=c++2a -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX2A %s
+//
+// CXX2A:#define __GNUG__ {{.*}}
+// CXX2A:#define __GXX_EXPERIMENTAL_CXX0X__ 1
+// CXX2A:#define __GXX_RTTI 1
+// CXX2A:#define __GXX_WEAK__ 1
+// CXX2A:#define __cplusplus 201707L
+// CXX2A:#define __private_extern__ extern
+//
 // RUN: %clang_cc1 -x c++ -std=c++1z -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX1Z %s
 //
 // CXX1Z:#define __GNUG__ {{.*}}
@@ -110,7 +119,14 @@
 // RUN: %clang_cc1 -ffreestanding -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix FREESTANDING %s
 // FREESTANDING:#define __STDC_HOSTED__ 0
 //
+// RUN: %clang_cc1 -x c++ -std=gnu++2a -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX2A %s
 //
+// GXX2A:#define __GNUG__ {{.*}}
+// GXX2A:#define __GXX_WEAK__ 1
+// GXX2A:#define __cplusplus 201707L
+// GXX2A:#define __private_extern__ extern
+//
+//
 // RUN: %clang_cc1 -x c++ -std=gnu++1z -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX1Z %s
 //
 // GXX1Z:#define __GNUG__ {{.*}}
Index: test/Driver/unknown-std.cpp
===
--- test/Driver/unknown-std.cpp
+++ test/Driver/unknown-std.cpp
@@ -15,6 +15,8 @@
 // CHECK-NEXT: note: use 'gnu++14' for 'ISO C++ 2014 with amendments and GNU extensions' standard
 // CHECK-NEXT: note: use 'c++1z' for 'Working draft for ISO C++ 2017' standard
 // CHECK-NEXT: note: use 'gnu++1z' for 'Working draft for ISO C++ 2017 with GNU extensions' standard
+// CHECK-NEXT: note: use 'c++2a' for 'Working draft for ISO C++ 2020' standard
+// CHECK-NEXT: note: use 'gnu++2a' for 'Working draft for ISO C++ 2020 with GNU extensions' standard
 // CUDA-NEXT: note: use 'cuda' for 'NVIDIA CUDA(tm)' standard
 
 // Make sure that no other output is present.
Index: test/Driver/std.cpp
===
--- test/Driver/std.cpp
+++ test/Driver/std.cpp
@@ -9,7 +9,10 @@
 // RUN: not %clang -std=gnu++1y %s -fsyntax-only 2>&1 | FileCheck -check-prefix=GNUXX1Y %s
 // RUN: not %clang -std=c++1z %s -fsyntax-only 2>&1 | FileCheck -check-prefix=CXX1Z %s
 // RUN: not %clang -std=gnu++1z %s -fsyntax-only 2>&1 | FileCheck -check-prefix=GNUXX1Z %s
+// RUN: not %clang -std=c++2a %s -fsyntax-only 2>&1 | FileCheck -check-prefix=CXX2A %s
+// RUN: not %clang -std=gnu++2a %s -fsyntax-only 2>&1 | FileCheck -check-prefix=GNUXX2A %s
 
+
 void f(int n) {
   typeof(n)();
   decltype(n)();
@@ -38,3 +41,10 @@
 
 // GNUXX1Z-NOT: undeclared identifier 'typeof'
 // GNUXX1Z-NOT: undeclared identifier 'decltype'
+
+// CXX2A: undeclared identifier 'typeof'
+// CXX2A-NOT: undeclared identifier 'decltype'
+
+// GNUXX2A-NOT: undeclared identifier 'typeof'
+// GNUXX2A-NOT: undeclared identifier 'decltype'
+
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -374,10 +374,13 @@
 else if (!LangOpts.GNUMode && LangOpts.Digraphs)
   Builder.defineMacro("__STDC_VERSION__", "199409L");
   } else {
+// FIXME: Use correct value for C++20
+if (LangOpts.CPlusPlus2a)
+  Builder.defineMacro("__cplusplus", "201707L");
 // C++17 [cpp.predefined]p1:
 //   The name __cplusplus is defined to the value 201703L when compiling a
 //   C++ translation unit.
-if (LangOpts.CPlusPlus1z)
+else if (LangOpts.CPlusPlus1z)
   Builder.defineMacro("__cplusplus", "201703L");
 // C++1y [cpp.predefined]p1:
 //   The name __cplusplus is defined to the value 201402L when compiling a
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1683,6 +1683,7 @@
   Opts.CPlusPlus11 = Std.isCPlusPlus11();
   Opts.CPlusPlus14 = Std.isCPlusPlus14();
   Opts.CPlusPlus1z = Std.isCPlusPlus1z();
+  Opts.CPlusPlus2a = Std.isCPlusPlus2a();
   Opts.Digraphs = Std.hasDigraphs();
   Opts.GNUMode = Std.isGNUMode();
   Opts.GNUInline = !Opts.C99 && !Opts.CPlusPlus;
Index: include/clang/Frontend/LangStandards.def
===

[PATCH] D35454: [c++2a] Add option -std=c++2a to enable support for potential/transitional C++2a features

2017-07-15 Thread Faisal Vali via Phabricator via cfe-commits
faisalv created this revision.
faisalv added a project: clang.

At the optimistic least, I'm hoping to get around to adding support for 
familiar template syntax to lambdas and vaopt to the preprocessor, under it.


Repository:
  rL LLVM

https://reviews.llvm.org/D35454

Files:
  include/clang/Basic/LangOptions.def
  include/clang/Frontend/LangStandard.h
  include/clang/Frontend/LangStandards.def
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/InitPreprocessor.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExpr.cpp
  test/Driver/std.cpp
  test/Driver/unknown-std.cpp
  test/Preprocessor/init.c

Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -9,6 +9,15 @@
 // BLOCKS:#define __block __attribute__((__blocks__(byref)))
 //
 //
+// RUN: %clang_cc1 -x c++ -std=c++2a -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX2A %s
+//
+// CXX2A:#define __GNUG__ {{.*}}
+// CXX2A:#define __GXX_EXPERIMENTAL_CXX0X__ 1
+// CXX2A:#define __GXX_RTTI 1
+// CXX2A:#define __GXX_WEAK__ 1
+// CXX2A:#define __cplusplus 201707L
+// CXX2A:#define __private_extern__ extern
+//
 // RUN: %clang_cc1 -x c++ -std=c++1z -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX1Z %s
 //
 // CXX1Z:#define __GNUG__ {{.*}}
@@ -110,7 +119,14 @@
 // RUN: %clang_cc1 -ffreestanding -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix FREESTANDING %s
 // FREESTANDING:#define __STDC_HOSTED__ 0
 //
+// RUN: %clang_cc1 -x c++ -std=gnu++2a -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX2A %s
 //
+// GXX2A:#define __GNUG__ {{.*}}
+// GXX2A:#define __GXX_WEAK__ 1
+// GXX2A:#define __cplusplus 201707L
+// GXX2A:#define __private_extern__ extern
+//
+//
 // RUN: %clang_cc1 -x c++ -std=gnu++1z -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX1Z %s
 //
 // GXX1Z:#define __GNUG__ {{.*}}
Index: test/Driver/unknown-std.cpp
===
--- test/Driver/unknown-std.cpp
+++ test/Driver/unknown-std.cpp
@@ -15,6 +15,8 @@
 // CHECK-NEXT: note: use 'gnu++14' for 'ISO C++ 2014 with amendments and GNU extensions' standard
 // CHECK-NEXT: note: use 'c++1z' for 'Working draft for ISO C++ 2017' standard
 // CHECK-NEXT: note: use 'gnu++1z' for 'Working draft for ISO C++ 2017 with GNU extensions' standard
+// CHECK-NEXT: note: use 'c++2a' for 'Working draft for ISO C++ 2020' standard
+// CHECK-NEXT: note: use 'gnu++2a' for 'Working draft for ISO C++ 2020 with GNU extensions' standard
 // CUDA-NEXT: note: use 'cuda' for 'NVIDIA CUDA(tm)' standard
 
 // Make sure that no other output is present.
Index: test/Driver/std.cpp
===
--- test/Driver/std.cpp
+++ test/Driver/std.cpp
@@ -9,7 +9,10 @@
 // RUN: not %clang -std=gnu++1y %s -fsyntax-only 2>&1 | FileCheck -check-prefix=GNUXX1Y %s
 // RUN: not %clang -std=c++1z %s -fsyntax-only 2>&1 | FileCheck -check-prefix=CXX1Z %s
 // RUN: not %clang -std=gnu++1z %s -fsyntax-only 2>&1 | FileCheck -check-prefix=GNUXX1Z %s
+// RUN: not %clang -std=c++2a %s -fsyntax-only 2>&1 | FileCheck -check-prefix=CXX2A %s
+// RUN: not %clang -std=gnu++2a %s -fsyntax-only 2>&1 | FileCheck -check-prefix=GNUXX2A %s
 
+
 void f(int n) {
   typeof(n)();
   decltype(n)();
@@ -38,3 +41,10 @@
 
 // GNUXX1Z-NOT: undeclared identifier 'typeof'
 // GNUXX1Z-NOT: undeclared identifier 'decltype'
+
+// CXX2A: undeclared identifier 'typeof'
+// CXX2A-NOT: undeclared identifier 'decltype'
+
+// GNUXX2A-NOT: undeclared identifier 'typeof'
+// GNUXX2A-NOT: undeclared identifier 'decltype'
+
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -4635,8 +4635,7 @@
   // We already type-checked the argument, so we know it works. 
   // Just mark all of the declarations in this potentially-evaluated expression
   // as being "referenced".
-  MarkDeclarationsReferencedInExpr(Param->getDefaultArg(),
-   /*SkipLocalVariables=*/true);
+  MarkDeclarationsReferencedInExpr(Param->getDefaultArg());
   return false;
 }
 
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -101,9 +101,12 @@
   //   Local variables shall not be used in default argument
   //   expressions.
   if (VDecl->isLocalVarDecl())
-return S->Diag(DRE->getLocStart(),
-   diag::err_param_default_argument_references_local)
-  << VDecl->getDeclName() << DefaultArg->getSourceRange();
+if (!VDecl->isStaticLocal() &&
+!(VDecl->isUsableInConstantExpressions(VDecl->getASTContext()) &&
+  VDecl->checkInitIsICE()))
+  return S->Diag(DRE->getLocStart(),
+ diag::err_param_default_argume

[PATCH] D35447: [Bash-autocompletion] Add support for -W and -Wno

2017-07-15 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi updated this revision to Diff 106774.
yamaguchi added a comment.

Fixed indent.


https://reviews.llvm.org/D35447

Files:
  clang/include/clang/Basic/DiagnosticIDs.h
  clang/lib/Basic/DiagnosticIDs.cpp
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/autocomplete.c


Index: clang/test/Driver/autocomplete.c
===
--- clang/test/Driver/autocomplete.c
+++ clang/test/Driver/autocomplete.c
@@ -40,3 +40,7 @@
 // MRELOCMODEL_CLANG-NOT: -mrelocation-model
 // RUN: %clang --autocomplete=#-mrelocation-mode | FileCheck %s 
-check-prefix=MRELOCMODEL_CC1
 // MRELOCMODEL_CC1: -mrelocation-model
+// RUN: %clang --autocomplete=-Wma | FileCheck %s -check-prefix=WARNING
+// WARNING: -Wmacro-redefined -Wmain -Wmain-return-type 
-Wmalformed-warning-check -Wmany-braces-around-scalar-init -Wmax-unsigned-zero
+// RUN: %clang --autocomplete=-Wnoinvalid-pp- | FileCheck %s 
-check-prefix=NOWARNING
+// NOWARNING: -Wnoinvalid-pp-token
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1275,6 +1275,13 @@
   // we were requested to print out all option names that start with 
"-foo".
   // For example, "--autocomplete=-fsyn" is expanded to "-fsyntax-only".
   SuggestedCompletions = Opts->findByPrefix(PassedFlags, DisableFlags);
+
+  // We have to query the -W flags manually as they're not in the OptTable.
+  // TODO: Find a good way to add them to OptTable instead and them remove
+  // this code.
+  for (StringRef S : DiagnosticIDs::getDiagnosticFlags())
+if (StringRef(S).startswith(PassedFlags))
+  SuggestedCompletions.push_back(S);
 } else {
   // If the flag is in the form of "--autocomplete=foo,bar", we were
   // requested to print out all option values for "-foo" that start with
Index: clang/lib/Basic/DiagnosticIDs.cpp
===
--- clang/lib/Basic/DiagnosticIDs.cpp
+++ clang/lib/Basic/DiagnosticIDs.cpp
@@ -510,6 +510,18 @@
   return StringRef();
 }
 
+std::vector DiagnosticIDs::getDiagnosticFlags() {
+  std::vector Res;
+  for (size_t I = 1; DiagGroupNames[I] != '\0';) {
+std::string Diag(DiagGroupNames + I + 1, DiagGroupNames[I]);
+I += DiagGroupNames[I] + 1;
+Res.push_back("-W" + Diag);
+Res.push_back("-Wno" + Diag);
+  }
+
+  return Res;
+}
+
 /// Return \c true if any diagnostics were found in this group, even if they
 /// were filtered out due to having the wrong flavor.
 static bool getDiagnosticsInGroup(diag::Flavor Flavor,
Index: clang/include/clang/Basic/DiagnosticIDs.h
===
--- clang/include/clang/Basic/DiagnosticIDs.h
+++ clang/include/clang/Basic/DiagnosticIDs.h
@@ -18,6 +18,7 @@
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/StringRef.h"
+#include 
 
 namespace clang {
   class DiagnosticsEngine;
@@ -263,6 +264,9 @@
   /// are not SFINAE errors.
   static SFINAEResponse getDiagnosticSFINAEResponse(unsigned DiagID);
 
+  /// \brief Get the string of all diagnostic flags
+  static std::vector getDiagnosticFlags();
+
   /// \brief Get the set of all diagnostic IDs in the group with the given 
name.
   ///
   /// \param[out] Diags - On return, the diagnostics in the group.


Index: clang/test/Driver/autocomplete.c
===
--- clang/test/Driver/autocomplete.c
+++ clang/test/Driver/autocomplete.c
@@ -40,3 +40,7 @@
 // MRELOCMODEL_CLANG-NOT: -mrelocation-model
 // RUN: %clang --autocomplete=#-mrelocation-mode | FileCheck %s -check-prefix=MRELOCMODEL_CC1
 // MRELOCMODEL_CC1: -mrelocation-model
+// RUN: %clang --autocomplete=-Wma | FileCheck %s -check-prefix=WARNING
+// WARNING: -Wmacro-redefined -Wmain -Wmain-return-type -Wmalformed-warning-check -Wmany-braces-around-scalar-init -Wmax-unsigned-zero
+// RUN: %clang --autocomplete=-Wnoinvalid-pp- | FileCheck %s -check-prefix=NOWARNING
+// NOWARNING: -Wnoinvalid-pp-token
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1275,6 +1275,13 @@
   // we were requested to print out all option names that start with "-foo".
   // For example, "--autocomplete=-fsyn" is expanded to "-fsyntax-only".
   SuggestedCompletions = Opts->findByPrefix(PassedFlags, DisableFlags);
+
+  // We have to query the -W flags manually as they're not in the OptTable.
+  // TODO: Find a good way to add them to OptTable instead and them remove
+  // this code.
+  for (StringRef S : DiagnosticIDs::getDiagnosticFlags())
+if (StringRef(S).startswith(PassedFlags))
+  SuggestedCompletions.push_back(S);
 } else {
   // If the flag is in the form of "--autocomplete

r308101 - [cxx_status] Fix typos.

2017-07-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Sat Jul 15 08:51:59 2017
New Revision: 308101

URL: http://llvm.org/viewvc/llvm-project?rev=308101&view=rev
Log:
[cxx_status] Fix typos.

Modified:
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/www/cxx_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_status.html?rev=308101&r1=308100&r2=308101&view=diff
==
--- cfe/trunk/www/cxx_status.html (original)
+++ cfe/trunk/www/cxx_status.html Sat Jul 15 08:51:59 2017
@@ -777,7 +777,7 @@ code. This issue is expected to be recti
 
 C++2a implementation status
 
-Clang does not yet support any of the propose fetures of
+Clang does not yet support any of the proposed features of
 
 the C++ standard following C++17, provisionally named C++2a.
 Note that support for these features may change or be removed without notice,
@@ -797,7 +797,7 @@ as the draft C++2a standard evolves.
 
 
   Default member initializers for bit-fields
-  http://wg21.link/p0683r1";>P00683R1
+  http://wg21.link/p0683r1";>P0683R1
   No
 
 


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


r308099 - [cxx_status] Add approved Toronto WG21 motions.

2017-07-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Sat Jul 15 08:42:36 2017
New Revision: 308099

URL: http://llvm.org/viewvc/llvm-project?rev=308099&view=rev
Log:
[cxx_status] Add approved Toronto WG21 motions.

Modified:
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/www/cxx_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_status.html?rev=308099&r1=308098&r2=308099&view=diff
==
--- cfe/trunk/www/cxx_status.html (original)
+++ cfe/trunk/www/cxx_status.html Sat Jul 15 08:42:36 2017
@@ -2,7 +2,7 @@
 
 
   
-  Clang - C++1z, C++14, C++11 and C++98 Status
+  Clang - C++17, C++14, C++11 and C++98 Status
   
   
   

[libcxx] r308097 - Update issues moved in Toronto

2017-07-15 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Sat Jul 15 08:22:21 2017
New Revision: 308097

URL: http://llvm.org/viewvc/llvm-project?rev=308097&view=rev
Log:
Update issues moved in Toronto

Modified:
libcxx/trunk/www/upcoming_meeting.html

Modified: libcxx/trunk/www/upcoming_meeting.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/upcoming_meeting.html?rev=308097&r1=308096&r2=308097&view=diff
==
--- libcxx/trunk/www/upcoming_meeting.html (original)
+++ libcxx/trunk/www/upcoming_meeting.html Sat Jul 15 08:22:21 2017
@@ -73,7 +73,11 @@
http://wg21.link/LWG2974";>2974Diagnose 
out of bounds 
tuple_element/variant_alternativeToronto
 
Priority 1 
Bugs
-   http://wg21.link/LWG2665";>2665remove_filename() post 
condition is incorrectKonaWe do this already
+   http://wg21.link/LWG2665";>2665remove_filename() post 
condition is incorrectTorontoWe do this already
+
+   Immediate Issues in 
Toronto
+   http://wg21.link/LWG2901";>2901Variants 
cannot properly support allocatorsTorontoWe do this 
already
+   http://wg21.link/LWG2956";>2956filesystem::canonical()
 still defined in terms of absolute(p, 
base)Toronto
 
   
 


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


[PATCH] D35081: [ThinLTO] Allow multiple summary entries.

2017-07-15 Thread Florian Hahn via Phabricator via cfe-commits
fhahn abandoned this revision.
fhahn added a comment.

My understanding is that https://reviews.llvm.org/D35436 prevents the case 
described in this review from happening. Thanks for having a look!


https://reviews.llvm.org/D35081



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


r308092 - Use ARC parsing rules for ns_returns_retained in MRC so that code can

2017-07-15 Thread John McCall via cfe-commits
Author: rjmccall
Date: Sat Jul 15 04:06:46 2017
New Revision: 308092

URL: http://llvm.org/viewvc/llvm-project?rev=308092&view=rev
Log:
Use ARC parsing rules for ns_returns_retained in MRC so that code can
be shared without warnings.  Build AttributedTypes to leave breadcrumbs
for tools like the static analyzer.  Warn about attempting to use the
attribute with incompatible return types.

Added:
cfe/trunk/test/SemaObjC/attr-ns_returns_retained.m
Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/Analysis/retain-release.m
cfe/trunk/test/SemaCXX/attr-x86-no_caller_saved_registers.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=308092&r1=308091&r2=308092&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Sat Jul 15 04:06:46 2017
@@ -3878,6 +3878,7 @@ public:
 attr_sptr,
 attr_uptr,
 attr_nonnull,
+attr_ns_returns_retained,
 attr_nullable,
 attr_null_unspecified,
 attr_objc_kindof,

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=308092&r1=308091&r2=308092&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Sat Jul 15 04:06:46 2017
@@ -8380,6 +8380,8 @@ public:
  unsigned SpellingListIndex, bool isNSConsumed,
  bool isTemplateInstantiation);
 
+  bool checkNSReturnsRetainedReturnType(SourceLocation loc, QualType type);
+
   
//======//
   // C++ Coroutines TS
   //

Modified: cfe/trunk/lib/AST/Type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=308092&r1=308091&r2=308092&view=diff
==
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Sat Jul 15 04:06:46 2017
@@ -3023,6 +3023,7 @@ bool AttributedType::isQualifier() const
   case AttributedType::attr_sptr:
   case AttributedType::attr_uptr:
   case AttributedType::attr_objc_kindof:
+  case AttributedType::attr_ns_returns_retained:
 return false;
   }
   llvm_unreachable("bad attributed type kind");
@@ -3056,6 +3057,7 @@ bool AttributedType::isCallingConv() con
   case attr_objc_inert_unsafe_unretained:
   case attr_noreturn:
   case attr_nonnull:
+  case attr_ns_returns_retained:
   case attr_nullable:
   case attr_null_unspecified:
   case attr_objc_kindof:

Modified: cfe/trunk/lib/AST/TypePrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypePrinter.cpp?rev=308092&r1=308091&r2=308092&view=diff
==
--- cfe/trunk/lib/AST/TypePrinter.cpp (original)
+++ cfe/trunk/lib/AST/TypePrinter.cpp Sat Jul 15 04:06:46 2017
@@ -104,6 +104,7 @@ namespace {
 void printAfter(QualType T, raw_ostream &OS);
 void AppendScope(DeclContext *DC, raw_ostream &OS);
 void printTag(TagDecl *T, raw_ostream &OS);
+void printFunctionAfter(const FunctionType::ExtInfo &Info, raw_ostream 
&OS);
 #define ABSTRACT_TYPE(CLASS, PARENT)
 #define TYPE(CLASS, PARENT) \
 void print##CLASS##Before(const CLASS##Type *T, raw_ostream &OS); \
@@ -685,6 +686,36 @@ void TypePrinter::printFunctionProtoAfte
 
   FunctionType::ExtInfo Info = T->getExtInfo();
 
+  printFunctionAfter(Info, OS);
+
+  if (unsigned quals = T->getTypeQuals()) {
+OS << ' ';
+AppendTypeQualList(OS, quals, Policy.Restrict);
+  }
+
+  switch (T->getRefQualifier()) {
+  case RQ_None:
+break;
+
+  case RQ_LValue:
+OS << " &";
+break;
+
+  case RQ_RValue:
+OS << " &&";
+break;
+  }
+  T->printExceptionSpecification(OS, Policy);
+
+  if (T->hasTrailingReturn()) {
+OS << " -> ";
+print(T->getReturnType(), OS, StringRef());
+  } else
+printAfter(T->getReturnType(), OS);
+}
+
+void TypePrinter::printFunctionAfter(const FunctionType::ExtInfo &Info,
+ raw_ostream &OS) {
   if (!InsideCCAttribute) {
 switch (Info.getCC()) {
 case CC_C:
@@ -747,36 +778,13 @@ void TypePrinter::printFunctionProtoAfte
 
   if (Info.getNoReturn())
 OS << " __attribute__((noreturn))";
+  if (Info.getProducesResult())
+OS << " __attribute__((ns_returns_retained))";
   if (Info.getRegParm())
 OS << " __attribute__((regparm ("
<< Info.getRegParm() << ")))";
   if (Info.getNoCallerSavedRegs())
-OS << "__attribute__((no_caller_saved_registers))";
-
-  if (unsigned quals =

[PATCH] D34937: Suppressing Reference Counting Diagnostics for Functions Containing 'rc_ownership_trusted_implementation' Annotate Attribute

2017-07-15 Thread Malhar Thakkar via Phabricator via cfe-commits
malhar1995 updated this revision to Diff 106765.
malhar1995 added a comment.

Checked for "trusted" annotation on the function declaration corresponding to 
the function definition.


Repository:
  rL LLVM

https://reviews.llvm.org/D34937

Files:
  lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
  test/Analysis/retain-release-inline.m

Index: test/Analysis/retain-release-inline.m
===
--- test/Analysis/retain-release-inline.m
+++ test/Analysis/retain-release-inline.m
@@ -12,7 +12,7 @@
 //
 // It includes the basic definitions for the test cases below.
 //===--===//
-
+#define NULL 0
 typedef unsigned int __darwin_natural_t;
 typedef unsigned long uintptr_t;
 typedef unsigned int uint32_t;
@@ -267,6 +267,10 @@
 
 extern CFStringRef CFStringCreateWithCStringNoCopy(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding, CFAllocatorRef contentsDeallocator);
 
+typedef struct {
+  int ref;
+} isl_basic_map;
+
 //===--===//
 // Test cases.
 //===--===//
@@ -285,6 +289,7 @@
   foo(s);
   bar(s);
 }
+
 void test_neg() {
   NSString *s = [[NSString alloc] init]; // no-warning  
   foo(s);
@@ -294,6 +299,56 @@
   bar(s);
 }
 
+__attribute__((cf_returns_retained)) isl_basic_map *isl_basic_map_cow(__attribute__((cf_consumed)) isl_basic_map *bmap);
+void free(void *);
+
+// As 'isl_basic_map_free' is annotated with 'rc_ownership_trusted_implementation', RetainCountChecker trusts its
+// implementation and doesn't analyze its body. If the annotation 'rc_ownership_trusted_implementation' is removed,
+// a leak warning is raised by RetainCountChecker as the analyzer is unable to detect a decrement in the reference
+// count of 'bmap' along the path in 'isl_basic_map_free' assuming the predicate of the second 'if' branch to be
+// true or assuming both the predicates in the function to be false.
+__attribute__((annotate("rc_ownership_trusted_implementation"))) isl_basic_map *isl_basic_map_free(__attribute__((cf_consumed)) isl_basic_map *bmap) {
+  if (!bmap)
+return NULL;
+
+  if (--bmap->ref > 0)
+return NULL;
+
+  free(bmap);
+  return NULL;
+}
+
+// As 'isl_basic_map_copy' is annotated with 'rc_ownership_trusted_implementation', RetainCountChecker trusts its
+// implementation and doesn't analyze its body. If that annotation is removed, a 'use-after-release' warning might
+// be raised by RetainCountChecker as the pointer which is passed as an argument to this function and the pointer
+// which is returned from the function point to the same memory location.
+__attribute__((annotate("rc_ownership_trusted_implementation"))) __attribute__((cf_returns_retained)) isl_basic_map *isl_basic_map_copy(isl_basic_map *bmap)
+{
+  if (!bmap)
+return NULL;
+
+  bmap->ref++;
+  return bmap;
+}
+
+void test_use_after_release_with_trusted_implementation_annotate_attribute(__attribute__((cf_consumed)) isl_basic_map *bmap) {
+  // After this call, 'bmap' has a +1 reference count.
+  bmap = isl_basic_map_cow(bmap);
+  // After the call to 'isl_basic_map_copy', 'bmap' has a +1 reference count.
+  isl_basic_map *temp = isl_basic_map_cow(isl_basic_map_copy(bmap));
+  // After this call, 'bmap' has a +0 reference count.
+  isl_basic_map *temp2 = isl_basic_map_cow(bmap); // no-warning
+  isl_basic_map_free(temp2);
+  isl_basic_map_free(temp);
+}
+
+void test_leak_with_trusted_implementation_annotate_attribute(__attribute__((cf_consumed)) isl_basic_map *bmap) {
+  // After this call, 'bmap' has a +1 reference count.
+  bmap = isl_basic_map_cow(bmap); // no-warning
+  // After this call, 'bmap' has a +0 reference count.
+  isl_basic_map_free(bmap);
+}
+
 //===--===//
 // Test returning retained and not-retained values.
 //===--===//
Index: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
+++ lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
@@ -1894,6 +1894,16 @@
   return SFC->getAnalysisDeclContext()->isBodyAutosynthesized();
 }
 
+/// Returns true if the function declaration 'FD' contains
+/// 'rc_ownership_trusted_implementation' annotate attribute.
+bool isTrustedReferenceCountImplementation(const FunctionDecl *FD) {
+  for (const auto *Ann : FD->specific_attrs()) {
+if (Ann->getAnnotation() == "rc_ownership_trusted_implementation")
+  return true;
+  }
+  return false;
+}
+
 std::shared_ptr
 CFRefReportVisitor::VisitNode(const ExplodedNode *N, const ExplodedNode *PrevN,
   BugReporterContext &BRC, BugReport &BR) {
@@ -3380,6 +3390,9 @@
 
   // See if it's one 

[PATCH] D35447: [Bash-autocompletion] Add support for -W and -Wno

2017-07-15 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi updated this revision to Diff 106764.
yamaguchi added a comment.

Add code comment.


https://reviews.llvm.org/D35447

Files:
  clang/include/clang/Basic/DiagnosticIDs.h
  clang/lib/Basic/DiagnosticIDs.cpp
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/autocomplete.c


Index: clang/test/Driver/autocomplete.c
===
--- clang/test/Driver/autocomplete.c
+++ clang/test/Driver/autocomplete.c
@@ -40,3 +40,7 @@
 // MRELOCMODEL_CLANG-NOT: -mrelocation-model
 // RUN: %clang --autocomplete=#-mrelocation-mode | FileCheck %s 
-check-prefix=MRELOCMODEL_CC1
 // MRELOCMODEL_CC1: -mrelocation-model
+// RUN: %clang --autocomplete=-Wma | FileCheck %s -check-prefix=WARNING
+// WARNING: -Wmacro-redefined -Wmain -Wmain-return-type 
-Wmalformed-warning-check -Wmany-braces-around-scalar-init -Wmax-unsigned-zero
+// RUN: %clang --autocomplete=-Wnoinvalid-pp- | FileCheck %s 
-check-prefix=NOWARNING
+// NOWARNING: -Wnoinvalid-pp-token
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1275,6 +1275,12 @@
   // we were requested to print out all option names that start with 
"-foo".
   // For example, "--autocomplete=-fsyn" is expanded to "-fsyntax-only".
   SuggestedCompletions = Opts->findByPrefix(PassedFlags, DisableFlags);
+
+  // We have to query the -W flags manually as they're not in the OptTable.
+  // TODO: Find a good way to add them to OptTable instead and them remove 
this code.
+  for (StringRef S : DiagnosticIDs::getDiagnosticFlags())
+if (StringRef(S).startswith(PassedFlags))
+  SuggestedCompletions.push_back(S);
 } else {
   // If the flag is in the form of "--autocomplete=foo,bar", we were
   // requested to print out all option values for "-foo" that start with
Index: clang/lib/Basic/DiagnosticIDs.cpp
===
--- clang/lib/Basic/DiagnosticIDs.cpp
+++ clang/lib/Basic/DiagnosticIDs.cpp
@@ -510,6 +510,18 @@
   return StringRef();
 }
 
+std::vector DiagnosticIDs::getDiagnosticFlags() {
+  std::vector Res;
+  for (size_t I = 1; DiagGroupNames[I] != '\0';) {
+std::string Diag(DiagGroupNames + I + 1, DiagGroupNames[I]);
+I += DiagGroupNames[I] + 1;
+Res.push_back("-W" + Diag);
+Res.push_back("-Wno" + Diag);
+  }
+
+  return Res;
+}
+
 /// Return \c true if any diagnostics were found in this group, even if they
 /// were filtered out due to having the wrong flavor.
 static bool getDiagnosticsInGroup(diag::Flavor Flavor,
Index: clang/include/clang/Basic/DiagnosticIDs.h
===
--- clang/include/clang/Basic/DiagnosticIDs.h
+++ clang/include/clang/Basic/DiagnosticIDs.h
@@ -18,6 +18,7 @@
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/StringRef.h"
+#include 
 
 namespace clang {
   class DiagnosticsEngine;
@@ -263,6 +264,9 @@
   /// are not SFINAE errors.
   static SFINAEResponse getDiagnosticSFINAEResponse(unsigned DiagID);
 
+  /// \brief Get the string of all diagnostic flags
+  static std::vector getDiagnosticFlags();
+
   /// \brief Get the set of all diagnostic IDs in the group with the given 
name.
   ///
   /// \param[out] Diags - On return, the diagnostics in the group.


Index: clang/test/Driver/autocomplete.c
===
--- clang/test/Driver/autocomplete.c
+++ clang/test/Driver/autocomplete.c
@@ -40,3 +40,7 @@
 // MRELOCMODEL_CLANG-NOT: -mrelocation-model
 // RUN: %clang --autocomplete=#-mrelocation-mode | FileCheck %s -check-prefix=MRELOCMODEL_CC1
 // MRELOCMODEL_CC1: -mrelocation-model
+// RUN: %clang --autocomplete=-Wma | FileCheck %s -check-prefix=WARNING
+// WARNING: -Wmacro-redefined -Wmain -Wmain-return-type -Wmalformed-warning-check -Wmany-braces-around-scalar-init -Wmax-unsigned-zero
+// RUN: %clang --autocomplete=-Wnoinvalid-pp- | FileCheck %s -check-prefix=NOWARNING
+// NOWARNING: -Wnoinvalid-pp-token
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1275,6 +1275,12 @@
   // we were requested to print out all option names that start with "-foo".
   // For example, "--autocomplete=-fsyn" is expanded to "-fsyntax-only".
   SuggestedCompletions = Opts->findByPrefix(PassedFlags, DisableFlags);
+
+  // We have to query the -W flags manually as they're not in the OptTable.
+  // TODO: Find a good way to add them to OptTable instead and them remove this code.
+  for (StringRef S : DiagnosticIDs::getDiagnosticFlags())
+if (StringRef(S).startswith(PassedFlags))
+  SuggestedCompletions.push_back(S);
 } else {
   // If the flag is in the form of "--autocomplete=foo,bar", we w

[PATCH] D35447: [Bash-autocompletion] Add support for -W and -Wno

2017-07-15 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi updated this revision to Diff 106763.
yamaguchi added a comment.

Update diff according to Rui and teemperor's comments.


https://reviews.llvm.org/D35447

Files:
  clang/include/clang/Basic/DiagnosticIDs.h
  clang/lib/Basic/DiagnosticIDs.cpp
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/autocomplete.c


Index: clang/test/Driver/autocomplete.c
===
--- clang/test/Driver/autocomplete.c
+++ clang/test/Driver/autocomplete.c
@@ -40,3 +40,7 @@
 // MRELOCMODEL_CLANG-NOT: -mrelocation-model
 // RUN: %clang --autocomplete=#-mrelocation-mode | FileCheck %s 
-check-prefix=MRELOCMODEL_CC1
 // MRELOCMODEL_CC1: -mrelocation-model
+// RUN: %clang --autocomplete=-Wma | FileCheck %s -check-prefix=WARNING
+// WARNING: -Wmacro-redefined -Wmain -Wmain-return-type 
-Wmalformed-warning-check -Wmany-braces-around-scalar-init -Wmax-unsigned-zero
+// RUN: %clang --autocomplete=-Wnoinvalid-pp- | FileCheck %s 
-check-prefix=NOWARNING
+// NOWARNING: -Wnoinvalid-pp-token
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1275,6 +1275,10 @@
   // we were requested to print out all option names that start with 
"-foo".
   // For example, "--autocomplete=-fsyn" is expanded to "-fsyntax-only".
   SuggestedCompletions = Opts->findByPrefix(PassedFlags, DisableFlags);
+
+  for (StringRef S : DiagnosticIDs::getDiagnosticFlags())
+if (StringRef(S).startswith(PassedFlags))
+  SuggestedCompletions.push_back(S);
 } else {
   // If the flag is in the form of "--autocomplete=foo,bar", we were
   // requested to print out all option values for "-foo" that start with
Index: clang/lib/Basic/DiagnosticIDs.cpp
===
--- clang/lib/Basic/DiagnosticIDs.cpp
+++ clang/lib/Basic/DiagnosticIDs.cpp
@@ -510,6 +510,18 @@
   return StringRef();
 }
 
+std::vector DiagnosticIDs::getDiagnosticFlags() {
+  std::vector Res;
+  for (size_t I = 1; DiagGroupNames[I] != '\0';) {
+std::string Diag(DiagGroupNames + I + 1, DiagGroupNames[I]);
+I += DiagGroupNames[I] + 1;
+Res.push_back("-W" + Diag);
+Res.push_back("-Wno" + Diag);
+  }
+
+  return Res;
+}
+
 /// Return \c true if any diagnostics were found in this group, even if they
 /// were filtered out due to having the wrong flavor.
 static bool getDiagnosticsInGroup(diag::Flavor Flavor,
Index: clang/include/clang/Basic/DiagnosticIDs.h
===
--- clang/include/clang/Basic/DiagnosticIDs.h
+++ clang/include/clang/Basic/DiagnosticIDs.h
@@ -18,6 +18,7 @@
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/StringRef.h"
+#include 
 
 namespace clang {
   class DiagnosticsEngine;
@@ -263,6 +264,9 @@
   /// are not SFINAE errors.
   static SFINAEResponse getDiagnosticSFINAEResponse(unsigned DiagID);
 
+  /// \brief Get the string of all diagnostic flags
+  static std::vector getDiagnosticFlags();
+
   /// \brief Get the set of all diagnostic IDs in the group with the given 
name.
   ///
   /// \param[out] Diags - On return, the diagnostics in the group.


Index: clang/test/Driver/autocomplete.c
===
--- clang/test/Driver/autocomplete.c
+++ clang/test/Driver/autocomplete.c
@@ -40,3 +40,7 @@
 // MRELOCMODEL_CLANG-NOT: -mrelocation-model
 // RUN: %clang --autocomplete=#-mrelocation-mode | FileCheck %s -check-prefix=MRELOCMODEL_CC1
 // MRELOCMODEL_CC1: -mrelocation-model
+// RUN: %clang --autocomplete=-Wma | FileCheck %s -check-prefix=WARNING
+// WARNING: -Wmacro-redefined -Wmain -Wmain-return-type -Wmalformed-warning-check -Wmany-braces-around-scalar-init -Wmax-unsigned-zero
+// RUN: %clang --autocomplete=-Wnoinvalid-pp- | FileCheck %s -check-prefix=NOWARNING
+// NOWARNING: -Wnoinvalid-pp-token
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1275,6 +1275,10 @@
   // we were requested to print out all option names that start with "-foo".
   // For example, "--autocomplete=-fsyn" is expanded to "-fsyntax-only".
   SuggestedCompletions = Opts->findByPrefix(PassedFlags, DisableFlags);
+
+  for (StringRef S : DiagnosticIDs::getDiagnosticFlags())
+if (StringRef(S).startswith(PassedFlags))
+  SuggestedCompletions.push_back(S);
 } else {
   // If the flag is in the form of "--autocomplete=foo,bar", we were
   // requested to print out all option values for "-foo" that start with
Index: clang/lib/Basic/DiagnosticIDs.cpp
===
--- clang/lib/Basic/DiagnosticIDs.cpp
+++ clang/lib/Basic/DiagnosticIDs.cpp
@@ -510,6 +510,18 @@
   return StringRef(

[PATCH] D35447: [Bash-autocompletion] Add support for -W and -Wno

2017-07-15 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

@yamaguchi yes, the reason why we have to treat the `-W...` flags specially 
should be documented (as they're not in the OptTable as you said). E.g. 
something like `// We have to query the -W flags manually as they're not in the 
OptTable.` and then maybe a `TODO: Find a good way to add them to OptTable 
instead and them remove this code.`.


https://reviews.llvm.org/D35447



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


[PATCH] D35447: [Bash-autocompletion] Add support for -W and -Wno

2017-07-15 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi added a comment.

@teemperor 
I forgot to include  in DiagnosticIDs, thanks!

What do you mean `reuse the normal flags` ?
Do you think we should define these -W in Options.td like other flags?


https://reviews.llvm.org/D35447



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


[PATCH] D35372: [clang-tidy] Add a close-on-exec check on memfd_create() in Android module.

2017-07-15 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D35372#810457, @alexfh wrote:

> I have deja vu ;)
>
> Should we make a single check for all CLOEXEC and friends with a single 
> configurable list of (function name, flag name) pairs?


Okay, it may be a bit more complicated than just a list of function name -> 
flag name mappings, since we have to take in account the argument position as 
well. We also might want to check the signature to a certain degree to avoid 
matching wrong function. There are multiple approaches possible to rule out 
incorrect functions with the same name:

1. just look at the number of arguments - this might well be enough, since for 
a certain codebase I wouldn't expect multiple `memfd_create`'s etc. It would 
allow user configurability of the function -> flag mappings.
2. encode the types of arguments as strings and have a small dictionary of 
matchers in the check (e.g. `"const char*" -> 
pointerType(pointee(isAnyCharacter()))`) - that will be more precise and still 
quite flexible and also allow user-configurable function -> flag mappings. But 
this mechanism may be an overkill, if we don't anticipate user-configurable 
functions. I don't know how complex the resulting code turns out to be.
3. Add a matcher for each function statically. This would obviously allow for 
arbitrarily complex matchers, but won't be extensible via configuration options.


https://reviews.llvm.org/D35372



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


[PATCH] D35448: [Bash-autocompletion] Fixed a bug on bash

2017-07-15 Thread Yuka Takahashi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308091: [Bash-autocompletion] Fixed a bug on bash (authored 
by yamaguchi).

Changed prior to commit:
  https://reviews.llvm.org/D35448?vs=106752&id=106762#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35448

Files:
  cfe/trunk/utils/bash-autocomplete.sh


Index: cfe/trunk/utils/bash-autocomplete.sh
===
--- cfe/trunk/utils/bash-autocomplete.sh
+++ cfe/trunk/utils/bash-autocomplete.sh
@@ -20,18 +20,21 @@
 cur="${COMP_WORDS[$cword]}"
   fi
 
-  # bash always separates '=' as a token even if there's no space before/after 
'='.
-  # On the other hand, '=' is just a regular character for clang options that
-  # contain '='. For example, "-stdlib=" is defined as is, instead of 
"-stdlib" and "=".
-  # So, we need to partially undo bash tokenization here for integrity.
   w1="${COMP_WORDS[$cword - 1]}"
   if [[ $cword > 1 ]]; then
 w2="${COMP_WORDS[$cword - 2]}"
+  fi
+
   # Clang want to know if -cc1 or -Xclang option is specified or not, because 
we don't want to show
   # cc1 options otherwise.
   if [[ "${COMP_WORDS[1]}" == "-cc1" || "$w1" == "-Xclang" ]]; then
 arg="#"
   fi
+
+  # bash always separates '=' as a token even if there's no space before/after 
'='.
+  # On the other hand, '=' is just a regular character for clang options that
+  # contain '='. For example, "-stdlib=" is defined as is, instead of 
"-stdlib" and "=".
+  # So, we need to partially undo bash tokenization here for integrity.
   if [[ "$cur" == -* ]]; then
 # -foo
 arg="$arg$cur"


Index: cfe/trunk/utils/bash-autocomplete.sh
===
--- cfe/trunk/utils/bash-autocomplete.sh
+++ cfe/trunk/utils/bash-autocomplete.sh
@@ -20,18 +20,21 @@
 cur="${COMP_WORDS[$cword]}"
   fi
 
-  # bash always separates '=' as a token even if there's no space before/after '='.
-  # On the other hand, '=' is just a regular character for clang options that
-  # contain '='. For example, "-stdlib=" is defined as is, instead of "-stdlib" and "=".
-  # So, we need to partially undo bash tokenization here for integrity.
   w1="${COMP_WORDS[$cword - 1]}"
   if [[ $cword > 1 ]]; then
 w2="${COMP_WORDS[$cword - 2]}"
+  fi
+
   # Clang want to know if -cc1 or -Xclang option is specified or not, because we don't want to show
   # cc1 options otherwise.
   if [[ "${COMP_WORDS[1]}" == "-cc1" || "$w1" == "-Xclang" ]]; then
 arg="#"
   fi
+
+  # bash always separates '=' as a token even if there's no space before/after '='.
+  # On the other hand, '=' is just a regular character for clang options that
+  # contain '='. For example, "-stdlib=" is defined as is, instead of "-stdlib" and "=".
+  # So, we need to partially undo bash tokenization here for integrity.
   if [[ "$cur" == -* ]]; then
 # -foo
 arg="$arg$cur"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r308091 - [Bash-autocompletion] Fixed a bug on bash

2017-07-15 Thread Yuka Takahashi via cfe-commits
Author: yamaguchi
Date: Sat Jul 15 02:09:51 2017
New Revision: 308091

URL: http://llvm.org/viewvc/llvm-project?rev=308091&view=rev
Log:
[Bash-autocompletion] Fixed a bug on bash

Summary: Maybe I mismerged when merging previous commits by hand.

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

Modified:
cfe/trunk/utils/bash-autocomplete.sh

Modified: cfe/trunk/utils/bash-autocomplete.sh
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/bash-autocomplete.sh?rev=308091&r1=308090&r2=308091&view=diff
==
--- cfe/trunk/utils/bash-autocomplete.sh (original)
+++ cfe/trunk/utils/bash-autocomplete.sh Sat Jul 15 02:09:51 2017
@@ -20,18 +20,21 @@ _clang()
 cur="${COMP_WORDS[$cword]}"
   fi
 
-  # bash always separates '=' as a token even if there's no space before/after 
'='.
-  # On the other hand, '=' is just a regular character for clang options that
-  # contain '='. For example, "-stdlib=" is defined as is, instead of 
"-stdlib" and "=".
-  # So, we need to partially undo bash tokenization here for integrity.
   w1="${COMP_WORDS[$cword - 1]}"
   if [[ $cword > 1 ]]; then
 w2="${COMP_WORDS[$cword - 2]}"
+  fi
+
   # Clang want to know if -cc1 or -Xclang option is specified or not, because 
we don't want to show
   # cc1 options otherwise.
   if [[ "${COMP_WORDS[1]}" == "-cc1" || "$w1" == "-Xclang" ]]; then
 arg="#"
   fi
+
+  # bash always separates '=' as a token even if there's no space before/after 
'='.
+  # On the other hand, '=' is just a regular character for clang options that
+  # contain '='. For example, "-stdlib=" is defined as is, instead of 
"-stdlib" and "=".
+  # So, we need to partially undo bash tokenization here for integrity.
   if [[ "$cur" == -* ]]; then
 # -foo
 arg="$arg$cur"


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


[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-07-15 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D32210#810292, @ahatanak wrote:

> Address review comments.
>
> - Allow attaching "noescape" to pointers other than block pointers. Update 
> the docs accordingly.
> - Attach attribute "nocapture" to parameters that are annotated with 
> "noescape".
> - Call Sema::isValidPointerAttrType to determine whether "noescape" can be 
> applied to a parameter. Also, use the existing warning 
> "warn_attribute_pointers_only" rather than defining a new warning that will 
> be used just for noescape.
>
>   I also thought about what else we can do in the front-end when a parameter 
> has 'noescape".  One idea is to do something similar to what r301667 did and 
> omit emitting retains and releases of block captures when the block is passed 
> to a function taking a noescape parameter. If that is viable, I can look into 
> it after committing this patch.


Hmm.  Unfortunately, I'm not sure that's valid.  The retains and releases of 
block captures don't protect against anything related to escaping the block; 
they protect against the original variables being modified during the lifetime 
of the block.  It is true that a block literal passed to a noescape parameter 
has a shorter effective lifetime — we know for certain that it will be unused 
after the call, and ARC only promises that a value in an imprecise-lifetime 
strong variable like a block capture will be valid until the last load of that 
value from the variable.  But that duration is still long enough for someone to 
modify the original variable in a way that is properly sequenced after the 
formation of the block.

Now, if you could prove that the variable was not modified for the duration of 
the call, that would be sufficient.  And that would be easy to do in the common 
case by just proving that the address of the variable never escapes.  
Unfortunately, we don't have that information readily available because Sema 
doesn't collect it.

There are some other ways you could optimize blocks that are known not to 
escape, though.  One big caveat is that you have to make sure the block behaves 
reasonably in response to being copied, because being noescape doesn't 
guarantee that the callee won't try to copy the block.  However:

- Copying a global block is always a no-op.  If you gave the non-escaping stack 
block a global block isa, that would allow the blocks runtime to avoid doing 
extra work when a non-escaping block is spuriously copied, and it would allow 
the compiler to completely avoid emitting copy and destroy helpers for the 
block.  Please clear this with Greg Parker first, though.
- Even if that's not possible, you can still avoid emitting copy and destroy 
helpers in the common case where none of the captures are address-sensitive, 
i.e. __weak references or non-trivally-copyable C++ types, because the memcpy 
from the original block will be sufficient for correctness.
- You can just capture a reference to an outer block instead of copying 
anything that it captures.
- __block variables which are only captured by non-escaping blocks are 
themselves known not to escape.  (But remember that a non-escaping block can 
create an escaping block that captures the __block variable!)  Because __block 
variable copies are only ever kicked off by block copy helpers, and you won't 
be generating those (or at least won't be asking them to copy your __block 
variables for you), you also know that such variables can't be copied.  That in 
turn means you can completely drop all the nonsense that only exists to 
supporting the lazy copying of __block variables, like the __block header and 
copy/destroy helpers and forwarding.  Just generate the variable like a normal 
local variable and capture it by reference.

John.




Comment at: include/clang/AST/Type.h:3156
 };
 unsigned char Data;
 

Oh!  I hadn't noticed that you were adding this to ExtParameterInfo.  You're 
modifying the function type system; there's a lot of complexity to do that 
properly which you haven't done in this patch at all.  That's especially true 
because, unlike all these other ExtParameterInfo cases, there's a natural 
subtyping rule for escaping parameters: a function type that takes a 
non-escaping parameter should be implicitly convertible to be a function type 
that takes an escaping parameter.  You will also need to update a bunch of 
things, including the type printer, the mangler, the C++ function conversion 
rules, the C type compatibility rules, the redeclaration type matcher, and 
maybe even template argument deduction.  It's a big thing to do.

You will want Sema tests in C, ObjC, C++, and ObjC++.



Comment at: lib/CodeGen/CGCall.cpp:2096
+if (FI.getExtParameterInfo(ArgNo).isNoEscape())
+  Attrs.addAttribute(llvm::Attribute::NoCapture);
+

You should make sure that building a CGFunctionInfo with an ObjCMethodDecl* 
collects this from the parameter

[PATCH] D35362: [clang-tidy] Add a close-on-exec check on accept() in Android module.

2017-07-15 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

See the comment on https://reviews.llvm.org/D35372.


Repository:
  rL LLVM

https://reviews.llvm.org/D35362



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


[PATCH] D35363: [clang-tidy] Add a close-on-exec check on accept4() in Android module.

2017-07-15 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

See the comment on https://reviews.llvm.org/D35372.


Repository:
  rL LLVM

https://reviews.llvm.org/D35363



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


[PATCH] D35364: [clang-tidy] Add a close-on-exec check on dup() in Android module.

2017-07-15 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

See the comment on https://reviews.llvm.org/D35372.


Repository:
  rL LLVM

https://reviews.llvm.org/D35364



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


[PATCH] D35365: [clang-tidy] Add a close-on-exec check on epoll_create1() in Android module.

2017-07-15 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

See the comment on https://reviews.llvm.org/D35372.


https://reviews.llvm.org/D35365



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


[PATCH] D35368: [clang-tidy] Add a close-on-exec check on inotify_init1() in Android module.

2017-07-15 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

See the comment on https://reviews.llvm.org/D35372.


https://reviews.llvm.org/D35368



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


[PATCH] D35367: [clang-tidy] Add a close-on-exec check on epoll_create() in Android module.

2017-07-15 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

See the comment on https://reviews.llvm.org/D35372.


https://reviews.llvm.org/D35367



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


[PATCH] D35450: [analyzer] Support generating and reasoning over more symbolic constraint types

2017-07-15 Thread Dominic Chen via Phabricator via cfe-commits
ddcc added a comment.

Compared with https://reviews.llvm.org/D28953, this revision fixes the test 
failure with `PR3991.m` with RangeConstraintManager, and a few other failures 
with Z3ConstraintManager. However, there's one remaining test failure in 
`range_casts.c` that I'm not sure how to resolve. For reference, this is the 
simplified code snippet from that testcase:

  void f15(long foo) {
unsigned index = -1;
if (index < foo) index = foo;
unsigned int tmp = index + 1;
if (tmp == 0)
  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
else
  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
  }

In debug mode, an assertion about the system being over-constrained is thrown 
from `ConstraintManager.h`. This is because the new 
`Simplifier::VisitSymbolCast` function will attempt to evaluate the cast 
`(unsigned int) (reg_$0)`, which is suppressed by the call to 
`haveSameType()` in `SimpleSValBuilder::evalCastFromNonLoc` 
(https://reviews.llvm.org/D28955 fixes this, but only for Z3ConstraintManager), 
generating just the symbol `reg_$0`. Subsequently, the analyzer will 
attempt to evaluate the expression `((reg_$0) + 1U) == 0U` with the 
range `reg_$0 : { [4294967296, 9223372036854775807] }`, or `[UINT_MAX 
+ 1, LONG_MAX]`. However, in the case where the assumption is true, 
RangeConstraintManager takes the intersection of the previous range with 
`[UINT_MAX, UINT_MAX]` and produces the empty set, and likewise where the 
assumption is false, the intersection with `[UINT_MAX - 1, 0]` again produces 
the empty set. As a result, both program states are NULL, triggering the 
assertion.

I'm now somewhat inclined to drop the addition of 
`Simplified::VisitSymbolCast()` and those associated testsuite changes, because 
ignoring type casts is clearly incorrect and will introduce both false 
negatives and false positives.


https://reviews.llvm.org/D35450



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


[PATCH] D35370: [clang-tidy] Add a close-on-exec check on inotify_init() in Android module.

2017-07-15 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

See the comment on https://reviews.llvm.org/D35372.


https://reviews.llvm.org/D35370



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


[PATCH] D35450: [analyzer] Support generating and reasoning over more symbolic constraint types

2017-07-15 Thread Dominic Chen via Phabricator via cfe-commits
ddcc updated this revision to Diff 106758.
ddcc added a comment.

Modify Z3RangeConstraintManager::fixAPSInt() and add Expr::isCommutativeOp()


https://reviews.llvm.org/D35450

Files:
  include/clang/AST/Expr.h
  include/clang/Config/config.h.cmake
  include/clang/StaticAnalyzer/Checkers/SValExplainer.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
  lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
  lib/StaticAnalyzer/Core/SValBuilder.cpp
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
  test/Analysis/analyzer_test.py
  test/Analysis/bitwise-ops.c
  test/Analysis/bool-assignment.c
  test/Analysis/conditional-path-notes.c
  test/Analysis/explain-svals.cpp
  test/Analysis/plist-macros-z3.cpp
  test/Analysis/plist-macros.cpp
  test/Analysis/range_casts.c
  test/Analysis/std-c-library-functions.c

Index: test/Analysis/std-c-library-functions.c
===
--- test/Analysis/std-c-library-functions.c
+++ test/Analysis/std-c-library-functions.c
@@ -57,8 +57,7 @@
   size_t y = fread(buf, sizeof(int), 10, fp);
   clang_analyzer_eval(y <= 10); // expected-warning{{TRUE}}
   size_t z = fwrite(buf, sizeof(int), y, fp);
-  // FIXME: should be TRUE once symbol-symbol constraint support is improved.
-  clang_analyzer_eval(z <= y); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(z <= y); // expected-warning{{TRUE}}
 }
 
 ssize_t getline(char **, size_t *, FILE *);
Index: test/Analysis/range_casts.c
===
--- test/Analysis/range_casts.c
+++ test/Analysis/range_casts.c
@@ -67,8 +67,8 @@
 {
   unsigned index = -1;
   if (index < foo) index = foo;
-  if (index - 1 == 0) // Was not reached prior fix.
-clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  if (index - 1 == 0)
+clang_analyzer_warnIfReached(); // no-warning
   else
 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
 }
@@ -87,8 +87,8 @@
 {
   unsigned index = -1;
   if (index < foo) index = foo;
-  if (index - 1L == 0L) // Was not reached prior fix.
-clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  if (index - 1L == 0L)
+clang_analyzer_warnIfReached(); // no-warning
   else
 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
 }
@@ -117,8 +117,8 @@
 {
   unsigned index = -1;
   if (index < foo) index = foo;
-  if (index - 1UL == 0L) // Was not reached prior fix.
-clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  if (index - 1UL == 0L)
+clang_analyzer_warnIfReached(); // no-warning
   else
 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
 }
Index: test/Analysis/plist-macros.cpp
===
--- test/Analysis/plist-macros.cpp
+++ test/Analysis/plist-macros.cpp
@@ -1,7 +1,7 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,unix -analyzer-eagerly-assume -verify %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix -analyzer-eagerly-assume -analyzer-output=plist-multi-file -analyzer-config path-diagnostics-alternate=ture %s -o %t.plist
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix -analyzer-eagerly-assume -analyzer-output=plist-multi-file -analyzer-config path-diagnostics-alternate=true %s -o %t.plist
 // RUN: FileCheck --input-file=%t.plist %s
-
+// REQUIRES: !z3
 
 typedef __typeof(sizeof(int)) size_t;
 void *malloc(size_t);
@@ -11,13 +11,13 @@
   y++;
   y--;
   mallocmemory
-  y++; 
+  y++;
   y++;
   delete x; // expected-warning {{Memory allocated by malloc() should be deallocated by free(), not 'delete'}}
 }
 
 void macroIsFirstInFunction(int y) {
-  mallocmemory 
+  mallocmemory
   y++; // expected-warning {{Potential leak of memory pointed to by 'x'}}
 }
 
@@ -39,7 +39,7 @@
   return *p; // expected-warning {{Dereference of null pointer}}
 }
 
-#define macroWithArg(mp) mp==0 
+#define macroWithArg(mp) mp==0
 int macroWithArgInExpression(int *p, int y) {;
   y++;
   if (macroWithArg(p))
@@ -85,6 +85,7 @@
 void test2(int *p) {
   CALL_FN(p);
 }
+
 // CHECK:  diagnostics
 // CHECK-NEXT:  
 // CHECK-NEXT:   
@@ -636,6 +637,69 @@
 // CHECK-NEXT: end
 // CHECK-NEXT:  
 // CHECK-NEXT:   
+// CHECK-NEXT:line36
+// CHECK-NEXT:col7
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:   
+// CHECK-NEXT:line36
+// CHECK-NEXT:col7
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT:   
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  kindevent
+// CHECK-NEXT:  location
+// CHECK-NEXT:  
+// CHECK-NEXT:   line36
+// CHECK-NEXT:   col7
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT:  ranges
+// 

[PATCH] D35372: [clang-tidy] Add a close-on-exec check on memfd_create() in Android module.

2017-07-15 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

I have deja vu ;)

Should we make a single check for all CLOEXEC and friends with a single 
configurable list of (function name, flag name) pairs?


https://reviews.llvm.org/D35372



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


[PATCH] D35447: [Bash-autocompletion] Add support for -W and -Wno

2017-07-15 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor requested changes to this revision.
teemperor added a comment.
This revision now requires changes to proceed.

It seems the code doesn't compile in clang because on your platform 
`std::vector` is implicitly included by some header, on clang+Arch however it 
isn`t (see the error at the end of https://teemperor.de/ccir/D35447).




Comment at: clang/lib/Driver/Driver.cpp:1279
+
+  for (std::string S : DiagnosticIDs::getDiagnosticFlags())
+if (StringRef(S).startswith(PassedFlags))

ruiu wrote:
> Let's avoid copy: std::string -> StringRef
> 
Could you document why we had to do it this way and can't reuse the normal 
flags? Maybe even add a `TODO:` because it would be nice project for someone to 
refactor this into one data structure.


https://reviews.llvm.org/D35447



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


[PATCH] D35427: [clang] Fix handling of "%zd" format specifier

2017-07-15 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap added a comment.

@chapuni - many thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D35427



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