[PATCH] D39451: P0620 follow-up: deducing `auto` from braced-init-list in new expr

2017-12-07 Thread Zhihao Yuan via Phabricator via cfe-commits
lichray updated this revision to Diff 126092.
lichray added a comment.

Keep a pedantic Extension warning.


Repository:
  rC Clang

https://reviews.llvm.org/D39451

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExprCXX.cpp
  test/CXX/expr/expr.unary/expr.new/p2-cxx0x.cpp
  test/CXX/expr/expr.unary/expr.new/p2-cxx14.cpp
  test/CXX/expr/expr.unary/expr.new/p2-cxx1z.cpp
  test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp

Index: test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
===
--- test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
+++ test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
@@ -148,7 +148,7 @@
 }
 
 void dangle() {
-  new auto{1, 2, 3}; // expected-error {{cannot use list-initialization}}
+  new auto{1, 2, 3}; // expected-error {{new expression for type 'auto' contains multiple constructor arguments}}
   new std::initializer_list{1, 2, 3}; // expected-warning {{at the end of the full-expression}}
 }
 
Index: test/CXX/expr/expr.unary/expr.new/p2-cxx1z.cpp
===
--- /dev/null
+++ test/CXX/expr/expr.unary/expr.new/p2-cxx1z.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++14
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++17 -pedantic
+
+void f() {
+  new auto('a');
+  new auto {2};
+  new auto {1, 2}; // expected-error{{new expression for type 'auto' contains multiple constructor arguments}}
+  new auto({1});
+  new auto {}; // expected-error{{new expression for type 'auto' requires a constructor argument}}
+  new decltype(auto)({1, 2}); // expected-error{{new expression for type 'decltype(auto)' contains multiple constructor arguments}}
+}
Index: test/CXX/expr/expr.unary/expr.new/p2-cxx14.cpp
===
--- /dev/null
+++ test/CXX/expr/expr.unary/expr.new/p2-cxx14.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++14 -pedantic
+
+void f() {
+  new auto('a');
+  new auto {2}; // expected-warning {{ISO C++ standards before C++17 does not allow new expression for type 'auto' using list-initialization}}
+  new auto {1, 2}; // expected-warning {{ISO C++ standards before C++17 does not allow new expression for type 'auto' using list-initialization}} expected-error{{new expression for type 'auto' contains multiple constructor arguments}}
+  new auto({1}); // expected-warning {{ISO C++ standards before C++17 does not allow new expression for type 'auto' using list-initialization}}
+  new auto {}; // expected-error{{new expression for type 'auto' requires a constructor argument}}
+  new decltype(auto)({1, 2}); // expected-warning {{ISO C++ standards before C++17 does not allow new expression for type 'decltype(auto)' using list-initialization}} expected-error{{new expression for type 'decltype(auto)' contains multiple constructor arguments}}
+}
Index: test/CXX/expr/expr.unary/expr.new/p2-cxx0x.cpp
===
--- test/CXX/expr/expr.unary/expr.new/p2-cxx0x.cpp
+++ test/CXX/expr/expr.unary/expr.new/p2-cxx0x.cpp
@@ -9,12 +9,14 @@
 void f() {
   only p = new const auto (0);
   only q = new (auto) (0.0);
+  only r = new auto {'a'};
 
   new auto; // expected-error{{new expression for type 'auto' requires a constructor argument}}
   new (const auto)(); // expected-error{{new expression for type 'const auto' requires a constructor argument}}
   new (auto) (1,2,3); // expected-error{{new expression for type 'auto' contains multiple constructor arguments}}
-  new auto {1,2,3}; // expected-error{{new expression for type 'auto' cannot use list-initialization}}
-  new auto ({1,2,3}); // expected-error{{new expression for type 'auto' cannot use list-initialization}}
+  new auto {}; // expected-error{{new expression for type 'auto' requires a constructor argument}}
+  new auto {1,2,3}; // expected-error{{new expression for type 'auto' contains multiple constructor arguments}}
+  new auto ({1,2,3}); // expected-error{{new expression for type 'auto' contains multiple constructor arguments}}
 }
 
 void p2example() {
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -1748,14 +1748,21 @@
 if (AllocType.isNull())
   return ExprError();
   } else if (Deduced) {
+bool Braced = (initStyle == CXXNewExpr::ListInit);
+if (NumInits == 1) {
+  if (auto p = dyn_cast_or_null(Inits[0])) {
+Inits = p->getInits();
+NumInits = p->getNumInits();
+Braced = true;
+  }
+}
+
 if (initStyle == CXXNewExpr::NoInit || NumInits == 0)
   return ExprError(Diag(StartLoc, diag::err_auto_new_requires_ctor_arg)
<< AllocType << TypeRange);
-if (initStyle == CXXNewExpr::ListInit ||
-(NumInits == 1 && 

[PATCH] D39050: Add index-while-building support to Clang

2017-12-07 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added a comment.

In https://reviews.llvm.org/D39050#948500, @akyrtzi wrote:

> @malaperle, to clarify we are not suggesting that you write your own parser, 
> the suggestion is to use clang in 'fast-scan' mode to get the structure of 
> the declarations of a single file, see `CXTranslationUnit_SingleFileParse` 
> (along with enabling skipping of bodies). We have found clang is super fast 
> when you only try to get the structure of a file like this.


Thank you, that sounds very useful. I will try that and get some measurements.

> We can make convenient APIs to provide the syntactic structure of 
> declarations based on their location.

Perhaps just for the end-loc since it's pretty much guaranteed to be needed by 
everyone. But if it's very straightforward, perhaps that's not needed. I'll try 
and see.

> But let's say we added the end-loc, is it enough ? If you want to implement 
> the 'peek the definition' like Eclipse, then it is not enough, you also need 
> to figure out if there are documentation comments associated with the 
> declaration and also show those. Also what if you want to highlight the type 
> signature of a function, then just storing the location of the closing brace 
> of its body is not enough. There can be any arbitrary things you may want to 
> get from the structure of the declaration (e.g. the parameter ranges), but we 
> could provide an API to gather any syntactic structure info you may want.

That's a very good point. I guess in the back of my mind, I have the worry that 
one cannot extend what is stored, either for a different performance trade-off 
or for additional things. The fact that both clang and clangd have to agree on 
the format so that index-while-building can be used seems to make it inherently 
not possible to extend. But perhaps it's better to not overthink this for now.


https://reviews.llvm.org/D39050



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


Re: r320124 - Fold together the in-range and out-of-range portions of -Wtautological-compare.

2017-12-07 Thread Hans Wennborg via cfe-commits
I've reverted in r320133 since it caused new warnings in Chromium that
I'm not sure were intentional. See comment on the revert.

On Thu, Dec 7, 2017 at 5:00 PM, Richard Smith via cfe-commits
 wrote:
> Author: rsmith
> Date: Thu Dec  7 17:00:27 2017
> New Revision: 320124
>
> URL: http://llvm.org/viewvc/llvm-project?rev=320124=rev
> Log:
> Fold together the in-range and out-of-range portions of 
> -Wtautological-compare.
>
> Modified:
> cfe/trunk/lib/Sema/SemaChecking.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=320124=320123=320124=diff
> ==
> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Dec  7 17:00:27 2017
> @@ -8801,12 +8801,7 @@ static bool CheckTautologicalComparison(
>  Expr *Constant, Expr *Other,
>  const llvm::APSInt ,
>  bool RhsConstant) {
> -  // Disable warning in template instantiations
> -  // and only analyze <, >, <= and >= operations.
> -  if (S.inTemplateInstantiation() || !E->isRelationalOp())
> -return false;
> -
> -  if (IsEnumConstOrFromMacro(S, Constant))
> +  if (S.inTemplateInstantiation())
>  return false;
>
>Expr *OriginalOther = Other;
> @@ -8833,94 +8828,23 @@ static bool CheckTautologicalComparison(
>OtherRange.Width =
>std::min(Bitfield->getBitWidthValue(S.Context), OtherRange.Width);
>
> -  // Check whether the constant value can be represented in OtherRange. Bail
> -  // out if so; this isn't an out-of-range comparison.
> +  // Determine the promoted range of the other type and see if a comparison 
> of
> +  // the constant against that range is tautological.
>PromotedRange OtherPromotedRange(OtherRange, Value.getBitWidth(),
> Value.isUnsigned());
> -
>auto Cmp = OtherPromotedRange.compare(Value);
> -  if (Cmp != PromotedRange::Min && Cmp != PromotedRange::Max &&
> -  Cmp != PromotedRange::OnlyValue)
> -return false;
> -
>auto Result = PromotedRange::constantValue(E->getOpcode(), Cmp, 
> RhsConstant);
>if (!Result)
>  return false;
>
> -  // Should be enough for uint128 (39 decimal digits)
> -  SmallString<64> PrettySourceValue;
> -  llvm::raw_svector_ostream OS(PrettySourceValue);
> -  OS << Value;
> -
> -  // FIXME: We use a somewhat different formatting for the cases involving
> -  // boolean values for historical reasons. We should pick a consistent way
> -  // of presenting these diagnostics.
> -  if (Other->isKnownToHaveBooleanValue()) {
> -S.DiagRuntimeBehavior(
> -  E->getOperatorLoc(), E,
> -  S.PDiag(diag::warn_tautological_bool_compare)
> -  << OS.str() << classifyConstantValue(Constant)
> -  << OtherT << !OtherT->isBooleanType() << *Result
> -  << E->getLHS()->getSourceRange() << E->getRHS()->getSourceRange());
> -return true;
> -  }
> -
> -  unsigned Diag = (isKnownToHaveUnsignedValue(OriginalOther) && Value == 0)
> -  ? (HasEnumType(OriginalOther)
> - ? 
> diag::warn_unsigned_enum_always_true_comparison
> - : diag::warn_unsigned_always_true_comparison)
> -  : diag::warn_tautological_constant_compare;
> -
> -  S.Diag(E->getOperatorLoc(), Diag)
> -  << RhsConstant << OtherT << E->getOpcodeStr() << OS.str() << *Result
> -  << E->getLHS()->getSourceRange() << E->getRHS()->getSourceRange();
> -
> -  return true;
> -}
> -
> -static bool DiagnoseOutOfRangeComparison(Sema , BinaryOperator *E,
> - Expr *Constant, Expr *Other,
> - const llvm::APSInt ,
> - bool RhsConstant) {
> -  // Disable warning in template instantiations.
> -  if (S.inTemplateInstantiation())
> -return false;
> -
> -  Constant = Constant->IgnoreParenImpCasts();
> -  Other = Other->IgnoreParenImpCasts();
> -
> -  // TODO: Investigate using GetExprRange() to get tighter bounds
> -  // on the bit ranges.
> -  QualType OtherT = Other->getType();
> -  if (const auto *AT = OtherT->getAs())
> -OtherT = AT->getValueType();
> -  IntRange OtherRange = IntRange::forValueOfType(S.Context, OtherT);
> -
> -  // Whether we're treating Other as being a bool because of the form of
> -  // expression despite it having another type (typically 'int' in C).
> -  bool OtherIsBooleanDespiteType =
> -  !OtherT->isBooleanType() && Other->isKnownToHaveBooleanValue();
> -  if (OtherIsBooleanDespiteType)
> -OtherRange = IntRange::forBoolType();
> -
> -  if (FieldDecl *Bitfield = Other->getSourceBitField())
> -if (!Bitfield->getBitWidth()->isValueDependent())
> -  OtherRange.Width 

r320133 - Revert r320124 "Fold together the in-range and out-of-range portions of -Wtautological-compare."

2017-12-07 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Dec  7 21:19:12 2017
New Revision: 320133

URL: http://llvm.org/viewvc/llvm-project?rev=320133=rev
Log:
Revert r320124 "Fold together the in-range and out-of-range portions of 
-Wtautological-compare."

This broke Chromium:

../../base/trace_event/trace_log.cc:1545:29: error: comparison of constant 64
with expression of type 'unsigned int' is always true
[-Werror,-Wtautological-constant-out-of-range-compare]
  DCHECK(handle.event_index < TraceBufferChunk::kTraceBufferChunkSize);
 ~~ ^ ~~~

The 'unsigned int' is really a 6-bit bitfield, which is why it's always
less than 63.

Did this use to fall under the "in-range" case before? I thought we
didn't use to warn when comparing against the boundaries of a type.

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

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=320133=320132=320133=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Dec  7 21:19:12 2017
@@ -8801,7 +8801,12 @@ static bool CheckTautologicalComparison(
 Expr *Constant, Expr *Other,
 const llvm::APSInt ,
 bool RhsConstant) {
-  if (S.inTemplateInstantiation())
+  // Disable warning in template instantiations
+  // and only analyze <, >, <= and >= operations.
+  if (S.inTemplateInstantiation() || !E->isRelationalOp())
+return false;
+
+  if (IsEnumConstOrFromMacro(S, Constant))
 return false;
 
   Expr *OriginalOther = Other;
@@ -8828,23 +8833,94 @@ static bool CheckTautologicalComparison(
   OtherRange.Width =
   std::min(Bitfield->getBitWidthValue(S.Context), OtherRange.Width);
 
-  // Determine the promoted range of the other type and see if a comparison of
-  // the constant against that range is tautological.
+  // Check whether the constant value can be represented in OtherRange. Bail
+  // out if so; this isn't an out-of-range comparison.
   PromotedRange OtherPromotedRange(OtherRange, Value.getBitWidth(),
Value.isUnsigned());
+
   auto Cmp = OtherPromotedRange.compare(Value);
+  if (Cmp != PromotedRange::Min && Cmp != PromotedRange::Max &&
+  Cmp != PromotedRange::OnlyValue)
+return false;
+
   auto Result = PromotedRange::constantValue(E->getOpcode(), Cmp, RhsConstant);
   if (!Result)
 return false;
 
-  // Suppress the diagnostic for an in-range comparison if the constant comes
-  // from a macro or enumerator. We don't want to diagnose
-  //
-  //   some_long_value <= INT_MAX
-  //
-  // when sizeof(int) == sizeof(long).
-  bool InRange = Cmp & PromotedRange::InRangeFlag;
-  if (InRange && IsEnumConstOrFromMacro(S, Constant))
+  // Should be enough for uint128 (39 decimal digits)
+  SmallString<64> PrettySourceValue;
+  llvm::raw_svector_ostream OS(PrettySourceValue);
+  OS << Value;
+
+  // FIXME: We use a somewhat different formatting for the cases involving
+  // boolean values for historical reasons. We should pick a consistent way
+  // of presenting these diagnostics.
+  if (Other->isKnownToHaveBooleanValue()) {
+S.DiagRuntimeBehavior(
+  E->getOperatorLoc(), E,
+  S.PDiag(diag::warn_tautological_bool_compare)
+  << OS.str() << classifyConstantValue(Constant)
+  << OtherT << !OtherT->isBooleanType() << *Result
+  << E->getLHS()->getSourceRange() << E->getRHS()->getSourceRange());
+return true;
+  }
+
+  unsigned Diag = (isKnownToHaveUnsignedValue(OriginalOther) && Value == 0)
+  ? (HasEnumType(OriginalOther)
+ ? diag::warn_unsigned_enum_always_true_comparison
+ : diag::warn_unsigned_always_true_comparison)
+  : diag::warn_tautological_constant_compare;
+
+  S.Diag(E->getOperatorLoc(), Diag)
+  << RhsConstant << OtherT << E->getOpcodeStr() << OS.str() << *Result
+  << E->getLHS()->getSourceRange() << E->getRHS()->getSourceRange();
+
+  return true;
+}
+
+static bool DiagnoseOutOfRangeComparison(Sema , BinaryOperator *E,
+ Expr *Constant, Expr *Other,
+ const llvm::APSInt ,
+ bool RhsConstant) {
+  // Disable warning in template instantiations.
+  if (S.inTemplateInstantiation())
+return false;
+
+  Constant = Constant->IgnoreParenImpCasts();
+  Other = Other->IgnoreParenImpCasts();
+
+  // TODO: Investigate using GetExprRange() to get tighter bounds
+  // on the bit ranges.
+  QualType OtherT = Other->getType();
+  if (const auto *AT = OtherT->getAs())
+OtherT = AT->getValueType();
+  IntRange OtherRange = IntRange::forValueOfType(S.Context, 

[PATCH] D40548: [clangd] Symbol index interfaces and index-based code completion.

2017-12-07 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added a comment.

As a follow-up, here's the interface for querying the index that I am using 
right now. It's meant to be able to retrieve from any kind of "backend", i.e. 
in-memory, ClangdIndexDataStore, libIndexStore, etc. I was able to implement 
"Open Workspace Symbol" (which is close to code completion in concept), Find 
References and Find Definitions.

  using USR = llvm::SmallString<256>;
  
  class ClangdIndexDataOccurrence;
  
  class ClangdIndexDataSymbol {
  public:
virtual index::SymbolKind getKind() = 0;
/// For example, for mynamespace::myclass::mymethod, this will be
/// mymethod.
virtual std::string getName() = 0;
/// For example, for mynamespace::myclass::mymethod, this will be
/// mynamespace::myclass::
virtual std::string getQualifier() = 0;
virtual std::string getUsr() = 0;
  
virtual void foreachOccurrence(index::SymbolRoleSet Roles, 
llvm::function_ref Receiver) = 0;
  
virtual ~ClangdIndexDataSymbol() = default;
  };
  
  class ClangdIndexDataOccurrence {
  public:
enum class OccurrenceType : uint16_t {
   OCCURRENCE,
   DEFINITION_OCCURRENCE
 };
  
virtual OccurrenceType getKind() const = 0;
virtual std::string getPath() = 0;
/// Get the start offset of the symbol occurrence. The SourceManager can be
/// used for implementations that need to convert from a line/column
/// representation to an offset.
virtual uint32_t getStartOffset(SourceManager ) = 0;
/// Get the end offset of the symbol occurrence. The SourceManager can be
/// used for implementations that need to convert from a line/column
/// representation to an offset.
virtual uint32_t getEndOffset(SourceManager ) = 0;
virtual ~ClangdIndexDataOccurrence() = default;
//TODO: Add relations
  
static bool classof(const ClangdIndexDataOccurrence *O) { return 
O->getKind() == OccurrenceType::OCCURRENCE; }
  };
  
  /// An occurrence that also has definition with a body that requires 
additional
  /// locations to keep track of the beginning and end of the body.
  class ClangdIndexDataDefinitionOccurrence : public ClangdIndexDataOccurrence {
  public:
virtual uint32_t getDefStartOffset(SourceManager ) = 0;
virtual uint32_t getDefEndOffset(SourceManager ) = 0;
  
static bool classof(const ClangdIndexDataOccurrence *O) { return 
O->getKind() == OccurrenceType::DEFINITION_OCCURRENCE; }
  };
  
  class ClangdIndexDataProvider {
  public:
  
virtual void foreachSymbols(StringRef Pattern, 
llvm::function_ref Receiver) = 0;
virtual void foreachSymbols(const USR , 
llvm::function_ref Receiver) = 0;
  
virtual ~ClangdIndexDataProvider() = default;
  };

The "Clangd" prefix adds a bit much of clutter so maybe it should be removed.  
I think the main points are that having generic 
foreachSymbols/foreachOccurrence with callbacks is well suited to implement 
multiple features with minimal copying.




Comment at: clangd/SymbolIndex.h:50
+  virtual llvm::Expected
+  complete(const CompletionRequest ) const = 0;
+

sammccall wrote:
> This is finding symbols that fuzzy-match a string, right?
> We shouldn't conflate this with code completion - code completion is 
> context-sensitive, and this query operation will be used for other operations 
> like navigate-to-symbol.
> 
> Suggest `fuzzyFind` or similar.
> (Similarly with CompletionRequest, CompletionSymbol)
Similar to completion is "Open Workspace Symbol". So a more generic query could 
be useful.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40548



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


[PATCH] D40897: [clangd] Introduce a "Symbol" class.

2017-12-07 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added inline comments.



Comment at: clangd/Symbol.h:23
+  // The path of the source file where a symbol occurs.
+  std::string FilePath;
+  // The offset to the first character of the symbol from the beginning of the

malaperle wrote:
> sammccall wrote:
> > ioeric wrote:
> > > Is this relative or absolute?
> > Having every symbol own a copy of the filepath seems wasteful.
> > It seems likely that the index will have per-file information too, so this 
> > representation should likely be a key to that. Hash of the filepath might 
> > work?
> How we model it is that a symbol doesn't have a "location", but its 
> occurrence do. One could consider the location of a symbol to be either its 
> declaration occurrence (SymbolRole::Declaration) or its definition 
> (SymbolRole::Definition).
> What we do to get the location path is each occurrence has a pointer (a 
> "database" pointer, but it doesn't matter) to a file entry and then we get 
> the path from the entry.
> 
> So conceptually, it works a bit like this (although it fetches information on 
> disk).
> ```
> class IndexOccurrence {
> IndexOccurrence *FilePtr;
> 
> std::string Occurrence::getPath() {
>   return FilePtr->getPath();
> }
> };
> ```
Oops, wrong type for the field, it should have been:
```
class IndexOccurrence {
IndexFile *FilePtr;

std::string Occurrence::getPath() {
  return FilePtr->getPath();
}
};
```


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40897



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


[PATCH] D40998: [driver][darwin] Take the OS version specified in "-target" as the target OS instead of inferring it from SDK / environment

2017-12-07 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith requested changes to this revision.
dexonsmith added inline comments.
This revision now requires changes to proceed.



Comment at: lib/Driver/ToolChains/Darwin.cpp:1234-1276
+// The -target option specifies the deployment target when
+// -m-version-min is not given and the OS version is present in the
+// target.
+if (Args.hasArg(options::OPT_target) && getTriple().getOSMajorVersion() &&
+getTriple().isOSDarwin()) {
+  unsigned Major, Minor, Micro;
+  auto RewriteVersionMinArg = [&](options::ID O) -> Arg * {

This logic seems to be duplicated from the `-target` handling below.  Perhaps 
this would be simpler if `-target` were processed first.

I suggest the following refactoring in an NFC prep patch:
- First, check for a `-target` option.  If it exists, extract all the bits.
- Then, handle the logic for `-arch`, `-m*-version-min`, and `-isysroot` 
(matching the current semantics, which I think are "override `-target`").

In a follow-up patch, change `-isysroot`/`SDKROOT` not to override a 
`-target`-specified environment (the semantic change from this patch).  After 
the refactoring, I suspect this will be trivial.

We should also warn/error when `-arch` disagrees with `-target`, and likely the 
same for `-m*-version-min`.  I suspect these follow-ups will also be trivial.



Comment at: lib/Driver/ToolChains/Darwin.cpp:1273
+  default:
+llvm_unreachable("invalid Os");
+  }

I'd spell this `"invalid OS"`.


Repository:
  rC Clang

https://reviews.llvm.org/D40998



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


[PATCH] D40998: [driver][darwin] Take the OS version specified in "-target" as the target OS instead of inferring it from SDK / environment

2017-12-07 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
Herald added a subscriber: javed.absar.

The OS version is specified in `-target` should be used instead of the one in 
an environment variable / SDK name.

rdar://35813850


Repository:
  rC Clang

https://reviews.llvm.org/D40998

Files:
  lib/Driver/ToolChains/Darwin.cpp
  test/Driver/appletvos-version-min.c
  test/Driver/darwin-multiarch-arm.c
  test/Driver/darwin-stdlib.cpp
  test/Driver/darwin-version.c

Index: test/Driver/darwin-version.c
===
--- test/Driver/darwin-version.c
+++ test/Driver/darwin-version.c
@@ -12,21 +12,25 @@
 // CHECK-VERSION-IOS3: "armv6k-apple-ios3.0.0"
 
 // RUN: env IPHONEOS_DEPLOYMENT_TARGET=11.0 \
-// RUN:   %clang -target armv7-apple-ios9.0 -c -### %s 2> %t.err
+// RUN:   %clang -target armv7-apple-ios -c -### %s 2> %t.err
 // RUN:   FileCheck --input-file=%t.err --check-prefix=CHECK-VERSION-IOS4 %s
 // CHECK-VERSION-IOS4: invalid iOS deployment version 'IPHONEOS_DEPLOYMENT_TARGET=11.0'
 
+// RUN: %clang -target armv7-apple-ios11 -c -### %s 2> %t.err
+// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-VERSION-IOS41 %s
+// CHECK-VERSION-IOS41: invalid iOS deployment version 'ios11.0.0'
+
 // RUN: %clang -target armv7-apple-ios9.0 -miphoneos-version-min=11.0 -c -### %s 2> %t.err
 // RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-VERSION-IOS5 %s
 // CHECK-VERSION-IOS5: invalid iOS deployment version '-miphoneos-version-min=11.0'
 
 // RUN: %clang -target i386-apple-darwin -mios-simulator-version-min=11.0 -c -### %s 2> %t.err
 // RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-VERSION-IOS6 %s
 // CHECK-VERSION-IOS6: invalid iOS deployment version '-mios-simulator-version-min=11.0'
 
-// RUN: %clang -target armv7-apple-ios11.1 -c -### %s 2>&1 | \
+// RUN: %clang -target armv7-apple-ios10.99.99 -c -### %s 2>&1 | \
 // RUN: FileCheck --check-prefix=CHECK-VERSION-IOS7 %s
-// RUN: %clang -target armv7-apple-ios9 -Wno-missing-sysroot -isysroot SDKs/iPhoneOS11.0.sdk -c -### %s 2>&1 | \
+// RUN: %clang -target armv7-apple-ios -Wno-missing-sysroot -isysroot SDKs/iPhoneOS11.0.sdk -c -### %s 2>&1 | \
 // RUN: FileCheck --check-prefix=CHECK-VERSION-IOS7 %s
 // CHECK-VERSION-IOS7: thumbv7-apple-ios10.99.99
 
@@ -98,33 +102,33 @@
 // RUN:   %clang -target i386-apple-darwin9 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX5 %s
 // RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 IPHONEOS_DEPLOYMENT_TARGET=2.0 \
-// RUN:   %clang -target armv6-apple-darwin9 -c %s -### 2>&1 | \
+// RUN:   %clang -target armv6-apple-darwin -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-IOS2 %s
 
 // RUN: env MACOSX_DEPLOYMENT_TARGET=10.4.10 \
-// RUN:   %clang -target i386-apple-darwin9 -c %s -### 2>&1 | \
+// RUN:   %clang -target i386-apple-darwin -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX49 %s
 // CHECK-VERSION-OSX49: "i386-apple-macosx10.4.10"
 // RUN: env IPHONEOS_DEPLOYMENT_TARGET=2.3.1 \
-// RUN:   %clang -target armv6-apple-darwin9 -c %s -### 2>&1 | \
+// RUN:   %clang -target armv6-apple-darwin -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-IOS231 %s
 // CHECK-VERSION-IOS231: "armv6k-apple-ios2.3.1"
 
 // RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 TVOS_DEPLOYMENT_TARGET=8.3.1 \
-// RUN:   %clang -target armv7-apple-darwin9 -c %s -### 2>&1 | \
+// RUN:   %clang -target armv7-apple-darwin -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-TVOS %s
 // CHECK-VERSION-TVOS: "thumbv7-apple-tvos8.3.1"
 // RUN: env TVOS_DEPLOYMENT_TARGET=8.3.1 \
-// RUN:   %clang -target i386-apple-darwin9 -c %s -### 2>&1 | \
+// RUN:   %clang -target i386-apple-darwin -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-TVOSSIM %s
 // CHECK-VERSION-TVOSSIM: "i386-apple-tvos8.3.1-simulator"
 
 // RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 WATCHOS_DEPLOYMENT_TARGET=2.0 \
-// RUN:   %clang -target armv7-apple-darwin9 -c %s -### 2>&1 | \
+// RUN:   %clang -target armv7-apple-darwin -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-WATCHOS %s
 // CHECK-VERSION-WATCHOS: "thumbv7-apple-watchos2.0.0"
 // RUN: env WATCHOS_DEPLOYMENT_TARGET=2.0 \
-// RUN:   %clang -target i386-apple-darwin9 -c %s -### 2>&1 | \
+// RUN:   %clang -target i386-apple-darwin -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-WATCHOSSIM %s
 // CHECK-VERSION-WATCHOSSIM: "i386-apple-watchos2.0.0-simulator"
 
@@ -139,3 +143,66 @@
 // RUN: %clang -target x86_64-apple-watchos4.0 -c %s -### 2>&1 | \
 // RUN: FileCheck --check-prefix=CHECK-VERSION-WATCHOS-TARGET %s
 // CHECK-VERSION-WATCHOS-TARGET: "x86_64-apple-watchos4.0.0-simulator"
+
+
+// Target can specify the OS version:
+
+// RUN: %clang -target x86_64-apple-darwin14 -c %s -### 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-VERSION-TMAC1 %s
+// CHECK-VERSION-TMAC1: "x86_64-apple-macosx10.10.0"
+
+// RUN: %clang -target 

[PATCH] D40997: [driver] Take target

2017-12-07 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman abandoned this revision.
arphaman added a comment.

Sorry, accidental Return. Will close and reopen.


Repository:
  rC Clang

https://reviews.llvm.org/D40997



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


[PATCH] D40997: [driver] Take target

2017-12-07 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
Herald added a subscriber: javed.absar.

Repository:
  rC Clang

https://reviews.llvm.org/D40997

Files:
  lib/Driver/ToolChains/Darwin.cpp
  test/Driver/appletvos-version-min.c
  test/Driver/darwin-multiarch-arm.c
  test/Driver/darwin-stdlib.cpp
  test/Driver/darwin-version.c

Index: test/Driver/darwin-version.c
===
--- test/Driver/darwin-version.c
+++ test/Driver/darwin-version.c
@@ -12,21 +12,25 @@
 // CHECK-VERSION-IOS3: "armv6k-apple-ios3.0.0"
 
 // RUN: env IPHONEOS_DEPLOYMENT_TARGET=11.0 \
-// RUN:   %clang -target armv7-apple-ios9.0 -c -### %s 2> %t.err
+// RUN:   %clang -target armv7-apple-ios -c -### %s 2> %t.err
 // RUN:   FileCheck --input-file=%t.err --check-prefix=CHECK-VERSION-IOS4 %s
 // CHECK-VERSION-IOS4: invalid iOS deployment version 'IPHONEOS_DEPLOYMENT_TARGET=11.0'
 
+// RUN: %clang -target armv7-apple-ios11 -c -### %s 2> %t.err
+// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-VERSION-IOS41 %s
+// CHECK-VERSION-IOS41: invalid iOS deployment version 'ios11.0.0'
+
 // RUN: %clang -target armv7-apple-ios9.0 -miphoneos-version-min=11.0 -c -### %s 2> %t.err
 // RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-VERSION-IOS5 %s
 // CHECK-VERSION-IOS5: invalid iOS deployment version '-miphoneos-version-min=11.0'
 
 // RUN: %clang -target i386-apple-darwin -mios-simulator-version-min=11.0 -c -### %s 2> %t.err
 // RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-VERSION-IOS6 %s
 // CHECK-VERSION-IOS6: invalid iOS deployment version '-mios-simulator-version-min=11.0'
 
-// RUN: %clang -target armv7-apple-ios11.1 -c -### %s 2>&1 | \
+// RUN: %clang -target armv7-apple-ios10.99.99 -c -### %s 2>&1 | \
 // RUN: FileCheck --check-prefix=CHECK-VERSION-IOS7 %s
-// RUN: %clang -target armv7-apple-ios9 -Wno-missing-sysroot -isysroot SDKs/iPhoneOS11.0.sdk -c -### %s 2>&1 | \
+// RUN: %clang -target armv7-apple-ios -Wno-missing-sysroot -isysroot SDKs/iPhoneOS11.0.sdk -c -### %s 2>&1 | \
 // RUN: FileCheck --check-prefix=CHECK-VERSION-IOS7 %s
 // CHECK-VERSION-IOS7: thumbv7-apple-ios10.99.99
 
@@ -98,33 +102,33 @@
 // RUN:   %clang -target i386-apple-darwin9 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX5 %s
 // RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 IPHONEOS_DEPLOYMENT_TARGET=2.0 \
-// RUN:   %clang -target armv6-apple-darwin9 -c %s -### 2>&1 | \
+// RUN:   %clang -target armv6-apple-darwin -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-IOS2 %s
 
 // RUN: env MACOSX_DEPLOYMENT_TARGET=10.4.10 \
-// RUN:   %clang -target i386-apple-darwin9 -c %s -### 2>&1 | \
+// RUN:   %clang -target i386-apple-darwin -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX49 %s
 // CHECK-VERSION-OSX49: "i386-apple-macosx10.4.10"
 // RUN: env IPHONEOS_DEPLOYMENT_TARGET=2.3.1 \
-// RUN:   %clang -target armv6-apple-darwin9 -c %s -### 2>&1 | \
+// RUN:   %clang -target armv6-apple-darwin -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-IOS231 %s
 // CHECK-VERSION-IOS231: "armv6k-apple-ios2.3.1"
 
 // RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 TVOS_DEPLOYMENT_TARGET=8.3.1 \
-// RUN:   %clang -target armv7-apple-darwin9 -c %s -### 2>&1 | \
+// RUN:   %clang -target armv7-apple-darwin -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-TVOS %s
 // CHECK-VERSION-TVOS: "thumbv7-apple-tvos8.3.1"
 // RUN: env TVOS_DEPLOYMENT_TARGET=8.3.1 \
-// RUN:   %clang -target i386-apple-darwin9 -c %s -### 2>&1 | \
+// RUN:   %clang -target i386-apple-darwin -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-TVOSSIM %s
 // CHECK-VERSION-TVOSSIM: "i386-apple-tvos8.3.1-simulator"
 
 // RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 WATCHOS_DEPLOYMENT_TARGET=2.0 \
-// RUN:   %clang -target armv7-apple-darwin9 -c %s -### 2>&1 | \
+// RUN:   %clang -target armv7-apple-darwin -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-WATCHOS %s
 // CHECK-VERSION-WATCHOS: "thumbv7-apple-watchos2.0.0"
 // RUN: env WATCHOS_DEPLOYMENT_TARGET=2.0 \
-// RUN:   %clang -target i386-apple-darwin9 -c %s -### 2>&1 | \
+// RUN:   %clang -target i386-apple-darwin -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-WATCHOSSIM %s
 // CHECK-VERSION-WATCHOSSIM: "i386-apple-watchos2.0.0-simulator"
 
@@ -139,3 +143,66 @@
 // RUN: %clang -target x86_64-apple-watchos4.0 -c %s -### 2>&1 | \
 // RUN: FileCheck --check-prefix=CHECK-VERSION-WATCHOS-TARGET %s
 // CHECK-VERSION-WATCHOS-TARGET: "x86_64-apple-watchos4.0.0-simulator"
+
+
+// Target can specify the OS version:
+
+// RUN: %clang -target x86_64-apple-darwin14 -c %s -### 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-VERSION-TMAC1 %s
+// CHECK-VERSION-TMAC1: "x86_64-apple-macosx10.10.0"
+
+// RUN: %clang -target x86_64-apple-macos10.11.2 -c %s -### 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-VERSION-TMAC2 %s
+// CHECK-VERSION-TMAC2: 

[PATCH] D40996: Add --no-cuda-version-check in unknown-std.cpp

2017-12-07 Thread Kelvin Li via Phabricator via cfe-commits
kkwli0 created this revision.

This unit test fails on the system that has CUDA Toolkit 9.0 installed.  And 
CUDA 9 does not support GPU arch sm_20.  It results in the following error.

  clang-6.0: error: GPU arch sm_20 is supported by CUDA versions between 7.0 
and 8.0 (inclusive), but installation at /usr/local/cuda is 9.0.  Use 
--cuda-path to specify a different CUDA install, pass a different GPU arch with 
--cuda-gpu-arch, or pass --no-cuda-version-check.


https://reviews.llvm.org/D40996

Files:
  test/Driver/unknown-std.cpp


Index: test/Driver/unknown-std.cpp
===
--- test/Driver/unknown-std.cpp
+++ test/Driver/unknown-std.cpp
@@ -4,7 +4,7 @@
 
 // RUN: not %clang %s -std=foobar -c 2>&1 | FileCheck --match-full-lines %s
 // RUN: not %clang -x objective-c++ %s -std=foobar -c 2>&1 | FileCheck 
--match-full-lines %s
-// RUN: not %clang -x cuda -nocudainc -nocudalib %s -std=foobar -c 2>&1 | 
FileCheck --match-full-lines --check-prefix=CHECK --check-prefix=CUDA %s
+// RUN: not %clang -x cuda -nocudainc -nocudalib --no-cuda-version-check %s 
-std=foobar -c 2>&1 | FileCheck --match-full-lines --check-prefix=CHECK 
--check-prefix=CUDA %s
 
 // CHECK: error: invalid value 'foobar' in '-std=foobar'
 // CHECK-NEXT: note: use 'c++98' or 'c++03' for 'ISO C++ 1998 with amendments' 
standard


Index: test/Driver/unknown-std.cpp
===
--- test/Driver/unknown-std.cpp
+++ test/Driver/unknown-std.cpp
@@ -4,7 +4,7 @@
 
 // RUN: not %clang %s -std=foobar -c 2>&1 | FileCheck --match-full-lines %s
 // RUN: not %clang -x objective-c++ %s -std=foobar -c 2>&1 | FileCheck --match-full-lines %s
-// RUN: not %clang -x cuda -nocudainc -nocudalib %s -std=foobar -c 2>&1 | FileCheck --match-full-lines --check-prefix=CHECK --check-prefix=CUDA %s
+// RUN: not %clang -x cuda -nocudainc -nocudalib --no-cuda-version-check %s -std=foobar -c 2>&1 | FileCheck --match-full-lines --check-prefix=CHECK --check-prefix=CUDA %s
 
 // CHECK: error: invalid value 'foobar' in '-std=foobar'
 // CHECK-NEXT: note: use 'c++98' or 'c++03' for 'ISO C++ 1998 with amendments' standard
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r320132 - [Blocks] Inherit sanitizer options from parent decl

2017-12-07 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Thu Dec  7 18:47:58 2017
New Revision: 320132

URL: http://llvm.org/viewvc/llvm-project?rev=320132=rev
Log:
[Blocks] Inherit sanitizer options from parent decl

There is no way to apply sanitizer suppressions to ObjC blocks. A
reasonable default is to have blocks inherit their parent's sanitizer
options.

rdar://32769634

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

Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/test/CodeGenObjC/no-sanitize.m

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=320132=320131=320132=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Thu Dec  7 18:47:58 2017
@@ -784,7 +784,9 @@ llvm::Value *CodeGenFunction::EmitBlockL
   8);
   // Using the computed layout, generate the actual block function.
   bool isLambdaConv = blockInfo.getBlockDecl()->isConversionFromLambda();
-  auto *InvokeFn = CodeGenFunction(CGM, true).GenerateBlockFunction(
+  CodeGenFunction BlockCGF{CGM, true};
+  BlockCGF.SanOpts = SanOpts;
+  auto *InvokeFn = BlockCGF.GenerateBlockFunction(
   CurGD, blockInfo, LocalDeclMap, isLambdaConv, blockInfo.CanBeGlobal);
   if (InvokeF)
 *InvokeF = InvokeFn;

Modified: cfe/trunk/test/CodeGenObjC/no-sanitize.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/no-sanitize.m?rev=320132=320131=320132=diff
==
--- cfe/trunk/test/CodeGenObjC/no-sanitize.m (original)
+++ cfe/trunk/test/CodeGenObjC/no-sanitize.m Thu Dec  7 18:47:58 2017
@@ -1,8 +1,9 @@
-// RUN: %clang_cc1 %s -emit-llvm -fsanitize=address -o - | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=address -fblocks -o - | FileCheck 
%s
 
 @interface I0 @end
 @implementation I0
 // CHECK-NOT: sanitize_address
 - (void) im0: (int) a0 __attribute__((no_sanitize("address"))) {
+  int (^blockName)() = ^int() { return 0; };
 }
 @end


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


[PATCH] D40668: [Blocks] Inherit sanitizer options from parent decl

2017-12-07 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC320132: [Blocks] Inherit sanitizer options from parent decl 
(authored by vedantk).

Repository:
  rC Clang

https://reviews.llvm.org/D40668

Files:
  lib/CodeGen/CGBlocks.cpp
  test/CodeGenObjC/no-sanitize.m


Index: lib/CodeGen/CGBlocks.cpp
===
--- lib/CodeGen/CGBlocks.cpp
+++ lib/CodeGen/CGBlocks.cpp
@@ -784,7 +784,9 @@
   8);
   // Using the computed layout, generate the actual block function.
   bool isLambdaConv = blockInfo.getBlockDecl()->isConversionFromLambda();
-  auto *InvokeFn = CodeGenFunction(CGM, true).GenerateBlockFunction(
+  CodeGenFunction BlockCGF{CGM, true};
+  BlockCGF.SanOpts = SanOpts;
+  auto *InvokeFn = BlockCGF.GenerateBlockFunction(
   CurGD, blockInfo, LocalDeclMap, isLambdaConv, blockInfo.CanBeGlobal);
   if (InvokeF)
 *InvokeF = InvokeFn;
Index: test/CodeGenObjC/no-sanitize.m
===
--- test/CodeGenObjC/no-sanitize.m
+++ test/CodeGenObjC/no-sanitize.m
@@ -1,8 +1,9 @@
-// RUN: %clang_cc1 %s -emit-llvm -fsanitize=address -o - | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=address -fblocks -o - | FileCheck 
%s
 
 @interface I0 @end
 @implementation I0
 // CHECK-NOT: sanitize_address
 - (void) im0: (int) a0 __attribute__((no_sanitize("address"))) {
+  int (^blockName)() = ^int() { return 0; };
 }
 @end


Index: lib/CodeGen/CGBlocks.cpp
===
--- lib/CodeGen/CGBlocks.cpp
+++ lib/CodeGen/CGBlocks.cpp
@@ -784,7 +784,9 @@
   8);
   // Using the computed layout, generate the actual block function.
   bool isLambdaConv = blockInfo.getBlockDecl()->isConversionFromLambda();
-  auto *InvokeFn = CodeGenFunction(CGM, true).GenerateBlockFunction(
+  CodeGenFunction BlockCGF{CGM, true};
+  BlockCGF.SanOpts = SanOpts;
+  auto *InvokeFn = BlockCGF.GenerateBlockFunction(
   CurGD, blockInfo, LocalDeclMap, isLambdaConv, blockInfo.CanBeGlobal);
   if (InvokeF)
 *InvokeF = InvokeFn;
Index: test/CodeGenObjC/no-sanitize.m
===
--- test/CodeGenObjC/no-sanitize.m
+++ test/CodeGenObjC/no-sanitize.m
@@ -1,8 +1,9 @@
-// RUN: %clang_cc1 %s -emit-llvm -fsanitize=address -o - | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=address -fblocks -o - | FileCheck %s
 
 @interface I0 @end
 @implementation I0
 // CHECK-NOT: sanitize_address
 - (void) im0: (int) a0 __attribute__((no_sanitize("address"))) {
+  int (^blockName)() = ^int() { return 0; };
 }
 @end
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39694: [VerifyDiagnosticConsumer] support -verify=

2017-12-07 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny updated this revision to Diff 126086.
jdenny added a comment.

This update does the following:

1. Fixes the line wrapping that Richard pointed out.

2. Converts from std::vector to std::set for more efficient prefix lookup.

3. Grows a dependence on https://reviews.llvm.org/D40995 (which is a small 
patch) because the test case here now exercises multiple invalid prefixes in 
one command line.

4. Rebases onto a more recent master.  One of the test cases rewritten here 
recently changed significantly.


https://reviews.llvm.org/D39694

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Basic/DiagnosticOptions.h
  include/clang/Driver/CC1Options.td
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/VerifyDiagnosticConsumer.cpp
  test/Frontend/diagnostics-order.c
  test/Frontend/verify-prefixes.c
  test/Sema/tautological-constant-compare.c
  test/Sema/tautological-constant-enum-compare.c
  test/Sema/tautological-unsigned-enum-zero-compare.c
  test/Sema/tautological-unsigned-enum-zero-compare.cpp
  test/Sema/tautological-unsigned-zero-compare.c

Index: test/Sema/tautological-unsigned-zero-compare.c
===
--- test/Sema/tautological-unsigned-zero-compare.c
+++ test/Sema/tautological-unsigned-zero-compare.c
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -DTEST -verify %s
-// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-zero-compare -verify %s
-// RUN: %clang_cc1 -fsyntax-only -DTEST -verify -x c++ %s
-// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-zero-compare -verify -x c++ %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-zero-compare -verify=silence %s
+// RUN: %clang_cc1 -fsyntax-only -verify -x c++ %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-zero-compare -verify=silence -x c++ %s
 
 unsigned uvalue(void);
 signed int svalue(void);
@@ -13,13 +13,8 @@
 void TFunc() {
   // Make sure that we do warn for normal variables in template functions !
   unsigned char c = svalue();
-#ifdef TEST
   if (c < 0) // expected-warning {{comparison of unsigned expression < 0 is always false}}
   return;
-#else
-  if (c < 0)
-  return;
-#endif
 
   if (c < macro(0))
   return;
@@ -39,7 +34,8 @@
 
   unsigned un = uvalue();
 
-#ifdef TEST
+  // silence-no-diagnostics
+
   if (un == 0)
   return 0;
   if (un != 0)
@@ -91,65 +87,10 @@
   return 0;
   if (0UL >= un)
   return 0;
-#else
-// expected-no-diagnostics
-  if (un == 0)
-  return 0;
-  if (un != 0)
-  return 0;
-  if (un < 0)
-  return 0;
-  if (un <= 0)
-  return 0;
-  if (un > 0)
-  return 0;
-  if (un >= 0)
-  return 0;
-
-  if (0 == un)
-  return 0;
-  if (0 != un)
-  return 0;
-  if (0 < un)
-  return 0;
-  if (0 <= un)
-  return 0;
-  if (0 > un)
-  return 0;
-  if (0 >= un)
-  return 0;
-
-  if (un == 0UL)
-  return 0;
-  if (un != 0UL)
-  return 0;
-  if (un < 0UL)
-  return 0;
-  if (un <= 0UL)
-  return 0;
-  if (un > 0UL)
-  return 0;
-  if (un >= 0UL)
-  return 0;
-
-  if (0UL == un)
-  return 0;
-  if (0UL != un)
-  return 0;
-  if (0UL < un)
-  return 0;
-  if (0UL <= un)
-  return 0;
-  if (0UL > un)
-  return 0;
-  if (0UL >= un)
-  return 0;
-#endif
 
 
   signed int a = svalue();
 
-#ifdef TEST
   if (a == 0)
   return 0;
   if (a != 0)
@@ -201,60 +142,6 @@
   return 0;
   if (0UL >= a)
   return 0;
-#else
-// expected-no-diagnostics
-  if (a == 0)
-  return 0;
-  if (a != 0)
-  return 0;
-  if (a < 0)
-  return 0;
-  if (a <= 0)
-  return 0;
-  if (a > 0)
-  return 0;
-  if (a >= 0)
-  return 0;
-
-  if (0 == a)
-  return 0;
-  if (0 != a)
-  return 0;
-  if (0 < a)
-  return 0;
-  if (0 <= a)
-  return 0;
-  if (0 > a)
-  return 0;
-  if (0 >= a)
-  return 0;
-
-  if (a == 0UL)
-  return 0;
-  if (a != 0UL)
-  return 0;
-  if (a < 0UL)
-  return 0;
-  if (a <= 0UL)
-  return 0;
-  if (a > 0UL)
-  return 0;
-  if (a >= 0UL)
-  return 0;
-
-  if (0UL == a)
-  return 0;
-  if (0UL != a)
-  return 0;
-  if (0UL < a)
-  return 0;
-  if (0UL <= a)
-  return 0;
-  if (0UL > a)
-  return 0;
-  if (0UL >= a)
-  return 0;
-#endif
 
 
   float fl = 0;
Index: test/Sema/tautological-unsigned-enum-zero-compare.cpp
===
--- test/Sema/tautological-unsigned-enum-zero-compare.cpp
+++ test/Sema/tautological-unsigned-enum-zero-compare.cpp
@@ -1,6 +1,12 @@
-// RUN: %clang_cc1 -std=c++11 -triple=x86_64-pc-linux-gnu -fsyntax-only -DUNSIGNED -verify %s
-// RUN: %clang_cc1 -std=c++11 -triple=x86_64-pc-win32 -fsyntax-only -DSIGNED -verify %s
-// RUN: %clang_cc1 -std=c++11 -triple=x86_64-pc-win32 -fsyntax-only -DSILENCE -Wno-tautological-unsigned-enum-zero-compare -verify %s
+// RUN: %clang_cc1 

[PATCH] D40668: [Blocks] Inherit sanitizer options from parent decl

2017-12-07 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

In https://reviews.llvm.org/D40668#949096, @zaks.anna wrote:

> LGTM.
>
> Thanks!
>
> I was wondering if there are other places where this propagation needs to be 
> added, for example, other calls to GenerateBlockFunction.


Thanks for the review :). Yes there is one other site which calls 
GenerateBlockFunction, but that is done in CodeGenModule, where there are no 
SanOpts to inherit *except* those from the CGM, which is already the default 
behavior. (You can apply suppressions to those by specifying "_block_invoke*" 
in your blacklist.) So I think this is all that's needed.


https://reviews.llvm.org/D40668



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


r320131 - Add a test that the __STDC_VERSION__ macro reports the correct value for -std=c17.

2017-12-07 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Dec  7 18:39:26 2017
New Revision: 320131

URL: http://llvm.org/viewvc/llvm-project?rev=320131=rev
Log:
Add a test that the __STDC_VERSION__ macro reports the correct value for 
-std=c17.

Added:
cfe/trunk/test/Preprocessor/c17.c

Added: cfe/trunk/test/Preprocessor/c17.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/c17.c?rev=320131=auto
==
--- cfe/trunk/test/Preprocessor/c17.c (added)
+++ cfe/trunk/test/Preprocessor/c17.c Thu Dec  7 18:39:26 2017
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c17 %s
+// expected-no-diagnostics
+
+_Static_assert(__STDC_VERSION__ == 201710L, "Incorrect __STDC_VERSION__");


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


[PATCH] D40995: [TextDiagnosticBuffer] Fix diagnostic note emission order.

2017-12-07 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny created this revision.

The frontend currently groups diagnostics from the command line
according to diagnostic level, but that places all notes last.  Fix
that by emitting such diagnostics in the order they were generated.


https://reviews.llvm.org/D40995

Files:
  include/clang/Frontend/TextDiagnosticBuffer.h
  lib/Frontend/TextDiagnosticBuffer.cpp
  test/Frontend/diagnostics-order.c


Index: test/Frontend/diagnostics-order.c
===
--- /dev/null
+++ test/Frontend/diagnostics-order.c
@@ -0,0 +1,10 @@
+// Make sure a note stays with its associated command-line argument diagnostic.
+// Previously, these diagnostics were grouped by diagnostic level with all
+// notes last.
+//
+// RUN: not %clang_cc1 -O999 -std=bogus %s 2> %t
+// RUN: FileCheck < %t %s
+//
+// CHECK: warning: optimization level '-O999' is not supported
+// CHECK-NEXT: error: invalid value 'bogus' in '-std=bogus'
+// CHECK-NEXT: note: use {{.*}} for {{.*}} standard
Index: lib/Frontend/TextDiagnosticBuffer.cpp
===
--- lib/Frontend/TextDiagnosticBuffer.cpp
+++ lib/Frontend/TextDiagnosticBuffer.cpp
@@ -30,34 +30,45 @@
   default: llvm_unreachable(
  "Diagnostic not handled during diagnostic 
buffering!");
   case DiagnosticsEngine::Note:
+All.emplace_back(Level, Notes.size());
 Notes.emplace_back(Info.getLocation(), Buf.str());
 break;
   case DiagnosticsEngine::Warning:
+All.emplace_back(Level, Warnings.size());
 Warnings.emplace_back(Info.getLocation(), Buf.str());
 break;
   case DiagnosticsEngine::Remark:
+All.emplace_back(Level, Remarks.size());
 Remarks.emplace_back(Info.getLocation(), Buf.str());
 break;
   case DiagnosticsEngine::Error:
   case DiagnosticsEngine::Fatal:
+All.emplace_back(Level, Errors.size());
 Errors.emplace_back(Info.getLocation(), Buf.str());
 break;
   }
 }
 
 void TextDiagnosticBuffer::FlushDiagnostics(DiagnosticsEngine ) const {
-  // FIXME: Flush the diagnostics in order.
-  for (const_iterator it = err_begin(), ie = err_end(); it != ie; ++it)
-Diags.Report(Diags.getCustomDiagID(DiagnosticsEngine::Error, "%0"))
-<< it->second;
-  for (const_iterator it = warn_begin(), ie = warn_end(); it != ie; ++it)
-Diags.Report(Diags.getCustomDiagID(DiagnosticsEngine::Warning, "%0"))
-<< it->second;
-  for (const_iterator it = remark_begin(), ie = remark_end(); it != ie; ++it)
-Diags.Report(Diags.getCustomDiagID(DiagnosticsEngine::Remark, "%0"))
-<< it->second;
-  for (const_iterator it = note_begin(), ie = note_end(); it != ie; ++it)
-Diags.Report(Diags.getCustomDiagID(DiagnosticsEngine::Note, "%0"))
-<< it->second;
+  for (auto it = All.begin(), ie = All.end(); it != ie; ++it) {
+auto Diag = Diags.Report(Diags.getCustomDiagID(it->first, "%0"));
+switch (it->first) {
+default: llvm_unreachable(
+   "Diagnostic not handled during diagnostic 
flushing!");
+case DiagnosticsEngine::Note:
+  Diag << Notes[it->second].second;
+  break;
+case DiagnosticsEngine::Warning:
+  Diag << Warnings[it->second].second;
+  break;
+case DiagnosticsEngine::Remark:
+  Diag << Remarks[it->second].second;
+  break;
+case DiagnosticsEngine::Error:
+case DiagnosticsEngine::Fatal:
+  Diag << Errors[it->second].second;
+  break;
+}
+  }
 }
 
Index: include/clang/Frontend/TextDiagnosticBuffer.h
===
--- include/clang/Frontend/TextDiagnosticBuffer.h
+++ include/clang/Frontend/TextDiagnosticBuffer.h
@@ -29,6 +29,11 @@
   typedef DiagList::const_iterator const_iterator;
 private:
   DiagList Errors, Warnings, Remarks, Notes;
+  /// All - All diagnostics in the order in which they were generated.  That
+  /// order likely doesn't correspond to user input order, but it at least
+  /// keeps notes in the right places.  Each pair in the vector is a diagnostic
+  /// level and an index into the corresponding DiagList above.
+  std::vector> All;
 public:
   const_iterator err_begin() const  { return Errors.begin(); }
   const_iterator err_end() const{ return Errors.end(); }


Index: test/Frontend/diagnostics-order.c
===
--- /dev/null
+++ test/Frontend/diagnostics-order.c
@@ -0,0 +1,10 @@
+// Make sure a note stays with its associated command-line argument diagnostic.
+// Previously, these diagnostics were grouped by diagnostic level with all
+// notes last.
+//
+// RUN: not %clang_cc1 -O999 -std=bogus %s 2> %t
+// RUN: FileCheck < %t %s
+//
+// CHECK: warning: optimization level '-O999' is not supported
+// CHECK-NEXT: error: invalid value 'bogus' in '-std=bogus'
+// CHECK-NEXT: note: use {{.*}} for {{.*}} standard
Index: 

[PATCH] D39694: [VerifyDiagnosticConsumer] support -verify=

2017-12-07 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

In https://reviews.llvm.org/D39694#949066, @rsmith wrote:

> I've not done a detailed review of the string manipulation here, but this 
> looks like a great feature, thanks!


Hi Richard.  Thanks for your feedback.  I'll fix the line wrapping you pointed 
out.


https://reviews.llvm.org/D39694



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


[PATCH] D39694: [VerifyDiagnosticConsumer] support -verify=

2017-12-07 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny marked 13 inline comments as done.
jdenny added a comment.

I marked the comments related to Hal's suggestions as done to avoid confusion 
for future reviews.  I'm not used to using this sort of tool for reviews.  
Hopefully it's appropriate for the author to do that rather than the reviewer.


https://reviews.llvm.org/D39694



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


[PATCH] D40668: [Blocks] Inherit sanitizer options from parent decl

2017-12-07 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna accepted this revision.
zaks.anna added a comment.
This revision is now accepted and ready to land.

LGTM.

Thanks!

I was wondering if there are other places where this propagation needs to be 
added, for example, other calls to GenerateBlockFunction.


https://reviews.llvm.org/D40668



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


r320128 - [ubsan] Use pass_object_size info in bounds checks

2017-12-07 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Thu Dec  7 17:51:47 2017
New Revision: 320128

URL: http://llvm.org/viewvc/llvm-project?rev=320128=rev
Log:
[ubsan] Use pass_object_size info in bounds checks

Teach UBSan's bounds check to opportunistically use pass_object_size
information to check array accesses.

rdar://33272922

Added:
cfe/trunk/test/CodeGen/ubsan-pass-object-size.c
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=320128=320127=320128=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Dec  7 17:51:47 2017
@@ -814,6 +814,53 @@ static bool isFlexibleArrayMemberExpr(co
   return false;
 }
 
+llvm::Value *CodeGenFunction::LoadPassedObjectSize(const Expr *E,
+   QualType EltTy) {
+  ASTContext  = getContext();
+  uint64_t EltSize = C.getTypeSizeInChars(EltTy).getQuantity();
+  if (!EltSize)
+return nullptr;
+
+  auto *ArrayDeclRef = dyn_cast(E->IgnoreParenImpCasts());
+  if (!ArrayDeclRef)
+return nullptr;
+
+  auto *ParamDecl = dyn_cast(ArrayDeclRef->getDecl());
+  if (!ParamDecl)
+return nullptr;
+
+  // Arrays don't have pass_object_size attributes, but if they have a constant
+  // size modifier it's the array size (C99 6.5.7.2p1).
+  if (auto *DecayedArrayTy = dyn_cast(ParamDecl->getType()))
+if (auto *ArrayTy =
+dyn_cast(DecayedArrayTy->getOriginalType()))
+  return llvm::ConstantInt::get(SizeTy,
+ArrayTy->getSize().getLimitedValue());
+
+  auto *POSAttr = ParamDecl->getAttr();
+  if (!POSAttr)
+return nullptr;
+
+  // Don't load the size if it's a lower bound.
+  int POSType = POSAttr->getType();
+  if (POSType != 0 && POSType != 1)
+return nullptr;
+
+  // Find the implicit size parameter.
+  auto PassedSizeIt = SizeArguments.find(ParamDecl);
+  if (PassedSizeIt == SizeArguments.end())
+return nullptr;
+
+  const ImplicitParamDecl *PassedSizeDecl = PassedSizeIt->second;
+  assert(LocalDeclMap.count(PassedSizeDecl) && "Passed size not loadable");
+  Address AddrOfSize = LocalDeclMap.find(PassedSizeDecl)->second;
+  llvm::Value *SizeInBytes = EmitLoadOfScalar(AddrOfSize, /*Volatile=*/false,
+  C.getSizeType(), 
E->getExprLoc());
+  llvm::Value *SizeOfElement =
+  llvm::ConstantInt::get(SizeInBytes->getType(), EltSize);
+  return Builder.CreateUDiv(SizeInBytes, SizeOfElement);
+}
+
 /// If Base is known to point to the start of an array, return the length of
 /// that array. Return 0 if the length cannot be determined.
 static llvm::Value *getArrayIndexingBound(
@@ -835,9 +882,16 @@ static llvm::Value *getArrayIndexingBoun
 return CGF.Builder.getInt(CAT->getSize());
   else if (const auto *VAT = dyn_cast(AT))
 return CGF.getVLASize(VAT).first;
+  // Ignore pass_object_size here. It's not applicable on decayed pointers.
 }
   }
 
+  QualType EltTy{Base->getType()->getPointeeOrArrayElementType(), 0};
+  if (llvm::Value *POS = CGF.LoadPassedObjectSize(Base, EltTy)) {
+IndexedType = Base->getType();
+return POS;
+  }
+
   return nullptr;
 }
 

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=320128=320127=320128=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Thu Dec  7 17:51:47 2017
@@ -3927,6 +3927,11 @@ public:
LValueBaseInfo *BaseInfo = nullptr,
TBAAAccessInfo *TBAAInfo = nullptr);
 
+  /// If \p E references a parameter with pass_object_size info or a constant
+  /// array size modifier, emit the object size divided by the size of \p 
EltTy.
+  /// Otherwise return null.
+  llvm::Value *LoadPassedObjectSize(const Expr *E, QualType EltTy);
+
   void EmitSanitizerStatReport(llvm::SanitizerStatKind SSK);
 
 private:

Added: cfe/trunk/test/CodeGen/ubsan-pass-object-size.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ubsan-pass-object-size.c?rev=320128=auto
==
--- cfe/trunk/test/CodeGen/ubsan-pass-object-size.c (added)
+++ cfe/trunk/test/CodeGen/ubsan-pass-object-size.c Thu Dec  7 17:51:47 2017
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 %s -emit-llvm -w -triple x86_64-apple-darwin10 
-fsanitize=array-bounds -o - | FileCheck %s
+
+// CHECK-LABEL: define i32 @foo(
+int foo(int *const p __attribute__((pass_object_size(0))), int n) {
+  int x = (p)[n];
+
+  // CHECK: [[SIZE_ALLOCA:%.*]] = alloca i64, align 8
+  // CHECK: store i64 %{{.*}}, i64* 

Re: r315996 - [CMake][OpenMP] Customize default offloading arch

2017-12-07 Thread Jonas Hahnfeld via cfe-commits

Am 2017-12-07 20:34, schrieb Jonas Hahnfeld via cfe-commits:

Hi Ahmed,

Am 2017-12-07 19:57, schrieb Ahmed Bougacha:

Hi Jonas,

On Tue, Oct 17, 2017 at 6:37 AM, Jonas Hahnfeld via cfe-commits
 wrote:

Author: hahnfeld
Date: Tue Oct 17 06:37:36 2017
New Revision: 315996

URL: http://llvm.org/viewvc/llvm-project?rev=315996=rev
Log:
[CMake][OpenMP] Customize default offloading arch

For the shuffle instructions in reductions we need at least sm_30
but the user may want to customize the default architecture.

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

Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/include/clang/Config/config.h.cmake
cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
cfe/trunk/lib/Driver/ToolChains/Cuda.h

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=315996=315995=315996=diff

==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Tue Oct 17 06:37:36 2017
@@ -235,6 +235,17 @@ endif()
 set(CLANG_DEFAULT_OPENMP_RUNTIME "libomp" CACHE STRING
   "Default OpenMP runtime used by -fopenmp.")

+# OpenMP offloading requires at least sm_30 because we use shuffle 
instructions

+# to generate efficient code for reductions.
+set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH "sm_30" CACHE STRING
+  "Default architecture for OpenMP offloading to Nvidia GPUs.")
+string(REGEX MATCH "^sm_([0-9]+)$" MATCHED_ARCH 
"${CLANG_OPENMP_NVPTX_DEFAULT_ARCH}")

+if (NOT DEFINED MATCHED_ARCH OR "${CMAKE_MATCH_1}" LESS 30)
+  message(WARNING "Resetting default architecture for OpenMP 
offloading to Nvidia GPUs to sm_30")


This warning is pretty noisy and doesn't affect most people: I don't
know what it means but I get it in every cmake run.
Can we somehow restrict or disable it?


So the next line used to say

+  set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH "sm_30" CACHE STRING
+"Default architecture for OpenMP offloading to Nvidia GPUs." 
FORCE)


which should make sure that the cache is updated to a "correct" value
and you only see the warning once. That said, we have raised the
default to "sm_35" today, maybe something has gone wrong here. Let me
check that and come back to you!


Works "correctly" (at least as intended) for me: I get a warning if the 
cache has an incorrect value or the user specifies it on the command 
line. Right then the cache is updated (FORCEd set) and the warning isn't 
printed in future CMake invocations. I'm using CMake 3.5.2, maybe a 
newer version behaves differently? In that case I agree that we should 
fix this, the warning wasn't meant to annoy everyone on each 
reconfiguration!


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


Re: r315996 - [CMake][OpenMP] Customize default offloading arch

2017-12-07 Thread Jonas Hahnfeld via cfe-commits

Hi Ahmed,

Am 2017-12-07 19:57, schrieb Ahmed Bougacha:

Hi Jonas,

On Tue, Oct 17, 2017 at 6:37 AM, Jonas Hahnfeld via cfe-commits
 wrote:

Author: hahnfeld
Date: Tue Oct 17 06:37:36 2017
New Revision: 315996

URL: http://llvm.org/viewvc/llvm-project?rev=315996=rev
Log:
[CMake][OpenMP] Customize default offloading arch

For the shuffle instructions in reductions we need at least sm_30
but the user may want to customize the default architecture.

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

Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/include/clang/Config/config.h.cmake
cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
cfe/trunk/lib/Driver/ToolChains/Cuda.h

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=315996=315995=315996=diff

==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Tue Oct 17 06:37:36 2017
@@ -235,6 +235,17 @@ endif()
 set(CLANG_DEFAULT_OPENMP_RUNTIME "libomp" CACHE STRING
   "Default OpenMP runtime used by -fopenmp.")

+# OpenMP offloading requires at least sm_30 because we use shuffle 
instructions

+# to generate efficient code for reductions.
+set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH "sm_30" CACHE STRING
+  "Default architecture for OpenMP offloading to Nvidia GPUs.")
+string(REGEX MATCH "^sm_([0-9]+)$" MATCHED_ARCH 
"${CLANG_OPENMP_NVPTX_DEFAULT_ARCH}")

+if (NOT DEFINED MATCHED_ARCH OR "${CMAKE_MATCH_1}" LESS 30)
+  message(WARNING "Resetting default architecture for OpenMP 
offloading to Nvidia GPUs to sm_30")


This warning is pretty noisy and doesn't affect most people: I don't
know what it means but I get it in every cmake run.
Can we somehow restrict or disable it?


So the next line used to say

+  set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH "sm_30" CACHE STRING
+"Default architecture for OpenMP offloading to Nvidia GPUs." 
FORCE)


which should make sure that the cache is updated to a "correct" value 
and you only see the warning once. That said, we have raised the default 
to "sm_35" today, maybe something has gone wrong here. Let me check that 
and come back to you!


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


r320124 - Fold together the in-range and out-of-range portions of -Wtautological-compare.

2017-12-07 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Dec  7 17:00:27 2017
New Revision: 320124

URL: http://llvm.org/viewvc/llvm-project?rev=320124=rev
Log:
Fold together the in-range and out-of-range portions of -Wtautological-compare.

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

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=320124=320123=320124=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Dec  7 17:00:27 2017
@@ -8801,12 +8801,7 @@ static bool CheckTautologicalComparison(
 Expr *Constant, Expr *Other,
 const llvm::APSInt ,
 bool RhsConstant) {
-  // Disable warning in template instantiations
-  // and only analyze <, >, <= and >= operations.
-  if (S.inTemplateInstantiation() || !E->isRelationalOp())
-return false;
-
-  if (IsEnumConstOrFromMacro(S, Constant))
+  if (S.inTemplateInstantiation())
 return false;
 
   Expr *OriginalOther = Other;
@@ -8833,94 +8828,23 @@ static bool CheckTautologicalComparison(
   OtherRange.Width =
   std::min(Bitfield->getBitWidthValue(S.Context), OtherRange.Width);
 
-  // Check whether the constant value can be represented in OtherRange. Bail
-  // out if so; this isn't an out-of-range comparison.
+  // Determine the promoted range of the other type and see if a comparison of
+  // the constant against that range is tautological.
   PromotedRange OtherPromotedRange(OtherRange, Value.getBitWidth(),
Value.isUnsigned());
-
   auto Cmp = OtherPromotedRange.compare(Value);
-  if (Cmp != PromotedRange::Min && Cmp != PromotedRange::Max &&
-  Cmp != PromotedRange::OnlyValue)
-return false;
-
   auto Result = PromotedRange::constantValue(E->getOpcode(), Cmp, RhsConstant);
   if (!Result)
 return false;
 
-  // Should be enough for uint128 (39 decimal digits)
-  SmallString<64> PrettySourceValue;
-  llvm::raw_svector_ostream OS(PrettySourceValue);
-  OS << Value;
-
-  // FIXME: We use a somewhat different formatting for the cases involving
-  // boolean values for historical reasons. We should pick a consistent way
-  // of presenting these diagnostics.
-  if (Other->isKnownToHaveBooleanValue()) {
-S.DiagRuntimeBehavior(
-  E->getOperatorLoc(), E,
-  S.PDiag(diag::warn_tautological_bool_compare)
-  << OS.str() << classifyConstantValue(Constant)
-  << OtherT << !OtherT->isBooleanType() << *Result
-  << E->getLHS()->getSourceRange() << E->getRHS()->getSourceRange());
-return true;
-  }
-
-  unsigned Diag = (isKnownToHaveUnsignedValue(OriginalOther) && Value == 0)
-  ? (HasEnumType(OriginalOther)
- ? diag::warn_unsigned_enum_always_true_comparison
- : diag::warn_unsigned_always_true_comparison)
-  : diag::warn_tautological_constant_compare;
-
-  S.Diag(E->getOperatorLoc(), Diag)
-  << RhsConstant << OtherT << E->getOpcodeStr() << OS.str() << *Result
-  << E->getLHS()->getSourceRange() << E->getRHS()->getSourceRange();
-
-  return true;
-}
-
-static bool DiagnoseOutOfRangeComparison(Sema , BinaryOperator *E,
- Expr *Constant, Expr *Other,
- const llvm::APSInt ,
- bool RhsConstant) {
-  // Disable warning in template instantiations.
-  if (S.inTemplateInstantiation())
-return false;
-
-  Constant = Constant->IgnoreParenImpCasts();
-  Other = Other->IgnoreParenImpCasts();
-
-  // TODO: Investigate using GetExprRange() to get tighter bounds
-  // on the bit ranges.
-  QualType OtherT = Other->getType();
-  if (const auto *AT = OtherT->getAs())
-OtherT = AT->getValueType();
-  IntRange OtherRange = IntRange::forValueOfType(S.Context, OtherT);
-
-  // Whether we're treating Other as being a bool because of the form of
-  // expression despite it having another type (typically 'int' in C).
-  bool OtherIsBooleanDespiteType =
-  !OtherT->isBooleanType() && Other->isKnownToHaveBooleanValue();
-  if (OtherIsBooleanDespiteType)
-OtherRange = IntRange::forBoolType();
-
-  if (FieldDecl *Bitfield = Other->getSourceBitField())
-if (!Bitfield->getBitWidth()->isValueDependent())
-  OtherRange.Width =
-  std::min(Bitfield->getBitWidthValue(S.Context), OtherRange.Width);
-
-  // Check whether the constant value can be represented in OtherRange. Bail
-  // out if so; this isn't an out-of-range comparison.
-  PromotedRange OtherPromotedRange(OtherRange, Value.getBitWidth(),
-   Value.isUnsigned());
-  auto Cmp = OtherPromotedRange.compare(Value);
-
-  // If Value is in the range of possible Other values, 

Re: r315996 - [CMake][OpenMP] Customize default offloading arch

2017-12-07 Thread Ahmed Bougacha via cfe-commits
Hi Jonas,

On Tue, Oct 17, 2017 at 6:37 AM, Jonas Hahnfeld via cfe-commits
 wrote:
> Author: hahnfeld
> Date: Tue Oct 17 06:37:36 2017
> New Revision: 315996
>
> URL: http://llvm.org/viewvc/llvm-project?rev=315996=rev
> Log:
> [CMake][OpenMP] Customize default offloading arch
>
> For the shuffle instructions in reductions we need at least sm_30
> but the user may want to customize the default architecture.
>
> Differential Revision: https://reviews.llvm.org/D38883
>
> Modified:
> cfe/trunk/CMakeLists.txt
> cfe/trunk/include/clang/Config/config.h.cmake
> cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
> cfe/trunk/lib/Driver/ToolChains/Cuda.h
>
> Modified: cfe/trunk/CMakeLists.txt
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=315996=315995=315996=diff
> ==
> --- cfe/trunk/CMakeLists.txt (original)
> +++ cfe/trunk/CMakeLists.txt Tue Oct 17 06:37:36 2017
> @@ -235,6 +235,17 @@ endif()
>  set(CLANG_DEFAULT_OPENMP_RUNTIME "libomp" CACHE STRING
>"Default OpenMP runtime used by -fopenmp.")
>
> +# OpenMP offloading requires at least sm_30 because we use shuffle 
> instructions
> +# to generate efficient code for reductions.
> +set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH "sm_30" CACHE STRING
> +  "Default architecture for OpenMP offloading to Nvidia GPUs.")
> +string(REGEX MATCH "^sm_([0-9]+)$" MATCHED_ARCH 
> "${CLANG_OPENMP_NVPTX_DEFAULT_ARCH}")
> +if (NOT DEFINED MATCHED_ARCH OR "${CMAKE_MATCH_1}" LESS 30)
> +  message(WARNING "Resetting default architecture for OpenMP offloading to 
> Nvidia GPUs to sm_30")

This warning is pretty noisy and doesn't affect most people: I don't
know what it means but I get it in every cmake run.
Can we somehow restrict or disable it?

Thanks!
-Ahmed

> +  set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH "sm_30" CACHE STRING
> +"Default architecture for OpenMP offloading to Nvidia GPUs." FORCE)
> +endif()
> +
>  set(CLANG_VENDOR ${PACKAGE_VENDOR} CACHE STRING
>"Vendor-specific text for showing with version information.")
>
>
> Modified: cfe/trunk/include/clang/Config/config.h.cmake
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Config/config.h.cmake?rev=315996=315995=315996=diff
> ==
> --- cfe/trunk/include/clang/Config/config.h.cmake (original)
> +++ cfe/trunk/include/clang/Config/config.h.cmake Tue Oct 17 06:37:36 2017
> @@ -20,6 +20,9 @@
>  /* Default OpenMP runtime used by -fopenmp. */
>  #define CLANG_DEFAULT_OPENMP_RUNTIME "${CLANG_DEFAULT_OPENMP_RUNTIME}"
>
> +/* Default architecture for OpenMP offloading to Nvidia GPUs. */
> +#define CLANG_OPENMP_NVPTX_DEFAULT_ARCH "${CLANG_OPENMP_NVPTX_DEFAULT_ARCH}"
> +
>  /* Multilib suffix for libdir. */
>  #define CLANG_LIBDIR_SUFFIX "${CLANG_LIBDIR_SUFFIX}"
>
>
> Modified: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cuda.cpp?rev=315996=315995=315996=diff
> ==
> --- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp Tue Oct 17 06:37:36 2017
> @@ -542,9 +542,9 @@ CudaToolChain::TranslateArgs(const llvm:
>// flags are not duplicated.
>// Also append the compute capability.
>if (DeviceOffloadKind == Action::OFK_OpenMP) {
> -for (Arg *A : Args){
> +for (Arg *A : Args) {
>bool IsDuplicate = false;
> -  for (Arg *DALArg : *DAL){
> +  for (Arg *DALArg : *DAL) {
>  if (A == DALArg) {
>IsDuplicate = true;
>break;
> @@ -555,14 +555,9 @@ CudaToolChain::TranslateArgs(const llvm:
>  }
>
>  StringRef Arch = DAL->getLastArgValue(options::OPT_march_EQ);
> -if (Arch.empty()) {
> -  // Default compute capability for CUDA toolchain is the
> -  // lowest compute capability supported by the installed
> -  // CUDA version.
> -  DAL->AddJoinedArg(nullptr,
> -  Opts.getOption(options::OPT_march_EQ),
> -  CudaInstallation.getLowestExistingArch());
> -}
> +if (Arch.empty())
> +  DAL->AddJoinedArg(nullptr, Opts.getOption(options::OPT_march_EQ),
> +CLANG_OPENMP_NVPTX_DEFAULT_ARCH);
>
>  return DAL;
>}
>
> Modified: cfe/trunk/lib/Driver/ToolChains/Cuda.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cuda.h?rev=315996=315995=315996=diff
> ==
> --- cfe/trunk/lib/Driver/ToolChains/Cuda.h (original)
> +++ cfe/trunk/lib/Driver/ToolChains/Cuda.h Tue Oct 17 06:37:36 2017
> @@ -76,17 +76,6 @@ public:
>std::string getLibDeviceFile(StringRef Gpu) const {
>  return LibDeviceMap.lookup(Gpu);
>}
> -  /// \brief Get lowest available compute capability
> -  /// for which a libdevice 

[PATCH] D39694: [VerifyDiagnosticConsumer] support -verify=

2017-12-07 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

I've not done a detailed review of the string manipulation here, but this looks 
like a great feature, thanks!




Comment at: include/clang/Basic/DiagnosticDriverKinds.td:342
+
+def note_drv_verify_prefix_spelling : Note<"-verify prefixes must start with a 
letter and contain only alphanumeric characters, hyphens, and underscores">;
 }

Please wrap this to 80 columns.



Comment at: include/clang/Driver/CC1Options.td:407
 def verify : Flag<["-"], "verify">,
-  HelpText<"Verify diagnostic output using comment directives">;
+  HelpText<"Similar to -verify=expected">;
 def verify_ignore_unexpected : Flag<["-"], "verify-ignore-unexpected">,

jdenny wrote:
> hfinkel wrote:
> > "Similar to" seems unfortunately vague. Can it say, "Equivalent to ..."?
> I agree I should have made it clearer.
> 
> "Equivalent to -verify=expected"  works if we decide that duplicate explicit 
> prefixes are permitted, as you've suggested in a later comment.
> 
> With the current implementation, it should be "All occurrences together are 
> equivalent to one occurrence of -verify=expected".  That is, I chose to 
> permit multiple occurrences of -verify without explicit prefixes for backward 
> compatibility, but I chose not to permit duplicate explicit prefixes for 
> reasons I'll discuss in the other comment.
> 
> I'll clean up the documentation once we agree on the right behavior.
> 
> 
I don't think we need to worry about backwards compatibility with people 
passing `-verify` more than once; it seems OK to disallow that if we need to.


https://reviews.llvm.org/D39694



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


r320122 - Unify implementation of our two different flavours of -Wtautological-compare.

2017-12-07 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Dec  7 16:45:25 2017
New Revision: 320122

URL: http://llvm.org/viewvc/llvm-project?rev=320122=rev
Log:
Unify implementation of our two different flavours of -Wtautological-compare.

In so doing, fix a handful of remaining bugs where we would report false
positives or false negatives if we promote a signed value to an unsigned type
for the comparison.

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/tautological-constant-compare.c
cfe/trunk/test/Sema/tautological-constant-enum-compare.c
cfe/trunk/test/SemaCXX/compare.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=320122=320121=320122=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Dec  7 16:45:25 2017
@@ -8662,54 +8662,113 @@ static bool isKnownToHaveUnsignedValue(E
 }
 
 namespace {
+/// The promoted range of values of a type. In general this has the
+/// following structure:
+///
+/// |---| . . . |---|
+/// ^   ^   ^   ^
+///Min   HoleMin  HoleMax  Max
+///
+/// ... where there is only a hole if a signed type is promoted to unsigned
+/// (in which case Min and Max are the smallest and largest representable
+/// values).
+struct PromotedRange {
+  // Min, or HoleMax if there is a hole.
+  llvm::APSInt PromotedMin;
+  // Max, or HoleMin if there is a hole.
+  llvm::APSInt PromotedMax;
+
+  PromotedRange(IntRange R, unsigned BitWidth, bool Unsigned) {
+if (R.Width == 0)
+  PromotedMin = PromotedMax = llvm::APSInt(BitWidth, Unsigned);
+else {
+  PromotedMin = llvm::APSInt::getMinValue(R.Width, R.NonNegative)
+.extOrTrunc(BitWidth);
+  PromotedMin.setIsUnsigned(Unsigned);
+
+  PromotedMax = llvm::APSInt::getMaxValue(R.Width, R.NonNegative)
+.extOrTrunc(BitWidth);
+  PromotedMax.setIsUnsigned(Unsigned);
+}
+  }
 
-enum class LimitType {
-  Max = 1U << 0U,  // e.g. 32767 for short
-  Min = 1U << 1U,  // e.g. -32768 for short
-  Both = Max | Min // When the value is both the Min and the Max limit at the
-   // same time; e.g. in C++, A::a in enum A { a = 0 };
-};
-
-} // namespace
+  // Determine whether this range is contiguous (has no hole).
+  bool isContiguous() const { return PromotedMin <= PromotedMax; }
 
-/// Checks whether Expr 'Constant' may be the
-/// std::numeric_limits<>::max() or std::numeric_limits<>::min()
-/// of the Expr 'Other'. If true, then returns the limit type (min or max).
-/// The Value is the evaluation of Constant
-static llvm::Optional IsTypeLimit(Sema , Expr *Constant,
- Expr *Other,
- const llvm::APSInt ) {
-  if (IsEnumConstOrFromMacro(S, Constant))
-return llvm::Optional();
+  // Where a constant value is within the range.
+  enum ComparisonResult {
+LT = 0x1,
+LE = 0x2,
+GT = 0x4,
+GE = 0x8,
+EQ = 0x10,
+NE = 0x20,
+InRangeFlag = 0x40,
+
+Less = LE | LT | NE,
+Min = LE | InRangeFlag,
+InRange = InRangeFlag,
+Max = GE | InRangeFlag,
+Greater = GE | GT | NE,
 
-  if (isKnownToHaveUnsignedValue(Other) && Value == 0)
-return LimitType::Min;
+OnlyValue = LE | GE | EQ | InRangeFlag,
+InHole = NE
+  };
 
-  // TODO: Investigate using GetExprRange() to get tighter bounds
-  // on the bit ranges.
-  QualType OtherT = Other->IgnoreParenImpCasts()->getType();
-  if (const auto *AT = OtherT->getAs())
-OtherT = AT->getValueType();
+  ComparisonResult compare(const llvm::APSInt ) const {
+assert(Value.getBitWidth() == PromotedMin.getBitWidth() &&
+   Value.isUnsigned() == PromotedMin.isUnsigned());
+if (!isContiguous()) {
+  assert(Value.isUnsigned() && "discontiguous range for signed compare");
+  if (Value.isMinValue()) return Min;
+  if (Value.isMaxValue()) return Max;
+  if (Value >= PromotedMin) return InRange;
+  if (Value <= PromotedMax) return InRange;
+  return InHole;
+}
 
-  IntRange OtherRange = IntRange::forValueOfType(S.Context, OtherT);
-  if (Other->isKnownToHaveBooleanValue())
-OtherRange = IntRange::forBoolType();
+switch (llvm::APSInt::compareValues(Value, PromotedMin)) {
+case -1: return Less;
+case 0: return PromotedMin == PromotedMax ? OnlyValue : Min;
+case 1:
+  switch (llvm::APSInt::compareValues(Value, PromotedMax)) {
+  case -1: return InRange;
+  case 0: return Max;
+  case 1: return Greater;
+  }
+}
 
-  // Special-case for C++ for enum with one enumerator with value of 0.
-  if (OtherRange.Width == 0)
-return Value == 0 ? LimitType::Both : llvm::Optional();
-
-  if (llvm::APSInt::isSameValue(
-  llvm::APSInt::getMaxValue(OtherRange.Width, 

[PATCH] D40941: [ubsan] Use pass_object_size info in bounds checks (compiler-rt)

2017-12-07 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added inline comments.



Comment at: test/ubsan/TestCases/Misc/bounds.cpp:9
+int get_int(int *const p __attribute__((pass_object_size(0))), int i) {
+  // CHECK-A-2: bounds.cpp:[[@LINE+1]]:10: runtime error: index 2 out of 
bounds for type 'int *'
+  return p[i];

george.burgess.iv wrote:
> Do we need extra `RUN:` lines/CHECK prefixes for these? I thought ubsan 
> runtime errors terminated the program.
We don't -- this test doesn't use ubsan's trapping mode. I'll try not to 
fat-finger the command to generate diff context next time -- this would've been 
clearer with the compile line present.


https://reviews.llvm.org/D40941



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


[PATCH] D40941: [ubsan] Use pass_object_size info in bounds checks (compiler-rt)

2017-12-07 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv added a comment.

If the answer to my question is "no, it'll just work," LGTM. Thanks!




Comment at: test/ubsan/TestCases/Misc/bounds.cpp:9
+int get_int(int *const p __attribute__((pass_object_size(0))), int i) {
+  // CHECK-A-2: bounds.cpp:[[@LINE+1]]:10: runtime error: index 2 out of 
bounds for type 'int *'
+  return p[i];

Do we need extra `RUN:` lines/CHECK prefixes for these? I thought ubsan runtime 
errors terminated the program.


https://reviews.llvm.org/D40941



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


[PATCH] D40940: [ubsan] Use pass_object_size info in bounds checks

2017-12-07 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv accepted this revision.
george.burgess.iv added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks again!


https://reviews.llvm.org/D40940



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


[PATCH] D40991: [libcxx] [test] Fix line endings, avoid unnecessary non-ASCII.

2017-12-07 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT created this revision.

[libcxx] [test] Fix line endings, avoid unnecessary non-ASCII.

I recently wrote a tool to audit MSVC's codebase for inconsistent line endings 
and unnecessary non-ASCII characters, and I ran it over libcxx's codebase too. 
I don't need any of these changes to be committed, so feel free to reject them 
- I just thought you might be interested.

There's a significant non-ASCII string in 
test/std/re/re.alg/re.alg.search/grep.pass.cpp which I haven't attempted to 
convert into escapes.

TODO.TXT
Avoid non-ASCII characters.

benchmarks/util_smartptr.bench.cpp
Change CRLF to LF.

test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp
Consistently comment "\u20ac" as EURO SIGN, its Unicode name, instead of the 
actual Unicode character.

test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_type.pass.cpp
Avoid non-ASCII dash.


https://reviews.llvm.org/D40991

Files:
  TODO.TXT
  benchmarks/util_smartptr.bench.cpp
  
test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp
  
test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_type.pass.cpp

Index: test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_type.pass.cpp
===
--- test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_type.pass.cpp
+++ test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_type.pass.cpp
@@ -26,7 +26,7 @@
 #include "uses_alloc_types.hpp"
 #include "controlled_allocators.hpp"
 
-// — If uses_allocator_v is false and
+// - If uses_allocator_v is false and
 //   is_constructible_v is true, calls
 //   OUTERMOST_ALLOC_TRAITS(*this)::construct(
 //  OUTERMOST (*this), p, std::forward(args)...).
Index: test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp
===
--- test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp
+++ test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp
@@ -117,7 +117,7 @@
 assert(ex == -123456789);
 }
 {   // zero, showbase
-std::string v = "0,00 \u20ac";  // €
+std::string v = "0,00 \u20ac";  // EURO SIGN
 showbase(ios);
 typedef input_iterator I;
 long double ex;
@@ -129,7 +129,7 @@
 assert(ex == 0);
 }
 {   // zero, showbase
-std::string v = "0,00 \u20ac";  // €
+std::string v = "0,00 \u20ac";  // EURO SIGN
 showbase(ios);
 typedef input_iterator I;
 long double ex;
@@ -141,7 +141,7 @@
 assert(ex == 0);
 }
 {   // negative one, showbase
-std::string v = "-0,01 \u20ac";
+std::string v = "-0,01 \u20ac";  // EURO SIGN
 typedef input_iterator I;
 long double ex;
 std::ios_base::iostate err = std::ios_base::goodbit;
@@ -152,7 +152,7 @@
 assert(ex == -1);
 }
 {   // negative one, showbase
-std::string v = "-0,01 \u20ac";
+std::string v = "-0,01 \u20ac";  // EURO SIGN
 showbase(ios);
 typedef input_iterator I;
 long double ex;
@@ -164,7 +164,7 @@
 assert(ex == -1);
 }
 {   // positive, showbase
-std::string v = "1 234 567,89 \u20ac";
+std::string v = "1 234 567,89 \u20ac";  // EURO SIGN
 typedef input_iterator I;
 long double ex;
 std::ios_base::iostate err = std::ios_base::goodbit;
@@ -175,7 +175,7 @@
 assert(ex == 123456789);
 }
 {   // positive, showbase
-std::string v = "1 234 567,89 \u20ac";
+std::string v = "1 234 567,89 \u20ac";  // EURO SIGN
 showbase(ios);
 typedef input_iterator I;
 long double ex;
@@ -188,7 +188,7 @@
 noshowbase(ios);
 }
 {   // negative, showbase
-std::string v = "-1 234 567,89 \u20ac";
+std::string v = "-1 234 567,89 \u20ac";  // EURO SIGN
 showbase(ios);
 typedef input_iterator I;
 long double ex;
@@ -450,7 +450,7 @@
 assert(ex == -123456789);
 }
 {   // zero, showbase
-std::wstring v = L"0,00 \u20ac";
+std::wstring v = L"0,00 \u20ac";  // EURO SIGN
 showbase(ios);
 typedef input_iterator I;
 long double ex;
@@ 

[PATCH] D39050: Add index-while-building support to Clang

2017-12-07 Thread Nathan Hawes via Phabricator via cfe-commits
nathawes updated this revision to Diff 126065.
nathawes added a comment.
Herald added a subscriber: mgrang.

Worked through the comments from @ioeric and split the code for writing out the 
collected indexing data into a separate patch.


https://reviews.llvm.org/D39050

Files:
  include/clang/Basic/AllDiagnostics.h
  include/clang/Basic/CMakeLists.txt
  include/clang/Basic/Diagnostic.td
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticIDs.h
  include/clang/Basic/DiagnosticIndexKinds.td
  include/clang/Driver/Job.h
  include/clang/Driver/Options.td
  include/clang/Frontend/CompilerInstance.h
  include/clang/Frontend/FrontendOptions.h
  include/clang/Index/IndexDataConsumer.h
  include/clang/Index/IndexDiagnostic.h
  include/clang/Index/IndexingAction.h
  include/clang/module.modulemap
  lib/Basic/DiagnosticIDs.cpp
  lib/Driver/Driver.cpp
  lib/Driver/Job.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/Darwin.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/FrontendTool/CMakeLists.txt
  lib/FrontendTool/ExecuteCompilerInvocation.cpp
  lib/Index/CMakeLists.txt
  lib/Index/FileIndexRecord.cpp
  lib/Index/FileIndexRecord.h
  lib/Index/IndexingAction.cpp
  lib/Index/IndexingContext.cpp
  lib/Index/IndexingContext.h
  test/Index/Store/assembly-invocation.c
  tools/c-index-test/core_main.cpp
  tools/diagtool/DiagnosticNames.cpp
  tools/libclang/CXIndexDataConsumer.cpp
  tools/libclang/CXIndexDataConsumer.h

Index: tools/libclang/CXIndexDataConsumer.h
===
--- tools/libclang/CXIndexDataConsumer.h
+++ tools/libclang/CXIndexDataConsumer.h
@@ -463,12 +463,12 @@
 private:
   bool handleDeclOccurence(const Decl *D, index::SymbolRoleSet Roles,
ArrayRef Relations,
-   FileID FID, unsigned Offset,
+   FileID FID, unsigned Offset, bool IsInSystemFile,
ASTNodeInfo ASTNode) override;
 
   bool handleModuleOccurence(const ImportDecl *ImportD,
- index::SymbolRoleSet Roles,
- FileID FID, unsigned Offset) override;
+ index::SymbolRoleSet Roles, FileID FID,
+ unsigned Offset, bool IsInSystemFile) override;
 
   void finish() override;
 
Index: tools/libclang/CXIndexDataConsumer.cpp
===
--- tools/libclang/CXIndexDataConsumer.cpp
+++ tools/libclang/CXIndexDataConsumer.cpp
@@ -150,11 +150,9 @@
 };
 }
 
-bool CXIndexDataConsumer::handleDeclOccurence(const Decl *D,
-  SymbolRoleSet Roles,
- ArrayRef Relations,
-  FileID FID, unsigned Offset,
-  ASTNodeInfo ASTNode) {
+bool CXIndexDataConsumer::handleDeclOccurence(
+const Decl *D, SymbolRoleSet Roles, ArrayRef Relations,
+FileID FID, unsigned Offset, bool IsInSystemFile, ASTNodeInfo ASTNode) {
   SourceLocation Loc = getASTContext().getSourceManager()
   .getLocForStartOfFile(FID).getLocWithOffset(Offset);
 
@@ -219,9 +217,9 @@
 }
 
 bool CXIndexDataConsumer::handleModuleOccurence(const ImportDecl *ImportD,
-SymbolRoleSet Roles,
-FileID FID,
-unsigned Offset) {
+SymbolRoleSet Roles, FileID FID,
+unsigned Offset,
+bool IsInSystemFile) {
   IndexingDeclVisitor(*this, SourceLocation(), nullptr).Visit(ImportD);
   return !shouldAbort();
 }
Index: tools/diagtool/DiagnosticNames.cpp
===
--- tools/diagtool/DiagnosticNames.cpp
+++ tools/diagtool/DiagnosticNames.cpp
@@ -43,6 +43,7 @@
 #include "clang/Basic/DiagnosticSemaKinds.inc"
 #include "clang/Basic/DiagnosticAnalysisKinds.inc"
 #include "clang/Basic/DiagnosticRefactoringKinds.inc"
+#include "clang/Basic/DiagnosticIndexKinds.inc"
 #undef DIAG
 };
 
Index: tools/c-index-test/core_main.cpp
===
--- tools/c-index-test/core_main.cpp
+++ tools/c-index-test/core_main.cpp
@@ -87,8 +87,8 @@
   }
 
   bool handleDeclOccurence(const Decl *D, SymbolRoleSet Roles,
-   ArrayRef Relations,
-   FileID FID, unsigned Offset,
+   ArrayRef Relations, FileID FID,
+   unsigned Offset, bool IsInSystemFile,
ASTNodeInfo ASTNode) override {
 ASTContext  = D->getASTContext();
 SourceManager  = Ctx.getSourceManager();
@@ -124,7 +124,8 

[PATCH] D40668: [Blocks] Inherit sanitizer options from parent decl

2017-12-07 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

Friendly ping.


https://reviews.llvm.org/D40668



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


[PATCH] D40940: [ubsan] Use pass_object_size info in bounds checks

2017-12-07 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 126064.
vsk added a comment.

- Handle constant size modifiers while we're at it (e.g "int foo(int p[static 
10])").


https://reviews.llvm.org/D40940

Files:
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/ubsan-pass-object-size.c

Index: test/CodeGen/ubsan-pass-object-size.c
===
--- /dev/null
+++ test/CodeGen/ubsan-pass-object-size.c
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 %s -emit-llvm -w -triple x86_64-apple-darwin10 -fsanitize=array-bounds -o - | FileCheck %s
+
+// CHECK-LABEL: define i32 @foo(
+int foo(int *const p __attribute__((pass_object_size(0))), int n) {
+  int x = (p)[n];
+
+  // CHECK: [[SIZE_ALLOCA:%.*]] = alloca i64, align 8
+  // CHECK: store i64 %{{.*}}, i64* [[SIZE_ALLOCA]], align 8
+  // CHECK: [[LOAD_SIZE:%.*]] = load i64, i64* [[SIZE_ALLOCA]], align 8, !nosanitize
+  // CHECK-NEXT: [[SCALED_SIZE:%.*]] = udiv i64 [[LOAD_SIZE]], 4, !nosanitize
+  // CHECK-NEXT: [[SEXT_N:%.*]] = sext i32 %{{.*}} to i64, !nosanitize
+  // CHECK-NEXT: [[ICMP:%.*]] = icmp ult i64 [[SEXT_N]], [[SCALED_SIZE]], !nosanitize
+  // CHECK-NEXT: br i1 [[ICMP]], {{.*}} !nosanitize
+  // CHECK: __ubsan_handle_out_of_bounds
+
+  {
+int **p =  // Shadow the parameter. The pass_object_size info is lost.
+// CHECK-NOT: __ubsan_handle_out_of_bounds
+x = *p[n];
+  }
+
+  // CHECK: ret i32
+  return x;
+}
+
+typedef struct {} ZeroSizedType;
+
+// CHECK-LABEL: define void @bar(
+ZeroSizedType bar(ZeroSizedType *const p __attribute__((pass_object_size(0))), int n) {
+  // CHECK-NOT: __ubsan_handle_out_of_bounds
+  // CHECK: ret void
+  return p[n];
+}
+
+// CHECK-LABEL: define i32 @baz(
+int baz(int *const p __attribute__((pass_object_size(1))), int n) {
+  // CHECK: __ubsan_handle_out_of_bounds
+  // CHECK: ret i32
+  return p[n];
+}
+
+// CHECK-LABEL: define i32 @mat(
+int mat(int *const p __attribute__((pass_object_size(2))), int n) {
+  // CHECK-NOT: __ubsan_handle_out_of_bounds
+  // CHECK: ret i32
+  return p[n];
+}
+
+// CHECK-LABEL: define i32 @pat(
+int pat(int *const p __attribute__((pass_object_size(3))), int n) {
+  // CHECK-NOT: __ubsan_handle_out_of_bounds
+  // CHECK: ret i32
+  return p[n];
+}
+
+// CHECK-LABEL: define i32 @cat(
+int cat(int p[static 10], int n) {
+  // CHECK: icmp ult i64 {{.*}}, 10, !nosanitize
+  // CHECK: __ubsan_handle_out_of_bounds
+  // CHECK: ret i32
+  return p[n];
+}
+
+// CHECK-LABEL: define i32 @bat(
+int bat(int n, int p[n]) {
+  // CHECK-NOT: __ubsan_handle_out_of_bounds
+  // CHECK: ret i32
+  return p[n];
+}
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -3932,6 +3932,11 @@
LValueBaseInfo *BaseInfo = nullptr,
TBAAAccessInfo *TBAAInfo = nullptr);
 
+  /// If \p E references a parameter with pass_object_size info or a constant
+  /// array size modifier, emit the object size divided by the size of \p EltTy.
+  /// Otherwise return null.
+  llvm::Value *LoadPassedObjectSize(const Expr *E, QualType EltTy);
+
   void EmitSanitizerStatReport(llvm::SanitizerStatKind SSK);
 
 private:
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -814,6 +814,53 @@
   return false;
 }
 
+llvm::Value *CodeGenFunction::LoadPassedObjectSize(const Expr *E,
+   QualType EltTy) {
+  ASTContext  = getContext();
+  uint64_t EltSize = C.getTypeSizeInChars(EltTy).getQuantity();
+  if (!EltSize)
+return nullptr;
+
+  auto *ArrayDeclRef = dyn_cast(E->IgnoreParenImpCasts());
+  if (!ArrayDeclRef)
+return nullptr;
+
+  auto *ParamDecl = dyn_cast(ArrayDeclRef->getDecl());
+  if (!ParamDecl)
+return nullptr;
+
+  // Arrays don't have pass_object_size attributes, but if they have a constant
+  // size modifier it's the array size (C99 6.5.7.2p1).
+  if (auto *DecayedArrayTy = dyn_cast(ParamDecl->getType()))
+if (auto *ArrayTy =
+dyn_cast(DecayedArrayTy->getOriginalType()))
+  return llvm::ConstantInt::get(SizeTy,
+ArrayTy->getSize().getLimitedValue());
+
+  auto *POSAttr = ParamDecl->getAttr();
+  if (!POSAttr)
+return nullptr;
+
+  // Don't load the size if it's a lower bound.
+  int POSType = POSAttr->getType();
+  if (POSType != 0 && POSType != 1)
+return nullptr;
+
+  // Find the implicit size parameter.
+  auto PassedSizeIt = SizeArguments.find(ParamDecl);
+  if (PassedSizeIt == SizeArguments.end())
+return nullptr;
+
+  const ImplicitParamDecl *PassedSizeDecl = PassedSizeIt->second;
+  assert(LocalDeclMap.count(PassedSizeDecl) && "Passed size not loadable");
+  Address AddrOfSize = LocalDeclMap.find(PassedSizeDecl)->second;
+  llvm::Value *SizeInBytes = 

[PATCH] D39050: Add index-while-building support to Clang

2017-12-07 Thread Nathan Hawes via Phabricator via cfe-commits
nathawes added inline comments.



Comment at: lib/FrontendTool/ExecuteCompilerInvocation.cpp:170
+Act = index::createIndexDataRecordingAction(FEOpts, std::move(Act));
+CI.setGenModuleActionWrapper(::createIndexDataRecordingAction);
+  }

ioeric wrote:
> Could you comment on what this does? The `Act` above is already wrapped. Why 
> do we need `setGenModuleActionWrapper` to `createIndexDataRecordingAction` 
> again? Also, `createIndexDataRecordingAction` doesn't seem related to 
> `GenModule`.
It's to wrap any GenerateModuleActions that get created as needed when/if Act 
ends up loading any modules, so that we output index data for them too. I'll 
add a comment.



Comment at: lib/Index/FileIndexRecord.cpp:39
+  auto It = std::upper_bound(Decls.begin(), Decls.end(), NewInfo);
+  Decls.insert(It, std::move(NewInfo));
+}

ioeric wrote:
> Why do we need `Decls` to be sorted by offset? If we want this for printing, 
> it might make sense to just do a sort there.
It's mostly for when we hash them, so that ordering doesn't change the hash, 
but it's also for printing. The IndexASTConsumer doesn't always report symbol 
occurrences in source order, due to the preprocessor and a few other cases.
We can sort them when the IndexRecordDataConsumer's finish() is called rather 
than as they're added to avoid the copying from repeated insert calls if that's 
the concern.



Comment at: lib/Index/IndexingAction.cpp:504
+
+CreatedASTConsumer = true;
+std::vector Consumers;

ioeric wrote:
>  Can we get this state from the base class instead of maintaining a another 
> state, which seems to be identical?
I don't see this state in either base class (WrapperFrontendAction and 
IndexRecordActionBase). WrappingIndexAction and WrappingIndexRecordAction both 
have this, though. Were you thinking a new intermediate common base class 
between them and WrapperFrontendAction?



Comment at: lib/Index/IndexingAction.cpp:769
+  IndexCtx.setSysrootPath(SysrootPath);
+  Recorder.init(, CI);
+

ioeric wrote:
> It's a bit worrying that `IndexDataRecorder` and `IndexContext` reference 
> each other. If you only need some information from the `IndexingContext`, 
> simply pass it into `Recorder`. In this case, I think you only need the 
> `SourceManager`  from the `ASTContext` in the recorder to calculate whether a 
> file is a system header. I see you also cache result of 
> `IndexingContext::isSystemFile` in the indexing context, but I think it would 
> be more sensible for the callers to handle caching for this call.
Good point. The IndexingContext was actually already calling IsSystemFile 
before it calls IndexDataRecorder's handleDeclOccurrence and 
handleModuleOccurrence anyway, so I'll change it to pass that through as an 
extra param and remove IndexDataRecorder's dependency on the IndexingContext.


https://reviews.llvm.org/D39050



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


[PATCH] D40988: Clang-format: add finer-grained options for putting all arguments on one line

2017-12-07 Thread Russell McClellan via Phabricator via cfe-commits
russellmcc created this revision.
Herald added a subscriber: klimek.

Add 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


Repository:
  rC Clang

https://reviews.llvm.org/D40988

Files:
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/Format.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -3433,6 +3433,43 @@
"() {}"));
 }
 
+TEST_F(FormatTest, AllowAllConstructorInitializersOnNextLine) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakConstructorInitializers = FormatStyle::BCIS_BeforeComma;
+  Style.ColumnLimit = 60;
+  Style.ConstructorInitializerAllOnOneLineOrOnePerLine = true;
+  Style.AllowAllConstructorInitializersOnNextLine = true;
+  verifyFormat("Constructor()\n"
+   ": (a), b(b) {}",
+   Style);
+
+  Style.AllowAllConstructorInitializersOnNextLine = false;
+  verifyFormat("Constructor()\n"
+   ": (a)\n"
+   ", b(b) {}",
+   Style);
+}
+
+TEST_F(FormatTest, AllowAllArgumentsOnNextLine) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakConstructorInitializers = FormatStyle::BCIS_BeforeComma;
+  Style.ColumnLimit = 60;
+  Style.BinPackArguments = false;
+  Style.AllowAllArgumentsOnNextLine = true;
+  verifyFormat("void foo() {\n"
+   "  FunctionCallWithReallyLongName(\n"
+   "  aaa, );\n"
+   "}",
+   Style);
+  Style.AllowAllArgumentsOnNextLine = false;
+  verifyFormat("void foo() {\n"
+   "  FunctionCallWithReallyLongName(\n"
+   "  aaa,\n"
+   "  );\n"
+   "}",
+   Style);
+}
+
 TEST_F(FormatTest, BreakConstructorInitializersAfterColon) {
   FormatStyle Style = getLLVMStyle();
   Style.BreakConstructorInitializers = FormatStyle::BCIS_AfterColon;
@@ -10020,6 +10057,8 @@
   CHECK_PARSE_BOOL(AlignTrailingComments);
   CHECK_PARSE_BOOL(AlignConsecutiveAssignments);
   CHECK_PARSE_BOOL(AlignConsecutiveDeclarations);
+  CHECK_PARSE_BOOL(AllowAllArgumentsOnNextLine);
+  CHECK_PARSE_BOOL(AllowAllConstructorInitializersOnNextLine);
   CHECK_PARSE_BOOL(AllowAllParametersOfDeclarationOnNextLine);
   CHECK_PARSE_BOOL(AllowShortBlocksOnASingleLine);
   CHECK_PARSE_BOOL(AllowShortCaseLabelsOnASingleLine);
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -287,6 +287,10 @@
 IO.mapOptional("AlignEscapedNewlines", Style.AlignEscapedNewlines);
 IO.mapOptional("AlignOperands", Style.AlignOperands);
 IO.mapOptional("AlignTrailingComments", Style.AlignTrailingComments);
+IO.mapOptional("AllowAllArgumentsOnNextLine",
+   Style.AllowAllArgumentsOnNextLine);
+IO.mapOptional("AllowAllConstructorInitializersOnNextLine",
+   Style.AllowAllConstructorInitializersOnNextLine);
 IO.mapOptional("AllowAllParametersOfDeclarationOnNextLine",
Style.AllowAllParametersOfDeclarationOnNextLine);
 IO.mapOptional("AllowShortBlocksOnASingleLine",
@@ -303,6 +307,7 @@
Style.AlwaysBreakAfterDefinitionReturnType);
 IO.mapOptional("AlwaysBreakAfterReturnType",
Style.AlwaysBreakAfterReturnType);
+
 // If AlwaysBreakAfterDefinitionReturnType was specified but
 // AlwaysBreakAfterReturnType was not, initialize the latter from the
 // former for backwards compatibility.
@@ -575,6 +580,8 @@
   LLVMStyle.AlignTrailingComments = true;
   LLVMStyle.AlignConsecutiveAssignments = false;
   LLVMStyle.AlignConsecutiveDeclarations = false;
+  LLVMStyle.AllowAllArgumentsOnNextLine = true;
+  LLVMStyle.AllowAllConstructorInitializersOnNextLine = true;
   LLVMStyle.AllowAllParametersOfDeclarationOnNextLine = true;
   LLVMStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
   LLVMStyle.AllowShortBlocksOnASingleLine = false;
@@ -738,6 +745,8 @@
 ChromiumStyle.AllowShortIfStatementsOnASingleLine = false;
 ChromiumStyle.AllowShortLoopsOnASingleLine = false;
   } else {
+ChromiumStyle.AllowAllArgumentsOnNextLine = true;
+

[PATCH] D40936: Hardware-assisted AddressSanitizer (clang part).

2017-12-07 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis updated this revision to Diff 126060.
eugenis added a comment.

clang-format


https://reviews.llvm.org/D40936

Files:
  clang/include/clang/Basic/Sanitizers.def
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/SanitizerMetadata.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/test/CodeGen/address-safety-attr-kasan-hwasan.cpp
  clang/test/Driver/Inputs/resource_dir/hwasan_blacklist.txt
  
clang/test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.hwasan-aarch64.a.syms
  clang/test/Driver/asan.c
  clang/test/Driver/fsanitize-blacklist.c
  clang/test/Driver/fsanitize-coverage.c
  clang/test/Driver/fsanitize.c
  clang/test/Driver/sanitize_unwind_tables.c
  clang/test/Driver/sanitizer-ld.c
  clang/test/Lexer/has_feature_address_sanitizer.cpp
  clang/test/SemaCXX/attr-no-sanitize.cpp

Index: clang/test/SemaCXX/attr-no-sanitize.cpp
===
--- clang/test/SemaCXX/attr-no-sanitize.cpp
+++ clang/test/SemaCXX/attr-no-sanitize.cpp
@@ -16,10 +16,15 @@
 // PRINT: int f4() {{\[\[}}clang::no_sanitize("thread")]]
 [[clang::no_sanitize("thread")]] int f4();
 
+// DUMP-LABEL: FunctionDecl {{.*}} f4
+// DUMP: NoSanitizeAttr {{.*}} hwaddress
+// PRINT: int f4() {{\[\[}}clang::no_sanitize("hwaddress")]]
+[[clang::no_sanitize("hwaddress")]] int f4();
+
 // DUMP-LABEL: FunctionDecl {{.*}} f5
-// DUMP: NoSanitizeAttr {{.*}} address thread
-// PRINT: int f5() __attribute__((no_sanitize("address", "thread")))
-int f5() __attribute__((no_sanitize("address", "thread")));
+// DUMP: NoSanitizeAttr {{.*}} address thread hwaddress
+// PRINT: int f5() __attribute__((no_sanitize("address", "thread", "hwaddress")))
+int f5() __attribute__((no_sanitize("address", "thread", "hwaddress")));
 
 // DUMP-LABEL: FunctionDecl {{.*}} f6
 // DUMP: NoSanitizeAttr {{.*}} unknown
Index: clang/test/Lexer/has_feature_address_sanitizer.cpp
===
--- clang/test/Lexer/has_feature_address_sanitizer.cpp
+++ clang/test/Lexer/has_feature_address_sanitizer.cpp
@@ -1,12 +1,25 @@
 // RUN: %clang_cc1 -E -fsanitize=address %s -o - | FileCheck --check-prefix=CHECK-ASAN %s
 // RUN: %clang_cc1 -E -fsanitize=kernel-address %s -o - | FileCheck --check-prefix=CHECK-ASAN %s
+// RUN: %clang_cc1 -E -fsanitize=hwaddress %s -o - | FileCheck --check-prefix=CHECK-HWASAN %s
 // RUN: %clang_cc1 -E  %s -o - | FileCheck --check-prefix=CHECK-NO-ASAN %s
 
 #if __has_feature(address_sanitizer)
 int AddressSanitizerEnabled();
 #else
 int AddressSanitizerDisabled();
 #endif
 
+#if __has_feature(hwaddress_sanitizer)
+int HWAddressSanitizerEnabled();
+#else
+int HWAddressSanitizerDisabled();
+#endif
+
 // CHECK-ASAN: AddressSanitizerEnabled
+// CHECK-ASAN: HWAddressSanitizerDisabled
+
+// CHECK-HWASAN: AddressSanitizerDisabled
+// CHECK-HWASAN: HWAddressSanitizerEnabled
+
 // CHECK-NO-ASAN: AddressSanitizerDisabled
+// CHECK-NO-ASAN: HWAddressSanitizerDisabled
Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -694,3 +694,56 @@
 // CHECK-SCUDO-ANDROID-STATIC: "-whole-archive" "{{.*}}libclang_rt.scudo-arm-android.a" "-no-whole-archive"
 // CHECK-SCUDO-ANDROID-STATIC-NOT: "-lstdc++"
 // CHECK-SCUDO-ANDROID-STATIC: "-lpthread"
+
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target aarch64-unknown-linux -fuse-ld=ld -fsanitize=hwaddress \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-HWASAN-LINUX %s
+//
+// CHECK-HWASAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-HWASAN-LINUX-NOT: "-lc"
+// CHECK-HWASAN-LINUX: libclang_rt.hwasan-aarch64.a"
+// CHECK-HWASAN-LINUX-NOT: "-export-dynamic"
+// CHECK-HWASAN-LINUX: "--dynamic-list={{.*}}libclang_rt.hwasan-aarch64.a.syms"
+// CHECK-HWASAN-LINUX-NOT: "-export-dynamic"
+// CHECK-HWASAN-LINUX: "-lpthread"
+// CHECK-HWASAN-LINUX: "-lrt"
+// CHECK-HWASAN-LINUX: "-ldl"
+
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target aarch64-unknown-linux -fuse-ld=ld -fsanitize=hwaddress -shared-libsan \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-SHARED-HWASAN-LINUX %s
+
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target aarch64-unknown-linux -fuse-ld=ld -fsanitize=hwaddress \
+// RUN: -shared-libsan \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | 

[PATCH] D39451: P0620 follow-up: deducing `auto` from braced-init-list in new expr

2017-12-07 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

EDG and MSVC do not appear to treat this as a defect resolution; I suspect this 
is an oversight in GCC rather than an intentional extension. Let's convert the 
error to an (off by default) pedantic `Extension` (ISO C++11 does not allow 
...), and suppress the extension warning in C++17 onwards.


https://reviews.llvm.org/D39451



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


r320115 - Correct line endings that got mixed up in r320088; NFC.

2017-12-07 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Dec  7 15:10:09 2017
New Revision: 320115

URL: http://llvm.org/viewvc/llvm-project?rev=320115=rev
Log:
Correct line endings that got mixed up in r320088; NFC.

Modified:
cfe/trunk/test/Preprocessor/has_c_attribute.c

Modified: cfe/trunk/test/Preprocessor/has_c_attribute.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/has_c_attribute.c?rev=320115=320114=320115=diff
==
--- cfe/trunk/test/Preprocessor/has_c_attribute.c (original)
+++ cfe/trunk/test/Preprocessor/has_c_attribute.c Thu Dec  7 15:10:09 2017
@@ -1,12 +1,12 @@
-// RUN: %clang_cc1 -fdouble-square-bracket-attributes -std=c11 -E %s -o - | 
FileCheck %s
-
-// CHECK: has_fallthrough
-#if __has_c_attribute(fallthrough)
-  int has_fallthrough();
-#endif
-
-// CHECK: does_not_have_selectany
-#if !__has_c_attribute(selectany)
-  int does_not_have_selectany();
-#endif
-
+// RUN: %clang_cc1 -fdouble-square-bracket-attributes -std=c11 -E %s -o - | 
FileCheck %s
+
+// CHECK: has_fallthrough
+#if __has_c_attribute(fallthrough)
+  int has_fallthrough();
+#endif
+
+// CHECK: does_not_have_selectany
+#if !__has_c_attribute(selectany)
+  int does_not_have_selectany();
+#endif
+


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


Re: r320089 - Add new language mode flags for C17.

2017-12-07 Thread Ahmed Bougacha via cfe-commits
On Thu, Dec 7, 2017 at 3:05 PM, Aaron Ballman  wrote:
> On Thu, Dec 7, 2017 at 6:00 PM, Aaron Ballman  wrote:
>> On Thu, Dec 7, 2017 at 5:59 PM, Ahmed Bougacha  
>> wrote:
>>> On Thu, Dec 7, 2017 at 2:56 PM, Richard Smith via cfe-commits
>>>  wrote:
 Looks like this might have messed up the line endings in a few files?
>>>
>>> Should be taken care of in r320112.
>>
>> Thanks, I was just getting on that. Sorry about the inadvertent churn there!
>
> I corrected the rest of the line endings in r320113.

Thanks!
-Ahmed

> ~Aaron
>
>>
>> ~Aaron
>>
>>>
>>> -Ahmed
>>>
 On 7 December 2017 at 13:46, Aaron Ballman via cfe-commits
  wrote:
>
> Author: aaronballman
> Date: Thu Dec  7 13:46:26 2017
> New Revision: 320089
>
> URL: http://llvm.org/viewvc/llvm-project?rev=320089=rev
> Log:
> Add new language mode flags for C17.
>
> This adds -std=c17, -std=gnu17, and -std=iso9899:2017 as language mode
> flags for C17 and updates the value of __STDC_VERSION__ to the value based
> on the C17 FDIS. Given that this ballot cannot succeed until 2018, it is
> expected that we (and GCC) will add c18 flags as aliases once the ballot
> passes.
>
> Modified:
> cfe/trunk/docs/ReleaseNotes.rst
> 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/unknown-std.c
>
> Modified: cfe/trunk/docs/ReleaseNotes.rst
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=320089=320088=320089=diff
>
> ==
> --- cfe/trunk/docs/ReleaseNotes.rst (original)
> +++ cfe/trunk/docs/ReleaseNotes.rst Thu Dec  7 13:46:26 2017
> @@ -121,6 +121,12 @@ New Compiler Flags
>number of attributes are supported outside of C++ mode. See the Clang
>attribute documentation for more information about which attributes are
>supported for each syntax.
> +
> +- Added the ``-std=c17``, ``-std=gnu17``, and ``-std=iso9899:2017``
> language
> +  mode flags for compatibility with GCC. This enables support for the
> next
> +  version of the C standard, expected to be published by ISO in 2018. The
> only
> +  difference between the ``-std=c17`` and ``-std=c11`` language modes is
> the
> +  value of the ``__STDC_VERSION__`` macro, as C17 is a bug fix release.
>
>  Deprecated Compiler Flags
>  -
>
> Modified: cfe/trunk/include/clang/Basic/LangOptions.def
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=320089=320088=320089=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/LangOptions.def (original)
> +++ cfe/trunk/include/clang/Basic/LangOptions.def Thu Dec  7 13:46:26 2017
> @@ -1,187 +1,188 @@
> -//===--- LangOptions.def - Language option database -*- C++
> -*-===//
> -//
> -// The LLVM Compiler Infrastructure
> -//
> -// This file is distributed under the University of Illinois Open Source
> -// License. See LICENSE.TXT for details.
> -//
>
> -//===--===//
> -//
> -// This file defines the language options. Users of this file must
> -// define the LANGOPT macro to make use of this information.
> -//
> -// Optionally, the user may also define:
> -//
> -// BENIGN_LANGOPT: for options that don't affect the construction of the
> AST in
> -// any way (that is, the value can be different between an implicit
> module
> -// and the user of that module).
> -//
> -// COMPATIBLE_LANGOPT: for options that affect the construction of the
> AST in
> -// a way that doesn't prevent interoperability (that is, the value
> can be
> -// different between an explicit module and the user of that module).
> -//
> -// ENUM_LANGOPT: for options that have enumeration, rather than unsigned,
> type.
> -//
> -// VALUE_LANGOPT: for options that describe a value rather than a flag.
> -//
> -// BENIGN_ENUM_LANGOPT, COMPATIBLE_ENUM_LANGOPT,
> -// BENIGN_VALUE_LANGOPT, COMPATIBLE_VALUE_LANGOPT: combinations of the
> above.
> -//
> -// FIXME: Clients should be able to more easily select whether they want
> -// different levels of compatibility versus how to handle different kinds
> -// of 

[PATCH] D35181: Defer addition of keywords to identifier table when loading AST

2017-12-07 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

LGTM, but I'd like the old `IdentifierTable` constructor to be removed if there 
are no callers left.




Comment at: include/clang/Basic/IdentifierTable.h:473-476
   /// \brief Create the identifier table, populating it with info about the
   /// language keywords for the language specified by \p LangOpts.
   IdentifierTable(const LangOptions ,
+  IdentifierInfoLookup *externalLookup = nullptr);

Can this constructor be removed?


https://reviews.llvm.org/D35181



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


Re: r320089 - Add new language mode flags for C17.

2017-12-07 Thread Ahmed Bougacha via cfe-commits
On Thu, Dec 7, 2017 at 3:00 PM, Aaron Ballman  wrote:
> On Thu, Dec 7, 2017 at 5:59 PM, Ahmed Bougacha  
> wrote:
>> On Thu, Dec 7, 2017 at 2:56 PM, Richard Smith via cfe-commits
>>  wrote:
>>> Looks like this might have messed up the line endings in a few files?
>>
>> Should be taken care of in r320112.

Oh, I missed some files.  I'll take care of it.

-Ahmed

> Thanks, I was just getting on that. Sorry about the inadvertent churn there!
>
> ~Aaron
>
>>
>> -Ahmed
>>
>>> On 7 December 2017 at 13:46, Aaron Ballman via cfe-commits
>>>  wrote:

 Author: aaronballman
 Date: Thu Dec  7 13:46:26 2017
 New Revision: 320089

 URL: http://llvm.org/viewvc/llvm-project?rev=320089=rev
 Log:
 Add new language mode flags for C17.

 This adds -std=c17, -std=gnu17, and -std=iso9899:2017 as language mode
 flags for C17 and updates the value of __STDC_VERSION__ to the value based
 on the C17 FDIS. Given that this ballot cannot succeed until 2018, it is
 expected that we (and GCC) will add c18 flags as aliases once the ballot
 passes.

 Modified:
 cfe/trunk/docs/ReleaseNotes.rst
 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/unknown-std.c

 Modified: cfe/trunk/docs/ReleaseNotes.rst
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=320089=320088=320089=diff

 ==
 --- cfe/trunk/docs/ReleaseNotes.rst (original)
 +++ cfe/trunk/docs/ReleaseNotes.rst Thu Dec  7 13:46:26 2017
 @@ -121,6 +121,12 @@ New Compiler Flags
number of attributes are supported outside of C++ mode. See the Clang
attribute documentation for more information about which attributes are
supported for each syntax.
 +
 +- Added the ``-std=c17``, ``-std=gnu17``, and ``-std=iso9899:2017``
 language
 +  mode flags for compatibility with GCC. This enables support for the
 next
 +  version of the C standard, expected to be published by ISO in 2018. The
 only
 +  difference between the ``-std=c17`` and ``-std=c11`` language modes is
 the
 +  value of the ``__STDC_VERSION__`` macro, as C17 is a bug fix release.

  Deprecated Compiler Flags
  -

 Modified: cfe/trunk/include/clang/Basic/LangOptions.def
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=320089=320088=320089=diff

 ==
 --- cfe/trunk/include/clang/Basic/LangOptions.def (original)
 +++ cfe/trunk/include/clang/Basic/LangOptions.def Thu Dec  7 13:46:26 2017
 @@ -1,187 +1,188 @@
 -//===--- LangOptions.def - Language option database -*- C++
 -*-===//
 -//
 -// The LLVM Compiler Infrastructure
 -//
 -// This file is distributed under the University of Illinois Open Source
 -// License. See LICENSE.TXT for details.
 -//

 -//===--===//
 -//
 -// This file defines the language options. Users of this file must
 -// define the LANGOPT macro to make use of this information.
 -//
 -// Optionally, the user may also define:
 -//
 -// BENIGN_LANGOPT: for options that don't affect the construction of the
 AST in
 -// any way (that is, the value can be different between an implicit
 module
 -// and the user of that module).
 -//
 -// COMPATIBLE_LANGOPT: for options that affect the construction of the
 AST in
 -// a way that doesn't prevent interoperability (that is, the value
 can be
 -// different between an explicit module and the user of that module).
 -//
 -// ENUM_LANGOPT: for options that have enumeration, rather than unsigned,
 type.
 -//
 -// VALUE_LANGOPT: for options that describe a value rather than a flag.
 -//
 -// BENIGN_ENUM_LANGOPT, COMPATIBLE_ENUM_LANGOPT,
 -// BENIGN_VALUE_LANGOPT, COMPATIBLE_VALUE_LANGOPT: combinations of the
 above.
 -//
 -// FIXME: Clients should be able to more easily select whether they want
 -// different levels of compatibility versus how to handle different kinds
 -// of option.
 -//
 -// The Description field should be a noun phrase, for instance "frobbing
 all
 -// widgets" or "C's implicit blintz feature".

 

Re: r320089 - Add new language mode flags for C17.

2017-12-07 Thread Aaron Ballman via cfe-commits
On Thu, Dec 7, 2017 at 6:00 PM, Aaron Ballman  wrote:
> On Thu, Dec 7, 2017 at 5:59 PM, Ahmed Bougacha  
> wrote:
>> On Thu, Dec 7, 2017 at 2:56 PM, Richard Smith via cfe-commits
>>  wrote:
>>> Looks like this might have messed up the line endings in a few files?
>>
>> Should be taken care of in r320112.
>
> Thanks, I was just getting on that. Sorry about the inadvertent churn there!

I corrected the rest of the line endings in r320113.

~Aaron

>
> ~Aaron
>
>>
>> -Ahmed
>>
>>> On 7 December 2017 at 13:46, Aaron Ballman via cfe-commits
>>>  wrote:

 Author: aaronballman
 Date: Thu Dec  7 13:46:26 2017
 New Revision: 320089

 URL: http://llvm.org/viewvc/llvm-project?rev=320089=rev
 Log:
 Add new language mode flags for C17.

 This adds -std=c17, -std=gnu17, and -std=iso9899:2017 as language mode
 flags for C17 and updates the value of __STDC_VERSION__ to the value based
 on the C17 FDIS. Given that this ballot cannot succeed until 2018, it is
 expected that we (and GCC) will add c18 flags as aliases once the ballot
 passes.

 Modified:
 cfe/trunk/docs/ReleaseNotes.rst
 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/unknown-std.c

 Modified: cfe/trunk/docs/ReleaseNotes.rst
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=320089=320088=320089=diff

 ==
 --- cfe/trunk/docs/ReleaseNotes.rst (original)
 +++ cfe/trunk/docs/ReleaseNotes.rst Thu Dec  7 13:46:26 2017
 @@ -121,6 +121,12 @@ New Compiler Flags
number of attributes are supported outside of C++ mode. See the Clang
attribute documentation for more information about which attributes are
supported for each syntax.
 +
 +- Added the ``-std=c17``, ``-std=gnu17``, and ``-std=iso9899:2017``
 language
 +  mode flags for compatibility with GCC. This enables support for the
 next
 +  version of the C standard, expected to be published by ISO in 2018. The
 only
 +  difference between the ``-std=c17`` and ``-std=c11`` language modes is
 the
 +  value of the ``__STDC_VERSION__`` macro, as C17 is a bug fix release.

  Deprecated Compiler Flags
  -

 Modified: cfe/trunk/include/clang/Basic/LangOptions.def
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=320089=320088=320089=diff

 ==
 --- cfe/trunk/include/clang/Basic/LangOptions.def (original)
 +++ cfe/trunk/include/clang/Basic/LangOptions.def Thu Dec  7 13:46:26 2017
 @@ -1,187 +1,188 @@
 -//===--- LangOptions.def - Language option database -*- C++
 -*-===//
 -//
 -// The LLVM Compiler Infrastructure
 -//
 -// This file is distributed under the University of Illinois Open Source
 -// License. See LICENSE.TXT for details.
 -//

 -//===--===//
 -//
 -// This file defines the language options. Users of this file must
 -// define the LANGOPT macro to make use of this information.
 -//
 -// Optionally, the user may also define:
 -//
 -// BENIGN_LANGOPT: for options that don't affect the construction of the
 AST in
 -// any way (that is, the value can be different between an implicit
 module
 -// and the user of that module).
 -//
 -// COMPATIBLE_LANGOPT: for options that affect the construction of the
 AST in
 -// a way that doesn't prevent interoperability (that is, the value
 can be
 -// different between an explicit module and the user of that module).
 -//
 -// ENUM_LANGOPT: for options that have enumeration, rather than unsigned,
 type.
 -//
 -// VALUE_LANGOPT: for options that describe a value rather than a flag.
 -//
 -// BENIGN_ENUM_LANGOPT, COMPATIBLE_ENUM_LANGOPT,
 -// BENIGN_VALUE_LANGOPT, COMPATIBLE_VALUE_LANGOPT: combinations of the
 above.
 -//
 -// FIXME: Clients should be able to more easily select whether they want
 -// different levels of compatibility versus how to handle different kinds
 -// of option.
 -//
 -// The Description field should be a noun phrase, for instance "frobbing
 all
 -// widgets" or "C's implicit blintz feature".

 

r320113 - Correct line endings that got mixed up in r320089; NFC.

2017-12-07 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Dec  7 15:04:11 2017
New Revision: 320113

URL: http://llvm.org/viewvc/llvm-project?rev=320113=rev
Log:
Correct line endings that got mixed up in r320089; NFC.

Modified:
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/unknown-std.c

Modified: cfe/trunk/include/clang/Frontend/LangStandard.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/LangStandard.h?rev=320113=320112=320113=diff
==
--- cfe/trunk/include/clang/Frontend/LangStandard.h (original)
+++ cfe/trunk/include/clang/Frontend/LangStandard.h Thu Dec  7 15:04:11 2017
@@ -1,114 +1,114 @@
-//===--- LangStandard.h -*- C++ 
-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-#ifndef LLVM_CLANG_FRONTEND_LANGSTANDARD_H
-#define LLVM_CLANG_FRONTEND_LANGSTANDARD_H
-
-#include "clang/Basic/LLVM.h"
-#include "clang/Frontend/FrontendOptions.h"
-#include "llvm/ADT/StringRef.h"
-
-namespace clang {
-
-namespace frontend {
-
-enum LangFeatures {
-  LineComment = (1 << 0),
-  C99 = (1 << 1),
-  C11 = (1 << 2),
-  C17 = (1 << 3),
-  CPlusPlus = (1 << 4),
-  CPlusPlus11 = (1 << 5),
-  CPlusPlus14 = (1 << 6),
-  CPlusPlus17 = (1 << 7),
-  CPlusPlus2a = (1 << 8),
-  Digraphs = (1 << 9),
-  GNUMode = (1 << 10),
-  HexFloat = (1 << 11),
-  ImplicitInt = (1 << 12),
-  OpenCL = (1 << 13)
-};
-
-}
-
-/// LangStandard - Information about the properties of a particular language
-/// standard.
-struct LangStandard {
-  enum Kind {
-#define LANGSTANDARD(id, name, lang, desc, features) \
-lang_##id,
-#include "clang/Frontend/LangStandards.def"
-lang_unspecified
-  };
-
-  const char *ShortName;
-  const char *Description;
-  unsigned Flags;
-  InputKind::Language Language;
-
-public:
-  /// getName - Get the name of this standard.
-  const char *getName() const { return ShortName; }
-
-  /// getDescription - Get the description of this standard.
-  const char *getDescription() const { return Description; }
-
-  /// Get the language that this standard describes.
-  InputKind::Language getLanguage() const { return Language; }
-
-  /// Language supports '//' comments.
-  bool hasLineComments() const { return Flags & frontend::LineComment; }
-
-  /// isC99 - Language is a superset of C99.
-  bool isC99() const { return Flags & frontend::C99; }
-
-  /// isC11 - Language is a superset of C11.
-  bool isC11() const { return Flags & frontend::C11; }
-
-  /// isC17 - Language is a superset of C17.
-  bool isC17() const { return Flags & frontend::C17; }
-
-  /// isCPlusPlus - Language is a C++ variant.
-  bool isCPlusPlus() const { return Flags & frontend::CPlusPlus; }
-
-  /// isCPlusPlus11 - Language is a C++11 variant (or later).
-  bool isCPlusPlus11() const { return Flags & frontend::CPlusPlus11; }
-
-  /// isCPlusPlus14 - Language is a C++14 variant (or later).
-  bool isCPlusPlus14() const { return Flags & frontend::CPlusPlus14; }
-
-  /// isCPlusPlus17 - Language is a C++17 variant (or later).
-  bool isCPlusPlus17() const { return Flags & frontend::CPlusPlus17; }
-
-  /// 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; }
-
-  /// isGNUMode - Language includes GNU extensions.
-  bool isGNUMode() const { return Flags & frontend::GNUMode; }
-
-  /// hasHexFloats - Language supports hexadecimal float constants.
-  bool hasHexFloats() const { return Flags & frontend::HexFloat; }
-
-  /// hasImplicitInt - Language allows variables to be typed as int implicitly.
-  bool hasImplicitInt() const { return Flags & frontend::ImplicitInt; }
-
-  /// isOpenCL - Language is a OpenCL variant.
-  bool isOpenCL() const { return Flags & frontend::OpenCL; }
-
-  static const LangStandard (Kind K);
-  static const LangStandard *getLangStandardForName(StringRef Name);
-};
-
-}  // end namespace clang
-
-#endif
+//===--- LangStandard.h -*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_FRONTEND_LANGSTANDARD_H
+#define LLVM_CLANG_FRONTEND_LANGSTANDARD_H
+
+#include "clang/Basic/LLVM.h"
+#include "clang/Frontend/FrontendOptions.h"

[PATCH] D40671: [clang-tidy] Support specific checks for NOLINT directive

2017-12-07 Thread Anton via Phabricator via cfe-commits
xgsa updated this revision to Diff 126058.
xgsa added a comment.

Documentation update


https://reviews.llvm.org/D40671

Files:
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/index.rst
  test/clang-tidy/nolint.cpp
  test/clang-tidy/nolintnextline.cpp

Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -250,6 +250,56 @@
   value:   'some value'
   ...
 
+:program:`clang-tidy` diagnostics are intended to call out code that does
+not adhere to a coding standard, or is otherwise problematic in some way.
+However, if it is known that the code is correct, the check-specific ways
+to silence the diagnostics could be used, if they are available (e.g. 
+bugprone-use-after-move can be silenced by re-initializing the variable after 
+it has been moved out, misc-string-integer-assignment can be suppressed by 
+explicitly casting the integer to char, readability-implicit-bool-conversion
+can also be suppressed by using explicit casts, etc.). If they are not 
+available or if changing the semantics of the code is not desired, 
+the ``NOLINT`` or ``NOLINTNEXTLINE`` comments can be used instead. For example:
+
+.. code-block:: c++
+
+  class Foo
+  {
+// Silent all the diagnostics for the line
+Foo(int param); // NOLINT
+
+// Silent only the specified checks for the line
+Foo(double param); // NOLINT(google-explicit-constructor, google-runtime-int)
+
+// Silent only the specified diagnostics for the next line
+// NOLINTNEXTLINE(google-explicit-constructor, google-runtime-int)
+Foo(bool param); 
+  };
+
+The formal syntax of ``NOLINT``/``NOLINTNEXTLINE`` is the following:
+
+.. parsed-literal::
+
+  lint-comment:
+lint-command
+lint-command lint-args
+
+  lint-args:
+**(** check-name-list **)**
+
+  check-name-list:
+*check-name*
+check-name-list **,** *check-name*
+
+  lint-command:
+**NOLINT**
+**NOLINTNEXTLINE**
+
+Note that whitespaces between ``NOLINT``/``NOLINTNEXTLINE`` and the opening
+parenthesis are not allowed (in this case the comment will be treated just as
+``NOLINT``/``NOLINTNEXTLINE``), whereas in check names list (inside
+the parenthesis) whitespaces can be used and will be ignored.
+
 .. _LibTooling: http://clang.llvm.org/docs/LibTooling.html
 .. _How To Setup Tooling For LLVM: http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html
 
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -256,6 +256,8 @@
   - `hicpp-use-nullptr `_
   - `hicpp-vararg `_
 
+- Added the ability to suppress specific checks (or all checks) in a ``NOLINT`` or ``NOLINTNEXTLINE`` comment.
+
 Improvements to include-fixer
 -
 
Index: test/clang-tidy/nolint.cpp
===
--- test/clang-tidy/nolint.cpp
+++ test/clang-tidy/nolint.cpp
@@ -13,7 +13,18 @@
 
 class B { B(int i); }; // NOLINT
 
-class C { C(int i); }; // NOLINT(we-dont-care-about-categories-yet)
+class C { C(int i); }; // NOLINT(for-some-other-check)
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
+
+class C1 { C1(int i); }; // NOLINT(*)
+
+class C2 { C2(int i); }; // NOLINT(not-closed-bracket-is-treated-as-skip-all
+
+class C3 { C3(int i); }; // NOLINT(google-explicit-constructor)
+
+class C4 { C4(int i); }; // NOLINT(some-check, google-explicit-constructor)
+
+class C5 { C5(int i); }; // NOLINT without-brackets-skip-all, another-check
 
 void f() {
   int i;
@@ -35,4 +46,4 @@
 #define DOUBLE_MACRO MACRO(H) // NOLINT
 DOUBLE_MACRO
 
-// CHECK-MESSAGES: Suppressed 8 warnings (8 NOLINT)
+// CHECK-MESSAGES: Suppressed 12 warnings (12 NOLINT)
Index: test/clang-tidy/nolintnextline.cpp
===
--- test/clang-tidy/nolintnextline.cpp
+++ test/clang-tidy/nolintnextline.cpp
@@ -4,8 +4,24 @@
 // NOLINTNEXTLINE
 class B { B(int i); };
 
-// NOLINTNEXTLINE(we-dont-care-about-categories-yet)
+// NOLINTNEXTLINE(for-some-other-check)
 class C { C(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
+
+// NOLINTNEXTLINE(*)
+class C1 { C1(int i); };
+
+// NOLINTNEXTLINE(not-closed-bracket-is-treated-as-skip-all
+class C2 { C2(int i); };
+
+// NOLINTNEXTLINE(google-explicit-constructor)
+class C3 { C3(int i); };
+
+// NOLINTNEXTLINE(some-check, google-explicit-constructor)
+class C4 { C4(int i); };
+
+// NOLINTNEXTLINE without-brackets-skip-all, another-check
+class C5 { C5(int i); };
 
 
 // NOLINTNEXTLINE
@@ -28,6 +44,6 @@
 // NOLINTNEXTLINE
 MACRO_NOARG
 
-// CHECK-MESSAGES: 

[PATCH] D40218: [Clang] Add __builtin_launder

2017-12-07 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/CodeGen/CGBuiltin.cpp:1674
+Value *Ptr = EmitScalarExpr(E->getArg(0));
+Ptr = Builder.CreateInvariantGroupBarrier(Ptr);
+return RValue::get(Ptr);

It would be nice to avoid this for types that contain no const subobjects / 
reference subobjects / vptrs. I think we can also omit this entirely if 
`-fstrict-vtable-ptrs` is disabled, since in that case we don't generate any 
`invariant.group` metadata.

I'd be OK with the former being left to a future change, but the latter should 
be part of this change so we don't generate unnecessarily-inefficient code in 
the default mode for uses of `std::launder`.



Comment at: lib/Sema/SemaChecking.cpp:860-864
+  if (!ArgTy->isPointerType()) {
+S.Diag(TheCall->getLocStart(), diag::err_builtin_launder_non_pointer_arg)
+<< TheCall->getSourceRange();
+return ExprError();
+  }

Please also check that the pointee type is an object type -- per 
[ptr.launder]p3, "the program is ill-formed if T is a function type or cv 
void", and we don't want our builtin to need to deal with such cases.


https://reviews.llvm.org/D40218



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


[PATCH] D40671: [clang-tidy] Support specific checks for NOLINT directive

2017-12-07 Thread Anton via Phabricator via cfe-commits
xgsa marked an inline comment as done.
xgsa added a comment.

In https://reviews.llvm.org/D40671#948826, @aaron.ballman wrote:

> There are still some outstanding concerns around the documentation wording, 
> but once those are resolved it should be ready to commit. If you don't have 
> commit access, I can commit on your behalf -- just let me know.


Yes, I don't have commit access, so I need your help with this, Aaron. Thank 
you!


https://reviews.llvm.org/D40671



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


Re: r320089 - Add new language mode flags for C17.

2017-12-07 Thread Aaron Ballman via cfe-commits
On Thu, Dec 7, 2017 at 5:59 PM, Ahmed Bougacha  wrote:
> On Thu, Dec 7, 2017 at 2:56 PM, Richard Smith via cfe-commits
>  wrote:
>> Looks like this might have messed up the line endings in a few files?
>
> Should be taken care of in r320112.

Thanks, I was just getting on that. Sorry about the inadvertent churn there!

~Aaron

>
> -Ahmed
>
>> On 7 December 2017 at 13:46, Aaron Ballman via cfe-commits
>>  wrote:
>>>
>>> Author: aaronballman
>>> Date: Thu Dec  7 13:46:26 2017
>>> New Revision: 320089
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=320089=rev
>>> Log:
>>> Add new language mode flags for C17.
>>>
>>> This adds -std=c17, -std=gnu17, and -std=iso9899:2017 as language mode
>>> flags for C17 and updates the value of __STDC_VERSION__ to the value based
>>> on the C17 FDIS. Given that this ballot cannot succeed until 2018, it is
>>> expected that we (and GCC) will add c18 flags as aliases once the ballot
>>> passes.
>>>
>>> Modified:
>>> cfe/trunk/docs/ReleaseNotes.rst
>>> 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/unknown-std.c
>>>
>>> Modified: cfe/trunk/docs/ReleaseNotes.rst
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=320089=320088=320089=diff
>>>
>>> ==
>>> --- cfe/trunk/docs/ReleaseNotes.rst (original)
>>> +++ cfe/trunk/docs/ReleaseNotes.rst Thu Dec  7 13:46:26 2017
>>> @@ -121,6 +121,12 @@ New Compiler Flags
>>>number of attributes are supported outside of C++ mode. See the Clang
>>>attribute documentation for more information about which attributes are
>>>supported for each syntax.
>>> +
>>> +- Added the ``-std=c17``, ``-std=gnu17``, and ``-std=iso9899:2017``
>>> language
>>> +  mode flags for compatibility with GCC. This enables support for the
>>> next
>>> +  version of the C standard, expected to be published by ISO in 2018. The
>>> only
>>> +  difference between the ``-std=c17`` and ``-std=c11`` language modes is
>>> the
>>> +  value of the ``__STDC_VERSION__`` macro, as C17 is a bug fix release.
>>>
>>>  Deprecated Compiler Flags
>>>  -
>>>
>>> Modified: cfe/trunk/include/clang/Basic/LangOptions.def
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=320089=320088=320089=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/Basic/LangOptions.def (original)
>>> +++ cfe/trunk/include/clang/Basic/LangOptions.def Thu Dec  7 13:46:26 2017
>>> @@ -1,187 +1,188 @@
>>> -//===--- LangOptions.def - Language option database -*- C++
>>> -*-===//
>>> -//
>>> -// The LLVM Compiler Infrastructure
>>> -//
>>> -// This file is distributed under the University of Illinois Open Source
>>> -// License. See LICENSE.TXT for details.
>>> -//
>>>
>>> -//===--===//
>>> -//
>>> -// This file defines the language options. Users of this file must
>>> -// define the LANGOPT macro to make use of this information.
>>> -//
>>> -// Optionally, the user may also define:
>>> -//
>>> -// BENIGN_LANGOPT: for options that don't affect the construction of the
>>> AST in
>>> -// any way (that is, the value can be different between an implicit
>>> module
>>> -// and the user of that module).
>>> -//
>>> -// COMPATIBLE_LANGOPT: for options that affect the construction of the
>>> AST in
>>> -// a way that doesn't prevent interoperability (that is, the value
>>> can be
>>> -// different between an explicit module and the user of that module).
>>> -//
>>> -// ENUM_LANGOPT: for options that have enumeration, rather than unsigned,
>>> type.
>>> -//
>>> -// VALUE_LANGOPT: for options that describe a value rather than a flag.
>>> -//
>>> -// BENIGN_ENUM_LANGOPT, COMPATIBLE_ENUM_LANGOPT,
>>> -// BENIGN_VALUE_LANGOPT, COMPATIBLE_VALUE_LANGOPT: combinations of the
>>> above.
>>> -//
>>> -// FIXME: Clients should be able to more easily select whether they want
>>> -// different levels of compatibility versus how to handle different kinds
>>> -// of option.
>>> -//
>>> -// The Description field should be a noun phrase, for instance "frobbing
>>> all
>>> -// widgets" or "C's implicit blintz feature".
>>>
>>> -//===--===//
>>> -
>>> -#ifndef LANGOPT
>>> -#  error Define the LANGOPT macro to handle language options
>>> -#endif
>>> -
>>> -#ifndef COMPATIBLE_LANGOPT
>>> -#  define COMPATIBLE_LANGOPT(Name, Bits, Default, Description) \
>>> - 

[PATCH] D39451: P0620 follow-up: deducing `auto` from braced-init-list in new expr

2017-12-07 Thread Zhihao Yuan via Phabricator via cfe-commits
lichray added a comment.

Ping.  Just accept this as a DR, like what GCC does, I guess?


https://reviews.llvm.org/D39451



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


Re: r320089 - Add new language mode flags for C17.

2017-12-07 Thread Ahmed Bougacha via cfe-commits
On Thu, Dec 7, 2017 at 2:56 PM, Richard Smith via cfe-commits
 wrote:
> Looks like this might have messed up the line endings in a few files?

Should be taken care of in r320112.

-Ahmed

> On 7 December 2017 at 13:46, Aaron Ballman via cfe-commits
>  wrote:
>>
>> Author: aaronballman
>> Date: Thu Dec  7 13:46:26 2017
>> New Revision: 320089
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=320089=rev
>> Log:
>> Add new language mode flags for C17.
>>
>> This adds -std=c17, -std=gnu17, and -std=iso9899:2017 as language mode
>> flags for C17 and updates the value of __STDC_VERSION__ to the value based
>> on the C17 FDIS. Given that this ballot cannot succeed until 2018, it is
>> expected that we (and GCC) will add c18 flags as aliases once the ballot
>> passes.
>>
>> Modified:
>> cfe/trunk/docs/ReleaseNotes.rst
>> 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/unknown-std.c
>>
>> Modified: cfe/trunk/docs/ReleaseNotes.rst
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=320089=320088=320089=diff
>>
>> ==
>> --- cfe/trunk/docs/ReleaseNotes.rst (original)
>> +++ cfe/trunk/docs/ReleaseNotes.rst Thu Dec  7 13:46:26 2017
>> @@ -121,6 +121,12 @@ New Compiler Flags
>>number of attributes are supported outside of C++ mode. See the Clang
>>attribute documentation for more information about which attributes are
>>supported for each syntax.
>> +
>> +- Added the ``-std=c17``, ``-std=gnu17``, and ``-std=iso9899:2017``
>> language
>> +  mode flags for compatibility with GCC. This enables support for the
>> next
>> +  version of the C standard, expected to be published by ISO in 2018. The
>> only
>> +  difference between the ``-std=c17`` and ``-std=c11`` language modes is
>> the
>> +  value of the ``__STDC_VERSION__`` macro, as C17 is a bug fix release.
>>
>>  Deprecated Compiler Flags
>>  -
>>
>> Modified: cfe/trunk/include/clang/Basic/LangOptions.def
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=320089=320088=320089=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/LangOptions.def (original)
>> +++ cfe/trunk/include/clang/Basic/LangOptions.def Thu Dec  7 13:46:26 2017
>> @@ -1,187 +1,188 @@
>> -//===--- LangOptions.def - Language option database -*- C++
>> -*-===//
>> -//
>> -// The LLVM Compiler Infrastructure
>> -//
>> -// This file is distributed under the University of Illinois Open Source
>> -// License. See LICENSE.TXT for details.
>> -//
>>
>> -//===--===//
>> -//
>> -// This file defines the language options. Users of this file must
>> -// define the LANGOPT macro to make use of this information.
>> -//
>> -// Optionally, the user may also define:
>> -//
>> -// BENIGN_LANGOPT: for options that don't affect the construction of the
>> AST in
>> -// any way (that is, the value can be different between an implicit
>> module
>> -// and the user of that module).
>> -//
>> -// COMPATIBLE_LANGOPT: for options that affect the construction of the
>> AST in
>> -// a way that doesn't prevent interoperability (that is, the value
>> can be
>> -// different between an explicit module and the user of that module).
>> -//
>> -// ENUM_LANGOPT: for options that have enumeration, rather than unsigned,
>> type.
>> -//
>> -// VALUE_LANGOPT: for options that describe a value rather than a flag.
>> -//
>> -// BENIGN_ENUM_LANGOPT, COMPATIBLE_ENUM_LANGOPT,
>> -// BENIGN_VALUE_LANGOPT, COMPATIBLE_VALUE_LANGOPT: combinations of the
>> above.
>> -//
>> -// FIXME: Clients should be able to more easily select whether they want
>> -// different levels of compatibility versus how to handle different kinds
>> -// of option.
>> -//
>> -// The Description field should be a noun phrase, for instance "frobbing
>> all
>> -// widgets" or "C's implicit blintz feature".
>>
>> -//===--===//
>> -
>> -#ifndef LANGOPT
>> -#  error Define the LANGOPT macro to handle language options
>> -#endif
>> -
>> -#ifndef COMPATIBLE_LANGOPT
>> -#  define COMPATIBLE_LANGOPT(Name, Bits, Default, Description) \
>> - LANGOPT(Name, Bits, Default, Description)
>> -#endif
>> -
>> -#ifndef BENIGN_LANGOPT
>> -#  define BENIGN_LANGOPT(Name, Bits, Default, Description) \
>> - COMPATIBLE_LANGOPT(Name, Bits, Default, Description)
>> -#endif
>> -
>> -#ifndef ENUM_LANGOPT
>> -#  define ENUM_LANGOPT(Name, Type, Bits, 

r320112 - Remove line-endings added by r320089. NFC.

2017-12-07 Thread Ahmed Bougacha via cfe-commits
Author: ab
Date: Thu Dec  7 14:58:02 2017
New Revision: 320112

URL: http://llvm.org/viewvc/llvm-project?rev=320112=rev
Log:
Remove line-endings added by r320089. NFC.

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

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=320112=320111=320112=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Thu Dec  7 14:58:02 2017
@@ -1,188 +1,188 @@
-//===--- LangOptions.def - Language option database -*- C++ 
-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-//
-// This file defines the language options. Users of this file must
-// define the LANGOPT macro to make use of this information.
-//
-// Optionally, the user may also define:
-//
-// BENIGN_LANGOPT: for options that don't affect the construction of the AST in
-// any way (that is, the value can be different between an implicit module
-// and the user of that module).
-//
-// COMPATIBLE_LANGOPT: for options that affect the construction of the AST in
-// a way that doesn't prevent interoperability (that is, the value can be
-// different between an explicit module and the user of that module).
-//
-// ENUM_LANGOPT: for options that have enumeration, rather than unsigned, type.
-//
-// VALUE_LANGOPT: for options that describe a value rather than a flag.
-//
-// BENIGN_ENUM_LANGOPT, COMPATIBLE_ENUM_LANGOPT,
-// BENIGN_VALUE_LANGOPT, COMPATIBLE_VALUE_LANGOPT: combinations of the above.
-//
-// FIXME: Clients should be able to more easily select whether they want
-// different levels of compatibility versus how to handle different kinds
-// of option.
-//
-// The Description field should be a noun phrase, for instance "frobbing all
-// widgets" or "C's implicit blintz feature".
-//===--===//
-
-#ifndef LANGOPT
-#  error Define the LANGOPT macro to handle language options
-#endif
-
-#ifndef COMPATIBLE_LANGOPT
-#  define COMPATIBLE_LANGOPT(Name, Bits, Default, Description) \
- LANGOPT(Name, Bits, Default, Description)
-#endif
-
-#ifndef BENIGN_LANGOPT
-#  define BENIGN_LANGOPT(Name, Bits, Default, Description) \
- COMPATIBLE_LANGOPT(Name, Bits, Default, Description)
-#endif
-
-#ifndef ENUM_LANGOPT
-#  define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
- LANGOPT(Name, Bits, Default, Description)
-#endif
-
-#ifndef COMPATIBLE_ENUM_LANGOPT
-#  define COMPATIBLE_ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
- ENUM_LANGOPT(Name, Type, Bits, Default, Description)
-#endif
-
-#ifndef BENIGN_ENUM_LANGOPT
-#  define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
- COMPATIBLE_ENUM_LANGOPT(Name, Type, Bits, Default, Description)
-#endif
-
-#ifndef VALUE_LANGOPT
-#  define VALUE_LANGOPT(Name, Bits, Default, Description) \
- LANGOPT(Name, Bits, Default, Description)
-#endif
-
-#ifndef COMPATIBLE_VALUE_LANGOPT
-#  define COMPATIBLE_VALUE_LANGOPT(Name, Bits, Default, Description) \
- VALUE_LANGOPT(Name, Bits, Default, Description)
-#endif
-
-#ifndef BENIGN_VALUE_LANGOPT
-#  define BENIGN_VALUE_LANGOPT(Name, Bits, Default, Description) \
- COMPATIBLE_VALUE_LANGOPT(Name, Bits, Default, Description)
-#endif
-
-// FIXME: A lot of the BENIGN_ options should be COMPATIBLE_ instead.
-LANGOPT(C99   , 1, 0, "C99")
-LANGOPT(C11   , 1, 0, "C11")
-LANGOPT(C17   , 1, 0, "C17")
-LANGOPT(MSVCCompat, 1, 0, "Microsoft Visual C++ full compatibility 
mode")
-LANGOPT(MicrosoftExt  , 1, 0, "Microsoft C++ extensions")
-LANGOPT(AsmBlocks , 1, 0, "Microsoft inline asm blocks")
-LANGOPT(Borland   , 1, 0, "Borland extensions")
-LANGOPT(CPlusPlus , 1, 0, "C++")
-LANGOPT(CPlusPlus11   , 1, 0, "C++11")
-LANGOPT(CPlusPlus14   , 1, 0, "C++14")
-LANGOPT(CPlusPlus17   , 1, 0, "C++17")
-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,
-   "Objective-C auto-synthesized properties")
-BENIGN_LANGOPT(EncodeExtendedBlockSig , 1, 0,
-   "Encoding extended block type signature")
-BENIGN_LANGOPT(ObjCInferRelatedResultType , 1, 1,
-   "Objective-C related result type inference")
-LANGOPT(AppExt , 1, 0, "Objective-C App Extension")
-LANGOPT(Trigraphs , 1, 0,"trigraphs")
-LANGOPT(LineComment   , 1, 0, "'//' comments")
-LANGOPT(Bool  , 1, 0, "bool, true, and false 

[PATCH] D40948: Switch Clang's default C++ language target to C++14

2017-12-07 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D40948#948843, @t.p.northover wrote:

> Thanks Richard. I'll file the bugs tomorrow for the issues you suggest. Do 
> you see either of them blocking the change to C++14 as a default? On a scale 
> of "no", "no but I want a commitment to fix them" and "yes" sort of thing.


I don't think these should block the change of default. The //new-expression// 
one is actually a missing C++14 feature -- we're supposed to be generating a 
call to a new ABI entry point in the negative-array-bound case to throw a 
`std::bad_array_new_length` (we missed it because it's a feature added by a 
core issue rather than by a paper as I recall). I see no problem with shipping 
a Clang 6 that doesn't implement the full feature, including throwing the new 
exception. I'm not entirely happy about shipping Clang 6 without fixing the 
negative-bound check, since that means we'll generate code that is less 
hardened against certain common attacks by default, but I don't think I would 
be release-blocker-level unhappy.




Comment at: clang/test/CodeGenCXX/vtable-available-externally.cpp:1-2
-// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -emit-llvm -o %t
-// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -O2 
-disable-llvm-passes -emit-llvm -o %t.opt
+// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -std=c++98 -emit-llvm 
-o %t
+// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -std=c++98 -O2 
-disable-llvm-passes -emit-llvm -o %t.opt
 // RUN: FileCheck --check-prefix=CHECK-TEST1 %s < %t

t.p.northover wrote:
> rsmith wrote:
> > Why does this one need a -std= flag?
> It's a bit late here so I'll just give the proximal cause this evening in 
> case that makes it obvious to you. I'll dig deeper tomorrow if not.
> 
> In this particular case (without the std flag) on the -O2 run line the 
> "vtable for Test11::D" does not get marked "available_externally".
> 
> The diff on line 1 is definitely unneeded.
See comment below.



Comment at: clang/test/CodeGenCXX/vtable-available-externally.cpp:275
 struct C {
   virtual D& operator=(const D&);
 };

To make this test work in C++11 onwards, you need to add a virtual move 
assignment operator here:

```
virtual D& operator=(D&&);
```


Repository:
  rC Clang

https://reviews.llvm.org/D40948



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


[PATCH] D40948: Switch Clang's default C++ language target to C++14

2017-12-07 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover added a comment.

Thanks Richard. I'll file the bugs tomorrow for the issues you suggest. Do you 
see either of them blocking the change to C++14 as a default? On a scale of 
"no", "no but I want a commitment to fix them" and "yes" sort of thing.

Tonight I've just got one comment that may or may not be useful context before 
I give you a proper answer tomorrow:




Comment at: clang/test/CodeGenCXX/vtable-available-externally.cpp:1-2
-// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -emit-llvm -o %t
-// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -O2 
-disable-llvm-passes -emit-llvm -o %t.opt
+// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -std=c++98 -emit-llvm 
-o %t
+// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -std=c++98 -O2 
-disable-llvm-passes -emit-llvm -o %t.opt
 // RUN: FileCheck --check-prefix=CHECK-TEST1 %s < %t

rsmith wrote:
> Why does this one need a -std= flag?
It's a bit late here so I'll just give the proximal cause this evening in case 
that makes it obvious to you. I'll dig deeper tomorrow if not.

In this particular case (without the std flag) on the -O2 run line the "vtable 
for Test11::D" does not get marked "available_externally".

The diff on line 1 is definitely unneeded.



Comment at: clang/test/Parser/cxx1z-nested-namespace-definition.cpp:3-4
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98
 // RUN: not %clang_cc1 -x c++ -fixit %t -Werror -DFIXIT
 // RUN: %clang_cc1 -x c++ %t -DFIXIT
 // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++17 -Wc++14-compat

rsmith wrote:
> I think these two should also be `-std=c++98`, right?
Probably; I'll convince myself of that fact tomorrow.



Comment at: clang/test/SemaCXX/unknown-type-name.cpp:110-111
 
 // FIXME: We can tell this was intended to be a function because it does not
 //have a dependent nested name specifier.
+template int i(T::type, int());

rsmith wrote:
> Maybe delete this (incorrect in C++14) FIXME?
Sounds sensible.


Repository:
  rC Clang

https://reviews.llvm.org/D40948



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


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

2017-12-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: dcoughlin.
aaron.ballman added a subscriber: dcoughlin.
aaron.ballman added a comment.

I share the concerns that @Eugene.Zelenko brought up regarding this not being 
in the analyzer. This is a path sensitive problem that I'm not certain 
clang-tidy is the best home for. You cover many of the simple cases, but fail 
to cover cases like nested loops, unsigned integer wrapping, non-integral 
types, function calls, globals, etc. I'm not certain this check will generalize 
over time as part of clang-tidy in the way it would in the analyzer. I'd be 
curious to hear what @alexfh and @dcoughlin think, though.


https://reviews.llvm.org/D40937



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


[libunwind] r320103 - Creating release candidate rc3 from release_501 branch

2017-12-07 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Thu Dec  7 14:11:09 2017
New Revision: 320103

URL: http://llvm.org/viewvc/llvm-project?rev=320103=rev
Log:
Creating release candidate rc3 from release_501 branch

Added:
libunwind/tags/RELEASE_501/rc3/   (props changed)
  - copied from r320102, libunwind/branches/release_50/

Propchange: libunwind/tags/RELEASE_501/rc3/
--
svn:mergeinfo = /libunwind/trunk:308871,309147


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


[libcxxabi] r320097 - Creating release candidate rc3 from release_501 branch

2017-12-07 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Thu Dec  7 14:10:43 2017
New Revision: 320097

URL: http://llvm.org/viewvc/llvm-project?rev=320097=rev
Log:
Creating release candidate rc3 from release_501 branch

Added:
libcxxabi/tags/RELEASE_501/rc3/
  - copied from r320096, libcxxabi/branches/release_50/

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


[libcxx] r320096 - Creating release candidate rc3 from release_501 branch

2017-12-07 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Thu Dec  7 14:10:39 2017
New Revision: 320096

URL: http://llvm.org/viewvc/llvm-project?rev=320096=rev
Log:
Creating release candidate rc3 from release_501 branch

Added:
libcxx/tags/RELEASE_501/rc3/   (props changed)
  - copied from r320095, libcxx/branches/release_50/

Propchange: libcxx/tags/RELEASE_501/rc3/
--
--- svn:mergeinfo (added)
+++ svn:mergeinfo Thu Dec  7 14:10:39 2017
@@ -0,0 +1,2 @@
+/libcxx/branches/apple:136569-137939
+/libcxx/trunk:309296,309307,309474,309838,309851,309917,309920


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


[PATCH] D40671: [clang-tidy] Support specific checks for NOLINT directive

2017-12-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman requested changes to this revision.
aaron.ballman added a comment.
This revision now requires changes to proceed.

In https://reviews.llvm.org/D40671#947762, @xgsa wrote:

> So can this patch be submitted? Should I do something to make it happen?


There are still some outstanding concerns around the documentation wording, but 
once those are resolved it should be ready to commit. If you don't have commit 
access, I can commit on your behalf -- just let me know.




Comment at: docs/clang-tidy/index.rst:254-255
+While :program:`clang-tidy` diagnostics are intended to call out code that does
+not adhere to a coding standard, or is otherwise problematic in some way, there
+are times when it is more appropriate to silence the diagnostic instead of 
+changing the semantics of the code. The preferable way of doing this is using

xgsa wrote:
> aaron.ballman wrote:
> > I would reword this somewhat now. I would put a period before ", there are 
> > times" and then move that whole "there are times" clause below.
> I tried to move the "there are times"-clause below, but in this case "The 
> preferable way of doing this is using..." becomes unclear, because it tries 
> to explain the way of doing something without naming the purpose that is 
> expected to achieve. So I suppose, it is necessary to place "However, there 
> are times when it is more appropriate to silence the diagnostic instead of 
> changing the semantics of the code" here. Am I missing something?
The current formatting of this flows strangely. It starts by saying clang-tidy 
calls out problems, says there are times when it is more appropriate to silence 
the diagnostic without changing the code, then says the preferred way is to 
change the code, then says you can NOLINT it if you don't want to change the 
code.

I'd prefer if the flow was: clang-tidy calls out problems, the preferred way is 
to change the code, but there are still times when changing the code is not 
helpful and thus you can use NOLINT.


https://reviews.llvm.org/D40671



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


[PATCH] D35181: Defer addition of keywords to identifier table when loading AST

2017-12-07 Thread Johann Klähn via Phabricator via cfe-commits
jklaehn added a comment.

Ping, can you take another look?


https://reviews.llvm.org/D35181



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


[PATCH] D40940: [ubsan] Use pass_object_size info in bounds checks

2017-12-07 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 126037.
vsk added a comment.

Thanks for your feedback.

- Give up on 0-sized types.
- Give up on pass_object_size(2 | 3).


https://reviews.llvm.org/D40940

Files:
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/ubsan-pass-object-size.c

Index: test/CodeGen/ubsan-pass-object-size.c
===
--- /dev/null
+++ test/CodeGen/ubsan-pass-object-size.c
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 %s -emit-llvm -w -triple x86_64-apple-darwin10 -fsanitize=array-bounds -o - | FileCheck %s
+
+// CHECK-LABEL: define i32 @foo(
+int foo(int *const p __attribute__((pass_object_size(0))), int n) {
+  int x = (p)[n];
+
+  // CHECK: [[SIZE_ALLOCA:%.*]] = alloca i64, align 8
+  // CHECK: store i64 %{{.*}}, i64* [[SIZE_ALLOCA]], align 8
+  // CHECK: [[LOAD_SIZE:%.*]] = load i64, i64* [[SIZE_ALLOCA]], align 8, !nosanitize
+  // CHECK-NEXT: [[SCALED_SIZE:%.*]] = udiv i64 [[LOAD_SIZE]], 4, !nosanitize
+  // CHECK-NEXT: [[SEXT_N:%.*]] = sext i32 %{{.*}} to i64, !nosanitize
+  // CHECK-NEXT: [[ICMP:%.*]] = icmp ult i64 [[SEXT_N]], [[SCALED_SIZE]], !nosanitize
+  // CHECK-NEXT: br i1 [[ICMP]], {{.*}} !nosanitize
+  // CHECK: __ubsan_handle_out_of_bounds
+
+  {
+int **p =  // Shadow the parameter. The pass_object_size info is lost.
+// CHECK-NOT: __ubsan_handle_out_of_bounds
+x = *p[n];
+  }
+
+  // CHECK: ret i32
+  return x;
+}
+
+typedef struct {} ZeroSizedType;
+
+// CHECK-LABEL: define void @bar(
+ZeroSizedType bar(ZeroSizedType *const p __attribute__((pass_object_size(0))), int n) {
+  // CHECK-NOT: __ubsan_handle_out_of_bounds
+  // CHECK: ret void
+  return p[n];
+}
+
+// CHECK-LABEL: define i32 @baz(
+int baz(int *const p __attribute__((pass_object_size(1))), int n) {
+  // CHECK: __ubsan_handle_out_of_bounds
+  // CHECK: ret i32
+  return p[n];
+}
+
+// CHECK-LABEL: define i32 @mat(
+int mat(int *const p __attribute__((pass_object_size(2))), int n) {
+  // CHECK-NOT: __ubsan_handle_out_of_bounds
+  // CHECK: ret i32
+  return p[n];
+}
+
+// CHECK-LABEL: define i32 @pat(
+int pat(int *const p __attribute__((pass_object_size(3))), int n) {
+  // CHECK-NOT: __ubsan_handle_out_of_bounds
+  // CHECK: ret i32
+  return p[n];
+}
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -3932,6 +3932,10 @@
LValueBaseInfo *BaseInfo = nullptr,
TBAAAccessInfo *TBAAInfo = nullptr);
 
+  /// If \p E references a parameter with pass_object_size info, load the
+  /// object size and divide by the size of \p EltTy. Otherwise return null.
+  llvm::Value *LoadPassedObjectSize(const Expr *E, QualType EltTy);
+
   void EmitSanitizerStatReport(llvm::SanitizerStatKind SSK);
 
 private:
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -814,6 +814,45 @@
   return false;
 }
 
+llvm::Value *CodeGenFunction::LoadPassedObjectSize(const Expr *E,
+   QualType EltTy) {
+  ASTContext  = getContext();
+  uint64_t EltSize = C.getTypeSizeInChars(EltTy).getQuantity();
+  if (!EltSize)
+return nullptr;
+
+  auto *ArrayDeclRef = dyn_cast(E->IgnoreParenImpCasts());
+  if (!ArrayDeclRef)
+return nullptr;
+
+  auto *ParamDecl = dyn_cast(ArrayDeclRef->getDecl());
+  if (!ParamDecl)
+return nullptr;
+
+  auto *POSAttr = ParamDecl->getAttr();
+  if (!POSAttr)
+return nullptr;
+
+  // Don't load the size if it's a lower bound.
+  int POSType = POSAttr->getType();
+  if (POSType != 0 && POSType != 1)
+return nullptr;
+
+  // Find the implicit size parameter.
+  auto PassedSizeIt = SizeArguments.find(ParamDecl);
+  if (PassedSizeIt == SizeArguments.end())
+return nullptr;
+
+  const ImplicitParamDecl *PassedSizeDecl = PassedSizeIt->second;
+  assert(LocalDeclMap.count(PassedSizeDecl) && "Passed size not loadable");
+  Address AddrOfSize = LocalDeclMap.find(PassedSizeDecl)->second;
+  llvm::Value *SizeInBytes = EmitLoadOfScalar(AddrOfSize, /*Volatile=*/false,
+  C.getSizeType(), E->getExprLoc());
+  llvm::Value *SizeOfElement =
+  llvm::ConstantInt::get(SizeInBytes->getType(), EltSize);
+  return Builder.CreateUDiv(SizeInBytes, SizeOfElement);
+}
+
 /// If Base is known to point to the start of an array, return the length of
 /// that array. Return 0 if the length cannot be determined.
 static llvm::Value *getArrayIndexingBound(
@@ -835,9 +874,16 @@
 return CGF.Builder.getInt(CAT->getSize());
   else if (const auto *VAT = dyn_cast(AT))
 return CGF.getVLASize(VAT).first;
+  // Ignore pass_object_size here. It's not applicable on decayed pointers.
 }
   }
 
+  QualType 

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

2017-12-07 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Thu Dec  7 13:55:09 2017
New Revision: 320091

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

Modified:
cfe/trunk/include/clang/Analysis/CFG.h
cfe/trunk/include/clang/Analysis/CallGraph.h
cfe/trunk/include/clang/Analysis/Support/BumpVector.h
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/lib/Analysis/CallGraph.cpp

Modified: cfe/trunk/include/clang/Analysis/CFG.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CFG.h?rev=320091=320090=320091=diff
==
--- cfe/trunk/include/clang/Analysis/CFG.h (original)
+++ cfe/trunk/include/clang/Analysis/CFG.h Thu Dec  7 13:55:09 2017
@@ -1,4 +1,4 @@
-//===--- CFG.h - Classes for representing and building CFGs--*- C++ 
-*-===//
+//===- CFG.h - Classes for representing and building CFGs ---*- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -17,38 +17,38 @@
 
 #include "clang/AST/Stmt.h"
 #include "clang/Analysis/Support/BumpVector.h"
-#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/LLVM.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/GraphTraits.h"
+#include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/iterator_range.h"
 #include "llvm/Support/Allocator.h"
-#include "llvm/Support/Casting.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
+#include 
 #include 
 #include 
+#include 
 
 namespace clang {
-  class CXXDestructorDecl;
-  class Decl;
-  class Stmt;
-  class Expr;
-  class FieldDecl;
-  class VarDecl;
-  class CXXCtorInitializer;
-  class CXXBaseSpecifier;
-  class CXXBindTemporaryExpr;
-  class CFG;
-  class PrinterHelper;
-  class LangOptions;
-  class ASTContext;
-  class CXXRecordDecl;
-  class CXXDeleteExpr;
-  class CXXNewExpr;
-  class BinaryOperator;
+
+class ASTContext;
+class BinaryOperator;
+class CFG;
+class CXXBaseSpecifier;
+class CXXBindTemporaryExpr;
+class CXXCtorInitializer;
+class CXXDeleteExpr;
+class CXXDestructorDecl;
+class CXXNewExpr;
+class CXXRecordDecl;
+class Decl;
+class FieldDecl;
+class LangOptions;
+class VarDecl;
 
 /// CFGElement - Represents a top-level expression in a basic block.
 class CFGElement {
@@ -76,14 +76,14 @@ protected:
   llvm::PointerIntPair Data2;
 
   CFGElement(Kind kind, const void *Ptr1, const void *Ptr2 = nullptr)
-: Data1(const_cast(Ptr1), ((unsigned) kind) & 0x3),
-  Data2(const_cast(Ptr2), (((unsigned) kind) >> 2) & 0x3) {
+  : Data1(const_cast(Ptr1), ((unsigned) kind) & 0x3),
+Data2(const_cast(Ptr2), (((unsigned) kind) >> 2) & 0x3) {
 assert(getKind() == kind);
   }
 
-  CFGElement() {}
-public:
+  CFGElement() = default;
 
+public:
   /// \brief Convert to the specified CFGElement type, asserting that this
   /// CFGElement is of the desired type.
   template
@@ -125,7 +125,9 @@ public:
 
 private:
   friend class CFGElement;
-  CFGStmt() {}
+
+  CFGStmt() = default;
+
   static bool isKind(const CFGElement ) {
 return E.getKind() == Statement;
   }
@@ -144,7 +146,9 @@ public:
 
 private:
   friend class CFGElement;
-  CFGInitializer() {}
+
+  CFGInitializer() = default;
+
   static bool isKind(const CFGElement ) {
 return E.getKind() == Initializer;
   }
@@ -163,7 +167,9 @@ public:
 
 private:
   friend class CFGElement;
-  CFGNewAllocator() {}
+
+  CFGNewAllocator() = default;
+
   static bool isKind(const CFGElement ) {
 return elem.getKind() == NewAllocator;
   }
@@ -177,19 +183,20 @@ private:
 /// entered.
 class CFGLoopExit : public CFGElement {
 public:
-explicit CFGLoopExit(const Stmt *stmt)
-: CFGElement(LoopExit, stmt) {}
+  explicit CFGLoopExit(const Stmt *stmt) : CFGElement(LoopExit, stmt) {}
 
-const Stmt *getLoopStmt() const {
-  return static_cast(Data1.getPointer());
-}
+  const Stmt *getLoopStmt() const {
+return static_cast(Data1.getPointer());
+  }
 
 private:
-friend class CFGElement;
-CFGLoopExit() {}
-static bool isKind(const CFGElement ) {
-  return elem.getKind() == LoopExit;
-}
+  friend class CFGElement;
+
+  CFGLoopExit() = default;
+
+  static bool isKind(const CFGElement ) {
+return elem.getKind() == LoopExit;
+  }
 };
 
 /// Represents the point where the lifetime of an automatic object ends
@@ -208,7 +215,9 @@ public:
 
 private:
   friend class CFGElement;
-  CFGLifetimeEnds() {}
+
+  CFGLifetimeEnds() = default;
+
   static bool isKind(const CFGElement ) {
 return elem.getKind() == LifetimeEnds;
   }
@@ -218,7 +227,8 @@ private:
 /// by compiler on various occasions.
 class CFGImplicitDtor : public CFGElement {
 protected:
-  CFGImplicitDtor() {}
+  CFGImplicitDtor() = default;
+
   CFGImplicitDtor(Kind kind, const void *data1, const void *data2 = nullptr)
 

r320082 - [OpenMP] NVPTX: Set default/minimum compute capability to sm_35

2017-12-07 Thread George Rokos via cfe-commits
Author: grokos
Date: Thu Dec  7 12:27:31 2017
New Revision: 320082

URL: http://llvm.org/viewvc/llvm-project?rev=320082=rev
Log:
[OpenMP] NVPTX: Set default/minimum compute capability to sm_35

The current implementation of the nvptx runtime (to be upstreamed shortly) uses 
the atomicMax operation on 64-bit integers.
This is only supported in compute capabilities 3.5 and later. I've changed the 
clang default to sm_35.

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


Modified:
cfe/trunk/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=320082=320081=320082=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Thu Dec  7 12:27:31 2017
@@ -241,14 +241,15 @@ set(CLANG_DEFAULT_OBJCOPY "objcopy" CACH
 set(CLANG_DEFAULT_OPENMP_RUNTIME "libomp" CACHE STRING
   "Default OpenMP runtime used by -fopenmp.")
 
-# OpenMP offloading requires at least sm_30 because we use shuffle instructions
-# to generate efficient code for reductions.
-set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH "sm_30" CACHE STRING
+# OpenMP offloading requires at least sm_35 because we use shuffle instructions
+# to generate efficient code for reductions and the atomicMax instruction on
+# 64-bit integers in the implementation of conditional lastprivate.
+set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH "sm_35" CACHE STRING
   "Default architecture for OpenMP offloading to Nvidia GPUs.")
 string(REGEX MATCH "^sm_([0-9]+)$" MATCHED_ARCH 
"${CLANG_OPENMP_NVPTX_DEFAULT_ARCH}")
-if (NOT DEFINED MATCHED_ARCH OR "${CMAKE_MATCH_1}" LESS 30)
-  message(WARNING "Resetting default architecture for OpenMP offloading to 
Nvidia GPUs to sm_30")
-  set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH "sm_30" CACHE STRING
+if (NOT DEFINED MATCHED_ARCH OR "${CMAKE_MATCH_1}" LESS 35)
+  message(WARNING "Resetting default architecture for OpenMP offloading to 
Nvidia GPUs to sm_35")
+  set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH "sm_35" CACHE STRING
 "Default architecture for OpenMP offloading to Nvidia GPUs." FORCE)
 endif()
 


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


[PATCH] D40225: Add -std=c17 as a flag

2017-12-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Commit in r320089.


https://reviews.llvm.org/D40225



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


r320089 - Add new language mode flags for C17.

2017-12-07 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Dec  7 13:46:26 2017
New Revision: 320089

URL: http://llvm.org/viewvc/llvm-project?rev=320089=rev
Log:
Add new language mode flags for C17.

This adds -std=c17, -std=gnu17, and -std=iso9899:2017 as language mode flags 
for C17 and updates the value of __STDC_VERSION__ to the value based on the C17 
FDIS. Given that this ballot cannot succeed until 2018, it is expected that we 
(and GCC) will add c18 flags as aliases once the ballot passes.

Modified:
cfe/trunk/docs/ReleaseNotes.rst
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/unknown-std.c

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=320089=320088=320089=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Thu Dec  7 13:46:26 2017
@@ -121,6 +121,12 @@ New Compiler Flags
   number of attributes are supported outside of C++ mode. See the Clang
   attribute documentation for more information about which attributes are
   supported for each syntax.
+  
+- Added the ``-std=c17``, ``-std=gnu17``, and ``-std=iso9899:2017`` language
+  mode flags for compatibility with GCC. This enables support for the next
+  version of the C standard, expected to be published by ISO in 2018. The only
+  difference between the ``-std=c17`` and ``-std=c11`` language modes is the
+  value of the ``__STDC_VERSION__`` macro, as C17 is a bug fix release.
 
 Deprecated Compiler Flags
 -

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=320089=320088=320089=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Thu Dec  7 13:46:26 2017
@@ -1,187 +1,188 @@
-//===--- LangOptions.def - Language option database -*- C++ 
-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-//
-// This file defines the language options. Users of this file must
-// define the LANGOPT macro to make use of this information.
-//
-// Optionally, the user may also define:
-//
-// BENIGN_LANGOPT: for options that don't affect the construction of the AST in
-// any way (that is, the value can be different between an implicit module
-// and the user of that module).
-//
-// COMPATIBLE_LANGOPT: for options that affect the construction of the AST in
-// a way that doesn't prevent interoperability (that is, the value can be
-// different between an explicit module and the user of that module).
-//
-// ENUM_LANGOPT: for options that have enumeration, rather than unsigned, type.
-//
-// VALUE_LANGOPT: for options that describe a value rather than a flag.
-//
-// BENIGN_ENUM_LANGOPT, COMPATIBLE_ENUM_LANGOPT,
-// BENIGN_VALUE_LANGOPT, COMPATIBLE_VALUE_LANGOPT: combinations of the above.
-//
-// FIXME: Clients should be able to more easily select whether they want
-// different levels of compatibility versus how to handle different kinds
-// of option.
-//
-// The Description field should be a noun phrase, for instance "frobbing all
-// widgets" or "C's implicit blintz feature".
-//===--===//
-
-#ifndef LANGOPT
-#  error Define the LANGOPT macro to handle language options
-#endif
-
-#ifndef COMPATIBLE_LANGOPT
-#  define COMPATIBLE_LANGOPT(Name, Bits, Default, Description) \
- LANGOPT(Name, Bits, Default, Description)
-#endif
-
-#ifndef BENIGN_LANGOPT
-#  define BENIGN_LANGOPT(Name, Bits, Default, Description) \
- COMPATIBLE_LANGOPT(Name, Bits, Default, Description)
-#endif
-
-#ifndef ENUM_LANGOPT
-#  define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
- LANGOPT(Name, Bits, Default, Description)
-#endif
-
-#ifndef COMPATIBLE_ENUM_LANGOPT
-#  define COMPATIBLE_ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
- ENUM_LANGOPT(Name, Type, Bits, Default, Description)
-#endif
-
-#ifndef BENIGN_ENUM_LANGOPT
-#  define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
- COMPATIBLE_ENUM_LANGOPT(Name, Type, Bits, Default, Description)
-#endif
-
-#ifndef VALUE_LANGOPT
-#  define VALUE_LANGOPT(Name, Bits, Default, Description) \
- LANGOPT(Name, Bits, Default, Description)
-#endif
-
-#ifndef COMPATIBLE_VALUE_LANGOPT
-#  define COMPATIBLE_VALUE_LANGOPT(Name, Bits, 

[PATCH] D40983: Generate Libclang invocation reproducers using a new -cc1gen-reproducer option

2017-12-07 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
Herald added a subscriber: mgorny.

This patch is a follow up to the previous work that recorded Libclang 
invocations into temporary files: https://reviews.llvm.org/D40527.

It adds a new -cc1 mode to clang: `-cc1gen-reproducer`. The goal of this mode 
is to generate Clang reproducer files for Libclang tool invocation. The JSON 
format in the invocation files is not really intended to be stable, so Libclang 
and Clang should be of the same version when generating reproducers.
The new mode emits the information about the temporary files in the reproducers 
to stdout using JSON. It also injects additional Libclang-specific information 
about the reproducer to the reproducer's .sh files.

Thanks for taking a look!


Repository:
  rC Clang

https://reviews.llvm.org/D40983

Files:
  include/clang/Driver/Driver.h
  lib/Driver/Driver.cpp
  test/Index/create-libclang-completion-reproducer.c
  test/Index/create-libclang-parsing-reproducer.c
  tools/driver/CMakeLists.txt
  tools/driver/cc1gen_reproducer_main.cpp
  tools/driver/driver.cpp

Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -205,6 +205,8 @@
 void *MainAddr);
 extern int cc1as_main(ArrayRef Argv, const char *Argv0,
   void *MainAddr);
+extern int cc1gen_reproducer_main(ArrayRef Argv,
+  const char *Argv0, void *MainAddr);
 
 static void insertTargetAndModeArgs(const ParsedClangName ,
 SmallVectorImpl ,
@@ -309,6 +311,8 @@
 return cc1_main(argv.slice(2), argv[0], GetExecutablePathVP);
   if (Tool == "as")
 return cc1as_main(argv.slice(2), argv[0], GetExecutablePathVP);
+  if (Tool == "gen-reproducer")
+return cc1gen_reproducer_main(argv.slice(2), argv[0], GetExecutablePathVP);
 
   // Reject unknown tools.
   llvm::errs() << "error: unknown integrated tool '" << Tool << "'\n";
Index: tools/driver/cc1gen_reproducer_main.cpp
===
--- /dev/null
+++ tools/driver/cc1gen_reproducer_main.cpp
@@ -0,0 +1,198 @@
+//===-- cc1gen_reproducer_main.cpp - Clang reproducer generator  --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This is the entry point to the clang -cc1gen-reproducer functionality, which
+// generates reproducers for invocations for clang-based tools.
+//
+//===--===//
+
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/VirtualFileSystem.h"
+#include "clang/Driver/Compilation.h"
+#include "clang/Driver/Driver.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/YAMLTraits.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace clang;
+
+namespace {
+
+struct UnsavedFileHash {
+  std::string Name;
+  std::string MD5;
+};
+
+struct ClangInvocationInfo {
+  std::string Toolchain;
+  std::string LibclangOperation;
+  std::string LibclangOptions;
+  std::vector Arguments;
+  std::vector InvocationArguments;
+  std::vector UnsavedFileHashes;
+  bool Dump = false;
+};
+
+} // end anonymous namespace
+
+LLVM_YAML_IS_SEQUENCE_VECTOR(UnsavedFileHash)
+
+namespace llvm {
+namespace yaml {
+
+template <> struct MappingTraits {
+  static void mapping(IO , UnsavedFileHash ) {
+IO.mapRequired("name", Info.Name);
+IO.mapRequired("md5", Info.MD5);
+  }
+};
+
+template <> struct MappingTraits {
+  static void mapping(IO , ClangInvocationInfo ) {
+IO.mapRequired("toolchain", Info.Toolchain);
+IO.mapOptional("libclang.operation", Info.LibclangOperation);
+IO.mapOptional("libclang.opts", Info.LibclangOptions);
+IO.mapRequired("args", Info.Arguments);
+IO.mapOptional("invocation-args", Info.InvocationArguments);
+IO.mapOptional("unsaved_file_hashes", Info.UnsavedFileHashes);
+  }
+};
+
+} // end namespace yaml
+} // end namespace llvm
+
+static std::string generateReproducerMetaInfo(const ClangInvocationInfo ) {
+  std::string Result;
+  llvm::raw_string_ostream OS(Result);
+  OS << '{';
+  bool NeedComma = false;
+  auto EmitKey = [&](StringRef Key) {
+if (NeedComma)
+  OS << ", ";
+NeedComma = true;
+OS << '"' << Key << "\": ";
+  };
+  auto EmitStringKey = [&](StringRef Key, StringRef Value) {
+if (Value.empty())
+  return;
+EmitKey(Key);
+OS << '"' << Value << '"';
+  };
+  EmitStringKey("libclang.operation", Info.LibclangOperation);
+  EmitStringKey("libclang.opts", Info.LibclangOptions);
+  if 

[PATCH] D39665: Support __has_c_attribute

2017-12-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Commit in r320088.


https://reviews.llvm.org/D39665



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


[PATCH] D40948: Switch Clang's default C++ language target to C++14

2017-12-07 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/test/CodeGenCXX/new-overflow.cpp:88
   // CHECK:  [[N:%.*]] = sext i16 {{%.*}} to i32
-  // CHECK-NEXT: [[T0:%.*]] = icmp slt i32 [[N]], 0
-  // CHECK-NEXT: [[T1:%.*]] = select i1 [[T0]], i32 -1, i32 [[N]]
-  // CHECK-NEXT: call i8* @_Znaj(i32 [[T1]])
+  // CHECK-NEXT: call i8* @_Znaj(i32 [[N]])
   // CHECK:  getelementptr inbounds {{.*}}, i32 [[N]]

The changes in this file are a regression; C++14 requires us to check whether 
the array bound prior to promotion is negative. Can you file a bug on that?



Comment at: clang/test/CodeGenCXX/vtable-available-externally.cpp:1-2
-// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -emit-llvm -o %t
-// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -O2 
-disable-llvm-passes -emit-llvm -o %t.opt
+// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -std=c++98 -emit-llvm 
-o %t
+// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -std=c++98 -O2 
-disable-llvm-passes -emit-llvm -o %t.opt
 // RUN: FileCheck --check-prefix=CHECK-TEST1 %s < %t

Why does this one need a -std= flag?



Comment at: clang/test/Parser/cxx1z-nested-namespace-definition.cpp:3-4
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98
 // RUN: not %clang_cc1 -x c++ -fixit %t -Werror -DFIXIT
 // RUN: %clang_cc1 -x c++ %t -DFIXIT
 // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++17 -Wc++14-compat

I think these two should also be `-std=c++98`, right?



Comment at: clang/test/SemaCXX/unknown-type-name.cpp:98
 
-template int junk1(T::junk); // expected-warning{{variable 
templates are a C++14 extension}}
+template int junk1(T::junk);
+#if __cplusplus <= 201103L

Huh, we should probably have a `-Wvexing-parse` warning for this. Can you file 
a bug?



Comment at: clang/test/SemaCXX/unknown-type-name.cpp:110-111
 
 // FIXME: We can tell this was intended to be a function because it does not
 //have a dependent nested name specifier.
+template int i(T::type, int());

Maybe delete this (incorrect in C++14) FIXME?


Repository:
  rC Clang

https://reviews.llvm.org/D40948



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


[PATCH] D40968: [OpenMP] Diagnose function name on the link clause

2017-12-07 Thread Kelvin Li via Phabricator via cfe-commits
kkwli0 updated this revision to Diff 126025.
kkwli0 marked an inline comment as done.

https://reviews.llvm.org/D40968

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/declare_target_ast_print.cpp
  test/OpenMP/declare_target_messages.cpp

Index: test/OpenMP/declare_target_messages.cpp
===
--- test/OpenMP/declare_target_messages.cpp
+++ test/OpenMP/declare_target_messages.cpp
@@ -19,6 +19,10 @@
 
 void c(); // expected-warning {{declaration is not declared in any declare target region}}
 
+void func() {} // expected-note {{'func' defined here}}
+
+#pragma omp declare target link(func) // expected-error {{function name is not allowed in 'link' clause}}
+
 extern int b;
 
 struct NonT {
Index: test/OpenMP/declare_target_ast_print.cpp
===
--- test/OpenMP/declare_target_ast_print.cpp
+++ test/OpenMP/declare_target_ast_print.cpp
@@ -108,9 +108,7 @@
 // CHECK: #pragma omp end declare target
 
 int c1, c2, c3;
-void f3() {
-}
-#pragma omp declare target link(c1) link(c2), link(c3, f3)
+#pragma omp declare target link(c1) link(c2), link(c3)
 // CHECK: #pragma omp declare target link
 // CHECK: int c1;
 // CHECK: #pragma omp end declare target
@@ -120,9 +118,6 @@
 // CHECK: #pragma omp declare target link
 // CHECK: int c3;
 // CHECK: #pragma omp end declare target
-// CHECK: #pragma omp declare target link
-// CHECK: void f3()
-// CHECK: #pragma omp end declare target
 
 struct SSSt {
 #pragma omp declare target
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -12578,7 +12578,7 @@
   ND->addAttr(A);
   if (ASTMutationListener *ML = Context.getASTMutationListener())
 ML->DeclarationMarkedOpenMPDeclareTarget(ND, A);
-  checkDeclIsAllowedInOpenMPTarget(nullptr, ND);
+  checkDeclIsAllowedInOpenMPTarget(nullptr, ND, );
 } else if (ND->getAttr()->getMapType() != MT) {
   Diag(Id.getLoc(), diag::err_omp_declare_target_to_and_link)
   << Id.getName();
@@ -12667,7 +12667,8 @@
   return true;
 }
 
-void Sema::checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D) {
+void Sema::checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D,
+const DeclarationNameInfo *Id) {
   if (!D || D->isInvalidDecl())
 return;
   SourceRange SR = E ? E->getSourceRange() : D->getSourceRange();
@@ -12696,6 +12697,16 @@
   return;
 }
   }
+  if (FunctionDecl *FD = dyn_cast(D)) {
+if (FD->hasAttr() &&
+(FD->getAttr()->getMapType() ==
+ OMPDeclareTargetDeclAttr::MT_Link)) {
+  assert(Id && "Null decl name info on link clause.");
+  Diag(Id->getLoc(), diag::err_omp_function_in_link_clause);
+  Diag(FD->getLocation(), diag::note_defined_here) << FD;
+  return;
+}
+  }
   if (!E) {
 // Checking declaration inside declare target region.
 if (!D->hasAttr() &&
Index: include/clang/Sema/Sema.h
===
--- include/clang/Sema/Sema.h
+++ include/clang/Sema/Sema.h
@@ -8652,7 +8652,8 @@
 OMPDeclareTargetDeclAttr::MapTypeTy MT,
 NamedDeclSetType );
   /// Check declaration inside target region.
-  void checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D);
+  void checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D,
+const DeclarationNameInfo *Id = nullptr);
   /// Return true inside OpenMP declare target region.
   bool isInOpenMPDeclareTargetContext() const {
 return IsInOpenMPDeclareTargetContext;
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -8709,6 +8709,8 @@
 def warn_omp_not_in_target_context : Warning<
   "declaration is not declared in any declare target region">,
   InGroup;
+def err_omp_function_in_link_clause : Error<
+  "function name is not allowed in 'link' clause">;
 def err_omp_aligned_expected_array_or_ptr : Error<
   "argument of aligned clause should be array"
   "%select{ or pointer|, pointer, reference to array or reference to pointer}1"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40968: [OpenMP] Diagnose function name on the link clause

2017-12-07 Thread Kelvin Li via Phabricator via cfe-commits
kkwli0 marked an inline comment as done.
kkwli0 added inline comments.



Comment at: lib/Sema/SemaOpenMP.cpp:12576
 
+if (MT == OMPDeclareTargetDeclAttr::MT_Link && isa(ND)) {
+  Diag(Id.getLoc(), diag::err_omp_function_in_link_clause);

ABataev wrote:
> I would like to see this some in `check` functions, like 
> `checkDeclIsAllowedInOpenMPTarget` rather than here 
Sure.  I will move the check into checkDeclIsAllowedInOpenMPTarget.


https://reviews.llvm.org/D40968



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


[PATCH] D40948: Switch Clang's default C++ language target to C++14

2017-12-07 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover added inline comments.



Comment at: clang/test/SemaCXX/new-array-size-conv.cpp:1
-// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -fsyntax-only -pedantic -verify -std=gnu++98 %s
 // RUN: %clang_cc1 -fsyntax-only -pedantic -verify -std=c++98 %s

probinson wrote:
> I think the intent here was "whatever the current default is" and not 
> specifically gnu++98, because the next line explicitly specifies c++98.  So, 
> unless this test fails miserably for C++14 (which I wouldn't expect) I think 
> it should be adapted to whatever gets reported for that dialect.
The original commit of this file (r107229 from Doug Gregor) called out the fact 
that what's being tested is a GNU and C++0x extension.

I think that implies that the 3 run lines really *should* test gnu++98, c++98 
and c++11.


Repository:
  rC Clang

https://reviews.llvm.org/D40948



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


[PATCH] D40625: Harmonizing attribute GNU/C++ spellings

2017-12-07 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM.

I think the `LateParsed` attributes are not going to work properly (because 
they'd be written in places where the function parameters are not in scope), so 
I wonder if we should avoid allowing them with [[clang::]] notation for now so 
we can choose to make them function type attributes in the future, but I'm 
happy with you making that call.


https://reviews.llvm.org/D40625



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


[PATCH] D40225: Add -std=c17 as a flag

2017-12-07 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM, makes sense to add this for GCC compatibility even if the standard ends 
up being called C18.


https://reviews.llvm.org/D40225



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


[PATCH] D39665: Support __has_c_attribute

2017-12-07 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Please update the documentation and the release notes.


https://reviews.llvm.org/D39665



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


r320085 - [libclang] Record code-completion invocations to a temporary file when

2017-12-07 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Dec  7 12:37:50 2017
New Revision: 320085

URL: http://llvm.org/viewvc/llvm-project?rev=320085=rev
Log:
[libclang] Record code-completion invocations to a temporary file when
requested by client

This is a follow up to r319702 which records parsing invocations.

These files are not emitted by default, and the client has to specify the
invocation emission path first.

rdar://35322543

Added:
cfe/trunk/test/Index/record-completion-invocation.c
Modified:
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp
cfe/trunk/tools/libclang/CIndexer.cpp
cfe/trunk/tools/libclang/CIndexer.h
cfe/trunk/tools/libclang/CXTranslationUnit.h

Added: cfe/trunk/test/Index/record-completion-invocation.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/record-completion-invocation.c?rev=320085=auto
==
--- cfe/trunk/test/Index/record-completion-invocation.c (added)
+++ cfe/trunk/test/Index/record-completion-invocation.c Thu Dec  7 12:37:50 2017
@@ -0,0 +1,11 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: env CINDEXTEST_INVOCATION_EMISSION_PATH=%t not c-index-test 
-code-completion-at=%s:10:1 
"-remap-file=%s,%S/Inputs/record-parsing-invocation-remap.c" %s
+// RUN: cat %t/libclang-* | FileCheck %s
+
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: env LIBCLANG_DISABLE_CRASH_RECOVERY=1 
CINDEXTEST_INVOCATION_EMISSION_PATH=%t not --crash c-index-test 
-code-completion-at=%s:10:1 
"-remap-file=%s,%S/Inputs/record-parsing-invocation-remap.c" %s
+// RUN: cat %t/libclang-* | FileCheck %s
+
+// CHECK: 
{"toolchain":"{{.*}}","libclang.operation":"complete","libclang.opts":1,"args":["clang","-fno-spell-checking","{{.*}}record-completion-invocation.c","-Xclang","-detailed-preprocessing-record","-fallow-editor-placeholders"],"invocation-args":["-code-completion-at={{.*}}record-completion-invocation.c:10:1"],"unsaved_file_hashes":[{"name":"{{.*}}record-completion-invocation.c","md5":"aee23773de90e665992b48209351d70e"}]}

Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=320085=320084=320085=diff
==
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Thu Dec  7 12:37:50 2017
@@ -2316,7 +2316,8 @@ int perform_code_completion(int argc, co
   CXTranslationUnit TU;
   unsigned I, Repeats = 1;
   unsigned completionOptions = clang_defaultCodeCompleteOptions();
-  
+  const char *InvocationPath;
+
   if (getenv("CINDEXTEST_CODE_COMPLETE_PATTERNS"))
 completionOptions |= CXCodeComplete_IncludeCodePatterns;
   if (getenv("CINDEXTEST_COMPLETION_BRIEF_COMMENTS"))
@@ -2335,7 +2336,10 @@ int perform_code_completion(int argc, co
 return -1;
 
   CIdx = clang_createIndex(0, 0);
-  
+  InvocationPath = getenv("CINDEXTEST_INVOCATION_EMISSION_PATH");
+  if (InvocationPath)
+clang_CXIndex_setInvocationEmissionPathOption(CIdx, InvocationPath);
+
   if (getenv("CINDEXTEST_EDITING"))
 Repeats = 5;
 

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=320085=320084=320085=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Thu Dec  7 12:37:50 2017
@@ -81,6 +81,8 @@ CXTranslationUnit cxtu::MakeCXTranslatio
   D->Diagnostics = nullptr;
   D->OverridenCursorsPool = createOverridenCXCursorsPool();
   D->CommentToXML = nullptr;
+  D->ParsingOptions = 0;
+  D->Arguments = {};
   return D;
 }
 
@@ -3440,7 +3442,8 @@ clang_parseTranslationUnit_Impl(CXIndex
 
   LibclangInvocationReporter InvocationReporter(
   *CXXIdx, LibclangInvocationReporter::OperationKind::ParseOperation,
-  options, llvm::makeArrayRef(*Args), unsaved_files);
+  options, llvm::makeArrayRef(*Args), /*InvocationArgs=*/None,
+  unsaved_files);
   std::unique_ptr Unit(ASTUnit::LoadFromCommandLine(
   Args->data(), Args->data() + Args->size(),
   CXXIdx->getPCHContainerOperations(), Diags,
@@ -3467,7 +3470,14 @@ clang_parseTranslationUnit_Impl(CXIndex
 return CXError_ASTReadError;
 
   *out_TU = MakeCXTranslationUnit(CXXIdx, std::move(Unit));
-  return *out_TU ? CXError_Success : CXError_Failure;
+  if (CXTranslationUnitImpl *TU = *out_TU) {
+TU->ParsingOptions = options;
+TU->Arguments.reserve(Args->size());
+for (const char *Arg : *Args)
+  TU->Arguments.push_back(Arg);
+return CXError_Success;
+  }
+  return CXError_Failure;
 }
 
 CXTranslationUnit

Modified: cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp
URL: 

[PATCH] D40977: [OpenMP] NVPTX: Set default/minimum compute capability to sm_35

2017-12-07 Thread George Rokos via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC320082: [OpenMP] NVPTX: Set default/minimum compute 
capability to sm_35 (authored by grokos).

Repository:
  rC Clang

https://reviews.llvm.org/D40977

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -241,14 +241,15 @@
 set(CLANG_DEFAULT_OPENMP_RUNTIME "libomp" CACHE STRING
   "Default OpenMP runtime used by -fopenmp.")
 
-# OpenMP offloading requires at least sm_30 because we use shuffle instructions
-# to generate efficient code for reductions.
-set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH "sm_30" CACHE STRING
+# OpenMP offloading requires at least sm_35 because we use shuffle instructions
+# to generate efficient code for reductions and the atomicMax instruction on
+# 64-bit integers in the implementation of conditional lastprivate.
+set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH "sm_35" CACHE STRING
   "Default architecture for OpenMP offloading to Nvidia GPUs.")
 string(REGEX MATCH "^sm_([0-9]+)$" MATCHED_ARCH 
"${CLANG_OPENMP_NVPTX_DEFAULT_ARCH}")
-if (NOT DEFINED MATCHED_ARCH OR "${CMAKE_MATCH_1}" LESS 30)
-  message(WARNING "Resetting default architecture for OpenMP offloading to 
Nvidia GPUs to sm_30")
-  set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH "sm_30" CACHE STRING
+if (NOT DEFINED MATCHED_ARCH OR "${CMAKE_MATCH_1}" LESS 35)
+  message(WARNING "Resetting default architecture for OpenMP offloading to 
Nvidia GPUs to sm_35")
+  set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH "sm_35" CACHE STRING
 "Default architecture for OpenMP offloading to Nvidia GPUs." FORCE)
 endif()
 


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -241,14 +241,15 @@
 set(CLANG_DEFAULT_OPENMP_RUNTIME "libomp" CACHE STRING
   "Default OpenMP runtime used by -fopenmp.")
 
-# OpenMP offloading requires at least sm_30 because we use shuffle instructions
-# to generate efficient code for reductions.
-set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH "sm_30" CACHE STRING
+# OpenMP offloading requires at least sm_35 because we use shuffle instructions
+# to generate efficient code for reductions and the atomicMax instruction on
+# 64-bit integers in the implementation of conditional lastprivate.
+set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH "sm_35" CACHE STRING
   "Default architecture for OpenMP offloading to Nvidia GPUs.")
 string(REGEX MATCH "^sm_([0-9]+)$" MATCHED_ARCH "${CLANG_OPENMP_NVPTX_DEFAULT_ARCH}")
-if (NOT DEFINED MATCHED_ARCH OR "${CMAKE_MATCH_1}" LESS 30)
-  message(WARNING "Resetting default architecture for OpenMP offloading to Nvidia GPUs to sm_30")
-  set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH "sm_30" CACHE STRING
+if (NOT DEFINED MATCHED_ARCH OR "${CMAKE_MATCH_1}" LESS 35)
+  message(WARNING "Resetting default architecture for OpenMP offloading to Nvidia GPUs to sm_35")
+  set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH "sm_35" CACHE STRING
 "Default architecture for OpenMP offloading to Nvidia GPUs." FORCE)
 endif()
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30691: [analyzer] Support for naive cross translational unit analysis

2017-12-07 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 125986.
xazax.hun added a comment.
Herald added a subscriber: rnkovacs.

- @gerazo addressed some review comments in scan-build-py.


https://reviews.llvm.org/D30691

Files:
  include/clang/AST/ASTContext.h
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/CMakeLists.txt
  lib/StaticAnalyzer/Core/CallEvent.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  lib/StaticAnalyzer/Frontend/CMakeLists.txt
  test/Analysis/Inputs/ctu-chain.cpp
  test/Analysis/Inputs/ctu-other.cpp
  test/Analysis/Inputs/externalFnMap.txt
  test/Analysis/ctu-main.cpp
  tools/scan-build-py/libscanbuild/__init__.py
  tools/scan-build-py/libscanbuild/analyze.py
  tools/scan-build-py/libscanbuild/arguments.py
  tools/scan-build-py/libscanbuild/clang.py
  tools/scan-build-py/libscanbuild/report.py
  tools/scan-build-py/tests/unit/test_analyze.py
  tools/scan-build-py/tests/unit/test_clang.py

Index: tools/scan-build-py/tests/unit/test_clang.py
===
--- tools/scan-build-py/tests/unit/test_clang.py
+++ tools/scan-build-py/tests/unit/test_clang.py
@@ -92,3 +92,15 @@
 self.assertEqual('Checker One description', result.get('checker.one'))
 self.assertTrue('checker.two' in result)
 self.assertEqual('Checker Two description', result.get('checker.two'))
+
+
+class ClangIsCtuCapableTest(unittest.TestCase):
+def test_ctu_not_found(self):
+is_ctu = sut.is_ctu_capable('not-found-clang-func-mapping')
+self.assertFalse(is_ctu)
+
+
+class ClangGetTripleArchTest(unittest.TestCase):
+def test_arch_is_not_empty(self):
+arch = sut.get_triple_arch(['clang', '-E', '-'], '.')
+self.assertTrue(len(arch) > 0)
Index: tools/scan-build-py/tests/unit/test_analyze.py
===
--- tools/scan-build-py/tests/unit/test_analyze.py
+++ tools/scan-build-py/tests/unit/test_analyze.py
@@ -4,12 +4,12 @@
 # This file is distributed under the University of Illinois Open Source
 # License. See LICENSE.TXT for details.
 
-import libear
-import libscanbuild.analyze as sut
 import unittest
 import re
 import os
 import os.path
+import libear
+import libscanbuild.analyze as sut
 
 
 class ReportDirectoryTest(unittest.TestCase):
@@ -333,3 +333,83 @@
 
 def test_method_exception_not_caught(self):
 self.assertRaises(Exception, method_exception_from_inside, dict())
+
+
+class PrefixWithTest(unittest.TestCase):
+
+def test_gives_empty_on_empty(self):
+res = sut.prefix_with(0, [])
+self.assertFalse(res)
+
+def test_interleaves_prefix(self):
+res = sut.prefix_with(0, [1, 2, 3])
+self.assertListEqual([0, 1, 0, 2, 0, 3], res)
+
+
+class MergeCtuMapTest(unittest.TestCase):
+
+def test_no_map_gives_empty(self):
+pairs = sut.create_global_ctu_function_map([])
+self.assertFalse(pairs)
+
+def test_multiple_maps_merged(self):
+concat_map = ['c:@F@fun1#I# ast/fun1.c.ast',
+  'c:@F@fun2#I# ast/fun2.c.ast',
+  'c:@F@fun3#I# ast/fun3.c.ast']
+pairs = sut.create_global_ctu_function_map(concat_map)
+self.assertTrue(('c:@F@fun1#I#', 'ast/fun1.c.ast') in pairs)
+self.assertTrue(('c:@F@fun2#I#', 'ast/fun2.c.ast') in pairs)
+self.assertTrue(('c:@F@fun3#I#', 'ast/fun3.c.ast') in pairs)
+self.assertEqual(3, len(pairs))
+
+def test_not_unique_func_left_out(self):
+concat_map = ['c:@F@fun1#I# ast/fun1.c.ast',
+  'c:@F@fun2#I# ast/fun2.c.ast',
+  'c:@F@fun1#I# ast/fun7.c.ast']
+pairs = sut.create_global_ctu_function_map(concat_map)
+self.assertFalse(('c:@F@fun1#I#', 'ast/fun1.c.ast') in pairs)
+self.assertFalse(('c:@F@fun1#I#', 'ast/fun7.c.ast') in pairs)
+self.assertTrue(('c:@F@fun2#I#', 'ast/fun2.c.ast') in pairs)
+self.assertEqual(1, len(pairs))
+
+def test_duplicates_are_kept(self):
+concat_map = ['c:@F@fun1#I# ast/fun1.c.ast',
+  'c:@F@fun2#I# ast/fun2.c.ast',
+  'c:@F@fun1#I# ast/fun1.c.ast']
+pairs = sut.create_global_ctu_function_map(concat_map)
+self.assertTrue(('c:@F@fun1#I#', 'ast/fun1.c.ast') in pairs)
+self.assertTrue(('c:@F@fun2#I#', 'ast/fun2.c.ast') in pairs)
+self.assertEqual(2, len(pairs))
+
+def test_space_handled_in_source(self):
+concat_map = ['c:@F@fun1#I# ast/f un.c.ast']
+pairs = sut.create_global_ctu_function_map(concat_map)
+self.assertTrue(('c:@F@fun1#I#', 'ast/f un.c.ast') in pairs)
+self.assertEqual(1, len(pairs))
+
+
+class FuncMapSrcToAstTest(unittest.TestCase):
+

[PATCH] D39363: [clang-tidy] Correctly classify constant arrays and constant strings as constants when checking identifiers naming

2017-12-07 Thread Beren Minor via Phabricator via cfe-commits
berenm added a comment.

In https://reviews.llvm.org/D39363#948134, @alexfh wrote:

> Sorry for the delay. I missed this revision somehow. Please add cfe-commits 
> to the subscribers list so that others can chime in.


No worries, I'll add it in the future.

Thanks!


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D39363



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


[PATCH] D40977: [OpenMP] NVPTX: Set default/minimum compute capability to sm_35

2017-12-07 Thread Guansong Zhang via Phabricator via cfe-commits
guansong added a comment.

LGTM.


Repository:
  rC Clang

https://reviews.llvm.org/D40977



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


[PATCH] D39363: [clang-tidy] Correctly classify constant arrays and constant strings as constants when checking identifiers naming

2017-12-07 Thread Beren Minor via Phabricator via cfe-commits
berenm updated this revision to Diff 126017.
berenm added a comment.
Herald added a subscriber: klimek.

Factor !Type.isNull() && Type.isConstQualified() condition


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D39363

Files:
  clang-tidy/readability/IdentifierNamingCheck.cpp
  test/clang-tidy/readability-identifier-naming.cpp

Index: test/clang-tidy/readability-identifier-naming.cpp
===
--- test/clang-tidy/readability-identifier-naming.cpp
+++ test/clang-tidy/readability-identifier-naming.cpp
@@ -405,6 +405,38 @@
 
   using ::FOO_NS::InlineNamespace::CE_function;
 // CHECK-FIXES: {{^}}  using ::foo_ns::inline_namespace::ce_function;{{$}}
+
+  unsigned MY_LOCAL_array[] = {1,2,3};
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: invalid case style for local variable 'MY_LOCAL_array'
+// CHECK-FIXES: {{^}}  unsigned my_local_array[] = {1,2,3};{{$}}
+
+  unsigned const MyConstLocal_array[] = {1,2,3};
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for local constant 'MyConstLocal_array'
+// CHECK-FIXES: {{^}}  unsigned const kMyConstLocalArray[] = {1,2,3};{{$}}
+
+  static unsigned MY_STATIC_array[] = {1,2,3};
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: invalid case style for static variable 'MY_STATIC_array'
+// CHECK-FIXES: {{^}}  static unsigned s_myStaticArray[] = {1,2,3};{{$}}
+
+  static unsigned const MyConstStatic_array[] = {1,2,3};
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: invalid case style for static constant 'MyConstStatic_array'
+// CHECK-FIXES: {{^}}  static unsigned const MY_CONST_STATIC_ARRAY[] = {1,2,3};{{$}}
+
+  char MY_LOCAL_string[] = "123";
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local variable 'MY_LOCAL_string'
+// CHECK-FIXES: {{^}}  char my_local_string[] = "123";{{$}}
+
+  char const MyConstLocal_string[] = "123";
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: invalid case style for local constant 'MyConstLocal_string'
+// CHECK-FIXES: {{^}}  char const kMyConstLocalString[] = "123";{{$}}
+
+  static char MY_STATIC_string[] = "123";
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for static variable 'MY_STATIC_string'
+// CHECK-FIXES: {{^}}  static char s_myStaticString[] = "123";{{$}}
+
+  static char const MyConstStatic_string[] = "123";
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: invalid case style for static constant 'MyConstStatic_string'
+// CHECK-FIXES: {{^}}  static char const MY_CONST_STATIC_STRING[] = "123";{{$}}
 }
 
 #define MY_TEST_Macro(X) X()
@@ -418,6 +450,27 @@
 
 template  struct a {
   typename t_t::template b<> c;
+
+  char const MY_ConstMember_string[4] = "123";
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: invalid case style for constant member 'MY_ConstMember_string'
+// CHECK-FIXES: {{^}}  char const my_const_member_string[4] = "123";{{$}}
+
+  static char const MyConstClass_string[];
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: invalid case style for class constant 'MyConstClass_string'
+// CHECK-FIXES: {{^}}  static char const kMyConstClassString[];{{$}}
 };
 
+template
+char const a::MyConstClass_string[] = "123";
+// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: invalid case style for class constant 'MyConstClass_string'
+// CHECK-FIXES: {{^}}char const a::kMyConstClassString[] = "123";{{$}}
+
 template  class A> struct b { A c; };
+
+unsigned MY_GLOBAL_array[] = {1,2,3};
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for global variable 'MY_GLOBAL_array'
+// CHECK-FIXES: {{^}}unsigned g_my_global_array[] = {1,2,3};{{$}}
+
+unsigned const MyConstGlobal_array[] = {1,2,3};
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for global constant 'MyConstGlobal_array'
+// CHECK-FIXES: {{^}}unsigned const MY_CONST_GLOBAL_ARRAY[] = {1,2,3};{{$}}
Index: clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -449,13 +449,13 @@
   if (const auto *Decl = dyn_cast(D)) {
 QualType Type = Decl->getType();
 
-if (!Type.isNull() && Type.isLocalConstQualified() &&
-NamingStyles[SK_ConstantMember])
-  return SK_ConstantMember;
+if (!Type.isNull() && Type.isConstQualified()) {
+  if (NamingStyles[SK_ConstantMember])
+return SK_ConstantMember;
 
-if (!Type.isNull() && Type.isLocalConstQualified() &&
-NamingStyles[SK_Constant])
-  return SK_Constant;
+  if (NamingStyles[SK_Constant])
+return SK_Constant;
+}
 
 if (Decl->getAccess() == AS_private && NamingStyles[SK_PrivateMember])
   return SK_PrivateMember;
@@ -478,13 +478,13 @@
 if (Decl->isConstexpr() && NamingStyles[SK_ConstexprVariable])
   return SK_ConstexprVariable;
 
-if (!Type.isNull() && Type.isLocalConstQualified() &&
-NamingStyles[SK_ConstantParameter])
-  return 

[PATCH] D40448: Add a printing policy for AST dumping

2017-12-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 126016.
aaron.ballman added a comment.

Ping. Added more context to the patch.


https://reviews.llvm.org/D40448

Files:
  include/clang/AST/Type.h
  lib/AST/ASTDumper.cpp
  lib/AST/TypePrinter.cpp
  lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
  test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-examples.cpp
  test/Frontend/float16.cpp
  test/Misc/ast-dump-attr.cpp
  test/Misc/ast-dump-decl.cpp
  test/Misc/ast-dump-invalid.cpp
  test/OpenMP/dump.cpp
  test/Parser/objc-default-ctor-init.mm
  test/SemaCXX/compound-literal.cpp
  test/SemaCXX/sourceranges.cpp
  test/SemaCXX/warn-redundant-move.cpp
  test/SemaObjCXX/block-cleanup.mm
  test/SemaTemplate/default-expr-arguments-2.cpp
  test/SemaTemplate/default-expr-arguments-3.cpp

Index: test/SemaTemplate/default-expr-arguments-3.cpp
===
--- test/SemaTemplate/default-expr-arguments-3.cpp
+++ test/SemaTemplate/default-expr-arguments-3.cpp
@@ -1,11 +1,11 @@
 // RUN: %clang_cc1 -std=c++14 -verify -ast-dump %s | FileCheck %s
 // expected-no-diagnostics
 
-// CHECK: FunctionDecl {{.*}} used func 'void (void)'
+// CHECK: FunctionDecl {{.*}} used func 'void ()'
 // CHECK-NEXT: TemplateArgument type 'int'
-// CHECK: LambdaExpr {{.*}} 'class (lambda at
-// CHECK: ParmVarDecl {{.*}} used f 'enum foo' cinit
-// CHECK-NEXT: DeclRefExpr {{.*}} 'enum foo' EnumConstant {{.*}} 'a' 'enum foo'
+// CHECK: LambdaExpr {{.*}} '(lambda at
+// CHECK: ParmVarDecl {{.*}} used f 'foo' cinit
+// CHECK-NEXT: DeclRefExpr {{.*}} 'foo' EnumConstant {{.*}} 'a' 'foo'
 
 namespace PR28795 {
   template
@@ -22,9 +22,9 @@
 
 // CHECK: ClassTemplateSpecializationDecl {{.*}} struct class2 definition
 // CHECK: TemplateArgument type 'int'
-// CHECK: LambdaExpr {{.*}} 'class (lambda at
-// CHECK: ParmVarDecl {{.*}} used f 'enum foo' cinit
-// CHECK-NEXT: DeclRefExpr {{.*}} 'enum foo' EnumConstant {{.*}} 'a' 'enum foo'
+// CHECK: LambdaExpr {{.*}} '(lambda at
+// CHECK: ParmVarDecl {{.*}} used f 'foo' cinit
+// CHECK-NEXT: DeclRefExpr {{.*}} 'foo' EnumConstant {{.*}} 'a' 'foo'
 
 // Template struct case:
 template  struct class2 {
@@ -38,11 +38,11 @@
 
 // CHECK: FunctionTemplateDecl {{.*}} f1
 // CHECK-NEXT: TemplateTypeParmDecl {{.*}} typename depth 0 index 0 T
-// CHECK-NEXT: FunctionDecl {{.*}} f1 'void (void)'
-// CHECK: FunctionDecl {{.*}} f1 'void (void)'
+// CHECK-NEXT: FunctionDecl {{.*}} f1 'void ()'
+// CHECK: FunctionDecl {{.*}} f1 'void ()'
 // CHECK-NEXT: TemplateArgument type 'int'
-// CHECK: ParmVarDecl {{.*}} n 'enum foo' cinit
-// CHECK-NEXT: DeclRefExpr {{.*}} 'enum foo' EnumConstant {{.*}} 'a' 'enum foo'
+// CHECK: ParmVarDecl {{.*}} n 'foo' cinit
+// CHECK-NEXT: DeclRefExpr {{.*}} 'foo' EnumConstant {{.*}} 'a' 'foo'
 
 template
 void f1() {
Index: test/SemaTemplate/default-expr-arguments-2.cpp
===
--- test/SemaTemplate/default-expr-arguments-2.cpp
+++ test/SemaTemplate/default-expr-arguments-2.cpp
@@ -9,8 +9,8 @@
   public: enum { kSomeConst = 128 };
 bar(int x = kSomeConst) {}
   };
-  
-  // CHECK: FunctionDecl{{.*}}f 'void (void)'
+
+  // CHECK: FunctionDecl{{.*}}f 'void ()'
   void f() {
 // CHECK: VarDecl{{.*}}tmp 'bar'
 // CHECK: CXXDefaultArgExpr{{.*}}'int'
Index: test/SemaObjCXX/block-cleanup.mm
===
--- test/SemaObjCXX/block-cleanup.mm
+++ test/SemaObjCXX/block-cleanup.mm
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.11.0 -std=gnu++11 -o /dev/null -x objective-c++ -fblocks -ast-dump %s 2>&1 | FileCheck %s
 
-// CHECK:  -FunctionDecl {{.*}} test 'id (void)'
+// CHECK:  -FunctionDecl {{.*}} test 'id ()'
 // CHECK-NEXT:   -CompoundStmt
 // CHECK-NEXT: -ReturnStmt
 // CHECK-NEXT:   -ExprWithCleanups
Index: test/SemaCXX/warn-redundant-move.cpp
===
--- test/SemaCXX/warn-redundant-move.cpp
+++ test/SemaCXX/warn-redundant-move.cpp
@@ -75,7 +75,7 @@
   return d;
   // Verify the implicit move from the AST dump
   // CHECK-AST: ReturnStmt{{.*}}line:[[@LINE-2]]
-  // CHECK-AST-NEXT: CXXConstructExpr{{.*}}struct D{{.*}}void (struct D &&)
+  // CHECK-AST-NEXT: CXXConstructExpr{{.*}}D{{.*}}void (D &&)
   // CHECK-AST-NEXT: ImplicitCastExpr
   // CHECK-AST-NEXT: DeclRefExpr{{.*}}ParmVar{{.*}}'d'
 
Index: test/SemaCXX/sourceranges.cpp
===
--- test/SemaCXX/sourceranges.cpp
+++ test/SemaCXX/sourceranges.cpp
@@ -46,7 +46,7 @@
 void construct() {
   using namespace foo;
   A a = A(12);
-  // CHECK: CXXConstructExpr {{0x[0-9a-fA-F]+}}  'class foo::A' 'void (int){{( __attribute__\(\(thiscall\)\))?}}'
+  // CHECK: CXXConstructExpr {{0x[0-9a-fA-F]+}}  'foo::A' 'void (int){{( __attribute__\(\(thiscall\)\))?}}'
   D d = D(12);
-  // CHECK: CXXConstructExpr 

[PATCH] D40225: Add -std=c17 as a flag

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

In https://reviews.llvm.org/D40225#944113, @aaron.ballman wrote:

> Rebased on ToT and given more context.


Ping. I'd like to get this in before the 6.0 branch.


https://reviews.llvm.org/D40225



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


[PATCH] D40625: Harmonizing attribute GNU/C++ spellings

2017-12-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 126015.
aaron.ballman marked an inline comment as done.
aaron.ballman added a comment.

Updated based on review feedback. This patch leaves off attributes with custom 
parsing, as well as `analyzer_noreturn`, so that we can handle them as special 
cases.


https://reviews.llvm.org/D40625

Files:
  include/clang/Basic/Attr.td

Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -513,7 +513,7 @@
 }
 
 def AddressSpace : TypeAttr {
-  let Spellings = [GNU<"address_space">];
+  let Spellings = [Clang<"address_space">];
   let Args = [IntArgument<"AddressSpace">];
   let Documentation = [Undocumented];
 }
@@ -598,7 +598,7 @@
 }
 
 def Annotate : InheritableParamAttr {
-  let Spellings = [GNU<"annotate">];
+  let Spellings = [Clang<"annotate">];
   let Args = [StringArgument<"Annotation">];
   // Ensure that the annotate attribute can be used with
   // '#pragma clang attribute' even though it has no subject list.
@@ -700,7 +700,7 @@
 }
 
 def Blocks : InheritableAttr {
-  let Spellings = [GNU<"blocks">];
+  let Spellings = [Clang<"blocks">];
   let Args = [EnumArgument<"Type", "BlockType", ["byref"], ["ByRef"]>];
   let Documentation = [Undocumented];
 }
@@ -727,34 +727,34 @@
 // cf_returns_retained attributes.  It is generally applied by
 // '#pragma clang arc_cf_code_audited' rather than explicitly.
 def CFAuditedTransfer : InheritableAttr {
-  let Spellings = [GNU<"cf_audited_transfer">];
+  let Spellings = [Clang<"cf_audited_transfer">];
   let Subjects = SubjectList<[Function], ErrorDiag>;
   let Documentation = [Undocumented];
 }
 
 // cf_unknown_transfer is an explicit opt-out of cf_audited_transfer.
 // It indicates that the function has unknown or unautomatable
 // transfer semantics.
 def CFUnknownTransfer : InheritableAttr {
-  let Spellings = [GNU<"cf_unknown_transfer">];
+  let Spellings = [Clang<"cf_unknown_transfer">];
   let Subjects = SubjectList<[Function], ErrorDiag>;
   let Documentation = [Undocumented];
 }
 
 def CFReturnsRetained : InheritableAttr {
-  let Spellings = [GNU<"cf_returns_retained">];
+  let Spellings = [Clang<"cf_returns_retained">];
 //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
   let Documentation = [Undocumented];
 }
 
 def CFReturnsNotRetained : InheritableAttr {
-  let Spellings = [GNU<"cf_returns_not_retained">];
+  let Spellings = [Clang<"cf_returns_not_retained">];
 //  let Subjects = SubjectList<[ObjCMethod, ObjCProperty, Function]>;
   let Documentation = [Undocumented];
 }
 
 def CFConsumed : InheritableParamAttr {
-  let Spellings = [GNU<"cf_consumed">];
+  let Spellings = [Clang<"cf_consumed">];
   let Subjects = SubjectList<[ParmVar]>;
   let Documentation = [Undocumented];
 }
@@ -875,7 +875,7 @@
 }
 
 def CXX11NoReturn : InheritableAttr {
-  let Spellings = [CXX11<"","noreturn", 200809>];
+  let Spellings = [CXX11<"", "noreturn", 200809>];
   let Subjects = SubjectList<[Function], ErrorDiag>;
   let Documentation = [CXX11NoReturnDocs];
 }
@@ -1030,13 +1030,13 @@
 }
 
 def MinSize : InheritableAttr {
-  let Spellings = [GNU<"minsize">];
+  let Spellings = [Clang<"minsize">];
   let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
   let Documentation = [Undocumented];
 }
 
 def FlagEnum : InheritableAttr {
-  let Spellings = [GNU<"flag_enum">];
+  let Spellings = [Clang<"flag_enum">];
   let Subjects = SubjectList<[Enum]>;
   let Documentation = [FlagEnumDocs];
 }
@@ -1085,22 +1085,22 @@
 }
 
 def IBAction : InheritableAttr {
-  let Spellings = [GNU<"ibaction">];
+  let Spellings = [Clang<"ibaction">];
   let Subjects = SubjectList<[ObjCInstanceMethod]>;
   // An AST node is created for this attribute, but is not used by other parts
   // of the compiler. However, this node needs to exist in the AST because
   // external tools rely on it.
   let Documentation = [Undocumented];
 }
 
 def IBOutlet : InheritableAttr {
-  let Spellings = [GNU<"iboutlet">];
+  let Spellings = [Clang<"iboutlet">];
 //  let Subjects = [ObjCIvar, ObjCProperty];
   let Documentation = [Undocumented];
 }
 
 def IBOutletCollection : InheritableAttr {
-  let Spellings = [GNU<"iboutletcollection">];
+  let Spellings = [Clang<"iboutletcollection">];
   let Args = [TypeArgument<"Interface", 1>];
 //  let Subjects = [ObjCIvar, ObjCProperty];
   let Documentation = [Undocumented];
@@ -1210,13 +1210,13 @@
 }
 
 def NeonPolyVectorType : TypeAttr {
-  let Spellings = [GNU<"neon_polyvector_type">];
+  let Spellings = [Clang<"neon_polyvector_type">];
   let Args = [IntArgument<"NumElements">];
   let Documentation = [Undocumented];
 }
 
 def NeonVectorType : TypeAttr {
-  let Spellings = [GNU<"neon_vector_type">];
+  let Spellings = [Clang<"neon_vector_type">];
   let Args = [IntArgument<"NumElements">];
   let Documentation = [Undocumented];
 }
@@ -1299,28 +1299,28 @@
 // this should be rejected on 

[PATCH] D40625: Harmonizing attribute GNU/C++ spellings

2017-12-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman marked 4 inline comments as done.
aaron.ballman added inline comments.



Comment at: include/clang/Basic/Attr.td:1218-1228
 def NeonPolyVectorType : TypeAttr {
-  let Spellings = [GNU<"neon_polyvector_type">];
+  let Spellings = [Clang<"neon_polyvector_type">];
   let Args = [IntArgument<"NumElements">];
   let Documentation = [Undocumented];
 }
 
 def NeonVectorType : TypeAttr {

sbaranga wrote:
> aaron.ballman wrote:
> > aaron.ballman wrote:
> > > rsmith wrote:
> > > > I *think* these are a Clang invention rather than part of the ARM NEON 
> > > > intrinsics specification, but perhaps you could ask someone from ARM to 
> > > > confirm that.
> > > @sbaranga or @jmolloy -- do you happen to know the answer to this, or 
> > > know someone who does?
> > Pinging this comment.
> Yes, these should be internal to clang and used to implement the ACLE 
> specification (which defines the NEON intrinsics). The ACLE doesn't define 
> these.
> 
> Here is a link to the latest spec: 
> https://developer.arm.com/products/software-development-tools/compilers/arm-compiler-5/docs/101028/latest/1-preface
Perfect, thank you @sbaranga!


https://reviews.llvm.org/D40625



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


[PATCH] D40940: [ubsan] Use pass_object_size info in bounds checks

2017-12-07 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv added a comment.

Thanks for this!

It's interesting to me that these array-bound checks don't seem to use 
`@llvm.objectsize` in some form already. I can't find any notes about it 
grepping through git/source, so I'm happy with it.




Comment at: lib/CodeGen/CGExpr.cpp:819
+   QualType EltTy) {
+  auto *DRE = dyn_cast(E->IgnoreImpCasts());
+  if (!DRE)

nit: would `IgnoreParenImpCasts` be better?



Comment at: lib/CodeGen/CGExpr.cpp:828
+  // Find the implicit size parameter.
+  auto SizeDeclIt = SizeArguments.find(PVD);
+  if (SizeDeclIt == SizeArguments.end())

We should probably only do this if the argument to `pass_object_size` is `0` or 
`1`. `2` and `3` give lower-bounds on size (and a default value of 0), which 
could result in false-positives.

(And please add a test that we don't do this for 2 or 3.)


https://reviews.llvm.org/D40940



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


r320078 - [OPENMP] Do not capture private variables in the target regions.

2017-12-07 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Dec  7 11:49:28 2017
New Revision: 320078

URL: http://llvm.org/viewvc/llvm-project?rev=320078=rev
Log:
[OPENMP] Do not capture private variables in the target regions.

Private variables are completely redefined in the outlined regions, so
we don't need to capture them. Patch adds this behavior to the
target-based regions.

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_private_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_private_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_private_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_private_codegen.cpp
cfe/trunk/test/OpenMP/teams_private_codegen.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=320078=320077=320078=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Dec  7 11:49:28 2017
@@ -14619,14 +14619,16 @@ bool Sema::tryCaptureVariable(
 // just break here. Similarly, global variables that are captured in a
 // target region should not be captured outside the scope of the 
region.
 if (RSI->CapRegionKind == CR_OpenMP) {
-  auto IsTargetCap = isOpenMPTargetCapturedDecl(Var, RSI->OpenMPLevel);
+  bool IsOpenMPPrivateDecl = isOpenMPPrivateDecl(Var, 
RSI->OpenMPLevel);
+  auto IsTargetCap = !IsOpenMPPrivateDecl &&
+ isOpenMPTargetCapturedDecl(Var, RSI->OpenMPLevel);
   // When we detect target captures we are looking from inside the
   // target region, therefore we need to propagate the capture from the
   // enclosing region. Therefore, the capture is not initially nested.
   if (IsTargetCap)
 FunctionScopesIndex--;
 
-  if (IsTargetCap || isOpenMPPrivateDecl(Var, RSI->OpenMPLevel)) {
+  if (IsTargetCap || IsOpenMPPrivateDecl) {
 Nested = !IsTargetCap;
 DeclRefType = DeclRefType.getUnqualifiedType();
 CaptureType = Context.getLValueReferenceType(DeclRefType);

Modified: 
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_private_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/teams_distribute_parallel_for_private_codegen.cpp?rev=320078=320077=320078=diff
==
--- cfe/trunk/test/OpenMP/teams_distribute_parallel_for_private_codegen.cpp 
(original)
+++ cfe/trunk/test/OpenMP/teams_distribute_parallel_for_private_codegen.cpp Thu 
Dec  7 11:49:28 2017
@@ -72,13 +72,13 @@ int main() {
   // LAMBDA: call void [[OUTER_LAMBDA:@.+]](
   [&]() {
 // LAMBDA: define{{.*}} internal{{.*}} void [[OUTER_LAMBDA]](
-// LAMBDA: call i32 @__tgt_target_teams(i64 -1, i8* @{{[^,]+}}, i32 3, 
i8** %{{[^,]+}}, i8** %{{[^,]+}}, i{{64|32}}* {{.+}}@{{[^,]+}}, i32 0, i32 0), 
i64* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32 0, i32 0)
+// LAMBDA: call i32 @__tgt_target_teams(i64 -1, i8* @{{[^,]+}}, i32 1, 
i8** %{{[^,]+}}, i8** %{{[^,]+}}, i{{64|32}}* {{.+}}@{{[^,]+}}, i32 0, i32 0), 
i64* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32 0, i32 0)
 // LAMBDA: call void @[[LOFFL1:.+]](
 // LAMBDA:  ret
 #pragma omp target
 #pragma omp teams distribute parallel for private(g, g1, sivar)
   for (int i = 0; i < 2; ++i) {
-// LAMBDA: define{{.*}} internal{{.*}} void @[[LOFFL1]](i{{64|32}} 
{{%.+}}, i{{64|32}} {{%.+}})
+// LAMBDA: define{{.*}} internal{{.*}} void @[[LOFFL1]](i{{64|32}} {{%.+}})
 // LAMBDA: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 0, {{.+}} 
@[[LOUTL1:.+]] to {{.+}})
 // LAMBDA: ret void
 
@@ -164,12 +164,12 @@ int main() {
 }
 
 // CHECK: define {{.*}}i{{[0-9]+}} @main()
-// CHECK: call i32 @__tgt_target_teams(i64 -1, i8* @{{[^,]+}}, i32 5, i8** 
%{{[^,]+}}, i8** %{{[^,]+}}, i{{64|32}}* {{.+}}@{{[^,]+}}, i32 0, i32 0), i64* 
{{.+}}@{{[^,]+}}, i32 0, i32 0), i32 0, i32 0)
-// CHECK: call void @[[OFFL1:.+]](i{{64|32}} %{{.+}})
+// CHECK: call i32 @__tgt_target_teams(i64 -1, i8* @{{[^,]+}}, i32 0, i8** 
null, i8** null, i{{64|32}}* null, i64* null, i32 0, i32 0)
+// CHECK: call void @[[OFFL1:.+]]()
 // CHECK: {{%.+}} = call{{.*}} i32 @[[TMAIN_INT:.+]]()
 // CHECK:  ret
 
-// CHECK: define{{.*}} void @[[OFFL1]]({{.+}})
+// CHECK: define{{.*}} void @[[OFFL1]]()
 // CHECK: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 0, {{.+}} 
@[[OUTL1:.+]] to {{.+}})
 // CHECK: ret void
 

Modified: 
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_private_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_private_codegen.cpp?rev=320078=320077=320078=diff
==
--- 

[PATCH] D40948: Switch Clang's default C++ language target to C++14

2017-12-07 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a reviewer: rjmccall.
probinson added a comment.

+rjmccall for the codegen bits.




Comment at: clang/test/SemaCXX/new-array-size-conv.cpp:1
-// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -fsyntax-only -pedantic -verify -std=gnu++98 %s
 // RUN: %clang_cc1 -fsyntax-only -pedantic -verify -std=c++98 %s

I think the intent here was "whatever the current default is" and not 
specifically gnu++98, because the next line explicitly specifies c++98.  So, 
unless this test fails miserably for C++14 (which I wouldn't expect) I think it 
should be adapted to whatever gets reported for that dialect.


Repository:
  rC Clang

https://reviews.llvm.org/D40948



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


[PATCH] D40977: [OpenMP] NVPTX: Set default/minimum compute capability to sm_35

2017-12-07 Thread George Rokos via Phabricator via cfe-commits
grokos created this revision.
grokos added a project: OpenMP.
Herald added a subscriber: mgorny.

The current implementation of the nvptx runtime (to be upstreamed shortly) uses 
the `atomicMax` operation on 64-bit integers. This is only supported in compute 
capabilities 3.5 and later. I've changed the clang default to `sm_35`.


Repository:
  rC Clang

https://reviews.llvm.org/D40977

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -241,14 +241,15 @@
 set(CLANG_DEFAULT_OPENMP_RUNTIME "libomp" CACHE STRING
   "Default OpenMP runtime used by -fopenmp.")
 
-# OpenMP offloading requires at least sm_30 because we use shuffle instructions
-# to generate efficient code for reductions.
-set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH "sm_30" CACHE STRING
+# OpenMP offloading requires at least sm_35 because we use shuffle instructions
+# to generate efficient code for reductions and the atomicMax instruction on
+# 64-bit integers in the implementation of conditional lastprivate.
+set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH "sm_35" CACHE STRING
   "Default architecture for OpenMP offloading to Nvidia GPUs.")
 string(REGEX MATCH "^sm_([0-9]+)$" MATCHED_ARCH 
"${CLANG_OPENMP_NVPTX_DEFAULT_ARCH}")
-if (NOT DEFINED MATCHED_ARCH OR "${CMAKE_MATCH_1}" LESS 30)
-  message(WARNING "Resetting default architecture for OpenMP offloading to 
Nvidia GPUs to sm_30")
-  set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH "sm_30" CACHE STRING
+if (NOT DEFINED MATCHED_ARCH OR "${CMAKE_MATCH_1}" LESS 35)
+  message(WARNING "Resetting default architecture for OpenMP offloading to 
Nvidia GPUs to sm_35")
+  set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH "sm_35" CACHE STRING
 "Default architecture for OpenMP offloading to Nvidia GPUs." FORCE)
 endif()
 


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -241,14 +241,15 @@
 set(CLANG_DEFAULT_OPENMP_RUNTIME "libomp" CACHE STRING
   "Default OpenMP runtime used by -fopenmp.")
 
-# OpenMP offloading requires at least sm_30 because we use shuffle instructions
-# to generate efficient code for reductions.
-set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH "sm_30" CACHE STRING
+# OpenMP offloading requires at least sm_35 because we use shuffle instructions
+# to generate efficient code for reductions and the atomicMax instruction on
+# 64-bit integers in the implementation of conditional lastprivate.
+set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH "sm_35" CACHE STRING
   "Default architecture for OpenMP offloading to Nvidia GPUs.")
 string(REGEX MATCH "^sm_([0-9]+)$" MATCHED_ARCH "${CLANG_OPENMP_NVPTX_DEFAULT_ARCH}")
-if (NOT DEFINED MATCHED_ARCH OR "${CMAKE_MATCH_1}" LESS 30)
-  message(WARNING "Resetting default architecture for OpenMP offloading to Nvidia GPUs to sm_30")
-  set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH "sm_30" CACHE STRING
+if (NOT DEFINED MATCHED_ARCH OR "${CMAKE_MATCH_1}" LESS 35)
+  message(WARNING "Resetting default architecture for OpenMP offloading to Nvidia GPUs to sm_35")
+  set(CLANG_OPENMP_NVPTX_DEFAULT_ARCH "sm_35" CACHE STRING
 "Default architecture for OpenMP offloading to Nvidia GPUs." FORCE)
 endif()
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40936: Hardware-assisted AddressSanitizer (clang part).

2017-12-07 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added inline comments.



Comment at: clang/include/clang/Basic/Sanitizers.def:47
 
+SANITIZER("hwaddress", HWAddress)
+

alekseyshl wrote:
> Why didn't we follow KASan style and name it "hw-address"?
A matter of taste, I guess.
I don't want the attribute to be sanitize_hw_address, too many underscores.
Also, kernel is a word and hw is just to letters.




Comment at: clang/lib/Driver/SanitizerArgs.cpp:383
+  std::make_pair(Efficiency, Address | HWAddress | Leak | Thread | Memory |
+ KernelAddress),
+  std::make_pair(Scudo, Address | HWAddress | Leak | Thread | Memory |

alekseyshl wrote:
> Nit: 4 less spaces here and for the next pair.
https://bugs.llvm.org/show_bug.cgi?id=35563


https://reviews.llvm.org/D40936



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


[PATCH] D39375: [clang] Add PPCallbacks list to preprocessor when building a preacompiled preamble.

2017-12-07 Thread William Enright via Phabricator via cfe-commits
Nebiroth added inline comments.



Comment at: lib/Frontend/PrecompiledPreamble.cpp:242
 std::shared_ptr PCHContainerOps, bool 
StoreInMemory,
-PreambleCallbacks ) {
+PreambleCallbacks , std::unique_ptr PPCallbacks) {
   assert(VFS && "VFS is null");

ilya-biryukov wrote:
> Could we add a method to `PreambleCallbacks` to create `PPCallbacks` instead?
> Otherwise we have both `MacroDefined` in `PreambleCallbacks` and a separate 
> set of PPCallbacks, so we have two ways of doing the same thing.
> 
> ```
> class PreambleCallbacks {
> public:
> // ...
> 
>   /// Remove this.
>   virtual void HandleMacroDefined(...);
> 
>   // Add this instead.
>   virtual std::unique_ptr createPPCallbacks();
> 
> }
> ```
> 
> Alternatively, follow the current pattern in `PreambleCallbacks` and add some 
> extra functions from the `PPCallbacks` interface to it. This would not 
> require changes to the existing usages of `PrecompiledPreamble` in `ASTUnit`. 
> Albeit, I'd prefer the first option.
> ```
> class PreambleCallbacks {
> public:
> // ...
> 
>   // Keep this
>   virtual void HandleMacroDefined(...);
>   // Add the ones you need, e.g.
>   virtual void InclusionDirective(...);
>   virtual void FileChanged(...);
> };
> ```
If we were to do that, one would then be required to define a wrapper class for 
PPCallbacks and create an instance of it inside createPPCallbacks() for the 
purpose of creating a unique_ptr? Then that unique_ptr would be sent from 
within the PreambleCallbacks parameter in the Build function?


Repository:
  rC Clang

https://reviews.llvm.org/D39375



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


[PATCH] D40938: update hwasan docs

2017-12-07 Thread Kostya Serebryany via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC320075: update hwasan docs (authored by kcc).

Changed prior to commit:
  https://reviews.llvm.org/D40938?vs=126001=126005#toc

Repository:
  rC Clang

https://reviews.llvm.org/D40938

Files:
  docs/HardwareAssistedAddressSanitizerDesign.rst


Index: docs/HardwareAssistedAddressSanitizerDesign.rst
===
--- docs/HardwareAssistedAddressSanitizerDesign.rst
+++ docs/HardwareAssistedAddressSanitizerDesign.rst
@@ -1,9 +1,9 @@
-=
-HardwareAssistedAddressSanitizer Design Documentation
-=
+===
+Hardware-assisted AddressSanitizer Design Documentation
+===
 
 This page is a design document for
-**HardwareAssistedAddressSanitizer** (or HWASAN)
+**hardware-assisted AddressSanitizer** (or **HWASAN**)
 a tool similar to :doc:`AddressSanitizer`,
 but based on partial hardware assistance.
 
@@ -23,7 +23,7 @@
 
 AArch64 has the `Address Tagging`_, a hardware feature that allows
 software to use 8 most significant bits of a 64-bit pointer as
-a tag. HardwareAssistedAddressSanitizer uses `Address Tagging`_
+a tag. HWASAN uses `Address Tagging`_
 to implement a memory safety tool, similar to :doc:`AddressSanitizer`,
 but with smaller memory overhead and slightly different (mostly better)
 accuracy guarantees.
@@ -77,11 +77,26 @@
 
 Errors are generated by `__builtin_trap` and are handled by a signal handler.
 
+Attribute
+-
+
+HWASAN uses it's own LLVM IR Attribute `sanitize_hwaddress` and a matching
+C function attribute. An alternative would be to re-use ASAN's attribute
+`sanitize_address`. The reasons to use a separate attribute are:
+
+  * Users may need to disable ASAN but not HWASAN, or vise versa,
+because the tools have different trade-offs and compatibility issues.
+  * LLVM (ideally) does not use flags to decide which pass is being used,
+ASAN or HWASAN are being applied, based on the function attributes.
+
+This does mean that users of HWASAN may need to add the new attribute
+to the code that already uses the old attribute.
+
 
 Comparison with AddressSanitizer
 
 
-HardwareAssistedAddressSanitizer:
+HWASAN:
   * Is less portable than :doc:`AddressSanitizer`
 as it relies on hardware `Address Tagging`_ (AArch64).
 Address Tagging can be emulated with compiler instrumentation,
@@ -91,15 +106,16 @@
   * May have compatibility problems if the target code uses higher
 pointer bits for other purposes.
   * May require changes in the OS kernels (e.g. Linux seems to dislike
-tagged pointers passed from address space).
+tagged pointers passed from address space:
+https://www.kernel.org/doc/Documentation/arm64/tagged-pointers.txt).
   * **Does not require redzones to detect buffer overflows**,
 but the buffer overflow detection is probabilistic, with roughly
 `(2**K-1)/(2**K)` probability of catching a bug.
   * **Does not require quarantine to detect heap-use-after-free,
 or stack-use-after-return**.
 The detection is similarly probabilistic.
 
-The memory overhead of HardwareAssistedAddressSanitizer is expected to be much 
smaller
+The memory overhead of HWASAN is expected to be much smaller
 than that of AddressSanitizer:
 `1/N` extra memory for the shadow
 and some overhead due to `N`-aligning all objects.


Index: docs/HardwareAssistedAddressSanitizerDesign.rst
===
--- docs/HardwareAssistedAddressSanitizerDesign.rst
+++ docs/HardwareAssistedAddressSanitizerDesign.rst
@@ -1,9 +1,9 @@
-=
-HardwareAssistedAddressSanitizer Design Documentation
-=
+===
+Hardware-assisted AddressSanitizer Design Documentation
+===
 
 This page is a design document for
-**HardwareAssistedAddressSanitizer** (or HWASAN)
+**hardware-assisted AddressSanitizer** (or **HWASAN**)
 a tool similar to :doc:`AddressSanitizer`,
 but based on partial hardware assistance.
 
@@ -23,7 +23,7 @@
 
 AArch64 has the `Address Tagging`_, a hardware feature that allows
 software to use 8 most significant bits of a 64-bit pointer as
-a tag. HardwareAssistedAddressSanitizer uses `Address Tagging`_
+a tag. HWASAN uses `Address Tagging`_
 to implement a memory safety tool, similar to :doc:`AddressSanitizer`,
 but with smaller memory overhead and slightly different (mostly better)
 accuracy guarantees.
@@ -77,11 +77,26 @@
 
 Errors are generated by `__builtin_trap` and are handled by a signal handler.
 
+Attribute
+-
+
+HWASAN uses it's own LLVM IR 

r320075 - update hwasan docs

2017-12-07 Thread Kostya Serebryany via cfe-commits
Author: kcc
Date: Thu Dec  7 11:21:30 2017
New Revision: 320075

URL: http://llvm.org/viewvc/llvm-project?rev=320075=rev
Log:
update hwasan docs

Summary:
* use more readable name
* document the hwasan attribute

Reviewers: eugenis

Reviewed By: eugenis

Subscribers: llvm-commits, cfe-commits

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

Modified:
cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst

Modified: cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst?rev=320075=320074=320075=diff
==
--- cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst (original)
+++ cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst Thu Dec  7 
11:21:30 2017
@@ -1,9 +1,9 @@
-=
-HardwareAssistedAddressSanitizer Design Documentation
-=
+===
+Hardware-assisted AddressSanitizer Design Documentation
+===
 
 This page is a design document for
-**HardwareAssistedAddressSanitizer** (or HWASAN)
+**hardware-assisted AddressSanitizer** (or **HWASAN**)
 a tool similar to :doc:`AddressSanitizer`,
 but based on partial hardware assistance.
 
@@ -23,7 +23,7 @@ See the `AddressSanitizer paper`_ for de
 
 AArch64 has the `Address Tagging`_, a hardware feature that allows
 software to use 8 most significant bits of a 64-bit pointer as
-a tag. HardwareAssistedAddressSanitizer uses `Address Tagging`_
+a tag. HWASAN uses `Address Tagging`_
 to implement a memory safety tool, similar to :doc:`AddressSanitizer`,
 but with smaller memory overhead and slightly different (mostly better)
 accuracy guarantees.
@@ -77,11 +77,26 @@ Error reporting
 
 Errors are generated by `__builtin_trap` and are handled by a signal handler.
 
+Attribute
+-
+
+HWASAN uses it's own LLVM IR Attribute `sanitize_hwaddress` and a matching
+C function attribute. An alternative would be to re-use ASAN's attribute
+`sanitize_address`. The reasons to use a separate attribute are:
+
+  * Users may need to disable ASAN but not HWASAN, or vise versa,
+because the tools have different trade-offs and compatibility issues.
+  * LLVM (ideally) does not use flags to decide which pass is being used,
+ASAN or HWASAN are being applied, based on the function attributes.
+
+This does mean that users of HWASAN may need to add the new attribute
+to the code that already uses the old attribute.
+
 
 Comparison with AddressSanitizer
 
 
-HardwareAssistedAddressSanitizer:
+HWASAN:
   * Is less portable than :doc:`AddressSanitizer`
 as it relies on hardware `Address Tagging`_ (AArch64).
 Address Tagging can be emulated with compiler instrumentation,
@@ -91,7 +106,8 @@ HardwareAssistedAddressSanitizer:
   * May have compatibility problems if the target code uses higher
 pointer bits for other purposes.
   * May require changes in the OS kernels (e.g. Linux seems to dislike
-tagged pointers passed from address space).
+tagged pointers passed from address space:
+https://www.kernel.org/doc/Documentation/arm64/tagged-pointers.txt).
   * **Does not require redzones to detect buffer overflows**,
 but the buffer overflow detection is probabilistic, with roughly
 `(2**K-1)/(2**K)` probability of catching a bug.
@@ -99,7 +115,7 @@ HardwareAssistedAddressSanitizer:
 or stack-use-after-return**.
 The detection is similarly probabilistic.
 
-The memory overhead of HardwareAssistedAddressSanitizer is expected to be much 
smaller
+The memory overhead of HWASAN is expected to be much smaller
 than that of AddressSanitizer:
 `1/N` extra memory for the shadow
 and some overhead due to `N`-aligning all objects.


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


[PATCH] D40936: Hardware-assisted AddressSanitizer (clang part).

2017-12-07 Thread Aleksey Shlyapnikov via Phabricator via cfe-commits
alekseyshl accepted this revision.
alekseyshl added inline comments.



Comment at: clang/include/clang/Basic/Sanitizers.def:47
 
+SANITIZER("hwaddress", HWAddress)
+

Why didn't we follow KASan style and name it "hw-address"?



Comment at: clang/lib/Driver/SanitizerArgs.cpp:383
+  std::make_pair(Efficiency, Address | HWAddress | Leak | Thread | Memory |
+ KernelAddress),
+  std::make_pair(Scudo, Address | HWAddress | Leak | Thread | Memory |

Nit: 4 less spaces here and for the next pair.


https://reviews.llvm.org/D40936



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


[PATCH] D40682: [driver] Set the 'simulator' environment for Darwin when -msimulator-version-min is used

2017-12-07 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC320073: [driver] Set the 'simulator' environment for Darwin 
when compiling for (authored by arphaman).

Repository:
  rC Clang

https://reviews.llvm.org/D40682

Files:
  include/clang/Driver/ToolChain.h
  lib/CodeGen/CGObjCMac.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains/Darwin.cpp
  lib/Driver/ToolChains/Darwin.h
  lib/Frontend/InitPreprocessor.cpp
  test/Driver/darwin-sdkroot.c
  test/Driver/darwin-simulator-macro.c
  test/Driver/darwin-version.c
  test/Driver/fsanitize.c

Index: include/clang/Driver/ToolChain.h
===
--- include/clang/Driver/ToolChain.h
+++ include/clang/Driver/ToolChain.h
@@ -93,7 +93,7 @@
 
 private:
   const Driver 
-  const llvm::Triple Triple;
+  llvm::Triple Triple;
   const llvm::opt::ArgList 
   // We need to initialize CachedRTTIArg before CachedRTTIMode
   const llvm::opt::Arg *const CachedRTTIArg;
@@ -136,6 +136,8 @@
   ToolChain(const Driver , const llvm::Triple ,
 const llvm::opt::ArgList );
 
+  void setTripleEnvironment(llvm::Triple::EnvironmentType Env);
+
   virtual Tool *buildAssembler() const;
   virtual Tool *buildLinker() const;
   virtual Tool *getTool(Action::ActionClass AC) const;
Index: test/Driver/darwin-simulator-macro.c
===
--- test/Driver/darwin-simulator-macro.c
+++ test/Driver/darwin-simulator-macro.c
@@ -4,9 +4,8 @@
 // RUN: %clang -target x86_64-apple-darwin10 -arch x86_64 -mappletvsimulator-version-min=6.0.0 -E -dM %s | FileCheck -check-prefix=SIM %s
 // RUN: %clang -target x86_64-apple-darwin10 -arch x86_64 -mwatchos-simulator-version-min=6.0.0 -E -dM %s | FileCheck -check-prefix=SIM %s
 // RUN: %clang -target x86_64-apple-darwin10 -arch x86_64 -mwatchsimulator-version-min=6.0.0 -E -dM %s | FileCheck -check-prefix=SIM %s
-// RUN: %clang -target x86_64-apple-darwin10 -arch x86_64 -mios-version-min=6.0.0 -E -dM %s | FileCheck -check-prefix=DEV %s
-// RUN: %clang -target x86_64-apple-darwin10 -arch x86_64 -mtvos-version-min=6.0.0 -E -dM %s | FileCheck -check-prefix=DEV %s
-// RUN: %clang -target x86_64-apple-darwin10 -arch x86_64 -mwatchos-version-min=6.0.0 -E -dM %s | FileCheck -check-prefix=DEV %s
+// RUN: %clang -target x86_64-apple-darwin10 -arch x86_64 -mios-version-min=6.0.0 -E -dM %s | FileCheck -check-prefix=SIM %s
+// RUN: %clang -target x86_64-apple-darwin10 -arch x86_64 -mtvos-version-min=6.0.0 -E -dM %s | FileCheck -check-prefix=SIM %s
+// RUN: %clang -target x86_64-apple-darwin10 -arch x86_64 -mwatchos-version-min=6.0.0 -E -dM %s | FileCheck -check-prefix=SIM %s
 
 // SIM: #define __APPLE_EMBEDDED_SIMULATOR__ 1
-// DEV-NOT: __APPLE_EMBEDDED_SIMULATOR__
Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -334,10 +334,10 @@
 // CHECK-TSAN-ARM-IOS: unsupported option '-fsanitize=thread' for target 'arm-apple-ios'
 
 // RUN: %clang -target i386-apple-iossimulator -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-I386-IOSSIMULATOR
-// CHECK-TSAN-I386-IOSSIMULATOR: unsupported option '-fsanitize=thread' for target 'i386-apple-iossimulator'
+// CHECK-TSAN-I386-IOSSIMULATOR: unsupported option '-fsanitize=thread' for target 'i386-apple-iossimulator-simulator'
 
 // RUN: %clang -target i386-apple-tvossimulator -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-I386-TVOSSIMULATOR
-// CHECK-TSAN-I386-TVOSSIMULATOR: unsupported option '-fsanitize=thread' for target 'i386-apple-tvossimulator'
+// CHECK-TSAN-I386-TVOSSIMULATOR: unsupported option '-fsanitize=thread' for target 'i386-apple-tvossimulator-simulator'
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=thread -fsanitize-thread-memory-access %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-MEMORY-ACCESS
 // CHECK-TSAN-MEMORY-ACCESS-NOT: -cc1{{.*}}tsan-instrument-memory-accesses=0
@@ -423,11 +423,11 @@
 
 // RUN: %clang -target i386-apple-iossimulator -fsanitize=efficiency-cache-frag %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ESAN-I386-IOSSIMULATOR
 // RUN: %clang -target i386-apple-iossimulator -fsanitize=efficiency-working-set %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ESAN-I386-IOSSIMULATOR
-// CHECK-ESAN-I386-IOSSIMULATOR: unsupported option '-fsanitize=efficiency-{{.*}}' for target 'i386-apple-iossimulator'
+// CHECK-ESAN-I386-IOSSIMULATOR: unsupported option '-fsanitize=efficiency-{{.*}}' for target 'i386-apple-iossimulator-simulator'
 
 // RUN: %clang -target i386-apple-tvossimulator -fsanitize=efficiency-cache-frag %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ESAN-I386-TVOSSIMULATOR
 // RUN: %clang -target i386-apple-tvossimulator -fsanitize=efficiency-working-set %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ESAN-I386-TVOSSIMULATOR
-// CHECK-ESAN-I386-TVOSSIMULATOR: unsupported 

[PATCH] D40938: update hwasan docs

2017-12-07 Thread Kostya Serebryany via Phabricator via cfe-commits
kcc updated this revision to Diff 126001.
kcc added a comment.

mention https://www.kernel.org/doc/Documentation/arm64/tagged-pointers.txt


Repository:
  rC Clang

https://reviews.llvm.org/D40938

Files:
  docs/HardwareAssistedAddressSanitizerDesign.rst


Index: docs/HardwareAssistedAddressSanitizerDesign.rst
===
--- docs/HardwareAssistedAddressSanitizerDesign.rst
+++ docs/HardwareAssistedAddressSanitizerDesign.rst
@@ -1,9 +1,9 @@
-=
-HardwareAssistedAddressSanitizer Design Documentation
-=
+===
+Hardware-assisted AddressSanitizer Design Documentation
+===
 
 This page is a design document for
-**HardwareAssistedAddressSanitizer** (or HWASAN)
+**hardware-assisted AddressSanitizer** (or **HWASAN**)
 a tool similar to :doc:`AddressSanitizer`,
 but based on partial hardware assistance.
 
@@ -23,7 +23,7 @@
 
 AArch64 has the `Address Tagging`_, a hardware feature that allows
 software to use 8 most significant bits of a 64-bit pointer as
-a tag. HardwareAssistedAddressSanitizer uses `Address Tagging`_
+a tag. HWASAN uses `Address Tagging`_
 to implement a memory safety tool, similar to :doc:`AddressSanitizer`,
 but with smaller memory overhead and slightly different (mostly better)
 accuracy guarantees.
@@ -77,11 +77,26 @@
 
 Errors are generated by `__builtin_trap` and are handled by a signal handler.
 
+Attribute
+-
+
+HWASAN uses it's own LLVM IR Attribute `sanitize_hwaddress` and a matching
+C function attribute. An alternative would be to re-use ASAN's attribute
+`sanitize_address`. The reasons to use a separate attribute are:
+
+  * Users may need to disable ASAN but not HWASAN, or vise versa,
+because the tools have different trade-offs and compatibility issues.
+  * LLVM (ideally) does not use flags to decide which pass is being used,
+ASAN or HWASAN are being applied, based on the function attributes.
+
+This does mean that users of HWASAN may need to add the new attribute
+to the code that already uses the old attribute.
+
 
 Comparison with AddressSanitizer
 
 
-HardwareAssistedAddressSanitizer:
+HWASAN:
   * Is less portable than :doc:`AddressSanitizer`
 as it relies on hardware `Address Tagging`_ (AArch64).
 Address Tagging can be emulated with compiler instrumentation,
@@ -91,15 +106,16 @@
   * May have compatibility problems if the target code uses higher
 pointer bits for other purposes.
   * May require changes in the OS kernels (e.g. Linux seems to dislike
-tagged pointers passed from address space).
+tagged pointers passed from address space:
+https://www.kernel.org/doc/Documentation/arm64/tagged-pointers.txt).
   * **Does not require redzones to detect buffer overflows**,
 but the buffer overflow detection is probabilistic, with roughly
 `(2**K-1)/(2**K)` probability of catching a bug.
   * **Does not require quarantine to detect heap-use-after-free,
 or stack-use-after-return**.
 The detection is similarly probabilistic.
 
-The memory overhead of HardwareAssistedAddressSanitizer is expected to be much 
smaller
+The memory overhead of HWASAN is expected to be much smaller
 than that of AddressSanitizer:
 `1/N` extra memory for the shadow
 and some overhead due to `N`-aligning all objects.


Index: docs/HardwareAssistedAddressSanitizerDesign.rst
===
--- docs/HardwareAssistedAddressSanitizerDesign.rst
+++ docs/HardwareAssistedAddressSanitizerDesign.rst
@@ -1,9 +1,9 @@
-=
-HardwareAssistedAddressSanitizer Design Documentation
-=
+===
+Hardware-assisted AddressSanitizer Design Documentation
+===
 
 This page is a design document for
-**HardwareAssistedAddressSanitizer** (or HWASAN)
+**hardware-assisted AddressSanitizer** (or **HWASAN**)
 a tool similar to :doc:`AddressSanitizer`,
 but based on partial hardware assistance.
 
@@ -23,7 +23,7 @@
 
 AArch64 has the `Address Tagging`_, a hardware feature that allows
 software to use 8 most significant bits of a 64-bit pointer as
-a tag. HardwareAssistedAddressSanitizer uses `Address Tagging`_
+a tag. HWASAN uses `Address Tagging`_
 to implement a memory safety tool, similar to :doc:`AddressSanitizer`,
 but with smaller memory overhead and slightly different (mostly better)
 accuracy guarantees.
@@ -77,11 +77,26 @@
 
 Errors are generated by `__builtin_trap` and are handled by a signal handler.
 
+Attribute
+-
+
+HWASAN uses it's own LLVM IR Attribute `sanitize_hwaddress` and a matching
+C function attribute. An 

[clang-tools-extra] r320074 - [clangd-fuzzer] Update contruction of LSPServer.

2017-12-07 Thread Matt Morehouse via cfe-commits
Author: morehouse
Date: Thu Dec  7 11:04:27 2017
New Revision: 320074

URL: http://llvm.org/viewvc/llvm-project?rev=320074=rev
Log:
[clangd-fuzzer] Update contruction of LSPServer.

The constructor for ClangdLSPServer changed in r318412 and r318925,
breaking the clangd-fuzzer build.

Modified:
clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp

Modified: clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp?rev=320074=320073=320074=diff
==
--- clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp (original)
+++ clang-tools-extra/trunk/clangd/fuzzer/ClangdFuzzer.cpp Thu Dec  7 11:04:27 
2017
@@ -13,16 +13,19 @@
 ///
 
//===--===//
 
+#include "CodeComplete.h"
 #include "ClangdLSPServer.h"
 #include 
 
 extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
   clang::clangd::JSONOutput Out(llvm::nulls(), llvm::nulls(), nullptr);
+  clang::clangd::CodeCompleteOptions CCOpts;
+  CCOpts.EnableSnippets = false;
 
   // Initialize and run ClangdLSPServer.
   clang::clangd::ClangdLSPServer LSPServer(
   Out, clang::clangd::getDefaultAsyncThreadsCount(),
-  /*EnableSnippets=*/false, llvm::None, llvm::None);
+  /*StorePreamblesInMemory=*/false, CCOpts, llvm::None, llvm::None);
 
   std::istringstream In(std::string(reinterpret_cast(data), size));
   LSPServer.run(In);


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


r320073 - [driver] Set the 'simulator' environment for Darwin when compiling for

2017-12-07 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Dec  7 11:04:10 2017
New Revision: 320073

URL: http://llvm.org/viewvc/llvm-project?rev=320073=rev
Log:
[driver] Set the 'simulator' environment for Darwin when compiling for
iOS/tvOS/watchOS simulator

rdar://35135215

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

Modified:
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/lib/Driver/ToolChains/Darwin.h
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/Driver/darwin-sdkroot.c
cfe/trunk/test/Driver/darwin-simulator-macro.c
cfe/trunk/test/Driver/darwin-version.c
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=320073=320072=320073=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Thu Dec  7 11:04:10 2017
@@ -93,7 +93,7 @@ public:
 
 private:
   const Driver 
-  const llvm::Triple Triple;
+  llvm::Triple Triple;
   const llvm::opt::ArgList 
   // We need to initialize CachedRTTIArg before CachedRTTIMode
   const llvm::opt::Arg *const CachedRTTIArg;
@@ -136,6 +136,8 @@ protected:
   ToolChain(const Driver , const llvm::Triple ,
 const llvm::opt::ArgList );
 
+  void setTripleEnvironment(llvm::Triple::EnvironmentType Env);
+
   virtual Tool *buildAssembler() const;
   virtual Tool *buildLinker() const;
   virtual Tool *getTool(Action::ActionClass AC) const;

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=320073=320072=320073=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Thu Dec  7 11:04:10 2017
@@ -4885,10 +4885,7 @@ void CGObjCCommonMac::EmitImageInfo() {
   }
 
   // Indicate whether we're compiling this to run on a simulator.
-  const llvm::Triple  = CGM.getTarget().getTriple();
-  if ((Triple.isiOS() || Triple.isWatchOS()) &&
-  (Triple.getArch() == llvm::Triple::x86 ||
-   Triple.getArch() == llvm::Triple::x86_64))
+  if (CGM.getTarget().getTriple().isSimulatorEnvironment())
 Mod.addModuleFlag(llvm::Module::Error, "Objective-C Is Simulated",
   eImageInfo_ImageIsSimulated);
 

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=320073=320072=320073=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Thu Dec  7 11:04:10 2017
@@ -81,6 +81,12 @@ ToolChain::ToolChain(const Driver , co
 getFilePaths().push_back(CandidateLibPath);
 }
 
+void ToolChain::setTripleEnvironment(llvm::Triple::EnvironmentType Env) {
+  Triple.setEnvironment(Env);
+  if (EffectiveTriple != llvm::Triple())
+EffectiveTriple.setEnvironment(Env);
+}
+
 ToolChain::~ToolChain() {
 }
 

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=320073=320072=320073=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Thu Dec  7 11:04:10 2017
@@ -1214,14 +1214,6 @@ void Darwin::AddDeploymentTarget(Derived
   if (iOSVersion)
 ExplicitIOSDeploymentTargetStr = iOSVersion->getAsString(Args);
 
-  // Add a macro to differentiate between m(iphone|tv|watch)os-version-min=X.Y 
and
-  // -m(iphone|tv|watch)simulator-version-min=X.Y.
-  if (Args.hasArg(options::OPT_mios_simulator_version_min_EQ) ||
-  Args.hasArg(options::OPT_mtvos_simulator_version_min_EQ) ||
-  Args.hasArg(options::OPT_mwatchos_simulator_version_min_EQ))
-Args.append(Args.MakeSeparateArg(nullptr, Opts.getOption(options::OPT_D),
- " __APPLE_EMBEDDED_SIMULATOR__=1"));
-
   if (OSXVersion && (iOSVersion || TvOSVersion || WatchOSVersion)) {
 getDriver().Diag(diag::err_drv_argument_not_allowed_with)
 << OSXVersion->getAsString(Args)

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.h?rev=320073=320072=320073=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.h Thu Dec  7 11:04:10 2017
@@ -329,6 +329,9 @@ protected:
 TargetInitialized = true;
 TargetPlatform = Platform;
 TargetVersion = VersionTuple(Major, Minor, Micro);
+if 

[PATCH] D39050: Add index-while-building support to Clang

2017-12-07 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi added a comment.

@malaperle, to clarify we are not suggesting that you write your own parser, 
the suggestion is to use clang in 'fast-scan' mode to get the structure of the 
declarations of a single file, see `CXTranslationUnit_SingleFileParse` (along 
with enabling skipping of bodies). We have found clang is super fast when you 
only try to get the structure of a file like this. We can make convenient APIs 
to provide the syntactic structure of declarations based on their location.

But let's say we added the end-loc, is it enough ? If you want to implement the 
'peek the definition' like Eclipse, then it is not enough, you also need to 
figure out if there are documentation comments associated with the declaration 
and also show those. Also what if you want to highlight the type signature of a 
function, then just storing the location of the closing brace of its body is 
not enough. There can be any arbitrary things you may want to get from the 
structure of the declaration (e.g. the parameter ranges), but we could provide 
an API to gather any syntactic structure info you may want.

I would encourage you to try 
`CXTranslationUnit_SingleFileParse|CXTranslationUnit_SkipFunctionBodies`, you 
will be pleasantly surprised with how fast this mode is. The `c-index-test` 
option is `-single-file-parse`.


https://reviews.llvm.org/D39050



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


[PATCH] D40968: [OpenMP] Diagnose function name on the link clause

2017-12-07 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/Sema/SemaOpenMP.cpp:12576
 
+if (MT == OMPDeclareTargetDeclAttr::MT_Link && isa(ND)) {
+  Diag(Id.getLoc(), diag::err_omp_function_in_link_clause);

I would like to see this some in `check` functions, like 
`checkDeclIsAllowedInOpenMPTarget` rather than here 


https://reviews.llvm.org/D40968



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


[PATCH] D39050: Add index-while-building support to Clang

2017-12-07 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added inline comments.



Comment at: include/indexstore/IndexStoreCXX.h:84
+
+  std::pair getLineCol() {
+unsigned line, col;

ioeric wrote:
> nathawes wrote:
> > malaperle wrote:
> > > From what I understand, this returns the beginning of the occurrence. It 
> > > would be useful to also have the end of the occurrence. From what I 
> > > tested in Xcode, when you do "Find Selected Symbol in Workspace", it 
> > > highlights the symbol name in yellow in the list of matches, so it mush 
> > > use that LineCol then highlight the matching name. This is works in many 
> > > situations but others occurrences won't have the name of the symbol. For 
> > > example:
> > > "MyClass o1, o2;"
> > > If I use "Find Selected Symbol in Workspace" on MyClass constructor, if 
> > > won't be able to highlight o1 and o2
> > > Do you think it would be possible to add that (EndLineCol)? If not, how 
> > > would one go about extending libindexstore in order to add additional 
> > > information per occurrence? It is not obvious to me so far.
> > > We also need other things, for example in the case of definitions, we 
> > > need the full range of the definition so that users can "peek" at 
> > > definitions in a pop-up. Without storing the end of the definition in the 
> > > index, we would need to reparse the file.
> > > 
> > Our approach to related locations (e.g. name, signature, body, and doc 
> > comment start/end locs) has been to not include them in the index and 
> > derive them from the start location later. There's less data to collect and 
> > write out during the build that way, and deriving the other locations isn't 
> > that costly usually, as in most cases you 1) don't need to type check or 
> > even preprocess to get the related locations, as with finding the end of o1 
> > and o2 in your example, and 2) usually only need to derive locations for a 
> > single or small number of occurrences, like when 'peeking' at a definition. 
> > 
> > Are there cases where you think this approach won't work/perform well 
> > enough for the indexer-backed queries clangd needs to support?
> > 
> I agree that we should try to keep the serialized symbol size minimal, but I 
> think it's worthwhile to also store end locations for occurrences because 1) 
> it's cheap, 2) it's not necessary easy to compute without parsing for 
> occurrences like `a::b::c` or `a::b`, 3) it would be useful for many LSP 
> use cases.
There's a few reason I think it's better to store the end loc.
- When doing "find references", computing the end loc of each occurrence will 
be costly. Imagine having thousands of occurrences and for each of them having 
to run logic to find the end of the occurrence.
- The AST and preprocessor are the best tools I know to figure out the proper 
end loc. Not using them means having to write a mini-preprocessor with some 
knowledge about the language semantics to cover some cases.
```
MyClass |o1, o2;
```
Here, I have to stop at the comma. So it's basically take any alpha-numerical 
character, right?
```
bool operator<(const Foo&, const Foo&)
Ret operator()(Params ...params)
```
No, in those cases, we have to take < and the first (). 
- In the case of body start/end locations, similarly, it can be non-trivial.
```
void foo() {
  if (0) {
  }
}
```
We have to count the balanced { } until we finish the body.

```
#define FUNC_BODY {\
\
}
void foo() FUNC_BODY
```
Oops, where's the body? We need another special logic for this, etc.

I think overall, it puts a lot of burden on the client of libIndexStore, burden 
that would be much more work and more inaccurate than using the 
AST/Preprocessor while indexing.



Comment at: include/indexstore/IndexStoreCXX.h:374
+
+  enum class DependencyKind {
+Unit,

nathawes wrote:
> malaperle wrote:
> > As part of this dependency tracking mechanism, I haven't found that it 
> > could provide information about about the files including a specific 
> > header. So given a header (or source file in odd cases), I do not see a way 
> > to get all the files that would need to be reindexed if that header 
> > changed. Is that something you achieve outside the index? Or perhaps this 
> > is something I missed in the code.
> The unit files store the path of the header/source files they depend on as 
> 'File' dependencies. So any unit file with 'File' dependency on header/source 
> file that was modified may need to be re-indexed.
> 
> To support finding which specific files include or are included by a given 
> header (rather than which units somehow transitively include it) we also 
> store the file-to-file inclusions in the unit file (retrieved via 
> IndexUnitReader's foreachInclude method below).
Thanks! I'll play around with this a bit more with this new information.



Comment at: include/indexstore/IndexStoreCXX.h:377
+Record,
+File,
+  };

nathawes wrote:

[PATCH] D40968: [OpenMP] Diagnose function name on the link clause

2017-12-07 Thread Kelvin Li via Phabricator via cfe-commits
kkwli0 created this revision.

This patch is to add diagnose when a function name is specified on the link 
clause.  According to the OpenMP spec, only the list items that exclude the 
function name are allowed on the link clause.

  void foo() {}
  #pragma omp declare target link(foo)



  d2.c:2:33: error: function name is not allowed in 'link' clause
  #pragma omp declare target link(foo)
  ^
  d2.c:1:6: note: 'foo' defined here
  void foo() {}
   ^
  1 error generated.


https://reviews.llvm.org/D40968

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/declare_target_ast_print.cpp
  test/OpenMP/declare_target_messages.cpp


Index: test/OpenMP/declare_target_messages.cpp
===
--- test/OpenMP/declare_target_messages.cpp
+++ test/OpenMP/declare_target_messages.cpp
@@ -19,6 +19,10 @@
 
 void c(); // expected-warning {{declaration is not declared in any declare 
target region}}
 
+void func() {} // expected-note {{'func' defined here}}
+
+#pragma omp declare target link(func) // expected-error {{function name is not 
allowed in 'link' clause}}
+
 extern int b;
 
 struct NonT {
Index: test/OpenMP/declare_target_ast_print.cpp
===
--- test/OpenMP/declare_target_ast_print.cpp
+++ test/OpenMP/declare_target_ast_print.cpp
@@ -108,9 +108,7 @@
 // CHECK: #pragma omp end declare target
 
 int c1, c2, c3;
-void f3() {
-}
-#pragma omp declare target link(c1) link(c2), link(c3, f3)
+#pragma omp declare target link(c1) link(c2), link(c3)
 // CHECK: #pragma omp declare target link
 // CHECK: int c1;
 // CHECK: #pragma omp end declare target
@@ -120,9 +118,6 @@
 // CHECK: #pragma omp declare target link
 // CHECK: int c3;
 // CHECK: #pragma omp end declare target
-// CHECK: #pragma omp declare target link
-// CHECK: void f3()
-// CHECK: #pragma omp end declare target
 
 struct SSSt {
 #pragma omp declare target
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -12573,6 +12573,11 @@
 if (!SameDirectiveDecls.insert(cast(ND->getCanonicalDecl(
   Diag(Id.getLoc(), diag::err_omp_declare_target_multiple) << Id.getName();
 
+if (MT == OMPDeclareTargetDeclAttr::MT_Link && isa(ND)) {
+  Diag(Id.getLoc(), diag::err_omp_function_in_link_clause);
+  Diag(ND->getLocation(), diag::note_defined_here) << ND;
+}
+
 if (!ND->hasAttr()) {
   Attr *A = OMPDeclareTargetDeclAttr::CreateImplicit(Context, MT);
   ND->addAttr(A);
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -8709,6 +8709,8 @@
 def warn_omp_not_in_target_context : Warning<
   "declaration is not declared in any declare target region">,
   InGroup;
+def err_omp_function_in_link_clause : Error<
+  "function name is not allowed in 'link' clause">;
 def err_omp_aligned_expected_array_or_ptr : Error<
   "argument of aligned clause should be array"
   "%select{ or pointer|, pointer, reference to array or reference to pointer}1"


Index: test/OpenMP/declare_target_messages.cpp
===
--- test/OpenMP/declare_target_messages.cpp
+++ test/OpenMP/declare_target_messages.cpp
@@ -19,6 +19,10 @@
 
 void c(); // expected-warning {{declaration is not declared in any declare target region}}
 
+void func() {} // expected-note {{'func' defined here}}
+
+#pragma omp declare target link(func) // expected-error {{function name is not allowed in 'link' clause}}
+
 extern int b;
 
 struct NonT {
Index: test/OpenMP/declare_target_ast_print.cpp
===
--- test/OpenMP/declare_target_ast_print.cpp
+++ test/OpenMP/declare_target_ast_print.cpp
@@ -108,9 +108,7 @@
 // CHECK: #pragma omp end declare target
 
 int c1, c2, c3;
-void f3() {
-}
-#pragma omp declare target link(c1) link(c2), link(c3, f3)
+#pragma omp declare target link(c1) link(c2), link(c3)
 // CHECK: #pragma omp declare target link
 // CHECK: int c1;
 // CHECK: #pragma omp end declare target
@@ -120,9 +118,6 @@
 // CHECK: #pragma omp declare target link
 // CHECK: int c3;
 // CHECK: #pragma omp end declare target
-// CHECK: #pragma omp declare target link
-// CHECK: void f3()
-// CHECK: #pragma omp end declare target
 
 struct SSSt {
 #pragma omp declare target
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -12573,6 +12573,11 @@
 if (!SameDirectiveDecls.insert(cast(ND->getCanonicalDecl(
   Diag(Id.getLoc(), diag::err_omp_declare_target_multiple) << Id.getName();
 
+if (MT == 

  1   2   >