[PATCH] D30210: [include-fixer] Add usage count to find-all-symbols.

2017-02-28 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 89982.
sammccall marked an inline comment as done.
sammccall added a comment.

Review comments


https://reviews.llvm.org/D30210

Files:
  include-fixer/InMemorySymbolIndex.cpp
  include-fixer/InMemorySymbolIndex.h
  include-fixer/IncludeFixer.cpp
  include-fixer/SymbolIndex.h
  include-fixer/SymbolIndexManager.cpp
  include-fixer/YamlSymbolIndex.cpp
  include-fixer/YamlSymbolIndex.h
  include-fixer/find-all-symbols/FindAllMacros.cpp
  include-fixer/find-all-symbols/FindAllMacros.h
  include-fixer/find-all-symbols/FindAllSymbols.cpp
  include-fixer/find-all-symbols/FindAllSymbols.h
  include-fixer/find-all-symbols/FindAllSymbolsAction.cpp
  include-fixer/find-all-symbols/SymbolInfo.cpp
  include-fixer/find-all-symbols/SymbolInfo.h
  include-fixer/find-all-symbols/SymbolReporter.h
  include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
  include-fixer/tool/ClangIncludeFixer.cpp
  test/include-fixer/Inputs/fake_yaml_db.yaml
  test/include-fixer/Inputs/merge/a.yaml
  test/include-fixer/Inputs/merge/b.yaml
  test/include-fixer/merge.test
  unittests/include-fixer/IncludeFixerTest.cpp
  unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -19,6 +19,7 @@
 #include "clang/Frontend/PCHContainerOperations.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "gtest/gtest.h"
@@ -31,34 +32,39 @@
 
 static const char HeaderName[] = "symbols.h";
 
