Re: [PATCH] D20420: [find-all-symbol] Add macro support.

2016-05-20 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 57901.
hokein added a comment.

Correct the header comments.


http://reviews.llvm.org/D20420

Files:
  include-fixer/find-all-symbols/CMakeLists.txt
  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.h
  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
  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
@@ -1,16 +1,18 @@
-//===-- FindAllSymbolsTests.cpp - find all symbols unit tests -===//
+//===-- FindAllSymbolsTests.cpp - find all symbols unit tests ---*- C++ -*-===//
 //
 // The LLVM Compiler Infrastructure
 //
 // This file is distributed under the University of Illinois Open Source
 // License. See LICENSE.TXT for details.
 //
 //===--===//
 
+#include "FindAllMacros.h"
 #include "FindAllSymbols.h"
 #include "HeaderMapCollector.h"
 #include "PragmaCommentHandler.h"
 #include "SymbolInfo.h"
+#include "SymbolReporter.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileSystemOptions.h"
@@ -31,17 +33,16 @@
 
 static const char HeaderName[] = "symbols.h";
 
-class MockReporter
-: public clang::find_all_symbols::FindAllSymbols::ResultReporter {
+class TestSymbolReporter : public clang::find_all_symbols::SymbolReporter {
 public:
-  ~MockReporter() override {}
+  ~TestSymbolReporter() override {}
 
-  void reportResult(llvm::StringRef FileName,
+  void reportSymbol(llvm::StringRef FileName,
 const SymbolInfo &Symbol) override {
 Symbols.push_back(Symbol);
   }
 
-  bool hasSymbol(const SymbolInfo &Symbol) {
+  bool hasSymbol(const SymbolInfo &Symbol) const {
 for (const auto &S : Symbols) {
   if (S == Symbol)
 return true;
@@ -55,20 +56,23 @@
 
 class TestFindAllSymbolsAction : public clang::ASTFrontendAction {
 public:
-  TestFindAllSymbolsAction(FindAllSymbols::ResultReporter *Reporter)
-  : MatchFinder(), Collector(), Handler(&Collector),
+  TestFindAllSymbolsAction(SymbolReporter *Reporter)
+  : Reporter(Reporter), MatchFinder(), Collector(), Handler(&Collector),
 Matcher(Reporter, &Collector) {
 Matcher.registerMatchers(&MatchFinder);
   }
 
   std::unique_ptr
   CreateASTConsumer(clang::CompilerInstance &Compiler,
 StringRef InFile) override {
 Compiler.getPreprocessor().addCommentHandler(&Handler);
+Compiler.getPreprocessor().addPPCallbacks(llvm::make_unique(
+Reporter, &Collector, &Compiler.getSourceManager()));
 return MatchFinder.newASTConsumer();
   }
 
 private:
+  SymbolReporter *const Reporter;
   ast_matchers::MatchFinder MatchFinder;
   HeaderMapCollector Collector;
   PragmaCommentHandler Handler;
@@ -78,14 +82,14 @@
 class TestFindAllSymbolsActionFactory
 : public clang::tooling::FrontendActionFactory {
 public:
-  TestFindAllSymbolsActionFactory(MockReporter *Reporter)
+  TestFindAllSymbolsActionFactory(TestSymbolReporter *Reporter)
   : Reporter(Reporter) {}
   clang::FrontendAction *create() override {
 return new TestFindAllSymbolsAction(Reporter);
   }
 
 private:
-  MockReporter *const Reporter;
+  TestSymbolReporter *const Reporter;
 };
 
 class FindAllSymbolsTest : public ::testing::Test {
@@ -122,7 +126,7 @@
   }
 
 private:
-  MockReporter Reporter;
+  TestSymbolReporter Reporter;
 };
 
 TEST_F(FindAllSymbolsTest, VariableSymbols) {
@@ -378,5 +382,42 @@
   EXPECT_TRUE(hasSymbol(Symbol));
 }
 
+TEST_F(FindAllSymbolsTest, MacroTest) {
+  static const char Code[] = R"(
+#define X
+#define Y 1
+#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
+  )";
+  runFindAllSymbols(Code);
+  SymbolInfo Symbol =
+  SymbolInfo("X", SymbolInfo::SymbolKind::Macro, HeaderName, 2, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo("Y", SymbolInfo::SymbolKind::Macro, HeaderName, 3, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo("MAX", SymbolInfo::SymbolKind::Macro, HeaderName, 4, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+}
+
+TEST_F(FindAllSymbolsTest, MacroTestWithIWYU) {
+  static const char Code[] = R"(
+// IWYU pragma: private, include "bar.h"
+#define X
+#define Y 1
+#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
+  )";
+  runFindAllSymbols(Code);
+  SymbolInfo Symbol =
+  SymbolInfo("X", Sym

Re: [PATCH] D20420: [find-all-symbol] Add macro support.

2016-05-20 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 57902.
hokein added a comment.

Remove an unneeded file.


http://reviews.llvm.org/D20420

Files:
  include-fixer/find-all-symbols/CMakeLists.txt
  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/SymbolInfo.cpp
  include-fixer/find-all-symbols/SymbolInfo.h
  include-fixer/find-all-symbols/SymbolReporter.h
  include-fixer/find-all-symbols/tool/FindAllSymbolsMain.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
@@ -1,16 +1,18 @@
-//===-- FindAllSymbolsTests.cpp - find all symbols unit tests -===//
+//===-- FindAllSymbolsTests.cpp - find all symbols unit tests ---*- C++ -*-===//
 //
 // The LLVM Compiler Infrastructure
 //
 // This file is distributed under the University of Illinois Open Source
 // License. See LICENSE.TXT for details.
 //
 //===--===//
 
+#include "FindAllMacros.h"
 #include "FindAllSymbols.h"
 #include "HeaderMapCollector.h"
 #include "PragmaCommentHandler.h"
 #include "SymbolInfo.h"
+#include "SymbolReporter.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileSystemOptions.h"
@@ -31,17 +33,16 @@
 
 static const char HeaderName[] = "symbols.h";
 
-class MockReporter
-: public clang::find_all_symbols::FindAllSymbols::ResultReporter {
+class TestSymbolReporter : public clang::find_all_symbols::SymbolReporter {
 public:
-  ~MockReporter() override {}
+  ~TestSymbolReporter() override {}
 
-  void reportResult(llvm::StringRef FileName,
+  void reportSymbol(llvm::StringRef FileName,
 const SymbolInfo &Symbol) override {
 Symbols.push_back(Symbol);
   }
 
-  bool hasSymbol(const SymbolInfo &Symbol) {
+  bool hasSymbol(const SymbolInfo &Symbol) const {
 for (const auto &S : Symbols) {
   if (S == Symbol)
 return true;
@@ -55,20 +56,23 @@
 
 class TestFindAllSymbolsAction : public clang::ASTFrontendAction {
 public:
-  TestFindAllSymbolsAction(FindAllSymbols::ResultReporter *Reporter)
-  : MatchFinder(), Collector(), Handler(&Collector),
+  TestFindAllSymbolsAction(SymbolReporter *Reporter)
+  : Reporter(Reporter), MatchFinder(), Collector(), Handler(&Collector),
 Matcher(Reporter, &Collector) {
 Matcher.registerMatchers(&MatchFinder);
   }
 
   std::unique_ptr
   CreateASTConsumer(clang::CompilerInstance &Compiler,
 StringRef InFile) override {
 Compiler.getPreprocessor().addCommentHandler(&Handler);
+Compiler.getPreprocessor().addPPCallbacks(llvm::make_unique(
+Reporter, &Collector, &Compiler.getSourceManager()));
 return MatchFinder.newASTConsumer();
   }
 
 private:
+  SymbolReporter *const Reporter;
   ast_matchers::MatchFinder MatchFinder;
   HeaderMapCollector Collector;
   PragmaCommentHandler Handler;
@@ -78,14 +82,14 @@
 class TestFindAllSymbolsActionFactory
 : public clang::tooling::FrontendActionFactory {
 public:
-  TestFindAllSymbolsActionFactory(MockReporter *Reporter)
+  TestFindAllSymbolsActionFactory(TestSymbolReporter *Reporter)
   : Reporter(Reporter) {}
   clang::FrontendAction *create() override {
 return new TestFindAllSymbolsAction(Reporter);
   }
 
 private:
-  MockReporter *const Reporter;
+  TestSymbolReporter *const Reporter;
 };
 
 class FindAllSymbolsTest : public ::testing::Test {
@@ -122,7 +126,7 @@
   }
 
 private:
-  MockReporter Reporter;
+  TestSymbolReporter Reporter;
 };
 
 TEST_F(FindAllSymbolsTest, VariableSymbols) {
@@ -378,5 +382,42 @@
   EXPECT_TRUE(hasSymbol(Symbol));
 }
 
+TEST_F(FindAllSymbolsTest, MacroTest) {
+  static const char Code[] = R"(
+#define X
+#define Y 1
+#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
+  )";
+  runFindAllSymbols(Code);
+  SymbolInfo Symbol =
+  SymbolInfo("X", SymbolInfo::SymbolKind::Macro, HeaderName, 2, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo("Y", SymbolInfo::SymbolKind::Macro, HeaderName, 3, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo("MAX", SymbolInfo::SymbolKind::Macro, HeaderName, 4, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+}
+
+TEST_F(FindAllSymbolsTest, MacroTestWithIWYU) {
+  static const char Code[] = R"(
+// IWYU pragma: private, include "bar.h"
+#define X
+#define Y 1
+#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
+  )";
+  runFindAllSymbols(Code);
+  SymbolInfo Symbol =
+  SymbolInfo("X", SymbolInfo::SymbolKind::Macro, "bar.h", 3, {});
+  EXPECT_TRUE(

Re: [PATCH] D20420: [find-all-symbol] Add macro support.

2016-05-20 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270189: [find-all-symbol] Add macro support. (authored by 
hokein).

Changed prior to commit:
  http://reviews.llvm.org/D20420?vs=57902&id=57903#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20420

Files:
  clang-tools-extra/trunk/include-fixer/find-all-symbols/CMakeLists.txt
  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/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/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -1,16 +1,18 @@
-//===-- FindAllSymbolsTests.cpp - find all symbols unit tests -===//
+//===-- FindAllSymbolsTests.cpp - find all symbols unit tests ---*- C++ -*-===//
 //
 // The LLVM Compiler Infrastructure
 //
 // This file is distributed under the University of Illinois Open Source
 // License. See LICENSE.TXT for details.
 //
 //===--===//
 
+#include "FindAllMacros.h"
 #include "FindAllSymbols.h"
 #include "HeaderMapCollector.h"
 #include "PragmaCommentHandler.h"
 #include "SymbolInfo.h"
+#include "SymbolReporter.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileSystemOptions.h"
@@ -31,17 +33,16 @@
 
 static const char HeaderName[] = "symbols.h";
 
-class MockReporter
-: public clang::find_all_symbols::FindAllSymbols::ResultReporter {
+class TestSymbolReporter : public clang::find_all_symbols::SymbolReporter {
 public:
-  ~MockReporter() override {}
+  ~TestSymbolReporter() override {}
 
-  void reportResult(llvm::StringRef FileName,
+  void reportSymbol(llvm::StringRef FileName,
 const SymbolInfo &Symbol) override {
 Symbols.push_back(Symbol);
   }
 
-  bool hasSymbol(const SymbolInfo &Symbol) {
+  bool hasSymbol(const SymbolInfo &Symbol) const {
 for (const auto &S : Symbols) {
   if (S == Symbol)
 return true;
@@ -55,20 +56,23 @@
 
 class TestFindAllSymbolsAction : public clang::ASTFrontendAction {
 public:
-  TestFindAllSymbolsAction(FindAllSymbols::ResultReporter *Reporter)
-  : MatchFinder(), Collector(), Handler(&Collector),
+  TestFindAllSymbolsAction(SymbolReporter *Reporter)
+  : Reporter(Reporter), MatchFinder(), Collector(), Handler(&Collector),
 Matcher(Reporter, &Collector) {
 Matcher.registerMatchers(&MatchFinder);
   }
 
   std::unique_ptr
   CreateASTConsumer(clang::CompilerInstance &Compiler,
 StringRef InFile) override {
 Compiler.getPreprocessor().addCommentHandler(&Handler);
+Compiler.getPreprocessor().addPPCallbacks(llvm::make_unique(
+Reporter, &Collector, &Compiler.getSourceManager()));
 return MatchFinder.newASTConsumer();
   }
 
 private:
+  SymbolReporter *const Reporter;
   ast_matchers::MatchFinder MatchFinder;
   HeaderMapCollector Collector;
   PragmaCommentHandler Handler;
@@ -78,14 +82,14 @@
 class TestFindAllSymbolsActionFactory
 : public clang::tooling::FrontendActionFactory {
 public:
-  TestFindAllSymbolsActionFactory(MockReporter *Reporter)
+  TestFindAllSymbolsActionFactory(TestSymbolReporter *Reporter)
   : Reporter(Reporter) {}
   clang::FrontendAction *create() override {
 return new TestFindAllSymbolsAction(Reporter);
   }
 
 private:
-  MockReporter *const Reporter;
+  TestSymbolReporter *const Reporter;
 };
 
 class FindAllSymbolsTest : public ::testing::Test {
@@ -122,7 +126,7 @@
   }
 
 private:
-  MockReporter Reporter;
+  TestSymbolReporter Reporter;
 };
 
 TEST_F(FindAllSymbolsTest, VariableSymbols) {
@@ -378,5 +382,42 @@
   EXPECT_TRUE(hasSymbol(Symbol));
 }
 
+TEST_F(FindAllSymbolsTest, MacroTest) {
+  static const char Code[] = R"(
+#define X
+#define Y 1
+#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
+  )";
+  runFindAllSymbols(Code);
+  SymbolInfo Symbol =
+  SymbolInfo("X", SymbolInfo::SymbolKind::Macro, HeaderName, 2, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo("Y", SymbolInfo::SymbolKind::Macro, HeaderName, 3, {});
+  EXPECT_TRUE(hasSymbol(S

[clang-tools-extra] r270189 - [find-all-symbol] Add macro support.

2016-05-20 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri May 20 03:04:36 2016
New Revision: 270189

URL: http://llvm.org/viewvc/llvm-project?rev=270189&view=rev
Log:
[find-all-symbol] Add macro support.

Reviewers: bkramer

Subscribers: cfe-commits, ioeric

Differential Revision: http://reviews.llvm.org/D20420

Added:
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/SymbolReporter.h
Modified:
clang-tools-extra/trunk/include-fixer/find-all-symbols/CMakeLists.txt
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/SymbolInfo.cpp
clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h

clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp

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

Modified: clang-tools-extra/trunk/include-fixer/find-all-symbols/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/CMakeLists.txt?rev=270189&r1=270188&r2=270189&view=diff
==
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/CMakeLists.txt 
(original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/CMakeLists.txt Fri 
May 20 03:04:36 2016
@@ -4,6 +4,7 @@ set(LLVM_LINK_COMPONENTS
 
 add_clang_library(findAllSymbols
   FindAllSymbols.cpp
+  FindAllMacros.cpp
   PragmaCommentHandler.cpp
   SymbolInfo.cpp
 

Added: clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllMacros.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllMacros.cpp?rev=270189&view=auto
==
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllMacros.cpp 
(added)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllMacros.cpp 
Fri May 20 03:04:36 2016
@@ -0,0 +1,45 @@
+//===-- FindAllMacros.cpp - find all macros -*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "FindAllMacros.h"
+#include "HeaderMapCollector.h"
+#include "SymbolInfo.h"
+#include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Lex/Token.h"
+
+namespace clang {
+namespace find_all_symbols {
+
+void FindAllMacros::MacroDefined(const Token &MacroNameTok,
+ const MacroDirective *MD) {
+  SourceLocation Loc = SM->getExpansionLoc(MacroNameTok.getLocation());
+  if (Loc.isInvalid() || SM->isInMainFile(Loc))
+return;
+
+  llvm::StringRef FilePath = SM->getFilename(Loc);
+  if (FilePath.empty())
+return;
+
+  // Check pragma remapping header.
+  auto HeaderMappingTable = Collector->getHeaderMappingTable();
+  auto Iter = HeaderMappingTable.find(FilePath);
+  if (Iter != HeaderMappingTable.end())
+FilePath = Iter->second;
+
+  SymbolInfo Symbol(MacroNameTok.getIdentifierInfo()->getName(),
+SymbolInfo::SymbolKind::Macro, FilePath.str(),
+SM->getSpellingLineNumber(Loc), {});
+
+  Reporter->reportSymbol(SM->getFileEntryForID(SM->getMainFileID())->getName(),
+ Symbol);
+}
+
+} // namespace find_all_symbols
+} // namespace clang

Added: clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllMacros.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllMacros.h?rev=270189&view=auto
==
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllMacros.h 
(added)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllMacros.h Fri 
May 20 03:04:36 2016
@@ -0,0 +1,48 @@
+//===-- FindAllMacros.h - find all macros ---*- C++ 
-*-===//
+//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_FIND_ALL_MACROS_H
+#define LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_FIND_ALL_MACROS_H
+
+#include "SymbolInfo.h"
+#include "SymbolReporter.h"
+#include "clang/Lex/PPCallbacks.h"
+
+namespace clang {
+namespace find_all_symbols {
+
+class HeaderMapCollector;
+
+/// \brief A preprocessor that collects

Re: [PATCH] D20429: [clang-tidy] Handle using-decls with more than one shadow decl.

2016-05-20 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 57904.
hokein added a comment.

Address more comments.


http://reviews.llvm.org/D20429

Files:
  clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  clang-tidy/misc/UnusedUsingDeclsCheck.h
  test/clang-tidy/misc-unused-using-decls.cpp

Index: test/clang-tidy/misc-unused-using-decls.cpp
===
--- test/clang-tidy/misc-unused-using-decls.cpp
+++ test/clang-tidy/misc-unused-using-decls.cpp
@@ -31,6 +31,8 @@
 template  int UsedTemplateFunc() { return 1; }
 template  int UnusedTemplateFunc() { return 1; }
 template  int UsedInTemplateFunc() { return 1; }
+void OverloadFunc(int);
+void OverloadFunc(double);
 
 class ostream {
 public:
@@ -79,6 +81,10 @@
   UsedInTemplateFunc();
 }
 
+using n::OverloadFunc; // OverloadFunc
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'OverloadFunc' is unused
+// CHECK-FIXES: {{^}}// OverloadFunc
+
 #define DEFINE_INT(name)\
   namespace INT {   \
   static const int _##name = 1; \
Index: clang-tidy/misc/UnusedUsingDeclsCheck.h
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.h
+++ clang-tidy/misc/UnusedUsingDeclsCheck.h
@@ -11,7 +11,8 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_UNUSED_USING_DECLS_H
 
 #include "../ClangTidy.h"
-#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallPtrSet.h"
+#include 
 
 namespace clang {
 namespace tidy {
@@ -32,8 +33,16 @@
 private:
   void removeFromFoundDecls(const Decl *D);
 
-  llvm::DenseMap FoundDecls;
-  llvm::DenseMap FoundRanges;
+  struct UsingDeclContext {
+explicit UsingDeclContext(const UsingDecl *FoundUsingDecl)
+: FoundUsingDecl(FoundUsingDecl), IsUsed(false) {}
+llvm::SmallPtrSet UsingTargetDecls;
+const UsingDecl *FoundUsingDecl;
+CharSourceRange UsingDeclRange;
+bool IsUsed;
+  };
+
+  std::vector Contexts;
 };
 
 } // namespace misc
Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -18,6 +18,25 @@
 namespace tidy {
 namespace misc {
 
+// A function that helps to tell whether a TargetDecl will be checked.
+// We only check a TargetDecl if :
+//   * The corresponding UsingDecl is not defined in macros or in class
+// definitions.
+//   * Only variable, function and class types are considered.
+static bool ShouldCheckDecl(const Decl *TargetDecl) {
+  // Ignores using-declarations defined in macros.
+  if (TargetDecl->getLocation().isMacroID())
+return false;
+
+  // Ignores using-declarations defined in class definition.
+  if (isa(TargetDecl->getDeclContext()))
+return false;
+
+  return isa(TargetDecl) || isa(TargetDecl) ||
+ isa(TargetDecl) || isa(TargetDecl) ||
+ isa(TargetDecl);
+}
+
 void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(usingDecl(isExpansionInMainFile()).bind("using"), this);
   auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
@@ -30,33 +49,20 @@
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
   if (const auto *Using = Result.Nodes.getNodeAs("using")) {
-// FIXME: Implement the correct behavior for using declarations with more
-// than one shadow.
-if (Using->shadow_size() != 1)
-  return;
-const auto *TargetDecl =
-Using->shadow_begin()->getTargetDecl()->getCanonicalDecl();
-
-// Ignores using-declarations defined in macros.
-if (TargetDecl->getLocation().isMacroID())
-  return;
-
-// Ignores using-declarations defined in class definition.
-if (isa(TargetDecl->getDeclContext()))
-  return;
-
-if (!isa(TargetDecl) && !isa(TargetDecl) &&
-!isa(TargetDecl) && !isa(TargetDecl) &&
-!isa(TargetDecl))
-  return;
-
-FoundDecls[TargetDecl] = Using;
-FoundRanges[TargetDecl] = CharSourceRange::getCharRange(
+UsingDeclContext Context(Using);
+Context.UsingDeclRange = CharSourceRange::getCharRange(
 Using->getLocStart(),
 Lexer::findLocationAfterToken(
 Using->getLocEnd(), tok::semi, *Result.SourceManager,
 Result.Context->getLangOpts(),
 /*SkipTrailingWhitespaceAndNewLine=*/true));
+for (const auto *UsingShadow : Using->shadows()) {
+  const auto *TargetDecl = UsingShadow->getTargetDecl()->getCanonicalDecl();
+  if (ShouldCheckDecl(TargetDecl))
+Context.UsingTargetDecls.insert(TargetDecl);
+}
+if (!Context.UsingTargetDecls.empty())
+  Contexts.push_back(Context);
 return;
   }
 
@@ -93,20 +99,23 @@
 }
 
 void UnusedUsingDeclsCheck::removeFromFoundDecls(const Decl *D) {
-  auto I = FoundDecls.find(D->getCanonicalDecl());
-  if (I != FoundDecls.end())
-I->second = nullptr;
+  for (auto &Context : Contexts) {
+if (Context.UsingTargetDecls.count(D->getCa

Re: [PATCH] D20429: [clang-tidy] Handle using-decls with more than one shadow decl.

2016-05-20 Thread Haojian Wu via cfe-commits
hokein marked 2 inline comments as done.


Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:59
@@ -59,1 +58,3 @@
 /*SkipTrailingWhitespaceAndNewLine=*/true));
+for (const auto It : Using->shadows()) {
+  const auto *TargetDecl = It->getTargetDecl()->getCanonicalDecl();

alexfh wrote:
> It's not iterator, so `It` is a confusing name. Something along the lines of 
> `Shadow` or `UsingShadow` should be better.
Actually, the `Using->shadows()` returns an iterator range, but I'm fine 
renaming it here.


http://reviews.llvm.org/D20429



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


[clang-tools-extra] r270191 - [clang-tidy] Handle using-decls with more than one shadow decl.

2016-05-20 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri May 20 03:34:32 2016
New Revision: 270191

URL: http://llvm.org/viewvc/llvm-project?rev=270191&view=rev
Log:
[clang-tidy] Handle using-decls with more than one shadow decl.

Reviewers: alexfh

Subscribers: cfe-commits, djasper

Differential Revision: http://reviews.llvm.org/D20429

Modified:
clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.h
clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp?rev=270191&r1=270190&r2=270191&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp Fri May 
20 03:34:32 2016
@@ -18,6 +18,25 @@ namespace clang {
 namespace tidy {
 namespace misc {
 
+// A function that helps to tell whether a TargetDecl will be checked.
+// We only check a TargetDecl if :
+//   * The corresponding UsingDecl is not defined in macros or in class
+// definitions.
+//   * Only variable, function and class types are considered.
+static bool ShouldCheckDecl(const Decl *TargetDecl) {
+  // Ignores using-declarations defined in macros.
+  if (TargetDecl->getLocation().isMacroID())
+return false;
+
+  // Ignores using-declarations defined in class definition.
+  if (isa(TargetDecl->getDeclContext()))
+return false;
+
+  return isa(TargetDecl) || isa(TargetDecl) ||
+ isa(TargetDecl) || isa(TargetDecl) ||
+ isa(TargetDecl);
+}
+
 void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(usingDecl(isExpansionInMainFile()).bind("using"), this);
   auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
@@ -30,33 +49,20 @@ void UnusedUsingDeclsCheck::registerMatc
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
   if (const auto *Using = Result.Nodes.getNodeAs("using")) {
-// FIXME: Implement the correct behavior for using declarations with more
-// than one shadow.
-if (Using->shadow_size() != 1)
-  return;
-const auto *TargetDecl =
-Using->shadow_begin()->getTargetDecl()->getCanonicalDecl();
-
-// Ignores using-declarations defined in macros.
-if (TargetDecl->getLocation().isMacroID())
-  return;
-
-// Ignores using-declarations defined in class definition.
-if (isa(TargetDecl->getDeclContext()))
-  return;
-
-if (!isa(TargetDecl) && !isa(TargetDecl) &&
-!isa(TargetDecl) && !isa(TargetDecl) &&
-!isa(TargetDecl))
-  return;
-
-FoundDecls[TargetDecl] = Using;
-FoundRanges[TargetDecl] = CharSourceRange::getCharRange(
+UsingDeclContext Context(Using);
+Context.UsingDeclRange = CharSourceRange::getCharRange(
 Using->getLocStart(),
 Lexer::findLocationAfterToken(
 Using->getLocEnd(), tok::semi, *Result.SourceManager,
 Result.Context->getLangOpts(),
 /*SkipTrailingWhitespaceAndNewLine=*/true));
+for (const auto *UsingShadow : Using->shadows()) {
+  const auto *TargetDecl = 
UsingShadow->getTargetDecl()->getCanonicalDecl();
+  if (ShouldCheckDecl(TargetDecl))
+Context.UsingTargetDecls.insert(TargetDecl);
+}
+if (!Context.UsingTargetDecls.empty())
+  Contexts.push_back(Context);
 return;
   }
 
@@ -93,20 +99,23 @@ void UnusedUsingDeclsCheck::check(const
 }
 
 void UnusedUsingDeclsCheck::removeFromFoundDecls(const Decl *D) {
-  auto I = FoundDecls.find(D->getCanonicalDecl());
-  if (I != FoundDecls.end())
-I->second = nullptr;
+  for (auto &Context : Contexts) {
+if (Context.UsingTargetDecls.count(D->getCanonicalDecl()) > 0) {
+  Context.IsUsed = true;
+  break;
+}
+  }
 }
 
 void UnusedUsingDeclsCheck::onEndOfTranslationUnit() {
-  for (const auto &FoundDecl : FoundDecls) {
-if (FoundDecl.second == nullptr)
-  continue;
-diag(FoundDecl.second->getLocation(), "using decl %0 is unused")
-<< FoundDecl.second
-<< FixItHint::CreateRemoval(FoundRanges[FoundDecl.first]);
+  for (const auto &Context : Contexts) {
+if (!Context.IsUsed) {
+  diag(Context.FoundUsingDecl->getLocation(), "using decl %0 is unused")
+  << Context.FoundUsingDecl
+  << FixItHint::CreateRemoval(Context.UsingDeclRange);
+}
   }
-  FoundDecls.clear();
+  Contexts.clear();
 }
 
 } // namespace misc

Modified: clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.h?rev=270191&r1=270190&r2=270191&view=diff
==
--- clang-tools-extra/tr

Re: [PATCH] D20429: [clang-tidy] Handle using-decls with more than one shadow decl.

2016-05-20 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
hokein marked an inline comment as done.
Closed by commit rL270191: [clang-tidy] Handle using-decls with more than one 
shadow decl. (authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D20429?vs=57904&id=57906#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20429

Files:
  clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.h
  clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp

Index: clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.h
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.h
@@ -11,7 +11,8 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_UNUSED_USING_DECLS_H
 
 #include "../ClangTidy.h"
-#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallPtrSet.h"
+#include 
 
 namespace clang {
 namespace tidy {
@@ -32,8 +33,16 @@
 private:
   void removeFromFoundDecls(const Decl *D);
 
-  llvm::DenseMap FoundDecls;
-  llvm::DenseMap FoundRanges;
+  struct UsingDeclContext {
+explicit UsingDeclContext(const UsingDecl *FoundUsingDecl)
+: FoundUsingDecl(FoundUsingDecl), IsUsed(false) {}
+llvm::SmallPtrSet UsingTargetDecls;
+const UsingDecl *FoundUsingDecl;
+CharSourceRange UsingDeclRange;
+bool IsUsed;
+  };
+
+  std::vector Contexts;
 };
 
 } // namespace misc
Index: clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -18,6 +18,25 @@
 namespace tidy {
 namespace misc {
 
+// A function that helps to tell whether a TargetDecl will be checked.
+// We only check a TargetDecl if :
+//   * The corresponding UsingDecl is not defined in macros or in class
+// definitions.
+//   * Only variable, function and class types are considered.
+static bool ShouldCheckDecl(const Decl *TargetDecl) {
+  // Ignores using-declarations defined in macros.
+  if (TargetDecl->getLocation().isMacroID())
+return false;
+
+  // Ignores using-declarations defined in class definition.
+  if (isa(TargetDecl->getDeclContext()))
+return false;
+
+  return isa(TargetDecl) || isa(TargetDecl) ||
+ isa(TargetDecl) || isa(TargetDecl) ||
+ isa(TargetDecl);
+}
+
 void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(usingDecl(isExpansionInMainFile()).bind("using"), this);
   auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
@@ -30,33 +49,20 @@
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
   if (const auto *Using = Result.Nodes.getNodeAs("using")) {
-// FIXME: Implement the correct behavior for using declarations with more
-// than one shadow.
-if (Using->shadow_size() != 1)
-  return;
-const auto *TargetDecl =
-Using->shadow_begin()->getTargetDecl()->getCanonicalDecl();
-
-// Ignores using-declarations defined in macros.
-if (TargetDecl->getLocation().isMacroID())
-  return;
-
-// Ignores using-declarations defined in class definition.
-if (isa(TargetDecl->getDeclContext()))
-  return;
-
-if (!isa(TargetDecl) && !isa(TargetDecl) &&
-!isa(TargetDecl) && !isa(TargetDecl) &&
-!isa(TargetDecl))
-  return;
-
-FoundDecls[TargetDecl] = Using;
-FoundRanges[TargetDecl] = CharSourceRange::getCharRange(
+UsingDeclContext Context(Using);
+Context.UsingDeclRange = CharSourceRange::getCharRange(
 Using->getLocStart(),
 Lexer::findLocationAfterToken(
 Using->getLocEnd(), tok::semi, *Result.SourceManager,
 Result.Context->getLangOpts(),
 /*SkipTrailingWhitespaceAndNewLine=*/true));
+for (const auto *UsingShadow : Using->shadows()) {
+  const auto *TargetDecl = UsingShadow->getTargetDecl()->getCanonicalDecl();
+  if (ShouldCheckDecl(TargetDecl))
+Context.UsingTargetDecls.insert(TargetDecl);
+}
+if (!Context.UsingTargetDecls.empty())
+  Contexts.push_back(Context);
 return;
   }
 
@@ -93,20 +99,23 @@
 }
 
 void UnusedUsingDeclsCheck::removeFromFoundDecls(const Decl *D) {
-  auto I = FoundDecls.find(D->getCanonicalDecl());
-  if (I != FoundDecls.end())
-I->second = nullptr;
+  for (auto &Context : Contexts) {
+if (Context.UsingTargetDecls.count(D->getCanonicalDecl()) > 0) {
+  Context.IsUsed = true;
+  break;
+}
+  }
 }
 
 void UnusedUsingDeclsCheck::onEndOfTranslationUnit() {
-  for (const auto &FoundDecl : FoundDecls) {
-if (FoundDecl.second == nullptr)
-  continue;
-diag(FoundDecl.second->getLocation(), "using decl %0 is unused")
-<< 

Re: [PATCH] D20437: [MSVC] Support of __unaligned qualifier for function types

2016-05-20 Thread Andrey Bokhanko via cfe-commits
andreybokhanko updated this revision to Diff 57907.
andreybokhanko added a comment.

Added a test for __unaligned arrays.


http://reviews.llvm.org/D20437

Files:
  include/clang/AST/Type.h
  include/clang/Sema/DeclSpec.h
  lib/AST/DeclCXX.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenCXX/mangle-ms-cxx11.cpp
  test/Sema/MicrosoftExtensions.c
  test/SemaCXX/MicrosoftExtensions.cpp

Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -1643,7 +1643,7 @@
 
   QualType ClassTy = C.getTypeDeclType(getParent());
   ClassTy = C.getQualifiedType(ClassTy,
-   Qualifiers::fromCVRMask(getTypeQualifiers()));
+   Qualifiers::fromCVRUMask(getTypeQualifiers()));
   return C.getPointerType(ClassTy);
 }
 
Index: lib/AST/MicrosoftMangle.cpp
===
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -1447,7 +1447,8 @@
   if (HasRestrict)
 Out << 'I';
 
-  if (!PointeeType.isNull() && PointeeType.getLocalQualifiers().hasUnaligned())
+  if (Quals.hasUnaligned() ||
+  (!PointeeType.isNull() && PointeeType.getLocalQualifiers().hasUnaligned()))
 Out << 'F';
 }
 
@@ -1822,7 +1823,7 @@
   // If this is a C++ instance method, mangle the CVR qualifiers for the
   // this pointer.
   if (HasThisQuals) {
-Qualifiers Quals = Qualifiers::fromCVRMask(Proto->getTypeQuals());
+Qualifiers Quals = Qualifiers::fromCVRUMask(Proto->getTypeQuals());
 manglePointerExtQualifiers(Quals, /*PointeeType=*/QualType());
 mangleRefQualifier(Proto->getRefQualifier());
 mangleQualifiers(Quals, /*IsMember=*/false);
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -2668,8 +2668,8 @@
 { "const", DeclSpec::TQ_const, ConstQualLoc },
 { "volatile", DeclSpec::TQ_volatile, VolatileQualLoc },
 { "restrict", DeclSpec::TQ_restrict, RestrictQualLoc },
-{ "_Atomic", DeclSpec::TQ_atomic, AtomicQualLoc },
-{ "__unaligned", DeclSpec::TQ_unaligned, UnalignedQualLoc }
+{ "__unaligned", DeclSpec::TQ_unaligned, UnalignedQualLoc },
+{ "_Atomic", DeclSpec::TQ_atomic, AtomicQualLoc }
   };
 
   SmallString<32> QualStr;
Index: lib/Sema/DeclSpec.cpp
===
--- lib/Sema/DeclSpec.cpp
+++ lib/Sema/DeclSpec.cpp
@@ -796,8 +796,8 @@
   case TQ_const:TQ_constLoc = Loc; return false;
   case TQ_restrict: TQ_restrictLoc = Loc; return false;
   case TQ_volatile: TQ_volatileLoc = Loc; return false;
-  case TQ_atomic:   TQ_atomicLoc = Loc; return false;
   case TQ_unaligned: TQ_unalignedLoc = Loc; return false;
+  case TQ_atomic:   TQ_atomicLoc = Loc; return false;
   }
 
   llvm_unreachable("Unknown type qualifier!");
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -934,6 +934,7 @@
   else
 Record = cast(ContextDecl);
 
+  CXXThisTypeQuals &= Qualifiers::FastMask;
   S.CXXThisTypeOverride
 = S.Context.getPointerType(
 S.Context.getRecordType(Record).withCVRQualifiers(CXXThisTypeQuals));
Index: include/clang/AST/Type.h
===
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -215,6 +215,12 @@
 return Qs;
   }
 
+  static Qualifiers fromCVRUMask(unsigned CVRU) {
+Qualifiers Qs;
+Qs.addCVRUQualifiers(CVRU);
+return Qs;
+  }
+
   // Deserialize qualifiers from an opaque representation.
   static Qualifiers fromOpaqueValue(unsigned opaque) {
 Qualifiers Qs;
@@ -265,6 +271,10 @@
 assert(!(mask & ~CVRMask) && "bitmask contains non-CVR bits");
 Mask |= mask;
   }
+  void addCVRUQualifiers(unsigned mask) {
+assert(!(mask & ~CVRMask & ~UMask) && "bitmask contains non-CVRU bits");
+Mask |= mask;
+  }
 
   bool hasUnaligned() const { return Mask & UMask; }
   void setUnaligned(bool flag) {
@@ -1372,7 +1382,7 @@
 ///
 /// C++ 8.3.5p4: The return type, the parameter type list and the
 /// cv-qualifier-seq, [...], are part of the function type.
-unsigned TypeQuals : 3;
+unsigned TypeQuals : 4;
 
 /// \brief The ref-qualifier associated with a \c FunctionProtoType.
 ///
Index: include/clang/Sema/DeclSpec.h
===
--- include/clang/Sema/DeclSpec.h
+++ include/clang/Sema/DeclSpec.h
@@ -311,12 +311,10 @@
 TQ_const   = 1,
 TQ_restrict= 2,
 TQ_volatile= 4,
+TQ_unaligned   = 8,
 // This has no corresponding Qualifiers::TQ value, because it's not treated
 // as a qualifier in our type system.
-TQ_atomic  = 8,
-// There is no

Re: [PATCH] D20437: [MSVC] Support of __unaligned qualifier for function types

2016-05-20 Thread Andrey Bokhanko via cfe-commits
andreybokhanko marked 2 inline comments as done.


Comment at: include/clang/Sema/DeclSpec.h:1152-1169
@@ -1153,19 +1151,20 @@
 
   struct ArrayTypeInfo : TypeInfoCommon {
-/// The type qualifiers for the array: const/volatile/restrict/_Atomic.
-unsigned TypeQuals : 4;
+/// The type qualifiers for the array:
+/// const/volatile/restrict/__unaligned/_Atomic.
+unsigned TypeQuals : 5;
 
 /// True if this dimension included the 'static' keyword.
 bool hasStatic : 1;
 
 /// True if this dimension was [*].  In this case, NumElts is null.
 bool isStar : 1;
 
 /// This is the size of the array, or null if [] or [*] was specified.
 /// Since the parser is multi-purpose, and we don't want to impose a root
 /// expression class on all clients, NumElts is untyped.
 Expr *NumElts;
 
 void destroy() {}
   };
 

Yes, MSVC does carry __unaligned in arrays. I added a test to 
MicrosoftExtensions.cpp.


Comment at: include/clang/Sema/DeclSpec.h:1414-1418
@@ -1414,7 +1413,7 @@
 
   struct MemberPointerTypeInfo : TypeInfoCommon {
-/// The type qualifiers: const/volatile/restrict/_Atomic.
-unsigned TypeQuals : 4;
+/// The type qualifiers: const/volatile/restrict/__unaligned/_Atomic.
+unsigned TypeQuals : 5;
 // CXXScopeSpec has a constructor, so it can't be a direct member.
 // So we need some pointer-aligned storage and a bit of trickery.
 union {

The same. A test already exists in MicrosoftExtensions.cpp (line 121).


http://reviews.llvm.org/D20437



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


Re: [PATCH] D20429: [clang-tidy] Handle using-decls with more than one shadow decl.

2016-05-20 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:59
@@ -59,1 +58,3 @@
 /*SkipTrailingWhitespaceAndNewLine=*/true));
+for (const auto It : Using->shadows()) {
+  const auto *TargetDecl = It->getTargetDecl()->getCanonicalDecl();

hokein wrote:
> alexfh wrote:
> > It's not iterator, so `It` is a confusing name. Something along the lines 
> > of `Shadow` or `UsingShadow` should be better.
> Actually, the `Using->shadows()` returns an iterator range, but I'm fine 
> renaming it here.
Sure, it returns a `llvm::iterator_range`, which is just a 
range adaptor for a pair of iterators. It's not a "collection of iterators", 
it's a "collection, defined by a pair of iterators". If you iterate over it 
using a range-based for loop, you get whatever is pointed by the iterators, not 
iterators.


Repository:
  rL LLVM

http://reviews.llvm.org/D20429



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


[PATCH] D20463: [clang-tidy] Add more descriptive comments and examples in misc-definitions-in-headers check.

2016-05-20 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: alexfh.
hokein added a subscriber: cfe-commits.

http://reviews.llvm.org/D20463

Files:
  docs/clang-tidy/checks/misc-definitions-in-headers.rst

Index: docs/clang-tidy/checks/misc-definitions-in-headers.rst
===
--- docs/clang-tidy/checks/misc-definitions-in-headers.rst
+++ docs/clang-tidy/checks/misc-definitions-in-headers.rst
@@ -4,36 +4,71 @@
 Finds non-extern non-inline function and variable definitions in header files,
 which can lead to potential ODR violations.
 
+If these headers are included from multiple translation units, there will be
+redefinition linker errors.
+
 .. code:: c++
 
// Foo.h
-   int a = 1; // Warning.
+   int a = 1; // Warning: variable definition.
extern int d; // OK: extern variable.
 
namespace N {
- int e = 2; // Warning.
+ int e = 2; // Warning: variable definition.
}
 
-   // Internal linkage variable definitions are ignored for now.
+   // Warning: variable definition.
+   const char* str = "foo";
+
+   // OK: internal linkage variable definitions are ignored for now.
// Although these might also cause ODR violations, we can be less certain 
and
// should try to keep the false-positive rate down.
static int b = 1;
const int c = 1;
+   const char* const str2 = "foo";
 
-   // Warning.
+   // Warning: function definition.
int g() {
  return 1;
}
 
-   // OK: inline function definition.
+   // OK: inline function definition is allowed to be multiply defined.
inline int e() {
  return 1;
}
 
class A {
 public:
- int f1() { return 1; } // OK: inline member function definition.
+ int f1() { return 1; } // OK: implicitly inline member function 
definition is allowed.
  int f2();
+ static int d;
+   };
+
+   // Warning: not a inline member function definition.
+   int A::f2() { return 1; }
+
+   // OK: class static data member declaration is allowed.
+   int A::d = 1;
+
+   // OK: funtion template is allowed.
+   template
+   T f3() {
+ T a = 1;
+ return a;
+   }
+
+   // Warning: full function template specialization is not allowed.
+   template <>
+   int f3() {
+ int a = 1;
+ return a;
+   }
+
+   template 
+   struct B {
+ void f1();
};
 
-   int A::f2() { return 1; } // Warning.
+   // OK: Member function definition of a class template is allowed.
+   template 
+   void B::f1() {}


Index: docs/clang-tidy/checks/misc-definitions-in-headers.rst
===
--- docs/clang-tidy/checks/misc-definitions-in-headers.rst
+++ docs/clang-tidy/checks/misc-definitions-in-headers.rst
@@ -4,36 +4,71 @@
 Finds non-extern non-inline function and variable definitions in header files,
 which can lead to potential ODR violations.
 
+If these headers are included from multiple translation units, there will be
+redefinition linker errors.
+
 .. code:: c++
 
// Foo.h
-   int a = 1; // Warning.
+   int a = 1; // Warning: variable definition.
extern int d; // OK: extern variable.
 
namespace N {
- int e = 2; // Warning.
+ int e = 2; // Warning: variable definition.
}
 
-   // Internal linkage variable definitions are ignored for now.
+   // Warning: variable definition.
+   const char* str = "foo";
+
+   // OK: internal linkage variable definitions are ignored for now.
// Although these might also cause ODR violations, we can be less certain and
// should try to keep the false-positive rate down.
static int b = 1;
const int c = 1;
+   const char* const str2 = "foo";
 
-   // Warning.
+   // Warning: function definition.
int g() {
  return 1;
}
 
-   // OK: inline function definition.
+   // OK: inline function definition is allowed to be multiply defined.
inline int e() {
  return 1;
}
 
class A {
 public:
- int f1() { return 1; } // OK: inline member function definition.
+ int f1() { return 1; } // OK: implicitly inline member function definition is allowed.
  int f2();
+ static int d;
+   };
+
+   // Warning: not a inline member function definition.
+   int A::f2() { return 1; }
+
+   // OK: class static data member declaration is allowed.
+   int A::d = 1;
+
+   // OK: funtion template is allowed.
+   template
+   T f3() {
+ T a = 1;
+ return a;
+   }
+
+   // Warning: full function template specialization is not allowed.
+   template <>
+   int f3() {
+ int a = 1;
+ return a;
+   }
+
+   template 
+   struct B {
+ void f1();
};
 
-   int A::f2() { return 1; } // Warning.
+   // OK: Member function definition of a class template is allowed.
+   template 
+   void B::f1() {}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20429: [clang-tidy] Handle using-decls with more than one shadow decl.

2016-05-20 Thread Haojian Wu via cfe-commits
hokein added inline comments.


Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:59
@@ -59,1 +58,3 @@
 /*SkipTrailingWhitespaceAndNewLine=*/true));
+for (const auto It : Using->shadows()) {
+  const auto *TargetDecl = It->getTargetDecl()->getCanonicalDecl();

alexfh wrote:
> hokein wrote:
> > alexfh wrote:
> > > It's not iterator, so `It` is a confusing name. Something along the lines 
> > > of `Shadow` or `UsingShadow` should be better.
> > Actually, the `Using->shadows()` returns an iterator range, but I'm fine 
> > renaming it here.
> Sure, it returns a `llvm::iterator_range`, which is just a 
> range adaptor for a pair of iterators. It's not a "collection of iterators", 
> it's a "collection, defined by a pair of iterators". If you iterate over it 
> using a range-based for loop, you get whatever is pointed by the iterators, 
> not iterators.
I see it now. Thanks for the explanations :-).


Repository:
  rL LLVM

http://reviews.llvm.org/D20429



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


[clang-tools-extra] r270193 - [find-all-symbols] make HeaderMapCollector optional in FindAllSymbols and FindAllMacros.

2016-05-20 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Fri May 20 04:12:01 2016
New Revision: 270193

URL: http://llvm.org/viewvc/llvm-project?rev=270193&view=rev
Log:
[find-all-symbols] make HeaderMapCollector optional in FindAllSymbols and 
FindAllMacros.

Modified:
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/HeaderMapCollector.h

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

Modified: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllMacros.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllMacros.cpp?rev=270193&r1=270192&r2=270193&view=diff
==
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllMacros.cpp 
(original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllMacros.cpp 
Fri May 20 04:12:01 2016
@@ -27,11 +27,13 @@ void FindAllMacros::MacroDefined(const T
   if (FilePath.empty())
 return;
 
-  // Check pragma remapping header.
-  auto HeaderMappingTable = Collector->getHeaderMappingTable();
-  auto Iter = HeaderMappingTable.find(FilePath);
-  if (Iter != HeaderMappingTable.end())
-FilePath = Iter->second;
+  // If Collector is not nullptr, check pragma remapping header.
+  if (Collector) {
+auto HeaderMappingTable = Collector->getHeaderMappingTable();
+auto Iter = HeaderMappingTable.find(FilePath);
+if (Iter != HeaderMappingTable.end())
+  FilePath = Iter->second;
+  }
 
   SymbolInfo Symbol(MacroNameTok.getIdentifierInfo()->getName(),
 SymbolInfo::SymbolKind::Macro, FilePath.str(),

Modified: clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllMacros.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllMacros.h?rev=270193&r1=270192&r2=270193&view=diff
==
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllMacros.h 
(original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllMacros.h Fri 
May 20 04:12:01 2016
@@ -25,9 +25,9 @@ class HeaderMapCollector;
 /// preprocessing period.
 class FindAllMacros : public clang::PPCallbacks {
 public:
-  explicit FindAllMacros(SymbolReporter *Reporter,
- HeaderMapCollector *Collector, SourceManager *SM)
-  : Reporter(Reporter), Collector(Collector), SM(SM) {}
+  explicit FindAllMacros(SymbolReporter *Reporter, SourceManager *SM,
+ HeaderMapCollector *Collector = nullptr)
+  : Reporter(Reporter), SM(SM), Collector(Collector) {}
 
   void MacroDefined(const Token &MacroNameTok,
 const MacroDirective *MD) override;
@@ -35,11 +35,10 @@ public:
 private:
   // Reporter for SymbolInfo.
   SymbolReporter *const Reporter;
+  SourceManager *const SM;
   // A remapping header file collector allowing clients to include a different
   // header.
   HeaderMapCollector *const Collector;
-
-  SourceManager *const SM;
 };
 
 } // namespace find_all_symbols

Modified: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp?rev=270193&r1=270192&r2=270193&view=diff
==
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp 
(original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp 
Fri May 20 04:12:01 2016
@@ -59,7 +59,7 @@ std::vector GetCont
 
 llvm::Optional
 CreateSymbolInfo(const NamedDecl *ND, const SourceManager &SM,
- const HeaderMapCollector::HeaderMap &HeaderMappingTable) {
+ const HeaderMapCollector *Collector) {
   SymbolInfo::SymbolKind Type;
   if (llvm::isa(ND)) {
 Type = SymbolInfo::SymbolKind::Variable;
@@ -96,10 +96,12 @@ CreateSymbolInfo(const NamedDecl *ND, co
   if (FilePath.empty())
 return llvm::None;
 
-  // Check pragma remapping header.
-  auto Iter = HeaderMappingTable.find(FilePath);
-  if (Iter != HeaderMappingTable.end())
-FilePath = Iter->second;
+  // If Collector is not nullptr, check pragma remapping header.
+  if (Collector) {
+auto Iter = Collector->getHeaderMappingTable().find(FilePath);
+if (Iter != Collector->getHeaderMappingTable().end())
+  FilePath = Iter->second;
+  }
 
   return SymbolInfo(ND->getNameAsString(), Type, FilePath.str(),
 SM.getExpansionLineNumber(Loc), GetContexts(ND));
@@ -215,7 +217,7 @@ void FindAll

Re: [PATCH] D20463: [clang-tidy] Add more descriptive comments and examples in misc-definitions-in-headers check.

2016-05-20 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision.
This revision now requires changes to proceed.


Comment at: docs/clang-tidy/checks/misc-definitions-in-headers.rst:8
@@ +7,3 @@
+If these headers are included from multiple translation units, there will be
+redefinition linker errors.
+

It wouldn't be a large problem, if linker was always able to detect ODR 
violations. However, there are cases, where it can't do so. You can still 
append "in case these headers are included from multiple translation units." to 
the previous sentence.


Comment at: docs/clang-tidy/checks/misc-definitions-in-headers.rst:35
@@ -27,3 +34,3 @@
 
-   // OK: inline function definition.
+   // OK: inline function definition is allowed to be multiply defined.
inline int e() {

s/multiply defined/defined multiple times/


Comment at: docs/clang-tidy/checks/misc-definitions-in-headers.rst:47
@@ +46,3 @@
+
+   // Warning: not a inline member function definition.
+   int A::f2() { return 1; }

s/a inline/an inline/


Comment at: docs/clang-tidy/checks/misc-definitions-in-headers.rst:53
@@ +52,3 @@
+
+   // OK: funtion template is allowed.
+   template

s/funtion/function/


Comment at: docs/clang-tidy/checks/misc-definitions-in-headers.rst:60
@@ +59,3 @@
+
+   // Warning: full function template specialization is not allowed.
+   template <>

`full specialization of a function template ...`


http://reviews.llvm.org/D20463



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


Re: [PATCH] D20287: [Coverage] Ensure that the hash for a used function is non-zero.

2016-05-20 Thread Igor Kudrin via cfe-commits
ikudrin abandoned this revision.
ikudrin added a comment.

This change is not needed anymore because the whole issue was fixed in 
http://reviews.llvm.org/D20286.


http://reviews.llvm.org/D20287



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


[clang-tools-extra] r270196 - [find-all-symbols] fixed FindAllMacros compilation error.

2016-05-20 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Fri May 20 04:23:19 2016
New Revision: 270196

URL: http://llvm.org/viewvc/llvm-project?rev=270196&view=rev
Log:
[find-all-symbols] fixed FindAllMacros compilation error.

Modified:

clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp

Modified: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp?rev=270196&r1=270195&r2=270196&view=diff
==
--- 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
 (original)
+++ 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
 Fri May 20 04:23:19 2016
@@ -103,7 +103,7 @@ public:
 StringRef InFile) override {
 Compiler.getPreprocessor().addCommentHandler(&Handler);
 Compiler.getPreprocessor().addPPCallbacks(llvm::make_unique(
-&Reporter, &Collector, &Compiler.getSourceManager()));
+&Reporter, &Compiler.getSourceManager(), &Collector));
 return MatchFinder.newASTConsumer();
   }
 


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


Re: [PATCH] D20463: [clang-tidy] Add more descriptive comments and examples in misc-definitions-in-headers check.

2016-05-20 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 57915.
hokein marked 5 inline comments as done.
hokein added a comment.

Address review comments.


http://reviews.llvm.org/D20463

Files:
  docs/clang-tidy/checks/misc-definitions-in-headers.rst

Index: docs/clang-tidy/checks/misc-definitions-in-headers.rst
===
--- docs/clang-tidy/checks/misc-definitions-in-headers.rst
+++ docs/clang-tidy/checks/misc-definitions-in-headers.rst
@@ -2,38 +2,71 @@
 ===
 
 Finds non-extern non-inline function and variable definitions in header files,
-which can lead to potential ODR violations.
+which can lead to potential ODR violations in the case these headers are
+included from multiple translation units.
 
 .. code:: c++
 
// Foo.h
-   int a = 1; // Warning.
+   int a = 1; // Warning: variable definition.
extern int d; // OK: extern variable.
 
namespace N {
- int e = 2; // Warning.
+ int e = 2; // Warning: variable definition.
}
 
-   // Internal linkage variable definitions are ignored for now.
+   // Warning: variable definition.
+   const char* str = "foo";
+
+   // OK: internal linkage variable definitions are ignored for now.
// Although these might also cause ODR violations, we can be less certain 
and
// should try to keep the false-positive rate down.
static int b = 1;
const int c = 1;
+   const char* const str2 = "foo";
 
-   // Warning.
+   // Warning: function definition.
int g() {
  return 1;
}
 
-   // OK: inline function definition.
+   // OK: inline function definition is allowed to be defined multiple times.
inline int e() {
  return 1;
}
 
class A {
 public:
- int f1() { return 1; } // OK: inline member function definition.
+ int f1() { return 1; } // OK: implicitly inline member function 
definition is allowed.
  int f2();
+ static int d;
+   };
+
+   // Warning: not an inline member function definition.
+   int A::f2() { return 1; }
+
+   // OK: class static data member declaration is allowed.
+   int A::d = 1;
+
+   // OK: function template is allowed.
+   template
+   T f3() {
+ T a = 1;
+ return a;
+   }
+
+   // Warning: full specialization of a function template is not allowed.
+   template <>
+   int f3() {
+ int a = 1;
+ return a;
+   }
+
+   template 
+   struct B {
+ void f1();
};
 
-   int A::f2() { return 1; } // Warning.
+   // OK: Member function definition of a class template is allowed.
+   template 
+   void B::f1() {}


Index: docs/clang-tidy/checks/misc-definitions-in-headers.rst
===
--- docs/clang-tidy/checks/misc-definitions-in-headers.rst
+++ docs/clang-tidy/checks/misc-definitions-in-headers.rst
@@ -2,38 +2,71 @@
 ===
 
 Finds non-extern non-inline function and variable definitions in header files,
-which can lead to potential ODR violations.
+which can lead to potential ODR violations in the case these headers are
+included from multiple translation units.
 
 .. code:: c++
 
// Foo.h
-   int a = 1; // Warning.
+   int a = 1; // Warning: variable definition.
extern int d; // OK: extern variable.
 
namespace N {
- int e = 2; // Warning.
+ int e = 2; // Warning: variable definition.
}
 
-   // Internal linkage variable definitions are ignored for now.
+   // Warning: variable definition.
+   const char* str = "foo";
+
+   // OK: internal linkage variable definitions are ignored for now.
// Although these might also cause ODR violations, we can be less certain and
// should try to keep the false-positive rate down.
static int b = 1;
const int c = 1;
+   const char* const str2 = "foo";
 
-   // Warning.
+   // Warning: function definition.
int g() {
  return 1;
}
 
-   // OK: inline function definition.
+   // OK: inline function definition is allowed to be defined multiple times.
inline int e() {
  return 1;
}
 
class A {
 public:
- int f1() { return 1; } // OK: inline member function definition.
+ int f1() { return 1; } // OK: implicitly inline member function definition is allowed.
  int f2();
+ static int d;
+   };
+
+   // Warning: not an inline member function definition.
+   int A::f2() { return 1; }
+
+   // OK: class static data member declaration is allowed.
+   int A::d = 1;
+
+   // OK: function template is allowed.
+   template
+   T f3() {
+ T a = 1;
+ return a;
+   }
+
+   // Warning: full specialization of a function template is not allowed.
+   template <>
+   int f3() {
+ int a = 1;
+ return a;
+   }
+
+   template 
+   struct B {
+ void f1();
};
 
-   int A::f2() { return 1; } // Warning.
+   // OK: Member function definition of a class template is allowed.
+   template 
+   void B::f1() {}
___
cfe-commits mailing list
cfe-commits@lists.llvm.o

Re: [PATCH] D20463: [clang-tidy] Add more descriptive comments and examples in misc-definitions-in-headers check.

2016-05-20 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 57917.
hokein added a comment.

fix a nit.


http://reviews.llvm.org/D20463

Files:
  docs/clang-tidy/checks/misc-definitions-in-headers.rst

Index: docs/clang-tidy/checks/misc-definitions-in-headers.rst
===
--- docs/clang-tidy/checks/misc-definitions-in-headers.rst
+++ docs/clang-tidy/checks/misc-definitions-in-headers.rst
@@ -2,38 +2,71 @@
 ===
 
 Finds non-extern non-inline function and variable definitions in header files,
-which can lead to potential ODR violations.
+which can lead to potential ODR violations in case these headers are included
+from multiple translation units.
 
 .. code:: c++
 
// Foo.h
-   int a = 1; // Warning.
+   int a = 1; // Warning: variable definition.
extern int d; // OK: extern variable.
 
namespace N {
- int e = 2; // Warning.
+ int e = 2; // Warning: variable definition.
}
 
-   // Internal linkage variable definitions are ignored for now.
+   // Warning: variable definition.
+   const char* str = "foo";
+
+   // OK: internal linkage variable definitions are ignored for now.
// Although these might also cause ODR violations, we can be less certain 
and
// should try to keep the false-positive rate down.
static int b = 1;
const int c = 1;
+   const char* const str2 = "foo";
 
-   // Warning.
+   // Warning: function definition.
int g() {
  return 1;
}
 
-   // OK: inline function definition.
+   // OK: inline function definition is allowed to be defined multiple times.
inline int e() {
  return 1;
}
 
class A {
 public:
- int f1() { return 1; } // OK: inline member function definition.
+ int f1() { return 1; } // OK: implicitly inline member function 
definition is allowed.
  int f2();
+ static int d;
+   };
+
+   // Warning: not an inline member function definition.
+   int A::f2() { return 1; }
+
+   // OK: class static data member declaration is allowed.
+   int A::d = 1;
+
+   // OK: function template is allowed.
+   template
+   T f3() {
+ T a = 1;
+ return a;
+   }
+
+   // Warning: full specialization of a function template is not allowed.
+   template <>
+   int f3() {
+ int a = 1;
+ return a;
+   }
+
+   template 
+   struct B {
+ void f1();
};
 
-   int A::f2() { return 1; } // Warning.
+   // OK: Member function definition of a class template is allowed.
+   template 
+   void B::f1() {}


Index: docs/clang-tidy/checks/misc-definitions-in-headers.rst
===
--- docs/clang-tidy/checks/misc-definitions-in-headers.rst
+++ docs/clang-tidy/checks/misc-definitions-in-headers.rst
@@ -2,38 +2,71 @@
 ===
 
 Finds non-extern non-inline function and variable definitions in header files,
-which can lead to potential ODR violations.
+which can lead to potential ODR violations in case these headers are included
+from multiple translation units.
 
 .. code:: c++
 
// Foo.h
-   int a = 1; // Warning.
+   int a = 1; // Warning: variable definition.
extern int d; // OK: extern variable.
 
namespace N {
- int e = 2; // Warning.
+ int e = 2; // Warning: variable definition.
}
 
-   // Internal linkage variable definitions are ignored for now.
+   // Warning: variable definition.
+   const char* str = "foo";
+
+   // OK: internal linkage variable definitions are ignored for now.
// Although these might also cause ODR violations, we can be less certain and
// should try to keep the false-positive rate down.
static int b = 1;
const int c = 1;
+   const char* const str2 = "foo";
 
-   // Warning.
+   // Warning: function definition.
int g() {
  return 1;
}
 
-   // OK: inline function definition.
+   // OK: inline function definition is allowed to be defined multiple times.
inline int e() {
  return 1;
}
 
class A {
 public:
- int f1() { return 1; } // OK: inline member function definition.
+ int f1() { return 1; } // OK: implicitly inline member function definition is allowed.
  int f2();
+ static int d;
+   };
+
+   // Warning: not an inline member function definition.
+   int A::f2() { return 1; }
+
+   // OK: class static data member declaration is allowed.
+   int A::d = 1;
+
+   // OK: function template is allowed.
+   template
+   T f3() {
+ T a = 1;
+ return a;
+   }
+
+   // Warning: full specialization of a function template is not allowed.
+   template <>
+   int f3() {
+ int a = 1;
+ return a;
+   }
+
+   template 
+   struct B {
+ void f1();
};
 
-   int A::f2() { return 1; } // Warning.
+   // OK: Member function definition of a class template is allowed.
+   template 
+   void B::f1() {}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20196: [clang-tidy] Inefficient string operation

2016-05-20 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision.
This revision now requires changes to proceed.


Comment at: clang-tidy/performance/InefficientStringAdditionCheck.cpp:28
@@ +27,3 @@
+: ClangTidyCheck(Name, Context),
+  IsStrictMode(Options.get("isStrictMode", 0)) {}
+

s/IsStrictMode/StrictMode/


Comment at: clang-tidy/performance/InefficientStringAdditionCheck.cpp:31
@@ +30,3 @@
+void InefficientStringAdditionCheck::registerMatchers(MatchFinder *Finder) {
+  const auto BasicStringType =
+  hasType(cxxRecordDecl(hasName("::std::basic_string")));

This check is only useful for C++. Please add

```
  if (!getLangOpts().CPlusPlus)
return;
```


Comment at: clang-tidy/performance/InefficientStringAdditionCheck.cpp:84
@@ +83,3 @@
+  const auto DiagMsg =
+  "inefficient string concatenation; use operator+= or "
+  "string::append() instead";

The root of inefficiency is in unnecessary allocations of temporary strings, so 
maybe we should note this in the warning message, e.g. "string concatenation 
results in allocation of unnecessary temporary strings; consider using 
'operator+=' or 'string::append()' instead".


Comment at: clang-tidy/performance/InefficientStringAdditionCheck.h:24
@@ +23,3 @@
+/// 
http://clang.llvm.org/extra/clang-tidy/checks/performance-inefficient-string-addition.html
+
+class InefficientStringAdditionCheck : public ClangTidyCheck {

Please remove the empty line.


Comment at: clang-tidy/performance/InefficientStringAdditionCheck.h:25
@@ +24,3 @@
+
+class InefficientStringAdditionCheck : public ClangTidyCheck {
+ public:

s/Addition/Concatenation/?


Comment at: clang-tidy/performance/InefficientStringAdditionCheck.h:33
@@ +32,3 @@
+ private:
+  int IsStrictMode;
+};

`const bool StrictMode;`


Comment at: 
docs/clang-tidy/checks/performance-inefficient-string-addition.rst:15
@@ +14,3 @@
+
+Instead of this structure you should use ``operator+=`` or std::string's 
(std::basic_string) class member function ``append``. For instance:
+   

Please enclose `std::string`, `std::basic_string` and other inline code 
snippets in double backquotes.


http://reviews.llvm.org/D20196



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


[PATCH] D20465: [find-all-symbol] Ignore inline namespace context.

2016-05-20 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: bkramer.
hokein added subscribers: ioeric, cfe-commits.

http://reviews.llvm.org/D20465

Files:
  include-fixer/find-all-symbols/FindAllSymbols.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
@@ -260,7 +260,8 @@
   int X1;
   namespace { int X2; }
   namespace { namespace { int X3; } }
-  namespace { namespace nb { int X4;} }
+  namespace { namespace nb { int X4; } }
+  namespace na { inline namespace __1 { int X5; } }
   )";
   runFindAllSymbols(Code);
 
@@ -281,6 +282,10 @@
   {{SymbolInfo::ContextType::Namespace, "nb"},
{SymbolInfo::ContextType::Namespace, ""}});
   EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo("X5", SymbolInfo::SymbolKind::Variable, HeaderName, 6,
+  {{SymbolInfo::ContextType::Namespace, "na"}});
+  EXPECT_TRUE(hasSymbol(Symbol));
 }
 
 TEST_F(FindAllSymbolsTest, DecayedTypeTest) {
Index: include-fixer/find-all-symbols/FindAllSymbols.cpp
===
--- include-fixer/find-all-symbols/FindAllSymbols.cpp
+++ include-fixer/find-all-symbols/FindAllSymbols.cpp
@@ -42,9 +42,9 @@
 assert(llvm::isa(Context) &&
"Expect Context to be a NamedDecl");
 if (const auto *NSD = dyn_cast(Context)) {
-  Contexts.emplace_back(SymbolInfo::ContextType::Namespace,
-NSD->isAnonymousNamespace() ? ""
-: 
NSD->getName().str());
+  if (!NSD->isInlineNamespace())
+Contexts.emplace_back(SymbolInfo::ContextType::Namespace,
+  NSD->getName().str());
 } else if (const auto *ED = dyn_cast(Context)) {
   Contexts.emplace_back(SymbolInfo::ContextType::EnumDecl,
 ED->getName().str());


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
@@ -260,7 +260,8 @@
   int X1;
   namespace { int X2; }
   namespace { namespace { int X3; } }
-  namespace { namespace nb { int X4;} }
+  namespace { namespace nb { int X4; } }
+  namespace na { inline namespace __1 { int X5; } }
   )";
   runFindAllSymbols(Code);
 
@@ -281,6 +282,10 @@
   {{SymbolInfo::ContextType::Namespace, "nb"},
{SymbolInfo::ContextType::Namespace, ""}});
   EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo("X5", SymbolInfo::SymbolKind::Variable, HeaderName, 6,
+  {{SymbolInfo::ContextType::Namespace, "na"}});
+  EXPECT_TRUE(hasSymbol(Symbol));
 }
 
 TEST_F(FindAllSymbolsTest, DecayedTypeTest) {
Index: include-fixer/find-all-symbols/FindAllSymbols.cpp
===
--- include-fixer/find-all-symbols/FindAllSymbols.cpp
+++ include-fixer/find-all-symbols/FindAllSymbols.cpp
@@ -42,9 +42,9 @@
 assert(llvm::isa(Context) &&
"Expect Context to be a NamedDecl");
 if (const auto *NSD = dyn_cast(Context)) {
-  Contexts.emplace_back(SymbolInfo::ContextType::Namespace,
-NSD->isAnonymousNamespace() ? ""
-: NSD->getName().str());
+  if (!NSD->isInlineNamespace())
+Contexts.emplace_back(SymbolInfo::ContextType::Namespace,
+  NSD->getName().str());
 } else if (const auto *ED = dyn_cast(Context)) {
   Contexts.emplace_back(SymbolInfo::ContextType::EnumDecl,
 ED->getName().str());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20463: [clang-tidy] Add more descriptive comments and examples in misc-definitions-in-headers check.

2016-05-20 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG. Thank you!


http://reviews.llvm.org/D20463



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


Re: [PATCH] D18575: [clang-tidy] New checker to replace deprecated throw() specifications

2016-05-20 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

Let's wait for http://reviews.llvm.org/D20428


http://reviews.llvm.org/D18575



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


[clang-tools-extra] r270197 - [clang-tidy] Add more descriptive comments and examples in misc-definitions-in-headers check.

2016-05-20 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri May 20 04:38:25 2016
New Revision: 270197

URL: http://llvm.org/viewvc/llvm-project?rev=270197&view=rev
Log:
[clang-tidy] Add more descriptive comments and examples in 
misc-definitions-in-headers check.

Reviewers: alexfh

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D20463

Modified:

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst?rev=270197&r1=270196&r2=270197&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst 
(original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst 
Fri May 20 04:38:25 2016
@@ -4,38 +4,71 @@ misc-definitions-in-headers
 ===
 
 Finds non-extern non-inline function and variable definitions in header files,
-which can lead to potential ODR violations.
+which can lead to potential ODR violations in case these headers are included
+from multiple translation units.
 
 .. code:: c++
 
// Foo.h
-   int a = 1; // Warning.
+   int a = 1; // Warning: variable definition.
extern int d; // OK: extern variable.
 
namespace N {
- int e = 2; // Warning.
+ int e = 2; // Warning: variable definition.
}
 
-   // Internal linkage variable definitions are ignored for now.
+   // Warning: variable definition.
+   const char* str = "foo";
+
+   // OK: internal linkage variable definitions are ignored for now.
// Although these might also cause ODR violations, we can be less certain 
and
// should try to keep the false-positive rate down.
static int b = 1;
const int c = 1;
+   const char* const str2 = "foo";
 
-   // Warning.
+   // Warning: function definition.
int g() {
  return 1;
}
 
-   // OK: inline function definition.
+   // OK: inline function definition is allowed to be defined multiple times.
inline int e() {
  return 1;
}
 
class A {
 public:
- int f1() { return 1; } // OK: inline member function definition.
+ int f1() { return 1; } // OK: implicitly inline member function 
definition is allowed.
  int f2();
+ static int d;
+   };
+
+   // Warning: not an inline member function definition.
+   int A::f2() { return 1; }
+
+   // OK: class static data member declaration is allowed.
+   int A::d = 1;
+
+   // OK: function template is allowed.
+   template
+   T f3() {
+ T a = 1;
+ return a;
+   }
+
+   // Warning: full specialization of a function template is not allowed.
+   template <>
+   int f3() {
+ int a = 1;
+ return a;
+   }
+
+   template 
+   struct B {
+ void f1();
};
 
-   int A::f2() { return 1; } // Warning.
+   // OK: member function definition of a class template is allowed.
+   template 
+   void B::f1() {}


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


Re: [PATCH] D20463: [clang-tidy] Add more descriptive comments and examples in misc-definitions-in-headers check.

2016-05-20 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270197: [clang-tidy] Add more descriptive comments and 
examples in misc-definitions… (authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D20463?vs=57917&id=57919#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20463

Files:
  clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst

Index: 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst
===
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst
@@ -4,38 +4,71 @@
 ===
 
 Finds non-extern non-inline function and variable definitions in header files,
-which can lead to potential ODR violations.
+which can lead to potential ODR violations in case these headers are included
+from multiple translation units.
 
 .. code:: c++
 
// Foo.h
-   int a = 1; // Warning.
+   int a = 1; // Warning: variable definition.
extern int d; // OK: extern variable.
 
namespace N {
- int e = 2; // Warning.
+ int e = 2; // Warning: variable definition.
}
 
-   // Internal linkage variable definitions are ignored for now.
+   // Warning: variable definition.
+   const char* str = "foo";
+
+   // OK: internal linkage variable definitions are ignored for now.
// Although these might also cause ODR violations, we can be less certain 
and
// should try to keep the false-positive rate down.
static int b = 1;
const int c = 1;
+   const char* const str2 = "foo";
 
-   // Warning.
+   // Warning: function definition.
int g() {
  return 1;
}
 
-   // OK: inline function definition.
+   // OK: inline function definition is allowed to be defined multiple times.
inline int e() {
  return 1;
}
 
class A {
 public:
- int f1() { return 1; } // OK: inline member function definition.
+ int f1() { return 1; } // OK: implicitly inline member function 
definition is allowed.
  int f2();
+ static int d;
+   };
+
+   // Warning: not an inline member function definition.
+   int A::f2() { return 1; }
+
+   // OK: class static data member declaration is allowed.
+   int A::d = 1;
+
+   // OK: function template is allowed.
+   template
+   T f3() {
+ T a = 1;
+ return a;
+   }
+
+   // Warning: full specialization of a function template is not allowed.
+   template <>
+   int f3() {
+ int a = 1;
+ return a;
+   }
+
+   template 
+   struct B {
+ void f1();
};
 
-   int A::f2() { return 1; } // Warning.
+   // OK: member function definition of a class template is allowed.
+   template 
+   void B::f1() {}


Index: clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst
===
--- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst
@@ -4,38 +4,71 @@
 ===
 
 Finds non-extern non-inline function and variable definitions in header files,
-which can lead to potential ODR violations.
+which can lead to potential ODR violations in case these headers are included
+from multiple translation units.
 
 .. code:: c++
 
// Foo.h
-   int a = 1; // Warning.
+   int a = 1; // Warning: variable definition.
extern int d; // OK: extern variable.
 
namespace N {
- int e = 2; // Warning.
+ int e = 2; // Warning: variable definition.
}
 
-   // Internal linkage variable definitions are ignored for now.
+   // Warning: variable definition.
+   const char* str = "foo";
+
+   // OK: internal linkage variable definitions are ignored for now.
// Although these might also cause ODR violations, we can be less certain and
// should try to keep the false-positive rate down.
static int b = 1;
const int c = 1;
+   const char* const str2 = "foo";
 
-   // Warning.
+   // Warning: function definition.
int g() {
  return 1;
}
 
-   // OK: inline function definition.
+   // OK: inline function definition is allowed to be defined multiple times.
inline int e() {
  return 1;
}
 
class A {
 public:
- int f1() { return 1; } // OK: inline member function definition.
+ int f1() { return 1; } // OK: implicitly inline member function definition is allowed.
  int f2();
+ static int d;
+   };
+
+   // Warning: not an inline member function definition.
+   int A::f2() { return 1; }
+
+   // OK: class static data member declaration is allowed.
+   int A::d = 1;
+
+   // OK: function template is allowed.
+   template
+   T f3() {
+ T a = 1;
+ return a;
+   }
+
+   // Warning: full specialization of a function template is not allowed.
+   template <>
+   int f3() {
+ i

Re: [PATCH] D20465: [find-all-symbol] Ignore inline namespace context.

2016-05-20 Thread Benjamin Kramer via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lg


http://reviews.llvm.org/D20465



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


Re: [PATCH] D20446: clang-rename: fix renaming members when referenced as macro arguments

2016-05-20 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: clang-rename/USRLocFinder.cpp:106-113
@@ -105,3 +105,10 @@
 if (getUSRForDecl(Decl) == USR) {
-  LocationsFound.push_back(Expr->getMemberLoc());
+  SourceLocation Location = Expr->getMemberLoc();
+  if (Location.isMacroID()) {
+// The location is expanded from a macro, look up the original spelling
+// location.
+const ASTContext &Context = Decl->getASTContext();
+Location = Context.getSourceManager().getSpellingLoc(Location);
+  }
+  LocationsFound.push_back(Location);
 }

Don't we just always want to do that?
Location = 
Decl->getASTContext().getSourceManager().getSpellingLoc(Expr->getMemberLoc());
should always work.


http://reviews.llvm.org/D20446



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


Re: [PATCH] D19479: 26748 - clang-cl fails to compile atlctrlw.h header from WTL

2016-05-20 Thread Andrew V. Tischenko via cfe-commits
avt77 added a comment.

It seems I gave up with this issue :-( We have 2 possible situations here:

1. A type from instantiated type used inside the template (like in the test I'm 
working on)
2. A feature from instantiated type used inside the template (like below)

struct A {

  int bar ();

}
template  struct B : public T {

  int foo () {return bar();}


}
void test (){

  B b;
  int c = b.foo();

}
We can't made any assumption about the unknown identificator: is it type or a 
feature? In the first case we should deal with ParsedType but in the second 
case we should deal with DependentScopeDeclRefExpr. Of course we could create 
something like TypeOrExpr but I'm not sure it's an acceptable solution. The 
best way here is real implementation of late parsing for all in-class defined 
features from templates: this parsing should be done at instantiation point 
only (when we can discover all involved entities.).

What do you think about? Could you give me a hint how to resolve the issue 
without really late parsing?


http://reviews.llvm.org/D19479



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


Re: [PATCH] D20446: clang-rename: fix renaming members when referenced as macro arguments

2016-05-20 Thread Miklos Vajna via cfe-commits
vmiklos updated this revision to Diff 57921.
vmiklos added a comment.

Done.


http://reviews.llvm.org/D20446

Files:
  clang-rename/USRLocFinder.cpp
  test/clang-rename/MemberExprMacro.cpp

Index: test/clang-rename/MemberExprMacro.cpp
===
--- /dev/null
+++ test/clang-rename/MemberExprMacro.cpp
@@ -0,0 +1,25 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=151 -new-name=Y %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class C
+{
+public:
+  int X;
+};
+
+int foo(int x)
+{
+  return 0;
+}
+#define FOO(a) foo(a)
+
+int main()
+{
+  C C;
+  C.X = 1; // CHECK: C.Y
+  FOO(C.X); // CHECK: C.Y
+  int y = C.X; // CHECK: C.Y
+}
+
+// Use grep -FUbo 'C'  to get the correct offset of foo when changing
+// this file.
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -103,7 +103,9 @@
   bool VisitMemberExpr(const MemberExpr *Expr) {
 const auto *Decl = Expr->getFoundDecl().getDecl();
 if (getUSRForDecl(Decl) == USR) {
-  LocationsFound.push_back(Expr->getMemberLoc());
+  const SourceManager &Manager = Decl->getASTContext().getSourceManager();
+  SourceLocation Location = Manager.getSpellingLoc(Expr->getMemberLoc());
+  LocationsFound.push_back(Location);
 }
 return true;
   }


Index: test/clang-rename/MemberExprMacro.cpp
===
--- /dev/null
+++ test/clang-rename/MemberExprMacro.cpp
@@ -0,0 +1,25 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=151 -new-name=Y %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class C
+{
+public:
+  int X;
+};
+
+int foo(int x)
+{
+  return 0;
+}
+#define FOO(a) foo(a)
+
+int main()
+{
+  C C;
+  C.X = 1; // CHECK: C.Y
+  FOO(C.X); // CHECK: C.Y
+  int y = C.X; // CHECK: C.Y
+}
+
+// Use grep -FUbo 'C'  to get the correct offset of foo when changing
+// this file.
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -103,7 +103,9 @@
   bool VisitMemberExpr(const MemberExpr *Expr) {
 const auto *Decl = Expr->getFoundDecl().getDecl();
 if (getUSRForDecl(Decl) == USR) {
-  LocationsFound.push_back(Expr->getMemberLoc());
+  const SourceManager &Manager = Decl->getASTContext().getSourceManager();
+  SourceLocation Location = Manager.getSpellingLoc(Expr->getMemberLoc());
+  LocationsFound.push_back(Location);
 }
 return true;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r270199 - [find-all-symbol] Try to fix the failure windows unittest.

2016-05-20 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri May 20 05:36:53 2016
New Revision: 270199

URL: http://llvm.org/viewvc/llvm-project?rev=270199&view=rev
Log:
[find-all-symbol] Try to fix the failure windows unittest.

Modified:

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

Modified: 
clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp?rev=270199&r1=270198&r2=270199&view=diff
==
--- 
clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
 (original)
+++ 
clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
 Fri May 20 05:36:53 2016
@@ -50,6 +50,10 @@ public:
 return false;
   }
 
+  const std::vector& getSymbols() const {
+return Symbols;
+  }
+
 private:
   std::vector Symbols;
 };
@@ -125,7 +129,7 @@ public:
 return true;
   }
 
-private:
+protected:
   TestSymbolReporter Reporter;
 };
 
@@ -410,6 +414,8 @@ TEST_F(FindAllSymbolsTest, MacroTestWith
   runFindAllSymbols(Code);
   SymbolInfo Symbol =
   SymbolInfo("X", SymbolInfo::SymbolKind::Macro, "bar.h", 3, {});
+  EXPECT_EQ(3, Reporter.getSymbols().size());
+  EXPECT_EQ("bar.h", Reporter.getSymbols().front().getFilePath());
   EXPECT_TRUE(hasSymbol(Symbol));
 
   Symbol = SymbolInfo("Y", SymbolInfo::SymbolKind::Macro, "bar.h", 4, {});


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


[clang-tools-extra] r270202 - [find-all-symbols] fix failing unittest for Windows build bot.

2016-05-20 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Fri May 20 06:14:36 2016
New Revision: 270202

URL: http://llvm.org/viewvc/llvm-project?rev=270202&view=rev
Log:
[find-all-symbols] fix failing unittest for Windows build bot.

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

Modified: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllMacros.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllMacros.cpp?rev=270202&r1=270201&r2=270202&view=diff
==
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllMacros.cpp 
(original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllMacros.cpp 
Fri May 20 06:14:36 2016
@@ -29,9 +29,8 @@ void FindAllMacros::MacroDefined(const T
 
   // If Collector is not nullptr, check pragma remapping header.
   if (Collector) {
-auto HeaderMappingTable = Collector->getHeaderMappingTable();
-auto Iter = HeaderMappingTable.find(FilePath);
-if (Iter != HeaderMappingTable.end())
+auto Iter = Collector->getHeaderMappingTable().find(FilePath);
+if (Iter != Collector->getHeaderMappingTable().end())
   FilePath = Iter->second;
   }
 


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


r270203 - clang-format: [JS] sort ES6 imports.

2016-05-20 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Fri May 20 06:24:24 2016
New Revision: 270203

URL: http://llvm.org/viewvc/llvm-project?rev=270203&view=rev
Log:
clang-format: [JS] sort ES6 imports.

Summary:
This change automatically sorts ES6 imports and exports into four groups:
absolute imports, parent imports, relative imports, and then exports. Exports
are sorted in the same order, but not grouped further.

To keep JS import sorting out of Format.cpp, this required extracting the
TokenAnalyzer infrastructure to separate header and implementation files.

Reviewers: djasper

Subscribers: cfe-commits, klimek

Differential Revision: http://reviews.llvm.org/D20198

Added:
cfe/trunk/lib/Format/FormatTokenLexer.cpp
cfe/trunk/lib/Format/FormatTokenLexer.h
cfe/trunk/lib/Format/SortJavaScriptImports.cpp
cfe/trunk/lib/Format/SortJavaScriptImports.h
cfe/trunk/lib/Format/TokenAnalyzer.cpp
cfe/trunk/lib/Format/TokenAnalyzer.h
cfe/trunk/unittests/Format/SortImportsTestJS.cpp
Modified:
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/lib/Format/CMakeLists.txt
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Format/FormatToken.h
cfe/trunk/unittests/Format/CMakeLists.txt

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=270203&r1=270202&r2=270203&view=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Fri May 20 06:24:24 2016
@@ -852,6 +852,22 @@ extern const char *StyleOptionHelpDescri
 FormatStyle getStyle(StringRef StyleName, StringRef FileName,
  StringRef FallbackStyle, vfs::FileSystem *FS = nullptr);
 
+// \brief Returns a string representation of ``Language``.
+inline StringRef getLanguageName(FormatStyle::LanguageKind Language) {
+  switch (Language) {
+  case FormatStyle::LK_Cpp:
+return "C++";
+  case FormatStyle::LK_Java:
+return "Java";
+  case FormatStyle::LK_JavaScript:
+return "JavaScript";
+  case FormatStyle::LK_Proto:
+return "Proto";
+  default:
+return "Unknown";
+  }
+}
+
 } // end namespace format
 } // end namespace clang
 

Modified: cfe/trunk/lib/Format/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/CMakeLists.txt?rev=270203&r1=270202&r2=270203&view=diff
==
--- cfe/trunk/lib/Format/CMakeLists.txt (original)
+++ cfe/trunk/lib/Format/CMakeLists.txt Fri May 20 06:24:24 2016
@@ -6,6 +6,9 @@ add_clang_library(clangFormat
   ContinuationIndenter.cpp
   Format.cpp
   FormatToken.cpp
+  FormatTokenLexer.cpp
+  SortJavaScriptImports.cpp
+  TokenAnalyzer.cpp
   TokenAnnotator.cpp
   UnwrappedLineFormatter.cpp
   UnwrappedLineParser.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=270203&r1=270202&r2=270203&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Fri May 20 06:24:24 2016
@@ -16,6 +16,9 @@
 #include "clang/Format/Format.h"
 #include "AffectedRangeManager.h"
 #include "ContinuationIndenter.h"
+#include "FormatTokenLexer.h"
+#include "SortJavaScriptImports.h"
+#include "TokenAnalyzer.h"
 #include "TokenAnnotator.h"
 #include "UnwrappedLineFormatter.h"
 #include "UnwrappedLineParser.h"
@@ -782,776 +785,6 @@ std::string configurationAsText(const Fo
 
 namespace {
 
-class FormatTokenLexer {
-public:
-  FormatTokenLexer(const SourceManager &SourceMgr, FileID ID,
-   const FormatStyle &Style, encoding::Encoding Encoding)
-  : FormatTok(nullptr), IsFirstToken(true), GreaterStashed(false),
-LessStashed(false), Column(0), TrailingWhitespace(0),
-SourceMgr(SourceMgr), ID(ID), Style(Style),
-IdentTable(getFormattingLangOpts(Style)), Keywords(IdentTable),
-Encoding(Encoding), FirstInLineIndex(0), FormattingDisabled(false),
-MacroBlockBeginRegex(Style.MacroBlockBegin),
-MacroBlockEndRegex(Style.MacroBlockEnd) {
-Lex.reset(new Lexer(ID, SourceMgr.getBuffer(ID), SourceMgr,
-getFormattingLangOpts(Style)));
-Lex->SetKeepWhitespaceMode(true);
-
-for (const std::string &ForEachMacro : Style.ForEachMacros)
-  ForEachMacros.push_back(&IdentTable.get(ForEachMacro));
-std::sort(ForEachMacros.begin(), ForEachMacros.end());
-  }
-
-  ArrayRef lex() {
-assert(Tokens.empty());
-assert(FirstInLineIndex == 0);
-do {
-  Tokens.push_back(getNextToken());
-  if (Style.Language == FormatStyle::LK_JavaScript) {
-tryParseJSRegexLiteral();
-tryParseTemplateString();
-  }
-  tryMergePreviousTokens();
-  if (Tokens.back()->NewlinesBefore > 0 || Tokens.back()->IsMultiline)
-FirstInLineIndex = Toke

Re: [PATCH] D20198: clang-format: [JS] sort ES6 imports.

2016-05-20 Thread Martin Probst via cfe-commits
This revision was automatically updated to reflect the committed changes.
mprobst marked 2 inline comments as done.
Closed by commit rL270203: clang-format: [JS] sort ES6 imports. (authored by 
mprobst).

Changed prior to commit:
  http://reviews.llvm.org/D20198?vs=57795&id=57922#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20198

Files:
  cfe/trunk/include/clang/Format/Format.h
  cfe/trunk/lib/Format/CMakeLists.txt
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/lib/Format/FormatToken.h
  cfe/trunk/lib/Format/FormatTokenLexer.cpp
  cfe/trunk/lib/Format/FormatTokenLexer.h
  cfe/trunk/lib/Format/SortJavaScriptImports.cpp
  cfe/trunk/lib/Format/SortJavaScriptImports.h
  cfe/trunk/lib/Format/TokenAnalyzer.cpp
  cfe/trunk/lib/Format/TokenAnalyzer.h
  cfe/trunk/unittests/Format/CMakeLists.txt
  cfe/trunk/unittests/Format/SortImportsTestJS.cpp

Index: cfe/trunk/include/clang/Format/Format.h
===
--- cfe/trunk/include/clang/Format/Format.h
+++ cfe/trunk/include/clang/Format/Format.h
@@ -852,6 +852,22 @@
 FormatStyle getStyle(StringRef StyleName, StringRef FileName,
  StringRef FallbackStyle, vfs::FileSystem *FS = nullptr);
 
+// \brief Returns a string representation of ``Language``.
+inline StringRef getLanguageName(FormatStyle::LanguageKind Language) {
+  switch (Language) {
+  case FormatStyle::LK_Cpp:
+return "C++";
+  case FormatStyle::LK_Java:
+return "Java";
+  case FormatStyle::LK_JavaScript:
+return "JavaScript";
+  case FormatStyle::LK_Proto:
+return "Proto";
+  default:
+return "Unknown";
+  }
+}
+
 } // end namespace format
 } // end namespace clang
 
Index: cfe/trunk/lib/Format/SortJavaScriptImports.h
===
--- cfe/trunk/lib/Format/SortJavaScriptImports.h
+++ cfe/trunk/lib/Format/SortJavaScriptImports.h
@@ -0,0 +1,36 @@
+//===--- SortJavaScriptImports.h - Sort ES6 Imports -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// \brief This file implements a sorter for JavaScript ES6 imports.
+///
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_FORMAT_SORTJAVASCRIPTIMPORTS_H
+#define LLVM_CLANG_LIB_FORMAT_SORTJAVASCRIPTIMPORTS_H
+
+#include "clang/Basic/LLVM.h"
+#include "clang/Format/Format.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace clang {
+namespace format {
+
+// Sort JavaScript ES6 imports/exports in ``Code``. The generated replacements
+// only monotonically increase the length of the given code.
+tooling::Replacements sortJavaScriptImports(const FormatStyle &Style,
+StringRef Code,
+ArrayRef Ranges,
+StringRef FileName);
+
+} // end namespace format
+} // end namespace clang
+
+#endif
Index: cfe/trunk/lib/Format/FormatToken.h
===
--- cfe/trunk/lib/Format/FormatToken.h
+++ cfe/trunk/lib/Format/FormatToken.h
@@ -535,6 +535,7 @@
 kw_NS_ENUM = &IdentTable.get("NS_ENUM");
 kw_NS_OPTIONS = &IdentTable.get("NS_OPTIONS");
 
+kw_as = &IdentTable.get("as");
 kw_async = &IdentTable.get("async");
 kw_await = &IdentTable.get("await");
 kw_finally = &IdentTable.get("finally");
@@ -585,6 +586,7 @@
   IdentifierInfo *kw___except;
 
   // JavaScript keywords.
+  IdentifierInfo *kw_as;
   IdentifierInfo *kw_async;
   IdentifierInfo *kw_await;
   IdentifierInfo *kw_finally;
Index: cfe/trunk/lib/Format/FormatTokenLexer.h
===
--- cfe/trunk/lib/Format/FormatTokenLexer.h
+++ cfe/trunk/lib/Format/FormatTokenLexer.h
@@ -0,0 +1,97 @@
+//===--- FormatTokenLexer.h - Format C++ code *- C++ *-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// \brief This file contains FormatTokenLexer, which tokenizes a source file
+/// into a token stream suitable for ClangFormat.
+///
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_FORMAT_FORMATTOKENLEXER_H
+#define LLVM_CLANG_LIB_FORMAT_FORMATTOKENLEXER_H
+
+#include "Encoding.h"
+#include "FormatToken.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Format/Format.h"
+#include "llvm/Support/Regex.h"
+
+namespace clang {
+n

Re: [PATCH] D19783: Fix cv-qualification of '*this' captures (and nasty bug PR27507 introduced by commit 263921 "Implement Lambda Capture of *this by Value as [=,*this]")

2016-05-20 Thread Faisal Vali via cfe-commits
I'm also a huge advocate of simple composable interfaces that do the
'one' task that they are expected (i.e. named) to do - and do it well.
I thought about this some, but perhaps not exhaustively - and settled
on being ok with getCurThisType, always returning the correct type for
 'this' as typed/referred to in code (with the right 'cv' quals) -
regardless of where it is called from.  Nevertheless, I'm open to
suggestions if you have a better alternative candidate for where the
call to adjustCVQuals should go?

Thanks for thinking about this.

Faisal Vali



On Fri, May 20, 2016 at 1:33 AM, Taewook Oh  wrote:
> twoh added a comment.
>
> @faisalv, thank you for the update. I wonder if getCurrentThisType() is the 
> best place to call adjustCVQualifiersForCXXThisWithinLambda(). It seems that 
> getCurrentThisType() does more than its name suggests. Is there any other 
> place that the adjustment function can be called?
>
>
> http://reviews.llvm.org/D19783
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r269907 - Add new intrinsic support for MONITORX and MWAITX instructions

2016-05-20 Thread Ashutosh Nema via cfe-commits
Apologize for breaking the build bot.

Thanks a lot Richard for taking care and fixing it.

Regards,
Ashutosh



On Fri, May 20, 2016 at 6:43 AM, Richard Smith 
wrote:

> Fixed in r270169.
>
> On Thu, May 19, 2016 at 2:13 PM, Richard Smith 
> wrote:
>
>> The modules buildbot has been broken since this commit landed:
>>
>>
>> http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhost-modules/builds/15761/steps/compile.llvm.stage2/logs/stdio
>>
>> Please fix or revert.
>>
>> On Wed, May 18, 2016 at 4:56 AM, Ashutosh Nema via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: ashutosh
>>> Date: Wed May 18 06:56:23 2016
>>> New Revision: 269907
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=269907&view=rev
>>> Log:
>>> Add new intrinsic support for MONITORX and MWAITX instructions
>>>
>>> Summary:
>>> MONITORX/MWAITX instructions provide similar capability to the
>>> MONITOR/MWAIT
>>> pair while adding a timer function, such that another termination of the
>>> MWAITX
>>> instruction occurs when the timer expires. The presence of the MONITORX
>>> and
>>> MWAITX instructions is indicated by CPUID 8000_0001, ECX, bit 29.
>>>
>>> The MONITORX and MWAITX instructions are intercepted by the same bits
>>> that
>>> intercept MONITOR and MWAIT. MONITORX instruction establishes a range to
>>> be
>>> monitored. MWAITX instruction causes the processor to stop instruction
>>> execution and enter an implementation-dependent optimized state until
>>> occurrence of a class of events.
>>>
>>> Opcode of MONITORX instruction is "0F 01 FA". Opcode of MWAITX
>>> instruction is
>>> "0F 01 FB". These opcode information is used in adding tests for the
>>> disassembler.
>>>
>>> These instructions are enabled for AMD's bdver4 architecture.
>>>
>>> Patch by Ganesh Gopalasubramanian!
>>>
>>> Reviewers: echristo, craig.topper
>>>
>>> Subscribers: RKSimon, joker.eph, llvm-commits, cfe-commits
>>>
>>> Differential Revision: http://reviews.llvm.org/D19796
>>>
>>> Added:
>>> cfe/trunk/lib/Headers/mwaitxintrin.h
>>> Modified:
>>> cfe/trunk/include/clang/Basic/BuiltinsX86.def
>>> cfe/trunk/include/clang/Driver/Options.td
>>> cfe/trunk/lib/Basic/Targets.cpp
>>> cfe/trunk/lib/Headers/CMakeLists.txt
>>> cfe/trunk/lib/Headers/module.modulemap
>>> cfe/trunk/lib/Headers/x86intrin.h
>>> cfe/trunk/test/CodeGen/builtins-x86.c
>>>
>>> Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=269907&r1=269906&r2=269907&view=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
>>> +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Wed May 18 06:56:23
>>> 2016
>>> @@ -2272,5 +2272,9 @@ TARGET_BUILTIN(__builtin_ia32_cvtusi2sd6
>>>  TARGET_BUILTIN(__builtin_ia32_cvtusi2ss32, "V4fV4fUiIi","","avx512f")
>>>  TARGET_BUILTIN(__builtin_ia32_cvtusi2ss64, "V4fV4fULLiIi","","avx512f")
>>>
>>> +// MONITORX/MWAITX
>>> +TARGET_BUILTIN(__builtin_ia32_monitorx, "vv*UiUi", "", "mwaitx")
>>> +TARGET_BUILTIN(__builtin_ia32_mwaitx, "vUiUiUi", "", "mwaitx")
>>> +
>>>  #undef BUILTIN
>>>  #undef TARGET_BUILTIN
>>>
>>> Modified: cfe/trunk/include/clang/Driver/Options.td
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=269907&r1=269906&r2=269907&view=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/Driver/Options.td (original)
>>> +++ cfe/trunk/include/clang/Driver/Options.td Wed May 18 06:56:23 2016
>>> @@ -1425,6 +1425,7 @@ def mno_xsave : Flag<["-"], "mno-xsave">
>>>  def mno_xsaveopt : Flag<["-"], "mno-xsaveopt">,
>>> Group;
>>>  def mno_xsavec : Flag<["-"], "mno-xsavec">, Group;
>>>  def mno_xsaves : Flag<["-"], "mno-xsaves">, Group;
>>> +def mno_mwaitx : Flag<["-"], "mno-mwaitx">, Group;
>>>  def mno_pku : Flag<["-"], "mno-pku">, Group;
>>>
>>>  def munaligned_access : Flag<["-"], "munaligned-access">,
>>> Group,
>>> @@ -1610,6 +1611,7 @@ def mxsave : Flag<["-"], "mxsave">, Grou
>>>  def mxsaveopt : Flag<["-"], "mxsaveopt">, Group;
>>>  def mxsavec : Flag<["-"], "mxsavec">, Group;
>>>  def mxsaves : Flag<["-"], "mxsaves">, Group;
>>> +def mmwaitx : Flag<["-"], "mmwaitx">, Group;
>>>  def mips16 : Flag<["-"], "mips16">, Group;
>>>  def mno_mips16 : Flag<["-"], "mno-mips16">, Group;
>>>  def mmicromips : Flag<["-"], "mmicromips">, Group;
>>>
>>> Modified: cfe/trunk/lib/Basic/Targets.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=269907&r1=269906&r2=269907&view=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/Basic/Targets.cpp (original)
>>> +++ cfe/trunk/lib/Basic/Targets.cpp Wed May 18 06:56:23 2016
>>> @@ -2273,6 +2273,7 @@ class X86TargetInfo : public TargetInfo
>>>bool HasXSAVEOPT = false;
>>

Re: [PATCH] D20446: clang-rename: fix renaming members when referenced as macro arguments

2016-05-20 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


http://reviews.llvm.org/D20446



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


Re: [PATCH] D20446: clang-rename: fix renaming members when referenced as macro arguments

2016-05-20 Thread Miklos Vajna via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270204: clang-rename: fix renaming members when referenced 
as macro arguments (authored by vmiklos).

Changed prior to commit:
  http://reviews.llvm.org/D20446?vs=57921&id=57923#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20446

Files:
  clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
  clang-tools-extra/trunk/test/clang-rename/MemberExprMacro.cpp

Index: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
===
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
@@ -103,7 +103,9 @@
   bool VisitMemberExpr(const MemberExpr *Expr) {
 const auto *Decl = Expr->getFoundDecl().getDecl();
 if (getUSRForDecl(Decl) == USR) {
-  LocationsFound.push_back(Expr->getMemberLoc());
+  const SourceManager &Manager = Decl->getASTContext().getSourceManager();
+  SourceLocation Location = Manager.getSpellingLoc(Expr->getMemberLoc());
+  LocationsFound.push_back(Location);
 }
 return true;
   }
Index: clang-tools-extra/trunk/test/clang-rename/MemberExprMacro.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/MemberExprMacro.cpp
+++ clang-tools-extra/trunk/test/clang-rename/MemberExprMacro.cpp
@@ -0,0 +1,25 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=151 -new-name=Y %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class C
+{
+public:
+  int X;
+};
+
+int foo(int x)
+{
+  return 0;
+}
+#define FOO(a) foo(a)
+
+int main()
+{
+  C C;
+  C.X = 1; // CHECK: C.Y
+  FOO(C.X); // CHECK: C.Y
+  int y = C.X; // CHECK: C.Y
+}
+
+// Use grep -FUbo 'C'  to get the correct offset of foo when changing
+// this file.


Index: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
===
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
@@ -103,7 +103,9 @@
   bool VisitMemberExpr(const MemberExpr *Expr) {
 const auto *Decl = Expr->getFoundDecl().getDecl();
 if (getUSRForDecl(Decl) == USR) {
-  LocationsFound.push_back(Expr->getMemberLoc());
+  const SourceManager &Manager = Decl->getASTContext().getSourceManager();
+  SourceLocation Location = Manager.getSpellingLoc(Expr->getMemberLoc());
+  LocationsFound.push_back(Location);
 }
 return true;
   }
Index: clang-tools-extra/trunk/test/clang-rename/MemberExprMacro.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/MemberExprMacro.cpp
+++ clang-tools-extra/trunk/test/clang-rename/MemberExprMacro.cpp
@@ -0,0 +1,25 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=151 -new-name=Y %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class C
+{
+public:
+  int X;
+};
+
+int foo(int x)
+{
+  return 0;
+}
+#define FOO(a) foo(a)
+
+int main()
+{
+  C C;
+  C.X = 1; // CHECK: C.Y
+  FOO(C.X); // CHECK: C.Y
+  int y = C.X; // CHECK: C.Y
+}
+
+// Use grep -FUbo 'C'  to get the correct offset of foo when changing
+// this file.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r270204 - clang-rename: fix renaming members when referenced as macro arguments

2016-05-20 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Fri May 20 06:43:59 2016
New Revision: 270204

URL: http://llvm.org/viewvc/llvm-project?rev=270204&view=rev
Log:
clang-rename: fix renaming members when referenced as macro arguments

The second check failed, FOO(C.X) wasn't renamed to FOO(C.Y).

Reviewers: klimek

Differential Revision: http://reviews.llvm.org/D20446

Added:
clang-tools-extra/trunk/test/clang-rename/MemberExprMacro.cpp
Modified:
clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp

Modified: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp?rev=270204&r1=270203&r2=270204&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp Fri May 20 06:43:59 
2016
@@ -103,7 +103,9 @@ public:
   bool VisitMemberExpr(const MemberExpr *Expr) {
 const auto *Decl = Expr->getFoundDecl().getDecl();
 if (getUSRForDecl(Decl) == USR) {
-  LocationsFound.push_back(Expr->getMemberLoc());
+  const SourceManager &Manager = Decl->getASTContext().getSourceManager();
+  SourceLocation Location = Manager.getSpellingLoc(Expr->getMemberLoc());
+  LocationsFound.push_back(Location);
 }
 return true;
   }

Added: clang-tools-extra/trunk/test/clang-rename/MemberExprMacro.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/MemberExprMacro.cpp?rev=270204&view=auto
==
--- clang-tools-extra/trunk/test/clang-rename/MemberExprMacro.cpp (added)
+++ clang-tools-extra/trunk/test/clang-rename/MemberExprMacro.cpp Fri May 20 
06:43:59 2016
@@ -0,0 +1,25 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=151 -new-name=Y %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class C
+{
+public:
+  int X;
+};
+
+int foo(int x)
+{
+  return 0;
+}
+#define FOO(a) foo(a)
+
+int main()
+{
+  C C;
+  C.X = 1; // CHECK: C.Y
+  FOO(C.X); // CHECK: C.Y
+  int y = C.X; // CHECK: C.Y
+}
+
+// Use grep -FUbo 'C'  to get the correct offset of foo when changing
+// this file.


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


[clang-tools-extra] r270206 - [find-all-symbol] Ignore inline namespace context.

2016-05-20 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri May 20 07:04:56 2016
New Revision: 270206

URL: http://llvm.org/viewvc/llvm-project?rev=270206&view=rev
Log:
[find-all-symbol] Ignore inline namespace context.

Reviewers: bkramer

Subscribers: cfe-commits, ioeric

Differential Revision: http://reviews.llvm.org/D20465

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

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

Modified: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp?rev=270206&r1=270205&r2=270206&view=diff
==
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp 
(original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp 
Fri May 20 07:04:56 2016
@@ -42,9 +42,9 @@ std::vector GetCont
 assert(llvm::isa(Context) &&
"Expect Context to be a NamedDecl");
 if (const auto *NSD = dyn_cast(Context)) {
-  Contexts.emplace_back(SymbolInfo::ContextType::Namespace,
-NSD->isAnonymousNamespace() ? ""
-: 
NSD->getName().str());
+  if (!NSD->isInlineNamespace())
+Contexts.emplace_back(SymbolInfo::ContextType::Namespace,
+  NSD->getName().str());
 } else if (const auto *ED = dyn_cast(Context)) {
   Contexts.emplace_back(SymbolInfo::ContextType::EnumDecl,
 ED->getName().str());

Modified: 
clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp?rev=270206&r1=270205&r2=270206&view=diff
==
--- 
clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
 (original)
+++ 
clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
 Fri May 20 07:04:56 2016
@@ -268,7 +268,8 @@ TEST_F(FindAllSymbolsTest, NamespaceTest
   int X1;
   namespace { int X2; }
   namespace { namespace { int X3; } }
-  namespace { namespace nb { int X4;} }
+  namespace { namespace nb { int X4; } }
+  namespace na { inline namespace __1 { int X5; } }
   )";
   runFindAllSymbols(Code);
 
@@ -289,6 +290,10 @@ TEST_F(FindAllSymbolsTest, NamespaceTest
   {{SymbolInfo::ContextType::Namespace, "nb"},
{SymbolInfo::ContextType::Namespace, ""}});
   EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo("X5", SymbolInfo::SymbolKind::Variable, HeaderName, 6,
+  {{SymbolInfo::ContextType::Namespace, "na"}});
+  EXPECT_TRUE(hasSymbol(Symbol));
 }
 
 TEST_F(FindAllSymbolsTest, DecayedTypeTest) {


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


Re: [PATCH] D20113: Fix mangled name of method with ns_consumed parameters.

2016-05-20 Thread Sylvain Defresne via cfe-commits
sdefresne updated this revision to Diff 57924.
sdefresne added a comment.

Ok, this make sense. I've updated my change to follow your recommendation. Can 
you take another look?

Using 'extern "C" { ... }" would probably not be an option in my case as I want 
to use "ns_consumed" for the parameter of a templated class (i.e. this probably 
won't work if using "C" mangling, and I'm not even sure it would compile).


http://reviews.llvm.org/D20113

Files:
  lib/AST/ItaniumMangle.cpp
  test/CodeGenObjCXX/arc-attrs.mm
  test/CodeGenObjCXX/arc-mangle.mm
  test/CodeGenObjCXX/mangle.mm

Index: test/CodeGenObjCXX/mangle.mm
===
--- test/CodeGenObjCXX/mangle.mm
+++ test/CodeGenObjCXX/mangle.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -std=c++11 -emit-llvm -fblocks -o - | FileCheck %s
 
 // CHECK: @"_ZZ11+[A shared]E1a" = internal global
 // CHECK: @"_ZZ11-[A(Foo) f]E1a" = internal global
@@ -113,3 +113,10 @@
 
 // CHECK-LABEL: define void @_Z19parameterized_test3P13Parameterized
 void parameterized_test3(Parameterized *p) {}
+
+// CHECK-LABEL: define {{.*}}void @_Z1fP11objc_object
+void f(__attribute__((ns_consumed)) id) {}
+// CHECK-LABEL: define {{.*}}void @_Z1fPFP11objc_objectS0_S0_E
+void f(id (*fn)(__attribute__((ns_consumed)) id, id)) {}
+// CHECK-LABEL: define {{.*}}void @_Z1fU13block_pointerFvP11objc_objectE
+void f(void (^)(__attribute__((ns_consumed)) id)) {}
Index: test/CodeGenObjCXX/arc-mangle.mm
===
--- test/CodeGenObjCXX/arc-mangle.mm
+++ test/CodeGenObjCXX/arc-mangle.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fobjc-arc -fobjc-runtime-has-weak -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fobjc-arc -fobjc-runtime-has-weak -triple %itanium_abi_triple -emit-llvm -fblocks -o - %s | FileCheck %s
 
 // CHECK-LABEL: define {{.*}}void @_Z1fPU8__strongP11objc_object(i8**)
 void f(__strong id *) {}
@@ -18,10 +18,14 @@
 void f(const __unsafe_unretained id *) {}
 // CHECK-LABEL: define {{.*}}void @_Z1fPFU19ns_returns_retainedP11objc_objectvE
 void f(__attribute__((ns_returns_retained)) id (*fn)()) {}
+// CHECK-LABEL: define {{.*}}void @_Z1fP11objc_object
+void f(__attribute__((ns_consumed)) id) {}
 // CHECK-LABEL: define {{.*}}void @_Z1fPFP11objc_objectU11ns_consumedS0_S0_E
 void f(id (*fn)(__attribute__((ns_consumed)) id, id)) {}
 // CHECK-LABEL: define {{.*}}void @_Z1fPFP11objc_objectS0_U11ns_consumedS0_E
 void f(__strong id (*fn)(id, __attribute__((ns_consumed)) id)) {}
+// CHECK-LABEL: define {{.*}}void @_Z1fU13block_pointerFvU11ns_consumedP11objc_objectE
+void f(void (^)(__attribute__((ns_consumed)) id)) {}
 
 template struct unsigned_c { };
 
Index: test/CodeGenObjCXX/arc-attrs.mm
===
--- test/CodeGenObjCXX/arc-attrs.mm
+++ test/CodeGenObjCXX/arc-attrs.mm
@@ -12,7 +12,7 @@
   id x = makeObject1();
 
   // CHECK-NEXT: [[OBJ2:%.*]] = call i8* @_Z11makeObject2v()
-  // CHECK-NEXT: call void @_Z13releaseObjectU11ns_consumedP11objc_object(i8* [[OBJ2]])
+  // CHECK-NEXT: call void @_Z13releaseObjectP11objc_object(i8* [[OBJ2]])
   releaseObject(makeObject2());
 
   // CHECK-NEXT: call void @objc_storeStrong(i8** [[X]], i8* null)
@@ -31,16 +31,16 @@
 // CHECK-LABEL: define void @_Z12templateTestv
 void templateTest() {
   // CHECK: [[X:%.*]] = alloca i8*, align 8
-  // CHECK-NEXT: [[OBJ1:%.*]] = call i8* @_Z12makeObjectT1IU8__strongP11objc_objectEU19ns_returns_retainedT_v()
+  // CHECK-NEXT: [[OBJ1:%.*]] = call i8* @_Z12makeObjectT1IU8__strongP11objc_objectET_v()
   // CHECK-NEXT: store i8* [[OBJ1]], i8** [[X]], align 8
   id x = makeObjectT1();
 
-  // CHECK-NEXT: [[OBJ2:%.*]] = call i8* @_Z12makeObjectT2IU8__strongP11objc_objectEU19ns_returns_retainedT_v()
-  // CHECK-NEXT: call void @_Z13releaseObjectU11ns_consumedP11objc_object(i8* [[OBJ2]])
+  // CHECK-NEXT: [[OBJ2:%.*]] = call i8* @_Z12makeObjectT2IU8__strongP11objc_objectET_v()
+  // CHECK-NEXT: call void @_Z13releaseObjectP11objc_object(i8* [[OBJ2]])
   releaseObject(makeObjectT2());
 
   // CHECK-NEXT: [[OBJ3:%.*]] = call i8* @_Z11makeObject1v()
-  // CHECK-NEXT: call void @_Z14releaseObjectTIU8__strongP11objc_objectEvU11ns_consumedT_(i8* [[OBJ3]])
+  // CHECK-NEXT: call void @_Z14releaseObjectTIU8__strongP11objc_objectEvT_(i8* [[OBJ3]])
   releaseObjectT(makeObject1());
 
   // CHECK-NEXT: call void @objc_storeStrong(i8** [[X]], i8* null)
Index: lib/AST/ItaniumMangle.cpp
===
--- lib/AST/ItaniumMangle.cpp
+++ lib/AST/ItaniumMangle.cpp
@@ -2243,7 +2243,7 @@
 FunctionTypeDepth.enterResultType();
 
 // Mangle ns_returns_retained as an order-sensitive qualifier here.
-if (Proto->getExtInfo().getProducesResult())
+if (Proto->getExtInfo().get

Re: [PATCH] D20465: [find-all-symbol] Ignore inline namespace context.

2016-05-20 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270206: [find-all-symbol] Ignore inline namespace context. 
(authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D20465?vs=57918&id=57925#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20465

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

Index: clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
===
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
@@ -42,9 +42,9 @@
 assert(llvm::isa(Context) &&
"Expect Context to be a NamedDecl");
 if (const auto *NSD = dyn_cast(Context)) {
-  Contexts.emplace_back(SymbolInfo::ContextType::Namespace,
-NSD->isAnonymousNamespace() ? ""
-: 
NSD->getName().str());
+  if (!NSD->isInlineNamespace())
+Contexts.emplace_back(SymbolInfo::ContextType::Namespace,
+  NSD->getName().str());
 } else if (const auto *ED = dyn_cast(Context)) {
   Contexts.emplace_back(SymbolInfo::ContextType::EnumDecl,
 ED->getName().str());
Index: 
clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- 
clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ 
clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -268,7 +268,8 @@
   int X1;
   namespace { int X2; }
   namespace { namespace { int X3; } }
-  namespace { namespace nb { int X4;} }
+  namespace { namespace nb { int X4; } }
+  namespace na { inline namespace __1 { int X5; } }
   )";
   runFindAllSymbols(Code);
 
@@ -289,6 +290,10 @@
   {{SymbolInfo::ContextType::Namespace, "nb"},
{SymbolInfo::ContextType::Namespace, ""}});
   EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo("X5", SymbolInfo::SymbolKind::Variable, HeaderName, 6,
+  {{SymbolInfo::ContextType::Namespace, "na"}});
+  EXPECT_TRUE(hasSymbol(Symbol));
 }
 
 TEST_F(FindAllSymbolsTest, DecayedTypeTest) {


Index: clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
===
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
@@ -42,9 +42,9 @@
 assert(llvm::isa(Context) &&
"Expect Context to be a NamedDecl");
 if (const auto *NSD = dyn_cast(Context)) {
-  Contexts.emplace_back(SymbolInfo::ContextType::Namespace,
-NSD->isAnonymousNamespace() ? ""
-: NSD->getName().str());
+  if (!NSD->isInlineNamespace())
+Contexts.emplace_back(SymbolInfo::ContextType::Namespace,
+  NSD->getName().str());
 } else if (const auto *ED = dyn_cast(Context)) {
   Contexts.emplace_back(SymbolInfo::ContextType::EnumDecl,
 ED->getName().str());
Index: clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -268,7 +268,8 @@
   int X1;
   namespace { int X2; }
   namespace { namespace { int X3; } }
-  namespace { namespace nb { int X4;} }
+  namespace { namespace nb { int X4; } }
+  namespace na { inline namespace __1 { int X5; } }
   )";
   runFindAllSymbols(Code);
 
@@ -289,6 +290,10 @@
   {{SymbolInfo::ContextType::Namespace, "nb"},
{SymbolInfo::ContextType::Namespace, ""}});
   EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo("X5", SymbolInfo::SymbolKind::Variable, HeaderName, 6,
+  {{SymbolInfo::ContextType::Namespace, "na"}});
+  EXPECT_TRUE(hasSymbol(Symbol));
 }
 
 TEST_F(FindAllSymbolsTest, DecayedTypeTest) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19324: [ASTMatchers] new forEachOverriden matcher

2016-05-20 Thread Clement Courbet via cfe-commits
courbet marked 10 inline comments as done.
courbet added a comment.

http://reviews.llvm.org/D19324



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


r270210 - [X86][AVX] Full set of AVX intrinsics tests

2016-05-20 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Fri May 20 07:41:02 2016
New Revision: 270210

URL: http://llvm.org/viewvc/llvm-project?rev=270210&view=rev
Log:
[X86][AVX] Full set of AVX intrinsics tests

llvm/test/CodeGen/X86/avx-intrinsics-fast-isel.ll will be synced to this

Modified:
cfe/trunk/test/CodeGen/avx-builtins.c

Modified: cfe/trunk/test/CodeGen/avx-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx-builtins.c?rev=270210&r1=270209&r2=270210&view=diff
==
--- cfe/trunk/test/CodeGen/avx-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx-builtins.c Fri May 20 07:41:02 2016
@@ -1,84 +1,1297 @@
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -target-feature +avx 
-emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -target-feature +avx 
-emit-llvm -o - -Werror | FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -target-feature +avx 
-fno-signed-char -emit-llvm -o - -Werror | FileCheck %s
 
 // Don't include mm_malloc.h, it's system specific.
 #define __MM_MALLOC_H
 
-#include 
+#include 
 
-//
-// Test LLVM IR codegen of shuffle instructions
-//
+// NOTE: This should match the tests in 
llvm/test/CodeGen/X86/sse-intrinsics-fast-isel.ll
 
-__m256 test__mm256_loadu_ps(void* p) {
-  // CHECK: load <8 x float>, <8 x float>* %{{.*}}, align 1
-  return _mm256_loadu_ps(p);
+__m256d test_mm256_add_pd(__m256d A, __m256d B) {
+  // CHECK-LABEL: test_mm256_add_pd
+  // CHECK: fadd <4 x double>
+  return _mm256_add_pd(A, B);
 }
 
-__m256d test__mm256_loadu_pd(void* p) {
-  // CHECK: load <4 x double>, <4 x double>* %{{.*}}, align 1
-  return _mm256_loadu_pd(p);
+__m256 test_mm256_add_ps(__m256 A, __m256 B) {
+  // CHECK-LABEL: test_mm256_add_ps
+  // CHECK: fadd <8 x float>
+  return _mm256_add_ps(A, B);
 }
 
-__m256i test__mm256_loadu_si256(void* p) {
-  // CHECK: load <4 x i64>, <4 x i64>* %{{.+}}, align 1
-  return _mm256_loadu_si256(p);
+__m256d test_mm256_addsub_pd(__m256d A, __m256d B) {
+  // CHECK-LABEL: test_mm256_addsub_pd
+  // CHECK: call <4 x double> @llvm.x86.avx.addsub.pd.256(<4 x double> 
%{{.*}}, <4 x double> %{{.*}})
+  return _mm256_addsub_pd(A, B);
 }
 
-int test_extract_epi32(__m256i __a) {
-  // CHECK-LABEL: @test_extract_epi32
-  // CHECK: [[SHIFT1:%[^ ]+]] = and i32 %{{.*}}, 7
-  // CHECK: extractelement <8 x i32> %{{.*}}, i32 [[SHIFT1]]
-  return _mm256_extract_epi32(__a, 8);
+__m256 test_mm256_addsub_ps(__m256 A, __m256 B) {
+  // CHECK-LABEL: test_mm256_addsub_ps
+  // CHECK: call <8 x float> @llvm.x86.avx.addsub.ps.256(<8 x float> %{{.*}}, 
<8 x float> %{{.*}})
+  return _mm256_addsub_ps(A, B);
 }
 
-int test_extract_epi16(__m256i __a) {
-  // CHECK-LABEL: @test_extract_epi16
-  // CHECK: [[SHIFT2:%[^ ]+]] = and i32 %{{.*}}, 15
-  // CHECK: extractelement <16 x i16> %{{.*}}, i32 [[SHIFT2]]
-  return _mm256_extract_epi16(__a, 16);
+__m256d test_mm256_and_pd(__m256d A, __m256d B) {
+  // CHECK-LABEL: test_mm256_and_pd
+  // CHECK: and <4 x i64>
+  return _mm256_and_pd(A, B);
 }
 
-int test_extract_epi8(__m256i __a) {
-  // CHECK-LABEL: @test_extract_epi8
-  // CHECK: [[SHIFT3:%[^ ]+]] = and i32 %{{.*}}, 31
-  // CHECK: extractelement <32 x i8> %{{.*}}, i32 [[SHIFT3]]
-  return _mm256_extract_epi8(__a, 32);
+__m256 test_mm256_and_ps(__m256 A, __m256 B) {
+  // CHECK-LABEL: test_mm256_and_ps
+  // CHECK: and <8 x i32>
+  return _mm256_and_ps(A, B);
 }
 
-__m256d test_256_blend_pd(__m256d __a, __m256d __b) {
-  // CHECK-LABEL: @test_256_blend_pd
+__m256d test_mm256_andnot_pd(__m256d A, __m256d B) {
+  // CHECK-LABEL: test_mm256_andnot_pd
+  // CHECK: xor <4 x i64> %{{.*}}, 
+  // CHECK: and <4 x i64>
+  return _mm256_andnot_pd(A, B);
+}
+
+__m256 test_mm256_andnot_ps(__m256 A, __m256 B) {
+  // CHECK-LABEL: test_mm256_andnot_ps
+  // CHECK: xor <8 x i32> %{{.*}}, 
+  // CHECK: and <8 x i32>
+  return _mm256_andnot_ps(A, B);
+}
+
+__m256d test_mm256_blend_pd(__m256d A, __m256d B) {
+  // CHECK-LABEL: test_mm256_blend_pd
   // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> %{{.*}}, <4 x 
i32> 
-  return _mm256_blend_pd(__a, __b, 0x35);
+  return _mm256_blend_pd(A, B, 0x35);
 }
 
-__m256 test_256_blend_ps(__m256 __a, __m256 __b) {
-  // CHECK-LABEL: @test_256_blend_ps
+__m256 test_mm256_blend_ps(__m256 A, __m256 B) {
+  // CHECK-LABEL: test_mm256_blend_ps
   // CHECK: shufflevector <8 x float> %{{.*}}, <8 x float> %{{.*}}, <8 x i32> 

-  return _mm256_blend_ps(__a, __b, 0x35);
+  return _mm256_blend_ps(A, B, 0x35);
+}
+
+__m256d test_mm256_blendv_pd(__m256d V1, __m256d V2, __m256d V3) {
+  // CHECK-LABEL: test_mm256_blendv_pd
+  // CHECK: call <4 x double> @llvm.x86.avx.blendv.pd.256(<4 x double> 
%{{.*}}, <4 x double> %{{.*}}, <4 x double> %{{.*}})
+  return _mm256_blendv_pd(V1, V2, V3);
+}
+
+__m256 test_mm256_blendv_ps(__m256 V1, __m256 V2, __m256 V3) {
+  // CHECK-LABEL: test_mm256_blendv_ps
+  // CHECK: call <8 x float> @llvm.x86.avx.blendv.ps.256(

[clang-tools-extra] r270211 - [find-all-symbols] Some cleanups in unittest.

2016-05-20 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri May 20 07:47:56 2016
New Revision: 270211

URL: http://llvm.org/viewvc/llvm-project?rev=270211&view=rev
Log:
[find-all-symbols] Some cleanups in unittest.

Modified:

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

Modified: 
clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp?rev=270211&r1=270210&r2=270211&view=diff
==
--- 
clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
 (original)
+++ 
clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
 Fri May 20 07:47:56 2016
@@ -50,10 +50,6 @@ public:
 return false;
   }
 
-  const std::vector& getSymbols() const {
-return Symbols;
-  }
-
 private:
   std::vector Symbols;
 };
@@ -419,8 +415,6 @@ TEST_F(FindAllSymbolsTest, MacroTestWith
   runFindAllSymbols(Code);
   SymbolInfo Symbol =
   SymbolInfo("X", SymbolInfo::SymbolKind::Macro, "bar.h", 3, {});
-  EXPECT_EQ(3, Reporter.getSymbols().size());
-  EXPECT_EQ("bar.h", Reporter.getSymbols().front().getFilePath());
   EXPECT_TRUE(hasSymbol(Symbol));
 
   Symbol = SymbolInfo("Y", SymbolInfo::SymbolKind::Macro, "bar.h", 4, {});


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


RE: r270047 - [Clang][AVX512][intrinsics] continue completing missing set intrinsics

2016-05-20 Thread Zuckerman, Michael via cfe-commits
No problem, 
I will look at it.

Regards 
Michael Zuckerman 

-Original Message-
From: steve...@apple.com [mailto:steve...@apple.com] 
Sent: Thursday, May 19, 2016 23:27
To: Zuckerman, Michael 
Cc: cfe-commits@lists.llvm.org
Subject: Re: r270047 - [Clang][AVX512][intrinsics] continue completing missing 
set intrinsics

Hi Michael

This commit seems break darwin LTO bootstrap bot. 
http://lab.llvm.org:8080/green/job/clang-stage2-configure-Rlto_check/7916/
Also breaks the Asan Ubsan bot:
http://lab.llvm.org:8080/green/job/clang-stage2-cmake-RgSan_check/1742/

Can you talk a look? I don't why the failure doesn't show up in other 
configuration. Let me know if you need any help.

Thanks

Steven


> On May 19, 2016, at 5:07 AM, Michael Zuckerman via cfe-commits 
>  wrote:
> 
> Author: mzuckerm
> Date: Thu May 19 07:07:49 2016
> New Revision: 270047
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=270047&view=rev
> Log:
> [Clang][AVX512][intrinsics] continue completing missing set intrinsics
> 
> Differential Revision: http://reviews.llvm.org/D20160
> 
> 
> Modified:
>cfe/trunk/lib/Headers/avx512fintrin.h
>cfe/trunk/test/CodeGen/avx512f-builtins.c
> 
> Modified: cfe/trunk/lib/Headers/avx512fintrin.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintri
> n.h?rev=270047&r1=270046&r2=270047&view=diff
> ==
> 
> --- cfe/trunk/lib/Headers/avx512fintrin.h (original)
> +++ cfe/trunk/lib/Headers/avx512fintrin.h Thu May 19 07:07:49 2016
> @@ -8983,6 +8983,21 @@ _mm512_mask_set1_epi64 (__m512i __O, __m
>  __M);
> }
> 
> +static __inline __m512i __DEFAULT_FN_ATTRS
> +_mm512_set_epi32 (int __A, int __B, int __C, int __D,
> + int __E, int __F, int __G, int __H,
> + int __I, int __J, int __K, int __L,
> + int __M, int __N, int __O, int __P) {
> +  return __extension__ (__m512i)(__v16si)
> +  { __P, __O, __N, __M, __L, __K, __J, __I,
> +__H, __G, __F, __E, __D, __C, __B, __A }; }
> +
> +#define _mm512_setr_epi32(e0,e1,e2,e3,e4,e5,e6,e7,   \
> +   e8,e9,e10,e11,e12,e13,e14,e15)  \
> +  
> +_mm512_set_epi32(e15,e14,e13,e12,e11,e10,e9,e8,e7,e6,e5,e4,e3,e2,e1,e
> +0)
> +  
> static __inline__ __m512i __DEFAULT_FN_ATTRS
> _mm512_set_epi64 (long long __A, long long __B, long long __C,
>  long long __D, long long __E, long long __F, @@ -8992,6 +9007,9 
> @@ _mm512_set_epi64 (long long __A, long lo
>   { __H, __G, __F, __E, __D, __C, __B, __A }; }
> 
> +#define _mm512_setr_epi64(e0,e1,e2,e3,e4,e5,e6,e7)   \
> +  _mm512_set_epi64(e7,e6,e5,e4,e3,e2,e1,e0)
> +
> static __inline__ __m512d __DEFAULT_FN_ATTRS _mm512_set_pd (double 
> __A, double __B, double __C, double __D,
> double __E, double __F, double __G, double __H) @@ -9000,6 
> +9018,9 @@ _mm512_set_pd (double __A, double __B, d
>   { __H, __G, __F, __E, __D, __C, __B, __A }; }
> 
> +#define _mm512_setr_pd(e0,e1,e2,e3,e4,e5,e6,e7)  \
> +  _mm512_set_pd(e7,e6,e5,e4,e3,e2,e1,e0)
> +
> static __inline__ __m512 __DEFAULT_FN_ATTRS _mm512_set_ps (float __A, 
> float __B, float __C, float __D,
> float __E, float __F, float __G, float __H, @@ -9011,6 +9032,9 
> @@ _mm512_set_ps (float __A, float __B, flo
> __H, __G, __F, __E, __D, __C, __B, __A }; }
> 
> +#define 
> +_mm512_setr_ps(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15) 
> +\
> +  
> +_mm512_set_ps(e15,e14,e13,e12,e11,e10,e9,e8,e7,e6,e5,e4,e3,e2,e1,e0)
> +
> #undef __DEFAULT_FN_ATTRS
> 
> #endif // __AVX512FINTRIN_H
> 
> Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-bui
> ltins.c?rev=270047&r1=270046&r2=270047&view=diff
> ==
> 
> --- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
> +++ cfe/trunk/test/CodeGen/avx512f-builtins.c Thu May 19 07:07:49 2016
> @@ -6521,6 +6521,74 @@ __m512i test_mm512_mask_set1_epi32 (__m5
>   return _mm512_mask_set1_epi32 ( __O, __M, __A); }
> 
> +__m512i test_mm512_set_epi32 (int __A, int __B, int __C, int __D,
> +   int __E, int __F, int __G, int __H,
> +   int __I, int __J, int __K, int __L,
> +   int __M, int __N, int __O, int __P) {
> + //CHECK-LABLE: @test_mm512_set_epi32
> + //CHECK: insertelement{{.*}}i32 0
> +//CHECK: insertelement{{.*}}i32 1
> +//CHECK: insertelement{{.*}}i32 2
> +//CHECK: insertelement{{.*}}i32 3
> +//CHECK: insertelement{{.*}}i32 4
> +//CHECK: insertelement{{.*}}i32 5
> +//CHECK: insertelement{{.*}}i32 6
> +//CHECK: insertelement{{.*}}i32 7
> +//CHECK: insertelement{{.*}}i32 8
> +//CHECK: insertelement{{.*}}i32 9
> +//CHECK: insertelement{{.*}}i32 10
> +//CHECK: insertelement{{.*}}i32 11
> +//CHECK: insertelement{{.*}}i32 12
> +//CHECK: insertelement{{.*}}i32 13
> +//CHECK: insertelement{{.*}}i32

[libcxx] r270213 - Reorganize locale extension fallbacks. NFCI

2016-05-20 Thread Ben Craig via cfe-commits
Author: bcraig
Date: Fri May 20 07:58:41 2016
New Revision: 270213

URL: http://llvm.org/viewvc/llvm-project?rev=270213&view=rev
Log:
Reorganize locale extension fallbacks. NFCI

The various _l locale extension functions originate from very
different places.  Some come from POSIX, some are BSD extensions,
and some are shared BSD and GLIBC extensions. This patch tries to
group the local extension reimplementations by source. This should
make it easier to make libcxx work with POSIX compliant C libraries
that lack these extensions.

The fallback locale functions are also useful on their own for other
lightweight platforms. Putting these fallback implementations in
support/xlocale should enable code sharing.

I have no access to a newlib system or an android system to build
and test with. I _do_ have access to a system without any of the _l
locale extensions though, and I was able to ensure that the new
__posix_l_fallback.h and __strtonum_fallback.h didn't have any massive
problems.

http://reviews.llvm.org/D17416

Added:
libcxx/trunk/include/support/xlocale/__posix_l_fallback.h
libcxx/trunk/include/support/xlocale/__strtonum_fallback.h
libcxx/trunk/include/support/xlocale/xlocale.h
Modified:
libcxx/trunk/include/support/android/locale_bionic.h
libcxx/trunk/include/support/newlib/xlocale.h

Modified: libcxx/trunk/include/support/android/locale_bionic.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/android/locale_bionic.h?rev=270213&r1=270212&r2=270213&view=diff
==
--- libcxx/trunk/include/support/android/locale_bionic.h (original)
+++ libcxx/trunk/include/support/android/locale_bionic.h Fri May 20 07:58:41 
2016
@@ -24,8 +24,8 @@ extern "C" {
 }
 #endif
 
-// Share implementation with Newlib
-#include 
+#include 
+#include 
 
 #endif // defined(__ANDROID__)
 #endif // _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H

Modified: libcxx/trunk/include/support/newlib/xlocale.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/newlib/xlocale.h?rev=270213&r1=270212&r2=270213&view=diff
==
--- libcxx/trunk/include/support/newlib/xlocale.h (original)
+++ libcxx/trunk/include/support/newlib/xlocale.h Fri May 20 07:58:41 2016
@@ -17,17 +17,8 @@
 #include 
 #include 
 #include 
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// Share implementation with Android's Bionic
-#include 
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
+#include 
+#include 
 
 #endif // _NEWLIB_VERSION
 

Added: libcxx/trunk/include/support/xlocale/__posix_l_fallback.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/xlocale/__posix_l_fallback.h?rev=270213&view=auto
==
--- libcxx/trunk/include/support/xlocale/__posix_l_fallback.h (added)
+++ libcxx/trunk/include/support/xlocale/__posix_l_fallback.h Fri May 20 
07:58:41 2016
@@ -0,0 +1,165 @@
+// -*- C++ -*-
+//===--- support/xlocale/__posix_l_fallback.h 
-===//
+//
+// 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.
+//
+//===--===//
+// These are reimplementations of some extended locale functions ( *_l ) that
+// are normally part of POSIX.  This shared implementation provides parts of 
the
+// extended locale support for libc's that normally don't have any (like
+// Android's bionic and Newlib).
+//===--===//
+
+#ifndef _LIBCPP_SUPPORT_XLOCALE_POSIX_L_FALLBACK_H
+#define _LIBCPP_SUPPORT_XLOCALE_POSIX_L_FALLBACK_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+inline _LIBCPP_ALWAYS_INLINE int isalnum_l(int c, locale_t) {
+  return ::isalnum(c);
+}
+
+inline _LIBCPP_ALWAYS_INLINE int isalpha_l(int c, locale_t) {
+  return ::isalpha(c);
+}
+
+inline _LIBCPP_ALWAYS_INLINE int isblank_l(int c, locale_t) {
+  return ::isblank(c);
+}
+
+inline _LIBCPP_ALWAYS_INLINE int iscntrl_l(int c, locale_t) {
+  return ::iscntrl(c);
+}
+
+inline _LIBCPP_ALWAYS_INLINE int isdigit_l(int c, locale_t) {
+  return ::isdigit(c);
+}
+
+inline _LIBCPP_ALWAYS_INLINE int isgraph_l(int c, locale_t) {
+  return ::isgraph(c);
+}
+
+inline _LIBCPP_ALWAYS_INLINE int islower_l(int c, locale_t) {
+  return ::islower(c);
+}
+
+inline _LIBCPP_ALWAYS_INLINE int isprint_l(int c, locale_t) {
+  return ::isprint(c);
+}
+
+inline _LIBCPP_ALWAYS_INLINE int ispunct_l(int c, locale_t) {
+  return ::ispunct(c);
+}
+
+inline _LIBCPP_ALWAYS_INLINE int isspace_l(int c, locale_t) {
+  return ::isspace(c);
+}
+
+inline _LIBCPP_ALWAYS_INLINE int isupper_l(int c, locale_t) {
+  return ::isupper(c);
+}
+
+inline _LIBCPP_ALWAYS_INLINE int isxdigit_l(i

[PATCH] D20467: [include-fixer] Mention more details in the document.

2016-05-20 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: bkramer.
hokein added subscribers: ioeric, cfe-commits.

http://reviews.llvm.org/D20467

Files:
  docs/include-fixer.rst

Index: docs/include-fixer.rst
===
--- docs/include-fixer.rst
+++ docs/include-fixer.rst
@@ -41,14 +41,16 @@
 .. code-block:: console
 
   $ cd path/to/llvm-build
+  $ ninja find-all-symbols // build find-all-symbols tool.
+  $ ninja clang-include-fixer // build clang-include-fixer tool.
   $ ls compile_commands.json # Make sure compile_commands.json exists.
 compile_commands.json
   $ 
path/to/llvm/source/tools/clang/tools/extra/include-fixer/find-all-symbols/tool/run-find-all-symbols.py
 ... wait as clang indexes the code base ...
   $ ln -s $PWD/find_all_symbols_db.yaml path/to/llvm/source/ # Link database 
into the source tree.
   $ ln -s $PWD/compile_commands.json path/to/llvm/source/ # Also link 
compilation database if it's not there already.
   $ cd path/to/llvm/source
-  $ clang-include-fixer -db=yaml path/to/file/with/missing/include.cpp
+  $ /path/to/clang-include-fixer -db=yaml path/to/file/with/missing/include.cpp
 Added #include "foo.h"
 
 Integrate with Vim
@@ -63,6 +65,9 @@
 This enables `clang-include-fixer` for NORMAL and VISUAL mode. Change ``,cf`` 
to
 another binding if you need clang-include-fixer on a different key.
 
+Make sure the path of :program:`clang-include-fixer` is in the environment PATH
+variable.
+
 See ``clang-include-fixer.py`` for more details.
 
 How it Works


Index: docs/include-fixer.rst
===
--- docs/include-fixer.rst
+++ docs/include-fixer.rst
@@ -41,14 +41,16 @@
 .. code-block:: console
 
   $ cd path/to/llvm-build
+  $ ninja find-all-symbols // build find-all-symbols tool.
+  $ ninja clang-include-fixer // build clang-include-fixer tool.
   $ ls compile_commands.json # Make sure compile_commands.json exists.
 compile_commands.json
   $ path/to/llvm/source/tools/clang/tools/extra/include-fixer/find-all-symbols/tool/run-find-all-symbols.py
 ... wait as clang indexes the code base ...
   $ ln -s $PWD/find_all_symbols_db.yaml path/to/llvm/source/ # Link database into the source tree.
   $ ln -s $PWD/compile_commands.json path/to/llvm/source/ # Also link compilation database if it's not there already.
   $ cd path/to/llvm/source
-  $ clang-include-fixer -db=yaml path/to/file/with/missing/include.cpp
+  $ /path/to/clang-include-fixer -db=yaml path/to/file/with/missing/include.cpp
 Added #include "foo.h"
 
 Integrate with Vim
@@ -63,6 +65,9 @@
 This enables `clang-include-fixer` for NORMAL and VISUAL mode. Change ``,cf`` to
 another binding if you need clang-include-fixer on a different key.
 
+Make sure the path of :program:`clang-include-fixer` is in the environment PATH
+variable.
+
 See ``clang-include-fixer.py`` for more details.
 
 How it Works
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17416: [libcxx] Reorganize locale extension fallbacks. NFCI

2016-05-20 Thread Ben Craig via cfe-commits
bcraig closed this revision.
bcraig added a comment.

r270213


http://reviews.llvm.org/D17416



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


r270212 - [X86][AVX] Added _mm256_extract_epi64 test

2016-05-20 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Fri May 20 07:57:21 2016
New Revision: 270212

URL: http://llvm.org/viewvc/llvm-project?rev=270212&view=rev
Log:
[X86][AVX] Added _mm256_extract_epi64 test

Modified:
cfe/trunk/test/CodeGen/avx-builtins.c

Modified: cfe/trunk/test/CodeGen/avx-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx-builtins.c?rev=270212&r1=270211&r2=270212&view=diff
==
--- cfe/trunk/test/CodeGen/avx-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx-builtins.c Fri May 20 07:57:21 2016
@@ -339,6 +339,13 @@ int test_mm256_extract_epi32(__m256i A)
   return _mm256_extract_epi32(A, 8);
 }
 
+long long test_mm256_extract_epi64(__m256i A) {
+  // CHECK-LABEL: test_mm256_extract_epi64
+  // CHECK: and i32 %{{.*}}, 3
+  // CHECK: extractelement <4 x i64> %{{.*}}, i32 %{{.*}}
+  return _mm256_extract_epi64(A, 5);
+}
+
 __m128d test_mm256_extractf128_pd(__m256d A) {
   // CHECK-LABEL: test_mm256_extractf128_pd
   // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> %{{.*}}, <2 x 
i32> 


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


[PATCH] D20468: [X86][AVX] Ensure zero-extension of _mm256_extract_epi8 and _mm256_extract_epi16

2016-05-20 Thread Simon Pilgrim via cfe-commits
RKSimon created this revision.
RKSimon added reviewers: mkuper, craig.topper, kromanova, spatel.
RKSimon added a subscriber: cfe-commits.
RKSimon set the repository for this revision to rL LLVM.

Ensure _mm256_extract_epi8 and _mm256_extract_epi16 zero extend their i8/i16 
result to i32. This matches _mm_extract_epi8 and _mm_extract_epi16.

Fix for PR27594 

Katya - I've updated the doxygen comments for _mm256_extract_epi8 and 
_mm256_extract_epi16, I guess this will need to be updated in Sony's intrinsics 
document for the next regeneration?

Repository:
  rL LLVM

http://reviews.llvm.org/D20468

Files:
  lib/Headers/avxintrin.h
  test/CodeGen/avx-builtins.c

Index: test/CodeGen/avx-builtins.c
===
--- test/CodeGen/avx-builtins.c
+++ test/CodeGen/avx-builtins.c
@@ -314,21 +314,19 @@
   return _mm256_dp_ps(A, B, 7);
 }
 
-// FIXME: ZEXT instead of SEXT
 int test_mm256_extract_epi8(__m256i A) {
   // CHECK-LABEL: test_mm256_extract_epi8
   // CHECK: and i32 %{{.*}}, 31
   // CHECK: extractelement <32 x i8> %{{.*}}, i32 %{{.*}}
-  // CHECK: ext i8 %{{.*}} to i32
+  // CHECK: zext i8 %{{.*}} to i32
   return _mm256_extract_epi8(A, 32);
 }
 
-// FIXME: ZEXT instead of SEXT
 int test_mm256_extract_epi16(__m256i A) {
   // CHECK-LABEL: test_mm256_extract_epi16
   // CHECK: and i32 %{{.*}}, 15
   // CHECK: extractelement <16 x i16> %{{.*}}, i32 %{{.*}}
-  // CHECK: ext i16 %{{.*}} to i32
+  // CHECK: zext i16 %{{.*}} to i32
   return _mm256_extract_epi16(A, 16);
 }
 
Index: lib/Headers/avxintrin.h
===
--- lib/Headers/avxintrin.h
+++ lib/Headers/avxintrin.h
@@ -1875,13 +1875,13 @@
 /// \param __imm
 ///An immediate integer operand with bits [3:0] determining which vector
 ///element is extracted and returned.
-/// \returns A 32-bit integer containing the extracted 16 bits of extended
+/// \returns A 32-bit integer containing the extracted 16 bits of zero extended
 ///packed data.
 static __inline int __DEFAULT_FN_ATTRS
 _mm256_extract_epi16(__m256i __a, const int __imm)
 {
   __v16hi __b = (__v16hi)__a;
-  return __b[__imm & 15];
+  return (unsigned short)__b[__imm & 15];
 }
 
 /// \brief Takes a [32 x i8] vector and returns the vector element value
@@ -1897,13 +1897,13 @@
 /// \param __imm
 ///An immediate integer operand with bits [4:0] determining which vector
 ///element is extracted and returned.
-/// \returns A 32-bit integer containing the extracted 8 bits of extended 
packed
-///data.
+/// \returns A 32-bit integer containing the extracted 8 bits of zero extended
+///packed data.
 static __inline int __DEFAULT_FN_ATTRS
 _mm256_extract_epi8(__m256i __a, const int __imm)
 {
   __v32qi __b = (__v32qi)__a;
-  return __b[__imm & 31];
+  return (unsigned char)__b[__imm & 31];
 }
 
 #ifdef __x86_64__


Index: test/CodeGen/avx-builtins.c
===
--- test/CodeGen/avx-builtins.c
+++ test/CodeGen/avx-builtins.c
@@ -314,21 +314,19 @@
   return _mm256_dp_ps(A, B, 7);
 }
 
-// FIXME: ZEXT instead of SEXT
 int test_mm256_extract_epi8(__m256i A) {
   // CHECK-LABEL: test_mm256_extract_epi8
   // CHECK: and i32 %{{.*}}, 31
   // CHECK: extractelement <32 x i8> %{{.*}}, i32 %{{.*}}
-  // CHECK: ext i8 %{{.*}} to i32
+  // CHECK: zext i8 %{{.*}} to i32
   return _mm256_extract_epi8(A, 32);
 }
 
-// FIXME: ZEXT instead of SEXT
 int test_mm256_extract_epi16(__m256i A) {
   // CHECK-LABEL: test_mm256_extract_epi16
   // CHECK: and i32 %{{.*}}, 15
   // CHECK: extractelement <16 x i16> %{{.*}}, i32 %{{.*}}
-  // CHECK: ext i16 %{{.*}} to i32
+  // CHECK: zext i16 %{{.*}} to i32
   return _mm256_extract_epi16(A, 16);
 }
 
Index: lib/Headers/avxintrin.h
===
--- lib/Headers/avxintrin.h
+++ lib/Headers/avxintrin.h
@@ -1875,13 +1875,13 @@
 /// \param __imm
 ///An immediate integer operand with bits [3:0] determining which vector
 ///element is extracted and returned.
-/// \returns A 32-bit integer containing the extracted 16 bits of extended
+/// \returns A 32-bit integer containing the extracted 16 bits of zero extended
 ///packed data.
 static __inline int __DEFAULT_FN_ATTRS
 _mm256_extract_epi16(__m256i __a, const int __imm)
 {
   __v16hi __b = (__v16hi)__a;
-  return __b[__imm & 15];
+  return (unsigned short)__b[__imm & 15];
 }
 
 /// \brief Takes a [32 x i8] vector and returns the vector element value
@@ -1897,13 +1897,13 @@
 /// \param __imm
 ///An immediate integer operand with bits [4:0] determining which vector
 ///element is extracted and returned.
-/// \returns A 32-bit integer containing the extracted 8 bits of extended packed
-///data.
+/// \returns A 32-bit integer containing the extracted 8 bits of zero extended
+///packed data.
 static __inline int __DEFAULT_FN_ATTRS
 _mm256_extract_epi8(__m256i __a, const int __imm

[PATCH] D20469: [include-fixer] Don't run the script if clang-include-fixer binary is not valid.

2016-05-20 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: ioeric.
hokein added subscribers: bkramer, cfe-commits.

Also show a better error message.

http://reviews.llvm.org/D20469

Files:
  include-fixer/tool/clang-include-fixer.py

Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -37,6 +37,14 @@
   help='String to initialize the database.')
   args = parser.parse_args()
 
+  # Check whether the path of clang-include-fixer binary is valid.
+  try:
+invocation = [binary, '-help']
+subprocess.check_output(invocation)
+  except:
+print >>sys.stderr, "Unable to find clang-include-fixer binary."
+return
+
   # Get the current text.
   buf = vim.current.buffer
   text = '\n'.join(buf)


Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -37,6 +37,14 @@
   help='String to initialize the database.')
   args = parser.parse_args()
 
+  # Check whether the path of clang-include-fixer binary is valid.
+  try:
+invocation = [binary, '-help']
+subprocess.check_output(invocation)
+  except:
+print >>sys.stderr, "Unable to find clang-include-fixer binary."
+return
+
   # Get the current text.
   buf = vim.current.buffer
   text = '\n'.join(buf)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r270215 - [clang-tidy] Switch to a more common way of customizing check behavior.

2016-05-20 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Fri May 20 08:42:40 2016
New Revision: 270215

URL: http://llvm.org/viewvc/llvm-project?rev=270215&view=rev
Log:
[clang-tidy] Switch to a more common way of customizing check behavior.

This should have been done this way from the start, however I somehow missed
r257177.

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp?rev=270215&r1=270214&r2=270215&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp Fri May 
20 08:42:40 2016
@@ -223,10 +223,6 @@ GlobList &ClangTidyContext::getChecksFil
   return *CheckFilter;
 }
 
-bool ClangTidyContext::isCheckEnabled(StringRef CheckName) const {
-  return CheckFilter->contains(CheckName);
-}
-
 GlobList &ClangTidyContext::getWarningAsErrorFilter() {
   assert(WarningAsErrorFilter != nullptr);
   return *WarningAsErrorFilter;

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h?rev=270215&r1=270214&r2=270215&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h Fri May 20 
08:42:40 2016
@@ -172,9 +172,6 @@ public:
   /// The \c CurrentFile can be changed using \c setCurrentFile.
   GlobList &getChecksFilter();
 
-  /// \brief Returns true if the check name is enabled for the \c CurrentFile.
-  bool isCheckEnabled(StringRef CheckName) const;
-
   /// \brief Returns check filter for the \c CurrentFile which
   /// selects checks for upgrade to error.
   GlobList &getWarningAsErrorFilter();

Modified: clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp?rev=270215&r1=270214&r2=270215&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp Fri May 20 
08:42:40 2016
@@ -69,6 +69,11 @@ public:
 CheckFactories.registerCheck(
 "cert-err34-c");
   }
+  ClangTidyOptions getModuleOptions() override {
+ClangTidyOptions Options;
+Options.CheckOptions["cert-oop11-cpp.UseCERTSemantics"] = "1";
+return Options;
+  }
 };
 
 } // namespace cert

Modified: clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp?rev=270215&r1=270214&r2=270215&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp Fri 
May 20 08:42:40 2016
@@ -44,7 +44,7 @@ MoveConstructorInitCheck::MoveConstructo
 : ClangTidyCheck(Name, Context),
   IncludeStyle(utils::IncludeSorter::parseIncludeStyle(
   Options.get("IncludeStyle", "llvm"))),
-  UseCERTSemantics(Context->isCheckEnabled("cert-oop11-cpp")) {}
+  UseCERTSemantics(Options.get("UseCERTSemantics", 0) != 0) {}
 
 void MoveConstructorInitCheck::registerMatchers(MatchFinder *Finder) {
   // Only register the matchers for C++11; the functionality currently does not
@@ -72,7 +72,7 @@ void MoveConstructorInitCheck::registerM
 
   // This checker is also used to implement cert-oop11-cpp, but when using that
   // form of the checker, we do not want to diagnose movable parameters.
-  if (!UseCERTSemantics)
+  if (!UseCERTSemantics) {
 Finder->addMatcher(
 cxxConstructorDecl(
 allOf(
@@ -89,6 +89,7 @@ void MoveConstructorInitCheck::registerM
 .bind("init-arg")))
 .bind("ctor-decl"),
 this);
+  }
 }
 
 void MoveConstructorInitCheck::check(const MatchFinder::MatchResult &Result) {
@@ -176,6 +177,7 @@ void MoveConstructorInitCheck::registerP
 void MoveConstructorInitCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) 
{
   Options.store(Opts, "IncludeStyle",
 utils::IncludeSorter::toString(IncludeStyle));
+  Options.store(Opts, "UseCERTSemantics", UseCERTSemantics ? 1 : 0);
 }
 
 } // namespace misc


__

r270216 - [Hexagon] Recognize "s" constraint in inline-asm

2016-05-20 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Fri May 20 08:50:32 2016
New Revision: 270216

URL: http://llvm.org/viewvc/llvm-project?rev=270216&view=rev
Log:
[Hexagon] Recognize "s" constraint in inline-asm

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/CodeGen/hexagon-inline-asm.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=270216&r1=270215&r2=270216&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri May 20 08:50:32 2016
@@ -6039,6 +6039,9 @@ public:
   return true;
 }
 break;
+  case 's':
+// Relocatable constant.
+return true;
 }
 return false;
   }

Modified: cfe/trunk/test/CodeGen/hexagon-inline-asm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/hexagon-inline-asm.c?rev=270216&r1=270215&r2=270216&view=diff
==
--- cfe/trunk/test/CodeGen/hexagon-inline-asm.c (original)
+++ cfe/trunk/test/CodeGen/hexagon-inline-asm.c Fri May 20 08:50:32 2016
@@ -3,9 +3,15 @@
 typedef int v64 __attribute__((__vector_size__(64)))
 __attribute__((aligned(64)));
 
+int g;
+
 void foo(v64 v0, v64 v1, v64 *p) {
+  int r;
   v64 q0;
   asm ("%0 = vgtw(%1.w,%2.w)" : "=q"(q0) : "v"(v0), "v"(v1));
 // CHECK: call <16 x i32> asm "$0 = vgtw($1.w,$2.w)", "=q,v,v"(<16 x 
i32>{{.*}}, <16 x i32>{{.*}})
   *p = q0;
+
+  asm ("%0 = memw(##%1)" : "=r"(r) : "s"(&g));
+// CHECK: call i32 asm "$0 = memw(##$1)", "=r,s"(i32* @g)
 }


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


Re: [PATCH] D20468: [X86][AVX] Ensure zero-extension of _mm256_extract_epi8 and _mm256_extract_epi16

2016-05-20 Thread Michael Kuperstein via cfe-commits
mkuper added a comment.

Could you point me to where in the documentation it says they must be 
zero-extended?
The Intel intrinsics guide actually has them with shorter return types:

  __int8 _mm256_extract_epi8 (__m256i a, const int index)
  __int16 _mm256_extract_epi16 (__m256i a, const int index)


Repository:
  rL LLVM

http://reviews.llvm.org/D20468



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


r270224 - Add all the avx512 flavors to __builtin_cpu_supports's list.

2016-05-20 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri May 20 10:21:08 2016
New Revision: 270224

URL: http://llvm.org/viewvc/llvm-project?rev=270224&view=rev
Log:
Add all the avx512 flavors to __builtin_cpu_supports's list.

This is matching what trunk gcc is accepting. Also adds a missing ssse3
case. PR27779. The amount of duplication here is annoying, maybe it
should be factored into a separate .def file?

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/target-builtin-noerror.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=270224&r1=270223&r2=270224&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri May 20 10:21:08 2016
@@ -3753,6 +3753,7 @@ bool X86TargetInfo::validateCpuSupports(
   .Case("sse", true)
   .Case("sse2", true)
   .Case("sse3", true)
+  .Case("ssse3", true)
   .Case("sse4.1", true)
   .Case("sse4.2", true)
   .Case("avx", true)
@@ -3764,6 +3765,16 @@ bool X86TargetInfo::validateCpuSupports(
   .Case("avx512f", true)
   .Case("bmi", true)
   .Case("bmi2", true)
+  .Case("aes", true)
+  .Case("pclmul", true)
+  .Case("avx512vl", true)
+  .Case("avx512bw", true)
+  .Case("avx512dq", true)
+  .Case("avx512cd", true)
+  .Case("avx512er", true)
+  .Case("avx512pf", true)
+  .Case("avx512vbmi", true)
+  .Case("avx512ifma", true)
   .Default(false);
 }
 

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=270224&r1=270223&r2=270224&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri May 20 10:21:08 2016
@@ -6336,6 +6336,16 @@ Value *CodeGenFunction::EmitX86BuiltinEx
   AVX512F,
   BMI,
   BMI2,
+  AES,
+  PCLMUL,
+  AVX512VL,
+  AVX512BW,
+  AVX512DQ,
+  AVX512CD,
+  AVX512ER,
+  AVX512PF,
+  AVX512VBMI,
+  AVX512IFMA,
   MAX
 };
 
@@ -6346,6 +6356,7 @@ Value *CodeGenFunction::EmitX86BuiltinEx
   .Case("sse", X86Features::SSE)
   .Case("sse2", X86Features::SSE2)
   .Case("sse3", X86Features::SSE3)
+  .Case("ssse3", X86Features::SSSE3)
   .Case("sse4.1", X86Features::SSE4_1)
   .Case("sse4.2", X86Features::SSE4_2)
   .Case("avx", X86Features::AVX)
@@ -6357,6 +6368,16 @@ Value *CodeGenFunction::EmitX86BuiltinEx
   .Case("avx512f", X86Features::AVX512F)
   .Case("bmi", X86Features::BMI)
   .Case("bmi2", X86Features::BMI2)
+  .Case("aes", X86Features::AES)
+  .Case("pclmul", X86Features::PCLMUL)
+  .Case("avx512vl", X86Features::AVX512VL)
+  .Case("avx512bw", X86Features::AVX512BW)
+  .Case("avx512dq", X86Features::AVX512DQ)
+  .Case("avx512cd", X86Features::AVX512CD)
+  .Case("avx512er", X86Features::AVX512ER)
+  .Case("avx512pf", X86Features::AVX512PF)
+  .Case("avx512vbmi", X86Features::AVX512VBMI)
+  .Case("avx512ifma", X86Features::AVX512IFMA)
   .Default(X86Features::MAX);
 assert(Feature != X86Features::MAX && "Invalid feature!");
 

Modified: cfe/trunk/test/CodeGen/target-builtin-noerror.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/target-builtin-noerror.c?rev=270224&r1=270223&r2=270224&view=diff
==
--- cfe/trunk/test/CodeGen/target-builtin-noerror.c (original)
+++ cfe/trunk/test/CodeGen/target-builtin-noerror.c Fri May 20 10:21:08 2016
@@ -42,3 +42,34 @@ __m128 __attribute__((target("fma4"))) f
 __m128 __attribute__((target("fma,fma4"))) fma_3(__m128 a, __m128 b, __m128 c) 
{
   return __builtin_ia32_vfmaddps(a, b, c);
 }
+
+void verifyfeaturestrings() {
+  (void)__builtin_cpu_supports("cmov");
+  (void)__builtin_cpu_supports("mmx");
+  (void)__builtin_cpu_supports("popcnt");
+  (void)__builtin_cpu_supports("sse");
+  (void)__builtin_cpu_supports("sse2");
+  (void)__builtin_cpu_supports("sse3");
+  (void)__builtin_cpu_supports("ssse3");
+  (void)__builtin_cpu_supports("sse4.1");
+  (void)__builtin_cpu_supports("sse4.2");
+  (void)__builtin_cpu_supports("avx");
+  (void)__builtin_cpu_supports("avx2");
+  (void)__builtin_cpu_supports("sse4a");

r270226 - Eliminate unnecessary file access checks in Clang driver on Windows

2016-05-20 Thread Adrian McCarthy via cfe-commits
Author: amccarth
Date: Fri May 20 10:46:23 2016
New Revision: 270226

URL: http://llvm.org/viewvc/llvm-project?rev=270226&view=rev
Log:
Eliminate unnecessary file access checks in Clang driver on Windows

Differential Revision: http://reviews.llvm.org/D20454

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

Modified: cfe/trunk/lib/Driver/MSVCToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/MSVCToolChain.cpp?rev=270226&r1=270225&r2=270226&view=diff
==
--- cfe/trunk/lib/Driver/MSVCToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/MSVCToolChain.cpp Fri May 20 10:46:23 2016
@@ -408,7 +408,10 @@ bool MSVCToolChain::getVisualStudioBinar
 
 SmallString<128> FilePath(PathSegment);
 llvm::sys::path::append(FilePath, "cl.exe");
-if (llvm::sys::fs::can_execute(FilePath.c_str()) &&
+// Checking if cl.exe exists is a small optimization over calling
+// can_execute, which really only checks for existence but will also do
+// extra checks for cl.exe.exe.  These add up when walking a long path.
+if (llvm::sys::fs::exists(FilePath.c_str()) &&
 !llvm::sys::fs::equivalent(FilePath.c_str(), clangProgramPath)) {
   // If we found it on the PATH, use it exactly as is with no
   // modifications.


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


Re: [PATCH] D20454: Eliminate unnecessary file access checks in Clang driver on Windows

2016-05-20 Thread Adrian McCarthy via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270226: Eliminate unnecessary file access checks in Clang 
driver on Windows (authored by amccarth).

Changed prior to commit:
  http://reviews.llvm.org/D20454?vs=57872&id=57936#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20454

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

Index: cfe/trunk/lib/Driver/MSVCToolChain.cpp
===
--- cfe/trunk/lib/Driver/MSVCToolChain.cpp
+++ cfe/trunk/lib/Driver/MSVCToolChain.cpp
@@ -408,7 +408,10 @@
 
 SmallString<128> FilePath(PathSegment);
 llvm::sys::path::append(FilePath, "cl.exe");
-if (llvm::sys::fs::can_execute(FilePath.c_str()) &&
+// Checking if cl.exe exists is a small optimization over calling
+// can_execute, which really only checks for existence but will also do
+// extra checks for cl.exe.exe.  These add up when walking a long path.
+if (llvm::sys::fs::exists(FilePath.c_str()) &&
 !llvm::sys::fs::equivalent(FilePath.c_str(), clangProgramPath)) {
   // If we found it on the PATH, use it exactly as is with no
   // modifications.


Index: cfe/trunk/lib/Driver/MSVCToolChain.cpp
===
--- cfe/trunk/lib/Driver/MSVCToolChain.cpp
+++ cfe/trunk/lib/Driver/MSVCToolChain.cpp
@@ -408,7 +408,10 @@
 
 SmallString<128> FilePath(PathSegment);
 llvm::sys::path::append(FilePath, "cl.exe");
-if (llvm::sys::fs::can_execute(FilePath.c_str()) &&
+// Checking if cl.exe exists is a small optimization over calling
+// can_execute, which really only checks for existence but will also do
+// extra checks for cl.exe.exe.  These add up when walking a long path.
+if (llvm::sys::fs::exists(FilePath.c_str()) &&
 !llvm::sys::fs::equivalent(FilePath.c_str(), clangProgramPath)) {
   // If we found it on the PATH, use it exactly as is with no
   // modifications.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r270227 - [X86][AVX] Added _mm256_testc_si256/_mm256_testnzc_si256/_mm256_testz_si256 tests

2016-05-20 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Fri May 20 10:49:17 2016
New Revision: 270227

URL: http://llvm.org/viewvc/llvm-project?rev=270227&view=rev
Log:
[X86][AVX] Added _mm256_testc_si256/_mm256_testnzc_si256/_mm256_testz_si256 
tests

Modified:
cfe/trunk/test/CodeGen/avx-builtins.c

Modified: cfe/trunk/test/CodeGen/avx-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx-builtins.c?rev=270227&r1=270226&r2=270227&view=diff
==
--- cfe/trunk/test/CodeGen/avx-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx-builtins.c Fri May 20 10:49:17 2016
@@ -1253,6 +1253,12 @@ int test_mm256_testc_ps(__m256 A, __m256
   return _mm256_testc_ps(A, B);
 }
 
+int test_mm256_testc_si256(__m256 A, __m256 B) {
+  // CHECK-LABEL: test_mm256_testc_si256
+  // CHECK: call i32 @llvm.x86.avx.ptestc.256(<4 x i64> %{{.*}}, <4 x i64> 
%{{.*}})
+  return _mm256_testc_si256(A, B);
+}
+
 int test_mm_testnzc_pd(__m128d A, __m128d B) {
   // CHECK-LABEL: test_mm_testnzc_pd
   // CHECK: call i32 @llvm.x86.avx.vtestnzc.pd(<2 x double> %{{.*}}, <2 x 
double> %{{.*}})
@@ -1277,6 +1283,12 @@ int test_mm256_testnzc_ps(__m256 A, __m2
   return _mm256_testnzc_ps(A, B);
 }
 
+int test_mm256_testnzc_si256(__m256 A, __m256 B) {
+  // CHECK-LABEL: test_mm256_testnzc_si256
+  // CHECK: call i32 @llvm.x86.avx.ptestnzc.256(<4 x i64> %{{.*}}, <4 x i64> 
%{{.*}})
+  return _mm256_testnzc_si256(A, B);
+}
+
 int test_mm_testz_pd(__m128d A, __m128d B) {
   // CHECK-LABEL: test_mm_testz_pd
   // CHECK: call i32 @llvm.x86.avx.vtestz.pd(<2 x double> %{{.*}}, <2 x 
double> %{{.*}})
@@ -1301,6 +1313,12 @@ int test_mm256_testz_ps(__m256 A, __m256
   return _mm256_testz_ps(A, B);
 }
 
+int test_mm256_testz_si256(__m256 A, __m256 B) {
+  // CHECK-LABEL: test_mm256_testz_si256
+  // CHECK: call i32 @llvm.x86.avx.ptestz.256(<4 x i64> %{{.*}}, <4 x i64> 
%{{.*}})
+  return _mm256_testz_si256(A, B);
+}
+
 __m256 test_mm256_undefined_ps() {
   // CHECK-LABEL: @test_mm256_undefined_ps
   // CHECK: ret <8 x float> undef


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


Re: [PATCH] D20415: Update Clang for D20147 ("DebugInfo: New metadata representation for global variables.")

2016-05-20 Thread Adrian Prantl via cfe-commits
aprantl added inline comments.


Comment at: lib/CodeGen/CGDebugInfo.cpp:3393
@@ +3392,3 @@
+DContext, FieldName, LinkageName, Unit, LineNo, FieldTy,
+Var->hasInternalLinkage(), nullptr, nullptr);
+Var->addDebugInfo(GV);

Is there a good reason for not changing the DIBuilder interface to drop the 
global field?


Comment at: lib/CodeGen/CGDebugInfo.cpp:3477
@@ -3473,1 +3476,3 @@
+InitExpr =
+DBuilder.createConstantValueExpression(Init.getInt().getExtValue());
   GV.reset(DBuilder.createGlobalVariable(

Are we regressing floating point constants here?


http://reviews.llvm.org/D20415



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


Re: [PATCH] D20415: Update Clang for D20147 ("DebugInfo: New metadata representation for global variables.")

2016-05-20 Thread Adrian Prantl via cfe-commits
aprantl added inline comments.


Comment at: lib/CodeGen/CGDebugInfo.cpp:3393
@@ +3392,3 @@
+DContext, FieldName, LinkageName, Unit, LineNo, FieldTy,
+Var->hasInternalLinkage(), nullptr, nullptr);
+Var->addDebugInfo(GV);

aprantl wrote:
> Is there a good reason for not changing the DIBuilder interface to drop the 
> global field?
Sorry about the confusion, I should have read the other patch first. This has 
morphed into the DIExpression. That's fine!


http://reviews.llvm.org/D20415



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


Re: r270164 - Avoid depending on test inputes that aren't in Inputs

2016-05-20 Thread David Blaikie via cfe-commits
I'm not sure, but assume the Inputs directories could be sunk to a common
parent (test/Inputs rather than test/CodeGen/Inputs, etc)

On Thu, May 19, 2016 at 5:38 PM, Reid Kleckner via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rnk
> Date: Thu May 19 19:38:25 2016
> New Revision: 270164
>
> URL: http://llvm.org/viewvc/llvm-project?rev=270164&view=rev
> Log:
> Avoid depending on test inputes that aren't in Inputs
>
> Some people have weird CI systems that run each test subdirectory
> independently without access to other parallel trees.
>
> Unfortunately, this means we have to suffer some duplication until Art
> can sort out how to share these types.
>
> Added:
> cfe/trunk/test/CodeGenCUDA/Inputs/cuda-initializers.h
> cfe/trunk/test/SemaCUDA/Inputs/cuda-initializers.h
> Modified:
> cfe/trunk/test/CodeGenCUDA/device-var-init.cu
> cfe/trunk/test/SemaCUDA/device-var-init.cu
>
> Added: cfe/trunk/test/CodeGenCUDA/Inputs/cuda-initializers.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/Inputs/cuda-initializers.h?rev=270164&view=auto
>
> ==
> --- cfe/trunk/test/CodeGenCUDA/Inputs/cuda-initializers.h (added)
> +++ cfe/trunk/test/CodeGenCUDA/Inputs/cuda-initializers.h Thu May 19
> 19:38:25 2016
> @@ -0,0 +1,145 @@
> +// CUDA struct types with interesting initialization properties.
> +// Keep in sync with ../SemaCUDA/Inputs/cuda-initializers.h.
> +
> +// Base classes with different initializer variants.
> +
> +// trivial constructor -- allowed
> +struct T {
> +  int t;
> +};
> +
> +// empty constructor
> +struct EC {
> +  int ec;
> +  __device__ EC() {} // -- allowed
> +  __device__ EC(int) {}  // -- not allowed
> +};
> +
> +// empty destructor
> +struct ED {
> +  __device__ ~ED() {} // -- allowed
> +};
> +
> +struct ECD {
> +  __device__ ECD() {} // -- allowed
> +  __device__ ~ECD() {}// -- allowed
> +};
> +
> +// empty templated constructor -- allowed with no arguments
> +struct ETC {
> +  template  __device__ ETC(T...) {}
> +};
> +
> +// undefined constructor -- not allowed
> +struct UC {
> +  int uc;
> +  __device__ UC();
> +};
> +
> +// undefined destructor -- not allowed
> +struct UD {
> +  int ud;
> +  __device__ ~UD();
> +};
> +
> +// empty constructor w/ initializer list -- not allowed
> +struct ECI {
> +  int eci;
> +  __device__ ECI() : eci(1) {}
> +};
> +
> +// non-empty constructor -- not allowed
> +struct NEC {
> +  int nec;
> +  __device__ NEC() { nec = 1; }
> +};
> +
> +// non-empty destructor -- not allowed
> +struct NED {
> +  int ned;
> +  __device__ ~NED() { ned = 1; }
> +};
> +
> +// no-constructor,  virtual method -- not allowed
> +struct NCV {
> +  int ncv;
> +  __device__ virtual void vm() {}
> +};
> +
> +// virtual destructor -- not allowed.
> +struct VD {
> +  __device__ virtual ~VD() {}
> +};
> +
> +// dynamic in-class field initializer -- not allowed
> +__device__ int f();
> +struct NCF {
> +  int ncf = f();
> +};
> +
> +// static in-class field initializer.  NVCC does not allow it, but
> +// clang generates static initializer for this, so we'll accept it.
> +// We still can't use it on __shared__ vars as they don't allow *any*
> +// initializers.
> +struct NCFS {
> +  int ncfs = 3;
> +};
> +
> +// undefined templated constructor -- not allowed
> +struct UTC {
> +  template  __device__ UTC(T...);
> +};
> +
> +// non-empty templated constructor -- not allowed
> +struct NETC {
> +  int netc;
> +  template  __device__ NETC(T...) { netc = 1; }
> +};
> +
> +// Regular base class -- allowed
> +struct T_B_T : T {};
> +
> +// Incapsulated object of allowed class -- allowed
> +struct T_F_T {
> +  T t;
> +};
> +
> +// array of allowed objects -- allowed
> +struct T_FA_T {
> +  T t[2];
> +};
> +
> +
> +// Calling empty base class initializer is OK
> +struct EC_I_EC : EC {
> +  __device__ EC_I_EC() : EC() {}
> +};
> +
> +// .. though passing arguments is not allowed.
> +struct EC_I_EC1 : EC {
> +  __device__ EC_I_EC1() : EC(1) {}
> +};
> +
> +// Virtual base class -- not allowed
> +struct T_V_T : virtual T {};
> +
> +// Inherited from or incapsulated class with non-empty constructor --
> +// not allowed
> +struct T_B_NEC : NEC {};
> +struct T_F_NEC {
> +  NEC nec;
> +};
> +struct T_FA_NEC {
> +  NEC nec[2];
> +};
> +
> +
> +// Inherited from or incapsulated class with non-empty desstructor --
> +// not allowed
> +struct T_B_NED : NED {};
> +struct T_F_NED {
> +  NED ned;
> +};
> +struct T_FA_NED {
> +  NED ned[2];
> +};
>
> Modified: cfe/trunk/test/CodeGenCUDA/device-var-init.cu
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/device-var-init.cu?rev=270164&r1=270163&r2=270164&view=diff
>
> ==
> --- cfe/trunk/test/CodeGenCUDA/device-var-init.cu (original)
> +++ cfe/trunk/test/CodeGenCUDA/device-var-init.cu Thu May 19 19:38:25 2016
> @@ -10,100 +10,8 @@
>  #i

Re: [clang-tools-extra] r261991 - [clang-tidy] Fix a crash issue when clang-tidy runs with compilation database.

2016-05-20 Thread Tom Stellard via cfe-commits
Hi,

This looks fine to me, go ahead and merge.

-Tom

On Thu, May 19, 2016 at 08:29:14PM +0200, Alexander Kornienko wrote:
> On Thu, May 19, 2016 at 4:45 PM, Hans Wennborg  wrote:
> 
> > +Tom who manages 3.8.1
> > +Alex who's owner of clang-tidy: is this ok for 3.8.1?
> >
> 
> Yes, would be nice to have this in 3.8.1. This fixes a rather annoying
> problem.
> 
> 
> >
> > On Thu, May 19, 2016 at 1:56 AM, Edoardo P. via cfe-commits
> >  wrote:
> > > Is it possible to port this commit to 3.8.1?
> > >
> > > Cheers,
> > > Edward-san
> > >
> > > 2016-02-26 10:19 GMT+01:00 Haojian Wu via cfe-commits
> > > :
> > >> Author: hokein
> > >> Date: Fri Feb 26 03:19:33 2016
> > >> New Revision: 261991
> > >>
> > >> URL: http://llvm.org/viewvc/llvm-project?rev=261991&view=rev
> > >> Log:
> > >> [clang-tidy] Fix a crash issue when clang-tidy runs with compilation
> > database.
> > >>
> > >> Summary:
> > >> The clang-tidy will trigger an assertion if it's not in the building
> > directory.
> > >>
> > >> TEST:
> > >> cd /
> > >> ./build/bin/clang-tidy --checks=-*,modernize-use-nullptr -p build
> > tools/clang/tools/extra/clang-tidy/ClangTidy.cpp
> > >>
> > >> The crash issue is gone after applying this patch.
> > >>
> > >> Fixes PR24834, PR26241
> > >>
> > >> Reviewers: bkramer, alexfh
> > >>
> > >> Subscribers: rizsotto.mailinglist, cfe-commits
> > >>
> > >> Differential Revision: http://reviews.llvm.org/D17335
> > >>
> > >> Added:
> > >> clang-tools-extra/trunk/test/clang-tidy/Inputs/compilation-database/
> > >>
> >  
> > clang-tools-extra/trunk/test/clang-tidy/Inputs/compilation-database/template.json
> > >>
> >  clang-tools-extra/trunk/test/clang-tidy/clang-tidy-run-with-database.cpp
> > >> Modified:
> > >> clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
> > >> clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
> > >> clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
> > >>
> > >> Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
> > >> URL:
> > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=261991&r1=261990&r2=261991&view=diff
> > >>
> > ==
> > >> --- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
> > >> +++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Fri Feb 26
> > 03:19:33 2016
> > >> @@ -107,6 +107,10 @@ public:
> > >>  DiagPrinter->BeginSourceFile(LangOpts);
> > >>}
> > >>
> > >> +  SourceManager& getSourceManager() {
> > >> +return SourceMgr;
> > >> +  }
> > >> +
> > >>void reportDiagnostic(const ClangTidyError &Error) {
> > >>  const ClangTidyMessage &Message = Error.Message;
> > >>  SourceLocation Loc = getLocation(Message.FilePath,
> > Message.FileOffset);
> > >> @@ -124,7 +128,10 @@ public:
> > >>auto Diag = Diags.Report(Loc, Diags.getCustomDiagID(Level, "%0
> > [%1]"))
> > >><< Message.Message << Name;
> > >>for (const tooling::Replacement &Fix : Error.Fix) {
> > >> -SourceLocation FixLoc = getLocation(Fix.getFilePath(),
> > Fix.getOffset());
> > >> +SmallString<128> FixAbsoluteFilePath = Fix.getFilePath();
> > >> +Files.makeAbsolutePath(FixAbsoluteFilePath);
> > >> +SourceLocation FixLoc =
> > >> +getLocation(FixAbsoluteFilePath, Fix.getOffset());
> > >>  SourceLocation FixEndLoc =
> > FixLoc.getLocWithOffset(Fix.getLength());
> > >>  Diag << FixItHint::CreateReplacement(SourceRange(FixLoc,
> > FixEndLoc),
> > >>   Fix.getReplacementText());
> > >> @@ -232,6 +239,13 @@ ClangTidyASTConsumerFactory::CreateASTCo
> > >>Context.setCurrentFile(File);
> > >>Context.setASTContext(&Compiler.getASTContext());
> > >>
> > >> +  auto WorkingDir = Compiler.getSourceManager()
> > >> +.getFileManager()
> > >> +.getVirtualFileSystem()
> > >> +->getCurrentWorkingDirectory();
> > >> +  if (WorkingDir)
> > >> +Context.setCurrentBuildDirectory(WorkingDir.get());
> > >> +
> > >>std::vector> Checks;
> > >>CheckFactories->createChecks(&Context, Checks);
> > >>
> > >> @@ -446,8 +460,24 @@ runClangTidy(std::unique_ptr > >>  void handleErrors(const std::vector &Errors, bool Fix,
> > >>unsigned &WarningsAsErrorsCount) {
> > >>ErrorReporter Reporter(Fix);
> > >> -  for (const ClangTidyError &Error : Errors)
> > >> +  vfs::FileSystem &FileSystem =
> > >> +
> > *Reporter.getSourceManager().getFileManager().getVirtualFileSystem();
> > >> +  auto InitialWorkingDir = FileSystem.getCurrentWorkingDirectory();
> > >> +  if (!InitialWorkingDir)
> > >> +llvm::report_fatal_error("Cannot get current working path.");
> > >> +
> > >> +  for (const ClangTidyError &Error : Errors) {
> > >> +if (!Error.BuildDirectory.empty()) {
> > >> +  // By default, the working directory of 

Re: [PATCH] D19479: 26748 - clang-cl fails to compile atlctrlw.h header from WTL

2016-05-20 Thread Reid Kleckner via cfe-commits
rnk added a comment.

You've described the core issue with parsing C++ templates prior to 
instantiation, you have to know what identifiers are types, and that's why we 
need typename. :) MSVC only parses templates after instantiation, so it doesn't 
need typename.

To deal with the specific case in ATL, we can use the 'new' expression as a 
hint that the unknown identifier is actually a dependent type. There should be 
some bit of context we can look at in DiagnoseUnknownTypeName to know that we 
are in a new expression inside a dependent template, and then form a 
DependentNameType to delay checking until template instantiation.

In the general case, I don't think we can ever behave exactly like MSVC without 
implementing token-based template instantiation, and nobody wants to add an 
entirely new, untested, separate codepath just for MSVC-style template 
instantiation. It means giving up on compiling invalid C++ that MSVC accepts, 
such as this:

  template 
  struct A : T {
void f() {
  g(TypeOrFunction());
}
  };
  // In A, it's a type
  struct B {
struct TypeOrFunction { };
void g(TypeOrFunction);
  };
  template struct A;
  // In A, it's a function
  struct C {
int TypeOrFunction();
void g(int);
  };
  template struct A;


http://reviews.llvm.org/D19479



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


Re: [PATCH] D20468: [X86][AVX] Ensure zero-extension of _mm256_extract_epi8 and _mm256_extract_epi16

2016-05-20 Thread Simon Pilgrim via cfe-commits
RKSimon added a comment.

In http://reviews.llvm.org/D20468#435522, @mkuper wrote:

> Could you point me to where in the documentation it says they must be 
> zero-extended?
>  The Intel intrinsics guide actually has them with shorter return types:
>
>   __int8 _mm256_extract_epi8 (__m256i a, const int index)
>   __int16 _mm256_extract_epi16 (__m256i a, const int index)


And the gcc version has them wrapped to the _mm_extract_epi* intrinsics which 
map to the real 128-bit instructions which do zero-extend.

I'm open to changing the return types in the headers instead, but really I'd 
expect the mm256 versions to zero extend like the older mm versions.


Repository:
  rL LLVM

http://reviews.llvm.org/D20468



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


Re: [PATCH] D20422: [MSVC2015] dllexport for defaulted special class members

2016-05-20 Thread Reid Kleckner via cfe-commits
rnk added inline comments.


Comment at: lib/Sema/SemaDeclCXX.cpp:13111
@@ -13090,3 +13110,3 @@
   llvm_unreachable("Invalid special member.");
 }
   } else {

DmitryPolukhin wrote:
> rnk wrote:
> > Can we add `if (InClassDef) ActOnFinishInlineFunctionDef(MD);` here 
> > instead? If the decl doesn't have dllexport, we will just defer it until 
> > its referenced, which seems OK.
> We can move this check here but condition has to be more complicated because 
> MSVC2015 doesn't export trivial defaulted c-tors even if they were explicitly 
> declared dllexport, see my check on line 4822.
Maybe we should handle that case by silently dropping dllexport on trivial 
defaulted ctors and dtors. Basically I'm trying to keep our dllexport policy 
decisions local to the dll attribute checking code. We should either 
consistently call ActOnFinishInlineFunctionDef for special members that were 
defaulted in the class body, or not do it at all.


http://reviews.llvm.org/D20422



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


Re: [PATCH] D20468: [X86][AVX] Ensure zero-extension of _mm256_extract_epi8 and _mm256_extract_epi16

2016-05-20 Thread Michael Kuperstein via cfe-commits
mkuper added a comment.

You're right, the underlying instructions zext, and it seems like it's the 
right thing to do. I'm just wondering if this is something user code is 
supposed to rely on, given the way the intrinsics guide documents them right 
now.
H.J, could you please take a look?


Repository:
  rL LLVM

http://reviews.llvm.org/D20468



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


Re: [PATCH] D20467: [include-fixer] Mention more details in the document.

2016-05-20 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko added a comment.

Could you please mention include-fixer in  docs/ReleaseNotes.rst? This is 
definitely major new feature in upcoming release.


http://reviews.llvm.org/D20467



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


r270238 - [OpenCL] Allow explicit cast of 0 to event_t.

2016-05-20 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Fri May 20 12:18:16 2016
New Revision: 270238

URL: http://llvm.org/viewvc/llvm-project?rev=270238&view=rev
Log:
[OpenCL] Allow explicit cast of 0 to event_t.

Patch by Aaron Enye Shi.

Differential Revision: http://reviews.llvm.org/D17578

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/test/CodeGenOpenCL/event_t.cl
cfe/trunk/test/SemaOpenCL/event_t.cl

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=270238&r1=270237&r2=270238&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri May 20 12:18:16 
2016
@@ -7821,6 +7821,8 @@ def err_sampler_argument_required : Erro
   "sampler_t variable required - got %0">;
 def err_wrong_sampler_addressspace: Error<
   "sampler type cannot be used with the __local and __global address space 
qualifiers">;
+def error_opencl_cast_non_zero_to_event_t : Error<
+  "cannot cast non-zero value '%0' to 'event_t'">;
 def err_opencl_global_invalid_addr_space : Error<
   "%select{program scope|static local|extern}0 variable must reside in %1 
address space">;
 def err_missing_actual_pipe_type : Error<

Modified: cfe/trunk/lib/Sema/SemaCast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=270238&r1=270237&r2=270238&view=diff
==
--- cfe/trunk/lib/Sema/SemaCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCast.cpp Fri May 20 12:18:16 2016
@@ -2441,6 +2441,22 @@ void CastOperation::CheckCStyleCast() {
   return;
 }
 
+// OpenCL v2.0 s6.13.10 - Allow casts from '0' to event_t type.
+if (Self.getLangOpts().OpenCL && DestType->isEventT()) {
+  llvm::APSInt CastInt;
+  if (SrcExpr.get()->EvaluateAsInt(CastInt, Self.Context)) {
+if (0 == CastInt) {
+  Kind = CK_ZeroToOCLEvent;
+  return;
+}
+Self.Diag(OpRange.getBegin(),
+  diag::error_opencl_cast_non_zero_to_event_t)
+  << CastInt.toString(10) << SrcExpr.get()->getSourceRange();
+SrcExpr = ExprError();
+return;
+  }
+}
+
 // Reject any other conversions to non-scalar types.
 Self.Diag(OpRange.getBegin(), diag::err_typecheck_cond_expect_scalar)
   << DestType << SrcExpr.get()->getSourceRange();

Modified: cfe/trunk/test/CodeGenOpenCL/event_t.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/event_t.cl?rev=270238&r1=270237&r2=270238&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/event_t.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/event_t.cl Fri May 20 12:18:16 2016
@@ -9,4 +9,6 @@ void kernel ker() {
 // CHECK: call {{.*}}void @foo(%opencl.event_t* %
   foo(0);
 // CHECK: call {{.*}}void @foo(%opencl.event_t* null)
+  foo((event_t)0);
+// CHECK: call {{.*}}void @foo(%opencl.event_t* null)
 }

Modified: cfe/trunk/test/SemaOpenCL/event_t.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/event_t.cl?rev=270238&r1=270237&r2=270238&view=diff
==
--- cfe/trunk/test/SemaOpenCL/event_t.cl (original)
+++ cfe/trunk/test/SemaOpenCL/event_t.cl Fri May 20 12:18:16 2016
@@ -14,5 +14,6 @@ void kernel ker(event_t argevt) { // exp
   foo(e);
   foo(0);
   foo(5); // expected-error {{passing 'int' to parameter of incompatible type 
'event_t'}}
+  foo((event_t)1); // expected-error {{cannot cast non-zero value '1' to 
'event_t'}}
 }
 


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


Re: [PATCH] D17578: [OpenCL]Allowing explicit conversion of "0" to event_t type

2016-05-20 Thread Yaxun Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270238: [OpenCL] Allow explicit cast of 0 to event_t. 
(authored by yaxunl).

Changed prior to commit:
  http://reviews.llvm.org/D17578?vs=56615&id=57951#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17578

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaCast.cpp
  cfe/trunk/test/CodeGenOpenCL/event_t.cl
  cfe/trunk/test/SemaOpenCL/event_t.cl

Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7821,6 +7821,8 @@
   "sampler_t variable required - got %0">;
 def err_wrong_sampler_addressspace: Error<
   "sampler type cannot be used with the __local and __global address space 
qualifiers">;
+def error_opencl_cast_non_zero_to_event_t : Error<
+  "cannot cast non-zero value '%0' to 'event_t'">;
 def err_opencl_global_invalid_addr_space : Error<
   "%select{program scope|static local|extern}0 variable must reside in %1 
address space">;
 def err_missing_actual_pipe_type : Error<
Index: cfe/trunk/test/CodeGenOpenCL/event_t.cl
===
--- cfe/trunk/test/CodeGenOpenCL/event_t.cl
+++ cfe/trunk/test/CodeGenOpenCL/event_t.cl
@@ -9,4 +9,6 @@
 // CHECK: call {{.*}}void @foo(%opencl.event_t* %
   foo(0);
 // CHECK: call {{.*}}void @foo(%opencl.event_t* null)
+  foo((event_t)0);
+// CHECK: call {{.*}}void @foo(%opencl.event_t* null)
 }
Index: cfe/trunk/test/SemaOpenCL/event_t.cl
===
--- cfe/trunk/test/SemaOpenCL/event_t.cl
+++ cfe/trunk/test/SemaOpenCL/event_t.cl
@@ -14,5 +14,6 @@
   foo(e);
   foo(0);
   foo(5); // expected-error {{passing 'int' to parameter of incompatible type 
'event_t'}}
+  foo((event_t)1); // expected-error {{cannot cast non-zero value '1' to 
'event_t'}}
 }
 
Index: cfe/trunk/lib/Sema/SemaCast.cpp
===
--- cfe/trunk/lib/Sema/SemaCast.cpp
+++ cfe/trunk/lib/Sema/SemaCast.cpp
@@ -2441,6 +2441,22 @@
   return;
 }
 
+// OpenCL v2.0 s6.13.10 - Allow casts from '0' to event_t type.
+if (Self.getLangOpts().OpenCL && DestType->isEventT()) {
+  llvm::APSInt CastInt;
+  if (SrcExpr.get()->EvaluateAsInt(CastInt, Self.Context)) {
+if (0 == CastInt) {
+  Kind = CK_ZeroToOCLEvent;
+  return;
+}
+Self.Diag(OpRange.getBegin(),
+  diag::error_opencl_cast_non_zero_to_event_t)
+  << CastInt.toString(10) << SrcExpr.get()->getSourceRange();
+SrcExpr = ExprError();
+return;
+  }
+}
+
 // Reject any other conversions to non-scalar types.
 Self.Diag(OpRange.getBegin(), diag::err_typecheck_cond_expect_scalar)
   << DestType << SrcExpr.get()->getSourceRange();


Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7821,6 +7821,8 @@
   "sampler_t variable required - got %0">;
 def err_wrong_sampler_addressspace: Error<
   "sampler type cannot be used with the __local and __global address space qualifiers">;
+def error_opencl_cast_non_zero_to_event_t : Error<
+  "cannot cast non-zero value '%0' to 'event_t'">;
 def err_opencl_global_invalid_addr_space : Error<
   "%select{program scope|static local|extern}0 variable must reside in %1 address space">;
 def err_missing_actual_pipe_type : Error<
Index: cfe/trunk/test/CodeGenOpenCL/event_t.cl
===
--- cfe/trunk/test/CodeGenOpenCL/event_t.cl
+++ cfe/trunk/test/CodeGenOpenCL/event_t.cl
@@ -9,4 +9,6 @@
 // CHECK: call {{.*}}void @foo(%opencl.event_t* %
   foo(0);
 // CHECK: call {{.*}}void @foo(%opencl.event_t* null)
+  foo((event_t)0);
+// CHECK: call {{.*}}void @foo(%opencl.event_t* null)
 }
Index: cfe/trunk/test/SemaOpenCL/event_t.cl
===
--- cfe/trunk/test/SemaOpenCL/event_t.cl
+++ cfe/trunk/test/SemaOpenCL/event_t.cl
@@ -14,5 +14,6 @@
   foo(e);
   foo(0);
   foo(5); // expected-error {{passing 'int' to parameter of incompatible type 'event_t'}}
+  foo((event_t)1); // expected-error {{cannot cast non-zero value '1' to 'event_t'}}
 }
 
Index: cfe/trunk/lib/Sema/SemaCast.cpp
===
--- cfe/trunk/lib/Sema/SemaCast.cpp
+++ cfe/trunk/lib/Sema/SemaCast.cpp
@@ -2441,6 +2441,22 @@
   return;
 }
 
+// OpenCL v2.0 s6.13.10 - Allow casts from '0' to event_t type.
+if (Self.getLangOpts().OpenCL && DestType->isEventT()) {
+  llvm::APSInt CastInt;
+  if (Sr

r270240 - Make __FreeBSD_cc_version predefined macro configurable at build time

2016-05-20 Thread Dimitry Andric via cfe-commits
Author: dim
Date: Fri May 20 12:27:22 2016
New Revision: 270240

URL: http://llvm.org/viewvc/llvm-project?rev=270240&view=rev
Log:
Make __FreeBSD_cc_version predefined macro configurable at build time

The `FreeBSDTargetInfo` class has always set the `__FreeBSD_cc_version`
predefined macro to a rather static value, calculated from the major OS
version.

In the FreeBSD base system, we will start incrementing the value of this
macro whenever we make any signifant change to clang, so we need a way
to configure the macro's value at build time.

Use `FREEBSD_CC_VERSION` for this, which we can define in the FreeBSD
build system using either the `-D` command line option, or an include
file.  Stock builds will keep the earlier value.

Differential Revision: http://reviews.llvm.org/D20037

Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=270240&r1=270239&r2=270240&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri May 20 12:27:22 2016
@@ -308,6 +308,10 @@ public:
   }
 };
 
+#ifndef FREEBSD_CC_VERSION
+#define FREEBSD_CC_VERSION 0U
+#endif
+
 // FreeBSD Target
 template
 class FreeBSDTargetInfo : public OSTargetInfo {
@@ -318,10 +322,13 @@ protected:
 
 unsigned Release = Triple.getOSMajorVersion();
 if (Release == 0U)
-  Release = 8;
+  Release = 8U;
+unsigned CCVersion = FREEBSD_CC_VERSION;
+if (CCVersion == 0U)
+  CCVersion = Release * 10U + 1U;
 
 Builder.defineMacro("__FreeBSD__", Twine(Release));
-Builder.defineMacro("__FreeBSD_cc_version", Twine(Release * 10U + 1U));
+Builder.defineMacro("__FreeBSD_cc_version", Twine(CCVersion));
 Builder.defineMacro("__KPRINTF_ATTRIBUTE__");
 DefineStd(Builder, "unix", Opts);
 Builder.defineMacro("__ELF__");


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


Re: [PATCH] D20037: Make __FreeBSD_cc_version predefined macro configurable at build time

2016-05-20 Thread Dimitry Andric via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270240: Make __FreeBSD_cc_version predefined macro 
configurable at build time (authored by dim).

Changed prior to commit:
  http://reviews.llvm.org/D20037?vs=56476&id=57952#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20037

Files:
  cfe/trunk/lib/Basic/Targets.cpp

Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -308,6 +308,10 @@
   }
 };
 
+#ifndef FREEBSD_CC_VERSION
+#define FREEBSD_CC_VERSION 0U
+#endif
+
 // FreeBSD Target
 template
 class FreeBSDTargetInfo : public OSTargetInfo {
@@ -318,10 +322,13 @@
 
 unsigned Release = Triple.getOSMajorVersion();
 if (Release == 0U)
-  Release = 8;
+  Release = 8U;
+unsigned CCVersion = FREEBSD_CC_VERSION;
+if (CCVersion == 0U)
+  CCVersion = Release * 10U + 1U;
 
 Builder.defineMacro("__FreeBSD__", Twine(Release));
-Builder.defineMacro("__FreeBSD_cc_version", Twine(Release * 10U + 1U));
+Builder.defineMacro("__FreeBSD_cc_version", Twine(CCVersion));
 Builder.defineMacro("__KPRINTF_ATTRIBUTE__");
 DefineStd(Builder, "unix", Opts);
 Builder.defineMacro("__ELF__");


Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -308,6 +308,10 @@
   }
 };
 
+#ifndef FREEBSD_CC_VERSION
+#define FREEBSD_CC_VERSION 0U
+#endif
+
 // FreeBSD Target
 template
 class FreeBSDTargetInfo : public OSTargetInfo {
@@ -318,10 +322,13 @@
 
 unsigned Release = Triple.getOSMajorVersion();
 if (Release == 0U)
-  Release = 8;
+  Release = 8U;
+unsigned CCVersion = FREEBSD_CC_VERSION;
+if (CCVersion == 0U)
+  CCVersion = Release * 10U + 1U;
 
 Builder.defineMacro("__FreeBSD__", Twine(Release));
-Builder.defineMacro("__FreeBSD_cc_version", Twine(Release * 10U + 1U));
+Builder.defineMacro("__FreeBSD_cc_version", Twine(CCVersion));
 Builder.defineMacro("__KPRINTF_ATTRIBUTE__");
 DefineStd(Builder, "unix", Opts);
 Builder.defineMacro("__ELF__");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r270241 - ObjectiveC: canonicalize "kindof id" to "id".

2016-05-20 Thread Manman Ren via cfe-commits
Author: mren
Date: Fri May 20 12:29:43 2016
New Revision: 270241

URL: http://llvm.org/viewvc/llvm-project?rev=270241&view=rev
Log:
ObjectiveC: canonicalize "kindof id" to "id".

There is no need to apply kindof on an unqualified id type.

rdar://24753825

Modified:
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaObjC/kindof.m

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=270241&r1=270240&r2=270241&view=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Fri May 20 12:29:43 2016
@@ -5900,10 +5900,11 @@ bool Sema::checkObjCKindOfType(QualType
 
   // Rebuild the "equivalent" type, which pushes __kindof down into
   // the object type.
-  QualType equivType = Context.getObjCObjectType(objType->getBaseType(),
- 
objType->getTypeArgsAsWritten(),
- objType->getProtocols(),
- /*isKindOf=*/true);
+  // There is no need to apply kindof on an unqualified id type.
+  QualType equivType = Context.getObjCObjectType(
+  objType->getBaseType(), objType->getTypeArgsAsWritten(),
+  objType->getProtocols(),
+  /*isKindOf=*/objType->isObjCUnqualifiedId() ? false : true);
 
   // If we started with an object pointer type, rebuild it.
   if (ptrType) {

Modified: cfe/trunk/test/SemaObjC/kindof.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/kindof.m?rev=270241&r1=270240&r2=270241&view=diff
==
--- cfe/trunk/test/SemaObjC/kindof.m (original)
+++ cfe/trunk/test/SemaObjC/kindof.m Fri May 20 12:29:43 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fblocks -fsyntax-only %s -verify
+// RUN: %clang_cc1 -fblocks -fsyntax-only %s -verify -Wmethod-signatures
 
 // Tests Objective-C 'kindof' types.
 
@@ -374,6 +374,27 @@ void testNullability() {
   processCopyable(0); // expected-warning{{null passed to a callee that 
requires a non-null argument}}
 }
 
+// Make sure that we don't emit a warning about conflicting parameter types
+// between __kindof id and id.
+@interface A2 : NSObject
+- (void)test:(__kindof id)T;
+@end
+@implementation A2
+- (void)test:(id)T {
+}
+@end
+
+@interface NSGeneric : NSObject
+- (void)test:(__kindof ObjectType)T;
+- (void)mapUsingBlock:(id (^)(__kindof ObjectType))block;
+@end
+@implementation NSGeneric
+- (void)test:(id)T {
+}
+- (void)mapUsingBlock:(id (^)(id))block {
+}
+@end
+
 // Check that clang doesn't crash when a type parameter is illegal.
 @interface Array1 : NSObject
 @end


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


Re: [PATCH] D20457: Update -ffast-math documentation to match reality.

2016-05-20 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 57958.
jlebar added a comment.

Update per Richard's review.


http://reviews.llvm.org/D20457

Files:
  docs/UsersManual.rst
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Options.td

Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -592,9 +592,7 @@
 def : Flag<["-"], "fno-extended-identifiers">, Group, 
Flags<[Unsupported]>;
 def fhosted : Flag<["-"], "fhosted">, Group;
 def ffast_math : Flag<["-"], "ffast-math">, Group, Flags<[CC1Option]>,
-  HelpText<"Enable the *frontend*'s 'fast-math' mode. This has no effect on "
-   "optimizations, but provides a preprocessor macro __FAST_MATH__ the 
"
-   "same as GCC's -ffast-math flag">;
+  HelpText<"Allow aggressive, lossy floating-point optimizations">;
 def fno_fast_math : Flag<["-"], "fno-fast-math">, Group;
 def fmath_errno : Flag<["-"], "fmath-errno">, Group, 
Flags<[CC1Option]>,
   HelpText<"Require math functions to indicate errors by setting errno">;
Index: include/clang/Basic/LangOptions.def
===
--- include/clang/Basic/LangOptions.def
+++ include/clang/Basic/LangOptions.def
@@ -162,7 +162,7 @@
 COMPATIBLE_LANGOPT(GNUInline , 1, 0, "GNU inline semantics")
 COMPATIBLE_LANGOPT(NoInlineDefine, 1, 0, "__NO_INLINE__ predefined macro")
 COMPATIBLE_LANGOPT(Deprecated, 1, 0, "__DEPRECATED predefined macro")
-COMPATIBLE_LANGOPT(FastMath  , 1, 0, "__FAST_MATH__ predefined macro")
+COMPATIBLE_LANGOPT(FastMath  , 1, 0, "fast fp math optimizations, and 
__FAST_MATH__ predefined macro")
 COMPATIBLE_LANGOPT(FiniteMathOnly, 1, 0, "__FINITE_MATH_ONLY__ predefined 
macro")
 COMPATIBLE_LANGOPT(UnsafeFPMath  , 1, 0, "Unsafe Floating Point Math")
 
Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -1055,6 +1055,18 @@
the behavior of sanitizers in the ``cfi`` group to allow checking
of cross-DSO virtual and indirect calls.
 
+.. option:: -ffast-math
+
+   Enable fast-math mode. This defines the ``__FAST_MATH__`` preprocessor
+   macro, and lets the compiler make aggressive, potentially-lossy assumptions
+   about floating-point math.  These include:
+
+   * Floating-point math obeys regular algebraic rules for real numbers (e.g.
+ ``+`` and ``*`` are associative, ``x/y == x * (1/y)``, and
+ ``(a + b) * c == a * c + b * c``),
+   * operands to fp operations are not equal to ``NaN`` and ``Inf``, and
+   * ``+0`` and ``-0`` are interchangeable.
+
 .. option:: -fwhole-program-vtables
 
Enable whole-program vtable optimizations, such as single-implementation


Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -592,9 +592,7 @@
 def : Flag<["-"], "fno-extended-identifiers">, Group, Flags<[Unsupported]>;
 def fhosted : Flag<["-"], "fhosted">, Group;
 def ffast_math : Flag<["-"], "ffast-math">, Group, Flags<[CC1Option]>,
-  HelpText<"Enable the *frontend*'s 'fast-math' mode. This has no effect on "
-   "optimizations, but provides a preprocessor macro __FAST_MATH__ the "
-   "same as GCC's -ffast-math flag">;
+  HelpText<"Allow aggressive, lossy floating-point optimizations">;
 def fno_fast_math : Flag<["-"], "fno-fast-math">, Group;
 def fmath_errno : Flag<["-"], "fmath-errno">, Group, Flags<[CC1Option]>,
   HelpText<"Require math functions to indicate errors by setting errno">;
Index: include/clang/Basic/LangOptions.def
===
--- include/clang/Basic/LangOptions.def
+++ include/clang/Basic/LangOptions.def
@@ -162,7 +162,7 @@
 COMPATIBLE_LANGOPT(GNUInline , 1, 0, "GNU inline semantics")
 COMPATIBLE_LANGOPT(NoInlineDefine, 1, 0, "__NO_INLINE__ predefined macro")
 COMPATIBLE_LANGOPT(Deprecated, 1, 0, "__DEPRECATED predefined macro")
-COMPATIBLE_LANGOPT(FastMath  , 1, 0, "__FAST_MATH__ predefined macro")
+COMPATIBLE_LANGOPT(FastMath  , 1, 0, "fast fp math optimizations, and __FAST_MATH__ predefined macro")
 COMPATIBLE_LANGOPT(FiniteMathOnly, 1, 0, "__FINITE_MATH_ONLY__ predefined macro")
 COMPATIBLE_LANGOPT(UnsafeFPMath  , 1, 0, "Unsafe Floating Point Math")
 
Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -1055,6 +1055,18 @@
the behavior of sanitizers in the ``cfi`` group to allow checking
of cross-DSO virtual and indirect calls.
 
+.. option:: -ffast-math
+
+   Enable fast-math mode. This defines the ``__FAST_MATH__`` preprocessor
+   macro, and lets the compiler make aggressive, potentially-lossy assumptions

RE: D20468: [X86][AVX] Ensure zero-extension of _mm256_extract_epi8 and _mm256_extract_epi16

2016-05-20 Thread Romanova, Katya via cfe-commits
Hi Simon,
Thank you for the patch and for fixing the doxygen comments. There is no need 
to update Sony's intrinsics document. Very soon our  documentation team is 
planning to release the documentation based on the doxygen headers in the  
upstream headers, so your change will funnel through automatically.

Thank you !
Katya.

> -Original Message-
> From: Simon Pilgrim [mailto:llvm-...@redking.me.uk]
> Sent: Friday, May 20, 2016 6:17 AM
> To: llvm-...@redking.me.uk; mku...@google.com;
> craig.top...@gmail.com; Romanova, Katya; spa...@rotateright.com
> Cc: cfe-commits@lists.llvm.org
> Subject: [PATCH] D20468: [X86][AVX] Ensure zero-extension of
> _mm256_extract_epi8 and _mm256_extract_epi16
> 
> RKSimon created this revision.
> RKSimon added reviewers: mkuper, craig.topper, kromanova, spatel.
> RKSimon added a subscriber: cfe-commits.
> RKSimon set the repository for this revision to rL LLVM.
> 
> Ensure _mm256_extract_epi8 and _mm256_extract_epi16 zero extend their
> i8/i16 result to i32. This matches _mm_extract_epi8 and _mm_extract_epi16.
> 
> Fix for PR27594
> 
> Katya - I've updated the doxygen comments for _mm256_extract_epi8 and
> _mm256_extract_epi16, I guess this will need to be updated in Sony's
> intrinsics document for the next regeneration?
> 
> Repository:
>   rL LLVM
> 
> http://reviews.llvm.org/D20468
> 
> Files:
>   lib/Headers/avxintrin.h
>   test/CodeGen/avx-builtins.c
> 
> Index: test/CodeGen/avx-builtins.c
> ===
> --- test/CodeGen/avx-builtins.c
> +++ test/CodeGen/avx-builtins.c
> @@ -314,21 +314,19 @@
>return _mm256_dp_ps(A, B, 7);
>  }
> 
> -// FIXME: ZEXT instead of SEXT
>  int test_mm256_extract_epi8(__m256i A) {
>// CHECK-LABEL: test_mm256_extract_epi8
>// CHECK: and i32 %{{.*}}, 31
>// CHECK: extractelement <32 x i8> %{{.*}}, i32 %{{.*}}
> -  // CHECK: ext i8 %{{.*}} to i32
> +  // CHECK: zext i8 %{{.*}} to i32
>return _mm256_extract_epi8(A, 32);
>  }
> 
> -// FIXME: ZEXT instead of SEXT
>  int test_mm256_extract_epi16(__m256i A) {
>// CHECK-LABEL: test_mm256_extract_epi16
>// CHECK: and i32 %{{.*}}, 15
>// CHECK: extractelement <16 x i16> %{{.*}}, i32 %{{.*}}
> -  // CHECK: ext i16 %{{.*}} to i32
> +  // CHECK: zext i16 %{{.*}} to i32
>return _mm256_extract_epi16(A, 16);
>  }
> 
> Index: lib/Headers/avxintrin.h
> ===
> --- lib/Headers/avxintrin.h
> +++ lib/Headers/avxintrin.h
> @@ -1875,13 +1875,13 @@
>  /// \param __imm
>  ///An immediate integer operand with bits [3:0] determining which
> vector
>  ///element is extracted and returned.
> -/// \returns A 32-bit integer containing the extracted 16 bits of extended
> +/// \returns A 32-bit integer containing the extracted 16 bits of zero
> +extended
>  ///packed data.
>  static __inline int __DEFAULT_FN_ATTRS
>  _mm256_extract_epi16(__m256i __a, const int __imm)  {
>__v16hi __b = (__v16hi)__a;
> -  return __b[__imm & 15];
> +  return (unsigned short)__b[__imm & 15];
>  }
> 
>  /// \brief Takes a [32 x i8] vector and returns the vector element value @@
> -1897,13 +1897,13 @@  /// \param __imm
>  ///An immediate integer operand with bits [4:0] determining which
> vector
>  ///element is extracted and returned.
> -/// \returns A 32-bit integer containing the extracted 8 bits of extended
> packed
> -///data.
> +/// \returns A 32-bit integer containing the extracted 8 bits of zero
> extended
> +///packed data.
>  static __inline int __DEFAULT_FN_ATTRS
>  _mm256_extract_epi8(__m256i __a, const int __imm)  {
>__v32qi __b = (__v32qi)__a;
> -  return __b[__imm & 31];
> +  return (unsigned char)__b[__imm & 31];
>  }
> 
>  #ifdef __x86_64__
> 

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


[PATCH] D20481: [CUDA] Define __USE_FAST_MATH__ when __FAST_MATH__ is defined.

2016-05-20 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: rsmith.
jlebar added a subscriber: cfe-commits.

The CUDA headers look for __USE_FAST_MATH__.

http://reviews.llvm.org/D20481

Files:
  lib/Headers/__clang_cuda_runtime_wrapper.h

Index: lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- lib/Headers/__clang_cuda_runtime_wrapper.h
+++ lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -42,6 +42,13 @@
 
 #if defined(__CUDA__) && defined(__clang__)
 
+// The CUDA headers use the __USE_FAST_MATH__ macro to determine whether we get
+// the slow-but-accurate or fast-but-inaccurate versions of functions like sin
+// and exp, but -ffast-math defines only __FAST_MATH__.
+#if defined(__FAST_MATH__) && !defined(__USE_FAST_MATH__)
+#define __USE_FAST_MATH__
+#endif
+
 // Include some forward declares that must come before cmath.
 #include <__clang_cuda_math_forward_declares.h>
 


Index: lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- lib/Headers/__clang_cuda_runtime_wrapper.h
+++ lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -42,6 +42,13 @@
 
 #if defined(__CUDA__) && defined(__clang__)
 
+// The CUDA headers use the __USE_FAST_MATH__ macro to determine whether we get
+// the slow-but-accurate or fast-but-inaccurate versions of functions like sin
+// and exp, but -ffast-math defines only __FAST_MATH__.
+#if defined(__FAST_MATH__) && !defined(__USE_FAST_MATH__)
+#define __USE_FAST_MATH__
+#endif
+
 // Include some forward declares that must come before cmath.
 #include <__clang_cuda_math_forward_declares.h>
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r269670 - [OpenCL] Add supported OpenCL extensions to target info.

2016-05-20 Thread Anastasia Stulova via cfe-commits
Hi Sam,

Has this been addressed?

@Jeroen, as far as I am aware adding supported extensions is completely new to 
Clang and shouldn't be braking any existing functionality that are related to 
that. Could you elaborate on the problem. Would creating new Clang target help? 
Otherwise, do you have any other proposal for the solution?

Thanks,
Anastasia



From: cfe-commits  on behalf of Jeroen 
Ketema via cfe-commits 
Sent: 17 May 2016 12:49
To: Yaxun Liu via cfe-commits
Subject: Re: r269670 - [OpenCL] Add supported OpenCL extensions to target info.

Hi,

The below commit enables all OpenCL extensions for the SPIR target by default. 
This incorrect, as SPIR allows you to specify which extensions are 
enabled/disabled its metadata. This means that any SPIR generated by Clang may 
now be rejected by specific OpenCL platforms, because they might not support 
all extensions.

If possible I would like to see this commit reverted until that problem has 
been addressed.

Regards,

Jeroen

> On 16 May 2016, at 18:06, Yaxun Liu via cfe-commits  lists.llvm.org> wrote:
>
> Author: yaxunl
> Date: Mon May 16 12:06:34 2016
> New Revision: 269670
>
> URL: http://llvm.org/viewvc/llvm-project?rev=269670&view=rev
> Log:
> [OpenCL] Add supported OpenCL extensions to target info.
>
> Add supported OpenCL extensions to target info. It serves as default values 
> to save the users of the burden setting each supported extensions and 
> optional core features in command line.
>
> Re-commit after fixing build error due to missing override attribute.
>
> Differential Revision: http://reviews.llvm.org/D19484
>
> Added:
>   cfe/trunk/include/clang/Basic/OpenCLOptions.h
>   cfe/trunk/test/SemaOpenCL/extensions.cl
> Removed:
>   cfe/trunk/test/SemaOpenCL/extension-fp64-cl1.1.cl
>   cfe/trunk/test/SemaOpenCL/extension-fp64.cl
>   cfe/trunk/test/SemaOpenCL/optional-core-fp64-cl1.2.cl
>   cfe/trunk/test/SemaOpenCL/optional-core-fp64-cl2.0.cl
> Modified:
>   cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
>   cfe/trunk/include/clang/Basic/LangOptions.h
>   cfe/trunk/include/clang/Basic/OpenCLExtensions.def
>   cfe/trunk/include/clang/Basic/TargetInfo.h
>   cfe/trunk/include/clang/Basic/TargetOptions.h
>   cfe/trunk/lib/Basic/Targets.cpp
>   cfe/trunk/lib/Frontend/InitPreprocessor.cpp
>   cfe/trunk/lib/Parse/ParsePragma.cpp
>   cfe/trunk/lib/Sema/Sema.cpp
>   cfe/trunk/test/CodeGenOpenCL/builtins-r600.cl
>   cfe/trunk/test/CodeGenOpenCL/fpmath.cl
>   cfe/trunk/test/CodeGenOpenCL/half.cl
>   cfe/trunk/test/Lexer/opencl-half-literal.cl
>   cfe/trunk/test/Misc/languageOptsOpenCL.cl
>   cfe/trunk/test/PCH/opencl-extensions.cl
>   cfe/trunk/test/Parser/opencl-astype.cl
>   cfe/trunk/test/Parser/opencl-atomics-cl20.cl
>   cfe/trunk/test/Parser/opencl-pragma.cl
>   cfe/trunk/test/Parser/opencl-storage-class.cl
>   cfe/trunk/test/SemaOpenCL/half.cl
>   cfe/trunk/test/SemaOpenCL/invalid-kernel-parameters.cl
>   cfe/trunk/test/SemaOpenCL/invalid-logical-ops-1.2.cl
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=269670&r1=269669&r2=269670&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Mon May 16 12:06:34 
> 2016
> @@ -926,6 +926,10 @@ def warn_pragma_expected_enable_disable
>  "expected 'enable' or 'disable' - ignoring">, InGroup;
> def warn_pragma_unknown_extension : Warning<
>  "unknown OpenCL extension %0 - ignoring">, InGroup;
> +def warn_pragma_unsupported_extension : Warning<
> +  "unsupported OpenCL extension %0 - ignoring">, InGroup;
> +def warn_pragma_extension_is_core : Warning<
> +  "OpenCL extension %0 is core feature or supported optional core feature - 
> ignoring">, InGroup;
>
> // OpenCL errors.
> def err_opencl_taking_function_address_parser : Error<
>
> Modified: cfe/trunk/include/clang/Basic/LangOptions.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=269670&r1=269669&r2=269670&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/LangOptions.h (original)
> +++ cfe/trunk/include/clang/Basic/LangOptions.h Mon May 16 12:06:34 2016
> @@ -160,18 +160,6 @@ public:
>fp_contract(LangOpts.DefaultFPContract) {}
> };
>
> -/// \brief OpenCL volatile options
> -class OpenCLOptions {
> -public:
> -#define OPENCLEXT(nm)  unsigned nm : 1;
> -#include "clang/Basic/OpenCLExtensions.def"
> -
> -  OpenCLOptions() {
> -#define OPENCLEXT(nm)   nm = 0;
> -#include "clang/Basic/OpenCLExtensions.def"
> -  }
> -};
> -
> /// \brief Describes the kind of translation unit being processed.
> enum TranslationUnitKind {
>  /// \brief The translation unit is a complete translation unit.
>
> Modified: cfe/

Re: [PATCH] D18138: Add -fnative-half-arguments-and-returns

2016-05-20 Thread Anastasia Stulova via cfe-commits
Anastasia added a subscriber: Anastasia.
Anastasia added a comment.

Has this commit been merged without being approved by all the reviewers?



Comment at: cfe/trunk/lib/CodeGen/TargetInfo.cpp:5109
@@ -5108,3 +5108,3 @@
   // natively, and does not need to interwork with AAPCS code.
-  if (Ty->isHalfType() && !getContext().getLangOpts().OpenCL) {
+  if (Ty->isHalfType() && 
!getContext().getLangOpts().NativeHalfArgsAndReturns) {
 llvm::Type *ResType = IsEffectivelyAAPCS_VFP ?

Even though this change seems to be fine for OpenCL, I don't understand the 
reason for it entirely.


Repository:
  rL LLVM

http://reviews.llvm.org/D18138



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


RE: r269670 - [OpenCL] Add supported OpenCL extensions to target info.

2016-05-20 Thread Liu, Yaxun (Sam) via cfe-commits
Currently Clang does not emit opencl.used.extensions metadata, so the issue 
mentioned does not exist.

Also extensions supported by a target and extensions used by an OpenCL program 
is different concept.

I'd say Clang currently miss a feature to detect used extensions and emit the 
metadata.

Sam

-Original Message-
From: Anastasia Stulova [mailto:anastasia.stul...@arm.com] 
Sent: Friday, May 20, 2016 3:23 PM
To: Liu, Yaxun (Sam) ; Jeroen Ketema 

Cc: Clang Commits ; nd 
Subject: Re: r269670 - [OpenCL] Add supported OpenCL extensions to target info.

Hi Sam,

Has this been addressed?

@Jeroen, as far as I am aware adding supported extensions is completely new to 
Clang and shouldn't be braking any existing functionality that are related to 
that. Could you elaborate on the problem. Would creating new Clang target help? 
Otherwise, do you have any other proposal for the solution?

Thanks,
Anastasia



From: cfe-commits  on behalf of Jeroen 
Ketema via cfe-commits 
Sent: 17 May 2016 12:49
To: Yaxun Liu via cfe-commits
Subject: Re: r269670 - [OpenCL] Add supported OpenCL extensions to target info.

Hi,

The below commit enables all OpenCL extensions for the SPIR target by default. 
This incorrect, as SPIR allows you to specify which extensions are 
enabled/disabled its metadata. This means that any SPIR generated by Clang may 
now be rejected by specific OpenCL platforms, because they might not support 
all extensions.

If possible I would like to see this commit reverted until that problem has 
been addressed.

Regards,

Jeroen

> On 16 May 2016, at 18:06, Yaxun Liu via cfe-commits  lists.llvm.org> wrote:
>
> Author: yaxunl
> Date: Mon May 16 12:06:34 2016
> New Revision: 269670
>
> URL: http://llvm.org/viewvc/llvm-project?rev=269670&view=rev
> Log:
> [OpenCL] Add supported OpenCL extensions to target info.
>
> Add supported OpenCL extensions to target info. It serves as default values 
> to save the users of the burden setting each supported extensions and 
> optional core features in command line.
>
> Re-commit after fixing build error due to missing override attribute.
>
> Differential Revision: http://reviews.llvm.org/D19484
>
> Added:
>   cfe/trunk/include/clang/Basic/OpenCLOptions.h
>   cfe/trunk/test/SemaOpenCL/extensions.cl
> Removed:
>   cfe/trunk/test/SemaOpenCL/extension-fp64-cl1.1.cl
>   cfe/trunk/test/SemaOpenCL/extension-fp64.cl
>   cfe/trunk/test/SemaOpenCL/optional-core-fp64-cl1.2.cl
>   cfe/trunk/test/SemaOpenCL/optional-core-fp64-cl2.0.cl
> Modified:
>   cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
>   cfe/trunk/include/clang/Basic/LangOptions.h
>   cfe/trunk/include/clang/Basic/OpenCLExtensions.def
>   cfe/trunk/include/clang/Basic/TargetInfo.h
>   cfe/trunk/include/clang/Basic/TargetOptions.h
>   cfe/trunk/lib/Basic/Targets.cpp
>   cfe/trunk/lib/Frontend/InitPreprocessor.cpp
>   cfe/trunk/lib/Parse/ParsePragma.cpp
>   cfe/trunk/lib/Sema/Sema.cpp
>   cfe/trunk/test/CodeGenOpenCL/builtins-r600.cl
>   cfe/trunk/test/CodeGenOpenCL/fpmath.cl
>   cfe/trunk/test/CodeGenOpenCL/half.cl
>   cfe/trunk/test/Lexer/opencl-half-literal.cl
>   cfe/trunk/test/Misc/languageOptsOpenCL.cl
>   cfe/trunk/test/PCH/opencl-extensions.cl
>   cfe/trunk/test/Parser/opencl-astype.cl
>   cfe/trunk/test/Parser/opencl-atomics-cl20.cl
>   cfe/trunk/test/Parser/opencl-pragma.cl
>   cfe/trunk/test/Parser/opencl-storage-class.cl
>   cfe/trunk/test/SemaOpenCL/half.cl
>   cfe/trunk/test/SemaOpenCL/invalid-kernel-parameters.cl
>   cfe/trunk/test/SemaOpenCL/invalid-logical-ops-1.2.cl
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diag
> nosticParseKinds.td?rev=269670&r1=269669&r2=269670&view=diff
> ==
> 
> --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Mon May 16 
> +++ 12:06:34 2016
> @@ -926,6 +926,10 @@ def warn_pragma_expected_enable_disable
>  "expected 'enable' or 'disable' - ignoring">, 
> InGroup; def warn_pragma_unknown_extension : Warning<  
> "unknown OpenCL extension %0 - ignoring">, InGroup;
> +def warn_pragma_unsupported_extension : Warning<
> +  "unsupported OpenCL extension %0 - ignoring">, 
> +InGroup; def warn_pragma_extension_is_core : Warning<
> +  "OpenCL extension %0 is core feature or supported optional core 
> +feature - ignoring">, InGroup;
>
> // OpenCL errors.
> def err_opencl_taking_function_address_parser : Error<
>
> Modified: cfe/trunk/include/clang/Basic/LangOptions.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Lang
> Options.h?rev=269670&r1=269669&r2=269670&view=diff
> ==
> 
> --- cfe/trunk/include/clang/Basic/LangOptions.h (original)
> +++ cfe/trunk/include/clang/Basic/LangOption

Re: [PATCH] D19932: [OpenCL] Add to_{global|local|private} builtin functions.

2016-05-20 Thread Anastasia Stulova via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.

LGTM! Thanks!


http://reviews.llvm.org/D19932



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


RE: r269670 - [OpenCL] Add supported OpenCL extensions to target info.

2016-05-20 Thread Liu, Yaxun (Sam) via cfe-commits
I think this feature can be implemented by keeping a record of enabled OpenCL 
extensions by user's program.

For optional core feature cl_khr_fp64, we just need to detect if double type is 
used by user's program.

Sam

-Original Message-
From: Liu, Yaxun (Sam) 
Sent: Friday, May 20, 2016 3:45 PM
To: 'Anastasia Stulova' ; Jeroen Ketema 

Cc: Clang Commits ; nd 
Subject: RE: r269670 - [OpenCL] Add supported OpenCL extensions to target info.

Currently Clang does not emit opencl.used.extensions metadata, so the issue 
mentioned does not exist.

Also extensions supported by a target and extensions used by an OpenCL program 
is different concept.

I'd say Clang currently miss a feature to detect used extensions and emit the 
metadata.

Sam

-Original Message-
From: Anastasia Stulova [mailto:anastasia.stul...@arm.com]
Sent: Friday, May 20, 2016 3:23 PM
To: Liu, Yaxun (Sam) ; Jeroen Ketema 

Cc: Clang Commits ; nd 
Subject: Re: r269670 - [OpenCL] Add supported OpenCL extensions to target info.

Hi Sam,

Has this been addressed?

@Jeroen, as far as I am aware adding supported extensions is completely new to 
Clang and shouldn't be braking any existing functionality that are related to 
that. Could you elaborate on the problem. Would creating new Clang target help? 
Otherwise, do you have any other proposal for the solution?

Thanks,
Anastasia



From: cfe-commits  on behalf of Jeroen 
Ketema via cfe-commits 
Sent: 17 May 2016 12:49
To: Yaxun Liu via cfe-commits
Subject: Re: r269670 - [OpenCL] Add supported OpenCL extensions to target info.

Hi,

The below commit enables all OpenCL extensions for the SPIR target by default. 
This incorrect, as SPIR allows you to specify which extensions are 
enabled/disabled its metadata. This means that any SPIR generated by Clang may 
now be rejected by specific OpenCL platforms, because they might not support 
all extensions.

If possible I would like to see this commit reverted until that problem has 
been addressed.

Regards,

Jeroen

> On 16 May 2016, at 18:06, Yaxun Liu via cfe-commits  lists.llvm.org> wrote:
>
> Author: yaxunl
> Date: Mon May 16 12:06:34 2016
> New Revision: 269670
>
> URL: http://llvm.org/viewvc/llvm-project?rev=269670&view=rev
> Log:
> [OpenCL] Add supported OpenCL extensions to target info.
>
> Add supported OpenCL extensions to target info. It serves as default values 
> to save the users of the burden setting each supported extensions and 
> optional core features in command line.
>
> Re-commit after fixing build error due to missing override attribute.
>
> Differential Revision: http://reviews.llvm.org/D19484
>
> Added:
>   cfe/trunk/include/clang/Basic/OpenCLOptions.h
>   cfe/trunk/test/SemaOpenCL/extensions.cl
> Removed:
>   cfe/trunk/test/SemaOpenCL/extension-fp64-cl1.1.cl
>   cfe/trunk/test/SemaOpenCL/extension-fp64.cl
>   cfe/trunk/test/SemaOpenCL/optional-core-fp64-cl1.2.cl
>   cfe/trunk/test/SemaOpenCL/optional-core-fp64-cl2.0.cl
> Modified:
>   cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
>   cfe/trunk/include/clang/Basic/LangOptions.h
>   cfe/trunk/include/clang/Basic/OpenCLExtensions.def
>   cfe/trunk/include/clang/Basic/TargetInfo.h
>   cfe/trunk/include/clang/Basic/TargetOptions.h
>   cfe/trunk/lib/Basic/Targets.cpp
>   cfe/trunk/lib/Frontend/InitPreprocessor.cpp
>   cfe/trunk/lib/Parse/ParsePragma.cpp
>   cfe/trunk/lib/Sema/Sema.cpp
>   cfe/trunk/test/CodeGenOpenCL/builtins-r600.cl
>   cfe/trunk/test/CodeGenOpenCL/fpmath.cl
>   cfe/trunk/test/CodeGenOpenCL/half.cl
>   cfe/trunk/test/Lexer/opencl-half-literal.cl
>   cfe/trunk/test/Misc/languageOptsOpenCL.cl
>   cfe/trunk/test/PCH/opencl-extensions.cl
>   cfe/trunk/test/Parser/opencl-astype.cl
>   cfe/trunk/test/Parser/opencl-atomics-cl20.cl
>   cfe/trunk/test/Parser/opencl-pragma.cl
>   cfe/trunk/test/Parser/opencl-storage-class.cl
>   cfe/trunk/test/SemaOpenCL/half.cl
>   cfe/trunk/test/SemaOpenCL/invalid-kernel-parameters.cl
>   cfe/trunk/test/SemaOpenCL/invalid-logical-ops-1.2.cl
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diag
> nosticParseKinds.td?rev=269670&r1=269669&r2=269670&view=diff
> ==
> 
> --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Mon May 16
> +++ 12:06:34 2016
> @@ -926,6 +926,10 @@ def warn_pragma_expected_enable_disable
>  "expected 'enable' or 'disable' - ignoring">, 
> InGroup; def warn_pragma_unknown_extension : Warning< 
> "unknown OpenCL extension %0 - ignoring">, InGroup;
> +def warn_pragma_unsupported_extension : Warning<
> +  "unsupported OpenCL extension %0 - ignoring">, 
> +InGroup; def warn_pragma_extension_is_core : Warning<
> +  "OpenCL extension %0 is core feature or supported optional core 
> +feature - ignoring">, InGroup;
>
> // Open

Re: [PATCH] D19932: [OpenCL] Add to_{global|local|private} builtin functions.

2016-05-20 Thread Yaxun Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270261: [OpenCL] Add to_{global|local|private} builtin 
functions. (authored by yaxunl).

Changed prior to commit:
  http://reviews.llvm.org/D19932?vs=57478&id=57972#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19932

Files:
  cfe/trunk/include/clang/Basic/Builtins.def
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/CodeGenOpenCL/to_addr_builtin.cl
  cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl

Index: cfe/trunk/include/clang/Basic/Builtins.def
===
--- cfe/trunk/include/clang/Basic/Builtins.def
+++ cfe/trunk/include/clang/Basic/Builtins.def
@@ -1305,6 +1305,11 @@
 LANGBUILTIN(get_pipe_num_packets, "Ui.", "tn", OCLC_LANG)
 LANGBUILTIN(get_pipe_max_packets, "Ui.", "tn", OCLC_LANG)
 
+// OpenCL v2.0 s6.13.9 - Address space qualifier functions.
+LANGBUILTIN(to_global, "v*v*", "tn", OCLC_LANG)
+LANGBUILTIN(to_local, "v*v*", "tn", OCLC_LANG)
+LANGBUILTIN(to_private, "v*v*", "tn", OCLC_LANG)
+
 #undef BUILTIN
 #undef LIBBUILTIN
 #undef LANGBUILTIN
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7856,6 +7856,8 @@
 def warn_opencl_attr_deprecated_ignored : Warning <
   "%0 attribute is deprecated and ignored in OpenCL version %1">,
   InGroup;
+def err_opencl_builtin_requires_version : Error<
+  "%0 requires OpenCL version %1%select{| or above}2">;
 
 // OpenCL v2.0 s6.13.6 -- Builtin Pipe Functions
 def err_opencl_builtin_pipe_first_arg : Error<
@@ -7887,6 +7889,11 @@
 def err_opencl_extern_block_declaration : Error<
   "invalid block variable declaration - using 'extern' storage class is disallowed">;
 
+// OpenCL v2.0 s6.13.9 - Address space qualifier functions. 
+def err_opencl_builtin_to_addr_arg_num : Error<
+  "invalid number of arguments to function: %0">;
+def err_opencl_builtin_to_addr_invalid_arg : Error<
+  "invalid argument %0 to function: %1, expecting a generic pointer argument">;
 } // end of sema category
 
 let CategoryName = "OpenMP Issue" in {
Index: cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl
===
--- cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl
+++ cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+// RUN: %clang_cc1 -verify -fsyntax-only -cl-std=CL2.0 %s
+
+void test(void) {
+  global int *glob;
+  local int *loc;
+  constant int *con;
+  typedef constant int const_int_ty;
+  const_int_ty *con_typedef;
+
+  glob = to_global(glob, loc);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}}
+#else
+  // expected-error@-4{{invalid number of arguments to function: 'to_global'}}
+#endif
+
+  int x;
+  glob = to_global(x);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}}
+#else
+  // expected-error@-4{{invalid argument x to function: 'to_global', expecting a generic pointer argument}}
+#endif
+
+  glob = to_global(con);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}}
+#else
+  // expected-error@-4{{invalid argument con to function: 'to_global', expecting a generic pointer argument}}
+#endif
+
+  glob = to_global(con_typedef);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}}
+#else
+  // expected-error@-4{{invalid argument con_typedef to function: 'to_global', expecting a generic pointer argument}}
+#endif
+
+  loc = to_global(glob);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}}
+#else
+  // expected-error@-4{{assigning '__global int *' to '__local int *' changes address space of pointer}}
+#endif
+
+  global char *glob_c = to_global(loc);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}}
+#else
+  // expected-warning@-4{{incompatible pointer types initializing '__global char *' with an expression of type '__global int *'}}
+#endif
+
+}
Index: cfe/trunk/test/CodeGenOpenCL/to_addr_builtin.cl
===
--- cfe/trunk/test/CodeGenOpenCL/to_addr_builtin.cl
+++ cfe/trunk/test/CodeGenOpenCL/to_addr_builtin.cl
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
+
+// CHECK: %[[A:.*]] = type { float, float, float }
+typedef struct {
+  float x,y,z;
+} A;
+typedef private A *PA;
+typedef global A *GA;
+
+

r270261 - [OpenCL] Add to_{global|local|private} builtin functions.

2016-05-20 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Fri May 20 14:54:38 2016
New Revision: 270261

URL: http://llvm.org/viewvc/llvm-project?rev=270261&view=rev
Log:
[OpenCL] Add to_{global|local|private} builtin functions.

OpenCL builtin functions to_{global|local|private} accepts argument of pointer 
type to arbitrary pointee type, and return a pointer to the same pointee type 
in different addr space, i.e.

global gentype *to_global(gentype *p);
It is not desirable to declare it as

global void *to_global(void *);
in opencl header file since it misses diagnostics.

This patch implements these builtin functions as Clang builtin functions. In 
the builtin def file they are defined to have signature void*(void*). When 
handling call expressions, their declarations are re-written to have correct 
parameter type and return type corresponding to the call argument.

In codegen call to addr void *to_addr(void*) is generated with addrcasts or 
bitcasts to facilitate implementation in builtin library.

Differential Revision: http://reviews.llvm.org/D19932

Added:
cfe/trunk/test/CodeGenOpenCL/to_addr_builtin.cl
cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl
Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=270261&r1=270260&r2=270261&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Fri May 20 14:54:38 2016
@@ -1305,6 +1305,11 @@ LANGBUILTIN(work_group_commit_write_pipe
 LANGBUILTIN(get_pipe_num_packets, "Ui.", "tn", OCLC_LANG)
 LANGBUILTIN(get_pipe_max_packets, "Ui.", "tn", OCLC_LANG)
 
+// OpenCL v2.0 s6.13.9 - Address space qualifier functions.
+LANGBUILTIN(to_global, "v*v*", "tn", OCLC_LANG)
+LANGBUILTIN(to_local, "v*v*", "tn", OCLC_LANG)
+LANGBUILTIN(to_private, "v*v*", "tn", OCLC_LANG)
+
 #undef BUILTIN
 #undef LIBBUILTIN
 #undef LANGBUILTIN

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=270261&r1=270260&r2=270261&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri May 20 14:54:38 
2016
@@ -7856,6 +7856,8 @@ def err_opencl_type_can_only_be_used_as_
 def warn_opencl_attr_deprecated_ignored : Warning <
   "%0 attribute is deprecated and ignored in OpenCL version %1">,
   InGroup;
+def err_opencl_builtin_requires_version : Error<
+  "%0 requires OpenCL version %1%select{| or above}2">;
 
 // OpenCL v2.0 s6.13.6 -- Builtin Pipe Functions
 def err_opencl_builtin_pipe_first_arg : Error<
@@ -7887,6 +7889,11 @@ def err_opencl_invalid_block_declaration
 def err_opencl_extern_block_declaration : Error<
   "invalid block variable declaration - using 'extern' storage class is 
disallowed">;
 
+// OpenCL v2.0 s6.13.9 - Address space qualifier functions. 
+def err_opencl_builtin_to_addr_arg_num : Error<
+  "invalid number of arguments to function: %0">;
+def err_opencl_builtin_to_addr_invalid_arg : Error<
+  "invalid argument %0 to function: %1, expecting a generic pointer argument">;
 } // end of sema category
 
 let CategoryName = "OpenMP Issue" in {

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=270261&r1=270260&r2=270261&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri May 20 14:54:38 2016
@@ -2124,6 +2124,29 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name), {Arg0}));
   }
 
+  // OpenCL v2.0 s6.13.9 - Address space qualifier functions.
+  case Builtin::BIto_global:
+  case Builtin::BIto_local:
+  case Builtin::BIto_private: {
+auto Arg0 = EmitScalarExpr(E->getArg(0));
+auto NewArgT = llvm::PointerType::get(Int8Ty,
+  CGM.getContext().getTargetAddressSpace(LangAS::opencl_generic));
+auto NewRetT = llvm::PointerType::get(Int8Ty,
+  CGM.getContext().getTargetAddressSpace(
+E->getType()->getPointeeType().getAddressSpace()));
+auto FTy = llvm::FunctionType::get(NewRetT, {NewArgT}, false);
+llvm::Value *NewArg;
+if (Arg0->getType()->getPointerAddressSpace() !=
+NewArgT->getPointerAddressSpace())
+  NewArg = Builder.CreateAddrSpaceCast(Arg0, NewArgT);
+else
+  NewArg = Builder.CreateBitOrPointerCast(Arg0, NewArgT);
+auto NewCall = Builder.CreateCall(CGM.CreateRuntimeFunction(FTy,
+  E->getDirectCallee()->getName

RE: r269670 - [OpenCL] Add supported OpenCL extensions to target info.

2016-05-20 Thread Anastasia Stulova via cfe-commits
Thanks Sam!

@Jeroen, could you give us more details about your problem.

Anastasia

-Original Message-
From: Liu, Yaxun (Sam) [mailto:yaxun@amd.com] 
Sent: 20 May 2016 20:52
To: Anastasia Stulova; Jeroen Ketema
Cc: Clang Commits; nd
Subject: RE: r269670 - [OpenCL] Add supported OpenCL extensions to target info.

I think this feature can be implemented by keeping a record of enabled OpenCL 
extensions by user's program.

For optional core feature cl_khr_fp64, we just need to detect if double type is 
used by user's program.

Sam

-Original Message-
From: Liu, Yaxun (Sam)
Sent: Friday, May 20, 2016 3:45 PM
To: 'Anastasia Stulova' ; Jeroen Ketema 

Cc: Clang Commits ; nd 
Subject: RE: r269670 - [OpenCL] Add supported OpenCL extensions to target info.

Currently Clang does not emit opencl.used.extensions metadata, so the issue 
mentioned does not exist.

Also extensions supported by a target and extensions used by an OpenCL program 
is different concept.

I'd say Clang currently miss a feature to detect used extensions and emit the 
metadata.

Sam

-Original Message-
From: Anastasia Stulova [mailto:anastasia.stul...@arm.com]
Sent: Friday, May 20, 2016 3:23 PM
To: Liu, Yaxun (Sam) ; Jeroen Ketema 

Cc: Clang Commits ; nd 
Subject: Re: r269670 - [OpenCL] Add supported OpenCL extensions to target info.

Hi Sam,

Has this been addressed?

@Jeroen, as far as I am aware adding supported extensions is completely new to 
Clang and shouldn't be braking any existing functionality that are related to 
that. Could you elaborate on the problem. Would creating new Clang target help? 
Otherwise, do you have any other proposal for the solution?

Thanks,
Anastasia



From: cfe-commits  on behalf of Jeroen 
Ketema via cfe-commits 
Sent: 17 May 2016 12:49
To: Yaxun Liu via cfe-commits
Subject: Re: r269670 - [OpenCL] Add supported OpenCL extensions to target info.

Hi,

The below commit enables all OpenCL extensions for the SPIR target by default. 
This incorrect, as SPIR allows you to specify which extensions are 
enabled/disabled its metadata. This means that any SPIR generated by Clang may 
now be rejected by specific OpenCL platforms, because they might not support 
all extensions.

If possible I would like to see this commit reverted until that problem has 
been addressed.

Regards,

Jeroen

> On 16 May 2016, at 18:06, Yaxun Liu via cfe-commits  lists.llvm.org> wrote:
>
> Author: yaxunl
> Date: Mon May 16 12:06:34 2016
> New Revision: 269670
>
> URL: http://llvm.org/viewvc/llvm-project?rev=269670&view=rev
> Log:
> [OpenCL] Add supported OpenCL extensions to target info.
>
> Add supported OpenCL extensions to target info. It serves as default values 
> to save the users of the burden setting each supported extensions and 
> optional core features in command line.
>
> Re-commit after fixing build error due to missing override attribute.
>
> Differential Revision: http://reviews.llvm.org/D19484
>
> Added:
>   cfe/trunk/include/clang/Basic/OpenCLOptions.h
>   cfe/trunk/test/SemaOpenCL/extensions.cl
> Removed:
>   cfe/trunk/test/SemaOpenCL/extension-fp64-cl1.1.cl
>   cfe/trunk/test/SemaOpenCL/extension-fp64.cl
>   cfe/trunk/test/SemaOpenCL/optional-core-fp64-cl1.2.cl
>   cfe/trunk/test/SemaOpenCL/optional-core-fp64-cl2.0.cl
> Modified:
>   cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
>   cfe/trunk/include/clang/Basic/LangOptions.h
>   cfe/trunk/include/clang/Basic/OpenCLExtensions.def
>   cfe/trunk/include/clang/Basic/TargetInfo.h
>   cfe/trunk/include/clang/Basic/TargetOptions.h
>   cfe/trunk/lib/Basic/Targets.cpp
>   cfe/trunk/lib/Frontend/InitPreprocessor.cpp
>   cfe/trunk/lib/Parse/ParsePragma.cpp
>   cfe/trunk/lib/Sema/Sema.cpp
>   cfe/trunk/test/CodeGenOpenCL/builtins-r600.cl
>   cfe/trunk/test/CodeGenOpenCL/fpmath.cl
>   cfe/trunk/test/CodeGenOpenCL/half.cl
>   cfe/trunk/test/Lexer/opencl-half-literal.cl
>   cfe/trunk/test/Misc/languageOptsOpenCL.cl
>   cfe/trunk/test/PCH/opencl-extensions.cl
>   cfe/trunk/test/Parser/opencl-astype.cl
>   cfe/trunk/test/Parser/opencl-atomics-cl20.cl
>   cfe/trunk/test/Parser/opencl-pragma.cl
>   cfe/trunk/test/Parser/opencl-storage-class.cl
>   cfe/trunk/test/SemaOpenCL/half.cl
>   cfe/trunk/test/SemaOpenCL/invalid-kernel-parameters.cl
>   cfe/trunk/test/SemaOpenCL/invalid-logical-ops-1.2.cl
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diag
> nosticParseKinds.td?rev=269670&r1=269669&r2=269670&view=diff
> ==
> 
> --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Mon May 16
> +++ 12:06:34 2016
> @@ -926,6 +926,10 @@ def warn_pragma_expected_enable_disable
>  "expected 'enable' or 'disable' - ignoring">, 
> InGroup; def warn_pragma_unknown_extension : Warning< 
> "un

Re: [PATCH] D18138: Add -fnative-half-arguments-and-returns

2016-05-20 Thread Pirama Arumuga Nainar via cfe-commits
pirama added inline comments.


Comment at: cfe/trunk/lib/CodeGen/TargetInfo.cpp:5109
@@ -5108,3 +5108,3 @@
   // natively, and does not need to interwork with AAPCS code.
-  if (Ty->isHalfType() && !getContext().getLangOpts().OpenCL) {
+  if (Ty->isHalfType() && 
!getContext().getLangOpts().NativeHalfArgsAndReturns) {
 llvm::Type *ResType = IsEffectivelyAAPCS_VFP ?

Anastasia wrote:
> Even though this change seems to be fine for OpenCL, I don't understand the 
> reason for it entirely.
This commit adds a generic option to skip the promotion of half types to float 
or int32.  RenderScript also handles half natively.  A new option makes this 
skip more general than langugage-specific.


Repository:
  rL LLVM

http://reviews.llvm.org/D18138



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


Re: [PATCH] D20415: Update Clang for D20147 ("DebugInfo: New metadata representation for global variables.")

2016-05-20 Thread Peter Collingbourne via cfe-commits
pcc added inline comments.


Comment at: lib/CodeGen/CGDebugInfo.cpp:3477
@@ -3473,1 +3476,3 @@
+InitExpr =
+DBuilder.createConstantValueExpression(Init.getInt().getExtValue());
   GV.reset(DBuilder.createGlobalVariable(

aprantl wrote:
> Are we regressing floating point constants here?
It looks like we never really supported floating point constants in the DWARF 
output. I can only see support for integer constants:
http://llvm-cs.pcc.me.uk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp#192


http://reviews.llvm.org/D20415



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


Re: [PATCH] D20407: [CodeGen][ObjC] zero-ext an i1 value to i8

2016-05-20 Thread Akira Hatanaka via cfe-commits
ahatanak added a comment.

I've managed to remove _Atomic from the types of the return and parameter of 
getter and setter functions in my new patch.

I'm not sure how I should handle typedefs though. If I had the following 
typedef,

typedef _Atomic(_Bool) AtomicBool,

would it be OK to desugar the typedef and then remove _Atomic? I'm not sure 
this is always correct because dusugaring typedefs will remove the attributes 
attached to them that might be important too.


http://reviews.llvm.org/D20407



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


Re: [PATCH] D20481: [CUDA] Define __USE_FAST_MATH__ when __FAST_MATH__ is defined.

2016-05-20 Thread Justin Lebar via cfe-commits
jlebar abandoned this revision.
jlebar added a comment.

Actually, after talking offline with Chandler, I need something more 
complicated than this.  I will send a new patch.

Sorry for the noise.


http://reviews.llvm.org/D20481



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


Re: [PATCH] D20415: Update Clang for D20147 ("DebugInfo: New metadata representation for global variables.")

2016-05-20 Thread Adrian Prantl via cfe-commits
aprantl added inline comments.


Comment at: lib/CodeGen/CGDebugInfo.cpp:3477
@@ -3473,1 +3476,3 @@
+InitExpr =
+DBuilder.createConstantValueExpression(Init.getInt().getExtValue());
   GV.reset(DBuilder.createGlobalVariable(

pcc wrote:
> aprantl wrote:
> > Are we regressing floating point constants here?
> It looks like we never really supported floating point constants in the DWARF 
> output. I can only see support for integer constants:
> http://llvm-cs.pcc.me.uk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp#192
Looking at http://llvm-cs.pcc.me.uk/test/DebugInfo/X86/float_const.ll we at 
least do to some degree :-)


http://reviews.llvm.org/D20415



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


Re: [PATCH] D20415: Update Clang for D20147 ("DebugInfo: New metadata representation for global variables.")

2016-05-20 Thread Peter Collingbourne via cfe-commits
pcc added inline comments.


Comment at: lib/CodeGen/CGDebugInfo.cpp:3477
@@ -3473,1 +3476,3 @@
+InitExpr =
+DBuilder.createConstantValueExpression(Init.getInt().getExtValue());
   GV.reset(DBuilder.createGlobalVariable(

aprantl wrote:
> pcc wrote:
> > aprantl wrote:
> > > Are we regressing floating point constants here?
> > It looks like we never really supported floating point constants in the 
> > DWARF output. I can only see support for integer constants:
> > http://llvm-cs.pcc.me.uk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp#192
> Looking at http://llvm-cs.pcc.me.uk/test/DebugInfo/X86/float_const.ll we at 
> least do to some degree :-)
That isn't a global variable test case though, is it?


http://reviews.llvm.org/D20415



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


Re: [PATCH] D20407: [CodeGen][ObjC] zero-ext an i1 value to i8

2016-05-20 Thread John McCall via cfe-commits
rjmccall added a comment.

Top-level attributes shouldn't really be affecting the ABI or code-generation 
in any way, so desugaring should be fine.


http://reviews.llvm.org/D20407



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


Re: [PATCH] D20415: Update Clang for D20147 ("DebugInfo: New metadata representation for global variables.")

2016-05-20 Thread Adrian Prantl via cfe-commits
aprantl added inline comments.


Comment at: lib/CodeGen/CGDebugInfo.cpp:3477
@@ -3473,1 +3476,3 @@
+InitExpr =
+DBuilder.createConstantValueExpression(Init.getInt().getExtValue());
   GV.reset(DBuilder.createGlobalVariable(

pcc wrote:
> aprantl wrote:
> > pcc wrote:
> > > aprantl wrote:
> > > > Are we regressing floating point constants here?
> > > It looks like we never really supported floating point constants in the 
> > > DWARF output. I can only see support for integer constants:
> > > http://llvm-cs.pcc.me.uk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp#192
> > Looking at http://llvm-cs.pcc.me.uk/test/DebugInfo/X86/float_const.ll we at 
> > least do to some degree :-)
> That isn't a global variable test case though, is it?
Ah that's right. We didn't support global float constants.


http://reviews.llvm.org/D20415



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


Re: [PATCH] D20113: Fix mangled name of method with ns_consumed parameters.

2016-05-20 Thread John McCall via cfe-commits
rjmccall added a comment.

That looks great, thank you.


http://reviews.llvm.org/D20113



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


[PATCH] D20490: [Parser] Fix a crash on invalid where a delayed TypoExpr was corrected twice

2016-05-20 Thread Erik Pilkington via cfe-commits
erik.pilkington created this revision.
erik.pilkington added a reviewer: rsmith.
erik.pilkington added a subscriber: cfe-commits.

Previously, Clang crashed when parsing a `BinaryOperator` in C with a typo when 
a typo was already found. This is because the parser called `Sema::ActOnBinOp`, 
which corrects the found typo in C mode, then corrects the typo again from the 
parser. During the first correction pass, the `TypoExprState` corresponding to 
the typo was cleared from Sema when it was corrected. During a second pass, an 
assert fails in `Sema::getTypoExprState` because it cannot find the 
`TypoExprState`. The fix is to avoid correcting delayed typos in the parser in 
that case.

This patch looks like it fixes PR26700, PR27231, and PR27038.

On a more general note, the handling of delayed typo expressions is very messy 
right now, some of them are handled in semantic analysis, and some are handled 
in the parser, leading to easy to make responsibility bugs like this one. I 
think I might take a look at moving the correcting to one side or the other in 
a future patch.

http://reviews.llvm.org/D20490

Files:
  lib/Parse/ParseExpr.cpp
  test/Sema/typo-correction.c

Index: test/Sema/typo-correction.c
===
--- test/Sema/typo-correction.c
+++ test/Sema/typo-correction.c
@@ -57,3 +57,11 @@
 }
 
 int d = X ? d : L; // expected-error 2 {{use of undeclared identifier}}
+
+int fn_with_ids() { ID = ID == ID >= ID ; } // expected-error 4 {{use of 
undeclared identifier}}
+
+int fn_with_rs(int r) { r = TYPO + r * TYPO; } // expected-error 2 {{use of 
undeclared identifier}}
+
+void fn_with_unknown(int a, int b) {
+  fn_with_unknown(unknown, unknown | unknown); // expected-error 3 {{use of 
undeclared identifier}}
+}
Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -446,6 +446,10 @@
 
 LHS = Actions.ActOnBinOp(getCurScope(), OpToken.getLocation(),
  OpToken.getKind(), LHS.get(), RHS.get());
+
+// In this case, ActOnBinOp performed the CorrectDelayedTyposInExpr 
check.
+if (!getLangOpts().CPlusPlus)
+  continue;
   } else {
 LHS = Actions.ActOnConditionalOp(OpToken.getLocation(), ColonLoc,
  LHS.get(), TernaryMiddle.get(),


Index: test/Sema/typo-correction.c
===
--- test/Sema/typo-correction.c
+++ test/Sema/typo-correction.c
@@ -57,3 +57,11 @@
 }
 
 int d = X ? d : L; // expected-error 2 {{use of undeclared identifier}}
+
+int fn_with_ids() { ID = ID == ID >= ID ; } // expected-error 4 {{use of undeclared identifier}}
+
+int fn_with_rs(int r) { r = TYPO + r * TYPO; } // expected-error 2 {{use of undeclared identifier}}
+
+void fn_with_unknown(int a, int b) {
+  fn_with_unknown(unknown, unknown | unknown); // expected-error 3 {{use of undeclared identifier}}
+}
Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -446,6 +446,10 @@
 
 LHS = Actions.ActOnBinOp(getCurScope(), OpToken.getLocation(),
  OpToken.getKind(), LHS.get(), RHS.get());
+
+// In this case, ActOnBinOp performed the CorrectDelayedTyposInExpr check.
+if (!getLangOpts().CPlusPlus)
+  continue;
   } else {
 LHS = Actions.ActOnConditionalOp(OpToken.getLocation(), ColonLoc,
  LHS.get(), TernaryMiddle.get(),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20468: [X86][AVX] Ensure zero-extension of _mm256_extract_epi8 and _mm256_extract_epi16

2016-05-20 Thread David Kreitzer via cfe-commits
DavidKreitzer added a subscriber: DavidKreitzer.
DavidKreitzer added a comment.

Hi Michael,

I think the Intel Intrinsics reference and the Intel Compiler are in error and 
that this is the right fix for the LLVM headers. (I'll follow up to get the 
Intel Intrinsics reference & Intel Compiler fixed.)

The _mm256_extract_epiN "convenience" intrinsics were first introduced by gcc 
and used an "int" return type. They were added to the Intel Compiler about 2 
years ago, but for some reason were defined to use the smaller signed types. 
I'm double checking with the developer that added them, but I think it was just 
a mistake.

-Dave


Repository:
  rL LLVM

http://reviews.llvm.org/D20468



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


Re: [PATCH] D20468: [X86][AVX] Ensure zero-extension of _mm256_extract_epi8 and _mm256_extract_epi16

2016-05-20 Thread Michael Kuperstein via cfe-commits
mkuper accepted this revision.
mkuper added a comment.
This revision is now accepted and ready to land.

Thanks, Dave!

In that case, LGTM.


Repository:
  rL LLVM

http://reviews.llvm.org/D20468



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


[PATCH] D20492: Clang support for __is_assignable intrinsic

2016-05-20 Thread Dave Bartolomeo via cfe-commits
DaveBartolomeo created this revision.
DaveBartolomeo added a reviewer: rnk.
DaveBartolomeo added a subscriber: cfe-commits.

MSVC now supports the __is_assignable type trait intrinsic, to enable easier 
and more efficient implementation of the Standard Library's is_assignable 
trait. As of Visual Studio 2015 Update 3, the VC Standard Library 
implementation uses the new intrinsic unconditionally. We had already 
implemented this trait for Clang/C2, so we're upstreaming the change so that 
mainline Clang can handle the new intrinsic as well.

The implementation is pretty straightforward, due to the previously existing 
__is_nothrow_assignable and __is_trivially_assignable. We handle 
__is_assignable via the same code as the other two, except that we skip the 
extra checks for nothrow or triviality.

http://reviews.llvm.org/D20492

Files:
  docs/LanguageExtensions.rst
  include/clang/Basic/TokenKinds.def
  include/clang/Basic/TypeTraits.h
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  test/PCH/cxx-traits.cpp
  test/PCH/cxx-traits.h

Index: test/PCH/cxx-traits.h
===
--- test/PCH/cxx-traits.h
+++ test/PCH/cxx-traits.h
@@ -1,69 +1,70 @@
-// Header for PCH test cxx-traits.cpp
-
-namespace n {
-
-template
-struct __is_pod { // expected-warning {{keyword '__is_pod' will be made available as an identifier for the remainder of the translation unit}}
-  enum { __value };
-};
-
-template
-struct __is_empty { // expected-warning {{keyword '__is_empty' will be made available as an identifier for the remainder of the translation unit}}
-  enum { __value };
-};
-
-template
-struct is_trivially_constructible {
-  static const bool value = __is_trivially_constructible(T, Args...);
-};
-
-struct __is_abstract {};  // expected-warning {{made available}}
-struct __is_arithmetic {};  // expected-warning {{made available}}
-struct __is_array {};  // expected-warning {{made available}}
-struct __is_base_of {};  // expected-warning {{made available}}
-struct __is_class {};  // expected-warning {{made available}}
-struct __is_complete_type {};  // expected-warning {{made available}}
-struct __is_compound {};  // expected-warning {{made available}}
-struct __is_const {};  // expected-warning {{made available}}
-struct __is_constructible {};  // expected-warning {{made available}}
-struct __is_convertible {};  // expected-warning {{made available}}
-struct __is_convertible_to {};  // expected-warning {{made available}}
-struct __is_destructible {};  // expected-warning {{made available}}
-struct __is_enum {};  // expected-warning {{made available}}
-struct __is_floating_point {};  // expected-warning {{made available}}
-struct __is_final {};  // expected-warning {{made available}}
-struct __is_function {};  // expected-warning {{made available}}
-struct __is_fundamental {};  // expected-warning {{made available}}
-struct __is_integral {};  // expected-warning {{made available}}
-struct __is_interface_class {};  // expected-warning {{made available}}
-struct __is_literal {};  // expected-warning {{made available}}
-struct __is_lvalue_expr {};  // expected-warning {{made available}}
-struct __is_lvalue_reference {};  // expected-warning {{made available}}
-struct __is_member_function_pointer {};  // expected-warning {{made available}}
-struct __is_member_object_pointer {};  // expected-warning {{made available}}
-struct __is_member_pointer {};  // expected-warning {{made available}}
-struct __is_nothrow_assignable {};  // expected-warning {{made available}}
-struct __is_nothrow_constructible {};  // expected-warning {{made available}}
-struct __is_nothrow_destructible {};  // expected-warning {{made available}}
-struct __is_object {};  // expected-warning {{made available}}
-struct __is_pointer {};  // expected-warning {{made available}}
-struct __is_polymorphic {};  // expected-warning {{made available}}
-struct __is_reference {};  // expected-warning {{made available}}
-struct __is_rvalue_expr {};  // expected-warning {{made available}}
-struct __is_rvalue_reference {};  // expected-warning {{made available}}
-struct __is_same {};  // expected-warning {{made available}}
-struct __is_scalar {};  // expected-warning {{made available}}
-struct __is_sealed {};  // expected-warning {{made available}}
-struct __is_signed {};  // expected-warning {{made available}}
-struct __is_standard_layout {};  // expected-warning {{made available}}
-struct __is_trivial {};  // expected-warning {{made available}}
-struct __is_trivially_assignable {};  // expected-warning {{made available}}
-struct __is_trivially_constructible {};  // expected-warning {{made available}}
-struct __is_trivially_copyable {};  // expected-warning {{made available}}
-struct __is_union {};  // expected-warning {{made available}}
-struct __is_unsigned {};  // expected-warning {{made available}}
-struct __is_void {};  // expected-warning {{made available}}
-struct __is_volatile {

[PATCH] D20493: [CUDA] Add -fcuda-approx-transcendentals flag.

2016-05-20 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: rnk.
jlebar added subscribers: cfe-commits, tra.

This lets us emit e.g. sin.approx.f32.  See
http://docs.nvidia.com/cuda/parallel-thread-execution/#floating-point-instructions-sin

http://reviews.llvm.org/D20493

Files:
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Options.td
  lib/Driver/ToolChains.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/InitPreprocessor.cpp
  lib/Headers/__clang_cuda_runtime_wrapper.h
  test/Preprocessor/cuda-approx-transcendentals.cu

Index: test/Preprocessor/cuda-approx-transcendentals.cu
===
--- /dev/null
+++ test/Preprocessor/cuda-approx-transcendentals.cu
@@ -0,0 +1,8 @@
+// RUN: %clang --cuda-host-only -nocudainc -target i386-unknown-linux-gnu -x cuda -E -dM -o - /dev/null | FileCheck --check-prefix HOST %s
+// RUN: %clang --cuda-device-only -nocudainc -target i386-unknown-linux-gnu -x cuda -E -dM -o - /dev/null | FileCheck --check-prefix DEVICE-NOFAST %s
+// RUN: %clang -fcuda-approx-transcendentals --cuda-device-only -nocudainc -target i386-unknown-linux-gnu -x cuda -E -dM -o - /dev/null | FileCheck --check-prefix DEVICE-FAST %s
+// RUN: %clang -ffast-math --cuda-device-only -nocudainc -target i386-unknown-linux-gnu -x cuda -E -dM -o - /dev/null | FileCheck --check-prefix DEVICE-FAST %s
+
+// HOST-NOT: __CLANG_CUDA_APPROX_TRANSCENDENTALS__
+// DEVICE-NOFAST-NOT: __CLANG_CUDA_APPROX_TRANSCENDENTALS__
+// DEVICE-FAST: __CLANG_CUDA_APPROX_TRANSCENDENTALS__
Index: lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- lib/Headers/__clang_cuda_runtime_wrapper.h
+++ lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -42,6 +42,14 @@
 
 #if defined(__CUDA__) && defined(__clang__)
 
+// The CUDA headers use the __USE_FAST_MATH__ macro to determine whether we get
+// the slow-but-accurate or fast-but-inaccurate versions of functions like sin
+// and exp.  This is controlled in clang by -fcuda-approx-transcendentals.
+#pragma push_macro("__USE_FAST_MATH__")
+#if defined(__CLANG_CUDA_APPROX_TRANSCENDENTALS__)
+#define __USE_FAST_MATH__
+#endif
+
 // Include some forward declares that must come before cmath.
 #include <__clang_cuda_math_forward_declares.h>
 
@@ -296,6 +304,7 @@
 #include "curand_mtgp32_kernel.h"
 #pragma pop_macro("dim3")
 #pragma pop_macro("uint3")
+#pragma pop_macro("__USE_FAST_MATH__")
 
 #endif // __CUDA__
 #endif // __CLANG_CUDA_RUNTIME_WRAPPER_H__
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -938,6 +938,12 @@
 Builder.defineMacro("__CUDA_ARCH__");
   }
 
+  // We need to communicate this to our CUDA header wrapper, which in turn
+  // informs the proper CUDA headers of this choice.
+  if (LangOpts.CUDADeviceApproxTranscendentals || LangOpts.FastMath) {
+Builder.defineMacro("__CLANG_CUDA_APPROX_TRANSCENDENTALS__");
+  }
+
   // OpenCL definitions.
   if (LangOpts.OpenCL) {
 #define OPENCLEXT(Ext) \
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1616,6 +1616,9 @@
   if (Opts.CUDAIsDevice && Args.hasArg(OPT_fcuda_flush_denormals_to_zero))
 Opts.CUDADeviceFlushDenormalsToZero = 1;
 
+  if (Opts.CUDAIsDevice && Args.hasArg(OPT_fcuda_approx_transcendentals))
+Opts.CUDADeviceApproxTranscendentals = 1;
+
   if (Opts.ObjC1) {
 if (Arg *arg = Args.getLastArg(OPT_fobjc_runtime_EQ)) {
   StringRef value = arg->getValue();
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -4285,6 +4285,10 @@
  options::OPT_fno_cuda_flush_denormals_to_zero, false))
 CC1Args.push_back("-fcuda-flush-denormals-to-zero");
 
+  if (DriverArgs.hasFlag(options::OPT_fcuda_approx_transcendentals,
+ options::OPT_fno_cuda_approx_transcendentals, false))
+CC1Args.push_back("-fcuda-approx-transcendentals");
+
   if (DriverArgs.hasArg(options::OPT_nocudalib))
 return;
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -395,6 +395,9 @@
 def fcuda_flush_denormals_to_zero : Flag<["-"], "fcuda-flush-denormals-to-zero">,
   Flags<[CC1Option]>, HelpText<"Flush denormal floating point values to zero in CUDA device mode.">;
 def fno_cuda_flush_denormals_to_zero : Flag<["-"], "fno-cuda-flush-denormals-to-zero">;
+def fcuda_approx_transcendentals : Flag<["-"], "fcuda-approx-transcendentals">,
+  Flags<[CC1Option]>, HelpText<"Use approximate transcendental functions">;
+def fno_cuda_approx_transcendentals : Flag

Re: [PATCH] D20492: Clang support for __is_assignable intrinsic

2016-05-20 Thread David Majnemer via cfe-commits
majnemer added a subscriber: majnemer.


Comment at: lib/Sema/SemaExprCXX.cpp:4523-4525
@@ -4521,1 +4522,5 @@
 
+if (BTT == BTT_IsAssignable) {
+  return true;
+}
+

I'd remove the braces and sort it above the `BTT_IsNothrowAssignable` case.


http://reviews.llvm.org/D20492



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


Re: [PATCH] D20457: Update -ffast-math documentation to match reality.

2016-05-20 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
This revision is now accepted and ready to land.


Comment at: docs/UsersManual.rst:1067
@@ +1066,3 @@
+ ``(a + b) * c == a * c + b * c``),
+   * operands to fp operations are not equal to ``NaN`` and ``Inf``, and
+   * ``+0`` and ``-0`` are interchangeable.

fp -> floating-point


Comment at: include/clang/Basic/LangOptions.def:165
@@ -164,3 +164,3 @@
 COMPATIBLE_LANGOPT(Deprecated, 1, 0, "__DEPRECATED predefined macro")
-COMPATIBLE_LANGOPT(FastMath  , 1, 0, "__FAST_MATH__ predefined macro")
+COMPATIBLE_LANGOPT(FastMath  , 1, 0, "fast fp math optimizations, and 
__FAST_MATH__ predefined macro")
 COMPATIBLE_LANGOPT(FiniteMathOnly, 1, 0, "__FINITE_MATH_ONLY__ predefined 
macro")

fp -> FP


http://reviews.llvm.org/D20457



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


Re: [PATCH] D20404: [Driver] Fix driver support for color diagnostics

2016-05-20 Thread Bruno Cardoso Lopes via cfe-commits
bruno added reviewers: dexonsmith, silvas.
bruno removed subscribers: silvas, dexonsmith.
bruno updated this revision to Diff 57993.
bruno added a comment.

Great idea Duncan, attached a new patch!


http://reviews.llvm.org/D20404

Files:
  include/clang/Frontend/CompilerInvocation.h
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp

Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -855,8 +855,51 @@
 ModuleFiles.end());
 }
 
+static bool parseShowColorsArgs(const ArgList &Args, bool DefaultColor) {
+  // Color diagnostics default to auto ("on" if terminal supports) in the driver
+  // but default to off in cc1, needing an explicit OPT_fdiagnostics_color.
+  // Support both clang's -f[no-]color-diagnostics and gcc's
+  // -f[no-]diagnostics-colors[=never|always|auto].
+  enum {
+Colors_On,
+Colors_Off,
+Colors_Auto
+  } ShowColors = DefaultColor ? Colors_Auto : Colors_Off;
+  for (Arg *A : Args) {
+const Option &O = A->getOption();
+if (!O.matches(options::OPT_fcolor_diagnostics) &&
+!O.matches(options::OPT_fdiagnostics_color) &&
+!O.matches(options::OPT_fno_color_diagnostics) &&
+!O.matches(options::OPT_fno_diagnostics_color) &&
+!O.matches(options::OPT_fdiagnostics_color_EQ))
+  continue;
+
+if (O.matches(options::OPT_fcolor_diagnostics) ||
+O.matches(options::OPT_fdiagnostics_color)) {
+  ShowColors = Colors_On;
+} else if (O.matches(options::OPT_fno_color_diagnostics) ||
+   O.matches(options::OPT_fno_diagnostics_color)) {
+  ShowColors = Colors_Off;
+} else {
+  assert(O.matches(options::OPT_fdiagnostics_color_EQ));
+  StringRef Value(A->getValue());
+  if (Value == "always")
+ShowColors = Colors_On;
+  else if (Value == "never")
+ShowColors = Colors_Off;
+  else if (Value == "auto")
+ShowColors = Colors_Auto;
+}
+  }
+  if (ShowColors == Colors_On ||
+  (ShowColors == Colors_Auto && llvm::sys::Process::StandardErrHasColors()))
+return true;
+  return false;
+}
+
 bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
-DiagnosticsEngine *Diags) {
+DiagnosticsEngine *Diags,
+bool DefaultDiagColor) {
   using namespace options;
   bool Success = true;
 
@@ -869,7 +912,7 @@
   Opts.Pedantic = Args.hasArg(OPT_pedantic);
   Opts.PedanticErrors = Args.hasArg(OPT_pedantic_errors);
   Opts.ShowCarets = !Args.hasArg(OPT_fno_caret_diagnostics);
-  Opts.ShowColors = Args.hasArg(OPT_fcolor_diagnostics);
+  Opts.ShowColors = parseShowColorsArgs(Args, DefaultDiagColor);
   Opts.ShowColumn = Args.hasFlag(OPT_fshow_column,
  OPT_fno_show_column,
  /*Default=*/true);
@@ -2226,7 +2269,8 @@
   Success &= ParseAnalyzerArgs(*Res.getAnalyzerOpts(), Args, Diags);
   Success &= ParseMigratorArgs(Res.getMigratorOpts(), Args);
   ParseDependencyOutputArgs(Res.getDependencyOutputOpts(), Args);
-  Success &= ParseDiagnosticArgs(Res.getDiagnosticOpts(), Args, &Diags);
+  Success &= ParseDiagnosticArgs(Res.getDiagnosticOpts(), Args, &Diags,
+ false /*DefaultDiagColor*/);
   ParseCommentArgs(LangOpts.CommentOpts, Args);
   ParseFileSystemArgs(Res.getFileSystemOpts(), Args);
   // FIXME: We shouldn't have to pass the DashX option around here
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5529,43 +5529,27 @@
   CmdArgs.push_back("-fno-diagnostics-show-note-include-stack");
   }
 
-  // Color diagnostics are the default, unless the terminal doesn't support
-  // them.
-  // Support both clang's -f[no-]color-diagnostics and gcc's
-  // -f[no-]diagnostics-colors[=never|always|auto].
-  enum { Colors_On, Colors_Off, Colors_Auto } ShowColors = Colors_Auto;
-  for (const auto &Arg : Args) {
-const Option &O = Arg->getOption();
+  // Color diagnostics are parsed by the driver directly from argv
+  // and later re-parsed to construct this job; claim any possible
+  // color diagnostic here to avoid warn_drv_unused_argument and
+  // diagnose bad OPT_fdiagnostics_color_EQ values.
+  for (Arg *A : Args) {
+const Option &O = A->getOption();
 if (!O.matches(options::OPT_fcolor_diagnostics) &&
 !O.matches(options::OPT_fdiagnostics_color) &&
 !O.matches(options::OPT_fno_color_diagnostics) &&
 !O.matches(options::OPT_fno_diagnostics_color) &&
 !O.matches(options::OPT_fdiagnostics_color_EQ))
   continue;
-
-Arg->claim();
-if (O.matches(options::OPT_fcolor_diagnostics) ||
-O.matches(options::OPT_fdiagnostics_color)) {
-  ShowColors = Colors_On;
-   

  1   2   >