-class TestSymbolReporter : public clang::find_all_symbols::SymbolReporter {
+class TestSymbolReporter : public SymbolReporter {
 public:
   ~TestSymbolReporter() override {}
 
-  void reportSymbol(llvm::StringRef FileName,
-const SymbolInfo &Symbol) override {
-Symbols.push_back(Symbol);
+  void reportSymbols(llvm::StringRef FileName,
+ const SymbolInfo::SignalMap &NewSymbols) override {
+for (const auto &Entry : NewSymbols)
+  Symbols[Entry.first] += Entry.second;
   }
 
   bool hasSymbol(const SymbolInfo &Symbol) const {
-for (const auto &S : Symbols) {
-  if (S == Symbol)
-return true;
-}
-return false;
+auto it = Symbols.find(Symbol);
+return it != Symbols.end() && it->second.Seen > 0;
+  }
+
+  bool hasUse(const SymbolInfo &Symbol) const {
+auto it = Symbols.find(Symbol);
+return it != Symbols.end() && it->second.Used > 0;
   }
 
 private:
-  std::vector Symbols;
+  SymbolInfo::SignalMap Symbols;
 };
 
 class FindAllSymbolsTest : public ::testing::Test {
 public:
   bool hasSymbol(const SymbolInfo &Symbol) {
 return Reporter.hasSymbol(Symbol);
   }
 
-  bool runFindAllSymbols(StringRef Code) {
+  bool hasUse(const SymbolInfo &Symbol) { return Reporter.hasUse(Symbol); }
+
+  bool runFindAllSymbols(StringRef HeaderCode, StringRef MainCode) {
 llvm::IntrusiveRefCntPtr InMemoryFileSystem(
 new vfs::InMemoryFileSystem);
 llvm::IntrusiveRefCntPtr Files(
@@ -88,7 +94,7 @@
 InMemoryFileSystem->addFile(InternalHeader, 0,
 llvm::MemoryBuffer::getMemBuffer(InternalCode));
 
-std::unique_ptr Factory(
+std::unique_ptr Factory(
 new FindAllSymbolsActionFactory(&Reporter, &RegexMap));
 
 tooling::ToolInvocation Invocation(
@@ -98,7 +104,7 @@
 std::make_shared());
 
 InMemoryFileSystem->addFile(HeaderName, 0,
-llvm::MemoryBuffer::getMemBuffer(Code));
+llvm::MemoryBuffer::getMemBuffer(HeaderCode));
 
 std::string Content = "#include\"" + std::string(HeaderName) +
   "\"\n"
@@ -118,6 +124,7 @@
 SymbolInfo DirtySymbol("ExtraInternal", SymbolInfo::SymbolKind::Class,
CleanHeader, 2, {});
 #endif // _MSC_VER && __MINGW32__
+Content += "\n" + MainCode.str();
 InMemoryFileSystem->addFile(FileName, 0,
 llvm::MemoryBuffer::getMemBuffer(Content));
 Invocation.run();
@@ -135,49 +142,64 @@
 };
 
 TEST_F(FindAllSymbolsTest, VariableSymbols) {
-  static const char Code[] = R"(
+  static const char Header[] = R"(
   extern int xargc;
   namespace na {
   static bool  = false;
   namespace nb { const long long *; }
   })";
-  runFindAllSymbols(Code);
+  static const char Main[] = R"(
+  auto y = &na::nb::;
+  int main() { if (na::) return xargc; }
+  )";
+  runFindAllSymbols(Header, Main);
 
   SymbolInfo Symbol =
   SymbolInfo("xargc", SymbolInfo::SymbolKind::Variable, HeaderName, 2, {});
   EXPECT_TRUE(hasSymbol(Symbol));
+  EXPECT_TRUE(ha

[clang-tools-extra] r296446 - [include-fixer] Add usage count to find-all-symbols.

2017-02-28 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Tue Feb 28 02:13:15 2017
New Revision: 296446

URL: http://llvm.org/viewvc/llvm-project?rev=296446&view=rev
Log:
[include-fixer] Add usage count to find-all-symbols.

Summary:
Add usage count to find-all-symbols.

FindAllSymbols now finds (most!) main-file usages of the discovered symbols.
The per-TU map output has NumUses=0 or 1 (only one use per file is counted).
The reducer aggregates these to find the number of files that use a symbol.

The NumOccurrences is now set to 1 in the mapper rather than being inferred by
the reducer, for consistency.

The idea here is to use NumUses for ranking: intuitively number of files that
use a symbol is more meaningful than number of files that include the header.

Reviewers: hokein, bkramer

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.cpp
clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.h
clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
clang-tools-extra/trunk/include-fixer/SymbolIndex.h
clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
clang-tools-extra/trunk/include-fixer/YamlSymbolIndex.cpp
clang-tools-extra/trunk/include-fixer/YamlSymbolIndex.h
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllMacros.cpp
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllMacros.h
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.h

clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.cpp
clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp
clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolReporter.h

clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml
clang-tools-extra/trunk/test/include-fixer/Inputs/merge/a.yaml
clang-tools-extra/trunk/test/include-fixer/Inputs/merge/b.yaml
clang-tools-extra/trunk/test/include-fixer/merge.test
clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp

clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Modified: clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.cpp?rev=296446&r1=296445&r2=296446&view=diff
==
--- clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.cpp Tue Feb 28 
02:13:15 2017
@@ -9,18 +9,18 @@
 
 #include "InMemorySymbolIndex.h"
 
-using clang::find_all_symbols::SymbolInfo;
+using clang::find_all_symbols::SymbolAndSignals;
 
 namespace clang {
 namespace include_fixer {
 
 InMemorySymbolIndex::InMemorySymbolIndex(
-const std::vector &Symbols) {
+const std::vector &Symbols) {
   for (const auto &Symbol : Symbols)
-LookupTable[Symbol.getName()].push_back(Symbol);
+LookupTable[Symbol.Symbol.getName()].push_back(Symbol);
 }
 
-std::vector
+std::vector
 InMemorySymbolIndex::search(llvm::StringRef Identifier) {
   auto I = LookupTable.find(Identifier);
   if (I != LookupTable.end())

Modified: clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.h?rev=296446&r1=296445&r2=296446&view=diff
==
--- clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.h (original)
+++ clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.h Tue Feb 28 
02:13:15 2017
@@ -21,13 +21,14 @@ namespace include_fixer {
 /// Xref database with fixed content.
 class InMemorySymbolIndex : public SymbolIndex {
 public:
-  InMemorySymbolIndex(const std::vector 
&Symbols);
+  InMemorySymbolIndex(
+  const std::vector &Symbols);
 
-  std::vector
+  std::vector
   search(llvm::StringRef Identifier) override;
 
 private:
-  std::map>
+  std::map>
   LookupTable;
 };
 

Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp?rev=296446&r1=296445&r2=296446&view=diff
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp Tue Feb 28 02:13:15 
2017
@@ -334,8 +334,7 @@ IncludeFixerContext IncludeFixerSemaSour
 SourceManager, HeaderSearch);
 SymbolCandida

[PATCH] D30210: [include-fixer] Add usage count to find-all-symbols.

2017-02-28 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296446: [include-fixer] Add usage count to find-all-symbols. 
(authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D30210?vs=89982&id=89983#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30210

Files:
  clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.cpp
  clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.h
  clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
  clang-tools-extra/trunk/include-fixer/SymbolIndex.h
  clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
  clang-tools-extra/trunk/include-fixer/YamlSymbolIndex.cpp
  clang-tools-extra/trunk/include-fixer/YamlSymbolIndex.h
  clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllMacros.cpp
  clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllMacros.h
  clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
  clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.h
  
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.cpp
  clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp
  clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
  clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolReporter.h
  
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
  clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
  clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml
  clang-tools-extra/trunk/test/include-fixer/Inputs/merge/a.yaml
  clang-tools-extra/trunk/test/include-fixer/Inputs/merge/b.yaml
  clang-tools-extra/trunk/test/include-fixer/merge.test
  clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
  
clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: clang-tools-extra/trunk/test/include-fixer/merge.test
===
--- clang-tools-extra/trunk/test/include-fixer/merge.test
+++ clang-tools-extra/trunk/test/include-fixer/merge.test
@@ -9,7 +9,8 @@
 FilePath:../include/bar.h
 LineNumber:  1
 Type:Class
-NumOccurrences:  1
+Seen:1
+Used:1
 ...
 ---
 Name:bar
@@ -19,7 +20,8 @@
 FilePath:../include/barbar.h
 LineNumber:  1
 Type:Class
-NumOccurrences:  1
+Seen:1
+Used:0
 ...
 ---
 Name:foo
@@ -29,5 +31,6 @@
 FilePath:foo.h
 LineNumber:  1
 Type:Class
-NumOccurrences:  2
+Seen:2
+Used:2
 ...
Index: clang-tools-extra/trunk/test/include-fixer/Inputs/merge/b.yaml
===
--- clang-tools-extra/trunk/test/include-fixer/Inputs/merge/b.yaml
+++ clang-tools-extra/trunk/test/include-fixer/Inputs/merge/b.yaml
@@ -6,7 +6,8 @@
 FilePath:foo.h
 LineNumber:  1
 Type:Class
-NumOccurrences:  1
+Seen:1
+Used:2
 ...
 ---
 Name:   bar
@@ -16,5 +17,6 @@
 FilePath:../include/barbar.h
 LineNumber:  1
 Type:Class
-NumOccurrences:  1
+Seen:1
+Used:0
 ...
Index: clang-tools-extra/trunk/test/include-fixer/Inputs/merge/a.yaml
===
--- clang-tools-extra/trunk/test/include-fixer/Inputs/merge/a.yaml
+++ clang-tools-extra/trunk/test/include-fixer/Inputs/merge/a.yaml
@@ -6,7 +6,8 @@
 FilePath:foo.h
 LineNumber:  1
 Type:Class
-NumOccurrences:  1
+Seen:1
+Used:1
 ...
 ---
 Name:   bar
@@ -16,5 +17,6 @@
 FilePath:../include/bar.h
 LineNumber:  1
 Type:Class
-NumOccurrences:  1
+Seen:1
+Used:2
 ...
Index: clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml
===
--- clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml
+++ clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml
@@ -8,7 +8,8 @@
 FilePath:foo.h
 LineNumber:  1
 Type:Class
-NumOccurrences:  1
+Seen:1
+Used:0
 ---
 Name:   bar
 Contexts:
@@ -19,7 +20,8 @@
 FilePath:../include/bar.h
 LineNumber:  1
 Type:Class
-NumOccurrences:  1
+Seen:1
+Used:0
 ---
 Name:   bar
 Contexts:
@@ -30,7 +32,8 @@
 FilePath:../include/bar.h
 LineNumber:  2
 Type:Class
-NumOccurrences:  3
+Seen:3
+Used:0
 ---
 Name:   bar
 Contexts:
@@ -41,20 +44,23 @@
 FilePath:../include/zbar.h
 LineNumber:  1
 Type:Class
-NumOccurrences:  3
+Seen:3
+Used:0
 ---
 Name:   b
 Contexts:
 FilePath:var.h
 LineNumber:  

r296453 - [clang-format] Fix test failure caused by "rm" on some buildbots.

2017-02-28 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue Feb 28 03:03:07 2017
New Revision: 296453

URL: http://llvm.org/viewvc/llvm-project?rev=296453&view=rev
Log:
[clang-format] Fix test failure caused by "rm" on some buildbots.

The begining command "rm" will return 1 when there is not such file to
delete.

This patch is to remove it, as it's not needed for the test.

Modified:
cfe/trunk/test/Format/inplace.cpp

Modified: cfe/trunk/test/Format/inplace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Format/inplace.cpp?rev=296453&r1=296452&r2=296453&view=diff
==
--- cfe/trunk/test/Format/inplace.cpp (original)
+++ cfe/trunk/test/Format/inplace.cpp Tue Feb 28 03:03:07 2017
@@ -1,6 +1,5 @@
 // Regression test to check that clang-format does not leave behind temporary
 // files on Windows when doing in-place formatting.
-// RUN: rm %T/inplace*
 // RUN: cp %s %T/inplace.cpp
 // RUN: clang-format -style=LLVM -i %T/inplace.cpp
 // RUN: ls %T > %T/files.txt


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


r296454 - [ARM] Don't pass -arm-execute-only to cc1as

2017-02-28 Thread Christof Douma via cfe-commits
Author: christof
Date: Tue Feb 28 03:09:53 2017
New Revision: 296454

URL: http://llvm.org/viewvc/llvm-project?rev=296454&view=rev
Log:
[ARM] Don't pass -arm-execute-only to cc1as

The option -mexecute-only is translated into the backend option
-arm-execute-only. But this option only makes sense for the compiler and
the assembler does not recognize it. This patch stops clang from passing
this option to the assembler.

Change-Id: I4f4cb1162c13cfd50a0a36702a4ecab1bc0324ba
Review: https://reviews.llvm.org/D30414

Modified:
cfe/trunk/lib/Driver/Arch/ARM.cpp
cfe/trunk/test/Driver/arm-execute-only.c

Modified: cfe/trunk/lib/Driver/Arch/ARM.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Arch/ARM.cpp?rev=296454&r1=296453&r2=296454&view=diff
==
--- cfe/trunk/lib/Driver/Arch/ARM.cpp (original)
+++ cfe/trunk/lib/Driver/Arch/ARM.cpp Tue Feb 28 03:09:53 2017
@@ -374,25 +374,28 @@ void arm::getARMTargetFeatures(const Too
   }
 
   // Generate execute-only output (no data access to code sections).
-  // Supported only on ARMv6T2 and ARMv7 and above.
-  // Cannot be combined with -mno-movt or -mlong-calls
-  if (Arg *A = Args.getLastArg(options::OPT_mexecute_only, 
options::OPT_mno_execute_only)) {
-if (A->getOption().matches(options::OPT_mexecute_only)) {
-  if (getARMSubArchVersionNumber(Triple) < 7 &&
-  llvm::ARM::parseArch(Triple.getArchName()) != llvm::ARM::AK_ARMV6T2)
-D.Diag(diag::err_target_unsupported_execute_only) << 
Triple.getArchName();
-  else if (Arg *B = Args.getLastArg(options::OPT_mno_movt))
-D.Diag(diag::err_opt_not_valid_with_opt) << A->getAsString(Args) << 
B->getAsString(Args);
-  // Long calls create constant pool entries and have not yet been fixed up
-  // to play nicely with execute-only. Hence, they cannot be used in
-  // execute-only code for now
-  else if (Arg *B = Args.getLastArg(options::OPT_mlong_calls, 
options::OPT_mno_long_calls)) {
-if (B->getOption().matches(options::OPT_mlong_calls))
+  // This only makes sense for the compiler, not for the assembler.
+  if (!ForAS) {
+// Supported only on ARMv6T2 and ARMv7 and above.
+// Cannot be combined with -mno-movt or -mlong-calls
+if (Arg *A = Args.getLastArg(options::OPT_mexecute_only, 
options::OPT_mno_execute_only)) {
+  if (A->getOption().matches(options::OPT_mexecute_only)) {
+if (getARMSubArchVersionNumber(Triple) < 7 &&
+llvm::ARM::parseArch(Triple.getArchName()) != 
llvm::ARM::AK_ARMV6T2)
+  D.Diag(diag::err_target_unsupported_execute_only) << 
Triple.getArchName();
+else if (Arg *B = Args.getLastArg(options::OPT_mno_movt))
   D.Diag(diag::err_opt_not_valid_with_opt) << A->getAsString(Args) << 
B->getAsString(Args);
-  }
+// Long calls create constant pool entries and have not yet been fixed 
up
+// to play nicely with execute-only. Hence, they cannot be used in
+// execute-only code for now
+else if (Arg *B = Args.getLastArg(options::OPT_mlong_calls, 
options::OPT_mno_long_calls)) {
+  if (B->getOption().matches(options::OPT_mlong_calls))
+D.Diag(diag::err_opt_not_valid_with_opt) << A->getAsString(Args) 
<< B->getAsString(Args);
+}
 
-  CmdArgs.push_back("-backend-option");
-  CmdArgs.push_back("-arm-execute-only");
+CmdArgs.push_back("-backend-option");
+CmdArgs.push_back("-arm-execute-only");
+  }
 }
   }
 

Modified: cfe/trunk/test/Driver/arm-execute-only.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arm-execute-only.c?rev=296454&r1=296453&r2=296454&view=diff
==
--- cfe/trunk/test/Driver/arm-execute-only.c (original)
+++ cfe/trunk/test/Driver/arm-execute-only.c Tue Feb 28 03:09:53 2017
@@ -90,6 +90,9 @@
 // RUN: not %clang -target armv8m.main-eabi -mpure-code -mlong-calls %s 2>&1 \
 // RUN:| FileCheck %s -check-prefix CHECK-EXECUTE-ONLY-LONG-CALLS
 
+// RUN: %clang -target armv7m-eabi -x assembler -mexecute-only %s -c -### 2>&1 
\
+// RUN:| FileCheck %s -check-prefix CHECK-NO-EXECUTE-ONLY -check-prefix 
CHECK-NO-EXECUTE-ONLY-ASM
+
 //
 // CHECK-NO-EXECUTE-ONLY-NOT: "-backend-option" "-arm-execute-only"
 // CHECK-EXECUTE-ONLY: "-backend-option" "-arm-execute-only"
@@ -97,3 +100,4 @@
 // CHECK-EXECUTE-ONLY-NOT-SUPPORTED: error: execute only is not supported for 
the thumbv6m sub-architecture
 // CHECK-EXECUTE-ONLY-NO-MOVT: error: option '-mexecute-only' cannot be 
specified with '-mno-movt'
 // CHECK-EXECUTE-ONLY-LONG-CALLS: error: option '-mexecute-only' cannot be 
specified with '-mlong-calls'
+// CHECK-NO-EXECUTE-ONLY-ASM: warning: argument unused during compilation: 
'-mexecute-only'


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

[PATCH] D30327: [Sema] Improve side effect checking for unused-lambda-capture warning

2017-02-28 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

I found this FIXME comment in `Expr::HasSideEffects()`:

  case LambdaExprClass: {
const LambdaExpr *LE = cast(this);
for (LambdaExpr::capture_iterator I = LE->capture_begin(),
  E = LE->capture_end(); I != E; ++I)
  if (I->getCaptureKind() == LCK_ByCopy)
// FIXME: Only has a side-effect if the variable is volatile or if
// the copy would invoke a non-trivial copy constructor.
return true;
return false;
  }

It seems a shame not to fix this now, but I don't think I can call Sema code 
from AST code, and my `CaptureHasSideEffects()` depends on 
`Sema::getCurrentThisType()`.

Any ideas?


https://reviews.llvm.org/D30327



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


Re: [clang-tools-extra] r296110 - [change-namepsace] make it possible to whitelist symbols so they don't get updated.

2017-02-28 Thread Eric Liu via cfe-commits
Sorry for losing track of this.

I thought I fixed it with r296113. Not sure why windows builds are still
failing. I'll look into this.

Thanks,
Eric

On Tue, Feb 28, 2017 at 2:19 AM Galina Kistanova 
wrote:

> Hello Eric,
>
> This commit broke test on one of our builders:
>
> Clang Tools :: change-namespace/white-list.cpp
>
>
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/6153/steps/test/logs/stdio
>
> Please have a look.
>
> Thanks
>
>
> Galina
>
>
> On Fri, Feb 24, 2017 at 3:54 AM, Eric Liu via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: ioeric
> Date: Fri Feb 24 05:54:45 2017
> New Revision: 296110
>
> URL: http://llvm.org/viewvc/llvm-project?rev=296110&view=rev
> Log:
> [change-namepsace] make it possible to whitelist symbols so they don't get
> updated.
>
> Reviewers: hokein
>
> Reviewed By: hokein
>
> Subscribers: cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D30328
>
> Added:
> clang-tools-extra/trunk/test/change-namespace/Inputs/
> clang-tools-extra/trunk/test/change-namespace/Inputs/fake-std.h
> clang-tools-extra/trunk/test/change-namespace/white-list.cpp
> Modified:
> clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
> clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
> clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp
>
> clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
>
> Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp?rev=296110&r1=296109&r2=296110&view=diff
>
> ==
> --- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp (original)
> +++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp Fri Feb
> 24 05:54:45 2017
> @@ -290,6 +290,7 @@ AST_MATCHER(EnumDecl, isScoped) {
>
>  ChangeNamespaceTool::ChangeNamespaceTool(
>  llvm::StringRef OldNs, llvm::StringRef NewNs, llvm::StringRef
> FilePattern,
> +llvm::ArrayRef WhiteListedSymbolPatterns,
>  std::map *FileToReplacements,
>  llvm::StringRef FallbackStyle)
>  : FallbackStyle(FallbackStyle),
> FileToReplacements(*FileToReplacements),
> @@ -308,6 +309,9 @@ ChangeNamespaceTool::ChangeNamespaceTool
>}
>DiffOldNamespace = joinNamespaces(OldNsSplitted);
>DiffNewNamespace = joinNamespaces(NewNsSplitted);
> +
> +  for (const auto &Pattern : WhiteListedSymbolPatterns)
> +WhiteListedSymbolRegexes.emplace_back(Pattern);
>  }
>
>  void ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder
> *Finder) {
> @@ -736,6 +740,9 @@ void ChangeNamespaceTool::replaceQualifi
>Result.SourceManager->getSpellingLoc(End)),
>*Result.SourceManager, Result.Context->getLangOpts());
>std::string FromDeclName = FromDecl->getQualifiedNameAsString();
> +  for (llvm::Regex &RE : WhiteListedSymbolRegexes)
> +if (RE.match(FromDeclName))
> +  return;
>std::string ReplaceName =
>getShortestQualifiedNameInNamespace(FromDeclName, NewNs);
>// Checks if there is any using namespace declarations that can shorten
> the
>
> Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/ChangeNamespace.h?rev=296110&r1=296109&r2=296110&view=diff
>
> ==
> --- clang-tools-extra/trunk/change-namespace/ChangeNamespace.h (original)
> +++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.h Fri Feb 24
> 05:54:45 2017
> @@ -50,6 +50,7 @@ public:
>// files matching `FilePattern`.
>ChangeNamespaceTool(
>llvm::StringRef OldNs, llvm::StringRef NewNs, llvm::StringRef
> FilePattern,
> +  llvm::ArrayRef WhiteListedSymbolPatterns,
>std::map *FileToReplacements,
>llvm::StringRef FallbackStyle = "LLVM");
>
> @@ -164,6 +165,9 @@ private:
>// CallExpr and one as DeclRefExpr), we record all DeclRefExpr's that
> have
>// been processed so that we don't handle them twice.
>llvm::SmallPtrSet ProcessedFuncRefs;
> +  // Patterns of symbol names whose references are not expected to be
> updated
> +  // when changing namespaces around them.
> +  std::vector WhiteListedSymbolRegexes;
>  };
>
>  } // namespace change_namespace
>
> Modified:
> clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp?rev=296110&r1=296109&r2=296110&view=diff
>
> ==
> --- clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp
> (original)
> +++ clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp
> Fri

[PATCH] D27810: FileManager: mark virtual file entries as valid entries

2017-02-28 Thread Kevin Funk via Phabricator via cfe-commits
kfunk added a comment.

@erikjv Ready for review? Does this reliably fix 
https://bugreports.qt.io/browse/QTCREATORBUG-15449?


https://reviews.llvm.org/D27810



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


[PATCH] D30327: [Sema] Improve side effect checking for unused-lambda-capture warning

2017-02-28 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons updated this revision to Diff 89988.
malcolm.parsons marked an inline comment as done.
malcolm.parsons added a comment.

Handle captures of volatile variables.


https://reviews.llvm.org/D30327

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaLambda.cpp
  test/SemaCXX/warn-unused-lambda-capture.cpp

Index: test/SemaCXX/warn-unused-lambda-capture.cpp
===
--- test/SemaCXX/warn-unused-lambda-capture.cpp
+++ test/SemaCXX/warn-unused-lambda-capture.cpp
@@ -1,10 +1,16 @@
-// RUN: %clang_cc1 -fsyntax-only -Wunused-lambda-capture -Wused-but-marked-unused -Wno-uninitialized -verify -std=c++14 %s
+// RUN: %clang_cc1 -fsyntax-only -Wunused-lambda-capture -Wused-but-marked-unused -Wno-uninitialized -verify -std=c++1z %s
 
 class NonTrivialConstructor {
 public:
   NonTrivialConstructor() {}
 };
 
+class NonTrivialCopyConstructor {
+public:
+  NonTrivialCopyConstructor() = default;
+  NonTrivialCopyConstructor(const NonTrivialCopyConstructor &) {}
+};
+
 class NonTrivialDestructor {
 public:
   ~NonTrivialDestructor() {}
@@ -57,14 +63,67 @@
 auto explicit_by_value_used = [i] { return i + 1; };
 auto explicit_by_value_unused = [i] {}; // expected-warning{{lambda capture 'i' is not used}}
   };
+
+  Trivial trivial;
+  auto explicit_by_value_trivial = [trivial] {}; // expected-warning{{lambda capture 'trivial' is not used}}
+
+  NonTrivialConstructor cons;
+  auto explicit_by_value_non_trivial_constructor = [cons] {}; // expected-warning{{lambda capture 'cons' is not used}}
+
+  NonTrivialCopyConstructor copy_cons;
+  auto explicit_by_value_non_trivial_copy_constructor = [copy_cons] {};
+
+  NonTrivialDestructor dest;
+  auto explicit_by_value_non_trivial_destructor = [dest] {};
+
+  volatile int v;
+  auto explicit_by_value_volatile = [v] {};
 }
 
-class Foo
-{
+class TrivialThis : Trivial {
   void test() {
 auto explicit_this_used = [this] { return i; };
 auto explicit_this_used_void = [this] { (void)this; };
 auto explicit_this_unused = [this] {}; // expected-warning{{lambda capture 'this' is not used}}
+auto explicit_star_this_used = [*this] { return i; };
+auto explicit_star_this_used_void = [*this] { (void)this; };
+auto explicit_star_this_unused = [*this] {}; // expected-warning{{lambda capture 'this' is not used}}
+  }
+  int i;
+};
+
+class NonTrivialConstructorThis : NonTrivialConstructor {
+  void test() {
+auto explicit_this_used = [this] { return i; };
+auto explicit_this_used_void = [this] { (void)this; };
+auto explicit_this_unused = [this] {}; // expected-warning{{lambda capture 'this' is not used}}
+auto explicit_star_this_used = [*this] { return i; };
+auto explicit_star_this_used_void = [*this] { (void)this; };
+auto explicit_star_this_unused = [*this] {}; // expected-warning{{lambda capture 'this' is not used}}
+  }
+  int i;
+};
+
+class NonTrivialCopyConstructorThis : NonTrivialCopyConstructor {
+  void test() {
+auto explicit_this_used = [this] { return i; };
+auto explicit_this_used_void = [this] { (void)this; };
+auto explicit_this_unused = [this] {}; // expected-warning{{lambda capture 'this' is not used}}
+auto explicit_star_this_used = [*this] { return i; };
+auto explicit_star_this_used_void = [*this] { (void)this; };
+auto explicit_star_this_unused = [*this] {};
+  }
+  int i;
+};
+
+class NonTrivialDestructorThis : NonTrivialDestructor {
+  void test() {
+auto explicit_this_used = [this] { return i; };
+auto explicit_this_used_void = [this] { (void)this; };
+auto explicit_this_unused = [this] {}; // expected-warning{{lambda capture 'this' is not used}}
+auto explicit_star_this_used = [*this] { return i; };
+auto explicit_star_this_used_void = [*this] { (void)this; };
+auto explicit_star_this_unused = [*this] {};
   }
   int i;
 };
@@ -107,6 +166,21 @@
 auto explicit_by_value_used = [i] { return i + 1; };
 auto explicit_by_value_unused = [i] {}; // expected-warning{{lambda capture 'i' is not used}}
   };
+
+  Trivial trivial;
+  auto explicit_by_value_trivial = [trivial] {}; // expected-warning{{lambda capture 'trivial' is not used}}
+
+  NonTrivialConstructor cons;
+  auto explicit_by_value_non_trivial_constructor = [cons] {}; // expected-warning{{lambda capture 'cons' is not used}}
+
+  NonTrivialCopyConstructor copy_cons;
+  auto explicit_by_value_non_trivial_copy_constructor = [copy_cons] {};
+
+  NonTrivialDestructor dest;
+  auto explicit_by_value_non_trivial_destructor = [dest] {};
+
+  volatile int v;
+  auto explicit_by_value_volatile = [v] {};
 }
 
 void test_use_template() {
Index: lib/Sema/SemaLambda.cpp
===
--- lib/Sema/SemaLambda.cpp
+++ lib/Sema/SemaLambda.cpp
@@ -1438,13 +1438,35 @@
   llvm_unreachable("Unknown implicit capture style");
 }
 
-void Sema::DiagnoseUnusedLambdaCapture(const LambdaScopeInfo::Capture &From) {
+

[PATCH] D30166: Honor __unaligned in codegen for declarations and expressions

2017-02-28 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 updated this revision to Diff 89989.
rogfer01 added a comment.

Avoid altering results of TypeInfo due to the __unaligned qualifier. Instead 
override the natural alignment to 1 if the type is __unaligned-qualified.


https://reviews.llvm.org/D30166

Files:
  lib/AST/ASTContext.cpp
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CodeGenFunction.cpp
  test/CodeGen/unaligned-decl.c
  test/CodeGen/unaligned-expr.c
  test/CodeGen/unaligned-field.c
  test/CodeGenCXX/unaligned.cpp

Index: test/CodeGenCXX/unaligned.cpp
===
--- /dev/null
+++ test/CodeGenCXX/unaligned.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -x c++ -std=c++11 -triple x86_64-unknown-linux-gnu -fms-extensions -emit-llvm < %s | FileCheck %s
+
+int foo() {
+  // CHECK: ret i32 1
+  return alignof(__unaligned int);
+}
Index: test/CodeGen/unaligned-field.c
===
--- /dev/null
+++ test/CodeGen/unaligned-field.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fms-extensions -emit-llvm < %s | FileCheck %s
+// Test that __unaligned does not impact the layout of the fields.
+
+struct A
+{
+char a;
+__unaligned int b;
+} a;
+// CHECK: %struct.A = type { i8, i32 }
+
+struct A2
+{
+int b;
+char a;
+__unaligned int c;
+} a2;
+// CHECK: %struct.A2 = type { i32, i8, i32 }
Index: test/CodeGen/unaligned-expr.c
===
--- /dev/null
+++ test/CodeGen/unaligned-expr.c
@@ -0,0 +1,217 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fms-extensions -emit-llvm < %s | FileCheck %s
+
+// -
+// Scalar integer
+// -
+__unaligned int x;
+void test1(void) {
+  // CHECK: {{%.*}} = load i32, i32* @x, align 1
+  // CHECK: store i32 {{%.*}}, i32* @x, align 1
+  x++;
+}
+
+void test2(void) {
+  // CHECK: %y = alloca i32, align 1
+  // CHECK: {{%.*}} = load i32, i32* %y, align 1
+  // CHECK: store i32 {{%.*}}, i32* %y, align 1
+  __unaligned int y;
+  y++;
+}
+
+void test2_1(void) {
+  // CHECK: %y = alloca i32, align 1
+  // CHECK: store i32 1, i32* %y, align 1
+  __unaligned int y = 1;
+}
+
+// -
+// Global pointer
+// -
+int *__unaligned p1;
+void test3(void) {
+
+  // CHECK: {{%.*}} = load i32*, i32** @p1, align 1
+  // CHECK: {{%.*}} = load i32, i32* {{%.*}}, align 4
+  // CHECK: store i32 {{%.*}}, i32* {{%.*}}, align 4
+  (*p1)++;
+}
+
+int __unaligned *p2;
+void test4(void) {
+  // CHECK: {{%.*}} = load i32*, i32** @p2, align 8
+  // CHECK: {{%.*}} = load i32, i32* {{%.*}}, align 1
+  // CHECK: store i32 {{%.*}}, i32* {{%.*}}, align 1
+  (*p2)++;
+}
+
+int __unaligned *__unaligned p3;
+void test5(void) {
+  // CHECK: {{%.*}} = load i32*, i32** @p3, align 1
+  // CHECK: {{%.*}} = load i32, i32* {{%.*}}, align 1
+  // CHECK: store i32 {{%.*}}, i32* {{%.*}}, align 1
+  (*p3)++;
+}
+
+// -
+// Local pointer
+// -
+void test6(void) {
+  // CHECK: %lp1 = alloca i32*, align 1
+  // CHECK: {{%.*}} = load i32*, i32** %lp1, align 1
+  // CHECK: {{%.*}} = load i32, i32* {{%.*}}, align 4
+  // CHECK: store i32 {{%.*}}, i32* {{%.*}}, align 4
+  int *__unaligned lp1;
+  (*lp1)++;
+}
+
+void test7(void) {
+  // CHECK: %lp2 = alloca i32*, align 8
+  // CHECK: {{%.*}} = load i32*, i32** %lp2, align 8
+  // CHECK: {{%.*}} = load i32, i32* {{%.*}}, align 1
+  // CHECK: store i32 {{%.*}}, i32* {{%.*}}, align 1
+  int __unaligned *lp2;
+  (*lp2)++;
+}
+
+void test8(void) {
+  // CHECK: %lp3 = alloca i32*, align 1
+  // CHECK: {{%.*}} = load i32*, i32** %lp3, align 1
+  // CHECK: {{%.*}} = load i32, i32* {{%.*}}, align 1
+  // CHECK: store i32 {{%.*}}, i32* {{%.*}}, align 1
+  int __unaligned *__unaligned lp3;
+  (*lp3)++;
+}
+
+// -
+// Global array
+// -
+__unaligned int a[10];
+void test9(void) {
+  // CHECK: {{%.*}} = load i32, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @a, i64 0, i64 3), align 1
+  // CHECK: store i32 {{%.*}}, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @a, i64 0, i64 3), align 1
+  (a[3])++;
+}
+
+// -
+// Local array
+// -
+void test10(void) {
+  // CHECK: %la = alloca [10 x i32], align 1
+  // CHECK: {{%.*}} = getelementptr inbounds [10 x i32], [10 x i32]* %la, i64 0, i64 3
+  // CHECK: {{%.*}} = load i32, i32* {{%.*}}, align 1
+  // CHECK: store i32 {{%.*}}, i32* {{%.*}}, align 1
+  __unaligned int la[10];
+  (la[3])++;
+}
+
+// 
+// Typedefs
+// 
+
+typedef __unaligned int UnalignedInt;
+void test13() {
+  // CHECK: %i = alloca i32, align 1
+  // CHECK: {{%.*}} = load i32, i32* %i, align 1
+  // CHECK: store i32 {{%.*}}, i32* %i, align 1
+  UnalignedInt i;
+  i++;
+}
+
+typedef int Aligned;
+typedef __unaligned Aligned UnalignedInt2;
+void test14() {
+  // CHECK: %i = alloca i32, align 1
+  // CHECK: {{%.*}} = load i32, i32* %i, align 1
+  // CHECK: store i32 {{%.*}}, i32* %i, align 1
+  

[clang-tools-extra] r296458 - [change-namespace] trying to fix windows buildbot failure.

2017-02-28 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Tue Feb 28 04:00:15 2017
New Revision: 296458

URL: http://llvm.org/viewvc/llvm-project?rev=296458&view=rev
Log:
[change-namespace] trying to fix windows buildbot failure.

Modified:
clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp

Modified: clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp?rev=296458&r1=296457&r2=296458&view=diff
==
--- clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp 
(original)
+++ clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp Tue 
Feb 28 04:00:15 2017
@@ -80,8 +80,9 @@ cl::opt WhiteListFile(
 cl::init(""), cl::cat(ChangeNamespaceCategory));
 
 llvm::ErrorOr> GetWhiteListedSymbolPatterns() {
+  std::vector Patterns;
   if (WhiteListFile.empty())
-return std::vector();
+return Patterns;
 
   llvm::SmallVector Lines;
   llvm::ErrorOr> File =
@@ -90,7 +91,9 @@ llvm::ErrorOr>
 return File.getError();
   llvm::StringRef Content = File.get()->getBuffer();
   Content.split(Lines, '\n', /*MaxSplit=*/-1, /*KeepEmpty=*/false);
-  return std::vector(Lines.begin(), Lines.end());
+  for (auto Line : Lines)
+Patterns.push_back(Line.trim());
+  return Patterns;
 }
 
 } // anonymous namespace


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


Re: [clang-tools-extra] r296110 - [change-namepsace] make it possible to whitelist symbols so they don't get updated.

2017-02-28 Thread Eric Liu via cfe-commits
I suspect it was caused by the new line splitting ("\r\n" vs "\n"?) on
Windows. In the test, I write some strings (expected to be new line
delimited) to a temp file (
https://github.com/llvm-mirror/clang-tools-extra/blob/master/test/change-namespace/white-list.cpp#L1),
read the content, and then split with "\n" (
https://github.com/llvm-mirror/clang-tools-extra/blob/master/change-namespace/tool/ClangChangeNamespace.cpp#L92).
I am trying trimming the lines to see if this fix the issue (r296458).

Unfortunately, I don't have a Windows machine available for testing so I
couldn't verify this locally.

- Eric

On Tue, Feb 28, 2017 at 10:28 AM Eric Liu  wrote:

> Sorry for losing track of this.
>
> I thought I fixed it with r296113. Not sure why windows builds are still
> failing. I'll look into this.
>
> Thanks,
> Eric
>
> On Tue, Feb 28, 2017 at 2:19 AM Galina Kistanova 
> wrote:
>
> Hello Eric,
>
> This commit broke test on one of our builders:
>
> Clang Tools :: change-namespace/white-list.cpp
>
>
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/6153/steps/test/logs/stdio
>
> Please have a look.
>
> Thanks
>
>
> Galina
>
>
> On Fri, Feb 24, 2017 at 3:54 AM, Eric Liu via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: ioeric
> Date: Fri Feb 24 05:54:45 2017
> New Revision: 296110
>
> URL: http://llvm.org/viewvc/llvm-project?rev=296110&view=rev
> Log:
> [change-namepsace] make it possible to whitelist symbols so they don't get
> updated.
>
> Reviewers: hokein
>
> Reviewed By: hokein
>
> Subscribers: cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D30328
>
> Added:
> clang-tools-extra/trunk/test/change-namespace/Inputs/
> clang-tools-extra/trunk/test/change-namespace/Inputs/fake-std.h
> clang-tools-extra/trunk/test/change-namespace/white-list.cpp
> Modified:
> clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
> clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
> clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp
>
> clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
>
> Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp?rev=296110&r1=296109&r2=296110&view=diff
>
> ==
> --- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp (original)
> +++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp Fri Feb
> 24 05:54:45 2017
> @@ -290,6 +290,7 @@ AST_MATCHER(EnumDecl, isScoped) {
>
>  ChangeNamespaceTool::ChangeNamespaceTool(
>  llvm::StringRef OldNs, llvm::StringRef NewNs, llvm::StringRef
> FilePattern,
> +llvm::ArrayRef WhiteListedSymbolPatterns,
>  std::map *FileToReplacements,
>  llvm::StringRef FallbackStyle)
>  : FallbackStyle(FallbackStyle),
> FileToReplacements(*FileToReplacements),
> @@ -308,6 +309,9 @@ ChangeNamespaceTool::ChangeNamespaceTool
>}
>DiffOldNamespace = joinNamespaces(OldNsSplitted);
>DiffNewNamespace = joinNamespaces(NewNsSplitted);
> +
> +  for (const auto &Pattern : WhiteListedSymbolPatterns)
> +WhiteListedSymbolRegexes.emplace_back(Pattern);
>  }
>
>  void ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder
> *Finder) {
> @@ -736,6 +740,9 @@ void ChangeNamespaceTool::replaceQualifi
>Result.SourceManager->getSpellingLoc(End)),
>*Result.SourceManager, Result.Context->getLangOpts());
>std::string FromDeclName = FromDecl->getQualifiedNameAsString();
> +  for (llvm::Regex &RE : WhiteListedSymbolRegexes)
> +if (RE.match(FromDeclName))
> +  return;
>std::string ReplaceName =
>getShortestQualifiedNameInNamespace(FromDeclName, NewNs);
>// Checks if there is any using namespace declarations that can shorten
> the
>
> Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/ChangeNamespace.h?rev=296110&r1=296109&r2=296110&view=diff
>
> ==
> --- clang-tools-extra/trunk/change-namespace/ChangeNamespace.h (original)
> +++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.h Fri Feb 24
> 05:54:45 2017
> @@ -50,6 +50,7 @@ public:
>// files matching `FilePattern`.
>ChangeNamespaceTool(
>llvm::StringRef OldNs, llvm::StringRef NewNs, llvm::StringRef
> FilePattern,
> +  llvm::ArrayRef WhiteListedSymbolPatterns,
>std::map *FileToReplacements,
>llvm::StringRef FallbackStyle = "LLVM");
>
> @@ -164,6 +165,9 @@ private:
>// CallExpr and one as DeclRefExpr), we record all DeclRefExpr's that
> have
>// been processed so that we don't handle them twice.
>llvm::SmallPtrSet ProcessedFuncRefs;
> +  // Patterns of symbol names

r296460 - clang/test/Format/inplace.cpp: Avoid using wildcard.

2017-02-28 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Tue Feb 28 04:05:56 2017
New Revision: 296460

URL: http://llvm.org/viewvc/llvm-project?rev=296460&view=rev
Log:
clang/test/Format/inplace.cpp: Avoid using wildcard.

MSYS' tools don't do globbing.

Modified:
cfe/trunk/test/Format/inplace.cpp

Modified: cfe/trunk/test/Format/inplace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Format/inplace.cpp?rev=296460&r1=296459&r2=296460&view=diff
==
--- cfe/trunk/test/Format/inplace.cpp (original)
+++ cfe/trunk/test/Format/inplace.cpp Tue Feb 28 04:05:56 2017
@@ -1,9 +1,11 @@
 // Regression test to check that clang-format does not leave behind temporary
 // files on Windows when doing in-place formatting.
-// RUN: cp %s %T/inplace.cpp
-// RUN: clang-format -style=LLVM -i %T/inplace.cpp
-// RUN: ls %T > %T/files.txt
-// RUN: FileCheck -strict-whitespace -input-file=%T/files.txt %s
+// RUN: rm -rf %t.dir
+// RUN: mkdir %t.dir
+// RUN: cp %s %t.dir/inplace.cpp
+// RUN: clang-format -style=LLVM -i %t.dir/inplace.cpp
+// RUN: ls %t.dir > %t.dir/files.txt
+// RUN: FileCheck -strict-whitespace -input-file=%t.dir/files.txt %s
 
 // CHECK-NOT: RF{{.*}}.TMP
 


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


[PATCH] D30326: [MS-ABI] Allow #pragma section to choose for ZI data

2017-02-28 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 added a comment.

Thanks @javed.absar

This LGTM now.


https://reviews.llvm.org/D30326



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


[PATCH] D30345: [CodeGen][Blocks] Refactor capture handling in code that generates block copy/destroy routines

2017-02-28 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In https://reviews.llvm.org/D30345#688144, @rjmccall wrote:

> You're doing this refactor to... support doing another refactor of the same 
> code?  Why are these patches separate?


Not quite, by "merging block copy/destroy routines" I meant that my next patch 
will try to generate the IR only for unique copy/destroy functions, so 
individual functions will be merged.


Repository:
  rL LLVM

https://reviews.llvm.org/D30345



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


[clang-tools-extra] r296461 - [find-all-symbols] Implement operator== for SymbolAndSignals and SymbolInfo::Signals.

2017-02-28 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue Feb 28 04:13:26 2017
New Revision: 296461

URL: http://llvm.org/viewvc/llvm-project?rev=296461&view=rev
Log:
[find-all-symbols] Implement operator== for SymbolAndSignals and 
SymbolInfo::Signals.

Modified:
clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp
clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h

Modified: clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp?rev=296461&r1=296460&r2=296461&view=diff
==
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp 
(original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp Tue 
Feb 28 04:13:26 2017
@@ -113,6 +113,14 @@ SymbolInfo::Signals SymbolInfo::Signals:
   return Result;
 }
 
+bool SymbolInfo::Signals::operator==(const Signals &RHS) const {
+  return std::tie(Seen, Used) == std::tie(RHS.Seen, RHS.Used);
+}
+
+bool SymbolAndSignals::operator==(const SymbolAndSignals& RHS) const {
+  return std::tie(Symbol, Signals) == std::tie(RHS.Symbol, RHS.Signals);
+}
+
 bool WriteSymbolInfosToStream(llvm::raw_ostream &OS,
   const SymbolInfo::SignalMap &Symbols) {
   llvm::yaml::Output yout(OS);

Modified: clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h?rev=296461&r1=296460&r2=296461&view=diff
==
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h 
(original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h Tue Feb 
28 04:13:26 2017
@@ -59,6 +59,7 @@ public:
 
 Signals &operator+=(const Signals &RHS);
 Signals operator+(const Signals &RHS) const;
+bool operator==(const Signals &RHS) const;
   };
 
   using SignalMap = std::map;
@@ -128,6 +129,7 @@ private:
 struct SymbolAndSignals {
   SymbolInfo Symbol;
   SymbolInfo::Signals Signals;
+  bool operator==(const SymbolAndSignals& RHS) const;
 };
 
 /// \brief Write SymbolInfos to a stream (YAML format).


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


[PATCH] D30452: Blacklist @mods and several other JSDoc tags from wrapping.

2017-02-28 Thread Martin Probst via Phabricator via cfe-commits
mprobst created this revision.
Herald added a subscriber: klimek.

Limit the blacklisting to only apply when the tag is actually followed by a 
parameter in curly braces.

  /** @mods {long.type.must.not.wrap} */

vs

  /** @const this is a long description that may wrap. */

JSDoc tag reference here:
https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler


https://reviews.llvm.org/D30452

Files:
  lib/Format/Format.cpp
  unittests/Format/FormatTestJS.cpp


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1575,6 +1575,30 @@
" * @export {this.is.a.long.path.to.a.Type}\n"
" */",
getGoogleJSStyleWithColumns(20));
+  verifyFormat("/**\n"
+   " * @mods {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   "/**\n"
+   " * @mods {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   getGoogleJSStyleWithColumns(20));
+  verifyFormat("/**\n"
+   " * @param {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   "/**\n"
+   " * @param {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   getGoogleJSStyleWithColumns(20));
+  verifyFormat(
+  "/**\n"
+  " * @param This is a\n"
+  " * long comment but\n"
+  " * no type\n"
+  " */",
+  "/**\n"
+  " * @param This is a long comment but no type\n"
+  " */",
+  getGoogleJSStyleWithColumns(20));
 }
 
 TEST_F(FormatTestJS, RequoteStringsSingle) {
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -620,8 +620,29 @@
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;
+// taze:, and @tag followed by { for a lot of JSDoc tags.
 GoogleStyle.CommentPragmas =
-"(taze:|@(export|requirecss|return|returns|see|visibility)) ";
+"(taze:|"
+"(@("
+"const|"
+"define|"
+"enum|"
+"export|"
+"extends|"
+"implements|"
+"modName|"
+"mods|"
+"param|"
+"private|"
+"public|"
+"requirecss|"
+"returns|"
+"return|"
+"see|"
+"this|"
+"visibility"
+") *{)"
+")";
 GoogleStyle.MaxEmptyLinesToKeep = 3;
 GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
 GoogleStyle.SpacesInContainerLiterals = false;


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1575,6 +1575,30 @@
" * @export {this.is.a.long.path.to.a.Type}\n"
" */",
getGoogleJSStyleWithColumns(20));
+  verifyFormat("/**\n"
+   " * @mods {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   "/**\n"
+   " * @mods {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   getGoogleJSStyleWithColumns(20));
+  verifyFormat("/**\n"
+   " * @param {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   "/**\n"
+   " * @param {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   getGoogleJSStyleWithColumns(20));
+  verifyFormat(
+  "/**\n"
+  " * @param This is a\n"
+  " * long comment but\n"
+  " * no type\n"
+  " */",
+  "/**\n"
+  " * @param This is a long comment but no type\n"
+  " */",
+  getGoogleJSStyleWithColumns(20));
 }
 
 TEST_F(FormatTestJS, RequoteStringsSingle) {
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -620,8 +620,29 @@
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;
+// taze:, and @tag followed by { for a lot of JSDoc tags.
 GoogleStyle.CommentPragmas =
-"(taze:|@(export|requirecss|return|returns|see|visibility)) ";
+"(taze:|"
+"(@("
+"const|"
+"define|"
+"enum|"
+"export|"
+"extends|"
+"implements|"
+"modName|"
+"mods|"
+"param|"
+"private|"
+"public|"
+"requirecss|"
+"returns|"
+"return|"
+"see|"
+"this|"
+"visibility"
+") *{)"
+")";
 GoogleStyle.MaxEmptyLinesToKeep = 3;
 GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
 GoogleStyle.SpacesIn

[PATCH] D30452: Blacklist @mods and several other JSDoc tags from wrapping.

2017-02-28 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added inline comments.



Comment at: lib/Format/Format.cpp:627
+"(@("
+"const|"
+"define|"

I'd vote for making this "@\w*\ *{". We have seen incorrectly spelled version 
and such of this in the past.


https://reviews.llvm.org/D30452



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


[PATCH] D30452: Blacklist @mods and several other JSDoc tags from wrapping.

2017-02-28 Thread Martin Probst via Phabricator via cfe-commits
mprobst updated this revision to Diff 8.
mprobst added a comment.

- Match \\w* for all JSDoc param tags.


https://reviews.llvm.org/D30452

Files:
  lib/Format/Format.cpp
  unittests/Format/FormatTestJS.cpp


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1575,6 +1575,30 @@
" * @export {this.is.a.long.path.to.a.Type}\n"
" */",
getGoogleJSStyleWithColumns(20));
+  verifyFormat("/**\n"
+   " * @mods {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   "/**\n"
+   " * @mods {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   getGoogleJSStyleWithColumns(20));
+  verifyFormat("/**\n"
+   " * @param {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   "/**\n"
+   " * @param {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   getGoogleJSStyleWithColumns(20));
+  verifyFormat(
+  "/**\n"
+  " * @param This is a\n"
+  " * long comment but\n"
+  " * no type\n"
+  " */",
+  "/**\n"
+  " * @param This is a long comment but no type\n"
+  " */",
+  getGoogleJSStyleWithColumns(20));
 }
 
 TEST_F(FormatTestJS, RequoteStringsSingle) {
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -620,8 +620,8 @@
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;
-GoogleStyle.CommentPragmas =
-"(taze:|@(export|requirecss|return|returns|see|visibility)) ";
+// taze:, and @tag followed by { for a lot of JSDoc tags.
+GoogleStyle.CommentPragmas = "(taze:|(@[A-Za-z_0-9-]*[ \\t]*{))";
 GoogleStyle.MaxEmptyLinesToKeep = 3;
 GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
 GoogleStyle.SpacesInContainerLiterals = false;


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1575,6 +1575,30 @@
" * @export {this.is.a.long.path.to.a.Type}\n"
" */",
getGoogleJSStyleWithColumns(20));
+  verifyFormat("/**\n"
+   " * @mods {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   "/**\n"
+   " * @mods {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   getGoogleJSStyleWithColumns(20));
+  verifyFormat("/**\n"
+   " * @param {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   "/**\n"
+   " * @param {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   getGoogleJSStyleWithColumns(20));
+  verifyFormat(
+  "/**\n"
+  " * @param This is a\n"
+  " * long comment but\n"
+  " * no type\n"
+  " */",
+  "/**\n"
+  " * @param This is a long comment but no type\n"
+  " */",
+  getGoogleJSStyleWithColumns(20));
 }
 
 TEST_F(FormatTestJS, RequoteStringsSingle) {
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -620,8 +620,8 @@
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;
-GoogleStyle.CommentPragmas =
-"(taze:|@(export|requirecss|return|returns|see|visibility)) ";
+// taze:, and @tag followed by { for a lot of JSDoc tags.
+GoogleStyle.CommentPragmas = "(taze:|(@[A-Za-z_0-9-]*[ \\t]*{))";
 GoogleStyle.MaxEmptyLinesToKeep = 3;
 GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
 GoogleStyle.SpacesInContainerLiterals = false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30412: [clang-tidy] Fix a false positive on modernize-use-nullptr check.

2017-02-28 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG. Thanks for tracking this down!


https://reviews.llvm.org/D30412



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


[PATCH] D30452: Blacklist @mods and several other JSDoc tags from wrapping.

2017-02-28 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added inline comments.
This revision is now accepted and ready to land.



Comment at: lib/Format/Format.cpp:624
+// taze:, and @tag followed by { for a lot of JSDoc tags.
+GoogleStyle.CommentPragmas = "(taze:|(@[A-Za-z_0-9-]*[ \\t]*{))";
 GoogleStyle.MaxEmptyLinesToKeep = 3;

Thinking again, I think the first "*" should probably be a "+", but not sure.


https://reviews.llvm.org/D30452



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


[PATCH] D30452: Blacklist @mods and several other JSDoc tags from wrapping.

2017-02-28 Thread Martin Probst via Phabricator via cfe-commits
mprobst marked an inline comment as done.
mprobst added inline comments.



Comment at: lib/Format/Format.cpp:624
+// taze:, and @tag followed by { for a lot of JSDoc tags.
+GoogleStyle.CommentPragmas = "(taze:|(@[A-Za-z_0-9-]*[ \\t]*{))";
 GoogleStyle.MaxEmptyLinesToKeep = 3;

djasper wrote:
> Thinking again, I think the first "*" should probably be a "+", but not sure.
Ah. I tried that initially, and fooled myself into thinking that didn't work. 
Done.


https://reviews.llvm.org/D30452



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


Re: r296408 - clang-format: Don't leave behind temp files in -i mode on Windows, PR26125, reloaded

2017-02-28 Thread NAKAMURA Takumi via cfe-commits
Tweaked in r296460.

On Tue, Feb 28, 2017 at 10:28 AM Galina Kistanova via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hello Nico,
>
> This commit broke test on one of our builders:
>
> Clang :: Format/inplace.cpp
>
>
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/6151/steps/test/logs/stdio
>
> Please have a look.
>
> Thanks
>
>
> Galina
>
> On Mon, Feb 27, 2017 at 2:59 PM, Nico Weber via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: nico
> Date: Mon Feb 27 16:59:58 2017
> New Revision: 296408
>
> URL: http://llvm.org/viewvc/llvm-project?rev=296408&view=rev
> Log:
> clang-format: Don't leave behind temp files in -i mode on Windows,
> PR26125, reloaded
>
> Second attempt after
> http://llvm.org/viewvc/llvm-project?rev=296166&view=rev
>
> In the first attempt, Code (the memory buffer backing the input file) was
> reset
> before overwriteChangedFiles() was called, but overwriteChangedFiles()
> still
> reads from it.  This time, load the whole input file into memory instead of
> using mmap when formatting in-place.
>
> (Since the test is identical to what was in the repo before chapuni's
> revert,
> svn diff doesn't show it – see the above link for the test.)
>
> https://reviews.llvm.org/D30385
>
> Added:
> cfe/trunk/test/Format/inplace.cpp
>   - copied unchanged from r296236, cfe/trunk/test/Format/inplace.cpp
> Modified:
> cfe/trunk/tools/clang-format/ClangFormat.cpp
>
> Modified: cfe/trunk/tools/clang-format/ClangFormat.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/ClangFormat.cpp?rev=296408&r1=296407&r2=296408&view=diff
>
> ==
> --- cfe/trunk/tools/clang-format/ClangFormat.cpp (original)
> +++ cfe/trunk/tools/clang-format/ClangFormat.cpp Mon Feb 27 16:59:58 2017
> @@ -236,8 +236,15 @@ static void outputReplacementsXML(const
>
>  // Returns true on error.
>  static bool format(StringRef FileName) {
> +  if (!OutputXML && Inplace && FileName == "-") {
> +errs() << "error: cannot use -i when reading from stdin.\n";
> +return false;
> +  }
> +  // On Windows, overwriting a file with an open file mapping doesn't
> work,
> +  // so read the whole file into memory when formatting in-place.
>ErrorOr> CodeOrErr =
> -  MemoryBuffer::getFileOrSTDIN(FileName);
> +  !OutputXML && Inplace ? MemoryBuffer::getFileAsStream(FileName) :
> +  MemoryBuffer::getFileOrSTDIN(FileName);
>if (std::error_code EC = CodeOrErr.getError()) {
>  errs() << EC.message() << "\n";
>  return true;
> @@ -297,9 +304,7 @@ static bool format(StringRef FileName) {
>  Rewriter Rewrite(Sources, LangOptions());
>  tooling::applyAllReplacements(Replaces, Rewrite);
>  if (Inplace) {
> -  if (FileName == "-")
> -errs() << "error: cannot use -i when reading from stdin.\n";
> -  else if (Rewrite.overwriteChangedFiles())
> +  if (Rewrite.overwriteChangedFiles())
>  return true;
>  } else {
>if (Cursor.getNumOccurrences() != 0)
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r296467 - Blacklist arbitrary @\\w+ JSDoc tags from wrapping.

2017-02-28 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Tue Feb 28 05:08:24 2017
New Revision: 296467

URL: http://llvm.org/viewvc/llvm-project?rev=296467&view=rev
Log:
Blacklist arbitrary @\\w+ JSDoc tags from wrapping.

Summary:
Also limits the blacklisting to only apply when the tag is actually
followed by a parameter in curly braces.

/** @mods {long.type.must.not.wrap} */

vs

/** @const this is a long description that may wrap. */

Reviewers: djasper

Subscribers: klimek, krasimir, cfe-commits

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

Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=296467&r1=296466&r2=296467&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Tue Feb 28 05:08:24 2017
@@ -620,8 +620,8 @@ FormatStyle getGoogleStyle(FormatStyle::
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;
-GoogleStyle.CommentPragmas =
-"(taze:|@(export|requirecss|return|returns|see|visibility)) ";
+// taze:, and @tag followed by { for a lot of JSDoc tags.
+GoogleStyle.CommentPragmas = "(taze:|(@[A-Za-z_0-9-]+[ \\t]*{))";
 GoogleStyle.MaxEmptyLinesToKeep = 3;
 GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
 GoogleStyle.SpacesInContainerLiterals = false;

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=296467&r1=296466&r2=296467&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue Feb 28 05:08:24 2017
@@ -1575,6 +1575,30 @@ TEST_F(FormatTestJS, JSDocAnnotations) {
" * @export {this.is.a.long.path.to.a.Type}\n"
" */",
getGoogleJSStyleWithColumns(20));
+  verifyFormat("/**\n"
+   " * @mods {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   "/**\n"
+   " * @mods {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   getGoogleJSStyleWithColumns(20));
+  verifyFormat("/**\n"
+   " * @param {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   "/**\n"
+   " * @param {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   getGoogleJSStyleWithColumns(20));
+  verifyFormat(
+  "/**\n"
+  " * @param This is a\n"
+  " * long comment but\n"
+  " * no type\n"
+  " */",
+  "/**\n"
+  " * @param This is a long comment but no type\n"
+  " */",
+  getGoogleJSStyleWithColumns(20));
 }
 
 TEST_F(FormatTestJS, RequoteStringsSingle) {


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


[PATCH] D30452: Blacklist @mods and several other JSDoc tags from wrapping.

2017-02-28 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296467: Blacklist arbitrary @\\w+ JSDoc tags from wrapping. 
(authored by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D30452?vs=8&id=90001#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30452

Files:
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp


Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -620,8 +620,8 @@
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;
-GoogleStyle.CommentPragmas =
-"(taze:|@(export|requirecss|return|returns|see|visibility)) ";
+// taze:, and @tag followed by { for a lot of JSDoc tags.
+GoogleStyle.CommentPragmas = "(taze:|(@[A-Za-z_0-9-]+[ \\t]*{))";
 GoogleStyle.MaxEmptyLinesToKeep = 3;
 GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
 GoogleStyle.SpacesInContainerLiterals = false;
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1575,6 +1575,30 @@
" * @export {this.is.a.long.path.to.a.Type}\n"
" */",
getGoogleJSStyleWithColumns(20));
+  verifyFormat("/**\n"
+   " * @mods {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   "/**\n"
+   " * @mods {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   getGoogleJSStyleWithColumns(20));
+  verifyFormat("/**\n"
+   " * @param {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   "/**\n"
+   " * @param {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   getGoogleJSStyleWithColumns(20));
+  verifyFormat(
+  "/**\n"
+  " * @param This is a\n"
+  " * long comment but\n"
+  " * no type\n"
+  " */",
+  "/**\n"
+  " * @param This is a long comment but no type\n"
+  " */",
+  getGoogleJSStyleWithColumns(20));
 }
 
 TEST_F(FormatTestJS, RequoteStringsSingle) {


Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -620,8 +620,8 @@
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;
-GoogleStyle.CommentPragmas =
-"(taze:|@(export|requirecss|return|returns|see|visibility)) ";
+// taze:, and @tag followed by { for a lot of JSDoc tags.
+GoogleStyle.CommentPragmas = "(taze:|(@[A-Za-z_0-9-]+[ \\t]*{))";
 GoogleStyle.MaxEmptyLinesToKeep = 3;
 GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
 GoogleStyle.SpacesInContainerLiterals = false;
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1575,6 +1575,30 @@
" * @export {this.is.a.long.path.to.a.Type}\n"
" */",
getGoogleJSStyleWithColumns(20));
+  verifyFormat("/**\n"
+   " * @mods {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   "/**\n"
+   " * @mods {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   getGoogleJSStyleWithColumns(20));
+  verifyFormat("/**\n"
+   " * @param {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   "/**\n"
+   " * @param {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   getGoogleJSStyleWithColumns(20));
+  verifyFormat(
+  "/**\n"
+  " * @param This is a\n"
+  " * long comment but\n"
+  " * no type\n"
+  " */",
+  "/**\n"
+  " * @param This is a long comment but no type\n"
+  " */",
+  getGoogleJSStyleWithColumns(20));
 }
 
 TEST_F(FormatTestJS, RequoteStringsSingle) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29027: [Stack Protection] Add remark for reasons why Stack Protection has been applied

2017-02-28 Thread James Henderson via Phabricator via cfe-commits
jhenderson abandoned this revision.
jhenderson added a comment.

Abandoning. Due to changes made in https://reviews.llvm.org/D29023, there is no 
more need for this patch. The new method followed in that patch means that 
clang gets support for the new remarks via -Rpass=stack-protector.


https://reviews.llvm.org/D29027



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


[PATCH] D30111: [clang-format] Add a test to check at once all the Mozilla coding style

2017-02-28 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

@krasimir is that ok with you?


https://reviews.llvm.org/D30111



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


[PATCH] D27918: [analyzer] OStreamChecker

2017-02-28 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 added a comment.

Hello,
This checker was developed indeed with internal usage in mind. It should not 
necessary be added as a default checker. However I have run it on the 
boost-1.63.0 codebase, and there some some mildly interesting findings in 
examples and tests. There is also a true positive result in the core codebase.

As for the patter described above, it certainly is a possible use-case to set 
streams inside functions, but very few ( if any ) false positives was found 
thanks to that, and the main case for them was that I could not run the 
cross-TU analyzer (boosts bjam build system proved to be reluctant to work 
together with ClangSA).


https://reviews.llvm.org/D27918



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


[PATCH] D27054: Introducing clang::tooling::EditList for refactoring tools.

2017-02-28 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 90011.
ioeric added a comment.

- Addressed review comments.
- Make key customize-able.
- Added replace() and insert() to replace current replacement interfaces.
- s/EditList/AtomicChange/


https://reviews.llvm.org/D27054

Files:
  include/clang/Tooling/Refactoring/AtomicChange.h
  lib/Tooling/CMakeLists.txt
  lib/Tooling/Refactoring/AtomicChange.cpp
  lib/Tooling/Refactoring/CMakeLists.txt
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -26,6 +26,7 @@
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/Refactoring/AtomicChange.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/SmallString.h"
 #include "gtest/gtest.h"
@@ -102,10 +103,10 @@
 
 // Checks that an llvm::Error instance contains a ReplacementError with expected
 // error code, expected new replacement, and expected existing replacement.
-static bool checkReplacementError(
-llvm::Error&& Error, replacement_error ExpectedErr,
-llvm::Optional ExpectedExisting,
-llvm::Optional ExpectedNew) {
+static bool checkReplacementError(llvm::Error &&Error,
+  replacement_error ExpectedErr,
+  llvm::Optional ExpectedExisting,
+  llvm::Optional ExpectedNew) {
   if (!Error) {
 llvm::errs() << "Error is a success.";
 return false;
@@ -1089,5 +1090,187 @@
   EXPECT_TRUE(FileToReplaces.empty());
 }
 
+class AtomicChangeTest : public ::testing::Test {
+  protected:
+void setUp() {
+  DefaultFileID = Context.createInMemoryFile("input.cpp", DefaultCode);
+  DefaultLoc = Context.Sources.getLocForStartOfFile(DefaultFileID)
+   .getLocWithOffset(20);
+  assert(DefaultLoc.isValid() && "Default location must be valid.");
+}
+
+RewriterTestContext Context;
+std::string DefaultCode = std::string(100, 'a');
+unsigned DefaultOffset = 20;
+SourceLocation DefaultLoc;
+FileID DefaultFileID;
+};
+
+TEST_F(AtomicChangeTest, AtomicChangeToYAML) {
+  setUp();
+  AtomicChange Change(Context.Sources, DefaultLoc);
+  llvm::Error Err =
+  Change.insert(Context.Sources, DefaultLoc, "aa", /*InsertAfter=*/false);
+  ASSERT_TRUE(!Err);
+  Err = Change.insert(Context.Sources, DefaultLoc.getLocWithOffset(10), "bb",
+/*InsertAfter=*/false);
+  ASSERT_TRUE(!Err);
+  Change.addHeader("a.h");
+  Change.removeHeader("b.h");
+  std::string YAMLString = Change.toYAMLString();
+
+  // NOTE: If this test starts to fail for no obvious reason, check whitespace.
+  ASSERT_STREQ("---\n"
+   "Key: 'input.cpp:20'\n"
+   "FilePath:input.cpp\n"
+   "Error:   ''\n"
+   "InsertedHeaders: [ a.h ]\n"
+   "RemovedHeaders:  [ b.h ]\n"
+   "Replacements:\n" // Extra whitespace here!
+   "  - FilePath:input.cpp\n"
+   "Offset:  20\n"
+   "Length:  0\n"
+   "ReplacementText: aa\n"
+   "  - FilePath:input.cpp\n"
+   "Offset:  30\n"
+   "Length:  0\n"
+   "ReplacementText: bb\n"
+   "...\n",
+   YAMLString.c_str());
+}
+
+TEST_F(AtomicChangeTest, YAMLToAtomicChange) {
+  setUp();
+  std::string YamlContent = "---\n"
+"Key: 'input.cpp:20'\n"
+"FilePath:input.cpp\n"
+"Error:   'ok'\n"
+"InsertedHeaders: [ a.h ]\n"
+"RemovedHeaders:  [ b.h ]\n"
+"Replacements:\n" // Extra whitespace here!
+"  - FilePath:input.cpp\n"
+"Offset:  20\n"
+"Length:  0\n"
+"ReplacementText: aa\n"
+"  - FilePath:input.cpp\n"
+"Offset:  30\n"
+"Length:  0\n"
+"ReplacementText: bb\n"
+"...\n";
+  AtomicChange ExpectedChange(Context.Sources, DefaultLoc);
+  llvm::Error Err = ExpectedChange.insert(Context.Sources, DefaultLoc, "aa",
+/*InsertAfter=*/false);
+  ASSERT_TRUE(!Err);
+  Err = ExpectedChange.insert(Context.Sources, DefaultLoc.getLocWithOffset(10),
+"bb", /*InsertAfter=*/false);
+  ASSERT_TRUE(!Err);
+

[PATCH] D27054: Introducing clang::tooling::AtomicChange for refactoring tools.

2017-02-28 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap added inline comments.



Comment at: include/clang/Tooling/Refactoring/AtomicChange.h:59
+  /// \brief Returns the path of the file containing this atomic change.
+  std::string getFilePath() const { return FilePath; }
+

i assume i might be missing smth - why here and above (in getKey, getFilePath, 
getError) std::string is returned by value  ?


https://reviews.llvm.org/D27054



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


[PATCH] D27054: Introducing clang::tooling::AtomicChange for refactoring tools.

2017-02-28 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap added inline comments.



Comment at: lib/Tooling/Refactoring/AtomicChange.cpp:35
+RemovedHeaders(E.getRemovedHeaders()) {
+std::copy(E.getReplacements().begin(), E.getReplacements().end(),
+  std::back_inserter(Replaces));

if i am not mistaken this can be done in the intialization list:
Replaces(E.getReplacements().begin(), E.getReplacements().end())
 


https://reviews.llvm.org/D27054



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


[PATCH] D27054: Introducing clang::tooling::AtomicChange for refactoring tools.

2017-02-28 Thread Eric Liu via Phabricator via cfe-commits
ioeric marked an inline comment as done.
ioeric added inline comments.



Comment at: include/clang/Tooling/Refactoring/AtomicChange.h:59
+  /// \brief Returns the path of the file containing this atomic change.
+  std::string getFilePath() const { return FilePath; }
+

alexshap wrote:
> i assume i might be missing smth - why here and above (in getKey, 
> getFilePath, getError) std::string is returned by value  ?
Otherwise, users would need to worry about the lifetimes of the object. And 
these methods are not expected to be called intensively, so performance is not 
an issue.



Comment at: lib/Tooling/Refactoring/AtomicChange.cpp:35
+RemovedHeaders(E.getRemovedHeaders()) {
+std::copy(E.getReplacements().begin(), E.getReplacements().end(),
+  std::back_inserter(Replaces));

alexshap wrote:
> if i am not mistaken this can be done in the intialization list:
> Replaces(E.getReplacements().begin(), E.getReplacements().end())
>  
You are right. 


https://reviews.llvm.org/D27054



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


[PATCH] D27054: Introducing clang::tooling::AtomicChange for refactoring tools.

2017-02-28 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 90012.
ioeric marked an inline comment as done.
ioeric added a comment.

- Addressed comments.


https://reviews.llvm.org/D27054

Files:
  include/clang/Tooling/Refactoring/AtomicChange.h
  lib/Tooling/CMakeLists.txt
  lib/Tooling/Refactoring/AtomicChange.cpp
  lib/Tooling/Refactoring/CMakeLists.txt
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -26,6 +26,7 @@
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/Refactoring/AtomicChange.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/SmallString.h"
 #include "gtest/gtest.h"
@@ -102,10 +103,10 @@
 
 // Checks that an llvm::Error instance contains a ReplacementError with expected
 // error code, expected new replacement, and expected existing replacement.
-static bool checkReplacementError(
-llvm::Error&& Error, replacement_error ExpectedErr,
-llvm::Optional ExpectedExisting,
-llvm::Optional ExpectedNew) {
+static bool checkReplacementError(llvm::Error &&Error,
+  replacement_error ExpectedErr,
+  llvm::Optional ExpectedExisting,
+  llvm::Optional ExpectedNew) {
   if (!Error) {
 llvm::errs() << "Error is a success.";
 return false;
@@ -1089,5 +1090,187 @@
   EXPECT_TRUE(FileToReplaces.empty());
 }
 
+class AtomicChangeTest : public ::testing::Test {
+  protected:
+void setUp() {
+  DefaultFileID = Context.createInMemoryFile("input.cpp", DefaultCode);
+  DefaultLoc = Context.Sources.getLocForStartOfFile(DefaultFileID)
+   .getLocWithOffset(20);
+  assert(DefaultLoc.isValid() && "Default location must be valid.");
+}
+
+RewriterTestContext Context;
+std::string DefaultCode = std::string(100, 'a');
+unsigned DefaultOffset = 20;
+SourceLocation DefaultLoc;
+FileID DefaultFileID;
+};
+
+TEST_F(AtomicChangeTest, AtomicChangeToYAML) {
+  setUp();
+  AtomicChange Change(Context.Sources, DefaultLoc);
+  llvm::Error Err =
+  Change.insert(Context.Sources, DefaultLoc, "aa", /*InsertAfter=*/false);
+  ASSERT_TRUE(!Err);
+  Err = Change.insert(Context.Sources, DefaultLoc.getLocWithOffset(10), "bb",
+/*InsertAfter=*/false);
+  ASSERT_TRUE(!Err);
+  Change.addHeader("a.h");
+  Change.removeHeader("b.h");
+  std::string YAMLString = Change.toYAMLString();
+
+  // NOTE: If this test starts to fail for no obvious reason, check whitespace.
+  ASSERT_STREQ("---\n"
+   "Key: 'input.cpp:20'\n"
+   "FilePath:input.cpp\n"
+   "Error:   ''\n"
+   "InsertedHeaders: [ a.h ]\n"
+   "RemovedHeaders:  [ b.h ]\n"
+   "Replacements:\n" // Extra whitespace here!
+   "  - FilePath:input.cpp\n"
+   "Offset:  20\n"
+   "Length:  0\n"
+   "ReplacementText: aa\n"
+   "  - FilePath:input.cpp\n"
+   "Offset:  30\n"
+   "Length:  0\n"
+   "ReplacementText: bb\n"
+   "...\n",
+   YAMLString.c_str());
+}
+
+TEST_F(AtomicChangeTest, YAMLToAtomicChange) {
+  setUp();
+  std::string YamlContent = "---\n"
+"Key: 'input.cpp:20'\n"
+"FilePath:input.cpp\n"
+"Error:   'ok'\n"
+"InsertedHeaders: [ a.h ]\n"
+"RemovedHeaders:  [ b.h ]\n"
+"Replacements:\n" // Extra whitespace here!
+"  - FilePath:input.cpp\n"
+"Offset:  20\n"
+"Length:  0\n"
+"ReplacementText: aa\n"
+"  - FilePath:input.cpp\n"
+"Offset:  30\n"
+"Length:  0\n"
+"ReplacementText: bb\n"
+"...\n";
+  AtomicChange ExpectedChange(Context.Sources, DefaultLoc);
+  llvm::Error Err = ExpectedChange.insert(Context.Sources, DefaultLoc, "aa",
+/*InsertAfter=*/false);
+  ASSERT_TRUE(!Err);
+  Err = ExpectedChange.insert(Context.Sources, DefaultLoc.getLocWithOffset(10),
+"bb", /*InsertAfter=*/false);
+  ASSERT_TRUE(!Err);
+
+  ExpectedChange.addHeader("a.h");
+  ExpectedChange.removeHeader("b.h");
+  ExpectedChange.s

Re: r296460 - clang/test/Format/inplace.cpp: Avoid using wildcard.

2017-02-28 Thread Nico Weber via cfe-commits
Thanks! That's a good technique, I'll remember it for next time. I wonder
if %T should work like that...

On Feb 28, 2017 5:17 AM, "NAKAMURA Takumi via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

> Author: chapuni
> Date: Tue Feb 28 04:05:56 2017
> New Revision: 296460
>
> URL: http://llvm.org/viewvc/llvm-project?rev=296460&view=rev
> Log:
> clang/test/Format/inplace.cpp: Avoid using wildcard.
>
> MSYS' tools don't do globbing.
>
> Modified:
> cfe/trunk/test/Format/inplace.cpp
>
> Modified: cfe/trunk/test/Format/inplace.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Format/
> inplace.cpp?rev=296460&r1=296459&r2=296460&view=diff
> 
> ==
> --- cfe/trunk/test/Format/inplace.cpp (original)
> +++ cfe/trunk/test/Format/inplace.cpp Tue Feb 28 04:05:56 2017
> @@ -1,9 +1,11 @@
>  // Regression test to check that clang-format does not leave behind
> temporary
>  // files on Windows when doing in-place formatting.
> -// RUN: cp %s %T/inplace.cpp
> -// RUN: clang-format -style=LLVM -i %T/inplace.cpp
> -// RUN: ls %T > %T/files.txt
> -// RUN: FileCheck -strict-whitespace -input-file=%T/files.txt %s
> +// RUN: rm -rf %t.dir
> +// RUN: mkdir %t.dir
> +// RUN: cp %s %t.dir/inplace.cpp
> +// RUN: clang-format -style=LLVM -i %t.dir/inplace.cpp
> +// RUN: ls %t.dir > %t.dir/files.txt
> +// RUN: FileCheck -strict-whitespace -input-file=%t.dir/files.txt %s
>
>  // CHECK-NOT: RF{{.*}}.TMP
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27054: Introducing clang::tooling::AtomicChange for refactoring tools.

2017-02-28 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap added inline comments.



Comment at: include/clang/Tooling/Refactoring/AtomicChange.h:59
+  /// \brief Returns the path of the file containing this atomic change.
+  std::string getFilePath() const { return FilePath; }
+

ioeric wrote:
> alexshap wrote:
> > i assume i might be missing smth - why here and above (in getKey, 
> > getFilePath, getError) std::string is returned by value  ?
> Otherwise, users would need to worry about the lifetimes of the object. And 
> these methods are not expected to be called intensively, so performance is 
> not an issue.
i see, thanks for the explanation, probably not particularly important
i thought that if a caller wanted to get a copy / take ownership 
it would just **accept** it by value, i.e. 
   auto path = change.getFilePath() /* assuming getFilePath returns const ref 
*/ 
At the same time if for example we need to check the filepath (or just print 
it),
not copies would be required:
   llvm::errs() << change.getFilePath();


https://reviews.llvm.org/D27054



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


Re: r296453 - [clang-format] Fix test failure caused by "rm" on some buildbots.

2017-02-28 Thread Nico Weber via cfe-commits
It's needed: when clang-format does leave temp files behind, they will
accumulate over builds and even if that's then fixed, the test would still
fail because of the temp files from prior builds. Thankfully, takuni fixed
this better in r296460.

On Feb 28, 2017 4:14 AM, "Haojian Wu via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

> Author: hokein
> Date: Tue Feb 28 03:03:07 2017
> New Revision: 296453
>
> URL: http://llvm.org/viewvc/llvm-project?rev=296453&view=rev
> Log:
> [clang-format] Fix test failure caused by "rm" on some buildbots.
>
> The begining command "rm" will return 1 when there is not such file to
> delete.
>
> This patch is to remove it, as it's not needed for the test.
>
> Modified:
> cfe/trunk/test/Format/inplace.cpp
>
> Modified: cfe/trunk/test/Format/inplace.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Format/
> inplace.cpp?rev=296453&r1=296452&r2=296453&view=diff
> 
> ==
> --- cfe/trunk/test/Format/inplace.cpp (original)
> +++ cfe/trunk/test/Format/inplace.cpp Tue Feb 28 03:03:07 2017
> @@ -1,6 +1,5 @@
>  // Regression test to check that clang-format does not leave behind
> temporary
>  // files on Windows when doing in-place formatting.
> -// RUN: rm %T/inplace*
>  // RUN: cp %s %T/inplace.cpp
>  // RUN: clang-format -style=LLVM -i %T/inplace.cpp
>  // RUN: ls %T > %T/files.txt
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27753: [analyzer] alpha.security.DirtyScalar Checker

2017-02-28 Thread Zoltán Gera via Phabricator via cfe-commits
gerazo marked an inline comment as done.
gerazo added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/DirtyScalarChecker.cpp:184
+Ty = Ctx.IntTy;
+  if (!Ty->isIntegerType() || Ctx.getIntWidth(Ty) <= TooNarrowForBoundCheck)
+return false;

a.sidorin wrote:
> Does the second check means that we exclude boolean and char values? I cannot 
> find any reason to do it for chars.
Yes, we exclude them.
Using lookup tables especially in cryptography sometimes involve reading a 
value from disk and than using this value immediately with a table lookup. This 
way, you use a dirty value directly in array indexing. Reading a byte and using 
it on a prepared 256 element table is common. As the read value gets bigger it 
is less performant and hence less common to do it.
I've found exactly 1 false positive in openssl without this exclusion.


https://reviews.llvm.org/D27753



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


[PATCH] D27054: Introducing clang::tooling::AtomicChange for refactoring tools.

2017-02-28 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: include/clang/Tooling/Refactoring/AtomicChange.h:59
+  /// \brief Returns the path of the file containing this atomic change.
+  std::string getFilePath() const { return FilePath; }
+

alexshap wrote:
> ioeric wrote:
> > alexshap wrote:
> > > i assume i might be missing smth - why here and above (in getKey, 
> > > getFilePath, getError) std::string is returned by value  ?
> > Otherwise, users would need to worry about the lifetimes of the object. And 
> > these methods are not expected to be called intensively, so performance is 
> > not an issue.
> i see, thanks for the explanation, probably not particularly important
> i thought that if a caller wanted to get a copy / take ownership 
> it would just **accept** it by value, i.e. 
>auto path = change.getFilePath() /* assuming getFilePath returns const ref 
> */ 
> At the same time if for example we need to check the filepath (or just print 
> it),
> not copies would be required:
>llvm::errs() << change.getFilePath();
I don't really have strong opinion about this. Another thing I was considering 
is whether the returned value always has an associated object in the class. For 
example, `getError` might return `Error` plus some extra message so that the 
return string can't be a reference. But these interfaces look pretty stable for 
now. And your examples make sense. Changed them to const ref instead.


https://reviews.llvm.org/D27054



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


[PATCH] D27054: Introducing clang::tooling::AtomicChange for refactoring tools.

2017-02-28 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 90018.
ioeric marked 3 inline comments as done.
ioeric added a comment.

- Return const refs in getXXX.


https://reviews.llvm.org/D27054

Files:
  include/clang/Tooling/Refactoring/AtomicChange.h
  lib/Tooling/CMakeLists.txt
  lib/Tooling/Refactoring/AtomicChange.cpp
  lib/Tooling/Refactoring/CMakeLists.txt
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -26,6 +26,7 @@
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/Refactoring/AtomicChange.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/SmallString.h"
 #include "gtest/gtest.h"
@@ -102,10 +103,10 @@
 
 // Checks that an llvm::Error instance contains a ReplacementError with expected
 // error code, expected new replacement, and expected existing replacement.
-static bool checkReplacementError(
-llvm::Error&& Error, replacement_error ExpectedErr,
-llvm::Optional ExpectedExisting,
-llvm::Optional ExpectedNew) {
+static bool checkReplacementError(llvm::Error &&Error,
+  replacement_error ExpectedErr,
+  llvm::Optional ExpectedExisting,
+  llvm::Optional ExpectedNew) {
   if (!Error) {
 llvm::errs() << "Error is a success.";
 return false;
@@ -1089,5 +1090,187 @@
   EXPECT_TRUE(FileToReplaces.empty());
 }
 
+class AtomicChangeTest : public ::testing::Test {
+  protected:
+void setUp() {
+  DefaultFileID = Context.createInMemoryFile("input.cpp", DefaultCode);
+  DefaultLoc = Context.Sources.getLocForStartOfFile(DefaultFileID)
+   .getLocWithOffset(20);
+  assert(DefaultLoc.isValid() && "Default location must be valid.");
+}
+
+RewriterTestContext Context;
+std::string DefaultCode = std::string(100, 'a');
+unsigned DefaultOffset = 20;
+SourceLocation DefaultLoc;
+FileID DefaultFileID;
+};
+
+TEST_F(AtomicChangeTest, AtomicChangeToYAML) {
+  setUp();
+  AtomicChange Change(Context.Sources, DefaultLoc);
+  llvm::Error Err =
+  Change.insert(Context.Sources, DefaultLoc, "aa", /*InsertAfter=*/false);
+  ASSERT_TRUE(!Err);
+  Err = Change.insert(Context.Sources, DefaultLoc.getLocWithOffset(10), "bb",
+/*InsertAfter=*/false);
+  ASSERT_TRUE(!Err);
+  Change.addHeader("a.h");
+  Change.removeHeader("b.h");
+  std::string YAMLString = Change.toYAMLString();
+
+  // NOTE: If this test starts to fail for no obvious reason, check whitespace.
+  ASSERT_STREQ("---\n"
+   "Key: 'input.cpp:20'\n"
+   "FilePath:input.cpp\n"
+   "Error:   ''\n"
+   "InsertedHeaders: [ a.h ]\n"
+   "RemovedHeaders:  [ b.h ]\n"
+   "Replacements:\n" // Extra whitespace here!
+   "  - FilePath:input.cpp\n"
+   "Offset:  20\n"
+   "Length:  0\n"
+   "ReplacementText: aa\n"
+   "  - FilePath:input.cpp\n"
+   "Offset:  30\n"
+   "Length:  0\n"
+   "ReplacementText: bb\n"
+   "...\n",
+   YAMLString.c_str());
+}
+
+TEST_F(AtomicChangeTest, YAMLToAtomicChange) {
+  setUp();
+  std::string YamlContent = "---\n"
+"Key: 'input.cpp:20'\n"
+"FilePath:input.cpp\n"
+"Error:   'ok'\n"
+"InsertedHeaders: [ a.h ]\n"
+"RemovedHeaders:  [ b.h ]\n"
+"Replacements:\n" // Extra whitespace here!
+"  - FilePath:input.cpp\n"
+"Offset:  20\n"
+"Length:  0\n"
+"ReplacementText: aa\n"
+"  - FilePath:input.cpp\n"
+"Offset:  30\n"
+"Length:  0\n"
+"ReplacementText: bb\n"
+"...\n";
+  AtomicChange ExpectedChange(Context.Sources, DefaultLoc);
+  llvm::Error Err = ExpectedChange.insert(Context.Sources, DefaultLoc, "aa",
+/*InsertAfter=*/false);
+  ASSERT_TRUE(!Err);
+  Err = ExpectedChange.insert(Context.Sources, DefaultLoc.getLocWithOffset(10),
+"bb", /*InsertAfter=*/false);
+  ASSERT_TRUE(!Err);
+
+  ExpectedChange.addHeader("a.h");
+  ExpectedChange.removeHeader("b.h");
+  Expecte

[clang-tools-extra] r296472 - Misspelled checker description (argument comment)

2017-02-28 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Tue Feb 28 08:13:26 2017
New Revision: 296472

URL: http://llvm.org/viewvc/llvm-project?rev=296472&view=rev
Log:
Misspelled checker description (argument comment)

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: Eugene.Zelenko

Tags: #clang-tools-extra

Patch by Peter Szecsi!

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

Modified:
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-argument-comment.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-argument-comment.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-argument-comment.rst?rev=296472&r1=296471&r2=296472&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-argument-comment.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-argument-comment.rst 
Tue Feb 28 08:13:26 2017
@@ -24,5 +24,6 @@ Options
 
 .. option:: StrictMode
 
-   When non-zero, the check will ignore leading and trailing underscores and
-   case when comparing parameter names.
+   When zero (default value), the check will ignore leading and trailing
+   underscores and case when comparing names -- otherwise they are taken into
+   account.


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


[PATCH] D29818: [libcxx] Threading support: Attempt to externalize system_clock::now() and steady_clock::now() implementations

2017-02-28 Thread Asiri Rathnayake via Phabricator via cfe-commits
rmaprath updated this revision to Diff 90025.
rmaprath added a comment.

Fixed minor omission.


https://reviews.llvm.org/D29818

Files:
  src/chrono.cpp


Index: src/chrono.cpp
===
--- src/chrono.cpp
+++ src/chrono.cpp
@@ -11,6 +11,7 @@
 #include "cerrno"// errno
 #include "system_error"  // __throw_system_error
 #include // clock_gettime, CLOCK_MONOTONIC and CLOCK_REALTIME
+#include "__threading_support"
 
 #if (__APPLE__)
 #if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
@@ -50,7 +51,8 @@
 #if !defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK)
 #if __APPLE__
 #include   // mach_absolute_time, mach_timebase_info_data_t
-#elif !defined(_LIBCPP_WIN32API) && !defined(CLOCK_MONOTONIC)
+#elif !defined(_LIBCPP_WIN32API) && !defined(CLOCK_MONOTONIC) && \
+  !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
 #error "Monotonic clock not implemented"
 #endif
 #endif
@@ -67,7 +69,12 @@
 system_clock::time_point
 system_clock::now() _NOEXCEPT
 {
-#if defined(_LIBCPP_WIN32API)
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+struct timespec tp;
+if (0 != __libcpp_clock_realtime(&tp))
+__throw_system_error(errno, "__libcpp_clock_realtime() failed");
+return time_point(seconds(tp.tv_sec) + microseconds(tp.tv_nsec / 1000));
+#elif defined(_LIBCPP_WIN32API)
   // FILETIME is in 100ns units
   using filetime_duration =
   _VSTD::chrono::duration<__int64,
@@ -91,8 +98,8 @@
   filetime_duration d{(static_cast<__int64>(ft.dwHighDateTime) << 32) |
static_cast<__int64>(ft.dwLowDateTime)};
   return time_point(duration_cast(d - nt_to_unix_epoch));
-#else
-#if defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_REALTIME)
+
+#elif defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_REALTIME)
 struct timespec tp;
 if (0 != clock_gettime(CLOCK_REALTIME, &tp))
 __throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed");
@@ -102,7 +109,6 @@
 gettimeofday(&tv, 0);
 return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
 #endif // _LIBCXX_USE_CLOCK_GETTIME && CLOCK_REALTIME
-#endif
 }
 
 time_t
@@ -126,7 +132,18 @@
 
 const bool steady_clock::is_steady;
 
-#if defined(__APPLE__)
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+
+steady_clock::time_point
+steady_clock::now() _NOEXCEPT
+{
+struct timespec tp;
+if (0 != __libcpp_clock_monotonic(&tp))
+__throw_system_error(errno, "__libcpp_clock_monotonic() failed");
+return time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));
+}
+
+#elif defined(__APPLE__)
 
 // Darwin libc versions >= 1133 provide ns precision via CLOCK_UPTIME_RAW
 #if defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_UPTIME_RAW)


Index: src/chrono.cpp
===
--- src/chrono.cpp
+++ src/chrono.cpp
@@ -11,6 +11,7 @@
 #include "cerrno"// errno
 #include "system_error"  // __throw_system_error
 #include // clock_gettime, CLOCK_MONOTONIC and CLOCK_REALTIME
+#include "__threading_support"
 
 #if (__APPLE__)
 #if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
@@ -50,7 +51,8 @@
 #if !defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK)
 #if __APPLE__
 #include   // mach_absolute_time, mach_timebase_info_data_t
-#elif !defined(_LIBCPP_WIN32API) && !defined(CLOCK_MONOTONIC)
+#elif !defined(_LIBCPP_WIN32API) && !defined(CLOCK_MONOTONIC) && \
+  !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
 #error "Monotonic clock not implemented"
 #endif
 #endif
@@ -67,7 +69,12 @@
 system_clock::time_point
 system_clock::now() _NOEXCEPT
 {
-#if defined(_LIBCPP_WIN32API)
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+struct timespec tp;
+if (0 != __libcpp_clock_realtime(&tp))
+__throw_system_error(errno, "__libcpp_clock_realtime() failed");
+return time_point(seconds(tp.tv_sec) + microseconds(tp.tv_nsec / 1000));
+#elif defined(_LIBCPP_WIN32API)
   // FILETIME is in 100ns units
   using filetime_duration =
   _VSTD::chrono::duration<__int64,
@@ -91,8 +98,8 @@
   filetime_duration d{(static_cast<__int64>(ft.dwHighDateTime) << 32) |
static_cast<__int64>(ft.dwLowDateTime)};
   return time_point(duration_cast(d - nt_to_unix_epoch));
-#else
-#if defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_REALTIME)
+
+#elif defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_REALTIME)
 struct timespec tp;
 if (0 != clock_gettime(CLOCK_REALTIME, &tp))
 __throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed");
@@ -102,7 +109,6 @@
 gettimeofday(&tv, 0);
 return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
 #endif // _LIBCXX_USE_CLOCK_GETTIME && CLOCK_REALTIME
-#endif
 }
 
 time_t
@@ -126,7 +132,18 @@
 
 const bool steady_clock::is_steady;
 
-#if defined(__APPLE__)
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
+
+steady_clock::time_point
+steady_clock::now() _NOEXCEPT
+{
+struct timespec tp;
+if (0 != __

[PATCH] D30459: [libcxxabi] Clean up macro usage

2017-02-28 Thread Ranjeet Singh via Phabricator via cfe-commits
rs created this revision.
Herald added a subscriber: mgorny.

Convention in libcxxabi is to use !defined(FOO) not !FOO.


https://reviews.llvm.org/D30459

Files:
  CMakeLists.txt
  include/__cxxabi_config.h
  include/cxxabi.h
  src/abort_message.cpp
  src/config.h
  src/cxa_default_handlers.cpp
  src/cxa_exception.cpp
  src/cxa_exception.hpp
  src/cxa_personality.cpp

Index: src/cxa_personality.cpp
===
--- src/cxa_personality.cpp
+++ src/cxa_personality.cpp
@@ -317,7 +317,7 @@
 std::terminate();
 }
 
-#if LIBCXXABI_ARM_EHABI
+#if defined(LIBCXXABI_ARM_EHABI)
 static const void* read_target2_value(const void* ptr)
 {
 uintptr_t offset = *reinterpret_cast(ptr);
@@ -328,7 +328,7 @@
 // deferred to the linker. For bare-metal they turn into absolute
 // relocations. For linux they turn into GOT-REL relocations."
 // https://gcc.gnu.org/ml/gcc-patches/2009-08/msg00264.html
-#if LIBCXXABI_BAREMETAL
+#if defined(LIBCXXABI_BAREMETAL)
 return reinterpret_cast(reinterpret_cast(ptr) +
  offset);
 #else
@@ -358,7 +358,7 @@
 return reinterpret_cast(
 read_target2_value(ttypePtr));
 }
-#else // !LIBCXXABI_ARM_EHABI
+#else // !defined(LIBCXXABI_ARM_EHABI
 static
 const __shim_type_info*
 get_shim_type_info(uint64_t ttypeIndex, const uint8_t* classInfo,
@@ -394,7 +394,7 @@
 classInfo -= ttypeIndex;
 return (const __shim_type_info*)readEncodedPointer(&classInfo, ttypeEncoding);
 }
-#endif // !LIBCXXABI_ARM_EHABI
+#endif // !defined(LIBCXXABI_ARM_EHABI)
 
 /*
 This is checking a thrown exception type, excpType, against a possibly empty
@@ -405,7 +405,7 @@
 the list will catch a excpType.  If any catchType in the list can catch an
 excpType, then this exception spec does not catch the excpType.
 */
-#if LIBCXXABI_ARM_EHABI
+#if defined(LIBCXXABI_ARM_EHABI)
 static
 bool
 exception_spec_can_catch(int64_t specIndex, const uint8_t* classInfo,
@@ -934,7 +934,7 @@
 Else a cleanup is not found: return _URC_CONTINUE_UNWIND
 */
 
-#if !LIBCXXABI_ARM_EHABI
+#if !defined(LIBCXXABI_ARM_EHABI)
 _LIBCXXABI_FUNC_VIS _Unwind_Reason_Code
 #ifdef __USING_SJLJ_EXCEPTIONS__
 __gxx_personality_sj0
@@ -1194,7 +1194,7 @@
 u_handler = old_exception_header->unexpectedHandler;
 // If std::__unexpected(u_handler) rethrows the same exception,
 //   these values get overwritten by the rethrow.  So save them now:
-#if LIBCXXABI_ARM_EHABI
+#if defined(LIBCXXABI_ARM_EHABI)
 ttypeIndex = (int64_t)(int32_t)unwind_exception->barrier_cache.bitpattern[4];
 lsda = (const uint8_t*)unwind_exception->barrier_cache.bitpattern[2];
 #else
Index: src/cxa_exception.hpp
===
--- src/cxa_exception.hpp
+++ src/cxa_exception.hpp
@@ -27,7 +27,7 @@
 static const uint64_t get_vendor_and_language = 0xFF00; // mask for CLNGC++
 
 struct __cxa_exception {
-#if defined(__LP64__) || LIBCXXABI_ARM_EHABI
+#if defined(__LP64__) || defined(LIBCXXABI_ARM_EHABI)
 // This is a new field to support C++ 0x exception_ptr.
 // For binary compatibility it is at the start of this
 // struct which is prepended to the object thrown in
@@ -45,7 +45,7 @@
 
 int handlerCount;
 
-#if LIBCXXABI_ARM_EHABI
+#if defined(LIBCXXABI_ARM_EHABI)
 __cxa_exception* nextPropagatingException;
 int propagationCount;
 #else
@@ -56,7 +56,7 @@
 void *adjustedPtr;
 #endif
 
-#if !defined(__LP64__) && !LIBCXXABI_ARM_EHABI
+#if !defined(__LP64__) && !defined(LIBCXXABI_ARM_EHABI)
 // This is a new field to support C++ 0x exception_ptr.
 // For binary compatibility it is placed where the compiler
 // previously adding padded to 64-bit align unwindHeader.
@@ -70,7 +70,7 @@
 // The layout of this structure MUST match the layout of __cxa_exception, with
 // primaryException instead of referenceCount.
 struct __cxa_dependent_exception {
-#if defined(__LP64__) || LIBCXXABI_ARM_EHABI
+#if defined(__LP64__) || defined(LIBCXXABI_ARM_EHABI)
 void* primaryException;
 #endif
 
@@ -83,7 +83,7 @@
 
 int handlerCount;
 
-#if LIBCXXABI_ARM_EHABI
+#if defined(LIBCXXABI_ARM_EHABI)
 __cxa_exception* nextPropagatingException;
 int propagationCount;
 #else
@@ -94,7 +94,7 @@
 void *adjustedPtr;
 #endif
 
-#if !defined(__LP64__) && !LIBCXXABI_ARM_EHABI
+#if !defined(__LP64__) && !defined(LIBCXXABI_ARM_EHABI)
 void* primaryException;
 #endif
 
@@ -104,7 +104,7 @@
 struct __cxa_eh_globals {
 __cxa_exception *   caughtExceptions;
 unsigned intuncaughtExceptions;
-#if LIBCXXABI_ARM_EHABI
+#if defined(LIBCXXABI_ARM_EHABI)
 __cxa_exception* propagatingExceptions;
 #endif
 };
Index: src/cxa_exception.cpp
===
--- src/cxa_exception.cpp
+++ src/cxa_exception.cpp
@@ -237,16 +237,16 @@
 */
 _LIBCXXABI_FUNC_VIS
 void *__cxa_get_e

r296477 - [Sema] Detect more array index out of bounds when C++ overloaded operators are used

2017-02-28 Thread Daniel Marjamaki via cfe-commits
Author: danielmarjamaki
Date: Tue Feb 28 08:53:50 2017
New Revision: 296477

URL: http://llvm.org/viewvc/llvm-project?rev=296477&view=rev
Log:
[Sema] Detect more array index out of bounds when C++ overloaded operators are 
used

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

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/SemaCXX/array-bounds.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=296477&r1=296476&r2=296477&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Feb 28 08:53:50 2017
@@ -10609,6 +10609,12 @@ void Sema::CheckArrayAccess(const Expr *
   CheckArrayAccess(rhs);
 return;
   }
+  case Stmt::CXXOperatorCallExprClass: {
+const auto *OCE = cast(expr);
+for (const auto *Arg : OCE->arguments())
+  CheckArrayAccess(Arg);
+return;
+  }
   default:
 return;
 }

Modified: cfe/trunk/test/SemaCXX/array-bounds.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/array-bounds.cpp?rev=296477&r1=296476&r2=296477&view=diff
==
--- cfe/trunk/test/SemaCXX/array-bounds.cpp (original)
+++ cfe/trunk/test/SemaCXX/array-bounds.cpp Tue Feb 28 08:53:50 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify -std=c++11 %s
 
 int foo() {
   int x[2]; // expected-note 4 {{array 'x' declared here}}
@@ -253,3 +253,19 @@ void test_rdar10916006(void)
int a[128]; // expected-note {{array 'a' declared here}}
a[(unsigned char)'\xA1'] = 1; // expected-warning {{array index 161 is 
past the end of the array}}
 }
+
+struct P {
+  int a;
+  int b;
+};
+
+void test_struct_array_index() {
+  struct P p[10]; // expected-note {{array 'p' declared here}}
+  p[11] = {0, 1}; // expected-warning {{array index 11 is past the end of the 
array (which contains 10 elements)}}
+}
+
+int operator+(const struct P &s1, const struct P &s2);
+int test_operator_overload_struct_array_index() {
+  struct P x[10] = {0}; // expected-note {{array 'x' declared here}}
+  return x[1] + x[11]; // expected-warning {{array index 11 is past the end of 
the array (which contains 10 elements)}}
+}


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


[PATCH] D30192: [Sema] Detecting more array index out of bounds

2017-02-28 Thread Daniel Marjamäki via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296477: [Sema] Detect more array index out of bounds when 
C++ overloaded operators are… (authored by danielmarjamaki).

Changed prior to commit:
  https://reviews.llvm.org/D30192?vs=89183&id=90027#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30192

Files:
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/SemaCXX/array-bounds.cpp


Index: cfe/trunk/test/SemaCXX/array-bounds.cpp
===
--- cfe/trunk/test/SemaCXX/array-bounds.cpp
+++ cfe/trunk/test/SemaCXX/array-bounds.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify -std=c++11 %s
 
 int foo() {
   int x[2]; // expected-note 4 {{array 'x' declared here}}
@@ -253,3 +253,19 @@
int a[128]; // expected-note {{array 'a' declared here}}
a[(unsigned char)'\xA1'] = 1; // expected-warning {{array index 161 is 
past the end of the array}}
 }
+
+struct P {
+  int a;
+  int b;
+};
+
+void test_struct_array_index() {
+  struct P p[10]; // expected-note {{array 'p' declared here}}
+  p[11] = {0, 1}; // expected-warning {{array index 11 is past the end of the 
array (which contains 10 elements)}}
+}
+
+int operator+(const struct P &s1, const struct P &s2);
+int test_operator_overload_struct_array_index() {
+  struct P x[10] = {0}; // expected-note {{array 'x' declared here}}
+  return x[1] + x[11]; // expected-warning {{array index 11 is past the end of 
the array (which contains 10 elements)}}
+}
Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -10609,6 +10609,12 @@
   CheckArrayAccess(rhs);
 return;
   }
+  case Stmt::CXXOperatorCallExprClass: {
+const auto *OCE = cast(expr);
+for (const auto *Arg : OCE->arguments())
+  CheckArrayAccess(Arg);
+return;
+  }
   default:
 return;
 }


Index: cfe/trunk/test/SemaCXX/array-bounds.cpp
===
--- cfe/trunk/test/SemaCXX/array-bounds.cpp
+++ cfe/trunk/test/SemaCXX/array-bounds.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify -std=c++11 %s
 
 int foo() {
   int x[2]; // expected-note 4 {{array 'x' declared here}}
@@ -253,3 +253,19 @@
 	int a[128]; // expected-note {{array 'a' declared here}}
 	a[(unsigned char)'\xA1'] = 1; // expected-warning {{array index 161 is past the end of the array}}
 }
+
+struct P {
+  int a;
+  int b;
+};
+
+void test_struct_array_index() {
+  struct P p[10]; // expected-note {{array 'p' declared here}}
+  p[11] = {0, 1}; // expected-warning {{array index 11 is past the end of the array (which contains 10 elements)}}
+}
+
+int operator+(const struct P &s1, const struct P &s2);
+int test_operator_overload_struct_array_index() {
+  struct P x[10] = {0}; // expected-note {{array 'x' declared here}}
+  return x[1] + x[11]; // expected-warning {{array index 11 is past the end of the array (which contains 10 elements)}}
+}
Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -10609,6 +10609,12 @@
   CheckArrayAccess(rhs);
 return;
   }
+  case Stmt::CXXOperatorCallExprClass: {
+const auto *OCE = cast(expr);
+for (const auto *Arg : OCE->arguments())
+  CheckArrayAccess(Arg);
+return;
+  }
   default:
 return;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r296453 - [clang-format] Fix test failure caused by "rm" on some buildbots.

2017-02-28 Thread Haojian Wu via cfe-commits
Oops, I should have read the patch more thoroughly, sorry for it. Thanks
for the explanation.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30341: [analyzer] clarify error messages about uninitialized function arguments

2017-02-28 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki updated this revision to Diff 90030.
danielmarjamaki added a comment.

minor updates. Use llvm::getOrdinalNumber(). Use llvm::Twine.


Repository:
  rL LLVM

https://reviews.llvm.org/D30341

Files:
  lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
  test/Analysis/NewDelete-checker-test.cpp
  test/Analysis/diagnostics/undef-value-param.m
  test/Analysis/malloc.m
  test/Analysis/misc-ps-region-store.m
  test/Analysis/misc-ps.m
  test/Analysis/null-deref-ps.c
  test/Analysis/nullptr.cpp
  test/Analysis/uninit-const.c
  test/Analysis/uninit-const.cpp
  test/Analysis/uninit-msg-expr.m
  test/Analysis/uninit-vals-ps.c
  test/Analysis/uninit-vals.cpp

Index: test/Analysis/uninit-vals.cpp
===
--- test/Analysis/uninit-vals.cpp
+++ test/Analysis/uninit-vals.cpp
@@ -27,7 +27,7 @@
   // case with undefined values, too.
   c1.b.a = c2->b.a;
 #else
-  c1.b.a = c2->b.a; // expected-warning{{Function call argument is an uninitialized value}}
+  c1.b.a = c2->b.a; // expected-warning{{1st function call argument is an uninitialized value}}
 #endif
 }
 }
Index: test/Analysis/uninit-vals-ps.c
===
--- test/Analysis/uninit-vals-ps.c
+++ test/Analysis/uninit-vals-ps.c
@@ -14,7 +14,7 @@
 
 int f1_b() {
   int x;
-  return bar(x)+1;  // expected-warning{{Function call argument is an uninitialized value}}
+  return bar(x)+1;  // expected-warning{{1st function call argument is an uninitialized value}}
 }
 
 int f2() {
Index: test/Analysis/uninit-msg-expr.m
===
--- test/Analysis/uninit-msg-expr.m
+++ test/Analysis/uninit-msg-expr.m
@@ -52,5 +52,5 @@
 void f3() {
   NSMutableArray *aArray = [NSArray array];
   NSString *aString;
-  [aArray addObject:aString]; // expected-warning {{Argument in message expression is an uninitialized value}}
+  [aArray addObject:aString]; // expected-warning {{1st argument in message expression is an uninitialized value}}
 }
Index: test/Analysis/uninit-const.cpp
===
--- test/Analysis/uninit-const.cpp
+++ test/Analysis/uninit-const.cpp
@@ -66,8 +66,8 @@
   int &p = t;
   int &s = p;
   int &q = s;  //expected-note {{'q' initialized here}}
-  doStuff6(q); //expected-warning {{Function call argument is an uninitialized value}}
-   //expected-note@-1 {{Function call argument is an uninitialized value}}
+  doStuff6(q); //expected-warning {{1st function call argument is an uninitialized value}}
+   //expected-note@-1 {{1st function call argument is an uninitialized value}}
 }
 
 void doStuff6_3(int& q_, int *ptr_) {}
@@ -78,32 +78,32 @@
   int &p = t;
   int &s = p;
   int &q = s;
-  doStuff6_3(q,ptr); //expected-warning {{Function call argument is an uninitialized value}}
-   //expected-note@-1 {{Function call argument is an uninitialized value}}
+  doStuff6_3(q,ptr); //expected-warning {{2nd function call argument is an uninitialized value}}
+   //expected-note@-1 {{2nd function call argument is an uninitialized value}}
 
 }
 
 void f6(void) {
   int k;   // expected-note {{'k' declared without an initial value}}
-  doStuff6(k); // expected-warning {{Function call argument is an uninitialized value}}
-   // expected-note@-1 {{Function call argument is an uninitialized value}}
+  doStuff6(k); // expected-warning {{1st function call argument is an uninitialized value}}
+   // expected-note@-1 {{1st function call argument is an uninitialized value}}
 
 }
 
 
 
 void f5(void) {
   int t;
   int* tp = &t;// expected-note {{'tp' initialized here}}
-  doStuff_uninit(tp);  // expected-warning {{Function call argument is a pointer to uninitialized value}}
-   // expected-note@-1 {{Function call argument is a pointer to uninitialized value}}
+  doStuff_uninit(tp);  // expected-warning {{1st function call argument is a pointer to uninitialized value}}
+   // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}}
 }
 
 
 void f4(void) {
   int y;// expected-note {{'y' declared without an initial value}}
-  doStuff4(y);  // expected-warning {{Function call argument is an uninitialized value}}
-// expected-note@-1 {{Function call argument is an uninitialized value}}
+  doStuff4(y);  // expected-warning {{1st function call argument is an uninitialized value}}
+// expected-note@-1 {{1st function call argument is an uninitialized value}}
 }
 
 void f3(void) {
@@ -123,6 +123,6 @@
 
 void f_uninit(void) {
   int x;
-  doStuff_uninit(&x);  // expected-warning {{Function call argument is a pointer to uninitialized value}}
-   // expected-note@-1 {{Function call argument is a pointer to uninitialized value}}
+  do

[PATCH] D30111: [clang-format] Add a test to check at once all the Mozilla coding style

2017-02-28 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

In https://reviews.llvm.org/D30111#688379, @sylvestre.ledru wrote:

> @krasimir is that ok with you?


Thank you for addressing my comments! The descriptions help to see what's 
supposed to happen.

Now another point with this test is that it tests that already Mozilla-valid 
source is not changed.
Maybe this is the right approach for a full style sanity test, I don't know.




Comment at: unittests/Format/check-coding-style-mozilla.cpp:77
+return mVar;
+  } // Tiny functions can be written in a single line.
+

Note that here the trailing comment will make a version of `TinyFunction` on a 
single line exceed the line limit.
If the comment is put before the definition of `TinyFunction`, it could really 
be made tiny, as in:
```
  // Tiny functions can be written in a single line.
  int TinyFunction() { return mVar; }
```


https://reviews.llvm.org/D30111



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


[PATCH] D30341: [analyzer] clarify error messages about uninitialized function arguments

2017-02-28 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki marked an inline comment as done.
danielmarjamaki added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp:211
   // Generate a report for this bug.
-  StringRef Desc =
-  describeUninitializedArgumentInCall(Call, IsFirstArgument);
+  std::string Desc =
+  describeUninitializedArgumentInCall(Call, ArgumentNumber);

zaks.anna wrote:
> Have you considered using  llvm::raw_svector_ostream here as well as passing 
> it an argument to describeUninitializedArgumentInCall? For example, see  
> MallocChecker.cpp.
I changed so describeUninitializedArgumentInCall() returns an llvm::Twine 
instead of std::string. hope you like it.



Repository:
  rL LLVM

https://reviews.llvm.org/D30341



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


[clang-tools-extra] r296479 - [clang-tidy] Fix a false positive on modernize-use-nullptr check.

2017-02-28 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue Feb 28 09:29:52 2017
New Revision: 296479

URL: http://llvm.org/viewvc/llvm-project?rev=296479&view=rev
Log:
[clang-tidy] Fix a false positive on modernize-use-nullptr check.

Summary:
The false positive happens on two neighbour CXXDefaultArgExpr AST nodes.
like below:

```
CXXFunctionalCastExpr 0x85c9670  'struct ZZ' functional cast to 
struct ZZ 
 `-CXXConstructExpr 0x85c9518  'struct ZZ' 'void (uint64, const 
uint64 *)'
   |-CallExpr 0x85a0a90  'uint64':'unsigned long long'
   | |-ImplicitCastExpr 0x85a0a78  'uint64 (*)(uint64)' 

   | | `-DeclRefExpr 0x85a09f0  'uint64 (uint64)' lvalue Function 
0x85a06a0 'Hash' 'uint64 (uint64)'
   | `-CXXDefaultArgExpr 0x85a0ac8 <> 'uint64':'unsigned long 
long'
   `-CXXDefaultArgExpr 0x85c94f8 <> 'const uint64 *'
```

For each particular CXXDefaultArgExpr node, we need to reset
FirstSubExpr, otherwise FirstSubExpr will refer to an incorrect expr.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: JDevlieghere, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp?rev=296479&r1=296478&r2=296479&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp Tue Feb 28 
09:29:52 2017
@@ -190,8 +190,10 @@ public:
   bool VisitStmt(Stmt *S) {
 auto *C = dyn_cast(S);
 // Catch the castExpr inside cxxDefaultArgExpr.
-if (auto *E = dyn_cast(S))
+if (auto *E = dyn_cast(S)) {
   C = dyn_cast(E->getExpr());
+  FirstSubExpr = nullptr;
+}
 if (!C) {
   FirstSubExpr = nullptr;
   return true;

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp?rev=296479&r1=296478&r2=296479&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp Tue Feb 
28 09:29:52 2017
@@ -228,3 +228,19 @@ struct D {
 void test_default_argument() {
   D(nullptr);
 }
+
+// Test on two neighbour CXXDefaultArgExprs nodes.
+typedef unsigned long long uint64;
+struct ZZ {
+  explicit ZZ(uint64, const uint64* = NULL) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:39: warning: use nullptr
+// CHECK-FIXES: explicit ZZ(uint64, const uint64* = nullptr) {}
+  operator bool()  { return true; }
+};
+
+uint64 Hash(uint64 seed = 0) { return 0; }
+
+void f() {
+  bool a;
+  a = ZZ(Hash());
+}


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


[PATCH] D30412: [clang-tidy] Fix a false positive on modernize-use-nullptr check.

2017-02-28 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296479: [clang-tidy] Fix a false positive on 
modernize-use-nullptr check. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D30412?vs=89894&id=90032#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30412

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp


Index: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
@@ -190,8 +190,10 @@
   bool VisitStmt(Stmt *S) {
 auto *C = dyn_cast(S);
 // Catch the castExpr inside cxxDefaultArgExpr.
-if (auto *E = dyn_cast(S))
+if (auto *E = dyn_cast(S)) {
   C = dyn_cast(E->getExpr());
+  FirstSubExpr = nullptr;
+}
 if (!C) {
   FirstSubExpr = nullptr;
   return true;
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
@@ -228,3 +228,19 @@
 void test_default_argument() {
   D(nullptr);
 }
+
+// Test on two neighbour CXXDefaultArgExprs nodes.
+typedef unsigned long long uint64;
+struct ZZ {
+  explicit ZZ(uint64, const uint64* = NULL) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:39: warning: use nullptr
+// CHECK-FIXES: explicit ZZ(uint64, const uint64* = nullptr) {}
+  operator bool()  { return true; }
+};
+
+uint64 Hash(uint64 seed = 0) { return 0; }
+
+void f() {
+  bool a;
+  a = ZZ(Hash());
+}


Index: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
@@ -190,8 +190,10 @@
   bool VisitStmt(Stmt *S) {
 auto *C = dyn_cast(S);
 // Catch the castExpr inside cxxDefaultArgExpr.
-if (auto *E = dyn_cast(S))
+if (auto *E = dyn_cast(S)) {
   C = dyn_cast(E->getExpr());
+  FirstSubExpr = nullptr;
+}
 if (!C) {
   FirstSubExpr = nullptr;
   return true;
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
@@ -228,3 +228,19 @@
 void test_default_argument() {
   D(nullptr);
 }
+
+// Test on two neighbour CXXDefaultArgExprs nodes.
+typedef unsigned long long uint64;
+struct ZZ {
+  explicit ZZ(uint64, const uint64* = NULL) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:39: warning: use nullptr
+// CHECK-FIXES: explicit ZZ(uint64, const uint64* = nullptr) {}
+  operator bool()  { return true; }
+};
+
+uint64 Hash(uint64 seed = 0) { return 0; }
+
+void f() {
+  bool a;
+  a = ZZ(Hash());
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30345: [CodeGen][Blocks] Refactor capture handling in code that generates block copy/destroy routines

2017-02-28 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 90033.
arphaman marked 3 inline comments as done.
arphaman added a comment.

The updated patch uses just one enum and simplifies the capture search loops.


Repository:
  rL LLVM

https://reviews.llvm.org/D30345

Files:
  lib/CodeGen/CGBlocks.cpp

Index: lib/CodeGen/CGBlocks.cpp
===
--- lib/CodeGen/CGBlocks.cpp
+++ lib/CodeGen/CGBlocks.cpp
@@ -1373,6 +1373,105 @@
   return fn;
 }
 
+namespace {
+
+/// Represents a type of copy/destroy operation that should be performed for an
+/// entity that's captured by a block.
+enum class BlockCaptureEntityType {
+  CXXRecord, // Copy or destroy
+  ARCWeak,
+  ARCStrong,
+  BlockObject, // Assign or release
+  None
+};
+
+/// Represents an entity captured by a block that requires custom operations
+/// to copy/release this entity.
+struct BlockCaptureManagedEntity {
+  BlockCaptureEntityType Type;
+  BlockFieldFlags Flags;
+  const BlockDecl::Capture &CI;
+  const CGBlockInfo::Capture &Capture;
+
+  BlockCaptureManagedEntity(BlockCaptureEntityType Type, BlockFieldFlags Flags,
+const BlockDecl::Capture &CI,
+const CGBlockInfo::Capture &Capture)
+  : Type(Type), Flags(Flags), CI(CI), Capture(Capture) {}
+};
+
+} // end anonymous namespace
+
+static std::pair
+computeCopyInfoForBlockCapture(const BlockDecl::Capture &CI, QualType Type,
+   const LangOptions &LangOpts) {
+  if (CI.getCopyExpr()) {
+assert(!CI.isByRef());
+// don't bother computing flags
+return std::make_pair(BlockCaptureEntityType::CXXRecord, BlockFieldFlags());
+  }
+  BlockFieldFlags Flags;
+  if (CI.isByRef()) {
+Flags = BLOCK_FIELD_IS_BYREF;
+if (Type.isObjCGCWeak())
+  Flags |= BLOCK_FIELD_IS_WEAK;
+return std::make_pair(BlockCaptureEntityType::BlockObject, Flags);
+  }
+  if (!Type->isObjCRetainableType())
+// For all other types, the memcpy is fine.
+return std::make_pair(BlockCaptureEntityType::None, Flags);
+
+  Flags = BLOCK_FIELD_IS_OBJECT;
+  bool isBlockPointer = Type->isBlockPointerType();
+  if (isBlockPointer)
+Flags = BLOCK_FIELD_IS_BLOCK;
+
+  // Special rules for ARC captures:
+  Qualifiers QS = Type.getQualifiers();
+
+  // We need to register __weak direct captures with the runtime.
+  if (QS.getObjCLifetime() == Qualifiers::OCL_Weak)
+return std::make_pair(BlockCaptureEntityType::ARCWeak, Flags);
+
+  // We need to retain the copied value for __strong direct captures.
+  if (QS.getObjCLifetime() == Qualifiers::OCL_Strong) {
+// If it's a block pointer, we have to copy the block and
+// assign that to the destination pointer, so we might as
+// well use _Block_object_assign.  Otherwise we can avoid that.
+return std::make_pair(!isBlockPointer ? BlockCaptureEntityType::ARCStrong
+  : BlockCaptureEntityType::BlockObject,
+  Flags);
+  }
+
+  // Non-ARC captures of retainable pointers are strong and
+  // therefore require a call to _Block_object_assign.
+  if (!QS.getObjCLifetime() && !LangOpts.ObjCAutoRefCount)
+return std::make_pair(BlockCaptureEntityType::BlockObject, Flags);
+
+  // Otherwise the memcpy is fine.
+  return std::make_pair(BlockCaptureEntityType::None, Flags);
+}
+
+/// Find the set of block captures that need to be explicitly copied or destroy.
+static void findBlockCapturedManagedEntities(
+const CGBlockInfo &BlockInfo, const LangOptions &LangOpts,
+SmallVectorImpl &ManagedCaptures,
+llvm::function_ref(
+const BlockDecl::Capture &, QualType, const LangOptions &)>
+Predicate) {
+  for (const auto &CI : BlockInfo.getBlockDecl()->captures()) {
+const VarDecl *Variable = CI.getVariable();
+QualType Type = Variable->getType();
+
+const CGBlockInfo::Capture &Capture = BlockInfo.getCapture(Variable);
+if (Capture.isConstant())
+  continue;
+
+auto Info = Predicate(CI, Type, LangOpts);
+if (Info.first != BlockCaptureEntityType::None)
+  ManagedCaptures.emplace_back(Info.first, Info.second, CI, Capture);
+  }
+}
+
 /// Generate the copy-helper function for a block closure object:
 ///   static void block_copy_helper(block_t *dst, block_t *src);
 /// The runtime will have previously initialized 'dst' by doing a
@@ -1431,78 +1530,28 @@
   dst = Address(Builder.CreateLoad(dst), blockInfo.BlockAlign);
   dst = Builder.CreateBitCast(dst, structPtrTy, "block.dest");
 
-  const BlockDecl *blockDecl = blockInfo.getBlockDecl();
-
-  for (const auto &CI : blockDecl->captures()) {
-const VarDecl *variable = CI.getVariable();
-QualType type = variable->getType();
-
-const CGBlockInfo::Capture &capture = blockInfo.getCapture(variable);
-if (capture.isConstant()) continue;
-
-const Expr *copyExpr = CI.getCopyExpr();
-BlockFieldFlags flags;
+  SmallVector CopiedCaptures;
+  findBlockCapturedMana

[PATCH] D30345: [CodeGen][Blocks] Refactor capture handling in code that generates block copy/destroy routines

2017-02-28 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: lib/CodeGen/CGBlocks.cpp:1414
+
+} // end anonymous namespace
+

vsk wrote:
> I don't see the need for two GenericInfo types (although it's plausible it'll 
> make sense with your upcoming changes!). I had in mind a single 'enum 
> BlockCaptureOperationType' with 8 entries, and a 'struct 
> BlockCaptureOperation'.
Agreed, fixed.


Repository:
  rL LLVM

https://reviews.llvm.org/D30345



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


[PATCH] D30268: Avoid copy of __atoms when char_type is char

2017-02-28 Thread Aditya Kumar via Phabricator via cfe-commits
hiraditya added a comment.

Ping


https://reviews.llvm.org/D30268



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


[PATCH] D30326: [MS-ABI] Allow #pragma section to choose for ZI data

2017-02-28 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

I'm surprised this is behind a flag. This pragma attempts to be compatible with 
cl.exe. Does cl.exe do this by default? If so, we should do it by default. If 
not, why add this as an incompatible thing to an MS extension instead of keying 
it off some attribute that works in non-MS mode too?


https://reviews.llvm.org/D30326



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


[PATCH] D29819: Introduce an 'external_source_symbol' attribute that describes the origin and the nature of a declaration

2017-02-28 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 90042.
arphaman marked 2 inline comments as done.
arphaman added a comment.

Use `ParseClangAttributeArgs` and add a string to an assert.


Repository:
  rL LLVM

https://reviews.llvm.org/D29819

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticCommonKinds.td
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Parse/Parser.h
  include/clang/Sema/AttributeList.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/Parser.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/Misc/ast-dump-attr.cpp
  test/Parser/attr-external-source-symbol-cxx11.cpp
  test/Parser/attr-external-source-symbol.m
  test/Sema/attr-external-source-symbol.c

Index: test/Sema/attr-external-source-symbol.c
===
--- /dev/null
+++ test/Sema/attr-external-source-symbol.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s
+
+void threeClauses() __attribute__((external_source_symbol(language="Swift", defined_in="module", generated_declaration)));
+
+void twoClauses() __attribute__((external_source_symbol(language="Swift", defined_in="module")));
+
+void fourClauses() __attribute__((external_source_symbol(language="Swift", defined_in="module", generated_declaration, generated_declaration))); // expected-error {{duplicate 'generated_declaration' clause in an 'external_source_symbol' attribute}}
+
+void oneClause() __attribute__((external_source_symbol(generated_declaration)));
+
+void noArguments()
+__attribute__((external_source_symbol)); // expected-error {{'external_source_symbol' attribute takes at least 1 argument}}
+
+void namedDeclsOnly() {
+  int (^block)(void) = ^ (void)
+__attribute__((external_source_symbol(language="Swift"))) { // expected-warning {{'external_source_symbol' attribute only applies to named declarations}}
+  return 1;
+  };
+}
Index: test/Parser/attr-external-source-symbol.m
===
--- /dev/null
+++ test/Parser/attr-external-source-symbol.m
@@ -0,0 +1,84 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void function() __attribute__((external_source_symbol(language="Swift", defined_in="module", generated_declaration)));
+
+__attribute__((external_source_symbol(language="Swift", defined_in="module")))
+@interface I
+
+- (void)method __attribute__((external_source_symbol(defined_in= "module")));
+
+@end
+
+enum E {
+  CaseA __attribute__((external_source_symbol(generated_declaration))),
+  CaseB __attribute__((external_source_symbol(generated_declaration, language="Swift")))
+} __attribute__((external_source_symbol(language = "Swift")));
+
+void f2()
+__attribute__((external_source_symbol())); // expected-error {{expected 'language', 'defined_in', or 'generated_declaration'}}
+void f3()
+__attribute__((external_source_symbol(invalid))); // expected-error {{expected 'language', 'defined_in', or 'generated_declaration'}}
+void f4()
+__attribute__((external_source_symbol(language))); // expected-error {{expected '=' after language}}
+void f5()
+__attribute__((external_source_symbol(language=))); // expected-error {{expected string literal for language name in 'external_source_symbol' attribute}}
+void f6()
+__attribute__((external_source_symbol(defined_in=20))); // expected-error {{expected string literal for source container name in 'external_source_symbol' attribute}}
+
+void f7()
+__attribute__((external_source_symbol(generated_declaration, generated_declaration))); // expected-error {{duplicate 'generated_declaration' clause in an 'external_source_symbol' attribute}}
+void f8()
+__attribute__((external_source_symbol(language="Swift", language="Swift"))); // expected-error {{duplicate 'language' clause in an 'external_source_symbol' attribute}}
+void f9()
+__attribute__((external_source_symbol(defined_in="module", language="Swift", defined_in="foo"))); // expected-error {{duplicate 'defined_in' clause in an 'external_source_symbol' attribute}}
+
+void f10()
+__attribute__((external_source_symbol(generated_declaration, language="Swift", defined_in="foo", generated_declaration, generated_declaration, language="Swift"))); // expected-error {{duplicate 'generated_declaration' clause in an 'external_source_symbol' attribute}}
+
+void f11()
+__attribute__((external_source_symbol(language="Objective-C++", defined_in="Some file with spaces")));
+
+void f12()
+__attribute__((external_source_symbol(language="C Sharp", defined_in="file:Hello world with spaces. cs")));
+
+void f13()
+__attribute__((external_source_symbol(language=Swift))); // expected-error {{expected string literal for language name in 'external_source_symbol' attribute}}
+
+void f14()
+__attribute__((external_source_symbol(=))); // expected-error {{expected 'language', 'defined_in', or 'generated_declaration'}}
+
+void f15()
+__attribute__((external_source_symbo

[PATCH] D29819: Introduce an 'external_source_symbol' attribute that describes the origin and the nature of a declaration

2017-02-28 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: lib/Parse/ParseDeclCXX.cpp:3818-3819
+  if (ScopeName && (ScopeName->getName() == "gnu" ||
+(ScopeName->getName() == "clang" &&
+ AttrName->isStr("external_source_symbol"
 // GNU-scoped attributes have some special cases to handle GNU-specific

aaron.ballman wrote:
> aaron.ballman wrote:
> > I don't really like hard-coding a list of attributes like this. I think you 
> > should handle clang-namespaced attributes with a separate helper function.
> This still isn't quite what I was looking for -- the helper function I was 
> talking about was a replacement for `ParseGNUAttributeArgs()`. I'm sorry if I 
> was unclear.
> 
> I think we should have a `ParseClangAttributeArgs()` that handles your custom 
> parsing; it can then call through to `ParseAttributeArgsCommon()` for common 
> argument handling in the same way `ParseGNUAttributeArgs()` does. So the 
> predicate would be `else if (ScopeName && ScopeName->getName() == "clang")`.
I see, I added `ParseClangAttributeArgs` in the updated patch.


Repository:
  rL LLVM

https://reviews.llvm.org/D29819



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


[PATCH] D27054: Introducing clang::tooling::AtomicChange for refactoring tools.

2017-02-28 Thread Manuel Klimek via Phabricator via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


https://reviews.llvm.org/D27054



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


[PATCH] D24933: Enable configuration files in clang

2017-02-28 Thread Derek Schuff via Phabricator via cfe-commits
dschuff added a comment.

Hello,
I work on WebAssembly toolchains (including emscripten, which is more or less 
the "cross-compiler SDK" use case). There's a lot of history in this review and 
I haven't looked at the details yet, but does the current summary text reflect 
the current proposal and/or content of the review?
Thanks!


https://reviews.llvm.org/D24933



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


[PATCH] D30465: [mips] Set the Int64Type / IntMaxType types correctly for OpenBSD/mips64

2017-02-28 Thread Brad Smith via Phabricator via cfe-commits
brad created this revision.

Set the Int64Type / IntMaxType types correctly for OpenBSD/mips64


Repository:
  rL LLVM

https://reviews.llvm.org/D30465

Files:
  lib/Basic/Targets.cpp
  test/Preprocessor/init.c


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -8766,6 +8766,8 @@
 // RUN: %clang_cc1 -E -dM -ffreestanding 
-triple=arm-unknown-openbsd6.1-gnueabi < /dev/null | FileCheck 
-match-full-lines -check-prefix OPENBSD %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=i386-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips64-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips64el-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc64-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
 // OPENBSD:#define __ELF__ 1
 // OPENBSD:#define __INT16_TYPE__ short
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -7577,7 +7577,11 @@
 
   void setN64ABITypes() {
 setN32N64ABITypes();
-Int64Type = SignedLong;
+if (getTriple().getOS() == llvm::Triple::OpenBSD) {
+  Int64Type = SignedLongLong;
+} else {
+  Int64Type = SignedLong;
+}
 IntMaxType = Int64Type;
 LongWidth = LongAlign = 64;
 PointerWidth = PointerAlign = 64;


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -8766,6 +8766,8 @@
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-unknown-openbsd6.1-gnueabi < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=i386-unknown-openbsd6.1 < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-unknown-openbsd6.1 < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips64-unknown-openbsd6.1 < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips64el-unknown-openbsd6.1 < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc64-unknown-openbsd6.1 < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
 // OPENBSD:#define __ELF__ 1
 // OPENBSD:#define __INT16_TYPE__ short
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -7577,7 +7577,11 @@
 
   void setN64ABITypes() {
 setN32N64ABITypes();
-Int64Type = SignedLong;
+if (getTriple().getOS() == llvm::Triple::OpenBSD) {
+  Int64Type = SignedLongLong;
+} else {
+  Int64Type = SignedLong;
+}
 IntMaxType = Int64Type;
 LongWidth = LongAlign = 64;
 PointerWidth = PointerAlign = 64;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30406: [Analyzer] Add support for displaying cross-file diagnostic paths in HTML output

2017-02-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added subscribers: a.sidorin, NoQ.
NoQ added a comment.

I think this is great. We've been hearing a lot of complaints on the mailing 
lists recently about that problem.

Did you check that scan-build properly de-duplicates cross-file reports that 
originate from different clang runs but point to the same header? With your 
approach i think it should work out of the box, but i'd rather be sure.

> It's not as immediately clear this is a multi-file output.

I'm still to have a closer look at the actual code, sorry for the delays.

I'm not having problems with that, i think. If you want to fix that, maybe a 
list of files at the header, with links to the beginning of each file, would be 
enough. Or maybe modify arrows between diagnostic pieces to highlight cases 
when they cross file boundaries: `<- 5. Calling foo() -> (into file foo.c)`.


https://reviews.llvm.org/D30406



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


[PATCH] D29221: clang-format-vsix: "format on save" feature

2017-02-28 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a subscriber: djasper.
hans added a comment.

>>> My only nit is that I'd prefer "clang-format" instead of "ClangFormat".
>>> 
>>> Manuel: the menu options under Tools currently say "Clang Format 
>>> {Selection,Document}". What do you think about using "clang-format" here 
>>> instead? That is the name of the tool after all, and I think it also works 
>>> nicely as a verb.
>>> 
>>> I realize the actual extension is called ClangFormat, but maybe there were 
>>> reasons for that, or we have to live with it?
>> 
>> I would also like clang-format in there rather than ClangFormat. One thing 
>> to validate is whether this change would mean people would lose their 
>> changes to the defaults in the configuration panel. I'll run some tests and 
>> see if this is indeed the case. Maybe there's a way to keep the internal 
>> name the same for config purposes, but change the displayed name instead. 
>> Will get back to you.
> 
> Okay, I looked into it, and the good news is that changing the name of the 
> category from ClangFormat to clang-format doesn't reset the previously saved 
> changes made in the options menu. I also changed the menu item names. Here's 
> what both would look like:
> 
> F3119242: pasted_file 
> 
> F3119244: pasted_file 
> 
> Now having said that, I'm not sure if this is the best change because of a 
> few things:
> 
> 1. The extension's name itself is ClangFormat, which was recently added to 
> the Visual Studio market place here: 
> https://marketplace.visualstudio.com/items?itemName=HansWennborg.ClangFormat 
> . Consequently, the extension appears with this name in the Visual Studio 
> extensions dialog: F3119249: pasted_file . 
> I don't think it would be easy to change this. You cannot really take down an 
> extension page on the marketplace once it's there; you'd have to document 
> that it has been deprecated and provide a link to a new page. When searching 
> for it in the Extensions dialog in VS, though, both the old and new extension 
> would show up.
> 2. Although the name of the executable is indeed "clang-format", the 
> documentation here  uses the 
> name ClangFormat: F3119251: pasted_file 
> 
>   So I leave it up to you whether you really want this change or not. We can 
> also decide later rather than fold it into this change.

Personally I think we should refer to the tool and the action of formatting as 
"clang-format" as much as possible. It's unfortunate we can't rename the 
extension, but maybe that slight inconsistency isn't the end of the world.

Manuel, Daniel: I'd like to hear your opinions here.


https://reviews.llvm.org/D29221



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


r296490 - Migrate all of aarch64-linux-gnu to \01_mcount instead of just when passing along gnueabi as this matches both gcc and what the kernel expects.

2017-02-28 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Tue Feb 28 11:22:05 2017
New Revision: 296490

URL: http://llvm.org/viewvc/llvm-project?rev=296490&view=rev
Log:
Migrate all of aarch64-linux-gnu to \01_mcount instead of just when passing 
along gnueabi as this matches both gcc and what the kernel expects.

More of PR27311

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Frontend/gnu-mcount.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=296490&r1=296489&r2=296490&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Feb 28 11:22:05 2017
@@ -5985,8 +5985,9 @@ public:
 // AArch64 targets default to using the ARM C++ ABI.
 TheCXXABI.set(TargetCXXABI::GenericAArch64);
 
-if (Triple.getOS() == llvm::Triple::Linux ||
-Triple.getOS() == llvm::Triple::UnknownOS)
+if (Triple.getOS() == llvm::Triple::Linux)
+  this->MCountName = "\01_mcount";
+else if (Triple.getOS() == llvm::Triple::UnknownOS)
   this->MCountName = Opts.EABIVersion == "gnu" ? "\01_mcount" : "mcount";
   }
 

Modified: cfe/trunk/test/Frontend/gnu-mcount.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/gnu-mcount.c?rev=296490&r1=296489&r2=296490&view=diff
==
--- cfe/trunk/test/Frontend/gnu-mcount.c (original)
+++ cfe/trunk/test/Frontend/gnu-mcount.c Tue Feb 28 11:22:05 2017
@@ -6,11 +6,11 @@
 // RUN: %clang -target aarch64-unknown-none-eabi -pg -meabi gnu -S -emit-llvm 
-o - %s | FileCheck %s -check-prefix CHECK -check-prefix 
CHECK-ARM64-EABI-MEABI-GNU
 // RUN: %clang -target armv7-unknown-linux-gnueabi -pg -S -emit-llvm -o - %s | 
FileCheck %s -check-prefix CHECK -check-prefix CHECK-ARM-EABI
 // RUN: %clang -target armv7-unknown-linux-gnueabi -meabi gnu -pg -S 
-emit-llvm -o - %s | FileCheck %s -check-prefix CHECK -check-prefix 
CHECK-ARM-EABI-MEABI-GNU
-// RUN: %clang -target aarch64-unknown-linux-gnueabi -pg -S -emit-llvm -o - %s 
| FileCheck %s -check-prefix CHECK -check-prefix CHECK-ARM64-EABI
+// RUN: %clang -target aarch64-unknown-linux-gnueabi -pg -S -emit-llvm -o - %s 
| FileCheck %s -check-prefix CHECK -check-prefix CHECK-ARM64-EABI-LINUX
 // RUN: %clang -target aarch64-unknown-linux-gnueabi -meabi gnu -pg -S 
-emit-llvm -o - %s | FileCheck %s -check-prefix CHECK -check-prefix 
CHECK-ARM64-EABI-MEABI-GNU
 // RUN: %clang -target armv7-unknown-linux-gnueabihf -pg -S -emit-llvm -o - %s 
| FileCheck %s -check-prefix CHECK -check-prefix CHECK-ARM-EABI
 // RUN: %clang -target armv7-unknown-linux-gnueabihf -meabi gnu -pg -S 
-emit-llvm -o - %s | FileCheck %s -check-prefix CHECK -check-prefix 
CHECK-ARM-EABI-MEABI-GNU
-// RUN: %clang -target aarch64-unknown-linux-gnueabihf -pg -S -emit-llvm -o - 
%s | FileCheck %s -check-prefix CHECK -check-prefix CHECK-ARM64-EABI
+// RUN: %clang -target aarch64-unknown-linux-gnueabihf -pg -S -emit-llvm -o - 
%s | FileCheck %s -check-prefix CHECK -check-prefix CHECK-ARM64-EABI-LINUX
 // RUN: %clang -target aarch64-unknown-linux-gnueabihf -meabi gnu -pg -S 
-emit-llvm -o - %s | FileCheck %s -check-prefix CHECK -check-prefix 
CHECK-ARM64-EABI-MEABI-GNU
 // RUN: %clang -target armv7-unknown-freebsd-gnueabihf -pg -S -emit-llvm -o - 
%s | FileCheck %s -check-prefix CHECK -check-prefix CHECK-ARM-EABI-FREEBSD
 // RUN: %clang -target armv7-unknown-freebsd-gnueabihf -meabi gnu -pg -S 
-emit-llvm -o - %s | FileCheck %s -check-prefix CHECK -check-prefix 
CHECK-ARM-EABI-FREEBSD
@@ -53,6 +53,7 @@ int f() {
 // CHECK-ARM64-EABI: attributes #{{[0-9]+}} = { 
{{.*}}"counting-function"="mcount"{{.*}} }
 // CHECK-ARM64-EABI-MEABI-GNU: attributes #{{[0-9]+}} = { 
{{.*}}"counting-function"="\01_mcount"{{.*}} }
 // CHECK-ARM64-EABI-NOT: attributes #{{[0-9]+}} = { 
{{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
+// CHECK-ARM64-EABI-LINUX: attributes #{{[0-9]+}} = { 
{{.*}}"counting-function"="\01_mcount"{{.*}} }
 // CHECK-ARM-EABI-FREEBSD: attributes #{{[0-9]+}} = { 
{{.*}}"counting-function"="__mcount"{{.*}} }
 // CHECK-ARM-EABI-FREEBSD-NOT: attributes #{{[0-9]+}} = { 
{{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
 // CHECK-ARM64-EABI-FREEBSD: attributes #{{[0-9]+}} = { 
{{.*}}"counting-function"=".mcount"{{.*}} }


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


r296485 - Driver: Update devtoolset usage for RHEL

2017-02-28 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Tue Feb 28 10:46:19 2017
New Revision: 296485

URL: http://llvm.org/viewvc/llvm-project?rev=296485&view=rev
Log:
Driver: Update devtoolset usage for RHEL

- remove path to dts-1.x (corresponds to gcc 4.7)
- add path to dts-6 (corresponds to 6.x)

Patch By: Maria Gottschalk

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

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

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=296485&r1=296484&r2=296485&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Tue Feb 28 10:46:19 2017
@@ -1438,11 +1438,10 @@ void Generic_GCC::GCCInstallationDetecto
 // Then look for distribution supplied gcc installations.
 if (D.SysRoot.empty()) {
   // Look for RHEL devtoolsets.
+  Prefixes.push_back("/opt/rh/devtoolset-6/root/usr");
   Prefixes.push_back("/opt/rh/devtoolset-4/root/usr");
   Prefixes.push_back("/opt/rh/devtoolset-3/root/usr");
   Prefixes.push_back("/opt/rh/devtoolset-2/root/usr");
-  Prefixes.push_back("/opt/rh/devtoolset-1.1/root/usr");
-  Prefixes.push_back("/opt/rh/devtoolset-1.0/root/usr");
   // And finally in /usr.
   Prefixes.push_back("/usr");
 }


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


[PATCH] D30111: [clang-format] Add a test to check at once all the Mozilla coding style

2017-02-28 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru updated this revision to Diff 90053.
Herald added a subscriber: mgorny.

https://reviews.llvm.org/D30111

Files:
  test/Format/check-coding-style-mozilla.cpp
  unittests/Format/CMakeLists.txt

Index: unittests/Format/CMakeLists.txt
===
--- unittests/Format/CMakeLists.txt
+++ unittests/Format/CMakeLists.txt
@@ -14,6 +14,7 @@
   NamespaceEndCommentsFixerTest.cpp
   SortImportsTestJS.cpp
   SortIncludesTest.cpp
+  check-coding-style-mozilla.cpp
   )
 
 target_link_libraries(FormatTests
Index: test/Format/check-coding-style-mozilla.cpp
===
--- test/Format/check-coding-style-mozilla.cpp
+++ test/Format/check-coding-style-mozilla.cpp
@@ -0,0 +1,130 @@
+// RUN: clang-format -style=Mozilla %s > %T/foo.cpp 2>&1
+// RUN: diff -u %s %T/foo.cpp
+// RUN: rm -rf %T/foo.cpp
+
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+if (true) {
+} else if (false) {
+} else {
+}
+
+while (true) {
+}
+
+do {
+} while (true);
+
+for (auto bar::in) {
+}
+
+switch (var) {
+  case 1: {
+// When you need to declare a variable in a switch, put the block in braces
+int var;
+break;
+  }
+  case 2:
+foo();
+break;
+  default:
+break;
+}
+
+namespace mozilla {
+
+class MyClass : public A
+{
+  void Myclass();
+};
+
+class MyClass : public X // When deriving from more than one class, put each on
+ // its own line.
+,
+public Y
+{
+public:
+  MyClass(int aVar, int aVar2)
+: mVar(aVar)
+, mVar2(aVar2)
+  {
+foo();
+  }
+
+  // Tiny constructors and destructors can be written on a single line.
+  MyClass() {}
+
+  // Unless it's a copy or move constructor or you have a specific reason to
+  // allow implicit conversions, mark all single-argument constructors explicit.
+  explicit MyClass(OtherClass aArg) { bar(); }
+
+  // This constructor can also take a single argument, so it also needs to be
+  // marked explicit.
+  explicit MyClass(OtherClass aArg, AnotherClass aArg2 = AnotherClass())
+  {
+foo();
+  }
+
+  int TinyFunction()
+  {
+return mVar;
+  } // Tiny functions can be written in a single line.
+
+  int LargerFunction()
+  {
+bar();
+foo();
+  }
+
+private:
+  int mVar;
+};
+
+} // namespace mozilla
+
+template // Templates on own line.
+static int
+MyFunction(int a) // Return type on own line for top-level functions.
+{
+  foo();
+}
+
+int
+MyClass::Method(long b)
+{
+  bar();
+}
+
+T* p; // Correct declaration style
+
+// Test the && and || with parentheses
+return (nextKeyframe < aTimeThreshold ||
+(mVideo.mTimeThreshold &&
+ mVideo.mTimeThreshold.ref().EndTime() < aTimeThreshold)) &&
+   nextKeyframe.ToMicroseconds() >= 0 && !nextKeyframe.IsInfinite();
+
+// The ? should be placed 2 spaces after the previous declaration
+LOGV("%d audio samples demuxed (sid:%d)",
+ aSamples->mSamples.Length(),
+ aSamples->mSamples[0]->mTrackInfo
+   ? aSamples->mSamples[0]->mTrackInfo->GetID()
+   : 0);
+
+// Test with the 80 chars limit
+return (aDecoder.HasPromise() || aDecoder.mTimeThreshold.isSome()) &&
+   !aDecoder.HasPendingDrain() && !aDecoder.HasFatalError() &&
+   !aDecoder.mDemuxRequest.Exists() && !aDecoder.mOutput.Length() &&
+   !aDecoder.HasInternalSeekPending() && !aDecoder.mDecodeRequest.Exists();
+
+template
+void
+foo();
+
+#define MACRO(V)   \
+  V(Rt2) /* one more char */   \
+  V(Rs)  /* than here  */  \
+/* comment 3 */
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30111: [clang-format] Add a test to check at once all the Mozilla coding style

2017-02-28 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

I will rename it before the upload if that is fine with you.




Comment at: unittests/Format/check-coding-style-mozilla.cpp:77
+return mVar;
+  } // Tiny functions can be written in a single line.
+

krasimir wrote:
> Note that here the trailing comment will make a version of `TinyFunction` on 
> a single line exceed the line limit.
> If the comment is put before the definition of `TinyFunction`, it could 
> really be made tiny, as in:
> ```
>   // Tiny functions can be written in a single line.
>   int TinyFunction() { return mVar; }
> ```
I will remove it for now. I will add it once we have the capability in 
clang-format


https://reviews.llvm.org/D30111



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


[PATCH] D28266: Transparent_union attribute should be possible in front of union (rework)

2017-02-28 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 90056.
erichkeane added a comment.

Response to Aaron's comments


https://reviews.llvm.org/D28266

Files:
  include/clang/Sema/Sema.h
  lib/Parse/ParseDeclCXX.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/transparent-union.c
  test/Sema/transparent-union.c

Index: lib/Parse/ParseDeclCXX.cpp
===
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -1887,6 +1887,10 @@
   ParseStructUnionBody(StartLoc, TagType, TagOrTempResult.get());
   }
 
+  if (!TagOrTempResult.isInvalid())
+// Delayed proccessing of attributes.
+Actions.ProcessDeclAttributeDelayed(TagOrTempResult.get(), attrs.getList());
+
   const char *PrevSpec = nullptr;
   unsigned DiagID;
   bool Result;
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -13637,9 +13637,6 @@
   if (Invalid)
 New->setInvalidDecl();
 
-  if (Attr)
-ProcessDeclAttributeList(S, New, Attr);
-
   // Set the lexical context. If the tag has a C++ scope specifier, the
   // lexical context will be different from the semantic context.
   New->setLexicalDeclContext(CurContext);
@@ -13658,6 +13655,9 @@
   if (TUK == TUK_Definition)
 New->startDefinition();
 
+  if (Attr)
+ProcessDeclAttributeList(S, New, Attr);
+
   // If this has an identifier, add it to the scope stack.
   if (TUK == TUK_Friend) {
 // We might be replacing an existing declaration in the lookup tables;
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -3193,8 +3193,9 @@
   }
 
   if (!RD->isCompleteDefinition()) {
-S.Diag(Attr.getLoc(),
-diag::warn_transparent_union_attribute_not_definition);
+if (!RD->isBeingDefined())
+  S.Diag(Attr.getLoc(),
+ diag::warn_transparent_union_attribute_not_definition);
 return;
   }
 
@@ -6314,6 +6315,15 @@
   }
 }
 
+// Helper for delayed proccessing TransparentUnion attribute.
+void Sema::ProcessDeclAttributeDelayed(Decl *D, const AttributeList *AttrList) {
+  for (const AttributeList *Attr= AttrList; Attr; Attr = Attr->getNext())
+if (Attr->getKind() == AttributeList::AT_TransparentUnion) {
+  handleTransparentUnionAttr(*this, D, *Attr);
+  break;
+}
+}
+
 // Annotation attributes are the only attributes allowed after an access
 // specifier.
 bool Sema::ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl,
Index: include/clang/Sema/Sema.h
===
--- include/clang/Sema/Sema.h
+++ include/clang/Sema/Sema.h
@@ -3122,6 +3122,8 @@
   void ProcessPragmaWeak(Scope *S, Decl *D);
   // Decl attributes - this routine is the top level dispatcher.
   void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD);
+  // Helper for delayed proccessing of attributes.
+  void ProcessDeclAttributeDelayed(Decl *D, const AttributeList *AttrList);
   void ProcessDeclAttributeList(Scope *S, Decl *D, const AttributeList *AL,
 bool IncludeCXX11Attributes = true);
   bool ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl,
Index: test/CodeGen/transparent-union.c
===
--- test/CodeGen/transparent-union.c
+++ test/CodeGen/transparent-union.c
@@ -3,10 +3,21 @@
 // RUN: %clang_cc1 -Werror -triple armv7-linux -emit-llvm -o - %s | FileCheck %s --check-prefix=ARM
 // RUN: %clang_cc1 -Werror -triple powerpc64le-linux -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -Werror -triple aarch64-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -DINFRONT -Werror -triple x86_64-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -DINFRONT -Werror -triple i386-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -DINFRONT -Werror -triple armv7-linux -emit-llvm -o - %s | FileCheck %s --check-prefix=ARM
+// RUN: %clang_cc1 -DINFRONT -Werror -triple powerpc64le-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -DINFRONT -Werror -triple aarch64-linux -emit-llvm -o - %s | FileCheck %s
 
+#ifdef INFRONT
+typedef union __attribute__((transparent_union)) {
+  void *f0;
+} transp_t0;
+#else
 typedef union {
   void *f0;
 } transp_t0 __attribute__((transparent_union));
+#endif
 
 void f0(transp_t0 obj);
 
Index: test/Sema/transparent-union.c
===
--- test/Sema/transparent-union.c
+++ test/Sema/transparent-union.c
@@ -54,11 +54,21 @@
   aligned_struct8 s8; // expected-warning{{alignment of field}}
 } TU1 __attribute__((transparent_union));
 
+typedef union __attribute__((transparent_union)) {
+  aligned_struct4 s4; // expected-note{{alignment of first field}}
+  aligned_struct8 s8; // expected-warning{{alignment of field}}
+} TU

[PATCH] D28266: Transparent_union attribute should be possible in front of union (rework)

2017-02-28 Thread Erich Keane via Phabricator via cfe-commits
erichkeane marked 6 inline comments as done.
erichkeane added a comment.

Thanks!  Changes incoming.


https://reviews.llvm.org/D28266



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


r296499 - clang-format: [Java] Fix bug in enum formatting.

2017-02-28 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Tue Feb 28 12:28:15 2017
New Revision: 296499

URL: http://llvm.org/viewvc/llvm-project?rev=296499&view=rev
Log:
clang-format: [Java] Fix bug in enum formatting.

Before:
  public enum VeryLongEnum {
ENUM_WITH_MANY_PARAMETERS("aa",
  "bbb",
  "ccc")
,
SECOND_ENUM("a", "b", "c");

private VeryLongEnum(String a, String b, String c) {}
  }

After:
  public enum VeryLongEnum {
ENUM_WITH_MANY_PARAMETERS("aa",
  "bbb",
  "ccc") ,
SECOND_ENUM("a", "b", "c");

private VeryLongEnum(String a, String b, String c) {}
  }

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJava.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=296499&r1=296498&r2=296499&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Feb 28 12:28:15 2017
@@ -1083,7 +1083,8 @@ private:
   if (Current.MatchingParen && Current.Next &&
   !Current.Next->isBinaryOperator() &&
   !Current.Next->isOneOf(tok::semi, tok::colon, tok::l_brace,
- tok::period, tok::arrow, tok::coloncolon))
+ tok::comma, tok::period, tok::arrow,
+ tok::coloncolon))
 if (FormatToken *AfterParen = Current.MatchingParen->Next) {
   // Make sure this isn't the return type of an Obj-C block declaration
   if (AfterParen->Tok.isNot(tok::caret)) {

Modified: cfe/trunk/unittests/Format/FormatTestJava.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJava.cpp?rev=296499&r1=296498&r2=296499&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJava.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJava.cpp Tue Feb 28 12:28:15 2017
@@ -225,6 +225,13 @@ TEST_F(FormatTestJava, EnumDeclarations)
"}\n"
"  };\n"
"}");
+  verifyFormat("public enum VeryLongEnum {\n"
+   "  ENUM_WITH_MANY_PARAMETERS(\n"
+   "  \"a\", \"\", 
"
+   "\"\"),\n"
+   "  SECOND_ENUM(\"a\", \"b\", \"c\");\n"
+   "  private VeryLongEnum(String a, String b, String c) {}\n"
+   "}\n");
 }
 
 TEST_F(FormatTestJava, ArrayInitializers) {


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


[PATCH] D30345: [CodeGen][Blocks] Refactor capture handling in code that generates block copy/destroy routines

2017-02-28 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D30345#688298, @arphaman wrote:

> In https://reviews.llvm.org/D30345#688144, @rjmccall wrote:
>
> > You're doing this refactor to... support doing another refactor of the same 
> > code?  Why are these patches separate?
>
>
> Not quite, by "merging block copy/destroy routines" I meant that my next 
> patch will try to generate the IR only for unique copy/destroy functions, so 
> individual functions will be merged.


Ah, okay, sure.




Comment at: lib/CodeGen/CGBlocks.cpp:1380
+/// entity that's captured by a block.
+enum class BlockCaptureEntityType {
+  CXXRecord, // Copy or destroy

BlockCaptureEntityKind, please.



Comment at: lib/CodeGen/CGBlocks.cpp:1389
+/// Represents an entity captured by a block that requires custom operations
+/// to copy/release this entity.
+struct BlockCaptureManagedEntity {

Grammar, and the complementary generic operation to "copy" is "destroy", not 
"release".



Comment at: lib/CodeGen/CGBlocks.cpp:1391
+struct BlockCaptureManagedEntity {
+  BlockCaptureEntityType Type;
+  BlockFieldFlags Flags;

Similarly, please name this Kind.



Comment at: lib/CodeGen/CGBlocks.cpp:1608
+static std::pair
+computeDestroyInfoForBlockCapture(const BlockDecl::Capture &CI, QualType Type,
+  const LangOptions &LangOpts) {

Please don't name local variables "Type".  "QT" or "T" would be fine.


Repository:
  rL LLVM

https://reviews.llvm.org/D30345



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


Re: [PATCH] Improved plugin/tool support by expanding an existing attribute

2017-02-28 Thread Aaron Ballman via cfe-commits
On Fri, Feb 24, 2017 at 8:24 AM, Marcwell Helpdesk  wrote:
>
> As interesting the subject of pluggable attributes may be could we please 
> drop that discussion and focus on the intention of and what the patch 
> actually does? Two revisions of the patch have been supplied and both should 
> reasonable not cause any controversy since they only enriches an already 
> existing functionality.

That discussion and this patch are inextricably linked because they
are competing designs for the same functionality. The question boils
down to which way is the best way forward for users, and I do not
believe extending the annotate attribute in this way is the correct
approach.

> You left out the statement annotation when asking to split the patch, if this 
> is causing the controversy please explain why. It would be very interesting 
> to know the original intention of the annotate attribute should it deviate in 
> any way from being a general purpose information bearer. And as I have tried 
> to explain several times, the statement annotations are as 
> important/irrelevant as any other type of annotations and with the current 
> support in LLVM/clang it won’t support forwarding to IR but it may be used in 
> the AST.

As I've pointed out during the review, the annotate attribute is
inadequate for specifying things like subjects, arguments,
namespacing, or preventing other misuses of custom attributes. It is
error-prone to use, and so extending it to further uses only
exacerbates these problems. These can be solved in an ad hoc manner,
but that only pushes the design closer to a poor implementation of
pluggable attributes.

Just to be explicit: I agree with your assertion that statement
annotations are as important as other attributes and that we should
have a generic way to carry information on various constructs through
the AST (and to the IR when plausible). What I disagree with is the
way in which the functionality is exposed both to end-users and
attribute authors (or tool designers).

> Furthermore, if you don’t like the what the documentation says about using 
> the annotations for tools then drop the documentation or write it yourself, 
> it must not be the show-stopper.

The documentation is fine. I asked for the patch to be split so that
we could accept the documentation (and the C++11 spelling), because
those are not controversial.

~Aaron

>
> Cheers,
> Chris
>
>> On 21 feb 2017, at 15:11, Aaron Ballman  wrote:
>>
>> On Tue, Feb 14, 2017 at 6:05 AM, Marcwell Helpdesk wrote:
>>> The intention of the patch is to extend the functionality of annotations
>>> while utilizing existing infrastructure in the AST and IR as much as
>>> possible. Annotations are indeed a general purpose solution, sufficient for
>>> many use cases, and a complement, not mutual exclusive to pluggable
>>> attributes. And don’t forget the realm of AST tools. The compiler should not
>>> perform any content checking of annotations but leave that to tool
>>> implementations if it is used for other purposes than merely tags. For a
>>> more complete support of annotations the AST and IR needs further work but
>>> this patch is a step on the way.
>>>
>>> Having pluggable attributes would be cool but it would face even greater
>>> problems than you describe. Unless pluggable attributes involves writing
>>> pluggable AST and IR modules the AST and IR must both support some form of
>>> generic containers that could handle any type of attribute with any number
>>> of parameters. In either case, it would most likely involve substantial
>>> architectural changes to many parts.
>>
>> Pluggable attributes do not require these component up front (though
>> they could be explored for later iterations), but you are correct in
>> that they involve more work than simply piggy-backing off the annotate
>> attribute. However, that extra work comes with benefits that expanding
>> the annotate attribute will never realize with the end results being
>> roughly the same (the attribute metadata still gets passed down to the
>> LLVM IR and represented in a manner that AST tools can handle).
>>
>>> I have revised the patch by adding a second, optional parameter that makes
>>> it possible to group annotations, reducing the risk for collisions and since
>>> it is optional it won’t break any existing code. A non-zero group string is
>>> prepended to the value string when forwarded to IR. The C++11 attribute has
>>> been moved to the clang namespace as requested and unit tests and
>>> documentation are updated to reflect the changes.
>>
>> Can you please split this patch? The C++11 attribute name, associated
>> tests, and documentation of what the attribute does currently are not
>> controversial and those changes can go in pretty quickly if separated
>> from the greater discussion about how to allow generic, custom
>> attributes to be exposed.
>>
>> ~Aaron
>>
>>>
>>> Cheers,
>>> Chris
>>>
>>> Modified
>>>  include/clang/Basic/Attr.td
>>>  include/clang/Basic/AttrDocs

[PATCH] D29753: [PCH] Avoid early VarDecl emission attempt if no owning module avaiable

2017-02-28 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a subscriber: mehdi_amini.
hans added a comment.

To unblock 4.0, I'm leaning towards merging Bruno's patch as a stop-gap fix.

I realize it probably only fixes the problem for PCH, and not modules. But PCH 
is used more widely than modules, so maybe it's good enough for now?

We've run out of time for 4.0, and it seems fixing this properly might be 
involved.

What do folks think?


https://reviews.llvm.org/D29753



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


[PATCH] D29753: [PCH] Avoid early VarDecl emission attempt if no owning module avaiable

2017-02-28 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.



> It seems to me that the problem here is that `DeclMustBeEmitted` is not safe 
> to call in the middle of deserialization if anything partially-deserialized 
> might be reachable from the declaration we're querying, and yet we're 
> currently calling it in that case.

`DeclMustBeEmitted` name seems misleading since we does more than just 
checking, it actually tries to emit stuff. If it's a local module, shouldn't be 
everything already available? Do we have non-deserialized items for a local 
module? Maybe I get the wrong idea of what local means in this context..

> I don't see how this patch actually addresses that problem, though: if you 
> build this testcase as a module instead of a PCH, won't it still fail in the 
> same way that it does now?

`D->getImportedOwningModule` calls `isFromASTFile`, which refers to PCH and 
modules, shouldn't it work for both then? I couldn't come up with a testcase 
that triggered it for modules though.

> I think we probably need to track all the declarations we deserialize in a 
> top-level deserialization,  and only check whether they're interesting when 
> we finish recursive deserialization (somewhere around 
> `ASTReader::FinishedDeserializing`). For the update record case, this will 
> need some care in order to retain the property that we only pass a 
> declaration to the consumer once, but I think we can make that work by 
> observing that it should generally be safe to call `DeclMustBeEmitted` on a 
> declaration that we didn't create in this deserialization step, and when 
> we're loading update records we know whether that's the case.

Right. This is a more involved fix and I don't fully understand all r276159 
consequences yet. OTOH, the current patch improves the situation and unblock 
some big projects to compile with clang ToT, for instance, Unreal Engine 4.


https://reviews.llvm.org/D29753



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


[PATCH] D29753: [PCH] Avoid early VarDecl emission attempt if no owning module avaiable

2017-02-28 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.



> What do folks think?

IMO we should do it.


https://reviews.llvm.org/D29753



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


[PATCH] D29819: Introduce an 'external_source_symbol' attribute that describes the origin and the nature of a declaration

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

LGTM, despite a long-ish comment.




Comment at: lib/Parse/ParseDeclCXX.cpp:3830-3837
+  unsigned NumArgs;
+  // Some Clang-scoped attributes have some special parsing behavior.
+  if (ScopeName && ScopeName->getName() == "clang")
+NumArgs =
+ParseClangAttributeArgs(AttrName, AttrNameLoc, Attrs, EndLoc, 
ScopeName,
+ScopeLoc, AttributeList::AS_CXX11);
+  else

This code is equivalent to the old code, which is good. However, it points out 
what I think may be a latent bug -- for attributes in the clang namespace that 
are also standard attributes, I'm not certain we should be generating parse 
errors for the clang-namespaced spelling. This only impacts [[fallthrough]] vs 
[[clang::fallthrough]], according to the implementation of 
`IsBuiltInOrStandardCXX11Attribute()`.

All of that is to say: I'm not certain we need to hoist `NumArgs` to get to the 
call to `IsBuiltInOrStandardCXX11Attribute()` below, because attributes in the 
clang namespace are not built-in or standard attributes.

This requires a bit further exploration, but I won't have time to do that for a 
few weeks. I don't want to hold your patch up for that, so I think this is fine 
for now -- I can modify the code later when I have the chance to finish my 
exploration.


Repository:
  rL LLVM

https://reviews.llvm.org/D29819



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


[PATCH] D28266: Transparent_union attribute should be possible in front of union (rework)

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

LGTM, with one formatting nit.




Comment at: lib/Sema/SemaDeclAttr.cpp:6201
+void Sema::ProcessDeclAttributeDelayed(Decl *D, const AttributeList *AttrList) 
{
+  for (const AttributeList* l = AttrList; l; l = l->getNext())
+if (l->getKind() == AttributeList::AT_TransparentUnion) {

aaron.ballman wrote:
> Nit: the `*` should bind to `l` and `l` should be `L` by our usual naming 
> conventions (but a name better than `L` wouldn't be amiss).
Nit: missing a space before the first `=`. You should run clang-format on the 
patch to catch this sort of thing.


https://reviews.llvm.org/D28266



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


[PATCH] D30166: Honor __unaligned in codegen for declarations and expressions

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

I think this LGTM, but you should wait for confirmation from one of the other 
reviewers before committing.


https://reviews.llvm.org/D30166



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


r296518 - Allow attributes before union definition

2017-02-28 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Feb 28 14:44:39 2017
New Revision: 296518

URL: http://llvm.org/viewvc/llvm-project?rev=296518&view=rev
Log:
Allow attributes before union definition

permits typedef union __attribute__((transparent_union)) {...}

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

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/CodeGen/transparent-union.c
cfe/trunk/test/Sema/transparent-union.c

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=296518&r1=296517&r2=296518&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Feb 28 14:44:39 2017
@@ -3122,6 +3122,8 @@ public:
   void ProcessPragmaWeak(Scope *S, Decl *D);
   // Decl attributes - this routine is the top level dispatcher.
   void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD);
+  // Helper for delayed proccessing of attributes.
+  void ProcessDeclAttributeDelayed(Decl *D, const AttributeList *AttrList);
   void ProcessDeclAttributeList(Scope *S, Decl *D, const AttributeList *AL,
 bool IncludeCXX11Attributes = true);
   bool ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl,

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=296518&r1=296517&r2=296518&view=diff
==
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Tue Feb 28 14:44:39 2017
@@ -1887,6 +1887,10 @@ void Parser::ParseClassSpecifier(tok::To
   ParseStructUnionBody(StartLoc, TagType, TagOrTempResult.get());
   }
 
+  if (!TagOrTempResult.isInvalid())
+// Delayed proccessing of attributes.
+Actions.ProcessDeclAttributeDelayed(TagOrTempResult.get(), 
attrs.getList());
+
   const char *PrevSpec = nullptr;
   unsigned DiagID;
   bool Result;

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=296518&r1=296517&r2=296518&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Feb 28 14:44:39 2017
@@ -13637,9 +13637,6 @@ CreateNewDecl:
   if (Invalid)
 New->setInvalidDecl();
 
-  if (Attr)
-ProcessDeclAttributeList(S, New, Attr);
-
   // Set the lexical context. If the tag has a C++ scope specifier, the
   // lexical context will be different from the semantic context.
   New->setLexicalDeclContext(CurContext);
@@ -13658,6 +13655,9 @@ CreateNewDecl:
   if (TUK == TUK_Definition)
 New->startDefinition();
 
+  if (Attr)
+ProcessDeclAttributeList(S, New, Attr);
+
   // If this has an identifier, add it to the scope stack.
   if (TUK == TUK_Friend) {
 // We might be replacing an existing declaration in the lookup tables;

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=296518&r1=296517&r2=296518&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue Feb 28 14:44:39 2017
@@ -3193,8 +3193,9 @@ static void handleTransparentUnionAttr(S
   }
 
   if (!RD->isCompleteDefinition()) {
-S.Diag(Attr.getLoc(),
-diag::warn_transparent_union_attribute_not_definition);
+if (!RD->isBeingDefined())
+  S.Diag(Attr.getLoc(),
+ diag::warn_transparent_union_attribute_not_definition);
 return;
   }
 
@@ -6314,6 +6315,15 @@ void Sema::ProcessDeclAttributeList(Scop
   }
 }
 
+// Helper for delayed proccessing TransparentUnion attribute.
+void Sema::ProcessDeclAttributeDelayed(Decl *D, const AttributeList *AttrList) 
{
+  for (const AttributeList *Attr = AttrList; Attr; Attr = Attr->getNext())
+if (Attr->getKind() == AttributeList::AT_TransparentUnion) {
+  handleTransparentUnionAttr(*this, D, *Attr);
+  break;
+}
+}
+
 // Annotation attributes are the only attributes allowed after an access
 // specifier.
 bool Sema::ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl,

Modified: cfe/trunk/test/CodeGen/transparent-union.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/transparent-union.c?rev=296518&r1=296517&r2=296518&view=diff
==
--- cfe/trunk/test/CodeGen/transparent-union.c (original)
+++ cfe/trunk/test/CodeGen/transparent-union.c Tue Feb 28 14:44:39 2017
@@ -3,10 +3,21 @@
 // RUN: %clang_cc1 -Werror -triple armv7-linux -emit-llvm -o - %s | Fil

[PATCH] D28266: Transparent_union attribute should be possible in front of union (rework)

2017-02-28 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296518: Allow attributes before union definition (authored 
by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D28266?vs=90056&id=90075#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28266

Files:
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Parse/ParseDeclCXX.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/CodeGen/transparent-union.c
  cfe/trunk/test/Sema/transparent-union.c

Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -3122,6 +3122,8 @@
   void ProcessPragmaWeak(Scope *S, Decl *D);
   // Decl attributes - this routine is the top level dispatcher.
   void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD);
+  // Helper for delayed proccessing of attributes.
+  void ProcessDeclAttributeDelayed(Decl *D, const AttributeList *AttrList);
   void ProcessDeclAttributeList(Scope *S, Decl *D, const AttributeList *AL,
 bool IncludeCXX11Attributes = true);
   bool ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl,
Index: cfe/trunk/test/CodeGen/transparent-union.c
===
--- cfe/trunk/test/CodeGen/transparent-union.c
+++ cfe/trunk/test/CodeGen/transparent-union.c
@@ -3,10 +3,21 @@
 // RUN: %clang_cc1 -Werror -triple armv7-linux -emit-llvm -o - %s | FileCheck %s --check-prefix=ARM
 // RUN: %clang_cc1 -Werror -triple powerpc64le-linux -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -Werror -triple aarch64-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -DINFRONT -Werror -triple x86_64-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -DINFRONT -Werror -triple i386-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -DINFRONT -Werror -triple armv7-linux -emit-llvm -o - %s | FileCheck %s --check-prefix=ARM
+// RUN: %clang_cc1 -DINFRONT -Werror -triple powerpc64le-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -DINFRONT -Werror -triple aarch64-linux -emit-llvm -o - %s | FileCheck %s
 
+#ifdef INFRONT
+typedef union __attribute__((transparent_union)) {
+  void *f0;
+} transp_t0;
+#else
 typedef union {
   void *f0;
 } transp_t0 __attribute__((transparent_union));
+#endif
 
 void f0(transp_t0 obj);
 
Index: cfe/trunk/test/Sema/transparent-union.c
===
--- cfe/trunk/test/Sema/transparent-union.c
+++ cfe/trunk/test/Sema/transparent-union.c
@@ -54,11 +54,21 @@
   aligned_struct8 s8; // expected-warning{{alignment of field}}
 } TU1 __attribute__((transparent_union));
 
+typedef union __attribute__((transparent_union)) {
+  aligned_struct4 s4; // expected-note{{alignment of first field}}
+  aligned_struct8 s8; // expected-warning{{alignment of field}}
+} TU1b ;
+
 typedef union {
   char c; // expected-note{{size of first field is 8 bits}}
   int i; // expected-warning{{size of field}}
 } TU2 __attribute__((transparent_union));
 
+typedef union __attribute__((transparent_union)){
+  char c; // expected-note{{size of first field is 8 bits}}
+  int i; // expected-warning{{size of field}}
+} TU2b;
+
 typedef union {
   float f; // expected-warning{{floating}}
 } TU3 __attribute__((transparent_union));
@@ -98,3 +108,17 @@
 union pr30520s { struct stb b; } __attribute__((transparent_union)); // expected-error {{field has incomplete type 'struct stb'}}
 
 union pr30520s2 { int *v; struct stb b; } __attribute__((transparent_union)); // expected-error {{field has incomplete type 'struct stb'}}
+
+typedef union __attribute__((__transparent_union__)) {
+  int *i;
+  struct st *s;
+} TU6;
+
+void bar(TU6);
+
+void foo11(int *i) {
+  bar(i);
+}
+void foo2(struct st *s) {
+  bar(s);
+}
Index: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
===
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp
@@ -1887,6 +1887,10 @@
   ParseStructUnionBody(StartLoc, TagType, TagOrTempResult.get());
   }
 
+  if (!TagOrTempResult.isInvalid())
+// Delayed proccessing of attributes.
+Actions.ProcessDeclAttributeDelayed(TagOrTempResult.get(), attrs.getList());
+
   const char *PrevSpec = nullptr;
   unsigned DiagID;
   bool Result;
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -13637,9 +13637,6 @@
   if (Invalid)
 New->setInvalidDecl();
 
-  if (Attr)
-ProcessDeclAttributeList(S, New, Attr);
-
   // Set the lexical context. If the tag has a C++ scope specifier, the
   // lexical context will be different from the semantic context.
   New->setLexicalDeclContext(CurContext);
@@ -13658,6 +13655,9 

[PATCH] D30372: [Driver] Consolidate tools and toolchains by target platform. (NFC)

2017-02-28 Thread David L. Jones via Phabricator via cfe-commits
dlj added a comment.

In https://reviews.llvm.org/D30372#688154, @mehdi_amini wrote:

> In https://reviews.llvm.org/D30372#687060, @ahatanak wrote:
>
> > In https://reviews.llvm.org/D30372#687054, @dlj wrote:
> >
> > > In https://reviews.llvm.org/D30372#686871, @ahatanak wrote:
> > >
> > > > Have you considered using "include_directories" in CMakeLists.txt to 
> > > > avoid including "../Something.h"?
> > >
> > >
> > > I don't want to take that approach, and there's a specific reason why: my 
> > > concern isn't with three extra bytes, it's the fact that the headers are 
> > > in an unusual place. It's typical to include headers from a subdirectory, 
> > > or from the includes directory, but far less common to include from a 
> > > parent lib directory. Hiding that fact seems strictly worse to me.
> >
> >
> > OK. I was suggesting that only because LLVM already uses 
> > include_directories to include a header that exists in the parent directory 
> > in some cases. Apparently that's not what you wanted.
>
>
> Yes it seems "common" in LLVM to do this in CMake: `include_directories( 
> ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. )`


Actually, since I'm still keeping these files in the clangDriver rule, the 
lib/Driver directory is already on the search path, so I can use a subpath of 
Driver already.


https://reviews.llvm.org/D30372



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


[PATCH] D30327: [Sema] Improve side effect checking for unused-lambda-capture warning

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

LGTM!

In https://reviews.llvm.org/D30327#688254, @malcolm.parsons wrote:

> I found this FIXME comment in `Expr::HasSideEffects()`:
>
>   case LambdaExprClass: {
> const LambdaExpr *LE = cast(this);
> for (LambdaExpr::capture_iterator I = LE->capture_begin(),
>   E = LE->capture_end(); I != E; ++I)
>   if (I->getCaptureKind() == LCK_ByCopy)
> // FIXME: Only has a side-effect if the variable is volatile or if
> // the copy would invoke a non-trivial copy constructor.
> return true;
> return false;
>   }
>   
>
> It seems a shame not to fix this now, but I don't think I can call Sema code 
> from AST code, and my `CaptureHasSideEffects()` depends on 
> `Sema::getCurrentThisType()`.
>
> Any ideas?


Correct, you cannot call Sema code from AST. I don't know of a good way to 
resolve this off the top of my head given what `getCurrentThisType()` needs to 
do. I agree that this would be good to fix as well, but your patch is a good 
incremental improvement and should't be held up on this.


https://reviews.llvm.org/D30327



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


[PATCH] D30430: Make Lit tests C++11 compatible - IR ordering

2017-02-28 Thread Charles Li via Phabricator via cfe-commits
tigerleapgorge updated this revision to Diff 90078.
tigerleapgorge added a comment.

Updated patch.

Test only runs in C++11.
Added comments to explain CHECK-DAG and CHECK2-NOT.


https://reviews.llvm.org/D30430

Files:
  test/CodeGenCXX/template-instantiation.cpp


Index: test/CodeGenCXX/template-instantiation.cpp
===
--- test/CodeGenCXX/template-instantiation.cpp
+++ test/CodeGenCXX/template-instantiation.cpp
@@ -1,21 +1,22 @@
-// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 
-emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 
-std=c++11 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 
-std=c++11 -emit-llvm -o - | FileCheck %s --check-prefix=CHECK2
 
-// CHECK: @_ZN7PR100011xE = global
-// CHECK-NOT: @_ZN7PR100014kBarE = external global i32
-//
-// CHECK-NOT: @_ZTVN5test118stdio_sync_filebufIwEE = constant
-// CHECK-NOT: _ZTVN5test315basic_fstreamXXIcEE
-// CHECK-NOT: @_ZTVN5test018stdio_sync_filebufIA1_iEE
-// CHECK-NOT: @_ZTVN5test018stdio_sync_filebufIA2_iEE
-// CHECK: @_ZTVN5test018stdio_sync_filebufIA3_iEE = weak_odr unnamed_addr 
constant
+// Instantiation order varies on different C++ dialects (IE, between C++98 and 
C++11).
+// CHECK-DAG: @_ZN7PR100011xE = global
+// CHECK-DAG: @_ZTVN5test018stdio_sync_filebufIA3_iEE = weak_odr unnamed_addr 
constant
+// CHECK-DAG: @_ZN7PR100011SIiE3arrE = linkonce_odr global [3 x i32]
+// CHECK-DAG: @_ZTVN5test018stdio_sync_filebufIA4_iEE = linkonce_odr 
unnamed_addr constant
+
+// Negative checks go under prefix "CHECK2" to avoid interference with CHECK 
and CHECK-DAG.
+// CHECK2-NOT: @_ZN7PR100014kBarE = external global i32
+// CHECK2-NOT: @_ZTVN5test118stdio_sync_filebufIwEE = constant
+// CHECK2-NOT: _ZTVN5test315basic_fstreamXXIcEE
+// CHECK2-NOT: @_ZTVN5test018stdio_sync_filebufIA1_iEE
+// CHECK2-NOT: @_ZTVN5test018stdio_sync_filebufIA2_iEE
+// CHECK2-NOT: @_ZN7PR100011SIiE3arr2E = linkonce_odr global [3 x i32]A
 
-// CHECK: @_ZN7PR100011SIiE3arrE = linkonce_odr global [3 x i32]
-// CHECK-NOT: @_ZN7PR100011SIiE3arr2E = linkonce_odr global [3 x i32]A
-
-// CHECK: @_ZTVN5test018stdio_sync_filebufIA4_iEE = linkonce_odr 
unnamed_addr constant
-
-// CHECK-NOT: _ZTVN5test31SIiEE
-// CHECK-NOT: _ZTSN5test31SIiEE
+// CHECK2-NOT: _ZTVN5test31SIiEE
+// CHECK2-NOT: _ZTSN5test31SIiEE
 
 // CHECK-LABEL: define linkonce_odr void 
@_ZN5test21CIiEC1Ev(%"class.test2::C"* %this) unnamed_addr
 // CHECK-LABEL: define linkonce_odr void @_ZN5test21CIiE6foobarIdEEvT_(
@@ -152,7 +153,7 @@
   void f () {}
 };
 // Should not instantiate class B since it is introduced in namespace scope.
-// CHECK-NOT: _ZN6PR85051AILi0EE1B1fEv
+// CHECK2-NOT: _ZN6PR85051AILi0EE1B1fEv
 template class A<0>;
 }
 


Index: test/CodeGenCXX/template-instantiation.cpp
===
--- test/CodeGenCXX/template-instantiation.cpp
+++ test/CodeGenCXX/template-instantiation.cpp
@@ -1,21 +1,22 @@
-// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - | FileCheck %s --check-prefix=CHECK2
 
-// CHECK: @_ZN7PR100011xE = global
-// CHECK-NOT: @_ZN7PR100014kBarE = external global i32
-//
-// CHECK-NOT: @_ZTVN5test118stdio_sync_filebufIwEE = constant
-// CHECK-NOT: _ZTVN5test315basic_fstreamXXIcEE
-// CHECK-NOT: @_ZTVN5test018stdio_sync_filebufIA1_iEE
-// CHECK-NOT: @_ZTVN5test018stdio_sync_filebufIA2_iEE
-// CHECK: @_ZTVN5test018stdio_sync_filebufIA3_iEE = weak_odr unnamed_addr constant
+// Instantiation order varies on different C++ dialects (IE, between C++98 and C++11).
+// CHECK-DAG: @_ZN7PR100011xE = global
+// CHECK-DAG: @_ZTVN5test018stdio_sync_filebufIA3_iEE = weak_odr unnamed_addr constant
+// CHECK-DAG: @_ZN7PR100011SIiE3arrE = linkonce_odr global [3 x i32]
+// CHECK-DAG: @_ZTVN5test018stdio_sync_filebufIA4_iEE = linkonce_odr unnamed_addr constant
+
+// Negative checks go under prefix "CHECK2" to avoid interference with CHECK and CHECK-DAG.
+// CHECK2-NOT: @_ZN7PR100014kBarE = external global i32
+// CHECK2-NOT: @_ZTVN5test118stdio_sync_filebufIwEE = constant
+// CHECK2-NOT: _ZTVN5test315basic_fstreamXXIcEE
+// CHECK2-NOT: @_ZTVN5test018stdio_sync_filebufIA1_iEE
+// CHECK2-NOT: @_ZTVN5test018stdio_sync_filebufIA2_iEE
+// CHECK2-NOT: @_ZN7PR100011SIiE3arr2E = linkonce_odr global [3 x i32]A
 
-// CHECK: @_ZN7PR100011SIiE3arrE = linkonce_odr global [3 x i32]
-// CHECK-NOT: @_ZN7PR100011SIiE3arr2E = linkonce_odr global [3 x i32]A
-
-// CHECK: @_ZTVN5test018stdio_sync_filebufIA4_iEE = linkonce_odr unnamed_addr constant
-
-// CHECK-NOT: _ZTVN5test31SIiEE
-// CHE

r296521 - [ODRHash] Add basic support for CXXRecordDecl

2017-02-28 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue Feb 28 15:24:38 2017
New Revision: 296521

URL: http://llvm.org/viewvc/llvm-project?rev=296521&view=rev
Log:
[ODRHash] Add basic support for CXXRecordDecl

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=296521&r1=296520&r2=296521&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Tue Feb 28 
15:24:38 2017
@@ -121,10 +121,10 @@ def err_module_odr_violation_mismatch_de
   "%q0 has different definitions in different modules; first difference is "
   "%select{definition in module '%2'|defined here}1 found "
   "%select{end of class|public access specifier|private access specifier|"
-  "protected access specifier|static assert|field}3">;
+  "protected access specifier|static assert|field|method}3">;
 def note_module_odr_violation_mismatch_decl : Note<"but in '%0' found "
   "%select{end of class|public access specifier|private access specifier|"
-  "protected access specifier|static assert|field}1">;
+  "protected access specifier|static assert|field|method}1">;
 
 def err_module_odr_violation_mismatch_decl_diff : Error<
   "%q0 has different definitions in different modules; first difference is "
@@ -139,7 +139,8 @@ def err_module_odr_violation_mismatch_de
   "bitfield %4 with one width expression|"
   "%select{non-|}5mutable field %4|"
   "field %4 with %select{no|an}5 initalizer|"
-  "field %4 with an initializer}3">;
+  "field %4 with an initializer|"
+  "method %4}3">;
 
 def note_module_odr_violation_mismatch_decl_diff : Note<"but in '%0' found "
   "%select{"
@@ -152,7 +153,8 @@ def note_module_odr_violation_mismatch_d
   "bitfield %2 with different width expression|"
   "%select{non-|}3mutable field %2|"
   "field %2 with %select{no|an}3 initializer|"
-  "field %2 with a different initializer}1">;
+  "field %2 with a different initializer|"
+  "method %2}1">;
 
 def warn_module_uses_date_time : Warning<
   "%select{precompiled header|module}0 uses __DATE__ or __TIME__">,

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=296521&r1=296520&r2=296521&view=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Tue Feb 28 15:24:38 2017
@@ -194,6 +194,14 @@ public:
 
 Inherited::VisitFieldDecl(D);
   }
+
+  void VisitFunctionDecl(const FunctionDecl *D) {
+Inherited::VisitFunctionDecl(D);
+  }
+
+  void VisitCXXMethodDecl(const CXXMethodDecl *D) {
+Inherited::VisitCXXMethodDecl(D);
+  }
 };
 
 // Only allow a small portion of Decl's to be processed.  Remove this once
@@ -206,6 +214,7 @@ bool ODRHash::isWhitelistedDecl(const De
 default:
   return false;
 case Decl::AccessSpec:
+case Decl::CXXMethod:
 case Decl::Field:
 case Decl::StaticAssert:
   return true;

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=296521&r1=296520&r2=296521&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Feb 28 15:24:38 2017
@@ -8957,6 +8957,7 @@ void ASTReader::diagnoseOdrViolations()
 ProtectedSpecifer,
 StaticAssert,
 Field,
+CXXMethod,
 Other
   } FirstDiffType = Other,
 SecondDiffType = Other;
@@ -8982,6 +8983,8 @@ void ASTReader::diagnoseOdrViolations()
   return StaticAssert;
 case Decl::Field:
   return Field;
+case Decl::CXXMethod:
+  return CXXMethod;
 }
   };
 
@@ -9068,6 +9071,7 @@ void ASTReader::diagnoseOdrViolations()
 FieldSingleMutable,
 FieldSingleInitializer,
 FieldDifferentInitializers,
+MethodName,
   };
 
   // These lambdas have the common portions of the ODR diagnostics.  This
@@ -9287,6 +9291,25 @@ void ASTReader::diagnoseOdrViolations()
 }
 
 break;
+  }
+  case CXXMethod: {
+const CXXMethodDecl *FirstMethod = cast(FirstDecl);
+const CXXMethodDecl *SecondMethod = cast(SecondDecl);
+IdentifierInfo *FirstII = FirstMethod->getIdentifier();
+IdentifierInfo *SecondII = SecondMethod->getIdentifier();
+if (FirstII->getName() != SecondII->getName()) {
+  ODRDiagError(FirstMethod->getLocation(),
+   FirstMethod->ge

[PATCH] D30430: Make Lit tests C++11 compatible - IR ordering

2017-02-28 Thread Charles Li via Phabricator via cfe-commits
tigerleapgorge added a comment.

In https://reviews.llvm.org/D30430#688146, @rjmccall wrote:

> The C++98 behavior here is not really vital to test precisely; it's just 
> minor differences in what gets instantiated and when.


Hi John, my main concern with CHECK-NOT appearing between CHECK lines is that 
it makes the test brittle to the order of the IR.
For this reason I have separated out the CHECK-NOTs to go under a seperate 
prefix with a separate RUN line.
If you would like to old way of a single RUN line, I can do that too.

> I think it's fine to just update the run line to -std=c++11 for things like 
> this.

Done. I have deleted C++98 RUN lines and default (no -std) RUN lines.

>   But if you really want to test both configurations, this LGTM, although 
> please leave a comment in the test explaining that it's just trying to 
> account for differences in instantiation order between C++98 and C++11.

I have added 2 lines of comments. 
One explains why CHECK-DAG is used instead of CHECK.
Another explains why CHECK2-NOT is used instead of CHECK-NOT


https://reviews.llvm.org/D30430



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


Re: r296221 - [ODRHash] Move inherited visitor call to end of function.

2017-02-28 Thread Richard Trieu via cfe-commits
There's no functional change.  This was a mistake I made when splitting the
original patch into pieces and I wanted to correct before proceeding with
additional changes.

On Mon, Feb 27, 2017 at 8:27 AM, David Blaikie  wrote:

> An explanation as to why the code was moved (& possibly test cases, or
> "NFC" in the description) would be handy here.
>
> On Fri, Feb 24, 2017 at 5:41 PM Richard Trieu via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rtrieu
>> Date: Fri Feb 24 19:29:34 2017
>> New Revision: 296221
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=296221&view=rev
>> Log:
>> [ODRHash] Move inherited visitor call to end of function.
>>
>> Modified:
>> cfe/trunk/lib/AST/ODRHash.cpp
>>
>> Modified: cfe/trunk/lib/AST/ODRHash.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
>> ODRHash.cpp?rev=296221&r1=296220&r2=296221&view=diff
>> 
>> ==
>> --- cfe/trunk/lib/AST/ODRHash.cpp (original)
>> +++ cfe/trunk/lib/AST/ODRHash.cpp Fri Feb 24 19:29:34 2017
>> @@ -182,8 +182,6 @@ public:
>>}
>>
>>void VisitFieldDecl(const FieldDecl *D) {
>> -Inherited::VisitFieldDecl(D);
>> -
>>  const bool IsBitfield = D->isBitField();
>>  Hash.AddBoolean(IsBitfield);
>>
>> @@ -193,6 +191,8 @@ public:
>>
>>  Hash.AddBoolean(D->isMutable());
>>  AddStmt(D->getInClassInitializer());
>> +
>> +Inherited::VisitFieldDecl(D);
>>}
>>  };
>>
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29858: [clang-tidy] Catch trivially true statements like a != 1 || a != 3

2017-02-28 Thread Blaise Watson via Phabricator via cfe-commits
watsond marked 2 inline comments as done.
watsond added a comment.

In https://reviews.llvm.org/D29858#675055, @etienneb wrote:

> Could you add some tests with enums (like the one in your description)?
>  This is missing and it's a nice to have.


Added




Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:244
+  // x != 5 || x != 10
+  if (OpcodeLHS == BO_NE || OpcodeLHS == BO_NE)
+return true;

etienneb wrote:
> etienneb wrote:
> > The good news is that this code will be catch by this check!
> > ```
> >   if (OpcodeLHS == BO_NE || OpcodeLHS == BO_NE)   <<-- redundant expression
> > ```
> > Should be:
> > ```
> >   if (OpcodeLHS == BO_NE || OpcodeRHS == BO_NE) 
> > ```
> > 
> > 
> > 
> btw, it should be:
> 
> ```
>   if (OpcodeLHS == BO_NE && OpcodeRHS == BO_NE)
> ```
Thanks for catching!


https://reviews.llvm.org/D29858



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


[PATCH] D29858: [clang-tidy] Catch trivially true statements like a != 1 || a != 3

2017-02-28 Thread Blaise Watson via Phabricator via cfe-commits
watsond updated this revision to Diff 90087.
watsond marked an inline comment as done.
watsond added a comment.

Fixed logic error, added enum test case


https://reviews.llvm.org/D29858

Files:
  clang-tidy/misc/RedundantExpressionCheck.cpp
  test/clang-tidy/misc-redundant-expression.cpp


Index: test/clang-tidy/misc-redundant-expression.cpp
===
--- test/clang-tidy/misc-redundant-expression.cpp
+++ test/clang-tidy/misc-redundant-expression.cpp
@@ -321,6 +321,8 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always 
true
   if (X <= 10 || X >= 11) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always 
true
+  if (X != 7 || X != 14) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: logical expression is always 
true
 
   if (X < 7 && X < 6) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
@@ -422,6 +424,8 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: logical expression is always 
false
   if (C == Red && C != Red) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: logical expression is always 
false
+  if (C != Red || C != Yellow) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: logical expression is always 
true
 
   // Should not match.
   if (C == Red || C == Yellow) return 1;
Index: clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -239,6 +239,11 @@
   (OpcodeRHS == BO_LT || OpcodeRHS == BO_LE))
 return true;
 
+  // Handle cases where constants are different but both ops are !=, like:
+  // x != 5 || x != 10
+  if (OpcodeLHS == BO_NE && OpcodeRHS == BO_NE)
+return true;
+
   return false;
 }
 


Index: test/clang-tidy/misc-redundant-expression.cpp
===
--- test/clang-tidy/misc-redundant-expression.cpp
+++ test/clang-tidy/misc-redundant-expression.cpp
@@ -321,6 +321,8 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always true
   if (X <= 10 || X >= 11) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always true
+  if (X != 7 || X != 14) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: logical expression is always true
 
   if (X < 7 && X < 6) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
@@ -422,6 +424,8 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: logical expression is always false
   if (C == Red && C != Red) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: logical expression is always false
+  if (C != Red || C != Yellow) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: logical expression is always true
 
   // Should not match.
   if (C == Red || C == Yellow) return 1;
Index: clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -239,6 +239,11 @@
   (OpcodeRHS == BO_LT || OpcodeRHS == BO_LE))
 return true;
 
+  // Handle cases where constants are different but both ops are !=, like:
+  // x != 5 || x != 10
+  if (OpcodeLHS == BO_NE && OpcodeRHS == BO_NE)
+return true;
+
   return false;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29753: [PCH] Avoid early VarDecl emission attempt if no owning module avaiable

2017-02-28 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

In https://reviews.llvm.org/D29753#688845, @bruno wrote:

> > What do folks think?
>
> IMO we should do it.


Go ahead and commit this, but keep the bug open so we can work on fixing it 
properly eventually.


https://reviews.llvm.org/D29753



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


[PATCH] D30430: Make Lit tests C++11 compatible - IR ordering

2017-02-28 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296549: [Test] Make Lit tests C++11 compatible - IR ordering 
(authored by lcharles).

Changed prior to commit:
  https://reviews.llvm.org/D30430?vs=90078&id=90101#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30430

Files:
  cfe/trunk/test/CodeGenCXX/template-instantiation.cpp


Index: cfe/trunk/test/CodeGenCXX/template-instantiation.cpp
===
--- cfe/trunk/test/CodeGenCXX/template-instantiation.cpp
+++ cfe/trunk/test/CodeGenCXX/template-instantiation.cpp
@@ -1,21 +1,22 @@
-// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 
-emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 
-std=c++11 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 
-std=c++11 -emit-llvm -o - | FileCheck %s --check-prefix=CHECK2
 
-// CHECK: @_ZN7PR100011xE = global
-// CHECK-NOT: @_ZN7PR100014kBarE = external global i32
-//
-// CHECK-NOT: @_ZTVN5test118stdio_sync_filebufIwEE = constant
-// CHECK-NOT: _ZTVN5test315basic_fstreamXXIcEE
-// CHECK-NOT: @_ZTVN5test018stdio_sync_filebufIA1_iEE
-// CHECK-NOT: @_ZTVN5test018stdio_sync_filebufIA2_iEE
-// CHECK: @_ZTVN5test018stdio_sync_filebufIA3_iEE = weak_odr unnamed_addr 
constant
+// Instantiation order varies on different C++ dialects (IE, between C++98 and 
C++11).
+// CHECK-DAG: @_ZN7PR100011xE = global
+// CHECK-DAG: @_ZTVN5test018stdio_sync_filebufIA3_iEE = weak_odr unnamed_addr 
constant
+// CHECK-DAG: @_ZN7PR100011SIiE3arrE = linkonce_odr global [3 x i32]
+// CHECK-DAG: @_ZTVN5test018stdio_sync_filebufIA4_iEE = linkonce_odr 
unnamed_addr constant
+
+// Negative checks go under prefix "CHECK2" to avoid interference with CHECK 
and CHECK-DAG.
+// CHECK2-NOT: @_ZN7PR100014kBarE = external global i32
+// CHECK2-NOT: @_ZTVN5test118stdio_sync_filebufIwEE = constant
+// CHECK2-NOT: _ZTVN5test315basic_fstreamXXIcEE
+// CHECK2-NOT: @_ZTVN5test018stdio_sync_filebufIA1_iEE
+// CHECK2-NOT: @_ZTVN5test018stdio_sync_filebufIA2_iEE
+// CHECK2-NOT: @_ZN7PR100011SIiE3arr2E = linkonce_odr global [3 x i32]A
 
-// CHECK: @_ZN7PR100011SIiE3arrE = linkonce_odr global [3 x i32]
-// CHECK-NOT: @_ZN7PR100011SIiE3arr2E = linkonce_odr global [3 x i32]A
-
-// CHECK: @_ZTVN5test018stdio_sync_filebufIA4_iEE = linkonce_odr 
unnamed_addr constant
-
-// CHECK-NOT: _ZTVN5test31SIiEE
-// CHECK-NOT: _ZTSN5test31SIiEE
+// CHECK2-NOT: _ZTVN5test31SIiEE
+// CHECK2-NOT: _ZTSN5test31SIiEE
 
 // CHECK-LABEL: define linkonce_odr void 
@_ZN5test21CIiEC1Ev(%"class.test2::C"* %this) unnamed_addr
 // CHECK-LABEL: define linkonce_odr void @_ZN5test21CIiE6foobarIdEEvT_(
@@ -152,7 +153,7 @@
   void f () {}
 };
 // Should not instantiate class B since it is introduced in namespace scope.
-// CHECK-NOT: _ZN6PR85051AILi0EE1B1fEv
+// CHECK2-NOT: _ZN6PR85051AILi0EE1B1fEv
 template class A<0>;
 }
 


Index: cfe/trunk/test/CodeGenCXX/template-instantiation.cpp
===
--- cfe/trunk/test/CodeGenCXX/template-instantiation.cpp
+++ cfe/trunk/test/CodeGenCXX/template-instantiation.cpp
@@ -1,21 +1,22 @@
-// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - | FileCheck %s --check-prefix=CHECK2
 
-// CHECK: @_ZN7PR100011xE = global
-// CHECK-NOT: @_ZN7PR100014kBarE = external global i32
-//
-// CHECK-NOT: @_ZTVN5test118stdio_sync_filebufIwEE = constant
-// CHECK-NOT: _ZTVN5test315basic_fstreamXXIcEE
-// CHECK-NOT: @_ZTVN5test018stdio_sync_filebufIA1_iEE
-// CHECK-NOT: @_ZTVN5test018stdio_sync_filebufIA2_iEE
-// CHECK: @_ZTVN5test018stdio_sync_filebufIA3_iEE = weak_odr unnamed_addr constant
+// Instantiation order varies on different C++ dialects (IE, between C++98 and C++11).
+// CHECK-DAG: @_ZN7PR100011xE = global
+// CHECK-DAG: @_ZTVN5test018stdio_sync_filebufIA3_iEE = weak_odr unnamed_addr constant
+// CHECK-DAG: @_ZN7PR100011SIiE3arrE = linkonce_odr global [3 x i32]
+// CHECK-DAG: @_ZTVN5test018stdio_sync_filebufIA4_iEE = linkonce_odr unnamed_addr constant
+
+// Negative checks go under prefix "CHECK2" to avoid interference with CHECK and CHECK-DAG.
+// CHECK2-NOT: @_ZN7PR100014kBarE = external global i32
+// CHECK2-NOT: @_ZTVN5test118stdio_sync_filebufIwEE = constant
+// CHECK2-NOT: _ZTVN5test315basic_fstreamXXIcEE
+// CHECK2-NOT: @_ZTVN5test018stdio_sync_filebufIA1_iEE
+// CHECK2-NOT: @_ZTVN5test018stdio_sync_filebufIA2_iEE
+// CHECK2-NOT: @_ZN7PR100011SIiE3arr2E = linkonce_odr global [3 x i32]A
 
-// CHECK: @_ZN7PR100011SIiE3arrE = linkonce_odr global [3 x i32]
-// CHECK-NOT: @_ZN7PR100011SIiE3

r296549 - [Test] Make Lit tests C++11 compatible - IR ordering

2017-02-28 Thread Charles Li via cfe-commits
Author: lcharles
Date: Tue Feb 28 18:10:00 2017
New Revision: 296549

URL: http://llvm.org/viewvc/llvm-project?rev=296549&view=rev
Log:
[Test] Make Lit tests C++11 compatible - IR ordering

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

Modified:
cfe/trunk/test/CodeGenCXX/template-instantiation.cpp

Modified: cfe/trunk/test/CodeGenCXX/template-instantiation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/template-instantiation.cpp?rev=296549&r1=296548&r2=296549&view=diff
==
--- cfe/trunk/test/CodeGenCXX/template-instantiation.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/template-instantiation.cpp Tue Feb 28 18:10:00 
2017
@@ -1,21 +1,22 @@
-// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 
-emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 
-std=c++11 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 
-std=c++11 -emit-llvm -o - | FileCheck %s --check-prefix=CHECK2
 
-// CHECK: @_ZN7PR100011xE = global
-// CHECK-NOT: @_ZN7PR100014kBarE = external global i32
-//
-// CHECK-NOT: @_ZTVN5test118stdio_sync_filebufIwEE = constant
-// CHECK-NOT: _ZTVN5test315basic_fstreamXXIcEE
-// CHECK-NOT: @_ZTVN5test018stdio_sync_filebufIA1_iEE
-// CHECK-NOT: @_ZTVN5test018stdio_sync_filebufIA2_iEE
-// CHECK: @_ZTVN5test018stdio_sync_filebufIA3_iEE = weak_odr unnamed_addr 
constant
+// Instantiation order varies on different C++ dialects (IE, between C++98 and 
C++11).
+// CHECK-DAG: @_ZN7PR100011xE = global
+// CHECK-DAG: @_ZTVN5test018stdio_sync_filebufIA3_iEE = weak_odr unnamed_addr 
constant
+// CHECK-DAG: @_ZN7PR100011SIiE3arrE = linkonce_odr global [3 x i32]
+// CHECK-DAG: @_ZTVN5test018stdio_sync_filebufIA4_iEE = linkonce_odr 
unnamed_addr constant
+
+// Negative checks go under prefix "CHECK2" to avoid interference with CHECK 
and CHECK-DAG.
+// CHECK2-NOT: @_ZN7PR100014kBarE = external global i32
+// CHECK2-NOT: @_ZTVN5test118stdio_sync_filebufIwEE = constant
+// CHECK2-NOT: _ZTVN5test315basic_fstreamXXIcEE
+// CHECK2-NOT: @_ZTVN5test018stdio_sync_filebufIA1_iEE
+// CHECK2-NOT: @_ZTVN5test018stdio_sync_filebufIA2_iEE
+// CHECK2-NOT: @_ZN7PR100011SIiE3arr2E = linkonce_odr global [3 x i32]A
 
-// CHECK: @_ZN7PR100011SIiE3arrE = linkonce_odr global [3 x i32]
-// CHECK-NOT: @_ZN7PR100011SIiE3arr2E = linkonce_odr global [3 x i32]A
-
-// CHECK: @_ZTVN5test018stdio_sync_filebufIA4_iEE = linkonce_odr 
unnamed_addr constant
-
-// CHECK-NOT: _ZTVN5test31SIiEE
-// CHECK-NOT: _ZTSN5test31SIiEE
+// CHECK2-NOT: _ZTVN5test31SIiEE
+// CHECK2-NOT: _ZTSN5test31SIiEE
 
 // CHECK-LABEL: define linkonce_odr void 
@_ZN5test21CIiEC1Ev(%"class.test2::C"* %this) unnamed_addr
 // CHECK-LABEL: define linkonce_odr void @_ZN5test21CIiE6foobarIdEEvT_(
@@ -152,7 +153,7 @@ class B {
   void f () {}
 };
 // Should not instantiate class B since it is introduced in namespace scope.
-// CHECK-NOT: _ZN6PR85051AILi0EE1B1fEv
+// CHECK2-NOT: _ZN6PR85051AILi0EE1B1fEv
 template class A<0>;
 }
 


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


[PATCH] D29157: [libc++] Make _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS export members

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

LGTM, but with a macro other than `_LIBCPP_HIDDEN`.

Also could you please add doc explaining the rational for this new macro in 
depth. I think the summary for this revision would be sufficient.


https://reviews.llvm.org/D29157



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


[PATCH] D29157: [libc++] Make _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS export members

2017-02-28 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: include/string:1100
 template
+inline _LIBCPP_INLINE_VISIBILITY
 typename enable_if

smeenai wrote:
> EricWF wrote:
> > Why `inline _LIBCPP_INLINE_VISIBILITY` here but `_LIBCPP_HIDDEN` everywhere 
> > else?
> This function is really small, so I figured marking it for inlining was more 
> appropriate.
This should probably have _LIBCPP_INLINE_VISIBILITY on it then.


https://reviews.llvm.org/D29157



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


r296554 - [PS4] Set our default dialect to C++11. NFC for other targets.

2017-02-28 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Tue Feb 28 19:01:10 2017
New Revision: 296554

URL: http://llvm.org/viewvc/llvm-project?rev=296554&view=rev
Log:
[PS4] Set our default dialect to C++11. NFC for other targets.
Reapplies r296209 now that r296549 has fixed what really seems to be
the last problematic test.

Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=296554&r1=296553&r2=296554&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Feb 28 19:01:10 2017
@@ -1582,7 +1582,11 @@ void CompilerInvocation::setLangDefaults
 case IK_PreprocessedCXX:
 case IK_ObjCXX:
 case IK_PreprocessedObjCXX:
-  LangStd = LangStandard::lang_gnucxx98;
+  // The PS4 uses C++11 as the default C++ standard.
+  if (T.isPS4())
+LangStd = LangStandard::lang_gnucxx11;
+  else
+LangStd = LangStandard::lang_gnucxx98;
   break;
 case IK_RenderScript:
   LangStd = LangStandard::lang_c99;


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


[libcxx] r296558 - Updated the XFAIL comment in variant tests.

2017-02-28 Thread Michael Park via cfe-commits
Author: mpark
Date: Tue Feb 28 19:07:56 2017
New Revision: 296558

URL: http://llvm.org/viewvc/llvm-project?rev=296558&view=rev
Log:
Updated the XFAIL comment in variant tests.

Summary:
`ConstexprTestTypes::NoCtors` is an aggregate type (and consequently a literal 
type) in C++17,
but not in C++14 since it has a base class. This patch updates the comment to 
accurately describe the reason for the XFAIL.

Reviewers: EricWF

Reviewed By: EricWF

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

Modified:

libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/index.pass.cpp

libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/valueless_by_exception.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/index.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/index.pass.cpp?rev=296558&r1=296557&r2=296558&view=diff
==
--- 
libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/index.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/index.pass.cpp
 Tue Feb 28 19:07:56 2017
@@ -10,7 +10,10 @@
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 
-// The following compilers don't allow constexpr variables of non-literal type.
+// The following compilers don't consider a type an aggregate type (and
+// consequently not a literal type) if it has a base class at all.
+// In C++17, an aggregate type is allowed to have a base class if it's not
+// virtual, private, nor protected (e.g. ConstexprTestTypes:::NoCtors).
 // XFAIL: gcc-5, gcc-6
 // XFAIL: clang-3.5, clang-3.6, clang-3.7, clang-3.8
 // XFAIL: apple-clang-6, apple-clang-7, apple-clang-8

Modified: 
libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/valueless_by_exception.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/valueless_by_exception.pass.cpp?rev=296558&r1=296557&r2=296558&view=diff
==
--- 
libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/valueless_by_exception.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/valueless_by_exception.pass.cpp
 Tue Feb 28 19:07:56 2017
@@ -10,7 +10,10 @@
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 
-// The following compilers don't allow constexpr variables of non-literal type.
+// The following compilers don't consider a type an aggregate type (and
+// consequently not a literal type) if it has a base class at all.
+// In C++17, an aggregate type is allowed to have a base class if it's not
+// virtual, private, nor protected (e.g. ConstexprTestTypes:::NoCtors).
 // XFAIL: gcc-5, gcc-6
 // XFAIL: clang-3.5, clang-3.6, clang-3.7, clang-3.8
 // XFAIL: apple-clang-6, apple-clang-7, apple-clang-8


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


[libcxx] r296561 - Fix PR32097 - is_abstract doesn't work on class templates.

2017-02-28 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Feb 28 19:27:14 2017
New Revision: 296561

URL: http://llvm.org/viewvc/llvm-project?rev=296561&view=rev
Log:
Fix PR32097 - is_abstract doesn't work on class templates.

This patch fixes llvm.org/PR32097 by using the __is_abstract
builtin type-trait instead of the previous library-only implementation.

All supported compilers provide this trait. I've tested as far
back as Clang 3.2, GCC 4.6 and MSVC trunk.

Modified:
libcxx/trunk/include/type_traits

libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp

Modified: libcxx/trunk/include/type_traits
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=296561&r1=296560&r2=296561&view=diff
==
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Tue Feb 28 19:27:14 2017
@@ -1297,18 +1297,8 @@ template  using decay_t = typ
 
 // is_abstract
 
-namespace __is_abstract_imp
-{
-template  char  __test(_Tp (*)[1]);
-template  __two __test(...);
-}
-
-template ::value>
-struct __libcpp_abstract : public integral_constant(0)) != 1> {};
-
-template  struct __libcpp_abstract<_Tp, false> : public false_type 
{};
-
-template  struct _LIBCPP_TEMPLATE_VIS is_abstract : public 
__libcpp_abstract<_Tp> {};
+template  struct _LIBCPP_TEMPLATE_VIS is_abstract
+: public integral_constant {};
 
 #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
 template  _LIBCPP_CONSTEXPR bool is_abstract_v

Modified: 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp?rev=296561&r1=296560&r2=296561&view=diff
==
--- 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp
 Tue Feb 28 19:27:14 2017
@@ -65,6 +65,14 @@ class Abstract
 virtual ~Abstract() = 0;
 };
 
+template 
+struct AbstractTemplate {
+  virtual void test() = 0;
+};
+
+template <>
+struct AbstractTemplate {};
+
 int main()
 {
 test_is_not_abstract();
@@ -81,4 +89,6 @@ int main()
 test_is_not_abstract();
 
 test_is_abstract();
+test_is_abstract >();
+test_is_not_abstract >();
 }


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


[PATCH] D29157: [libc++] Make _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS export members

2017-02-28 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added inline comments.



Comment at: include/string:1100
 template
+inline _LIBCPP_INLINE_VISIBILITY
 typename enable_if

EricWF wrote:
> smeenai wrote:
> > EricWF wrote:
> > > Why `inline _LIBCPP_INLINE_VISIBILITY` here but `_LIBCPP_HIDDEN` 
> > > everywhere else?
> > This function is really small, so I figured marking it for inlining was 
> > more appropriate.
> This should probably have _LIBCPP_INLINE_VISIBILITY on it then.
I was assuming any client that cares about what they're exporting would build 
with `-fvisibility-inlines-hidden`, in which case just `inline` should be 
enough.


https://reviews.llvm.org/D29157



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


[PATCH] D29157: [libc++] Make _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS export members

2017-02-28 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai updated this revision to Diff 90108.
smeenai edited the summary of this revision.
smeenai added a comment.

Addressing comments


https://reviews.llvm.org/D29157

Files:
  docs/DesignDocs/VisibilityMacros.rst
  include/__config
  include/locale
  include/string

Index: include/string
===
--- include/string
+++ include/string
@@ -792,6 +792,7 @@
 basic_string(const basic_string& __str, size_type __pos,
  const _Allocator& __a = _Allocator());
 template
+_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
 basic_string(const _Tp& __t, size_type __pos, size_type __n,
  const allocator_type& __a = allocator_type(),
  typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type* = 0);
Index: include/locale
===
--- include/locale
+++ include/locale
@@ -623,16 +623,19 @@
 ~num_get() {}
 
 template 
+_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
 iter_type __do_get_floating_point
 (iter_type __b, iter_type __e, ios_base& __iob,
  ios_base::iostate& __err, _Fp& __v) const;
 
 template 
+_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
 iter_type __do_get_signed
 (iter_type __b, iter_type __e, ios_base& __iob,
  ios_base::iostate& __err, _Signed& __v) const;
 
 template 
+_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
 iter_type __do_get_unsigned
 (iter_type __b, iter_type __e, ios_base& __iob,
  ios_base::iostate& __err, _Unsigned& __v) const;
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -591,6 +591,7 @@
 #define _LIBCPP_EXTERN_VIS  _LIBCPP_DLL_VIS
 #define _LIBCPP_EXCEPTION_ABI   _LIBCPP_DLL_VIS
 #define _LIBCPP_HIDDEN
+#define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
 #define _LIBCPP_TEMPLATE_VIS
 #define _LIBCPP_FUNC_VIS_ONLY
 #define _LIBCPP_ENUM_VIS
@@ -614,6 +615,8 @@
 #endif
 #endif
 
+#define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_HIDDEN
+
 #ifndef _LIBCPP_FUNC_VIS
 #if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
 #define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default")))
@@ -668,7 +671,7 @@
 
 #ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
 #  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
-#define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__type_visibility__("default")))
+#define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__visibility__("default")))
 #  else
 #define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
 #  endif
Index: docs/DesignDocs/VisibilityMacros.rst
===
--- docs/DesignDocs/VisibilityMacros.rst
+++ docs/DesignDocs/VisibilityMacros.rst
@@ -110,6 +110,35 @@
   the extern template declaration) as exported on Windows, as discussed above.
   On all other platforms, this macro has an empty definition.
 
+**_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS**
+  Mark a symbol as hidden so it will not be exported from shared libraries. This
+  is intended specifically for method templates of either classes marked with
+  `_LIBCPP_TYPE_VIS` or classes with an extern template instantiation
+  declaration marked with `_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS`.
+
+  When building libc++ with hidden visibility, we want explicit template
+  instantiations to export members, which is consistent with existing Windows
+  behavior. We also want classes annotated with `_LIBCPP_TYPE_VIS` to export
+  their members, which is again consistent with existing Windows behavior.
+  Both these changes are necessary for clients to be able to link against a
+  libc++ DSO built with hidden visibility without encountering missing symbols.
+
+  An unfortunate side effect, however, is that method templates of classes
+  either marked `_LIBCPP_TYPE_VIS` or with extern template instantiation
+  declarations marked with `_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS` also get default
+  visibility when instantiated. These methods are often implicitly instantiated
+  inside other libraries which use the libc++ headers, and will therefore end up
+  being exported from those libraries, since those implicit instantiations will
+  receive default visibility. This is not acceptable for libraries that wish to
+  control their visibility, and led to PR30642.
+
+  Consequently, all such problematic method templates are explicitly marked
+  either hidden (via this macro) or inline, so that they don't leak into client
+  libraries. The problematic methods were found by running
+  `bad-visibility-finder 

[PATCH] D25208: [libc++] Make _LIBCPP_TYPE_VIS export members

2017-02-28 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai updated this revision to Diff 90109.
smeenai added a comment.

Rebase atop https://reviews.llvm.org/D29157 and switch to 
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS


https://reviews.llvm.org/D25208

Files:
  docs/DesignDocs/VisibilityMacros.rst
  include/__config
  include/__locale
  include/__mutex_base
  include/condition_variable
  include/future
  include/mutex
  include/thread

Index: include/thread
===
--- include/thread
+++ include/thread
@@ -300,7 +300,9 @@
  >
 explicit thread(_Fp&& __f, _Args&&... __args);
 #else  // _LIBCPP_HAS_NO_VARIADICS
-template  explicit thread(_Fp __f);
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+explicit thread(_Fp __f);
 #endif
 ~thread();
 
Index: include/mutex
===
--- include/mutex
+++ include/mutex
@@ -248,6 +248,7 @@
 bool try_lock_for(const chrono::duration<_Rep, _Period>& __d)
 {return try_lock_until(chrono::steady_clock::now() + __d);}
 template 
+_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
 bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t);
 void unlock() _NOEXCEPT;
 };
@@ -291,6 +292,7 @@
 bool try_lock_for(const chrono::duration<_Rep, _Period>& __d)
 {return try_lock_until(chrono::steady_clock::now() + __d);}
 template 
+_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
 bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t);
 void unlock() _NOEXCEPT;
 };
Index: include/future
===
--- include/future
+++ include/future
@@ -582,6 +582,7 @@
 _LIBCPP_INLINE_VISIBILITY
 wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const;
 template 
+_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
 future_status
 wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const;
 
@@ -1674,6 +1675,7 @@
 public:
 promise();
 template 
+_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
 promise(allocator_arg_t, const _Allocator& __a);
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 _LIBCPP_INLINE_VISIBILITY
Index: include/condition_variable
===
--- include/condition_variable
+++ include/condition_variable
@@ -133,12 +133,14 @@
 void notify_all() _NOEXCEPT;
 
 template 
+_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
 void wait(_Lock& __lock);
 template 
 _LIBCPP_INLINE_VISIBILITY
 void wait(_Lock& __lock, _Predicate __pred);
 
 template 
+_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
 cv_status
 wait_until(_Lock& __lock,
const chrono::time_point<_Clock, _Duration>& __t);
Index: include/__mutex_base
===
--- include/__mutex_base
+++ include/__mutex_base
@@ -316,20 +316,24 @@
 
 void wait(unique_lock& __lk) _NOEXCEPT;
 template 
+inline _LIBCPP_INLINE_VISIBILITY
 void wait(unique_lock& __lk, _Predicate __pred);
 
 template 
+_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
 cv_status
 wait_until(unique_lock& __lk,
const chrono::time_point<_Clock, _Duration>& __t);
 
 template 
+_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
 bool
 wait_until(unique_lock& __lk,
const chrono::time_point<_Clock, _Duration>& __t,
_Predicate __pred);
 
 template 
+_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
 cv_status
 wait_for(unique_lock& __lk,
  const chrono::duration<_Rep, _Period>& __d);
Index: include/__locale
===
--- include/__locale
+++ include/__locale
@@ -92,13 +92,16 @@
 
 const locale& operator=(const locale&)  _NOEXCEPT;
 
-template  locale combine(const locale&) const;
+template 
+  inline _LIBCPP_INLINE_VISIBILITY
+  locale combine(const locale&) const;
 
 // locale operations:
 string name() const;
 bool operator==(const locale&) const;
 bool operator!=(const locale& __y) const {return !(*this == __y);}
 template 
+  inline _LIBCPP_INLINE_VISIBILITY
   bool operator()(const basic_string<_CharT, _Traits, _Allocator>&,
   const basic_string<_CharT, _Traits, _Allocator>&) const;
 
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -627,18 +627,22 @@
 
 #ifndef _LIBCPP_TYPE_VIS
 #  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
-#if __has_attribute(__type_visibility__)
-#  define _LIBCP

r296562 - [Analyzer] Fix crash in ObjCPropertyChecker on protocol property

2017-02-28 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Tue Feb 28 19:47:37 2017
New Revision: 296562

URL: http://llvm.org/viewvc/llvm-project?rev=296562&view=rev
Log:
[Analyzer] Fix crash in ObjCPropertyChecker on protocol property

Fix a crash in the ObjCPropertyChecker when analyzing a 'copy' property of an
NSMutable* type in a protocol.

rdar://problem/30766684

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp
cfe/trunk/test/Analysis/ObjCPropertiesSyntaxChecks.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp?rev=296562&r1=296561&r2=296562&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp Tue Feb 28 
19:47:37 2017
@@ -58,8 +58,7 @@ void ObjCPropertyChecker::checkCopyMutab
   if (const ObjCInterfaceDecl *IntD =
   dyn_cast(D->getDeclContext())) {
 ImplD = IntD->getImplementation();
-  } else {
-const ObjCCategoryDecl *CatD = cast(D->getDeclContext());
+  } else if (auto *CatD = dyn_cast(D->getDeclContext())) {
 ImplD = CatD->getClassInterface()->getImplementation();
   }
 

Modified: cfe/trunk/test/Analysis/ObjCPropertiesSyntaxChecks.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/ObjCPropertiesSyntaxChecks.m?rev=296562&r1=296561&r2=296562&view=diff
==
--- cfe/trunk/test/Analysis/ObjCPropertiesSyntaxChecks.m (original)
+++ cfe/trunk/test/Analysis/ObjCPropertiesSyntaxChecks.m Tue Feb 28 19:47:37 
2017
@@ -59,3 +59,10 @@
 @interface IWithoutImpl : NSObject {}
 @property(copy) NSMutableString *mutableStr; // no-warning
 @end
+
+@protocol SomeProtocol
+// Don't warn on protocol properties because it is possible to
+// conform to them correctly; it is only synthesized setters that
+// that are definitely incorrect.
+@property (copy) NSMutableString *myProp; // no-crash // no-warning
+@end


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


[libcxx] r296565 - Improve diagnostics when an invalid hash is used in an unordered container.

2017-02-28 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Feb 28 20:02:28 2017
New Revision: 296565

URL: http://llvm.org/viewvc/llvm-project?rev=296565&view=rev
Log:
Improve diagnostics when an invalid hash is used in an unordered container.

This patch adds a static assertion that the specified hash meets
the requirements of an enabled hash, and it ensures that the static
assertion is evaluated before __compressed_pair is instantiated.
That way the static assertion diagnostic is emitted first.

Added:

libcxx/trunk/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp
Modified:
libcxx/trunk/include/__hash_table

Modified: libcxx/trunk/include/__hash_table
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__hash_table?rev=296565&r1=296564&r2=296565&view=diff
==
--- libcxx/trunk/include/__hash_table (original)
+++ libcxx/trunk/include/__hash_table Tue Feb 28 20:02:28 2017
@@ -871,11 +871,20 @@ public:
 template 
 struct __diagnose_hash_table_helper {
   static constexpr bool __trigger_diagnostics()
-  _LIBCPP_DIAGNOSE_WARNING(!__invokable<_Hash const&, _Key const&>::value,
-"the specified hash functor does not provide a const call operator")
-  _LIBCPP_DIAGNOSE_WARNING(!__invokable<_Equal const&, _Key const&, _Key 
const&>::value,
-"the specified comparator type does not provide a const call operator")
-  { return true; }
+_LIBCPP_DIAGNOSE_WARNING(__has_enabled_hash<_Key, _Hash>::value
+ && !__invokable<_Hash const&, _Key const&>::value,
+  "the specified hash functor does not provide a const call operator")
+_LIBCPP_DIAGNOSE_WARNING(is_copy_constructible<_Equal>::value
+  && !__invokable<_Equal const&, _Key const&, _Key 
const&>::value,
+  "the specified comparator type does not provide a const call operator")
+  {
+static_assert(__has_enabled_hash<_Key, _Hash>::value,
+  "the specified hash functor does not meet the requirements for an "
+  "enabled hash");
+static_assert(is_copy_constructible<_Equal>::value,
+  "the specified comparator is required to be copy constructible");
+return true;
+  }
 };
 
 template 
@@ -951,6 +960,10 @@ private:
 typedef allocator_traits<__pointer_allocator>  
__pointer_alloc_traits;
 typedef typename __bucket_list_deleter::pointer   
__node_pointer_pointer;
 
+#ifndef _LIBCPP_CXX03_LANG
+static_assert(__diagnose_hash_table_helper<_Tp, _Hash, _Equal, 
_Alloc>::__trigger_diagnostics(), "");
+#endif
+
 // --- Member data begin ---
 __bucket_list __bucket_list_;
 __compressed_pair<__first_node, __node_allocator> __p1_;
@@ -1482,13 +1495,13 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
 template 
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table()
 {
+#if defined(_LIBCPP_CXX03_LANG)
 static_assert((is_copy_constructible::value),
  "Predicate must be copy-constructible.");
 static_assert((is_copy_constructible::value),
  "Hasher must be copy-constructible.");
-#ifndef _LIBCPP_CXX03_LANG
-static_assert(__diagnose_hash_table_helper<_Tp, _Hash, _Equal, 
_Alloc>::__trigger_diagnostics(), "");
 #endif
+
 __deallocate_node(__p1_.first().__next_);
 #if _LIBCPP_DEBUG_LEVEL >= 2
 __get_db()->__erase_c(this);

Added: 
libcxx/trunk/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp?rev=296565&view=auto
==
--- 
libcxx/trunk/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp
 (added)
+++ 
libcxx/trunk/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp
 Tue Feb 28 20:02:28 2017
@@ -0,0 +1,32 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+// REQUIRES: diagnose-if-support
+
+// 
+
+// Test that we generate a reasonable diagnostic when the specified hash is
+// not enabled.
+
+#include 
+#include 
+
+using VT = std::pair;
+using Set = std::unordered_set;
+
+int main() {
+
+  Set s; // expected-error@__hash_table:* {{the specified hash functor does 
not meet the requirements for an enabled hash}}
+
+  // FIXME: It would be great to suppress the below diagnostic all together.
+  //but for now it's sufficient that it appears last. However there is
+  //currently no way to test the order diagnostics are issued.
+  // expected-error@memory:* {{call t

[libcxxabi] r296567 - Fix non-reserved macro names LIBCXXABI_NORETURN and LIBCXXABI_ARM_EHABI.

2017-02-28 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Feb 28 20:23:54 2017
New Revision: 296567

URL: http://llvm.org/viewvc/llvm-project?rev=296567&view=rev
Log:
Fix non-reserved macro names LIBCXXABI_NORETURN and LIBCXXABI_ARM_EHABI.

This patch adds the required leading underscore to those macros.

Modified:
libcxxabi/trunk/include/__cxxabi_config.h
libcxxabi/trunk/include/cxxabi.h
libcxxabi/trunk/src/cxa_aux_runtime.cpp
libcxxabi/trunk/src/cxa_exception.cpp
libcxxabi/trunk/src/cxa_exception.hpp
libcxxabi/trunk/src/cxa_personality.cpp
libcxxabi/trunk/src/cxa_virtual.cpp

Modified: libcxxabi/trunk/include/__cxxabi_config.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/include/__cxxabi_config.h?rev=296567&r1=296566&r2=296567&view=diff
==
--- libcxxabi/trunk/include/__cxxabi_config.h (original)
+++ libcxxabi/trunk/include/__cxxabi_config.h Tue Feb 28 20:23:54 2017
@@ -12,9 +12,9 @@
 
 #if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) && 
\
 !defined(__ARM_DWARF_EH__)
-#define LIBCXXABI_ARM_EHABI 1
+#define _LIBCXXABI_ARM_EHABI 1
 #else
-#define LIBCXXABI_ARM_EHABI 0
+#define _LIBCXXABI_ARM_EHABI 0
 #endif
 
 #if !defined(__has_attribute)

Modified: libcxxabi/trunk/include/cxxabi.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/include/cxxabi.h?rev=296567&r1=296566&r2=296567&view=diff
==
--- libcxxabi/trunk/include/cxxabi.h (original)
+++ libcxxabi/trunk/include/cxxabi.h Tue Feb 28 20:23:54 2017
@@ -21,7 +21,7 @@
 #include <__cxxabi_config.h>
 
 #define _LIBCPPABI_VERSION 1002
-#define LIBCXXABI_NORETURN  __attribute__((noreturn))
+#define _LIBCXXABI_NORETURN  __attribute__((noreturn))
 
 #ifdef __cplusplus
 
@@ -45,7 +45,7 @@ extern _LIBCXXABI_FUNC_VIS void
 __cxa_free_exception(void *thrown_exception) throw();
 
 // 2.4.3 Throwing the Exception Object
-extern _LIBCXXABI_FUNC_VIS LIBCXXABI_NORETURN void
+extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void
 __cxa_throw(void *thrown_exception, std::type_info *tinfo,
 void (*dest)(void *));
 
@@ -55,7 +55,7 @@ __cxa_get_exception_ptr(void *exceptionO
 extern _LIBCXXABI_FUNC_VIS void *
 __cxa_begin_catch(void *exceptionObject) throw();
 extern _LIBCXXABI_FUNC_VIS void __cxa_end_catch();
-#if LIBCXXABI_ARM_EHABI
+#if _LIBCXXABI_ARM_EHABI
 extern _LIBCXXABI_FUNC_VIS bool
 __cxa_begin_cleanup(void *exceptionObject) throw();
 extern _LIBCXXABI_FUNC_VIS void __cxa_end_cleanup();
@@ -63,19 +63,19 @@ extern _LIBCXXABI_FUNC_VIS void __cxa_en
 extern _LIBCXXABI_FUNC_VIS std::type_info *__cxa_current_exception_type();
 
 // 2.5.4 Rethrowing Exceptions
-extern _LIBCXXABI_FUNC_VIS LIBCXXABI_NORETURN void __cxa_rethrow();
+extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_rethrow();
 
 // 2.6 Auxiliary Runtime APIs
-extern _LIBCXXABI_FUNC_VIS LIBCXXABI_NORETURN void __cxa_bad_cast(void);
-extern _LIBCXXABI_FUNC_VIS LIBCXXABI_NORETURN void __cxa_bad_typeid(void);
-extern _LIBCXXABI_FUNC_VIS LIBCXXABI_NORETURN void
+extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_bad_cast(void);
+extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_bad_typeid(void);
+extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void
 __cxa_throw_bad_array_new_length(void);
 
 // 3.2.6 Pure Virtual Function API
-extern _LIBCXXABI_FUNC_VIS LIBCXXABI_NORETURN void __cxa_pure_virtual(void);
+extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_pure_virtual(void);
 
 // 3.2.7 Deleted Virtual Function API
-extern _LIBCXXABI_FUNC_VIS LIBCXXABI_NORETURN void __cxa_deleted_virtual(void);
+extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void 
__cxa_deleted_virtual(void);
 
 // 3.3.2 One-time Construction API
 #ifdef __arm__

Modified: libcxxabi/trunk/src/cxa_aux_runtime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_aux_runtime.cpp?rev=296567&r1=296566&r2=296567&view=diff
==
--- libcxxabi/trunk/src/cxa_aux_runtime.cpp (original)
+++ libcxxabi/trunk/src/cxa_aux_runtime.cpp Tue Feb 28 20:23:54 2017
@@ -16,7 +16,7 @@
 
 namespace __cxxabiv1 {
 extern "C" {
-_LIBCXXABI_FUNC_VIS LIBCXXABI_NORETURN void __cxa_bad_cast(void) {
+_LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_bad_cast(void) {
 #ifndef _LIBCXXABI_NO_EXCEPTIONS
   throw std::bad_cast();
 #else
@@ -24,7 +24,7 @@ _LIBCXXABI_FUNC_VIS LIBCXXABI_NORETURN v
 #endif
 }
 
-_LIBCXXABI_FUNC_VIS LIBCXXABI_NORETURN void __cxa_bad_typeid(void) {
+_LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_bad_typeid(void) {
 #ifndef _LIBCXXABI_NO_EXCEPTIONS
   throw std::bad_typeid();
 #else
@@ -32,7 +32,7 @@ _LIBCXXABI_FUNC_VIS LIBCXXABI_NORETURN v
 #endif
 }
 
-_LIBCXXABI_FUNC_VIS LIBCXXABI_NORETURN void
+_LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void
 __cxa_throw_bad_array_new_length(void) {
 #ifndef _LIBCXXABI_NO_EXCEPTIONS
   throw std::ba

  1   2   >